foreman_rh_cloud 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +619 -0
- data/README.md +38 -0
- data/Rakefile +47 -0
- data/app/controllers/foreman_inventory_upload/accounts_controller.rb +39 -0
- data/app/controllers/foreman_inventory_upload/react_controller.rb +7 -0
- data/app/controllers/foreman_inventory_upload/reports_controller.rb +30 -0
- data/app/controllers/foreman_inventory_upload/uploads_controller.rb +31 -0
- data/app/helpers/foreman_inventory_upload_helper.rb +13 -0
- data/app/views/foreman_inventory_upload/layouts/react.html.erb +16 -0
- data/config/routes.rb +10 -0
- data/lib/foreman_inventory_upload.rb +51 -0
- data/lib/foreman_inventory_upload/async/generate_all_reports_job.rb +19 -0
- data/lib/foreman_inventory_upload/async/generate_report_job.rb +37 -0
- data/lib/foreman_inventory_upload/async/progress_output.rb +61 -0
- data/lib/foreman_inventory_upload/async/queue_for_upload_job.rb +47 -0
- data/lib/foreman_inventory_upload/async/shell_process.rb +36 -0
- data/lib/foreman_inventory_upload/async/upload_report_job.rb +58 -0
- data/lib/foreman_inventory_upload/generators/archived_report.rb +53 -0
- data/lib/foreman_inventory_upload/generators/fact_helpers.rb +18 -0
- data/lib/foreman_inventory_upload/generators/json_stream.rb +55 -0
- data/lib/foreman_inventory_upload/generators/metadata.rb +36 -0
- data/lib/foreman_inventory_upload/generators/queries.rb +61 -0
- data/lib/foreman_inventory_upload/generators/slice.rb +147 -0
- data/lib/foreman_inventory_upload/scripts/uploader.sh.erb +44 -0
- data/lib/foreman_rh_cloud.rb +4 -0
- data/lib/foreman_rh_cloud/engine.rb +62 -0
- data/lib/foreman_rh_cloud/version.rb +3 -0
- data/lib/tasks/foreman_rh_cloud_tasks.rake +37 -0
- data/lib/tasks/generator.rake +29 -0
- data/locale/Makefile +60 -0
- data/locale/en/foreman_rh_cloud.po +19 -0
- data/locale/foreman_rh_cloud.pot +19 -0
- data/locale/gemspec.rb +2 -0
- data/package.json +125 -0
- data/test/controllers/accounts_controller_test.rb +25 -0
- data/test/controllers/reports_controller_test.rb +21 -0
- data/test/controllers/uploads_controller_test.rb +21 -0
- data/test/factories/inventory_upload_factories.rb +88 -0
- data/test/test_plugin_helper.rb +26 -0
- data/test/unit/archived_report_generator_test.rb +61 -0
- data/test/unit/metadata_generator_test.rb +40 -0
- data/test/unit/shell_process_job_test.rb +27 -0
- data/test/unit/slice_generator_test.rb +177 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js +37 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js +74 -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 +41 -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 +50 -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 +7 -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 +44 -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 +69 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListSelectors.test.js.snap +46 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/accountList.scss +9 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/index.js +27 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.fixtures.js +50 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.js +145 -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 +35 -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 +34 -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 +18 -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 +53 -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 +56 -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 +47 -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 +43 -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/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 +318 -0
@@ -0,0 +1,37 @@
|
|
1
|
+
import { noop } from 'patternfly-react';
|
2
|
+
|
3
|
+
export const API_SUCCESS_RESPONSE = {
|
4
|
+
Account1: {
|
5
|
+
label: 'test_org1',
|
6
|
+
upload_report_status: 'running',
|
7
|
+
generate_report_status: 'running',
|
8
|
+
},
|
9
|
+
Account2: {
|
10
|
+
label: 'test_org2',
|
11
|
+
upload_report_status: 'unknown',
|
12
|
+
generate_report_status: 'failure',
|
13
|
+
},
|
14
|
+
Account3: {
|
15
|
+
label: 'test_org3',
|
16
|
+
upload_report_status: 'success',
|
17
|
+
generate_report_status: 'running',
|
18
|
+
},
|
19
|
+
};
|
20
|
+
|
21
|
+
export const accounts = API_SUCCESS_RESPONSE;
|
22
|
+
|
23
|
+
export const pollingProcessID = 0;
|
24
|
+
|
25
|
+
export const error = 'some-error';
|
26
|
+
|
27
|
+
export const accountID = 'user@redhat.com';
|
28
|
+
|
29
|
+
export const processStatusName = 'upload_report_status';
|
30
|
+
|
31
|
+
export const props = {
|
32
|
+
accounts,
|
33
|
+
fetchAccountsStatus: noop,
|
34
|
+
startAccountStatusPolling: noop,
|
35
|
+
stopAccountStatusPolling: noop,
|
36
|
+
pollingProcessID,
|
37
|
+
};
|
@@ -0,0 +1,74 @@
|
|
1
|
+
import React, { Component } from 'react';
|
2
|
+
import { ListView, noop } from 'patternfly-react';
|
3
|
+
import PropTypes from 'prop-types';
|
4
|
+
import ListItem from './Components/ListItem';
|
5
|
+
import EmptyState from './Components/EmptyState';
|
6
|
+
import ErrorState from './Components/ErrorState';
|
7
|
+
import './accountList.scss';
|
8
|
+
|
9
|
+
class AccountList extends Component {
|
10
|
+
componentDidMount() {
|
11
|
+
const { fetchAccountsStatus, startAccountStatusPolling } = this.props;
|
12
|
+
fetchAccountsStatus();
|
13
|
+
const pollingProcessID = setInterval(fetchAccountsStatus, 5000);
|
14
|
+
startAccountStatusPolling(pollingProcessID);
|
15
|
+
}
|
16
|
+
|
17
|
+
componentWillUnmount() {
|
18
|
+
const { stopAccountStatusPolling, pollingProcessID } = this.props;
|
19
|
+
stopAccountStatusPolling(pollingProcessID);
|
20
|
+
}
|
21
|
+
|
22
|
+
render() {
|
23
|
+
const { accounts, error } = this.props;
|
24
|
+
const accountIds = Object.keys(accounts);
|
25
|
+
|
26
|
+
if (error) {
|
27
|
+
return <ErrorState error={error} />;
|
28
|
+
}
|
29
|
+
|
30
|
+
if (accountIds.length === 0) {
|
31
|
+
return <EmptyState />;
|
32
|
+
}
|
33
|
+
const items = accountIds.map((accountID, index) => {
|
34
|
+
const account = accounts[accountID];
|
35
|
+
return (
|
36
|
+
<ListItem
|
37
|
+
key={index}
|
38
|
+
accountID={accountID}
|
39
|
+
account={account}
|
40
|
+
initExpanded={index === 0}
|
41
|
+
/>
|
42
|
+
);
|
43
|
+
});
|
44
|
+
return <ListView className="account_list">{items}</ListView>;
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
AccountList.propTypes = {
|
49
|
+
fetchAccountsStatus: PropTypes.func,
|
50
|
+
startAccountStatusPolling: PropTypes.func,
|
51
|
+
stopAccountStatusPolling: PropTypes.func,
|
52
|
+
pollingProcessID: PropTypes.number,
|
53
|
+
account: PropTypes.shape({
|
54
|
+
generate_report_status: PropTypes.string,
|
55
|
+
upload_report_status: PropTypes.string,
|
56
|
+
}),
|
57
|
+
accounts: PropTypes.object,
|
58
|
+
error: PropTypes.string,
|
59
|
+
};
|
60
|
+
|
61
|
+
AccountList.defaultProps = {
|
62
|
+
fetchAccountsStatus: noop,
|
63
|
+
startAccountStatusPolling: noop,
|
64
|
+
stopAccountStatusPolling: noop,
|
65
|
+
pollingProcessID: 0,
|
66
|
+
account: {
|
67
|
+
generate_report_status: 'unknown',
|
68
|
+
upload_report_status: 'unknown',
|
69
|
+
},
|
70
|
+
accounts: {},
|
71
|
+
error: '',
|
72
|
+
};
|
73
|
+
|
74
|
+
export default AccountList;
|
@@ -0,0 +1,18 @@
|
|
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 AccountList from './AccountList';
|
7
|
+
|
8
|
+
const store = configureStore();
|
9
|
+
|
10
|
+
storiesOf('Account list', module)
|
11
|
+
.addDecorator(withKnobs)
|
12
|
+
.add('Account list', () => (
|
13
|
+
<div style={{ margin: '20px' }}>
|
14
|
+
<Provider store={store}>
|
15
|
+
<AccountList />
|
16
|
+
</Provider>
|
17
|
+
</div>
|
18
|
+
));
|
@@ -0,0 +1,65 @@
|
|
1
|
+
import API from 'foremanReact/API';
|
2
|
+
import {
|
3
|
+
INVENTORY_ACCOUNT_STATUS_POLLING,
|
4
|
+
INVENTORY_ACCOUNT_STATUS_POLLING_ERROR,
|
5
|
+
INVENTORY_ACCOUNT_STATUS_POLLING_START,
|
6
|
+
INVENTORY_ACCOUNT_STATUS_POLLING_STOP,
|
7
|
+
INVENTORY_PROCESS_RESTART,
|
8
|
+
} from './AccountListConstants';
|
9
|
+
|
10
|
+
export const fetchAccountsStatus = () => async dispatch => {
|
11
|
+
try {
|
12
|
+
const {
|
13
|
+
data: { accounts },
|
14
|
+
} = await API.get('accounts');
|
15
|
+
dispatch({
|
16
|
+
type: INVENTORY_ACCOUNT_STATUS_POLLING,
|
17
|
+
payload: {
|
18
|
+
accounts,
|
19
|
+
},
|
20
|
+
});
|
21
|
+
} catch (error) {
|
22
|
+
dispatch({
|
23
|
+
type: INVENTORY_ACCOUNT_STATUS_POLLING_ERROR,
|
24
|
+
payload: {
|
25
|
+
error: error.message,
|
26
|
+
},
|
27
|
+
});
|
28
|
+
}
|
29
|
+
};
|
30
|
+
|
31
|
+
export const startAccountStatusPolling = pollingProcessID => ({
|
32
|
+
type: INVENTORY_ACCOUNT_STATUS_POLLING_START,
|
33
|
+
payload: {
|
34
|
+
pollingProcessID,
|
35
|
+
},
|
36
|
+
});
|
37
|
+
|
38
|
+
export const stopAccountStatusPolling = pollingProcessID => dispatch => {
|
39
|
+
clearInterval(pollingProcessID);
|
40
|
+
dispatch({
|
41
|
+
type: INVENTORY_ACCOUNT_STATUS_POLLING_STOP,
|
42
|
+
});
|
43
|
+
};
|
44
|
+
|
45
|
+
export const restartProcess = (accountID, activeTab) => dispatch => {
|
46
|
+
let processController = null;
|
47
|
+
let processStatusName = null;
|
48
|
+
|
49
|
+
if (activeTab === 'uploading') {
|
50
|
+
processController = 'uploads';
|
51
|
+
processStatusName = 'upload_report_status';
|
52
|
+
} else {
|
53
|
+
processController = 'reports';
|
54
|
+
processStatusName = 'generate_report_status';
|
55
|
+
}
|
56
|
+
|
57
|
+
API.post(`${accountID}/${processController}`);
|
58
|
+
dispatch({
|
59
|
+
type: INVENTORY_PROCESS_RESTART,
|
60
|
+
payload: {
|
61
|
+
accountID,
|
62
|
+
processStatusName,
|
63
|
+
},
|
64
|
+
});
|
65
|
+
};
|
@@ -0,0 +1,9 @@
|
|
1
|
+
export const INVENTORY_ACCOUNT_STATUS_POLLING =
|
2
|
+
'INVENTORY_ACCOUNT_STATUS_POLLING';
|
3
|
+
export const INVENTORY_ACCOUNT_STATUS_POLLING_ERROR =
|
4
|
+
'INVENTORY_ACCOUNT_STATUS_POLLING_ERROR';
|
5
|
+
export const INVENTORY_ACCOUNT_STATUS_POLLING_START =
|
6
|
+
'INVENTORY_ACCOUNT_STATUS_POLLING_START';
|
7
|
+
export const INVENTORY_ACCOUNT_STATUS_POLLING_STOP =
|
8
|
+
'INVENTORY_ACCOUNT_STATUS_POLLING_STOP';
|
9
|
+
export const INVENTORY_PROCESS_RESTART = 'INVENTORY_PROCESS_RESTART';
|
File without changes
|
@@ -0,0 +1,55 @@
|
|
1
|
+
import Immutable from 'seamless-immutable';
|
2
|
+
import {
|
3
|
+
INVENTORY_ACCOUNT_STATUS_POLLING,
|
4
|
+
INVENTORY_ACCOUNT_STATUS_POLLING_ERROR,
|
5
|
+
INVENTORY_ACCOUNT_STATUS_POLLING_START,
|
6
|
+
INVENTORY_PROCESS_RESTART,
|
7
|
+
} from './AccountListConstants';
|
8
|
+
|
9
|
+
const initialState = Immutable({
|
10
|
+
accounts: {},
|
11
|
+
pollingProcessID: 0,
|
12
|
+
error: null,
|
13
|
+
});
|
14
|
+
|
15
|
+
export default (state = initialState, action) => {
|
16
|
+
const {
|
17
|
+
payload: {
|
18
|
+
pollingProcessID,
|
19
|
+
error,
|
20
|
+
accounts,
|
21
|
+
accountID,
|
22
|
+
processStatusName,
|
23
|
+
} = {},
|
24
|
+
} = action;
|
25
|
+
|
26
|
+
switch (action.type) {
|
27
|
+
case INVENTORY_ACCOUNT_STATUS_POLLING:
|
28
|
+
return state.merge({
|
29
|
+
...state,
|
30
|
+
accounts,
|
31
|
+
error: null,
|
32
|
+
});
|
33
|
+
case INVENTORY_ACCOUNT_STATUS_POLLING_ERROR:
|
34
|
+
return state.merge({
|
35
|
+
...state,
|
36
|
+
accounts: {},
|
37
|
+
error,
|
38
|
+
});
|
39
|
+
case INVENTORY_ACCOUNT_STATUS_POLLING_START:
|
40
|
+
return state.merge({
|
41
|
+
...state,
|
42
|
+
pollingProcessID,
|
43
|
+
});
|
44
|
+
case INVENTORY_PROCESS_RESTART:
|
45
|
+
return state.setIn(['accounts'], {
|
46
|
+
...state.accounts,
|
47
|
+
[accountID]: {
|
48
|
+
...state.accounts[accountID],
|
49
|
+
[processStatusName]: 'Restarting...',
|
50
|
+
},
|
51
|
+
});
|
52
|
+
default:
|
53
|
+
return state;
|
54
|
+
}
|
55
|
+
};
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { selectForemanInventoryUpload } from '../../ForemanInventoryUploadSelectors';
|
2
|
+
|
3
|
+
export const selectAccountsList = state =>
|
4
|
+
selectForemanInventoryUpload(state).accountsList;
|
5
|
+
export const selectAccounts = state => selectAccountsList(state).accounts;
|
6
|
+
export const selectPollingProcessID = state =>
|
7
|
+
selectAccountsList(state).pollingProcessID;
|
8
|
+
export const selectError = state => selectAccountsList(state).error;
|
File without changes
|
data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/EmptyState.js
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { EmptyState, Spinner } from 'patternfly-react';
|
3
|
+
import { translate as __ } from 'foremanReact/common/I18n';
|
4
|
+
import './emptyState.scss';
|
5
|
+
|
6
|
+
const inventoryEmptyState = () => (
|
7
|
+
<EmptyState>
|
8
|
+
<Spinner loading inline size="lg" />
|
9
|
+
<EmptyState.Title>
|
10
|
+
{__('Fetching data about your accounts')}
|
11
|
+
</EmptyState.Title>
|
12
|
+
<EmptyState.Info>{__('Loading')}...</EmptyState.Info>
|
13
|
+
</EmptyState>
|
14
|
+
);
|
15
|
+
|
16
|
+
export default inventoryEmptyState;
|
data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/EmptyStateHelper.js
ADDED
File without changes
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
|
2
|
+
|
3
|
+
import EmptyState from '../EmptyState';
|
4
|
+
|
5
|
+
const fixtures = {
|
6
|
+
'render without Props': {},
|
7
|
+
/** fixtures, props for the component */
|
8
|
+
};
|
9
|
+
|
10
|
+
describe('EmptyState', () => {
|
11
|
+
describe('rendering', () =>
|
12
|
+
testComponentSnapshotsWithFixtures(EmptyState, fixtures));
|
13
|
+
});
|
@@ -0,0 +1,26 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`EmptyState rendering render without Props 1`] = `
|
4
|
+
<EmptyState
|
5
|
+
className=""
|
6
|
+
>
|
7
|
+
<Spinner
|
8
|
+
className=""
|
9
|
+
inline={true}
|
10
|
+
inverse={false}
|
11
|
+
loading={true}
|
12
|
+
size="lg"
|
13
|
+
/>
|
14
|
+
<EmptyStateTitle
|
15
|
+
className=""
|
16
|
+
>
|
17
|
+
Fetching data about your accounts
|
18
|
+
</EmptyStateTitle>
|
19
|
+
<EmptyStateInfo
|
20
|
+
className=""
|
21
|
+
>
|
22
|
+
Loading
|
23
|
+
...
|
24
|
+
</EmptyStateInfo>
|
25
|
+
</EmptyState>
|
26
|
+
`;
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './EmptyState';
|
File without changes
|
data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/ErrorState.js
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import { Icon } from 'patternfly-react';
|
4
|
+
import { translate as __ } from 'foremanReact/common/I18n';
|
5
|
+
import './errorState.scss';
|
6
|
+
|
7
|
+
const ErrorState = ({ error }) => (
|
8
|
+
<div className="error_state">
|
9
|
+
<Icon className="error_icon" name="times" size="2x" />
|
10
|
+
<p>{__('Encountered an error while trying to access the server:')}</p>
|
11
|
+
<p className="error_description">{error}</p>
|
12
|
+
</div>
|
13
|
+
);
|
14
|
+
|
15
|
+
ErrorState.propTypes = {
|
16
|
+
error: PropTypes.string,
|
17
|
+
};
|
18
|
+
|
19
|
+
ErrorState.defaultProps = {
|
20
|
+
error: '',
|
21
|
+
};
|
22
|
+
|
23
|
+
export default ErrorState;
|
data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/ErrorStateHelper.js
ADDED
File without changes
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
|
2
|
+
|
3
|
+
import ErrorState from '../ErrorState';
|
4
|
+
|
5
|
+
const fixtures = {
|
6
|
+
'render without Props': {},
|
7
|
+
/** fixtures, props for the component */
|
8
|
+
};
|
9
|
+
|
10
|
+
describe('ErrorState', () => {
|
11
|
+
describe('rendering', () =>
|
12
|
+
testComponentSnapshotsWithFixtures(ErrorState, fixtures));
|
13
|
+
});
|
@@ -0,0 +1,20 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`ErrorState rendering render without Props 1`] = `
|
4
|
+
<div
|
5
|
+
className="error_state"
|
6
|
+
>
|
7
|
+
<Icon
|
8
|
+
className="error_icon"
|
9
|
+
name="times"
|
10
|
+
size="2x"
|
11
|
+
type="fa"
|
12
|
+
/>
|
13
|
+
<p>
|
14
|
+
Encountered an error while trying to access the server:
|
15
|
+
</p>
|
16
|
+
<p
|
17
|
+
className="error_description"
|
18
|
+
/>
|
19
|
+
</div>
|
20
|
+
`;
|
data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/errorState.scss
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
$error_color: #d10d0d;
|
2
|
+
|
3
|
+
.error_state {
|
4
|
+
margin-top: 100px;
|
5
|
+
text-align: center;
|
6
|
+
font-weight: bold;
|
7
|
+
font-size: 16px;
|
8
|
+
|
9
|
+
.error_icon {
|
10
|
+
color: $error_color;
|
11
|
+
margin-right: 15px;
|
12
|
+
margin-bottom: 10px;
|
13
|
+
}
|
14
|
+
|
15
|
+
.error_description {
|
16
|
+
color: $error_color;
|
17
|
+
}
|
18
|
+
}
|