Sha256: 6da8b51ac0b1665b288f58afd168b584c97bad083b5760aecce8ca85203f5cc7

Contents?: true

Size: 1.93 KB

Versions: 25

Compression:

Stored size: 1.93 KB

Contents

import React from 'react';
import { capitalize } from 'lodash';
import classNames from 'classnames';
import { Icon, Button } from 'patternfly-react';
import {
  TASKS_DASHBOARD_AVAILABLE_QUERY_STATES,
  TASKS_DASHBOARD_AVAILABLE_QUERY_MODES,
} from '../../../../TasksDashboardConstants';

const resultIcons = {
  error: <Icon type="pf" name="error-circle-o" />,
  warning: <Icon type="pf" name="warning-triangle-o" />,
  success: <Icon type="pf" name="ok" />,
};

export const StoppedTable = (data, query, time, updateQuery) =>
  Object.entries(data).map(([result, { total, last }]) => {
    const { STOPPED } = TASKS_DASHBOARD_AVAILABLE_QUERY_STATES;
    const { LAST } = TASKS_DASHBOARD_AVAILABLE_QUERY_MODES;
    const { state, mode } = query;

    const active = state === STOPPED && query.result === result;
    const activeTotal = active && mode !== LAST;
    const activeLast = active && mode === LAST && query.time === time;
    const notFocusedTotal =
      state && !(state === STOPPED && !query.result) && !activeTotal;
    const notFocusedLast =
      state && !(state === STOPPED && !query.result) && !activeLast;

    return (
      <tr key={result}>
        <td>
          {resultIcons[result]}
          {capitalize(result)}
        </td>
        <td
          className={classNames('data-col', {
            active: active && mode !== LAST,
            'not-focused': notFocusedTotal,
          })}
          onClick={() => updateQuery({ state: STOPPED, result })}
        >
          <Button bsStyle="link">{total}</Button>
        </td>
        <td
          className={classNames('data-col', {
            active: activeLast,
            'not-focused': notFocusedLast,
          })}
          onClick={() =>
            updateQuery({
              state: STOPPED,
              result,
              mode: LAST,
              time,
            })
          }
        >
          <Button bsStyle="link">{last}</Button>
        </td>
      </tr>
    );
  });

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
foreman-tasks-2.0.3 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCardHelper.js
foreman-tasks-3.0.0 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCardHelper.js
foreman-tasks-2.0.2 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCardHelper.js
foreman-tasks-1.1.3 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCardHelper.js
foreman-tasks-1.1.2 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCardHelper.js
foreman-tasks-2.0.1 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCardHelper.js
foreman-tasks-2.0.0 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCardHelper.js
foreman-tasks-1.2.0 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCardHelper.js
foreman-tasks-1.1.1 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCardHelper.js
foreman-tasks-1.1.0 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCardHelper.js
foreman-tasks-0.17.6 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCardHelper.js
foreman-tasks-1.0.1 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCardHelper.js
foreman-tasks-1.0.0 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCardHelper.js
foreman-tasks-0.17.5 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCardHelper.js
foreman-tasks-0.17.4 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCardHelper.js
foreman-tasks-0.17.3 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCardHelper.js
foreman-tasks-0.17.2 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCardHelper.js
foreman-tasks-0.16.3 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCardHelper.js
foreman-tasks-0.17.1 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCardHelper.js
foreman-tasks-0.15.11 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCardHelper.js