foreman_rh_cloud 1.0.5 → 2.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +8 -0
  3. data/app/controllers/foreman_inventory_upload/accounts_controller.rb +2 -6
  4. data/app/controllers/foreman_rh_cloud/react_controller.rb +8 -0
  5. data/app/models/setting/rh_cloud.rb +1 -0
  6. data/app/views/foreman_rh_cloud/react/inventory_upload.html.erb +1 -0
  7. data/app/views/{foreman_inventory_upload/layouts/react.html.erb → layouts/foreman_rh_cloud/application.html.erb} +2 -2
  8. data/config/routes.rb +4 -1
  9. data/lib/foreman_inventory_upload/async/async_helpers.rb +13 -0
  10. data/lib/foreman_inventory_upload/async/shell_process.rb +3 -1
  11. data/lib/foreman_inventory_upload/async/upload_report_job.rb +1 -5
  12. data/lib/foreman_inventory_upload/generators/fact_helpers.rb +56 -0
  13. data/lib/foreman_inventory_upload/generators/queries.rb +6 -0
  14. data/lib/foreman_inventory_upload/generators/slice.rb +14 -9
  15. data/lib/foreman_rh_cloud/engine.rb +17 -5
  16. data/lib/foreman_rh_cloud/version.rb +1 -1
  17. data/package.json +20 -100
  18. data/test/factories/inventory_upload_factories.rb +13 -13
  19. data/test/unit/archived_report_generator_test.rb +1 -0
  20. data/test/unit/fact_helpers_test.rb +29 -0
  21. data/test/unit/slice_generator_test.rb +206 -20
  22. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js +6 -2
  23. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js +13 -10
  24. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.stories.js +5 -14
  25. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js +3 -2
  26. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListHelper.js +10 -0
  27. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListSelectors.js +1 -1
  28. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/EmptyResults.js +15 -0
  29. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/__tests__/EmptyResults.test.js +13 -0
  30. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/__tests__/__snapshots__/EmptyResults.test.js.snap +18 -0
  31. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/emptyResults.scss +7 -0
  32. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/index.js +1 -0
  33. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/__tests__/EmptyState.test.js +1 -1
  34. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/__tests__/ErrorState.test.js +1 -1
  35. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.js +1 -4
  36. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/ListItem.test.js +1 -1
  37. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/__tests__/ListItemStatus.test.js +1 -1
  38. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountList.test.js +2 -1
  39. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListActions.test.js +1 -1
  40. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListHelper.test.js +12 -0
  41. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListIntegration.test.js +2 -2
  42. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListReducer.test.js +1 -1
  43. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListSelectors.test.js +8 -9
  44. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountList.test.js.snap +2 -3
  45. data/webpack/ForemanInventoryUpload/Components/AccountList/index.js +2 -0
  46. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcherActions.js +4 -1
  47. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/AutoUploadSwitcher.test.js +1 -1
  48. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/AutoUploadSwitcherActions.test.js +1 -1
  49. data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.fixtures.js +13 -9
  50. data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.stories.js +5 -15
  51. data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardActions.js +4 -3
  52. data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardSelectors.js +1 -1
  53. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/Dashboard.test.js +1 -2
  54. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js +17 -5
  55. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardIntegration.test.js +2 -2
  56. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardReducer.test.js +1 -1
  57. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardSelectors.test.js +4 -3
  58. data/webpack/ForemanInventoryUpload/Components/FileDownload/__tests__/FileDownload.test.js +1 -1
  59. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/__tests__/FullScreenModal.test.js +1 -1
  60. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/Components/ClearButton/ClearButton.js +26 -0
  61. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/Components/ClearButton/index.js +1 -0
  62. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.fixtures.js +2 -0
  63. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js +39 -0
  64. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterActions.js +16 -0
  65. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterConstants.js +3 -0
  66. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterReducer.js +36 -0
  67. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterSelectors.js +7 -0
  68. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilter.test.js +14 -0
  69. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterActions.test.js +14 -0
  70. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterReducer.test.js +35 -0
  71. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterSelectors.test.js +21 -0
  72. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilter.test.js.snap +25 -0
  73. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterActions.test.js.snap +17 -0
  74. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterReducer.test.js.snap +25 -0
  75. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterSelectors.test.js.snap +9 -0
  76. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/integration.test.js.snap +31 -0
  77. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/integration.test.js +18 -0
  78. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/index.js +17 -0
  79. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/inventoryFilter.scss +28 -0
  80. data/webpack/ForemanInventoryUpload/Components/NavContainer/NavContainer.fixtures.js +5 -2
  81. data/webpack/ForemanInventoryUpload/Components/NavContainer/__tests__/NavContainer.test.js +1 -2
  82. data/webpack/ForemanInventoryUpload/Components/NavContainer/__tests__/__snapshots__/NavContainer.test.js.snap +1 -1
  83. data/webpack/ForemanInventoryUpload/Components/PageHeader/PageHeader.js +12 -3
  84. data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/PageHeader.test.js +1 -1
  85. data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageHeader.test.js.snap +11 -2
  86. data/webpack/ForemanInventoryUpload/Components/PageHeader/pageHeader.scss +3 -0
  87. data/webpack/ForemanInventoryUpload/Components/ReportGenerate/__tests__/ReportGenerate.test.js +1 -1
  88. data/webpack/ForemanInventoryUpload/Components/ReportUpload/__tests__/ReportUpload.test.js +1 -1
  89. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/__tests__/ScheduledRun.test.js +1 -1
  90. data/webpack/ForemanInventoryUpload/Components/StatusChart/__tests__/StatusChart.test.js +1 -1
  91. data/webpack/ForemanInventoryUpload/Components/TabBody/__tests__/TabBody.test.js +1 -1
  92. data/webpack/ForemanInventoryUpload/Components/TabContainer/__tests__/TabContainer.test.js +1 -1
  93. data/webpack/ForemanInventoryUpload/Components/TabFooter/__tests__/TabFooter.test.js +1 -1
  94. data/webpack/ForemanInventoryUpload/Components/TabHeader/__tests__/TabHeader.test.js +1 -1
  95. data/webpack/ForemanInventoryUpload/Components/Terminal/Terminal.js +1 -1
  96. data/webpack/ForemanInventoryUpload/Components/Terminal/__tests__/Terminal.test.js +1 -2
  97. data/webpack/ForemanInventoryUpload/ForemanInventoryConstants.js +3 -0
  98. data/webpack/ForemanInventoryUpload/ForemanInventoryHelpers.js +4 -0
  99. data/webpack/ForemanInventoryUpload/ForemanInventoryUpload.js +16 -8
  100. data/webpack/ForemanInventoryUpload/ForemanInventoryUploadReducers.js +4 -4
  101. data/webpack/ForemanInventoryUpload/__tests__/ForemanInventoryHelpers.test.js +9 -0
  102. data/webpack/ForemanInventoryUpload/{ForemanInventoryUpload.test.js → __tests__/ForemanInventoryUpload.test.js} +2 -2
  103. data/webpack/ForemanInventoryUpload/__tests__/__snapshots__/ForemanInventoryHelpers.test.js.snap +3 -0
  104. data/webpack/ForemanInventoryUpload/{__snapshots__ → __tests__/__snapshots__}/ForemanInventoryUpload.test.js.snap +0 -0
  105. data/webpack/ForemanRhCloudHelpers.js +6 -0
  106. data/webpack/ForemanRhCloudReducers.js +8 -0
  107. data/webpack/ForemanRhCloudSelectors.js +3 -0
  108. data/webpack/ForemanRhCloudTestHelpers.js +5 -0
  109. data/webpack/__mocks__/foremanReact/components/Layout/LayoutConstants.js +1 -0
  110. data/webpack/__tests__/ForemanRhCloudHelpers.test.js +11 -0
  111. data/webpack/__tests__/ForemanRhCloudSelectors.test.js +17 -0
  112. data/webpack/__tests__/ForemanRhCloudTestHelpers.test.js +10 -0
  113. data/webpack/__tests__/__snapshots__/ForemanRhCloudHelpers.test.js.snap +3 -0
  114. data/webpack/__tests__/__snapshots__/ForemanRhCloudSelectors.test.js.snap +15 -0
  115. data/webpack/__tests__/__snapshots__/ForemanRhCloudTestHelpers.test.js.snap +11 -0
  116. data/webpack/index.js +1 -1
  117. metadata +52 -14
  118. data/app/controllers/foreman_inventory_upload/react_controller.rb +0 -7
  119. data/webpack/ForemanInventoryUpload/ForemanInventoryUploadSelectors.js +0 -4
  120. data/webpack/stories/ForemanInventoryUploadReducers.js +0 -3
  121. data/webpack/stories/configureStore.js +0 -15
  122. data/webpack/stories/decorators/index.js +0 -1
  123. data/webpack/stories/decorators/withCardsDecorator.js +0 -14
  124. data/webpack/stories/index.js +0 -10
  125. data/webpack/stories/index.scss +0 -7
  126. data/webpack/test_setup.js +0 -6
@@ -4,6 +4,8 @@ import PropTypes from 'prop-types';
4
4
  import ListItem from './Components/ListItem';
5
5
  import EmptyState from './Components/EmptyState';
6
6
  import ErrorState from './Components/ErrorState';
7
+ import EmptyResults from './Components/EmptyResults';
8
+ import { filterAccounts } from './AccountListHelper';
7
9
  import './accountList.scss';
8
10
 
9
11
  class AccountList extends Component {
@@ -20,8 +22,9 @@ class AccountList extends Component {
20
22
  }
21
23
 
22
24
  render() {
23
- const { accounts, error } = this.props;
25
+ const { accounts, error, filterTerm } = this.props;
24
26
  const accountIds = Object.keys(accounts);
27
+ const filteredAccountIds = filterAccounts(accounts, accountIds, filterTerm);
25
28
 
26
29
  if (error) {
27
30
  return <ErrorState error={error} />;
@@ -30,16 +33,14 @@ class AccountList extends Component {
30
33
  if (accountIds.length === 0) {
31
34
  return <EmptyState />;
32
35
  }
33
- const items = accountIds.map((accountID, index) => {
36
+
37
+ if (filteredAccountIds.length === 0) {
38
+ return <EmptyResults />;
39
+ }
40
+
41
+ const items = filteredAccountIds.map((accountID, index) => {
34
42
  const account = accounts[accountID];
35
- return (
36
- <ListItem
37
- key={index}
38
- accountID={accountID}
39
- account={account}
40
- initExpanded={index === 0}
41
- />
42
- );
43
+ return <ListItem key={index} accountID={accountID} account={account} />;
43
44
  });
44
45
  return <ListView className="account_list">{items}</ListView>;
45
46
  }
@@ -56,6 +57,7 @@ AccountList.propTypes = {
56
57
  }),
57
58
  accounts: PropTypes.object,
58
59
  error: PropTypes.string,
60
+ filterTerm: PropTypes.string,
59
61
  };
60
62
 
61
63
  AccountList.defaultProps = {
@@ -69,6 +71,7 @@ AccountList.defaultProps = {
69
71
  },
70
72
  accounts: {},
71
73
  error: '',
74
+ filterTerm: null,
72
75
  };
73
76
 
74
77
  export default AccountList;
@@ -1,18 +1,9 @@
1
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
2
  import AccountList from './AccountList';
7
3
 
8
- const store = configureStore();
4
+ export default {
5
+ title: 'AccountList',
6
+ component: AccountList,
7
+ };
9
8
 
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
- ));
9
+ export const Basic = () => <AccountList />;
@@ -1,4 +1,5 @@
1
1
  import API from 'foremanReact/API';
2
+ import { inventoryUrl } from '../../ForemanInventoryHelpers';
2
3
  import {
3
4
  INVENTORY_ACCOUNT_STATUS_POLLING,
4
5
  INVENTORY_ACCOUNT_STATUS_POLLING_ERROR,
@@ -11,7 +12,7 @@ export const fetchAccountsStatus = () => async dispatch => {
11
12
  try {
12
13
  const {
13
14
  data: { accounts, autoUploadEnabled },
14
- } = await API.get('accounts');
15
+ } = await API.get(inventoryUrl('accounts'));
15
16
  dispatch({
16
17
  type: INVENTORY_ACCOUNT_STATUS_POLLING,
17
18
  payload: {
@@ -55,7 +56,7 @@ export const restartProcess = (accountID, activeTab) => dispatch => {
55
56
  processStatusName = 'generate_report_status';
56
57
  }
57
58
 
58
- API.post(`${accountID}/${processController}`);
59
+ API.post(inventoryUrl(`${accountID}/${processController}`));
59
60
  dispatch({
60
61
  type: INVENTORY_PROCESS_RESTART,
61
62
  payload: {
@@ -0,0 +1,10 @@
1
+ export const filterAccounts = (accounts, accountIds, filterTerm) => {
2
+ if (!filterTerm || !accountIds.length) {
3
+ return accountIds;
4
+ }
5
+
6
+ const filterTermLowerCased = filterTerm.toLowerCase();
7
+ return accountIds.filter(id =>
8
+ accounts[id].label.toLowerCase().includes(filterTermLowerCased)
9
+ );
10
+ };
@@ -1,4 +1,4 @@
1
- import { selectForemanInventoryUpload } from '../../ForemanInventoryUploadSelectors';
1
+ import { selectForemanInventoryUpload } from '../../../ForemanRhCloudSelectors';
2
2
 
3
3
  export const selectAccountsList = state =>
4
4
  selectForemanInventoryUpload(state).accountsList;
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { EmptyState, Icon } from 'patternfly-react';
3
+ import { translate as __ } from 'foremanReact/common/I18n';
4
+ import './emptyResults.scss';
5
+
6
+ const inventoryEmptyResults = () => (
7
+ <EmptyState>
8
+ <EmptyState.Title>
9
+ <Icon className="no_results_icon" name="meh-o" />
10
+ {__("Oops! Couldn't find organization that matches your query")}
11
+ </EmptyState.Title>
12
+ </EmptyState>
13
+ );
14
+
15
+ export default inventoryEmptyResults;
@@ -0,0 +1,13 @@
1
+ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
+
3
+ import EmptyResults from '../EmptyResults';
4
+
5
+ const fixtures = {
6
+ 'render without Props': {},
7
+ /** fixtures, props for the component */
8
+ };
9
+
10
+ describe('EmptyResults', () => {
11
+ describe('rendering', () =>
12
+ testComponentSnapshotsWithFixtures(EmptyResults, fixtures));
13
+ });
@@ -0,0 +1,18 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`EmptyResults rendering render without Props 1`] = `
4
+ <EmptyState
5
+ className=""
6
+ >
7
+ <EmptyStateTitle
8
+ className=""
9
+ >
10
+ <Icon
11
+ className="no_results_icon"
12
+ name="meh-o"
13
+ type="fa"
14
+ />
15
+ Oops! Couldn't find organization that matches your query
16
+ </EmptyStateTitle>
17
+ </EmptyState>
18
+ `;
@@ -0,0 +1,7 @@
1
+ .blank-slate-pf {
2
+ margin-top: 100px;
3
+
4
+ .no_results_icon {
5
+ margin-right: 5px;
6
+ }
7
+ }
@@ -0,0 +1 @@
1
+ export { default } from './EmptyResults';
@@ -1,4 +1,4 @@
1
- import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
1
+ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
2
 
3
3
  import EmptyState from '../EmptyState';
4
4
 
@@ -1,4 +1,4 @@
1
- import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
1
+ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
2
 
3
3
  import ErrorState from '../ErrorState';
4
4
 
@@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
4
4
  import ListItemStatus from '../ListItemStatus';
5
5
  import Dashboard from '../../../Dashboard';
6
6
 
7
- const ListItem = ({ accountID, account, initExpanded }) => (
7
+ const ListItem = ({ accountID, account }) => (
8
8
  <ListView.Item
9
9
  leftContent={<ListView.Icon name="user" />}
10
10
  heading={account.label}
@@ -13,7 +13,6 @@ const ListItem = ({ accountID, account, initExpanded }) => (
13
13
  ]}
14
14
  stacked
15
15
  hideCloseIcon
16
- initExpanded={initExpanded}
17
16
  >
18
17
  <Dashboard accountID={accountID} account={account} />
19
18
  </ListView.Item>
@@ -26,7 +25,6 @@ ListItem.propTypes = {
26
25
  upload_report_status: PropTypes.string,
27
26
  label: PropTypes.string,
28
27
  }),
29
- initExpanded: PropTypes.bool,
30
28
  };
31
29
 
32
30
  ListItem.defaultProps = {
@@ -35,7 +33,6 @@ ListItem.defaultProps = {
35
33
  upload_report_status: 'unknown',
36
34
  label: 'default_org_name',
37
35
  },
38
- initExpanded: false,
39
36
  };
40
37
 
41
38
  export default ListItem;
@@ -1,4 +1,4 @@
1
- import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
1
+ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
2
 
3
3
  import ListItem from '../ListItem';
4
4
  import { props } from '../ListItem.fixtures';
@@ -1,4 +1,4 @@
1
- import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
1
+ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
2
 
3
3
  import ListItemStatus from '../ListItemStatus';
4
4
  import { props } from '../ListItemStatus.fixtures';
@@ -1,10 +1,11 @@
1
- import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
1
+ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
2
 
3
3
  import AccountList from '../AccountList';
4
4
  import { props } from '../AccountList.fixtures';
5
5
 
6
6
  const fixtures = {
7
7
  'render with props': props,
8
+ 'show empty results': { ...props, filterTerm: 'not_matching_term' },
8
9
  };
9
10
 
10
11
  describe('AccountList', () => {
@@ -1,4 +1,4 @@
1
- import { testActionSnapshotWithFixtures } from 'react-redux-test-utils';
1
+ import { testActionSnapshotWithFixtures } from '@theforeman/test';
2
2
  import {
3
3
  fetchAccountsStatus,
4
4
  startAccountStatusPolling,
@@ -0,0 +1,12 @@
1
+ import { filterAccounts } from '../AccountListHelper';
2
+ import { accounts, accountIDs } from '../AccountList.fixtures';
3
+
4
+ describe('AccountList helpers', () => {
5
+ it('account ids filter should return all accounts where label contains "test"', () => {
6
+ expect(filterAccounts(accounts, accountIDs, 'test')).toEqual(accountIDs);
7
+ });
8
+
9
+ it('account ids filter should not match', () => {
10
+ expect(filterAccounts(accounts, accountIDs, 'no_match')).toEqual([]);
11
+ });
12
+ });
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
- import { IntegrationTestHelper } from 'react-redux-test-utils';
2
+ import { IntegrationTestHelper } from '@theforeman/test';
3
3
 
4
4
  import AccountList from '../index';
5
- import reducers from '../../../ForemanInventoryUploadReducers';
5
+ import reducers from '../../../../ForemanRhCloudReducers';
6
6
 
7
7
  describe('AccountList integration test', () => {
8
8
  it('should flow', async () => {
@@ -1,4 +1,4 @@
1
- import { testReducerSnapshotWithFixtures } from 'react-redux-test-utils';
1
+ import { testReducerSnapshotWithFixtures } from '@theforeman/test';
2
2
 
3
3
  import {
4
4
  INVENTORY_ACCOUNT_STATUS_POLLING,
@@ -1,4 +1,4 @@
1
- import { testSelectorsSnapshotWithFixtures } from 'react-redux-test-utils';
1
+ import { testSelectorsSnapshotWithFixtures } from '@theforeman/test';
2
2
  import {
3
3
  selectAccountsList,
4
4
  selectAccounts,
@@ -10,16 +10,15 @@ import {
10
10
  accounts,
11
11
  autoUploadEnabled,
12
12
  } from '../AccountList.fixtures';
13
+ import { inventoryStateWrapper } from '../../../../ForemanRhCloudTestHelpers';
13
14
 
14
- const state = {
15
- ForemanInventoryUpload: {
16
- accountsList: {
17
- accounts,
18
- pollingProcessID,
19
- autoUploadEnabled,
20
- },
15
+ const state = inventoryStateWrapper({
16
+ accountsList: {
17
+ accounts,
18
+ pollingProcessID,
19
+ autoUploadEnabled,
21
20
  },
22
- };
21
+ });
23
22
 
24
23
  const fixtures = {
25
24
  'should return AccountsList': () => selectAccountsList(state),
@@ -13,7 +13,6 @@ exports[`AccountList rendering render with props 1`] = `
13
13
  }
14
14
  }
15
15
  accountID="Account1"
16
- initExpanded={true}
17
16
  key="0"
18
17
  />
19
18
  <ListItem
@@ -25,7 +24,6 @@ exports[`AccountList rendering render with props 1`] = `
25
24
  }
26
25
  }
27
26
  accountID="Account2"
28
- initExpanded={false}
29
27
  key="1"
30
28
  />
31
29
  <ListItem
@@ -37,8 +35,9 @@ exports[`AccountList rendering render with props 1`] = `
37
35
  }
38
36
  }
39
37
  accountID="Account3"
40
- initExpanded={false}
41
38
  key="2"
42
39
  />
43
40
  </ListView>
44
41
  `;
42
+
43
+ exports[`AccountList rendering show empty results 1`] = `<inventoryEmptyResults />`;
@@ -9,12 +9,14 @@ import {
9
9
  selectPollingProcessID,
10
10
  selectError,
11
11
  } from './AccountListSelectors';
12
+ import { selectFilterTerm } from '../InventoryFilter/InventoryFilterSelectors';
12
13
 
13
14
  // map state to props
14
15
  const mapStateToProps = state => ({
15
16
  accounts: selectAccounts(state),
16
17
  pollingProcessID: selectPollingProcessID(state),
17
18
  error: selectError(state),
19
+ filterTerm: selectFilterTerm(state),
18
20
  });
19
21
 
20
22
  // map action dispatchers to props
@@ -1,4 +1,5 @@
1
1
  import API from 'foremanReact/API';
2
+ import { inventoryUrl } from '../../ForemanInventoryHelpers';
2
3
  import {
3
4
  AUTO_UPLOAD_TOGGLE,
4
5
  AUTO_UPLOAD_TOGGLE_ERROR,
@@ -9,7 +10,9 @@ export const handleToggle = currentAutoUploadEnabled => async dispatch => {
9
10
  try {
10
11
  const {
11
12
  data: { autoUploadEnabled },
12
- } = await API.post('auto_upload', { value: toggledAutoUploadEnabled });
13
+ } = await API.post(inventoryUrl('auto_upload'), {
14
+ value: toggledAutoUploadEnabled,
15
+ });
13
16
  dispatch({
14
17
  type: AUTO_UPLOAD_TOGGLE,
15
18
  payload: {
@@ -1,4 +1,4 @@
1
- import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
1
+ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
2
  import { noop } from 'patternfly-react';
3
3
 
4
4
  import AutoUploadSwitcher from '../AutoUploadSwitcher';
@@ -1,4 +1,4 @@
1
- import { testActionSnapshotWithFixtures } from 'react-redux-test-utils';
1
+ import { testActionSnapshotWithFixtures } from '@theforeman/test';
2
2
  import API from 'foremanReact/API';
3
3
  import { handleToggle } from '../AutoUploadSwitcherActions';
4
4
  import { handleToggleResponse } from '../AutoUploadSwitcher.fixtures';
@@ -8,16 +8,20 @@ export const completed = 25;
8
8
 
9
9
  export const error = 'some-error';
10
10
 
11
+ export const generating = {
12
+ logs,
13
+ completed,
14
+ };
15
+
16
+ export const uploading = {
17
+ logs,
18
+ completed,
19
+ files,
20
+ };
21
+
11
22
  export const inventory = {
12
- generating: {
13
- logs,
14
- completed,
15
- },
16
- uploading: {
17
- logs,
18
- completed,
19
- files,
20
- },
23
+ generating,
24
+ uploading,
21
25
  };
22
26
 
23
27
  export const accountID = 'some-account-ID';
@@ -1,19 +1,9 @@
1
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
2
  import Dashboard from './index';
7
- import { generating, uploading } from './Dashboard.fixtures';
8
3
 
9
- const store = configureStore();
4
+ export default {
5
+ title: 'Dashboard',
6
+ component: Dashboard,
7
+ };
10
8
 
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
- ));
9
+ export const Basic = () => <Dashboard />;