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.
- checksums.yaml +4 -4
- data/.babelrc +9 -1
- data/.eslintrc +6 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +6 -0
- data/.storybook/webpack.config.js +51 -54
- data/app/controllers/foreman_tasks/api/tasks_controller.rb +0 -2
- data/app/controllers/foreman_tasks/tasks_controller.rb +6 -1
- data/app/helpers/foreman_tasks/foreman_tasks_helper.rb +8 -0
- data/app/lib/actions/base.rb +7 -0
- data/app/lib/actions/helpers/lifecycle_logging.rb +21 -0
- data/app/lib/actions/proxy_action.rb +4 -2
- data/app/models/foreman_tasks/task.rb +23 -0
- data/app/models/foreman_tasks/task/summarizer.rb +96 -6
- data/app/models/foreman_tasks/triggering.rb +2 -2
- data/app/models/setting/foreman_tasks.rb +8 -1
- data/app/services/foreman_tasks/dashboard_table_filter.rb +47 -0
- data/app/services/foreman_tasks/troubleshooting_help_generator.rb +92 -0
- data/app/services/ui_notifications/tasks.rb +20 -0
- data/app/services/ui_notifications/tasks/task_paused_admin.rb +43 -0
- data/app/services/ui_notifications/tasks/task_paused_owner.rb +30 -0
- data/app/views/foreman_tasks/tasks/_details.html.erb +5 -3
- data/app/views/foreman_tasks/tasks/index.html.erb +13 -0
- data/config/routes.rb +1 -0
- data/db/migrate/20190318153925_add_task_state_updated_at.foreman_tasks.rb +5 -0
- data/db/migrate/20190404132157_add_implicit_varchar_uuid_cast.rb +25 -0
- data/db/seeds.d/30-notification_blueprints.rb +33 -0
- data/foreman-tasks.gemspec +1 -1
- data/lib/foreman_tasks/cleaner.rb +5 -4
- data/lib/foreman_tasks/engine.rb +1 -1
- data/lib/foreman_tasks/test_helpers.rb +10 -0
- data/lib/foreman_tasks/version.rb +1 -1
- data/package.json +14 -11
- data/test/controllers/tasks_controller_test.rb +10 -0
- data/test/foreman_tasks_test_helper.rb +4 -0
- data/test/support/dummy_dynflow_action.rb +29 -0
- data/test/support/history_tasks_builder.rb +42 -0
- data/test/unit/actions/action_with_sub_plans_test.rb +4 -1
- data/test/unit/actions/bulk_action_test.rb +2 -0
- data/test/unit/cleaner_test.rb +15 -0
- data/test/unit/dashboard_table_filter_test.rb +65 -0
- data/test/unit/summarizer_test.rb +39 -0
- data/test/unit/task_test.rb +14 -0
- data/test/unit/troubleshooting_help_generator_test.rb +71 -0
- data/test/unit/ui_notifications_test.rb +86 -0
- data/webpack/ForemanTasks/Components/Chart/Chart.js +128 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/PausedTasksCard/PausedTasksCard.js +20 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/PausedTasksCard/PausedTasksCard.stories.js +51 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/PausedTasksCard/PausedTasksCard.test.js +11 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/PausedTasksCard/__snapshots__/PausedTasksCard.test.js.snap +36 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/RunningTasksCard/RunningTasksCard.js +20 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/RunningTasksCard/RunningTasksCard.stories.js +51 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/RunningTasksCard/RunningTasksCard.test.js +11 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/RunningTasksCard/__snapshots__/RunningTasksCard.test.js.snap +36 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/ScheduledTasksCard/ScheduledTasksCard.js +64 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/ScheduledTasksCard/ScheduledTasksCard.scss +25 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/ScheduledTasksCard/ScheduledTasksCard.stories.js +28 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/ScheduledTasksCard/ScheduledTasksCard.test.js +18 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/ScheduledTasksCard/__snapshots__/ScheduledTasksCard.test.js.snap +94 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.js +89 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.scss +46 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.stories.js +72 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.test.js +48 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCardHelper.js +63 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/__snapshots__/StoppedTasksCard.test.js.snap +973 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutCard/TasksDonutCard.js +96 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutCard/TasksDonutCard.scss +17 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutCard/TasksDonutCard.stories.js +46 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutCard/TasksDonutCard.test.js +43 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutCard/__snapshots__/TasksDonutCard.test.js.snap +183 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutChart/TasksDonutChart.js +166 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutChart/TasksDonutChart.scss +24 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutChart/TasksDonutChart.stories.js +25 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutChart/TasksDonutChart.test.js +40 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutChart/TasksDonutChartConstants.js +13 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutChart/TasksDonutChartHelper.js +94 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutChart/TasksDonutChartHelper.test.js +152 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutChart/__snapshots__/TasksDonutChart.test.js.snap +302 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutChart/__snapshots__/TasksDonutChartHelper.test.js.snap +21 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/TasksCardsGrid.fixtures.js +25 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/TasksCardsGrid.js +72 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/TasksCardsGrid.stories.js +52 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/TasksCardsGrid.test.js +21 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/__snapshots__/TasksCardsGrid.test.js.snap +223 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.js +57 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.scss +26 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.stories.js +22 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.test.js +57 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/__snapshots__/TasksLabelsRow.test.js.snap +47 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js +51 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.stories.js +23 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.test.js +19 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/__snapshots__/TimeDropDown.test.js.snap +85 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/TasksTimeRow.js +33 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/TasksTimeRow.scss +11 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/TasksTimeRow.stories.js +22 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/TasksTimeRow.test.js +15 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/__snapshots__/TasksTimeRow.test.js.snap +41 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboard.js +77 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboard.scss +6 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardActions.js +62 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardConstants.js +94 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardHelper.js +78 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardPropTypes.js +13 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardReducer.js +50 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardSelectors.js +44 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboard.test.js +13 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboardActions.test.js +37 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboardHelper.test.js +36 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboardReducer.test.js +58 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboardSelectors.test..js +59 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/__snapshots__/TasksDashboard.test.js.snap +51 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/__snapshots__/TasksDashboardActions.test.js.snap +61 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/__snapshots__/TasksDashboardReducer.test.js.snap +280 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/index.js +25 -0
- data/webpack/ForemanTasks/ForemanTasksReducers.js +10 -0
- data/webpack/ForemanTasks/ForemanTasksSelectors.js +1 -0
- data/webpack/__mocks__/foremanReact/API.js +7 -0
- data/webpack/__mocks__/foremanReact/common/I18n.js +5 -0
- data/webpack/__mocks__/foremanReact/common/helpers.js +3 -0
- data/webpack/index.js +13 -1
- data/webpack/stories/decorators/index.js +1 -0
- data/webpack/stories/decorators/withCardsDecorator.js +14 -0
- data/webpack/stories/index.js +1 -3
- data/webpack/stories/index.scss +6 -0
- metadata +101 -8
- data/webpack/ForemanTasks/components/Hello/Hello.stories.js +0 -5
- data/webpack/ForemanTasks/components/Hello/__tests__/Hello.test.js +0 -11
- data/webpack/ForemanTasks/components/Hello/__tests__/__snapshots__/Hello.test.js.snap +0 -7
- data/webpack/ForemanTasks/components/Hello/index.js +0 -5
@@ -0,0 +1,21 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`TasksDonutChartHelper should create chart-data 1`] = `
|
4
|
+
Object {
|
5
|
+
"columns": Array [
|
6
|
+
Array [
|
7
|
+
"last",
|
8
|
+
1,
|
9
|
+
],
|
10
|
+
Array [
|
11
|
+
"older",
|
12
|
+
3,
|
13
|
+
],
|
14
|
+
],
|
15
|
+
"names": Object {
|
16
|
+
"last": "1 Last 24h",
|
17
|
+
"older": "3 Older 24h",
|
18
|
+
},
|
19
|
+
"onItemClick": [Function],
|
20
|
+
}
|
21
|
+
`;
|
@@ -0,0 +1,25 @@
|
|
1
|
+
export const MOCKED_DATA = {
|
2
|
+
running: {
|
3
|
+
last: 3,
|
4
|
+
older: 5,
|
5
|
+
},
|
6
|
+
paused: {
|
7
|
+
last: 3,
|
8
|
+
older: 5,
|
9
|
+
},
|
10
|
+
stopped: {
|
11
|
+
error: {
|
12
|
+
total: 8,
|
13
|
+
last: 1,
|
14
|
+
},
|
15
|
+
warning: {
|
16
|
+
total: 20,
|
17
|
+
last: 2,
|
18
|
+
},
|
19
|
+
success: {
|
20
|
+
total: 25,
|
21
|
+
last: 3,
|
22
|
+
},
|
23
|
+
},
|
24
|
+
scheduled: 1,
|
25
|
+
};
|
data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/TasksCardsGrid.js
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import { CardGrid } from 'patternfly-react';
|
4
|
+
import { noop } from 'foremanReact/common/helpers';
|
5
|
+
|
6
|
+
import RunningTasksCard from './Components/RunningTasksCard/RunningTasksCard';
|
7
|
+
import PausedTasksCard from './Components/PausedTasksCard/PausedTasksCard';
|
8
|
+
import StoppedTasksCard from './Components/StoppedTasksCard/StoppedTasksCard';
|
9
|
+
import ScheduledTasksCard from './Components/ScheduledTasksCard/ScheduledTasksCard';
|
10
|
+
|
11
|
+
import {
|
12
|
+
TASKS_DASHBOARD_AVAILABLE_TIMES,
|
13
|
+
TASKS_DASHBOARD_AVAILABLE_QUERY_STATES,
|
14
|
+
} from '../../TasksDashboardConstants';
|
15
|
+
import { timePropType, queryPropType } from '../../TasksDashboardPropTypes';
|
16
|
+
|
17
|
+
const TasksCardsGrid = ({ time, query, data, updateQuery }) => (
|
18
|
+
<CardGrid matchHeight fluid>
|
19
|
+
<CardGrid.Row>
|
20
|
+
{[
|
21
|
+
[TASKS_DASHBOARD_AVAILABLE_QUERY_STATES.RUNNING, RunningTasksCard],
|
22
|
+
[TASKS_DASHBOARD_AVAILABLE_QUERY_STATES.PAUSED, PausedTasksCard],
|
23
|
+
[TASKS_DASHBOARD_AVAILABLE_QUERY_STATES.STOPPED, StoppedTasksCard],
|
24
|
+
[TASKS_DASHBOARD_AVAILABLE_QUERY_STATES.SCHEDULED, ScheduledTasksCard],
|
25
|
+
].map(([key, Card]) => (
|
26
|
+
<CardGrid.Col sm={6} lg={3} key={key}>
|
27
|
+
<Card
|
28
|
+
matchHeight
|
29
|
+
data={data[key]}
|
30
|
+
query={query}
|
31
|
+
time={time}
|
32
|
+
updateQuery={updateQuery}
|
33
|
+
/>
|
34
|
+
</CardGrid.Col>
|
35
|
+
))}
|
36
|
+
</CardGrid.Row>
|
37
|
+
</CardGrid>
|
38
|
+
);
|
39
|
+
|
40
|
+
TasksCardsGrid.propTypes = {
|
41
|
+
time: timePropType,
|
42
|
+
query: queryPropType,
|
43
|
+
data: PropTypes.shape({
|
44
|
+
[TASKS_DASHBOARD_AVAILABLE_QUERY_STATES.RUNNING]:
|
45
|
+
RunningTasksCard.propTypes.data,
|
46
|
+
[TASKS_DASHBOARD_AVAILABLE_QUERY_STATES.PAUSED]:
|
47
|
+
PausedTasksCard.propTypes.data,
|
48
|
+
[TASKS_DASHBOARD_AVAILABLE_QUERY_STATES.STOPPED]:
|
49
|
+
StoppedTasksCard.propTypes.data,
|
50
|
+
[TASKS_DASHBOARD_AVAILABLE_QUERY_STATES.SCHEDULED]:
|
51
|
+
ScheduledTasksCard.propTypes.data,
|
52
|
+
}),
|
53
|
+
updateQuery: PropTypes.func,
|
54
|
+
};
|
55
|
+
|
56
|
+
TasksCardsGrid.defaultProps = {
|
57
|
+
time: TASKS_DASHBOARD_AVAILABLE_TIMES.H24,
|
58
|
+
query: {},
|
59
|
+
data: {
|
60
|
+
[TASKS_DASHBOARD_AVAILABLE_QUERY_STATES.RUNNING]:
|
61
|
+
RunningTasksCard.defaultProps.data,
|
62
|
+
[TASKS_DASHBOARD_AVAILABLE_QUERY_STATES.PAUSED]:
|
63
|
+
PausedTasksCard.defaultProps.data,
|
64
|
+
[TASKS_DASHBOARD_AVAILABLE_QUERY_STATES.STOPPED]:
|
65
|
+
StoppedTasksCard.defaultProps.data,
|
66
|
+
[TASKS_DASHBOARD_AVAILABLE_QUERY_STATES.SCHEDULED]:
|
67
|
+
ScheduledTasksCard.defaultProps.data,
|
68
|
+
},
|
69
|
+
updateQuery: noop,
|
70
|
+
};
|
71
|
+
|
72
|
+
export default TasksCardsGrid;
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { storiesOf } from '@storybook/react';
|
3
|
+
import { withKnobs, object, select } from '@storybook/addon-knobs';
|
4
|
+
import { action } from '@storybook/addon-actions';
|
5
|
+
|
6
|
+
import {
|
7
|
+
TASKS_DASHBOARD_AVAILABLE_TIMES,
|
8
|
+
TASKS_DASHBOARD_AVAILABLE_QUERY_STATES,
|
9
|
+
TASKS_DASHBOARD_AVAILABLE_QUERY_RESULTS,
|
10
|
+
TASKS_DASHBOARD_AVAILABLE_QUERY_MODES,
|
11
|
+
} from '../../TasksDashboardConstants';
|
12
|
+
import { MOCKED_DATA } from './TasksCardsGrid.fixtures';
|
13
|
+
import TasksCardsGrid from './TasksCardsGrid';
|
14
|
+
|
15
|
+
const createSelect = (name, options) =>
|
16
|
+
select(name, { ...options, NONE: 'none' }, 'none');
|
17
|
+
|
18
|
+
storiesOf('TasksDashboard/TasksCardsGrid', module)
|
19
|
+
.addDecorator(withKnobs)
|
20
|
+
.add('TasksCardsGrid', () => {
|
21
|
+
const selectTime = select(
|
22
|
+
'time',
|
23
|
+
TASKS_DASHBOARD_AVAILABLE_TIMES,
|
24
|
+
TasksCardsGrid.defaultProps.time
|
25
|
+
);
|
26
|
+
const selectState = createSelect(
|
27
|
+
'query.state',
|
28
|
+
TASKS_DASHBOARD_AVAILABLE_QUERY_STATES
|
29
|
+
);
|
30
|
+
const selectResult = createSelect(
|
31
|
+
'query.result',
|
32
|
+
TASKS_DASHBOARD_AVAILABLE_QUERY_RESULTS
|
33
|
+
);
|
34
|
+
const selectMode = createSelect(
|
35
|
+
'query.mode',
|
36
|
+
TASKS_DASHBOARD_AVAILABLE_QUERY_MODES
|
37
|
+
);
|
38
|
+
|
39
|
+
return (
|
40
|
+
<TasksCardsGrid
|
41
|
+
time={selectTime}
|
42
|
+
query={{
|
43
|
+
state: selectState,
|
44
|
+
result: selectResult,
|
45
|
+
mode: selectMode,
|
46
|
+
time: selectTime,
|
47
|
+
}}
|
48
|
+
data={object('data', MOCKED_DATA)}
|
49
|
+
updateQuery={action('updateQuery')}
|
50
|
+
/>
|
51
|
+
);
|
52
|
+
});
|
data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/TasksCardsGrid.test.js
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
|
2
|
+
|
3
|
+
import {
|
4
|
+
TASKS_DASHBOARD_AVAILABLE_TIMES,
|
5
|
+
TASKS_DASHBOARD_AVAILABLE_QUERY_STATES,
|
6
|
+
} from '../../TasksDashboardConstants';
|
7
|
+
import { MOCKED_DATA } from './TasksCardsGrid.fixtures';
|
8
|
+
import TasksCardsGrid from './TasksCardsGrid';
|
9
|
+
|
10
|
+
const fixtures = {
|
11
|
+
'render with minimal props': {},
|
12
|
+
'render with props': {
|
13
|
+
time: TASKS_DASHBOARD_AVAILABLE_TIMES.WEEK,
|
14
|
+
query: { state: TASKS_DASHBOARD_AVAILABLE_QUERY_STATES.RUNNING },
|
15
|
+
data: MOCKED_DATA,
|
16
|
+
updateQuery: jest.fn(),
|
17
|
+
},
|
18
|
+
};
|
19
|
+
|
20
|
+
describe('TasksCardsGrid', () =>
|
21
|
+
testComponentSnapshotsWithFixtures(TasksCardsGrid, fixtures));
|
@@ -0,0 +1,223 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`TasksCardsGrid render with minimal props 1`] = `
|
4
|
+
<CardGrid
|
5
|
+
className=""
|
6
|
+
fluid={true}
|
7
|
+
matchHeight={true}
|
8
|
+
>
|
9
|
+
<Row
|
10
|
+
bsClass="row"
|
11
|
+
componentClass="div"
|
12
|
+
>
|
13
|
+
<Col
|
14
|
+
bsClass="col"
|
15
|
+
componentClass="div"
|
16
|
+
key="running"
|
17
|
+
lg={3}
|
18
|
+
sm={6}
|
19
|
+
>
|
20
|
+
<RunningTasksCard
|
21
|
+
className=""
|
22
|
+
data={
|
23
|
+
Object {
|
24
|
+
"last": 0,
|
25
|
+
"older": 0,
|
26
|
+
}
|
27
|
+
}
|
28
|
+
matchHeight={true}
|
29
|
+
query={Object {}}
|
30
|
+
time="H24"
|
31
|
+
updateQuery={[Function]}
|
32
|
+
/>
|
33
|
+
</Col>
|
34
|
+
<Col
|
35
|
+
bsClass="col"
|
36
|
+
componentClass="div"
|
37
|
+
key="paused"
|
38
|
+
lg={3}
|
39
|
+
sm={6}
|
40
|
+
>
|
41
|
+
<PausedTasksCard
|
42
|
+
className=""
|
43
|
+
data={
|
44
|
+
Object {
|
45
|
+
"last": 0,
|
46
|
+
"older": 0,
|
47
|
+
}
|
48
|
+
}
|
49
|
+
matchHeight={true}
|
50
|
+
query={Object {}}
|
51
|
+
time="H24"
|
52
|
+
updateQuery={[Function]}
|
53
|
+
/>
|
54
|
+
</Col>
|
55
|
+
<Col
|
56
|
+
bsClass="col"
|
57
|
+
componentClass="div"
|
58
|
+
key="stopped"
|
59
|
+
lg={3}
|
60
|
+
sm={6}
|
61
|
+
>
|
62
|
+
<StoppedTasksCard
|
63
|
+
className=""
|
64
|
+
data={
|
65
|
+
Object {
|
66
|
+
"error": Object {
|
67
|
+
"last": 0,
|
68
|
+
"total": 0,
|
69
|
+
},
|
70
|
+
"success": Object {
|
71
|
+
"last": 0,
|
72
|
+
"total": 0,
|
73
|
+
},
|
74
|
+
"warning": Object {
|
75
|
+
"last": 0,
|
76
|
+
"total": 0,
|
77
|
+
},
|
78
|
+
}
|
79
|
+
}
|
80
|
+
matchHeight={true}
|
81
|
+
query={Object {}}
|
82
|
+
time="H24"
|
83
|
+
updateQuery={[Function]}
|
84
|
+
/>
|
85
|
+
</Col>
|
86
|
+
<Col
|
87
|
+
bsClass="col"
|
88
|
+
componentClass="div"
|
89
|
+
key="scheduled"
|
90
|
+
lg={3}
|
91
|
+
sm={6}
|
92
|
+
>
|
93
|
+
<ScheduledTasksCard
|
94
|
+
className=""
|
95
|
+
data={0}
|
96
|
+
matchHeight={true}
|
97
|
+
query={Object {}}
|
98
|
+
time="H24"
|
99
|
+
updateQuery={[Function]}
|
100
|
+
/>
|
101
|
+
</Col>
|
102
|
+
</Row>
|
103
|
+
</CardGrid>
|
104
|
+
`;
|
105
|
+
|
106
|
+
exports[`TasksCardsGrid render with props 1`] = `
|
107
|
+
<CardGrid
|
108
|
+
className=""
|
109
|
+
fluid={true}
|
110
|
+
matchHeight={true}
|
111
|
+
>
|
112
|
+
<Row
|
113
|
+
bsClass="row"
|
114
|
+
componentClass="div"
|
115
|
+
>
|
116
|
+
<Col
|
117
|
+
bsClass="col"
|
118
|
+
componentClass="div"
|
119
|
+
key="running"
|
120
|
+
lg={3}
|
121
|
+
sm={6}
|
122
|
+
>
|
123
|
+
<RunningTasksCard
|
124
|
+
className=""
|
125
|
+
data={
|
126
|
+
Object {
|
127
|
+
"last": 3,
|
128
|
+
"older": 5,
|
129
|
+
}
|
130
|
+
}
|
131
|
+
matchHeight={true}
|
132
|
+
query={
|
133
|
+
Object {
|
134
|
+
"state": "running",
|
135
|
+
}
|
136
|
+
}
|
137
|
+
time="WEEK"
|
138
|
+
updateQuery={[MockFunction]}
|
139
|
+
/>
|
140
|
+
</Col>
|
141
|
+
<Col
|
142
|
+
bsClass="col"
|
143
|
+
componentClass="div"
|
144
|
+
key="paused"
|
145
|
+
lg={3}
|
146
|
+
sm={6}
|
147
|
+
>
|
148
|
+
<PausedTasksCard
|
149
|
+
className=""
|
150
|
+
data={
|
151
|
+
Object {
|
152
|
+
"last": 3,
|
153
|
+
"older": 5,
|
154
|
+
}
|
155
|
+
}
|
156
|
+
matchHeight={true}
|
157
|
+
query={
|
158
|
+
Object {
|
159
|
+
"state": "running",
|
160
|
+
}
|
161
|
+
}
|
162
|
+
time="WEEK"
|
163
|
+
updateQuery={[MockFunction]}
|
164
|
+
/>
|
165
|
+
</Col>
|
166
|
+
<Col
|
167
|
+
bsClass="col"
|
168
|
+
componentClass="div"
|
169
|
+
key="stopped"
|
170
|
+
lg={3}
|
171
|
+
sm={6}
|
172
|
+
>
|
173
|
+
<StoppedTasksCard
|
174
|
+
className=""
|
175
|
+
data={
|
176
|
+
Object {
|
177
|
+
"error": Object {
|
178
|
+
"last": 1,
|
179
|
+
"total": 8,
|
180
|
+
},
|
181
|
+
"success": Object {
|
182
|
+
"last": 3,
|
183
|
+
"total": 25,
|
184
|
+
},
|
185
|
+
"warning": Object {
|
186
|
+
"last": 2,
|
187
|
+
"total": 20,
|
188
|
+
},
|
189
|
+
}
|
190
|
+
}
|
191
|
+
matchHeight={true}
|
192
|
+
query={
|
193
|
+
Object {
|
194
|
+
"state": "running",
|
195
|
+
}
|
196
|
+
}
|
197
|
+
time="WEEK"
|
198
|
+
updateQuery={[MockFunction]}
|
199
|
+
/>
|
200
|
+
</Col>
|
201
|
+
<Col
|
202
|
+
bsClass="col"
|
203
|
+
componentClass="div"
|
204
|
+
key="scheduled"
|
205
|
+
lg={3}
|
206
|
+
sm={6}
|
207
|
+
>
|
208
|
+
<ScheduledTasksCard
|
209
|
+
className=""
|
210
|
+
data={1}
|
211
|
+
matchHeight={true}
|
212
|
+
query={
|
213
|
+
Object {
|
214
|
+
"state": "running",
|
215
|
+
}
|
216
|
+
}
|
217
|
+
time="WEEK"
|
218
|
+
updateQuery={[MockFunction]}
|
219
|
+
/>
|
220
|
+
</Col>
|
221
|
+
</Row>
|
222
|
+
</CardGrid>
|
223
|
+
`;
|
data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.js
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import { Row, Button, Label } from 'patternfly-react';
|
4
|
+
import { noop } from 'foremanReact/common/helpers';
|
5
|
+
import { translate as __ } from 'foremanReact/common/I18n';
|
6
|
+
|
7
|
+
import { getQueryKeyText, getQueryValueText } from '../../TasksDashboardHelper';
|
8
|
+
import { queryPropType } from '../../TasksDashboardPropTypes';
|
9
|
+
import './TasksLabelsRow.scss';
|
10
|
+
|
11
|
+
const TasksLabelsRow = ({ query, updateQuery }) => {
|
12
|
+
const onDeleteClick = keyToDelete => {
|
13
|
+
const { [keyToDelete]: deleted, ...queryWithoutDeleted } = query;
|
14
|
+
updateQuery(queryWithoutDeleted);
|
15
|
+
};
|
16
|
+
|
17
|
+
const getLabelText = (key, value) => {
|
18
|
+
const translatedKey = getQueryKeyText(key);
|
19
|
+
const translatedValue = getQueryValueText(value);
|
20
|
+
|
21
|
+
return `${translatedKey} = ${translatedValue}`;
|
22
|
+
};
|
23
|
+
|
24
|
+
const queryEntries = Object.entries(query);
|
25
|
+
|
26
|
+
return (
|
27
|
+
<Row className="tasks-labels-row">
|
28
|
+
<span className="title">{__('Active Filters:')}</span>
|
29
|
+
{queryEntries.map(([key, value]) => (
|
30
|
+
<Label
|
31
|
+
bsStyle="info"
|
32
|
+
key={key}
|
33
|
+
onRemoveClick={() => onDeleteClick(key)}
|
34
|
+
>
|
35
|
+
{getLabelText(key, value)}
|
36
|
+
</Label>
|
37
|
+
))}
|
38
|
+
{queryEntries.length > 0 && (
|
39
|
+
<Button bsStyle="link" onClick={() => updateQuery({})}>
|
40
|
+
{__('Clear All Filters')}
|
41
|
+
</Button>
|
42
|
+
)}
|
43
|
+
</Row>
|
44
|
+
);
|
45
|
+
};
|
46
|
+
|
47
|
+
TasksLabelsRow.propTypes = {
|
48
|
+
query: queryPropType,
|
49
|
+
updateQuery: PropTypes.func,
|
50
|
+
};
|
51
|
+
|
52
|
+
TasksLabelsRow.defaultProps = {
|
53
|
+
query: {},
|
54
|
+
updateQuery: noop,
|
55
|
+
};
|
56
|
+
|
57
|
+
export default TasksLabelsRow;
|