Sha256: cc3a7400708ad118157fbfd1e2acdf1a005429c4da98411ba313a58b0bddc5e9

Contents?: true

Size: 1.28 KB

Versions: 19

Compression:

Stored size: 1.28 KB

Contents

import API from 'foremanReact/API';
import { addToast } from 'foremanReact/redux/actions/toasts';
import { insightsCloudUrl } from '../../InsightsCloudSyncHelpers';
import {
  INSIGHTS_SYNC_SETTING_SET,
  INSIGHTS_SYNC_SETTINGS_GET_SUCCESS,
} from './InsightsSettingsConstants';

export const getInsightsSyncSettings = () => async dispatch => {
  try {
    const {
      data: { insightsSyncEnabled },
    } = await API.get(insightsCloudUrl('settings'));
    dispatch({
      type: INSIGHTS_SYNC_SETTINGS_GET_SUCCESS,
      payload: {
        settings: {
          insightsSyncEnabled,
        },
      },
    });
  } catch ({ message }) {
    dispatch(
      addToast({
        sticky: true,
        type: 'error',
        message,
      })
    );
  }
};

export const setInsightsSyncEnabled = currentInsightsSyncEnabled => async dispatch => {
  try {
    const {
      data: { insightsSyncEnabled },
    } = await API.patch(insightsCloudUrl('settings'), {
      insightsSyncEnabled: currentInsightsSyncEnabled,
    });
    dispatch({
      type: INSIGHTS_SYNC_SETTING_SET,
      payload: {
        settings: {
          insightsSyncEnabled,
        },
      },
    });
  } catch ({ message }) {
    dispatch(
      addToast({
        sticky: true,
        type: 'error',
        message,
      })
    );
  }
};

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
foreman_rh_cloud-2.0.18.1 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-1.0.18 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-2.0.18 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-1.0.17 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-2.0.17 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-2.0.16 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-1.0.16 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-1.0.15 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-2.0.15 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-3.0.14 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-2.0.14 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-1.0.14 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-0.9.14 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-0.9.13.1 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-1.0.13.1 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-2.0.13.1 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-0.9.13 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-1.0.13 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-2.0.13 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js