foreman_inventory_upload 1.0.0.beta1 → 1.0.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/foreman_inventory_upload/version.rb +1 -1
- data/package.json +124 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js +34 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js +72 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.stories.js +18 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js +65 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListConstants.js +9 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js +55 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListSelectors.js +8 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/EmptyState.fixtures.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/EmptyState.js +16 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/EmptyStateHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/__tests__/EmptyState.test.js +13 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/__tests__/__snapshots__/EmptyState.test.js.snap +26 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/emptyState.scss +7 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/ErrorState.fixtures.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/ErrorState.js +23 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/ErrorStateHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/__tests__/ErrorState.test.js +13 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/__tests__/__snapshots__/ErrorState.test.js.snap +20 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/errorState.scss +18 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.fixtures.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.js +39 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItemHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/ListItem.test.js +13 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/__snapshots__/ListItem.test.js.snap +48 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/listItem.scss +0 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/ListItemStatus.fixtures.js +6 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/ListItemStatus.js +43 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/ListItemStatusHelper.js +29 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/__tests__/ListItemStatus.test.js +14 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/__tests__/__snapshots__/ListItemStatus.test.js.snap +78 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/listItemStatus.scss +16 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountList.test.js +13 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListActions.test.js +20 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListIntegration.test.js +14 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListReducer.test.js +60 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListSelectors.test.js +26 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountList.test.js.snap +41 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListActions.test.js.snap +47 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListReducer.test.js.snap +66 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListSelectors.test.js.snap +40 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/accountList.scss +9 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/index.js +30 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.fixtures.js +50 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.js +146 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.stories.js +19 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardActions.js +87 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardConstants.js +9 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js +68 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardSelectors.js +17 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/Dashboard.test.js +25 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js +39 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardIntegration.test.js +16 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardReducer.test.js +64 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardSelectors.test.js +45 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/__snapshots__/Dashboard.test.js.snap +36 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/__snapshots__/DashboardActions.test.js.snap +76 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/__snapshots__/DashboardReducer.test.js.snap +44 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/__snapshots__/DashboardSelectors.test.js.snap +42 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/dashboard.scss +0 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/index.js +37 -0
- data/webpack/ForemanInventoryUpload/Components/FileDownload/FileDownload.fixtures.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/FileDownload/FileDownload.js +22 -0
- data/webpack/ForemanInventoryUpload/Components/FileDownload/FileDownloadHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/FileDownload/__tests__/FileDownload.test.js +13 -0
- data/webpack/ForemanInventoryUpload/Components/FileDownload/__tests__/__snapshots__/FileDownload.test.js.snap +25 -0
- data/webpack/ForemanInventoryUpload/Components/FileDownload/fileDownload.scss +3 -0
- data/webpack/ForemanInventoryUpload/Components/FileDownload/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModal.fixtures.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModal.js +50 -0
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModalHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/__tests__/FullScreenModal.test.js +13 -0
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/__tests__/__snapshots__/FullScreenModal.test.js.snap +64 -0
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/fullScreenModal.scss +10 -0
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/NavContainer/NavContainer.fixtures.js +10 -0
- data/webpack/ForemanInventoryUpload/Components/NavContainer/NavContainer.js +83 -0
- data/webpack/ForemanInventoryUpload/Components/NavContainer/NavContainerHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/NavContainer/__tests__/NavContainer.test.js +26 -0
- data/webpack/ForemanInventoryUpload/Components/NavContainer/__tests__/__snapshots__/NavContainer.test.js.snap +89 -0
- data/webpack/ForemanInventoryUpload/Components/NavContainer/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/NavContainer/navContainer.scss +7 -0
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerate.fixtures.js +16 -0
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerate.js +57 -0
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerateHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/__tests__/ReportGenerate.test.js +14 -0
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/__tests__/__snapshots__/ReportGenerate.test.js.snap +45 -0
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/reportGenerate.scss +0 -0
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/ReportUpload.fixtures.js +18 -0
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/ReportUpload.js +57 -0
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/ReportUploadHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/__tests__/ReportUpload.test.js +14 -0
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/__tests__/__snapshots__/ReportUpload.test.js.snap +45 -0
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/reportUpload.scss +0 -0
- data/webpack/ForemanInventoryUpload/Components/ScheduledRun/ScheduledRun.fixtures.js +3 -0
- data/webpack/ForemanInventoryUpload/Components/ScheduledRun/ScheduledRun.js +27 -0
- data/webpack/ForemanInventoryUpload/Components/ScheduledRun/ScheduledRunHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/ScheduledRun/__tests__/ScheduledRun.test.js +14 -0
- data/webpack/ForemanInventoryUpload/Components/ScheduledRun/__tests__/__snapshots__/ScheduledRun.test.js.snap +25 -0
- data/webpack/ForemanInventoryUpload/Components/ScheduledRun/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/ScheduledRun/scheduledRun.scss +11 -0
- data/webpack/ForemanInventoryUpload/Components/StatusChart/StatusChart.fixtures.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/StatusChart/StatusChart.js +53 -0
- data/webpack/ForemanInventoryUpload/Components/StatusChart/StatusChartHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/StatusChart/__tests__/StatusChart.test.js +13 -0
- data/webpack/ForemanInventoryUpload/Components/StatusChart/__tests__/__snapshots__/StatusChart.test.js.snap +74 -0
- data/webpack/ForemanInventoryUpload/Components/StatusChart/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/StatusChart/statusChart.scss +8 -0
- data/webpack/ForemanInventoryUpload/Components/TabBody/TabBody.fixtures.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/TabBody/TabBody.js +31 -0
- data/webpack/ForemanInventoryUpload/Components/TabBody/TabBodyHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/TabBody/__tests__/TabBody.test.js +13 -0
- data/webpack/ForemanInventoryUpload/Components/TabBody/__tests__/__snapshots__/TabBody.test.js.snap +19 -0
- data/webpack/ForemanInventoryUpload/Components/TabBody/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/TabBody/tabBody.scss +3 -0
- data/webpack/ForemanInventoryUpload/Components/TabContainer/TabContainer.fixtures.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/TabContainer/TabContainer.js +24 -0
- data/webpack/ForemanInventoryUpload/Components/TabContainer/TabContainerHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/TabContainer/__tests__/TabContainer.test.js +13 -0
- data/webpack/ForemanInventoryUpload/Components/TabContainer/__tests__/__snapshots__/TabContainer.test.js.snap +18 -0
- data/webpack/ForemanInventoryUpload/Components/TabContainer/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/TabContainer/tabContainer.scss +8 -0
- data/webpack/ForemanInventoryUpload/Components/TabFooter/TabFooter.fixtures.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/TabFooter/TabFooter.js +19 -0
- data/webpack/ForemanInventoryUpload/Components/TabFooter/TabFooterHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/TabFooter/__tests__/TabFooter.test.js +13 -0
- data/webpack/ForemanInventoryUpload/Components/TabFooter/__tests__/__snapshots__/TabFooter.test.js.snap +12 -0
- data/webpack/ForemanInventoryUpload/Components/TabFooter/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/TabFooter/tabFooter.scss +0 -0
- data/webpack/ForemanInventoryUpload/Components/TabHeader/TabHeader.fixtures.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/TabHeader/TabHeader.js +45 -0
- data/webpack/ForemanInventoryUpload/Components/TabHeader/TabHeaderHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/TabHeader/__tests__/TabHeader.test.js +13 -0
- data/webpack/ForemanInventoryUpload/Components/TabHeader/__tests__/__snapshots__/TabHeader.test.js.snap +53 -0
- data/webpack/ForemanInventoryUpload/Components/TabHeader/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/TabHeader/tabHeader.scss +21 -0
- data/webpack/ForemanInventoryUpload/Components/Terminal/Terminal.fixtures.js +10 -0
- data/webpack/ForemanInventoryUpload/Components/Terminal/Terminal.js +112 -0
- data/webpack/ForemanInventoryUpload/Components/Terminal/TerminalHelper.js +6 -0
- data/webpack/ForemanInventoryUpload/Components/Terminal/__tests__/Terminal.test.js +35 -0
- data/webpack/ForemanInventoryUpload/Components/Terminal/__tests__/__snapshots__/Terminal.test.js.snap +98 -0
- data/webpack/ForemanInventoryUpload/Components/Terminal/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/Terminal/terminal.scss +31 -0
- data/webpack/ForemanInventoryUpload/Components/Tree/Tree.fixtures.js +3 -0
- data/webpack/ForemanInventoryUpload/Components/Tree/Tree.js +29 -0
- data/webpack/ForemanInventoryUpload/Components/Tree/TreeHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/Tree/__tests__/Tree.test.js +14 -0
- data/webpack/ForemanInventoryUpload/Components/Tree/__tests__/__snapshots__/Tree.test.js.snap +63 -0
- data/webpack/ForemanInventoryUpload/Components/Tree/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/Tree/tree.scss +0 -0
- data/webpack/ForemanInventoryUpload/ForemanInventoryUpload.js +15 -0
- data/webpack/ForemanInventoryUpload/ForemanInventoryUpload.test.js +10 -0
- data/webpack/ForemanInventoryUpload/ForemanInventoryUploadReducers.js +12 -0
- data/webpack/ForemanInventoryUpload/ForemanInventoryUploadSelectors.js +4 -0
- data/webpack/ForemanInventoryUpload/__snapshots__/ForemanInventoryUpload.test.js.snap +16 -0
- data/webpack/ForemanInventoryUpload/index.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 +18 -0
- data/webpack/stories/ForemanInventoryUploadReducers.js +3 -0
- data/webpack/stories/configureStore.js +15 -0
- data/webpack/stories/decorators/index.js +1 -0
- data/webpack/stories/decorators/withCardsDecorator.js +14 -0
- data/webpack/stories/index.js +10 -0
- data/webpack/stories/index.scss +7 -0
- data/webpack/test_setup.js +6 -0
- metadata +177 -2
@@ -0,0 +1,146 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import { noop } from 'patternfly-react';
|
4
|
+
import { translate as __ } from 'foremanReact/common/I18n';
|
5
|
+
import ReportGenerate from '../ReportGenerate';
|
6
|
+
import ReportUpload from '../ReportUpload';
|
7
|
+
import NavContainer from '../NavContainer';
|
8
|
+
import './dashboard.scss';
|
9
|
+
|
10
|
+
class Dashboard extends React.Component {
|
11
|
+
componentDidMount() {
|
12
|
+
const { startPolling, fetchLogs, accountID } = this.props;
|
13
|
+
fetchLogs(accountID);
|
14
|
+
const pollingProcessID = setInterval(() => fetchLogs(accountID), 5000);
|
15
|
+
startPolling(accountID, pollingProcessID);
|
16
|
+
}
|
17
|
+
|
18
|
+
componentWillUnmount() {
|
19
|
+
const { stopPolling, pollingProcessID, accountID } = this.props;
|
20
|
+
stopPolling(accountID, pollingProcessID);
|
21
|
+
}
|
22
|
+
|
23
|
+
handleDownload = () => {
|
24
|
+
const { downloadReports, accountID } = this.props;
|
25
|
+
downloadReports(accountID);
|
26
|
+
};
|
27
|
+
|
28
|
+
handleRestart = () => {
|
29
|
+
const { restartProcess, accountID, activeTab } = this.props;
|
30
|
+
restartProcess(accountID, activeTab);
|
31
|
+
};
|
32
|
+
|
33
|
+
handleTabChange = async tabName => {
|
34
|
+
const { setActiveTab, accountID, fetchLogs } = this.props;
|
35
|
+
await setActiveTab(accountID, tabName);
|
36
|
+
fetchLogs(accountID);
|
37
|
+
};
|
38
|
+
|
39
|
+
handleToggleFullScreen = () => {
|
40
|
+
const { toggleFullScreen, accountID } = this.props;
|
41
|
+
toggleFullScreen(accountID);
|
42
|
+
};
|
43
|
+
|
44
|
+
render() {
|
45
|
+
const {
|
46
|
+
uploading,
|
47
|
+
generating,
|
48
|
+
statuses,
|
49
|
+
showFullScreen,
|
50
|
+
activeTab,
|
51
|
+
} = this.props;
|
52
|
+
return (
|
53
|
+
<NavContainer
|
54
|
+
items={[
|
55
|
+
{
|
56
|
+
icon: 'database',
|
57
|
+
name: __('Generating'),
|
58
|
+
component: ReportGenerate,
|
59
|
+
props: {
|
60
|
+
...generating,
|
61
|
+
restartProcess: this.handleRestart,
|
62
|
+
exitCode: statuses.generate_report_status,
|
63
|
+
toggleFullScreen: this.handleToggleFullScreen,
|
64
|
+
},
|
65
|
+
onClick: () => this.handleTabChange('generating'),
|
66
|
+
},
|
67
|
+
{
|
68
|
+
icon: 'cloud-upload',
|
69
|
+
name: __('Uploading'),
|
70
|
+
component: ReportUpload,
|
71
|
+
props: {
|
72
|
+
...uploading,
|
73
|
+
restartProcess: this.handleRestart,
|
74
|
+
downloadReports: this.handleDownload,
|
75
|
+
exitCode: statuses.upload_report_status,
|
76
|
+
toggleFullScreen: this.handleToggleFullScreen,
|
77
|
+
},
|
78
|
+
onClick: () => this.handleTabChange('uploading'),
|
79
|
+
},
|
80
|
+
]}
|
81
|
+
toggleFullScreen={this.handleToggleFullScreen}
|
82
|
+
showFullScreen={showFullScreen}
|
83
|
+
terminalProps={this.props[activeTab]}
|
84
|
+
/>
|
85
|
+
);
|
86
|
+
}
|
87
|
+
}
|
88
|
+
|
89
|
+
Dashboard.propTypes = {
|
90
|
+
accountID: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
91
|
+
.isRequired,
|
92
|
+
startPolling: PropTypes.func,
|
93
|
+
fetchLogs: PropTypes.func,
|
94
|
+
stopPolling: PropTypes.func,
|
95
|
+
setActiveTab: PropTypes.func,
|
96
|
+
uploading: PropTypes.shape({
|
97
|
+
exitCode: PropTypes.string,
|
98
|
+
logs: PropTypes.oneOfType([
|
99
|
+
PropTypes.arrayOf(PropTypes.string),
|
100
|
+
PropTypes.string,
|
101
|
+
]),
|
102
|
+
completed: PropTypes.number,
|
103
|
+
files: PropTypes.arrayOf(PropTypes.string),
|
104
|
+
error: PropTypes.string,
|
105
|
+
}),
|
106
|
+
generating: PropTypes.shape({
|
107
|
+
exitCode: PropTypes.string,
|
108
|
+
logs: PropTypes.oneOfType([
|
109
|
+
PropTypes.arrayOf(PropTypes.string),
|
110
|
+
PropTypes.string,
|
111
|
+
]),
|
112
|
+
completed: PropTypes.number,
|
113
|
+
error: PropTypes.string,
|
114
|
+
}),
|
115
|
+
restartProcess: PropTypes.func,
|
116
|
+
downloadReports: PropTypes.func,
|
117
|
+
pollingProcessID: PropTypes.number,
|
118
|
+
statuses: PropTypes.shape({
|
119
|
+
generate_report_status: PropTypes.string,
|
120
|
+
upload_report_status: PropTypes.string,
|
121
|
+
}),
|
122
|
+
showFullScreen: PropTypes.bool,
|
123
|
+
toggleFullScreen: PropTypes.func,
|
124
|
+
activeTab: PropTypes.string,
|
125
|
+
};
|
126
|
+
|
127
|
+
Dashboard.defaultProps = {
|
128
|
+
uploading: {},
|
129
|
+
generating: {},
|
130
|
+
startPolling: noop,
|
131
|
+
fetchLogs: noop,
|
132
|
+
stopPolling: noop,
|
133
|
+
setActiveTab: noop,
|
134
|
+
restartProcess: noop,
|
135
|
+
downloadReports: noop,
|
136
|
+
pollingProcessID: 0,
|
137
|
+
statuses: {
|
138
|
+
generate_report_status: 'unknown',
|
139
|
+
upload_report_status: 'unknown',
|
140
|
+
},
|
141
|
+
showFullScreen: false,
|
142
|
+
toggleFullScreen: noop,
|
143
|
+
activeTab: 'generating',
|
144
|
+
};
|
145
|
+
|
146
|
+
export default Dashboard;
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { storiesOf } from '@storybook/react';
|
3
|
+
import { withKnobs } from '@storybook/addon-knobs';
|
4
|
+
import { Provider } from 'react-redux';
|
5
|
+
import configureStore from '../../../stories/configureStore';
|
6
|
+
import Dashboard from './index';
|
7
|
+
import { generating, uploading } from './Dashboard.fixtures';
|
8
|
+
|
9
|
+
const store = configureStore();
|
10
|
+
|
11
|
+
storiesOf('Dashboard', module)
|
12
|
+
.addDecorator(withKnobs)
|
13
|
+
.add('Dashboard', () => (
|
14
|
+
<div style={{ margin: '20px' }}>
|
15
|
+
<Provider store={store}>
|
16
|
+
<Dashboard generating={generating} uploading={uploading} />
|
17
|
+
</Provider>
|
18
|
+
</div>
|
19
|
+
));
|
@@ -0,0 +1,87 @@
|
|
1
|
+
import API from 'foremanReact/API';
|
2
|
+
import {
|
3
|
+
INVENTORY_POLLING_START,
|
4
|
+
INVENTORY_POLLING_STOP,
|
5
|
+
INVENTORY_POLLING,
|
6
|
+
INVENTORY_TAB_CHANGED,
|
7
|
+
INVENTORY_POLLING_ERROR,
|
8
|
+
INVENTORY_REPORTS_DOWNLOAD,
|
9
|
+
INVENTORY_TOGGLE_TERMINAL_FULL_SCREEN,
|
10
|
+
} from './DashboardConstants';
|
11
|
+
import { selectActiveTab } from './DashboardSelectors';
|
12
|
+
|
13
|
+
export const startPolling = (accountID, pollingProcessID) => ({
|
14
|
+
type: INVENTORY_POLLING_START,
|
15
|
+
payload: {
|
16
|
+
accountID,
|
17
|
+
pollingProcessID,
|
18
|
+
},
|
19
|
+
});
|
20
|
+
|
21
|
+
export const stopPolling = (accountID, pollingProcessID) => dispatch => {
|
22
|
+
clearInterval(pollingProcessID);
|
23
|
+
dispatch({
|
24
|
+
type: INVENTORY_POLLING_STOP,
|
25
|
+
payload: {
|
26
|
+
accountID,
|
27
|
+
},
|
28
|
+
});
|
29
|
+
};
|
30
|
+
|
31
|
+
export const fetchLogs = accountID => async (dispatch, getState) => {
|
32
|
+
const activeTab = selectActiveTab(getState(), accountID);
|
33
|
+
try {
|
34
|
+
const processController = activeTab === 'uploading' ? 'uploads' : 'reports';
|
35
|
+
const {
|
36
|
+
data: { output, scheduled },
|
37
|
+
} = await API.get(`${accountID}/${processController}/last`);
|
38
|
+
const outputArray = output.split('\n');
|
39
|
+
dispatch({
|
40
|
+
type: INVENTORY_POLLING,
|
41
|
+
payload: {
|
42
|
+
accountID,
|
43
|
+
activeTab,
|
44
|
+
logs: outputArray,
|
45
|
+
scheduled,
|
46
|
+
},
|
47
|
+
});
|
48
|
+
} catch (error) {
|
49
|
+
dispatch({
|
50
|
+
type: INVENTORY_POLLING_ERROR,
|
51
|
+
payload: {
|
52
|
+
accountID,
|
53
|
+
activeTab,
|
54
|
+
error: error.message,
|
55
|
+
},
|
56
|
+
});
|
57
|
+
}
|
58
|
+
};
|
59
|
+
|
60
|
+
export const setActiveTab = (accountID, tabName) => ({
|
61
|
+
type: INVENTORY_TAB_CHANGED,
|
62
|
+
payload: {
|
63
|
+
accountID,
|
64
|
+
activeTab: tabName,
|
65
|
+
},
|
66
|
+
});
|
67
|
+
|
68
|
+
export const downloadReports = accountID => {
|
69
|
+
window.location.href = `/foreman_inventory_upload/${accountID}/uploads/file`;
|
70
|
+
return {
|
71
|
+
type: INVENTORY_REPORTS_DOWNLOAD,
|
72
|
+
payload: {
|
73
|
+
accountID,
|
74
|
+
},
|
75
|
+
};
|
76
|
+
};
|
77
|
+
|
78
|
+
export const toggleFullScreen = accountID => (dispatch, getState) => {
|
79
|
+
const activeTab = selectActiveTab(getState(), accountID);
|
80
|
+
dispatch({
|
81
|
+
type: INVENTORY_TOGGLE_TERMINAL_FULL_SCREEN,
|
82
|
+
payload: {
|
83
|
+
activeTab,
|
84
|
+
accountID,
|
85
|
+
},
|
86
|
+
});
|
87
|
+
};
|
@@ -0,0 +1,9 @@
|
|
1
|
+
export const INVENTORY_POLLING = 'INVENTORY_POLLING';
|
2
|
+
export const INVENTORY_POLLING_START = 'INVENTORY_POLLING_START';
|
3
|
+
export const INVENTORY_POLLING_STOP = 'INVENTORY_POLLING_STOP';
|
4
|
+
export const INVENTORY_POLLING_ERROR = 'INVENTORY_POLLING_ERROR';
|
5
|
+
export const INVENTORY_TAB_CHANGED = 'INVENTORY_TAB_CHANGED';
|
6
|
+
export const INVENTORY_REPORTS_DOWNLOAD = 'INVENTORY_REPORTS_DOWNLOAD';
|
7
|
+
export const INVENTORY_PROCESS_RESTART = 'INVENTORY_PROCESS_RESTART';
|
8
|
+
export const INVENTORY_TOGGLE_TERMINAL_FULL_SCREEN =
|
9
|
+
'INVENTORY_TOGGLE_TERMINAL_FULL_SCREEN';
|
File without changes
|
@@ -0,0 +1,68 @@
|
|
1
|
+
import Immutable from 'seamless-immutable';
|
2
|
+
|
3
|
+
import {
|
4
|
+
INVENTORY_POLLING_START,
|
5
|
+
INVENTORY_POLLING,
|
6
|
+
INVENTORY_TAB_CHANGED,
|
7
|
+
INVENTORY_POLLING_ERROR,
|
8
|
+
INVENTORY_TOGGLE_TERMINAL_FULL_SCREEN,
|
9
|
+
} from './DashboardConstants';
|
10
|
+
|
11
|
+
const initialState = Immutable({});
|
12
|
+
|
13
|
+
export default (state = initialState, action) => {
|
14
|
+
const {
|
15
|
+
payload: {
|
16
|
+
accountID,
|
17
|
+
pollingProcessID,
|
18
|
+
logs,
|
19
|
+
error,
|
20
|
+
activeTab,
|
21
|
+
scheduled,
|
22
|
+
} = {},
|
23
|
+
} = action;
|
24
|
+
|
25
|
+
const getTabState = () =>
|
26
|
+
state[accountID] ? state[accountID][activeTab] : {};
|
27
|
+
switch (action.type) {
|
28
|
+
case INVENTORY_POLLING_START:
|
29
|
+
return state.setIn([accountID], {
|
30
|
+
...state[accountID],
|
31
|
+
pollingProcessID,
|
32
|
+
activeTab: 'generating',
|
33
|
+
});
|
34
|
+
case INVENTORY_POLLING:
|
35
|
+
return state.setIn([accountID], {
|
36
|
+
...state[accountID],
|
37
|
+
[activeTab]: {
|
38
|
+
...getTabState(),
|
39
|
+
logs,
|
40
|
+
scheduled,
|
41
|
+
error: null,
|
42
|
+
},
|
43
|
+
});
|
44
|
+
case INVENTORY_TAB_CHANGED:
|
45
|
+
return state.setIn([accountID], {
|
46
|
+
...state[accountID],
|
47
|
+
activeTab,
|
48
|
+
});
|
49
|
+
case INVENTORY_POLLING_ERROR:
|
50
|
+
return state.setIn([accountID], {
|
51
|
+
...state[accountID],
|
52
|
+
[activeTab]: {
|
53
|
+
...getTabState(),
|
54
|
+
error,
|
55
|
+
},
|
56
|
+
});
|
57
|
+
case INVENTORY_TOGGLE_TERMINAL_FULL_SCREEN:
|
58
|
+
return state.setIn([accountID], {
|
59
|
+
...state[accountID],
|
60
|
+
[activeTab]: {
|
61
|
+
...getTabState(),
|
62
|
+
showFullScreen: !state[accountID][activeTab].showFullScreen,
|
63
|
+
},
|
64
|
+
});
|
65
|
+
default:
|
66
|
+
return state;
|
67
|
+
}
|
68
|
+
};
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { selectForemanInventoryUpload } from '../../ForemanInventoryUploadSelectors';
|
2
|
+
|
3
|
+
export const selectDashboard = (state, accountID) =>
|
4
|
+
selectForemanInventoryUpload(state).dashboard[accountID] || {};
|
5
|
+
export const selectUploading = (state, accountID) =>
|
6
|
+
selectDashboard(state, accountID).uploading;
|
7
|
+
export const selectGenerating = (state, accountID) =>
|
8
|
+
selectDashboard(state, accountID).generating;
|
9
|
+
export const selectPollingProcessID = (state, accountID) =>
|
10
|
+
selectDashboard(state, accountID).pollingProcessID;
|
11
|
+
export const selectActiveTab = (state, accountID) =>
|
12
|
+
selectDashboard(state, accountID).activeTab || 'generating';
|
13
|
+
export const selectShowFullScreen = (state, accountID) => {
|
14
|
+
const activeTab = selectActiveTab(state, accountID);
|
15
|
+
const tabProperties = selectDashboard(state, accountID)[activeTab];
|
16
|
+
return tabProperties ? tabProperties.showFullScreen || false : false;
|
17
|
+
};
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { shallow } from 'enzyme';
|
3
|
+
import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
|
4
|
+
import Dashboard from '../Dashboard';
|
5
|
+
import { props } from '../Dashboard.fixtures';
|
6
|
+
|
7
|
+
const fixtures = {
|
8
|
+
'with props': props,
|
9
|
+
};
|
10
|
+
|
11
|
+
describe('Dashboard', () => {
|
12
|
+
describe('rendering', () =>
|
13
|
+
testComponentSnapshotsWithFixtures(Dashboard, fixtures));
|
14
|
+
|
15
|
+
it('componentWillUnmount should call "stopPolling"', () => {
|
16
|
+
const stopPolling = jest.fn();
|
17
|
+
const modifiedProps = {
|
18
|
+
...props,
|
19
|
+
stopPolling,
|
20
|
+
};
|
21
|
+
const wrapper = shallow(<Dashboard {...modifiedProps} />);
|
22
|
+
wrapper.unmount();
|
23
|
+
expect(stopPolling).toBeCalled();
|
24
|
+
});
|
25
|
+
});
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import { testActionSnapshotWithFixtures } from 'react-redux-test-utils';
|
2
|
+
import API from 'foremanReact/API';
|
3
|
+
import {
|
4
|
+
startPolling,
|
5
|
+
stopPolling,
|
6
|
+
fetchLogs,
|
7
|
+
setActiveTab,
|
8
|
+
downloadReports,
|
9
|
+
toggleFullScreen,
|
10
|
+
} from '../DashboardActions';
|
11
|
+
import {
|
12
|
+
pollingProcessID,
|
13
|
+
serverMock,
|
14
|
+
activeTab,
|
15
|
+
accountID,
|
16
|
+
} from '../Dashboard.fixtures';
|
17
|
+
|
18
|
+
jest.mock('foremanReact/API');
|
19
|
+
API.get.mockImplementation(() => serverMock);
|
20
|
+
|
21
|
+
const runWithGetState = (state, action, params) => dispatch => {
|
22
|
+
const getState = () => ({
|
23
|
+
dashboard: state,
|
24
|
+
});
|
25
|
+
action(params)(dispatch, getState);
|
26
|
+
};
|
27
|
+
|
28
|
+
const fixtures = {
|
29
|
+
'should startPolling': () => startPolling(accountID, pollingProcessID),
|
30
|
+
'should fetchLogs': () =>
|
31
|
+
runWithGetState({ activeTab: 'uploads' }, fetchLogs, accountID),
|
32
|
+
'should stopPolling': () => stopPolling(accountID, pollingProcessID),
|
33
|
+
'should setActiveTab': () => setActiveTab(accountID, activeTab),
|
34
|
+
'should downloadReports': () => downloadReports(accountID),
|
35
|
+
'should toggleFullScreen': () =>
|
36
|
+
runWithGetState({ activeTab: 'reports' }, toggleFullScreen, accountID),
|
37
|
+
};
|
38
|
+
|
39
|
+
describe('Dashboard actions', () => testActionSnapshotWithFixtures(fixtures));
|
data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardIntegration.test.js
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { IntegrationTestHelper } from 'react-redux-test-utils';
|
3
|
+
|
4
|
+
import Dashboard, { reducers } from '../index';
|
5
|
+
import { accountID } from '../Dashboard.fixtures';
|
6
|
+
|
7
|
+
describe('Dashboard integration test', () => {
|
8
|
+
it('should flow', async () => {
|
9
|
+
const integrationTestHelper = new IntegrationTestHelper(reducers);
|
10
|
+
const component = integrationTestHelper.mount(
|
11
|
+
<Dashboard accountID={accountID} />
|
12
|
+
);
|
13
|
+
component.update();
|
14
|
+
/** Create a Flow test */
|
15
|
+
});
|
16
|
+
});
|
@@ -0,0 +1,64 @@
|
|
1
|
+
import { testReducerSnapshotWithFixtures } from 'react-redux-test-utils';
|
2
|
+
|
3
|
+
import {
|
4
|
+
INVENTORY_POLLING_START,
|
5
|
+
INVENTORY_POLLING,
|
6
|
+
INVENTORY_TAB_CHANGED,
|
7
|
+
INVENTORY_POLLING_ERROR,
|
8
|
+
} from '../DashboardConstants';
|
9
|
+
import reducer from '../DashboardReducer';
|
10
|
+
import {
|
11
|
+
pollingProcessID,
|
12
|
+
logs,
|
13
|
+
initialState,
|
14
|
+
activeTab,
|
15
|
+
error,
|
16
|
+
accountID,
|
17
|
+
scheduled,
|
18
|
+
} from '../Dashboard.fixtures';
|
19
|
+
|
20
|
+
const fixtures = {
|
21
|
+
'should return the initial state': initialState,
|
22
|
+
'should handle INVENTORY_POLLING_START': {
|
23
|
+
action: {
|
24
|
+
type: INVENTORY_POLLING_START,
|
25
|
+
payload: {
|
26
|
+
pollingProcessID,
|
27
|
+
accountID,
|
28
|
+
},
|
29
|
+
},
|
30
|
+
},
|
31
|
+
'should handle INVENTORY_POLLING': {
|
32
|
+
action: {
|
33
|
+
type: INVENTORY_POLLING,
|
34
|
+
payload: {
|
35
|
+
logs,
|
36
|
+
accountID,
|
37
|
+
activeTab,
|
38
|
+
scheduled,
|
39
|
+
},
|
40
|
+
},
|
41
|
+
},
|
42
|
+
'should handle INVENTORY_TAB_CHANGED': {
|
43
|
+
action: {
|
44
|
+
type: INVENTORY_TAB_CHANGED,
|
45
|
+
payload: {
|
46
|
+
activeTab,
|
47
|
+
accountID,
|
48
|
+
},
|
49
|
+
},
|
50
|
+
},
|
51
|
+
'should handle INVENTORY_POLLING_ERROR': {
|
52
|
+
action: {
|
53
|
+
type: INVENTORY_POLLING_ERROR,
|
54
|
+
payload: {
|
55
|
+
error,
|
56
|
+
accountID,
|
57
|
+
activeTab,
|
58
|
+
},
|
59
|
+
},
|
60
|
+
},
|
61
|
+
};
|
62
|
+
|
63
|
+
describe('Dashboard reducer', () =>
|
64
|
+
testReducerSnapshotWithFixtures(reducer, fixtures));
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import { testSelectorsSnapshotWithFixtures } from 'react-redux-test-utils';
|
2
|
+
import {
|
3
|
+
selectDashboard,
|
4
|
+
selectPollingProcessID,
|
5
|
+
selectActiveTab,
|
6
|
+
selectUploading,
|
7
|
+
selectGenerating,
|
8
|
+
} from '../DashboardSelectors';
|
9
|
+
import {
|
10
|
+
logs,
|
11
|
+
completed,
|
12
|
+
pollingProcessID,
|
13
|
+
activeTab,
|
14
|
+
accountID,
|
15
|
+
} from '../Dashboard.fixtures';
|
16
|
+
|
17
|
+
const state = {
|
18
|
+
dashboard: {
|
19
|
+
[accountID]: {
|
20
|
+
generating: {
|
21
|
+
logs,
|
22
|
+
completed,
|
23
|
+
},
|
24
|
+
uploading: {
|
25
|
+
logs,
|
26
|
+
completed,
|
27
|
+
},
|
28
|
+
activeTab,
|
29
|
+
pollingProcessID,
|
30
|
+
},
|
31
|
+
},
|
32
|
+
};
|
33
|
+
|
34
|
+
const fixtures = {
|
35
|
+
'should return Dashboard': () => selectDashboard(state, accountID),
|
36
|
+
'should return Dashboard uploading': () => selectUploading(state, accountID),
|
37
|
+
'should return Dashboard generating': () =>
|
38
|
+
selectGenerating(state, accountID),
|
39
|
+
'should return Dashboard pollingProcessID': () =>
|
40
|
+
selectPollingProcessID(state, accountID),
|
41
|
+
'should return Dashboard activeTab': () => selectActiveTab(state, accountID),
|
42
|
+
};
|
43
|
+
|
44
|
+
describe('Dashboard selectors', () =>
|
45
|
+
testSelectorsSnapshotWithFixtures(fixtures));
|
@@ -0,0 +1,36 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`Dashboard rendering with props 1`] = `
|
4
|
+
<NavContainer
|
5
|
+
items={
|
6
|
+
Array [
|
7
|
+
Object {
|
8
|
+
"component": [Function],
|
9
|
+
"icon": "database",
|
10
|
+
"name": "Generating",
|
11
|
+
"onClick": [Function],
|
12
|
+
"props": Object {
|
13
|
+
"exitCode": "unknown",
|
14
|
+
"restartProcess": [Function],
|
15
|
+
"toggleFullScreen": [Function],
|
16
|
+
},
|
17
|
+
},
|
18
|
+
Object {
|
19
|
+
"component": [Function],
|
20
|
+
"icon": "cloud-upload",
|
21
|
+
"name": "Uploading",
|
22
|
+
"onClick": [Function],
|
23
|
+
"props": Object {
|
24
|
+
"downloadReports": [Function],
|
25
|
+
"exitCode": "unknown",
|
26
|
+
"restartProcess": [Function],
|
27
|
+
"toggleFullScreen": [Function],
|
28
|
+
},
|
29
|
+
},
|
30
|
+
]
|
31
|
+
}
|
32
|
+
showFullScreen={false}
|
33
|
+
terminalProps={Object {}}
|
34
|
+
toggleFullScreen={[Function]}
|
35
|
+
/>
|
36
|
+
`;
|
@@ -0,0 +1,76 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`Dashboard actions should downloadReports 1`] = `
|
4
|
+
Object {
|
5
|
+
"payload": Object {
|
6
|
+
"accountID": "some-account-ID",
|
7
|
+
},
|
8
|
+
"type": "INVENTORY_REPORTS_DOWNLOAD",
|
9
|
+
}
|
10
|
+
`;
|
11
|
+
|
12
|
+
exports[`Dashboard actions should fetchLogs 1`] = `
|
13
|
+
Array [
|
14
|
+
Array [
|
15
|
+
Object {
|
16
|
+
"payload": Object {
|
17
|
+
"accountID": "some-account-ID",
|
18
|
+
"activeTab": "generating",
|
19
|
+
"logs": Array [
|
20
|
+
"some-logs",
|
21
|
+
"some-logs",
|
22
|
+
],
|
23
|
+
"scheduled": "2019-08-21T16:14:16.520+03:00",
|
24
|
+
},
|
25
|
+
"type": "INVENTORY_POLLING",
|
26
|
+
},
|
27
|
+
],
|
28
|
+
]
|
29
|
+
`;
|
30
|
+
|
31
|
+
exports[`Dashboard actions should setActiveTab 1`] = `
|
32
|
+
Object {
|
33
|
+
"payload": Object {
|
34
|
+
"accountID": "some-account-ID",
|
35
|
+
"activeTab": "uploads",
|
36
|
+
},
|
37
|
+
"type": "INVENTORY_TAB_CHANGED",
|
38
|
+
}
|
39
|
+
`;
|
40
|
+
|
41
|
+
exports[`Dashboard actions should startPolling 1`] = `
|
42
|
+
Object {
|
43
|
+
"payload": Object {
|
44
|
+
"accountID": "some-account-ID",
|
45
|
+
"pollingProcessID": 1,
|
46
|
+
},
|
47
|
+
"type": "INVENTORY_POLLING_START",
|
48
|
+
}
|
49
|
+
`;
|
50
|
+
|
51
|
+
exports[`Dashboard actions should stopPolling 1`] = `
|
52
|
+
Array [
|
53
|
+
Array [
|
54
|
+
Object {
|
55
|
+
"payload": Object {
|
56
|
+
"accountID": "some-account-ID",
|
57
|
+
},
|
58
|
+
"type": "INVENTORY_POLLING_STOP",
|
59
|
+
},
|
60
|
+
],
|
61
|
+
]
|
62
|
+
`;
|
63
|
+
|
64
|
+
exports[`Dashboard actions should toggleFullScreen 1`] = `
|
65
|
+
Array [
|
66
|
+
Array [
|
67
|
+
Object {
|
68
|
+
"payload": Object {
|
69
|
+
"accountID": "some-account-ID",
|
70
|
+
"activeTab": "generating",
|
71
|
+
},
|
72
|
+
"type": "INVENTORY_TOGGLE_TERMINAL_FULL_SCREEN",
|
73
|
+
},
|
74
|
+
],
|
75
|
+
]
|
76
|
+
`;
|