katello 3.7.0.rc2 → 3.7.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of katello might be problematic. Click here for more details.

Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/katello/api/v2/repository_sets_controller.rb +10 -1
  3. data/app/models/katello/glue/candlepin/owner.rb +0 -8
  4. data/app/models/katello/product_content.rb +4 -1
  5. data/app/services/katello/ui_notifications/pulp/proxy_disk_space.rb +3 -1
  6. data/app/views/overrides/activation_keys/_host_environment_select.html.erb +1 -1
  7. data/lib/katello/version.rb +1 -1
  8. data/package.json +2 -1
  9. data/webpack/__mocks__/foremanReact/components/BreadcrumbBar.js +3 -0
  10. data/webpack/__mocks__/foremanReact/redux/actions/toasts.js +6 -0
  11. data/webpack/mockRequest.js +3 -3
  12. data/webpack/move_to_foreman/common/helpers.js +45 -8
  13. data/webpack/redux/actions/RedHatRepositories/sets.js +1 -1
  14. data/webpack/scenes/Subscriptions/Details/SubscriptionDetailActions.js +2 -7
  15. data/webpack/scenes/Subscriptions/Details/SubscriptionDetailReducer.js +1 -1
  16. data/webpack/scenes/Subscriptions/Details/SubscriptionDetails.js +44 -6
  17. data/webpack/scenes/Subscriptions/Details/__tests__/SubscriptionDetailReducer.test.js +3 -1
  18. data/webpack/scenes/Subscriptions/Details/__tests__/SubscriptionDetails.test.js +0 -1
  19. data/webpack/scenes/Subscriptions/Details/__tests__/__snapshots__/SubscriptionDetails.test.js.snap +22 -14
  20. data/webpack/scenes/Subscriptions/Details/__tests__/subscriptionDetails.fixtures.js +3 -4
  21. data/webpack/scenes/Subscriptions/Details/index.js +2 -2
  22. data/webpack/scenes/Subscriptions/Manifest/ManifestActions.js +5 -24
  23. data/webpack/scenes/Subscriptions/Manifest/ManifestHistoryReducer.js +1 -1
  24. data/webpack/scenes/Subscriptions/Manifest/__tests__/ManifestActions.test.js +20 -8
  25. data/webpack/scenes/Subscriptions/Manifest/__tests__/ManifestHistoryReducer.test.js +3 -1
  26. data/webpack/scenes/Subscriptions/Manifest/__tests__/manifest.fixtures.js +9 -16
  27. data/webpack/scenes/Subscriptions/SubscriptionActions.js +5 -26
  28. data/webpack/scenes/Subscriptions/SubscriptionReducer.js +6 -2
  29. data/webpack/scenes/Subscriptions/SubscriptionsPage.js +13 -10
  30. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsActions.js +3 -12
  31. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsPage.js +55 -20
  32. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsReducer.js +2 -3
  33. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsTableSchema.js +10 -5
  34. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/__tests__/UpstreamSubscriptionsActions.test.js +10 -5
  35. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/__tests__/UpstreamSubscriptionsPage.test.js +50 -5
  36. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/__tests__/UpstreamSubscriptionsReducer.test.js +8 -3
  37. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/__tests__/__snapshots__/UpstreamSubscriptionsPage.test.js.snap +18 -5
  38. data/webpack/scenes/Subscriptions/UpstreamSubscriptions/__tests__/upstreamSubscriptions.fixtures.js +5 -8
  39. data/webpack/scenes/Subscriptions/__tests__/SubscriptionsReducer.test.js +9 -3
  40. data/webpack/scenes/Subscriptions/__tests__/__snapshots__/SubscriptionsPage.test.js.snap +1 -0
  41. data/webpack/scenes/Subscriptions/__tests__/subscriptions.fixtures.js +10 -14
  42. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/SubscriptionsTable.js +16 -39
  43. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/SubscriptionsTableHelpers.js +2 -2
  44. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/__tests__/SubscriptionsTable.test.js +1 -0
  45. data/webpack/scenes/Subscriptions/components/SubscriptionsTable/__tests__/__snapshots__/SubscriptionsTable.test.js.snap +349 -355
  46. data/webpack/scenes/Subscriptions/index.js +1 -2
  47. data/webpack/services/api/testHelpers.js +28 -0
  48. metadata +7 -5
  49. data/webpack/services/api/fixtures.js +0 -353
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9a4f6bd736dcb2608d0f0eb09fc42a3365633e81
4
- data.tar.gz: d4d554bed1a2b7d416f8c57cf6e786fc2188aaa5
3
+ metadata.gz: 8fac07da0f8761539cf0d1277ef31e4afd4252e7
4
+ data.tar.gz: 0c327b63c0b1ea5296657f5551e80e61c98f84fd
5
5
  SHA512:
6
- metadata.gz: b4e75ade9c719b6f7ba594591fdef8e7665440bf5781802ad5c80dc42d413bb8c2ce71ab17c7805665dfef6dc56e270d30227cbc6127e3f0db3956a0b5ea45d5
7
- data.tar.gz: 3318e9625546af01d1f72dc7dc30f998d0213f124189cdb2cc4572652a644648d84935fc114e5d98c1c8368f979319929bb29b033a2c8f05519e717cbaeea9ce
6
+ metadata.gz: 0fa3348cfe3b738493a89038154f305bf1ba9ecb142c89e23851049f4d548e50bcdaeb564ed6bc7132e227cb54975df908f1b0114efc521b8c73e55e131c2924
7
+ data.tar.gz: '0941f97d419cea37695d53344727dfd59c8bae0104fa27ffe42bfcbb031dbdba8d029ab6b428383f5d494a1f74a426911685d39c3816bddc100787c786f17e43'
@@ -17,6 +17,7 @@ module Katello
17
17
  param :product_id, :number, :required => true, :desc => N_("ID of a product to list repository sets from")
18
18
  param :name, String, :required => false, :desc => N_("Repository set name to search on")
19
19
  param :enabled, :bool, :required => false, :desc => N_("If true, only return repository sets that have been enabled. Defaults to false")
20
+ param :with_active_subscription, :bool, :required => false, :desc => N_("If true, only return repository sets that are associated with an active subscriptions")
20
21
  param_group :search, Api::V2::ApiController
21
22
  def index
22
23
  respond(:collection => scoped_search(index_relation, nil, nil, :custom_sort => default_sort,
@@ -92,7 +93,15 @@ module Katello
92
93
  relation = @product.displayable_product_contents
93
94
  end
94
95
 
95
- relation = relation.enabled(@organization) if ::Foreman::Cast.to_bool(params[:enabled])
96
+ if ::Foreman::Cast.to_bool(params[:enabled])
97
+ relation = relation.enabled(@organization)
98
+ elsif ::Foreman::Cast.to_bool(params[:with_active_subscription])
99
+ relation = relation.with_valid_subscription(@organization)
100
+ else
101
+ relation = relation.where(:id => Katello::ProductContent.with_valid_subscription(@organization)).or(
102
+ relation.where(:id => Katello::ProductContent.enabled(@organization)))
103
+ end
104
+
96
105
  relation = relation.where(Katello::Content.table_name => {:name => params[:name]}) if params[:name].present?
97
106
  relation.redhat
98
107
  end
@@ -39,14 +39,6 @@ module Katello
39
39
  self.owner_details['contentAccessMode']
40
40
  end
41
41
 
42
- def pools(consumer_uuid = nil)
43
- if consumer_uuid
44
- Resources::Candlepin::Owner.pools self.label, :consumer => consumer_uuid
45
- else
46
- Resources::Candlepin::Owner.pools self.label
47
- end
48
- end
49
-
50
42
  def generate_debug_cert
51
43
  Resources::Candlepin::Owner.generate_ueber_cert(label)
52
44
  end
@@ -12,7 +12,6 @@ module Katello
12
12
 
13
13
  scope :displayable, -> {
14
14
  joins(:content).where.not("#{content_table_name}.content_type IN (?)", Katello::Repository.undisplayable_types)
15
- .order("LOWER(#{content_table_name}.name) ASC")
16
15
  }
17
16
 
18
17
  scope :redhat, -> {
@@ -32,6 +31,10 @@ module Katello
32
31
  joins(:content).where("#{self.content_table_name}.cp_content_id" => Katello::Repository.in_organization(organization).select(:content_id))
33
32
  end
34
33
 
34
+ def self.with_valid_subscription(organization)
35
+ where(:product_id => Katello::PoolProduct.where(:pool_id => organization.pools).select(:product_id))
36
+ end
37
+
35
38
  # used by Katello::Api::V2::RepositorySetsController#index
36
39
  def repositories
37
40
  product.repositories.in_default_view.has_url.where(:content_id => content.cp_content_id)
@@ -5,7 +5,9 @@ module Katello
5
5
  class << self
6
6
  def deliver!
7
7
  SmartProxy.unscoped.with_content.each do |proxy|
8
- percentage = proxy.statuses[:pulp].storage['pulp_dir']['percent']
8
+ status = proxy.statuses[:pulp] || proxy.statuses[:pulpnode]
9
+ next unless (percentage = status&.storage&.dig('pulp_dir', 'percent'))
10
+
9
11
  if percentage[0..2].to_i < 90 && notification_already_exists?(proxy)
10
12
  blueprint.notifications.where(subject: proxy).destroy_all
11
13
  elsif update_notifications(proxy).empty? && percentage[0..2].to_i > 90
@@ -41,6 +41,6 @@ end %>
41
41
  select_tag cs_select_id, options_from_collection_for_select(proxies, :id, :name, @hostgroup.content_source_id), :data => {"spinner_path" => spinner_path},
42
42
  :class => 'form-control', :name => cs_select_name, include_blank: true
43
43
  else
44
- select_tag cs_select_id, options_from_collection_for_select(proxies, :id, :name, (@hostgroup || @host).content_source_id), :data => {"spinner_path" => spinner_path}, :class => 'form-control', :name => cs_select_name, include_blank: true
44
+ select_tag cs_select_id, options_from_collection_for_select(proxies, :id, :name, @host.content_source_id), :data => {"spinner_path" => spinner_path}, :class => 'form-control', :name => cs_select_name, include_blank: true
45
45
  end
46
46
  end %>
@@ -1,3 +1,3 @@
1
1
  module Katello
2
- VERSION = "3.7.0.rc2".freeze
2
+ VERSION = "3.7.0".freeze
3
3
  end
@@ -75,7 +75,8 @@
75
75
  "testPathIgnorePatterns": [
76
76
  "/node_modules/",
77
77
  "<rootDir>/foreman/",
78
- "<rootDir>/.+fixtures.+"
78
+ "<rootDir>/.+fixtures.+",
79
+ "<rootDir>/engines"
79
80
  ],
80
81
  "moduleNameMapper": {
81
82
  "^.+\\.(css|scss)$": "identity-obj-proxy"
@@ -0,0 +1,3 @@
1
+
2
+ const BreadcrumbsBar = () => jest.fn();
3
+ export default BreadcrumbsBar;
@@ -0,0 +1,6 @@
1
+ export const addToast = toast => ({
2
+ type: 'TOASTS_ADD',
3
+ payload: {
4
+ message: toast,
5
+ },
6
+ });
@@ -2,7 +2,7 @@ import axios from 'axios';
2
2
  import MockAdapter from 'axios-mock-adapter';
3
3
 
4
4
  // TODO: figure out way to reuse this from foreman
5
- const mock = new MockAdapter(axios);
5
+ export const mock = new MockAdapter(axios);
6
6
  const methods = {
7
7
  GET: 'onGet',
8
8
  POST: 'onPost',
@@ -15,10 +15,10 @@ const errorResponse = msg => ({ displayMessage: msg });
15
15
  export const mockRequest = ({
16
16
  method = 'GET',
17
17
  url,
18
- data = null,
18
+ data,
19
19
  status = 200,
20
20
  response = null,
21
- }) => mock[methods[method]](url, data).reply(status, response);
21
+ }) => mock[methods[method.toUpperCase()]](url, data).reply(status, response);
22
22
 
23
23
  export const mockErrorRequest = ({
24
24
  status = 500,
@@ -1,11 +1,41 @@
1
- export default {
2
- urlBuilder(controller, action, id = undefined) {
3
- return `/${controller}/${id ? `${id}/` : ''}${action}`;
4
- },
1
+ import { addToast } from 'foremanReact/redux/actions/toasts';
2
+
3
+ const urlBuilder = (controller, action, id = undefined) =>
4
+ `/${controller}/${id ? `${id}/` : ''}${action}`;
5
+
6
+ const urlWithSearch = (base, searchQuery) =>
7
+ `/${base}?search=${searchQuery}`;
8
+
9
+ const stringIsInteger = (value) => {
10
+ // checking for positive integers only
11
+ const reg = new RegExp('^[0-9]+$');
12
+ return reg.test(value);
13
+ };
5
14
 
6
- urlWithSearch(base, searchQuery) {
7
- return `/${base}?search=${searchQuery}`;
8
- },
15
+ export const getResponseErrorMsgs = ({ data }) => {
16
+ if (data) {
17
+ const messages = (data.errors || data.displayMessage || data.message || data.error);
18
+ return (Array.isArray(messages) ? messages : [messages]);
19
+ }
20
+ return [];
21
+ };
22
+
23
+ export const apiError = (actionType, result) => (dispatch) => {
24
+ const messages = getResponseErrorMsgs(result.response);
25
+ dispatch({
26
+ type: actionType,
27
+ payload: {
28
+ result,
29
+ messages,
30
+ },
31
+ });
32
+ messages.forEach((msg) => {
33
+ dispatch(addToast({
34
+ type: 'error',
35
+ message: msg,
36
+ sticky: true,
37
+ }));
38
+ });
9
39
  };
10
40
 
11
41
  export const KEY_CODES = {
@@ -14,4 +44,11 @@ export const KEY_CODES = {
14
44
  ESCAPE_KEY: 27,
15
45
  };
16
46
 
17
- export const getResponseError = ({ data }) => data && (data.displayMessage || data.error);
47
+ export default {
48
+ urlBuilder,
49
+ urlWithSearch,
50
+ getResponseErrorMsgs,
51
+ apiError,
52
+ KEY_CODES,
53
+ stringIsInteger,
54
+ };
@@ -28,7 +28,7 @@ export const loadRepositorySets = (extendedParams = {}) => (dispatch, getState)
28
28
  ]);
29
29
 
30
30
  const params = {
31
- ...{ organization_id: orgId() },
31
+ ...{ organization_id: orgId(), with_active_subscription: true },
32
32
  ...propsToSnakeCase(extendedParams),
33
33
  search,
34
34
  };
@@ -4,7 +4,7 @@ import {
4
4
  SUBSCRIPTION_DETAILS_SUCCESS,
5
5
  SUBSCRIPTION_DETAILS_FAILURE,
6
6
  } from './SubscriptionDetailConstants';
7
- import { getResponseError } from '../../../move_to_foreman/common/helpers.js';
7
+ import { apiError } from '../../../move_to_foreman/common/helpers.js';
8
8
 
9
9
  export const loadSubscriptionDetails = subscriptionId => (dispatch) => {
10
10
  dispatch({ type: SUBSCRIPTION_DETAILS_REQUEST });
@@ -17,12 +17,7 @@ export const loadSubscriptionDetails = subscriptionId => (dispatch) => {
17
17
  response: data,
18
18
  });
19
19
  })
20
- .catch((result) => {
21
- dispatch({
22
- type: SUBSCRIPTION_DETAILS_FAILURE,
23
- error: getResponseError(result.response),
24
- });
25
- });
20
+ .catch(result => dispatch(apiError(SUBSCRIPTION_DETAILS_FAILURE, result)));
26
21
  };
27
22
 
28
23
  export default loadSubscriptionDetails;
@@ -26,7 +26,7 @@ export default (state = initialState, action) => {
26
26
 
27
27
  case SUBSCRIPTION_DETAILS_FAILURE: {
28
28
  return state.merge({
29
- error: action.error,
29
+ error: action.payload.message,
30
30
  loading: false,
31
31
  });
32
32
  }
@@ -1,33 +1,70 @@
1
1
  import React, { Component } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { Grid, Row, Col } from 'patternfly-react';
4
+ import BreadcrumbsBar from 'foremanReact/components/BreadcrumbBar';
4
5
  import SubscriptionDetailInfo from './SubscriptionDetailInfo';
5
6
  import SubscriptionDetailAssociations from './SubscriptionDetailAssociations';
6
7
  import SubscriptionDetailProducts from './SubscriptionDetailProducts';
7
8
  import { LoadingState } from '../../../move_to_pf/LoadingState';
8
9
  import { notify } from '../../../move_to_foreman/foreman_toast_notifications';
10
+ import api from '../../../services/api';
9
11
 
10
12
  class SubscriptionDetails extends Component {
13
+ constructor() {
14
+ super();
15
+ this.handleBreadcrumbSwitcherItem = this.handleBreadcrumbSwitcherItem.bind(this);
16
+ }
11
17
  componentDidMount() {
12
18
  // eslint-disable-next-line react/prop-types
13
19
  const routerParams = this.props.match.params;
14
20
  this.props.loadSubscriptionDetails(parseInt(routerParams.id, 10));
15
21
  }
16
22
 
23
+ componentDidUpdate(prevProps) {
24
+ const routerParams = this.props.match.params;
25
+ if (routerParams.id !== prevProps.match.params.id) {
26
+ this.props.loadSubscriptionDetails(parseInt(routerParams.id, 10));
27
+ }
28
+ }
29
+
30
+ handleBreadcrumbSwitcherItem(e, url) {
31
+ this.props.history.push(url);
32
+ e.preventDefault();
33
+ }
34
+
17
35
  render() {
18
36
  const { subscriptionDetails } = this.props;
37
+ const resource = {
38
+ nameField: 'name',
39
+ resourceUrl: api.getApiUrl('/subscriptions'),
40
+ switcherItemUrl: '/subscriptions/:id',
41
+ };
19
42
 
20
- if (subscriptionDetails.error) { notify({ message: subscriptionDetails.error }); }
43
+ if (subscriptionDetails.error) {
44
+ notify({ message: subscriptionDetails.error });
45
+ }
21
46
 
22
47
  return (
23
48
  <Grid bsClass="container-fluid">
49
+ {!subscriptionDetails.loading && <BreadcrumbsBar
50
+ onSwitcherItemClick={(e, url) => this.handleBreadcrumbSwitcherItem(e, url)}
51
+ data={{
52
+ isSwitchable: true,
53
+ breadcrumbItems: [
54
+ {
55
+ caption: __('Subscriptions'),
56
+ onClick: () =>
57
+ this.props.history.push('/subscriptions'),
58
+ },
59
+ {
60
+ caption: String(subscriptionDetails.name),
61
+ },
62
+ ],
63
+ resource,
64
+ }}
65
+ />}
24
66
  <div>
25
67
  <LoadingState loading={subscriptionDetails.loading} loadingText={__('Loading')}>
26
- <Row>
27
- <Col sm={12}>
28
- <h1>{subscriptionDetails.name}</h1>
29
- </Col>
30
- </Row>
31
68
  <Row>
32
69
  <Col sm={6}>
33
70
  <SubscriptionDetailInfo
@@ -53,6 +90,7 @@ class SubscriptionDetails extends Component {
53
90
  SubscriptionDetails.propTypes = {
54
91
  loadSubscriptionDetails: PropTypes.func.isRequired,
55
92
  subscriptionDetails: PropTypes.shape({}).isRequired,
93
+ history: PropTypes.shape({ push: PropTypes.func.isRequired }).isRequired,
56
94
  };
57
95
 
58
96
  export default SubscriptionDetails;
@@ -30,7 +30,9 @@ describe('subscriptions reducer', () => {
30
30
  const error = 'nothing worked';
31
31
  expect(reducer(initialState, {
32
32
  type: types.SUBSCRIPTION_DETAILS_FAILURE,
33
- error,
33
+ payload: {
34
+ message: error,
35
+ },
34
36
  })).toEqual({
35
37
  ...initialState,
36
38
  error,
@@ -19,7 +19,6 @@ describe('subscriptions details page', () => {
19
19
  subscriptionDetails={successState}
20
20
  match={match}
21
21
  />);
22
- expect(wrapper.find('h1').text()).toEqual(successState.name);
23
22
  expect(wrapper.find(SubscriptionDetailAssociations)).toHaveLength(1);
24
23
  expect(wrapper.find(SubscriptionDetailInfo)).toHaveLength(1);
25
24
  expect(wrapper.find(SubscriptionDetailProducts)).toHaveLength(1);
@@ -6,25 +6,33 @@ exports[`subscriptions details page should render and contain appropiate compone
6
6
  componentClass="div"
7
7
  fluid={false}
8
8
  >
9
+ <BreadcrumbsBar
10
+ data={
11
+ Object {
12
+ "breadcrumbItems": Array [
13
+ Object {
14
+ "caption": "Subscriptions",
15
+ "onClick": [Function],
16
+ },
17
+ Object {
18
+ "caption": "OpenShift Employee Subscription",
19
+ },
20
+ ],
21
+ "isSwitchable": true,
22
+ "resource": Object {
23
+ "nameField": "name",
24
+ "resourceUrl": "/katello/api/v2/subscriptions",
25
+ "switcherItemUrl": "/subscriptions/:id",
26
+ },
27
+ }
28
+ }
29
+ onSwitcherItemClick={[Function]}
30
+ />
9
31
  <div>
10
32
  <LoadingState
11
33
  loading={false}
12
34
  loadingText="Loading"
13
35
  >
14
- <Row
15
- bsClass="row"
16
- componentClass="div"
17
- >
18
- <Col
19
- bsClass="col"
20
- componentClass="div"
21
- sm={12}
22
- >
23
- <h1>
24
- OpenShift Employee Subscription
25
- </h1>
26
- </Col>
27
- </Row>
28
36
  <Row
29
37
  bsClass="row"
30
38
  componentClass="div"
@@ -1,4 +1,5 @@
1
1
  import Immutable from 'seamless-immutable';
2
+ import { toastErrorAction, failureAction } from '../../../../services/api/testHelpers';
2
3
 
3
4
  export const initialState = Immutable({
4
5
  loading: false,
@@ -148,10 +149,8 @@ export const loadSubscriptionsDetailsFailureActions = [
148
149
  {
149
150
  type: 'SUBSCRIPTION_DETAILS_REQUEST',
150
151
  },
151
- {
152
- error: 'Request failed with status code 500',
153
- type: 'SUBSCRIPTION_DETAILS_FAILURE',
154
- },
152
+ failureAction('SUBSCRIPTION_DETAILS_FAILURE', 'Request failed with status code 500'),
153
+ toastErrorAction('Request failed with status code 500'),
155
154
  ];
156
155
 
157
156
  export const loadSubscriptionsDetailsSuccessActions = [
@@ -1,6 +1,6 @@
1
1
  import { bindActionCreators } from 'redux';
2
2
  import { connect } from 'react-redux';
3
-
3
+ import { withRouter } from 'react-router';
4
4
  import reducer from './SubscriptionDetailReducer';
5
5
  import * as subscriptionDetailActions from './SubscriptionDetailActions';
6
6
  import SubscriptionDetails from './SubscriptionDetails';
@@ -16,4 +16,4 @@ const mapDispatchToProps = dispatch => bindActionCreators(subscriptionDetailActi
16
16
  export const subscriptionDetails = reducer;
17
17
 
18
18
  // export connected component
19
- export default connect(mapStateToProps, mapDispatchToProps)(SubscriptionDetails);
19
+ export default connect(mapStateToProps, mapDispatchToProps)(withRouter(SubscriptionDetails));
@@ -1,5 +1,6 @@
1
1
  import api, { orgId } from '../../../services/api';
2
2
  import { propsToSnakeCase } from '../../../services/index';
3
+ import { apiError } from '../../../move_to_foreman/common/helpers.js';
3
4
 
4
5
  import {
5
6
  UPLOAD_MANIFEST_REQUEST,
@@ -34,12 +35,7 @@ export const uploadManifest = file => (dispatch) => {
34
35
  response: data,
35
36
  });
36
37
  })
37
- .catch((result) => {
38
- dispatch({
39
- type: UPLOAD_MANIFEST_FAILURE,
40
- result,
41
- });
42
- });
38
+ .catch(result => dispatch(apiError(UPLOAD_MANIFEST_FAILURE, result)));
43
39
  };
44
40
 
45
41
  export const refreshManifest = (extendedParams = {}) => (dispatch) => {
@@ -57,12 +53,7 @@ export const refreshManifest = (extendedParams = {}) => (dispatch) => {
57
53
  response: data,
58
54
  });
59
55
  })
60
- .catch((result) => {
61
- dispatch({
62
- type: REFRESH_MANIFEST_FAILURE,
63
- result,
64
- });
65
- });
56
+ .catch(result => dispatch(apiError(REFRESH_MANIFEST_FAILURE, result)));
66
57
  };
67
58
 
68
59
  export const deleteManifest = (extendedParams = {}) => (dispatch) => {
@@ -80,12 +71,7 @@ export const deleteManifest = (extendedParams = {}) => (dispatch) => {
80
71
  response: data,
81
72
  });
82
73
  })
83
- .catch((result) => {
84
- dispatch({
85
- type: DELETE_MANIFEST_FAILURE,
86
- result,
87
- });
88
- });
74
+ .catch(result => dispatch(apiError(DELETE_MANIFEST_FAILURE, result)));
89
75
  };
90
76
 
91
77
  export const loadManifestHistory = (extendedParams = {}) => (dispatch) => {
@@ -103,12 +89,7 @@ export const loadManifestHistory = (extendedParams = {}) => (dispatch) => {
103
89
  response: data,
104
90
  });
105
91
  })
106
- .catch((result) => {
107
- dispatch({
108
- type: MANIFEST_HISTORY_FAILURE,
109
- result,
110
- });
111
- });
92
+ .catch(result => dispatch(apiError(MANIFEST_HISTORY_FAILURE, result)));
112
93
  };
113
94
 
114
95
  export default loadManifestHistory;