foreman_rh_cloud 1.0.17 → 1.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/foreman_inventory_upload/accounts_controller.rb +2 -2
  3. data/app/controllers/foreman_inventory_upload/uploads_controller.rb +1 -8
  4. data/lib/foreman_inventory_upload.rb +2 -1
  5. data/lib/foreman_inventory_upload/generators/json_stream.rb +1 -1
  6. data/lib/foreman_rh_cloud/version.rb +1 -1
  7. data/package.json +1 -1
  8. data/test/controllers/accounts_controller_test.rb +1 -1
  9. data/test/unit/slice_generator_test.rb +1 -1
  10. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js +3 -3
  11. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js +7 -7
  12. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListHelper.js +6 -6
  13. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.fixtures.js +10 -1
  14. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.js +7 -7
  15. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/__snapshots__/ListItem.test.js.snap +11 -8
  16. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListHelper.test.js +3 -3
  17. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountList.test.js.snap +6 -6
  18. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListActions.test.js.snap +3 -3
  19. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListReducer.test.js.snap +3 -3
  20. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListSelectors.test.js.snap +6 -6
  21. data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardActions.js +1 -1
  22. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js +14 -1
  23. metadata +16 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0724cdfa4e0563ba9b2cbab222198ab8dd921527f8c31d1136795a158b659038
4
- data.tar.gz: 7bc88ae8db51b586e7e4d6d8e05baf16dc782f86626e059aecacece43adbd4d8
3
+ metadata.gz: 222e7f5392e6276d4c38fdeb9bdbbf1078bcbbbc10bbf4aa3eb841ed1395bff9
4
+ data.tar.gz: 746a4388499f65ad2691188ccb36e0936486222ed7a278bb90e35ce27adff85f
5
5
  SHA512:
6
- metadata.gz: 0e7e3dd16635ecbac89f7ad2cb2f62a59c29b71108e323dee2c050a9aedf62b7c1a304a977fe589322ae18044f5f2ffdbb1e22eb07ad9ee3e9e67045fa3d4614
7
- data.tar.gz: 46f916e376facb3b487eb125e65916efca85b51c40c7ff4f090758e677ac37638cf81f07dec0e3279a61c67455d4c966948a6343eb4a26ed20ef3e76e0a3fafa
6
+ metadata.gz: 19504446398f9dca2bee75c9a89265fc9b67b24e43b018c516a0fbc8351f7e4f888f3c4295606049ea15390b8291599401913cfc8d974ca0d86be9029ff2a5f8
7
+ data.tar.gz: ce53ae2e0a0b1eba451d8e7b498fbd7c50257416c5604ae57df4cfbab6e5815e2cf91ddfd1f3ffa0b89933201dd01f68904fe7e50514a042a4685ddffdbc35f7
@@ -10,11 +10,11 @@ module ForemanInventoryUpload
10
10
  upload_report_status = status_for(id, ForemanInventoryUpload::Async::UploadReportJob)
11
11
 
12
12
  [
13
- id,
13
+ label,
14
14
  {
15
15
  generate_report_status: generate_report_status,
16
16
  upload_report_status: upload_report_status,
17
- label: label,
17
+ id: id,
18
18
  },
19
19
  ]
20
20
  end
@@ -14,14 +14,7 @@ module ForemanInventoryUpload
14
14
  files = Dir["{#{ForemanInventoryUpload.uploads_file_path(filename)},#{ForemanInventoryUpload.done_file_path(filename)}}"]
15
15
 
16
16
  return send_file files.first, disposition: 'attachment', filename: filename unless files.empty?
17
- throw_flash_error "File doesn't exist"
18
- end
19
-
20
- def throw_flash_error(message)
21
- process_error(
22
- :redirect => foreman_inventory_upload_index_path,
23
- :error_msg => message
24
- )
17
+ raise ::Foreman::Exception.new("The report file doesn't exist")
25
18
  end
26
19
 
27
20
  def auto_upload
@@ -62,6 +62,7 @@ module ForemanInventoryUpload
62
62
  end
63
63
 
64
64
  def self.inventory_export_url
65
- ForemanRhCloud.base_url + '/api/inventory/v1/hosts'
65
+ tags = URI.encode("satellite/satellite_instance_id=#{Foreman.instance_id}")
66
+ ForemanRhCloud.base_url + "/api/inventory/v1/hosts?tags=#{tags}"
66
67
  end
67
68
  end
@@ -63,7 +63,7 @@ module ForemanInventoryUpload
63
63
  return value if value.is_a?(FalseClass)
64
64
  return value.to_json if value.is_a?(Hash)
65
65
 
66
- "\"#{value}\""
66
+ ActiveSupport::JSON.encode(value)
67
67
  end
68
68
  end
69
69
  end
@@ -1,3 +1,3 @@
1
1
  module ForemanRhCloud
2
- VERSION = '1.0.17'.freeze
2
+ VERSION = '1.0.18'.freeze
3
3
  end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foreman_rh_cloud",
3
- "version": "1.0.17",
3
+ "version": "1.0.18",
4
4
  "description": "Inventory Upload =============",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -21,7 +21,7 @@ class AccountsControllerTest < ActionController::TestCase
21
21
 
22
22
  assert_response :success
23
23
  actual = JSON.parse(response.body)
24
- actual_account_statuses = actual['accounts'][test_org.id.to_s]
24
+ actual_account_statuses = actual['accounts'][test_org.label]
25
25
  assert_equal 'generate_status_test', actual_account_statuses['generate_report_status']
26
26
  assert_equal 'upload_status_test', actual_account_statuses['upload_report_status']
27
27
 
@@ -290,7 +290,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
290
290
  end
291
291
 
292
292
  test 'generates a report with satellite facts' do
293
- hostgroup = FactoryBot.create(:hostgroup)
293
+ hostgroup = FactoryBot.create(:hostgroup, name: 'Special"name')
294
294
  @host.hostgroup = hostgroup
295
295
  @host.save!
296
296
 
@@ -2,17 +2,17 @@ import { noop } from 'patternfly-react';
2
2
 
3
3
  export const accounts = {
4
4
  Account1: {
5
- label: 'test_org1',
5
+ id: 1,
6
6
  upload_report_status: 'running',
7
7
  generate_report_status: 'running',
8
8
  },
9
9
  Account2: {
10
- label: 'test_org2',
10
+ id: 2,
11
11
  upload_report_status: 'unknown',
12
12
  generate_report_status: 'failure',
13
13
  },
14
14
  Account3: {
15
- label: 'test_org3',
15
+ id: 3,
16
16
  upload_report_status: 'success',
17
17
  generate_report_status: 'running',
18
18
  },
@@ -1,5 +1,6 @@
1
1
  import React, { Component } from 'react';
2
2
  import { ListView, noop } from 'patternfly-react';
3
+ import { isEmpty } from 'lodash';
3
4
  import PropTypes from 'prop-types';
4
5
  import ListItem from './Components/ListItem';
5
6
  import EmptyState from './Components/EmptyState';
@@ -23,24 +24,23 @@ class AccountList extends Component {
23
24
 
24
25
  render() {
25
26
  const { accounts, error, filterTerm } = this.props;
26
- const accountIds = Object.keys(accounts);
27
- const filteredAccountIds = filterAccounts(accounts, accountIds, filterTerm);
27
+ const filteredAccount = filterAccounts(accounts, filterTerm);
28
28
 
29
29
  if (error) {
30
30
  return <ErrorState error={error} />;
31
31
  }
32
32
 
33
- if (accountIds.length === 0) {
33
+ if (isEmpty(accounts)) {
34
34
  return <EmptyState />;
35
35
  }
36
36
 
37
- if (filteredAccountIds.length === 0) {
37
+ if (isEmpty(filteredAccount)) {
38
38
  return <EmptyResults />;
39
39
  }
40
40
 
41
- const items = filteredAccountIds.map((accountID, index) => {
42
- const account = accounts[accountID];
43
- return <ListItem key={index} accountID={accountID} account={account} />;
41
+ const items = Object.keys(filteredAccount).map((label, index) => {
42
+ const account = accounts[label];
43
+ return <ListItem key={index} label={label} account={account} />;
44
44
  });
45
45
  return <ListView className="account_list">{items}</ListView>;
46
46
  }
@@ -1,10 +1,10 @@
1
- export const filterAccounts = (accounts, accountIds, filterTerm) => {
2
- if (!filterTerm || !accountIds.length) {
3
- return accountIds;
4
- }
1
+ import { pickBy } from 'lodash';
2
+
3
+ export const filterAccounts = (accounts, filterTerm) => {
4
+ if (!filterTerm) return accounts;
5
5
 
6
6
  const filterTermLowerCased = filterTerm.toLowerCase();
7
- return accountIds.filter(id =>
8
- accounts[id].label.toLowerCase().includes(filterTermLowerCased)
7
+ return pickBy(accounts, (value, key) =>
8
+ key.toLowerCase().includes(filterTermLowerCased)
9
9
  );
10
10
  };
@@ -1 +1,10 @@
1
- export const props = { accountID: '1' };
1
+ export const props = {
2
+ label: 'test',
3
+ account: {
4
+ test: {
5
+ generate_report_status: 'unknown',
6
+ upload_report_status: 'unknown',
7
+ id: 1,
8
+ },
9
+ },
10
+ };
@@ -4,26 +4,26 @@ import PropTypes from 'prop-types';
4
4
  import ListItemStatus from '../ListItemStatus';
5
5
  import Dashboard from '../../../Dashboard';
6
6
 
7
- const ListItem = ({ accountID, account }) => (
7
+ const ListItem = ({ label, account }) => (
8
8
  <ListView.Item
9
9
  leftContent={<ListView.Icon name="user" />}
10
- heading={account.label}
10
+ heading={label}
11
11
  additionalInfo={[
12
- <ListItemStatus key={`${accountID}_status`} account={account} />,
12
+ <ListItemStatus key={`${label}_status`} account={account} />,
13
13
  ]}
14
14
  stacked
15
15
  hideCloseIcon
16
16
  >
17
- <Dashboard accountID={accountID} account={account} />
17
+ <Dashboard accountID={account.id} account={account} />
18
18
  </ListView.Item>
19
19
  );
20
20
 
21
21
  ListItem.propTypes = {
22
- accountID: PropTypes.string.isRequired,
22
+ label: PropTypes.string.isRequired,
23
23
  account: PropTypes.shape({
24
24
  generate_report_status: PropTypes.string,
25
25
  upload_report_status: PropTypes.string,
26
- label: PropTypes.string,
26
+ id: PropTypes.number,
27
27
  }),
28
28
  };
29
29
 
@@ -31,7 +31,7 @@ ListItem.defaultProps = {
31
31
  account: {
32
32
  generate_report_status: 'unknown',
33
33
  upload_report_status: 'unknown',
34
- label: 'default_org_name',
34
+ id: 0,
35
35
  },
36
36
  };
37
37
 
@@ -8,9 +8,11 @@ exports[`ListItem rendering render with Props 1`] = `
8
8
  <ListItemStatus
9
9
  account={
10
10
  Object {
11
- "generate_report_status": "unknown",
12
- "label": "default_org_name",
13
- "upload_report_status": "unknown",
11
+ "test": Object {
12
+ "generate_report_status": "unknown",
13
+ "id": 1,
14
+ "upload_report_status": "unknown",
15
+ },
14
16
  }
15
17
  }
16
18
  />,
@@ -20,7 +22,7 @@ exports[`ListItem rendering render with Props 1`] = `
20
22
  compoundExpand={false}
21
23
  compoundExpanded={false}
22
24
  description={null}
23
- heading="default_org_name"
25
+ heading="test"
24
26
  hideCloseIcon={true}
25
27
  initExpanded={false}
26
28
  leftContent={
@@ -39,12 +41,13 @@ exports[`ListItem rendering render with Props 1`] = `
39
41
  <Connect(Dashboard)
40
42
  account={
41
43
  Object {
42
- "generate_report_status": "unknown",
43
- "label": "default_org_name",
44
- "upload_report_status": "unknown",
44
+ "test": Object {
45
+ "generate_report_status": "unknown",
46
+ "id": 1,
47
+ "upload_report_status": "unknown",
48
+ },
45
49
  }
46
50
  }
47
- accountID="1"
48
51
  />
49
52
  </ListViewItem>
50
53
  `;
@@ -1,12 +1,12 @@
1
1
  import { filterAccounts } from '../AccountListHelper';
2
- import { accounts, accountIDs } from '../AccountList.fixtures';
2
+ import { accounts } from '../AccountList.fixtures';
3
3
 
4
4
  describe('AccountList helpers', () => {
5
5
  it('account ids filter should return all accounts where label contains "test"', () => {
6
- expect(filterAccounts(accounts, accountIDs, 'test')).toEqual(accountIDs);
6
+ expect(filterAccounts(accounts, 'AcCoUnT')).toEqual(accounts);
7
7
  });
8
8
 
9
9
  it('account ids filter should not match', () => {
10
- expect(filterAccounts(accounts, accountIDs, 'no_match')).toEqual([]);
10
+ expect(filterAccounts(accounts, 'no_match')).toEqual({});
11
11
  });
12
12
  });
@@ -8,34 +8,34 @@ exports[`AccountList rendering render with props 1`] = `
8
8
  account={
9
9
  Object {
10
10
  "generate_report_status": "running",
11
- "label": "test_org1",
11
+ "id": 1,
12
12
  "upload_report_status": "running",
13
13
  }
14
14
  }
15
- accountID="Account1"
16
15
  key="0"
16
+ label="Account1"
17
17
  />
18
18
  <ListItem
19
19
  account={
20
20
  Object {
21
21
  "generate_report_status": "failure",
22
- "label": "test_org2",
22
+ "id": 2,
23
23
  "upload_report_status": "unknown",
24
24
  }
25
25
  }
26
- accountID="Account2"
27
26
  key="1"
27
+ label="Account2"
28
28
  />
29
29
  <ListItem
30
30
  account={
31
31
  Object {
32
32
  "generate_report_status": "running",
33
- "label": "test_org3",
33
+ "id": 3,
34
34
  "upload_report_status": "success",
35
35
  }
36
36
  }
37
- accountID="Account3"
38
37
  key="2"
38
+ label="Account3"
39
39
  />
40
40
  </ListView>
41
41
  `;
@@ -8,17 +8,17 @@ Array [
8
8
  "accounts": Object {
9
9
  "Account1": Object {
10
10
  "generate_report_status": "running",
11
- "label": "test_org1",
11
+ "id": 1,
12
12
  "upload_report_status": "running",
13
13
  },
14
14
  "Account2": Object {
15
15
  "generate_report_status": "failure",
16
- "label": "test_org2",
16
+ "id": 2,
17
17
  "upload_report_status": "unknown",
18
18
  },
19
19
  "Account3": Object {
20
20
  "generate_report_status": "running",
21
- "label": "test_org3",
21
+ "id": 3,
22
22
  "upload_report_status": "success",
23
23
  },
24
24
  },
@@ -23,17 +23,17 @@ Object {
23
23
  "accounts": Object {
24
24
  "Account1": Object {
25
25
  "generate_report_status": "running",
26
- "label": "test_org1",
26
+ "id": 1,
27
27
  "upload_report_status": "running",
28
28
  },
29
29
  "Account2": Object {
30
30
  "generate_report_status": "failure",
31
- "label": "test_org2",
31
+ "id": 2,
32
32
  "upload_report_status": "unknown",
33
33
  },
34
34
  "Account3": Object {
35
35
  "generate_report_status": "running",
36
- "label": "test_org3",
36
+ "id": 3,
37
37
  "upload_report_status": "success",
38
38
  },
39
39
  },
@@ -4,17 +4,17 @@ exports[`AccountList selectors should return AccountList accounts 1`] = `
4
4
  Object {
5
5
  "Account1": Object {
6
6
  "generate_report_status": "running",
7
- "label": "test_org1",
7
+ "id": 1,
8
8
  "upload_report_status": "running",
9
9
  },
10
10
  "Account2": Object {
11
11
  "generate_report_status": "failure",
12
- "label": "test_org2",
12
+ "id": 2,
13
13
  "upload_report_status": "unknown",
14
14
  },
15
15
  "Account3": Object {
16
16
  "generate_report_status": "running",
17
- "label": "test_org3",
17
+ "id": 3,
18
18
  "upload_report_status": "success",
19
19
  },
20
20
  }
@@ -35,17 +35,17 @@ Object {
35
35
  "accounts": Object {
36
36
  "Account1": Object {
37
37
  "generate_report_status": "running",
38
- "label": "test_org1",
38
+ "id": 1,
39
39
  "upload_report_status": "running",
40
40
  },
41
41
  "Account2": Object {
42
42
  "generate_report_status": "failure",
43
- "label": "test_org2",
43
+ "id": 2,
44
44
  "upload_report_status": "unknown",
45
45
  },
46
46
  "Account3": Object {
47
47
  "generate_report_status": "running",
48
- "label": "test_org3",
48
+ "id": 3,
49
49
  "upload_report_status": "success",
50
50
  },
51
51
  },
@@ -67,7 +67,7 @@ export const setActiveTab = (accountID, tabName) => ({
67
67
  });
68
68
 
69
69
  export const downloadReports = accountID => {
70
- window.location.href = inventoryUrl(`${accountID}/uploads/file`);
70
+ window.open(inventoryUrl(`${accountID}/uploads/file`), '_blank');
71
71
  return {
72
72
  type: INVENTORY_REPORTS_DOWNLOAD,
73
73
  payload: {
@@ -35,4 +35,17 @@ const fixtures = {
35
35
  runWithGetState({ activeTab: 'reports' }, toggleFullScreen, accountID),
36
36
  };
37
37
 
38
- describe('Dashboard actions', () => testActionSnapshotWithFixtures(fixtures));
38
+ describe('Dashboard actions', () => {
39
+ const { location } = window;
40
+
41
+ beforeAll(() => {
42
+ delete window.location;
43
+ window.location = { href: jest.fn() };
44
+ });
45
+
46
+ afterAll(() => {
47
+ window.location = location;
48
+ });
49
+
50
+ return testActionSnapshotWithFixtures(fixtures);
51
+ });
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_rh_cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.17
4
+ version: 1.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Foreman Red Hat Cloud team
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-22 00:00:00.000000000 Z
11
+ date: 2021-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: katello
@@ -535,7 +535,7 @@ homepage: https://github.com/theforeman/foreman_rh_cloud
535
535
  licenses:
536
536
  - GPL-3.0
537
537
  metadata: {}
538
- post_install_message:
538
+ post_install_message:
539
539
  rdoc_options: []
540
540
  require_paths:
541
541
  - lib
@@ -550,25 +550,25 @@ required_rubygems_version: !ruby/object:Gem::Requirement
550
550
  - !ruby/object:Gem::Version
551
551
  version: '0'
552
552
  requirements: []
553
- rubygems_version: 3.0.6
554
- signing_key:
553
+ rubygems_version: 3.2.3
554
+ signing_key:
555
555
  specification_version: 4
556
556
  summary: Summary of ForemanRhCloud.
557
557
  test_files:
558
- - test/controllers/uploads_controller_test.rb
559
- - test/controllers/insights_sync/settings_controller_test.rb
560
558
  - test/controllers/accounts_controller_test.rb
559
+ - test/controllers/insights_sync/settings_controller_test.rb
561
560
  - test/controllers/reports_controller_test.rb
562
- - test/test_plugin_helper.rb
563
- - test/jobs/upload_report_job_test.rb
561
+ - test/controllers/uploads_controller_test.rb
562
+ - test/factories/insights_factories.rb
563
+ - test/factories/inventory_upload_factories.rb
564
564
  - test/jobs/insights_full_sync_test.rb
565
565
  - test/jobs/inventory_full_sync_test.rb
566
- - test/factories/inventory_upload_factories.rb
567
- - test/factories/insights_factories.rb
568
- - test/unit/shell_process_job_test.rb
569
- - test/unit/metadata_generator_test.rb
566
+ - test/jobs/upload_report_job_test.rb
567
+ - test/test_plugin_helper.rb
568
+ - test/unit/archived_report_generator_test.rb
569
+ - test/unit/fact_helpers_test.rb
570
570
  - test/unit/insights_facet_test.rb
571
+ - test/unit/metadata_generator_test.rb
571
572
  - test/unit/rh_cloud_http_proxy_test.rb
572
- - test/unit/fact_helpers_test.rb
573
- - test/unit/archived_report_generator_test.rb
573
+ - test/unit/shell_process_job_test.rb
574
574
  - test/unit/slice_generator_test.rb