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,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
|
+
});
|