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,26 @@
1
+ @import '~patternfly/dist/sass/patternfly/_color-variables.scss';
2
+
3
+ .tasks-labels-row {
4
+ margin: 0;
5
+ padding: 0 10px;
6
+ .title {
7
+ font-weight: 600;
8
+ font-size: 13px;
9
+ }
10
+ .label {
11
+ font-size: 100%;
12
+
13
+ margin-left: 5px;
14
+ margin-right: 5px;
15
+ a {
16
+ padding-left: 10px;
17
+ }
18
+ }
19
+ .pficon-close {
20
+ color: $color-pf-white;
21
+ }
22
+ .compound-label-pf {
23
+ margin-left: 0;
24
+ margin: 10px;
25
+ }
26
+ }
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import { storiesOf } from '@storybook/react';
3
+ import { withKnobs, object } from '@storybook/addon-knobs';
4
+ import { action } from '@storybook/addon-actions';
5
+ import { Grid } from 'patternfly-react';
6
+
7
+ import { TASKS_DASHBOARD_AVAILABLE_TIMES } from '../../TasksDashboardConstants';
8
+ import TasksLabelsRow from './TasksLabelsRow';
9
+
10
+ storiesOf('TasksDashboard/TasksLabelsRow', module)
11
+ .addDecorator(withKnobs)
12
+ .addDecorator(storyFn => <Grid style={{ padding: 40 }}>{storyFn()}</Grid>)
13
+ .add('TasksLabelsRow', () => (
14
+ <TasksLabelsRow
15
+ query={object('query', {
16
+ state: 'running',
17
+ mode: 'last',
18
+ time: TASKS_DASHBOARD_AVAILABLE_TIMES.H24,
19
+ })}
20
+ deleteQueryKey={action('deleteQueryKey')}
21
+ />
22
+ ));
@@ -0,0 +1,57 @@
1
+ import React from 'react';
2
+ import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
3
+ import { shallow } from 'enzyme';
4
+
5
+ import { getQueryKeyText, getQueryValueText } from '../../TasksDashboardHelper';
6
+ import TasksLabelsRow from './TasksLabelsRow';
7
+
8
+ jest.mock('../../TasksDashboardHelper');
9
+
10
+ getQueryKeyText.mockImplementation(val => val);
11
+ getQueryValueText.mockImplementation(val => val);
12
+
13
+ const fixtures = {
14
+ 'render with minimal props': {},
15
+ 'render with props': {
16
+ query: { some: 'query' },
17
+ updateQuery: jest.fn(),
18
+ },
19
+ };
20
+
21
+ describe('TasksLabelsRow', () => {
22
+ describe('rendering', () =>
23
+ testComponentSnapshotsWithFixtures(TasksLabelsRow, fixtures));
24
+
25
+ describe('triggering', () => {
26
+ it('should trigger updateQuery when label delete-click', () => {
27
+ const updateQuery = jest.fn();
28
+ const query = { some: 'query', someOther: 'some-query' };
29
+
30
+ const component = shallow(
31
+ <TasksLabelsRow query={query} updateQuery={updateQuery} />
32
+ );
33
+ const labels = component.find('Label');
34
+
35
+ const firstLabel = labels.first();
36
+ const secondLabel = labels.at(1);
37
+
38
+ firstLabel.simulate('removeClick');
39
+ expect(updateQuery).toHaveBeenCalledWith({ someOther: 'some-query' });
40
+
41
+ secondLabel.simulate('removeClick');
42
+ expect(updateQuery).toHaveBeenCalledWith({ some: 'query' });
43
+ });
44
+
45
+ it('should trigger updateQuery when -clear-all- click', () => {
46
+ const updateQuery = jest.fn();
47
+ const query = { some: 'query', someOther: 'some-query' };
48
+
49
+ const component = shallow(
50
+ <TasksLabelsRow query={query} updateQuery={updateQuery} />
51
+ );
52
+ component.find('Button').simulate('click');
53
+
54
+ expect(updateQuery).toHaveBeenCalledWith({});
55
+ });
56
+ });
57
+ });
@@ -0,0 +1,47 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`TasksLabelsRow rendering render with minimal props 1`] = `
4
+ <Row
5
+ bsClass="row"
6
+ className="tasks-labels-row"
7
+ componentClass="div"
8
+ >
9
+ <span
10
+ className="title"
11
+ >
12
+ Active Filters:
13
+ </span>
14
+ </Row>
15
+ `;
16
+
17
+ exports[`TasksLabelsRow rendering render with props 1`] = `
18
+ <Row
19
+ bsClass="row"
20
+ className="tasks-labels-row"
21
+ componentClass="div"
22
+ >
23
+ <span
24
+ className="title"
25
+ >
26
+ Active Filters:
27
+ </span>
28
+ <Label
29
+ bsStyle="info"
30
+ key="some"
31
+ onRemoveClick={[Function]}
32
+ type="default"
33
+ >
34
+ some = query
35
+ </Label>
36
+ <Button
37
+ active={false}
38
+ block={false}
39
+ bsClass="btn"
40
+ bsStyle="link"
41
+ disabled={false}
42
+ onClick={[Function]}
43
+ >
44
+ Clear All Filters
45
+ </Button>
46
+ </Row>
47
+ `;
@@ -0,0 +1,51 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { DropdownButton, MenuItem } from 'patternfly-react';
4
+ import { noop } from 'foremanReact/common/helpers';
5
+
6
+ import { TASKS_DASHBOARD_AVAILABLE_TIMES } from '../../../../TasksDashboardConstants';
7
+ import { getQueryValueText } from '../../../../TasksDashboardHelper';
8
+
9
+ const TimeDropDown = ({ id, className, selectedTime, onChange, ...props }) => {
10
+ const availableTimes = Object.keys(TASKS_DASHBOARD_AVAILABLE_TIMES).map(
11
+ key => ({
12
+ key,
13
+ text: getQueryValueText(key),
14
+ active: key === selectedTime,
15
+ })
16
+ );
17
+
18
+ return (
19
+ <DropdownButton
20
+ id={id}
21
+ className={className}
22
+ title={getQueryValueText(selectedTime)}
23
+ {...props}
24
+ >
25
+ {availableTimes.map(({ key, text, active }) => (
26
+ <MenuItem
27
+ key={key}
28
+ active={active}
29
+ onClick={() => active || onChange(key)}
30
+ >
31
+ {text}
32
+ </MenuItem>
33
+ ))}
34
+ </DropdownButton>
35
+ );
36
+ };
37
+
38
+ TimeDropDown.propTypes = {
39
+ id: PropTypes.string.isRequired,
40
+ className: PropTypes.string,
41
+ selectedTime: PropTypes.oneOf(Object.keys(TASKS_DASHBOARD_AVAILABLE_TIMES)),
42
+ onChange: PropTypes.func,
43
+ };
44
+
45
+ TimeDropDown.defaultProps = {
46
+ className: '',
47
+ selectedTime: TASKS_DASHBOARD_AVAILABLE_TIMES.H24,
48
+ onChange: noop,
49
+ };
50
+
51
+ export default TimeDropDown;
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import { storiesOf } from '@storybook/react';
3
+ import { withKnobs, select } from '@storybook/addon-knobs';
4
+ import { action } from '@storybook/addon-actions';
5
+ import { withCardsDecorator } from '../../../../../../../stories/decorators';
6
+
7
+ import { TASKS_DASHBOARD_AVAILABLE_TIMES } from '../../../../TasksDashboardConstants';
8
+ import TimeDropDown from './TimeDropDown';
9
+
10
+ storiesOf('TasksDashboard/TasksTimeRow', module)
11
+ .addDecorator(withKnobs)
12
+ .addDecorator(withCardsDecorator)
13
+ .add('TimeDropDown', () => (
14
+ <TimeDropDown
15
+ id="time-period-dropdown"
16
+ selectedTime={select(
17
+ 'selectedTime',
18
+ TASKS_DASHBOARD_AVAILABLE_TIMES,
19
+ TASKS_DASHBOARD_AVAILABLE_TIMES.H24
20
+ )}
21
+ onChange={action('onChange')}
22
+ />
23
+ ));
@@ -0,0 +1,19 @@
1
+ import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
2
+
3
+ import { TASKS_DASHBOARD_AVAILABLE_TIMES } from '../../../../TasksDashboardConstants';
4
+ import TimeDropDown from './TimeDropDown';
5
+
6
+ const createRequiredProps = () => ({ id: 'some-id' });
7
+
8
+ const fixtures = {
9
+ 'render with minimal props': { ...createRequiredProps() },
10
+ 'render with all props': {
11
+ ...createRequiredProps(),
12
+ className: 'some-class',
13
+ selectedTime: TASKS_DASHBOARD_AVAILABLE_TIMES.WEEK,
14
+ onChange: jest.fn(),
15
+ },
16
+ };
17
+
18
+ describe('TimeDropDown', () =>
19
+ testComponentSnapshotsWithFixtures(TimeDropDown, fixtures));
@@ -0,0 +1,85 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`TimeDropDown render with all props 1`] = `
4
+ <DropdownButton
5
+ className="some-class"
6
+ id="some-id"
7
+ title="week"
8
+ >
9
+ <MenuItem
10
+ active={false}
11
+ bsClass="dropdown"
12
+ disabled={false}
13
+ divider={false}
14
+ header={false}
15
+ key="H24"
16
+ onClick={[Function]}
17
+ >
18
+ 24h
19
+ </MenuItem>
20
+ <MenuItem
21
+ active={false}
22
+ bsClass="dropdown"
23
+ disabled={false}
24
+ divider={false}
25
+ header={false}
26
+ key="H12"
27
+ onClick={[Function]}
28
+ >
29
+ 12h
30
+ </MenuItem>
31
+ <MenuItem
32
+ active={true}
33
+ bsClass="dropdown"
34
+ disabled={false}
35
+ divider={false}
36
+ header={false}
37
+ key="WEEK"
38
+ onClick={[Function]}
39
+ >
40
+ week
41
+ </MenuItem>
42
+ </DropdownButton>
43
+ `;
44
+
45
+ exports[`TimeDropDown render with minimal props 1`] = `
46
+ <DropdownButton
47
+ className=""
48
+ id="some-id"
49
+ title="24h"
50
+ >
51
+ <MenuItem
52
+ active={true}
53
+ bsClass="dropdown"
54
+ disabled={false}
55
+ divider={false}
56
+ header={false}
57
+ key="H24"
58
+ onClick={[Function]}
59
+ >
60
+ 24h
61
+ </MenuItem>
62
+ <MenuItem
63
+ active={false}
64
+ bsClass="dropdown"
65
+ disabled={false}
66
+ divider={false}
67
+ header={false}
68
+ key="H12"
69
+ onClick={[Function]}
70
+ >
71
+ 12h
72
+ </MenuItem>
73
+ <MenuItem
74
+ active={false}
75
+ bsClass="dropdown"
76
+ disabled={false}
77
+ divider={false}
78
+ header={false}
79
+ key="WEEK"
80
+ onClick={[Function]}
81
+ >
82
+ week
83
+ </MenuItem>
84
+ </DropdownButton>
85
+ `;
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Row } from 'patternfly-react';
4
+ import { noop } from 'foremanReact/common/helpers';
5
+ import { translate as __ } from 'foremanReact/common/I18n';
6
+
7
+ import { timePropType } from '../../TasksDashboardPropTypes';
8
+ import { TASKS_DASHBOARD_AVAILABLE_TIMES } from '../../TasksDashboardConstants';
9
+ import TimeDropDown from './Components/TimeDropDown/TimeDropDown';
10
+ import './TasksTimeRow.scss';
11
+
12
+ const TasksTimeRow = ({ time, updateTime }) => (
13
+ <Row className="tasks-time-row">
14
+ <span className="time-label">{__('With focus on last')}</span>
15
+ <TimeDropDown
16
+ id="tasks-dashboard-time-period-dropdown"
17
+ selectedTime={time}
18
+ onChange={updateTime}
19
+ />
20
+ </Row>
21
+ );
22
+
23
+ TasksTimeRow.propTypes = {
24
+ time: timePropType,
25
+ updateTime: PropTypes.func,
26
+ };
27
+
28
+ TasksTimeRow.defaultProps = {
29
+ time: TASKS_DASHBOARD_AVAILABLE_TIMES.H24,
30
+ updateTime: noop,
31
+ };
32
+
33
+ export default TasksTimeRow;
@@ -0,0 +1,11 @@
1
+ .tasks-time-row {
2
+ margin: 0;
3
+ padding: 0 10px;
4
+
5
+ .time-label {
6
+ font-size: 130%;
7
+ font-weight: bold;
8
+ margin-right: 10px;
9
+ vertical-align: middle;
10
+ }
11
+ }
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import { storiesOf } from '@storybook/react';
3
+ import { withKnobs, select } from '@storybook/addon-knobs';
4
+ import { action } from '@storybook/addon-actions';
5
+ import { withCardsDecorator } from '../../../../../stories/decorators';
6
+
7
+ import { TASKS_DASHBOARD_AVAILABLE_TIMES } from '../../TasksDashboardConstants';
8
+ import TasksTimeRow from './TasksTimeRow';
9
+
10
+ storiesOf('TasksDashboard/TasksTimeRow', module)
11
+ .addDecorator(withKnobs)
12
+ .addDecorator(withCardsDecorator)
13
+ .add('TasksTimeRow', () => (
14
+ <TasksTimeRow
15
+ time={select(
16
+ 'time',
17
+ TASKS_DASHBOARD_AVAILABLE_TIMES,
18
+ TASKS_DASHBOARD_AVAILABLE_TIMES.H24
19
+ )}
20
+ updateTime={action('updateTime')}
21
+ />
22
+ ));
@@ -0,0 +1,15 @@
1
+ import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
2
+
3
+ import { TASKS_DASHBOARD_AVAILABLE_TIMES } from '../../TasksDashboardConstants';
4
+ import TasksTimeRow from './TasksTimeRow';
5
+
6
+ const fixtures = {
7
+ 'render with minimal props': {},
8
+ 'render with props': {
9
+ time: TASKS_DASHBOARD_AVAILABLE_TIMES.WEEK,
10
+ updateTime: jest.fn(),
11
+ },
12
+ };
13
+
14
+ describe('TasksTimeRow', () =>
15
+ testComponentSnapshotsWithFixtures(TasksTimeRow, fixtures));
@@ -0,0 +1,41 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`TasksTimeRow render with minimal props 1`] = `
4
+ <Row
5
+ bsClass="row"
6
+ className="tasks-time-row"
7
+ componentClass="div"
8
+ >
9
+ <span
10
+ className="time-label"
11
+ >
12
+ With focus on last
13
+ </span>
14
+ <TimeDropDown
15
+ className=""
16
+ id="tasks-dashboard-time-period-dropdown"
17
+ onChange={[Function]}
18
+ selectedTime="H24"
19
+ />
20
+ </Row>
21
+ `;
22
+
23
+ exports[`TasksTimeRow render with props 1`] = `
24
+ <Row
25
+ bsClass="row"
26
+ className="tasks-time-row"
27
+ componentClass="div"
28
+ >
29
+ <span
30
+ className="time-label"
31
+ >
32
+ With focus on last
33
+ </span>
34
+ <TimeDropDown
35
+ className=""
36
+ id="tasks-dashboard-time-period-dropdown"
37
+ onChange={[MockFunction]}
38
+ selectedTime="WEEK"
39
+ />
40
+ </Row>
41
+ `;