Sha256: d2ad2f7b7e3b90811404b4a73aae63376fe548841f59050888ea8aa099d25018

Contents?: true

Size: 1.59 KB

Versions: 14

Compression:

Stored size: 1.59 KB

Contents

import { propsToSnakeCase } from 'foremanReact/common/helpers';

import api, { orgId } from '../../../services/api';
import { apiError } from '../../../move_to_foreman/common/helpers.js';

import {
  UPSTREAM_SUBSCRIPTIONS_REQUEST,
  UPSTREAM_SUBSCRIPTIONS_SUCCESS,
  UPSTREAM_SUBSCRIPTIONS_FAILURE,
  SAVE_UPSTREAM_SUBSCRIPTIONS_REQUEST,
  SAVE_UPSTREAM_SUBSCRIPTIONS_SUCCESS,
  SAVE_UPSTREAM_SUBSCRIPTIONS_FAILURE,
} from './UpstreamSubscriptionsContstants';

export const loadUpstreamSubscriptions = (extendedParams = {}) => (dispatch) => {
  dispatch({ type: UPSTREAM_SUBSCRIPTIONS_REQUEST });

  const params = {
    ...{ organization_id: orgId(), attachable: true },
    ...propsToSnakeCase(extendedParams),
  };

  return api
    .get(`/organizations/${orgId()}/upstream_subscriptions`, {}, params)
    .then(({ data }) => {
      dispatch({
        type: UPSTREAM_SUBSCRIPTIONS_SUCCESS,
        response: data,
        search: extendedParams.search,
      });
    })
    .catch(result => dispatch(apiError(UPSTREAM_SUBSCRIPTIONS_FAILURE, result)));
};

export const saveUpstreamSubscriptions = upstreamSubscriptions => (dispatch) => {
  dispatch({ type: SAVE_UPSTREAM_SUBSCRIPTIONS_REQUEST });

  const params = {
    ...propsToSnakeCase(upstreamSubscriptions),
  };

  return api
    .post(`/organizations/${orgId()}/upstream_subscriptions`, params)
    .then(({ data }) => {
      dispatch({
        type: SAVE_UPSTREAM_SUBSCRIPTIONS_SUCCESS,
        response: data,
      });
    })
    .catch(result => dispatch(apiError(SAVE_UPSTREAM_SUBSCRIPTIONS_FAILURE, result)));
};

export default loadUpstreamSubscriptions;

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
katello-3.13.4 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsActions.js
katello-3.13.3 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsActions.js
katello-3.13.2 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsActions.js
katello-3.13.1 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsActions.js
katello-3.13.0 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsActions.js
katello-3.13.0.rc2.1 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsActions.js
katello-3.13.0.rc2 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsActions.js
katello-3.12.3 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsActions.js
katello-3.12.2 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsActions.js
katello-3.13.0.rc1 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsActions.js
katello-3.12.1 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsActions.js
katello-3.12.0 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsActions.js
katello-3.12.0.rc2 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsActions.js
katello-3.12.0.rc1 webpack/scenes/Subscriptions/UpstreamSubscriptions/UpstreamSubscriptionsActions.js