foreman-tasks 0.15.1 → 0.15.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/.babelrc +9 -1
  3. data/.eslintrc +6 -0
  4. data/.gitignore +1 -0
  5. data/.rubocop.yml +6 -0
  6. data/.storybook/webpack.config.js +51 -54
  7. data/app/controllers/foreman_tasks/api/tasks_controller.rb +0 -2
  8. data/app/controllers/foreman_tasks/tasks_controller.rb +6 -1
  9. data/app/helpers/foreman_tasks/foreman_tasks_helper.rb +8 -0
  10. data/app/lib/actions/base.rb +7 -0
  11. data/app/lib/actions/helpers/lifecycle_logging.rb +21 -0
  12. data/app/lib/actions/proxy_action.rb +4 -2
  13. data/app/models/foreman_tasks/task.rb +23 -0
  14. data/app/models/foreman_tasks/task/summarizer.rb +96 -6
  15. data/app/models/foreman_tasks/triggering.rb +2 -2
  16. data/app/models/setting/foreman_tasks.rb +8 -1
  17. data/app/services/foreman_tasks/dashboard_table_filter.rb +47 -0
  18. data/app/services/foreman_tasks/troubleshooting_help_generator.rb +92 -0
  19. data/app/services/ui_notifications/tasks.rb +20 -0
  20. data/app/services/ui_notifications/tasks/task_paused_admin.rb +43 -0
  21. data/app/services/ui_notifications/tasks/task_paused_owner.rb +30 -0
  22. data/app/views/foreman_tasks/tasks/_details.html.erb +5 -3
  23. data/app/views/foreman_tasks/tasks/index.html.erb +13 -0
  24. data/config/routes.rb +1 -0
  25. data/db/migrate/20190318153925_add_task_state_updated_at.foreman_tasks.rb +5 -0
  26. data/db/migrate/20190404132157_add_implicit_varchar_uuid_cast.rb +25 -0
  27. data/db/seeds.d/30-notification_blueprints.rb +33 -0
  28. data/foreman-tasks.gemspec +1 -1
  29. data/lib/foreman_tasks/cleaner.rb +5 -4
  30. data/lib/foreman_tasks/engine.rb +1 -1
  31. data/lib/foreman_tasks/test_helpers.rb +10 -0
  32. data/lib/foreman_tasks/version.rb +1 -1
  33. data/package.json +14 -11
  34. data/test/controllers/tasks_controller_test.rb +10 -0
  35. data/test/foreman_tasks_test_helper.rb +4 -0
  36. data/test/support/dummy_dynflow_action.rb +29 -0
  37. data/test/support/history_tasks_builder.rb +42 -0
  38. data/test/unit/actions/action_with_sub_plans_test.rb +4 -1
  39. data/test/unit/actions/bulk_action_test.rb +2 -0
  40. data/test/unit/cleaner_test.rb +15 -0
  41. data/test/unit/dashboard_table_filter_test.rb +65 -0
  42. data/test/unit/summarizer_test.rb +39 -0
  43. data/test/unit/task_test.rb +14 -0
  44. data/test/unit/troubleshooting_help_generator_test.rb +71 -0
  45. data/test/unit/ui_notifications_test.rb +86 -0
  46. data/webpack/ForemanTasks/Components/Chart/Chart.js +128 -0
  47. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/PausedTasksCard/PausedTasksCard.js +20 -0
  48. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/PausedTasksCard/PausedTasksCard.stories.js +51 -0
  49. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/PausedTasksCard/PausedTasksCard.test.js +11 -0
  50. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/PausedTasksCard/__snapshots__/PausedTasksCard.test.js.snap +36 -0
  51. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/RunningTasksCard/RunningTasksCard.js +20 -0
  52. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/RunningTasksCard/RunningTasksCard.stories.js +51 -0
  53. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/RunningTasksCard/RunningTasksCard.test.js +11 -0
  54. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/RunningTasksCard/__snapshots__/RunningTasksCard.test.js.snap +36 -0
  55. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/ScheduledTasksCard/ScheduledTasksCard.js +64 -0
  56. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/ScheduledTasksCard/ScheduledTasksCard.scss +25 -0
  57. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/ScheduledTasksCard/ScheduledTasksCard.stories.js +28 -0
  58. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/ScheduledTasksCard/ScheduledTasksCard.test.js +18 -0
  59. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/ScheduledTasksCard/__snapshots__/ScheduledTasksCard.test.js.snap +94 -0
  60. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.js +89 -0
  61. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.scss +46 -0
  62. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.stories.js +72 -0
  63. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.test.js +48 -0
  64. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCardHelper.js +63 -0
  65. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/__snapshots__/StoppedTasksCard.test.js.snap +973 -0
  66. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutCard/TasksDonutCard.js +96 -0
  67. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutCard/TasksDonutCard.scss +17 -0
  68. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutCard/TasksDonutCard.stories.js +46 -0
  69. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutCard/TasksDonutCard.test.js +43 -0
  70. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutCard/__snapshots__/TasksDonutCard.test.js.snap +183 -0
  71. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutChart/TasksDonutChart.js +166 -0
  72. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutChart/TasksDonutChart.scss +24 -0
  73. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutChart/TasksDonutChart.stories.js +25 -0
  74. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutChart/TasksDonutChart.test.js +40 -0
  75. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutChart/TasksDonutChartConstants.js +13 -0
  76. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutChart/TasksDonutChartHelper.js +94 -0
  77. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutChart/TasksDonutChartHelper.test.js +152 -0
  78. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutChart/__snapshots__/TasksDonutChart.test.js.snap +302 -0
  79. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutChart/__snapshots__/TasksDonutChartHelper.test.js.snap +21 -0
  80. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/TasksCardsGrid.fixtures.js +25 -0
  81. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/TasksCardsGrid.js +72 -0
  82. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/TasksCardsGrid.stories.js +52 -0
  83. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/TasksCardsGrid.test.js +21 -0
  84. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/__snapshots__/TasksCardsGrid.test.js.snap +223 -0
  85. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.js +57 -0
  86. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.scss +26 -0
  87. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.stories.js +22 -0
  88. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.test.js +57 -0
  89. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/__snapshots__/TasksLabelsRow.test.js.snap +47 -0
  90. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js +51 -0
  91. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.stories.js +23 -0
  92. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.test.js +19 -0
  93. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/__snapshots__/TimeDropDown.test.js.snap +85 -0
  94. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/TasksTimeRow.js +33 -0
  95. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/TasksTimeRow.scss +11 -0
  96. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/TasksTimeRow.stories.js +22 -0
  97. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/TasksTimeRow.test.js +15 -0
  98. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/__snapshots__/TasksTimeRow.test.js.snap +41 -0
  99. data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboard.js +77 -0
  100. data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboard.scss +6 -0
  101. data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardActions.js +62 -0
  102. data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardConstants.js +94 -0
  103. data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardHelper.js +78 -0
  104. data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardPropTypes.js +13 -0
  105. data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardReducer.js +50 -0
  106. data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardSelectors.js +44 -0
  107. data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboard.test.js +13 -0
  108. data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboardActions.test.js +37 -0
  109. data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboardHelper.test.js +36 -0
  110. data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboardReducer.test.js +58 -0
  111. data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboardSelectors.test..js +59 -0
  112. data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/__snapshots__/TasksDashboard.test.js.snap +51 -0
  113. data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/__snapshots__/TasksDashboardActions.test.js.snap +61 -0
  114. data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/__snapshots__/TasksDashboardReducer.test.js.snap +280 -0
  115. data/webpack/ForemanTasks/Components/TasksDashboard/index.js +25 -0
  116. data/webpack/ForemanTasks/ForemanTasksReducers.js +10 -0
  117. data/webpack/ForemanTasks/ForemanTasksSelectors.js +1 -0
  118. data/webpack/__mocks__/foremanReact/API.js +7 -0
  119. data/webpack/__mocks__/foremanReact/common/I18n.js +5 -0
  120. data/webpack/__mocks__/foremanReact/common/helpers.js +3 -0
  121. data/webpack/index.js +13 -1
  122. data/webpack/stories/decorators/index.js +1 -0
  123. data/webpack/stories/decorators/withCardsDecorator.js +14 -0
  124. data/webpack/stories/index.js +1 -3
  125. data/webpack/stories/index.scss +6 -0
  126. metadata +101 -8
  127. data/webpack/ForemanTasks/components/Hello/Hello.stories.js +0 -5
  128. data/webpack/ForemanTasks/components/Hello/__tests__/Hello.test.js +0 -11
  129. data/webpack/ForemanTasks/components/Hello/__tests__/__snapshots__/Hello.test.js.snap +0 -7
  130. data/webpack/ForemanTasks/components/Hello/index.js +0 -5
@@ -0,0 +1,64 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Card } from 'patternfly-react';
4
+ import classNames from 'classnames';
5
+ import { noop } from 'foremanReact/common/helpers';
6
+ import { translate as __ } from 'foremanReact/common/I18n';
7
+
8
+ import { TASKS_DASHBOARD_AVAILABLE_QUERY_STATES } from '../../../../TasksDashboardConstants';
9
+ import { queryPropType } from '../../../../TasksDashboardPropTypes';
10
+ import './ScheduledTasksCard.scss';
11
+
12
+ const ScheduledTasksCard = ({
13
+ data,
14
+ className,
15
+ query,
16
+ updateQuery,
17
+ ...props
18
+ }) => {
19
+ const { SCHEDULED } = TASKS_DASHBOARD_AVAILABLE_QUERY_STATES;
20
+ const onClick = () => updateQuery({ state: SCHEDULED });
21
+
22
+ return (
23
+ <Card
24
+ className={classNames(
25
+ 'tasks-donut-card',
26
+ 'scheduled-tasks-card',
27
+ className,
28
+ {
29
+ 'selected-tasks-card': query.state === SCHEDULED,
30
+ }
31
+ )}
32
+ {...props}
33
+ >
34
+ <Card.Title onClick={onClick}>{__('Scheduled')}</Card.Title>
35
+ <Card.Body>
36
+ <div
37
+ className={classNames('scheduled-data', {
38
+ 'not-focused': query.state && query.state !== SCHEDULED,
39
+ })}
40
+ onClick={onClick}
41
+ >
42
+ {data}
43
+ <p>{__('Total')}</p>
44
+ </div>
45
+ </Card.Body>
46
+ </Card>
47
+ );
48
+ };
49
+
50
+ ScheduledTasksCard.propTypes = {
51
+ data: PropTypes.number,
52
+ query: queryPropType,
53
+ className: PropTypes.string,
54
+ updateQuery: PropTypes.func,
55
+ };
56
+
57
+ ScheduledTasksCard.defaultProps = {
58
+ data: 0,
59
+ query: {},
60
+ className: '',
61
+ updateQuery: noop,
62
+ };
63
+
64
+ export default ScheduledTasksCard;
@@ -0,0 +1,25 @@
1
+ .scheduled-tasks-card {
2
+ text-align: center;
3
+ .not-focused {
4
+ opacity: 0.3;
5
+ }
6
+ .scheduled-data {
7
+ padding-right: 15px;
8
+ cursor: pointer;
9
+ font-size: 40px;
10
+ font-weight: 300;
11
+ transition: font-weight 50ms ease-in;
12
+ p {
13
+ font-size: 20px;
14
+ margin: 0;
15
+ }
16
+ * {
17
+ margin: 10px;
18
+ }
19
+
20
+ &:hover {
21
+ transition: font-weight 50ms ease-in;
22
+ font-weight: 600;
23
+ }
24
+ }
25
+ }
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+ import { storiesOf } from '@storybook/react';
3
+ import { withKnobs, number, select } from '@storybook/addon-knobs';
4
+ import { action } from '@storybook/addon-actions';
5
+ import { withCardsDecorator } from '../../../../../../../stories/decorators';
6
+
7
+ import { TASKS_DASHBOARD_AVAILABLE_QUERY_STATES } from '../../../../TasksDashboardConstants';
8
+ import ScheduledTasksCard from './ScheduledTasksCard';
9
+
10
+ storiesOf('TasksDashboard/TasksCardsGrid', module)
11
+ .addDecorator(withKnobs)
12
+ .addDecorator(withCardsDecorator)
13
+ .add('ScheduledTasksCard', () => {
14
+ const selectState = select(
15
+ 'query.state',
16
+ { ...TASKS_DASHBOARD_AVAILABLE_QUERY_STATES, NONE: 'none' },
17
+ 'none'
18
+ );
19
+ return (
20
+ <ScheduledTasksCard
21
+ data={number('data', 1)}
22
+ query={{
23
+ state: selectState,
24
+ }}
25
+ updateQuery={action('updateQuery')}
26
+ />
27
+ );
28
+ });
@@ -0,0 +1,18 @@
1
+ import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
2
+
3
+ import { TASKS_DASHBOARD_AVAILABLE_QUERY_STATES } from '../../../../TasksDashboardConstants';
4
+ import ScheduledTasksCard from './ScheduledTasksCard';
5
+
6
+ const fixtures = {
7
+ 'render with minimal props': {},
8
+ 'render with props': {
9
+ data: 3,
10
+ className: 'some-class',
11
+ },
12
+ 'render selected': {
13
+ query: { state: TASKS_DASHBOARD_AVAILABLE_QUERY_STATES.SCHEDULED },
14
+ },
15
+ };
16
+
17
+ describe('ScheduledTasksCard', () =>
18
+ testComponentSnapshotsWithFixtures(ScheduledTasksCard, fixtures));
@@ -0,0 +1,94 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`ScheduledTasksCard render selected 1`] = `
4
+ <Card
5
+ accented={false}
6
+ aggregated={false}
7
+ aggregatedMini={false}
8
+ cardRef={null}
9
+ className="tasks-donut-card scheduled-tasks-card selected-tasks-card"
10
+ matchHeight={false}
11
+ >
12
+ <CardTitle
13
+ className=""
14
+ onClick={[Function]}
15
+ >
16
+ Scheduled
17
+ </CardTitle>
18
+ <CardBody
19
+ className=""
20
+ >
21
+ <div
22
+ className="scheduled-data"
23
+ onClick={[Function]}
24
+ >
25
+ 0
26
+ <p>
27
+ Total
28
+ </p>
29
+ </div>
30
+ </CardBody>
31
+ </Card>
32
+ `;
33
+
34
+ exports[`ScheduledTasksCard render with minimal props 1`] = `
35
+ <Card
36
+ accented={false}
37
+ aggregated={false}
38
+ aggregatedMini={false}
39
+ cardRef={null}
40
+ className="tasks-donut-card scheduled-tasks-card"
41
+ matchHeight={false}
42
+ >
43
+ <CardTitle
44
+ className=""
45
+ onClick={[Function]}
46
+ >
47
+ Scheduled
48
+ </CardTitle>
49
+ <CardBody
50
+ className=""
51
+ >
52
+ <div
53
+ className="scheduled-data"
54
+ onClick={[Function]}
55
+ >
56
+ 0
57
+ <p>
58
+ Total
59
+ </p>
60
+ </div>
61
+ </CardBody>
62
+ </Card>
63
+ `;
64
+
65
+ exports[`ScheduledTasksCard render with props 1`] = `
66
+ <Card
67
+ accented={false}
68
+ aggregated={false}
69
+ aggregatedMini={false}
70
+ cardRef={null}
71
+ className="tasks-donut-card scheduled-tasks-card some-class"
72
+ matchHeight={false}
73
+ >
74
+ <CardTitle
75
+ className=""
76
+ onClick={[Function]}
77
+ >
78
+ Scheduled
79
+ </CardTitle>
80
+ <CardBody
81
+ className=""
82
+ >
83
+ <div
84
+ className="scheduled-data"
85
+ onClick={[Function]}
86
+ >
87
+ 3
88
+ <p>
89
+ Total
90
+ </p>
91
+ </div>
92
+ </CardBody>
93
+ </Card>
94
+ `;
@@ -0,0 +1,89 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Card } from 'patternfly-react';
4
+ import classNames from 'classnames';
5
+ import { noop } from 'foremanReact/common/helpers';
6
+ import { translate as __ } from 'foremanReact/common/I18n';
7
+
8
+ import { StoppedTable } from './StoppedTasksCardHelper';
9
+ import {
10
+ timePropType,
11
+ queryPropType,
12
+ } from '../../../../TasksDashboardPropTypes';
13
+ import {
14
+ TASKS_DASHBOARD_AVAILABLE_TIMES,
15
+ TASKS_DASHBOARD_AVAILABLE_QUERY_STATES,
16
+ } from '../../../../TasksDashboardConstants';
17
+ import { getQueryValueText } from '../../../../TasksDashboardHelper';
18
+ import './StoppedTasksCard.scss';
19
+
20
+ const StoppedTasksCard = ({
21
+ data,
22
+ query,
23
+ time,
24
+ className,
25
+ updateQuery,
26
+ ...props
27
+ }) => {
28
+ const { STOPPED } = TASKS_DASHBOARD_AVAILABLE_QUERY_STATES;
29
+ return (
30
+ <Card
31
+ className={classNames(
32
+ 'tasks-donut-card',
33
+ 'stopped-tasks-card',
34
+ className,
35
+ {
36
+ 'selected-tasks-card': query.state === STOPPED,
37
+ }
38
+ )}
39
+ {...props}
40
+ >
41
+ <Card.Title onClick={() => updateQuery({ state: STOPPED })}>
42
+ {__('Stopped')}
43
+ </Card.Title>
44
+ <Card.Body>
45
+ <table className="table table-bordered table-striped stopped-table">
46
+ <thead>
47
+ <tr>
48
+ <th />
49
+ <th>{__('Total')}</th>
50
+ <th>{getQueryValueText(time)}</th>
51
+ </tr>
52
+ </thead>
53
+ <tbody>{StoppedTable(data, query, time, updateQuery)}</tbody>
54
+ </table>
55
+ </Card.Body>
56
+ </Card>
57
+ );
58
+ };
59
+
60
+ const resultPropType = PropTypes.shape({
61
+ total: PropTypes.number.isRequired,
62
+ last: PropTypes.number.isRequired,
63
+ });
64
+
65
+ StoppedTasksCard.propTypes = {
66
+ data: PropTypes.shape({
67
+ error: resultPropType.isRequired,
68
+ warning: resultPropType.isRequired,
69
+ success: resultPropType.isRequired,
70
+ }),
71
+ time: timePropType,
72
+ query: queryPropType,
73
+ className: PropTypes.string,
74
+ updateQuery: PropTypes.func,
75
+ };
76
+
77
+ StoppedTasksCard.defaultProps = {
78
+ data: {
79
+ error: { total: 0, last: 0 },
80
+ warning: { total: 0, last: 0 },
81
+ success: { total: 0, last: 0 },
82
+ },
83
+ time: TASKS_DASHBOARD_AVAILABLE_TIMES.H24,
84
+ query: {},
85
+ className: '',
86
+ updateQuery: noop,
87
+ };
88
+
89
+ export default StoppedTasksCard;
@@ -0,0 +1,46 @@
1
+ .stopped-tasks-card {
2
+ .stopped-table {
3
+ width: 100%;
4
+ border: none;
5
+ table-layout: fixed;
6
+
7
+ .not-focused {
8
+ opacity: 0.3;
9
+ }
10
+
11
+ thead {
12
+ background-color: transparent;
13
+ background-image: none;
14
+ tr {
15
+ th {
16
+ font-weight: bold;
17
+ border: none;
18
+ }
19
+ }
20
+ }
21
+
22
+ td,
23
+ th {
24
+ text-align: center;
25
+ padding-left: 5px;
26
+ width: 33%;
27
+
28
+ &:first-child {
29
+ text-align: left;
30
+ }
31
+ }
32
+
33
+ td {
34
+ &.active {
35
+ font-weight: bold;
36
+ }
37
+ }
38
+ .data-col {
39
+ &:hover {
40
+ cursor: pointer;
41
+ border: 1px solid #d1d1d1;
42
+ background-color: #def3fe;
43
+ }
44
+ }
45
+ }
46
+ }
@@ -0,0 +1,72 @@
1
+ import React from 'react';
2
+ import { storiesOf } from '@storybook/react';
3
+ import { withKnobs, number, select } from '@storybook/addon-knobs';
4
+ import { action } from '@storybook/addon-actions';
5
+ import { withCardsDecorator } from '../../../../../../../stories/decorators';
6
+
7
+ import {
8
+ TASKS_DASHBOARD_AVAILABLE_TIMES,
9
+ TASKS_DASHBOARD_AVAILABLE_QUERY_STATES,
10
+ TASKS_DASHBOARD_AVAILABLE_QUERY_RESULTS,
11
+ TASKS_DASHBOARD_AVAILABLE_QUERY_MODES,
12
+ } from '../../../../TasksDashboardConstants';
13
+ import StoppedTasksCard from './StoppedTasksCard';
14
+
15
+ storiesOf('TasksDashboard/TasksCardsGrid', module)
16
+ .addDecorator(withKnobs)
17
+ .addDecorator(withCardsDecorator)
18
+ .add('StoppedTasksCard', () => {
19
+ const selectTime = select(
20
+ 'time',
21
+ TASKS_DASHBOARD_AVAILABLE_TIMES,
22
+ StoppedTasksCard.defaultProps.time
23
+ );
24
+ const selectState = select(
25
+ 'query.state',
26
+ { ...TASKS_DASHBOARD_AVAILABLE_QUERY_STATES, NONE: null },
27
+ TASKS_DASHBOARD_AVAILABLE_QUERY_STATES.STOPPED
28
+ );
29
+ const selectResult = select(
30
+ 'query.result',
31
+ { ...TASKS_DASHBOARD_AVAILABLE_QUERY_RESULTS, NONE: null },
32
+ null
33
+ );
34
+ const selectMode = select(
35
+ 'query.mode',
36
+ { ...TASKS_DASHBOARD_AVAILABLE_QUERY_MODES, NONE: null },
37
+ null
38
+ );
39
+ return (
40
+ <div>
41
+ <link
42
+ rel="stylesheet"
43
+ type="text/css"
44
+ href="https://cdnjs.cloudflare.com/ajax/libs/patternfly/3.24.0/css/patternfly-additions.min.css"
45
+ />
46
+ <StoppedTasksCard
47
+ data={{
48
+ error: {
49
+ total: number('errorTotal', 8),
50
+ last: number('errorLast', 1),
51
+ },
52
+ warning: {
53
+ total: number('warningTotal', 20),
54
+ last: number('warningLast', 2),
55
+ },
56
+ success: {
57
+ total: number('successTotal', 25),
58
+ last: number('successLast', 3),
59
+ },
60
+ }}
61
+ time={selectTime}
62
+ query={{
63
+ state: selectState,
64
+ result: selectResult,
65
+ mode: selectMode,
66
+ time: selectTime,
67
+ }}
68
+ updateQuery={action('updateQuery')}
69
+ />
70
+ </div>
71
+ );
72
+ });