foreman_rh_cloud 2.0.17 → 2.0.18

Sign up to get free protection for your applications and to get access to all the features.
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 +4 -4
  23. metadata +16 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b34803af6696737993eb885384efd806b443d28668c96734e175f2595ce4829
4
- data.tar.gz: e936612e09f71e9e3b351be01862763a4fae2f7caa29f6161547456416e8675f
3
+ metadata.gz: 65a5f371cd3cf04391dc00f0a9e797e052830b67ebeda760259af082b10fd95f
4
+ data.tar.gz: 3441080128c415a951878e6471b7de44cb2ab10e3baee7b27065c97ee165c072
5
5
  SHA512:
6
- metadata.gz: bb8e4f801f862736c5a4a93b3fe4b259067a1f7d44d1c81b5b11432e61b6047614c7ba7ec4e9d97af352fe85ee6a972ce1c7bcc5ac97b8602526750b0ff7018b
7
- data.tar.gz: 59c87465077fbc67aac9e71076cc7f70ede3a577aa3cb37af8e257e78ee12f9955a77f2dfdf4a11fe84c76be073c6f84503e3a2b4178dda1bbe13bad458abf1d
6
+ metadata.gz: '085d4e4e524e48a595b8833cf9777c0ebc6116cd88c28d7bdc01ff4b8080689d5d6ca334b4a4554f5978cf36f64baa3494d90ce63593c313887daff9fc19c0a9'
7
+ data.tar.gz: 2e073a6a25e049c41c4092854874dec161af475822055875ca042b472ea8c31c9bcdc89451840f83d752df95595e1127ae6d750716f5a5a71445eca3f7ce9be4
@@ -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 = '2.0.17'.freeze
2
+ VERSION = '2.0.18'.freeze
3
3
  end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foreman_rh_cloud",
3
- "version": "2.0.17",
3
+ "version": "2.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
 
@@ -287,7 +287,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
287
287
  end
288
288
 
289
289
  test 'generates a report with satellite facts' do
290
- hostgroup = FactoryBot.create(:hostgroup)
290
+ hostgroup = FactoryBot.create(:hostgroup, name: 'Special"name')
291
291
  @host.hostgroup = hostgroup
292
292
  @host.save!
293
293
 
@@ -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: {
@@ -36,15 +36,15 @@ const fixtures = {
36
36
  };
37
37
 
38
38
  describe('Dashboard actions', () => {
39
- const { location } = window;
39
+ const { open } = window;
40
40
 
41
41
  beforeAll(() => {
42
- delete window.location;
43
- window.location = { href: jest.fn() };
42
+ delete window.open;
43
+ window.open = jest.fn();
44
44
  });
45
45
 
46
46
  afterAll(() => {
47
- window.location = location;
47
+ window.open = open;
48
48
  });
49
49
 
50
50
  return testActionSnapshotWithFixtures(fixtures);
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: 2.0.17
4
+ version: 2.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-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: katello
@@ -528,7 +528,7 @@ homepage: https://github.com/theforeman/foreman_rh_cloud
528
528
  licenses:
529
529
  - GPL-3.0
530
530
  metadata: {}
531
- post_install_message:
531
+ post_install_message:
532
532
  rdoc_options: []
533
533
  require_paths:
534
534
  - lib
@@ -543,25 +543,25 @@ required_rubygems_version: !ruby/object:Gem::Requirement
543
543
  - !ruby/object:Gem::Version
544
544
  version: '0'
545
545
  requirements: []
546
- rubygems_version: 3.0.6
547
- signing_key:
546
+ rubygems_version: 3.2.3
547
+ signing_key:
548
548
  specification_version: 4
549
549
  summary: Summary of ForemanRhCloud.
550
550
  test_files:
551
- - test/controllers/uploads_controller_test.rb
552
- - test/controllers/insights_sync/settings_controller_test.rb
553
551
  - test/controllers/accounts_controller_test.rb
552
+ - test/controllers/insights_sync/settings_controller_test.rb
554
553
  - test/controllers/reports_controller_test.rb
555
- - test/test_plugin_helper.rb
556
- - test/jobs/upload_report_job_test.rb
554
+ - test/controllers/uploads_controller_test.rb
555
+ - test/factories/insights_factories.rb
556
+ - test/factories/inventory_upload_factories.rb
557
557
  - test/jobs/insights_full_sync_test.rb
558
558
  - test/jobs/inventory_full_sync_test.rb
559
- - test/factories/inventory_upload_factories.rb
560
- - test/factories/insights_factories.rb
561
- - test/unit/shell_process_job_test.rb
562
- - test/unit/metadata_generator_test.rb
559
+ - test/jobs/upload_report_job_test.rb
560
+ - test/test_plugin_helper.rb
561
+ - test/unit/archived_report_generator_test.rb
562
+ - test/unit/fact_helpers_test.rb
563
563
  - test/unit/insights_facet_test.rb
564
+ - test/unit/metadata_generator_test.rb
564
565
  - test/unit/rh_cloud_http_proxy_test.rb
565
- - test/unit/fact_helpers_test.rb
566
- - test/unit/archived_report_generator_test.rb
566
+ - test/unit/shell_process_job_test.rb
567
567
  - test/unit/slice_generator_test.rb