Sha256: 7c8bc36f79d454ac885129819ae4518deaf352c4b1be5f12368f6eecffd1a68e

Contents?: true

Size: 1.29 KB

Versions: 47

Compression:

Stored size: 1.29 KB

Contents

import { API } from 'foremanReact/redux/API';
import { addToast } from 'foremanReact/components/ToastsList';
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

47 entries across 47 versions & 1 rubygems

Version Path
foreman_rh_cloud-9.0.59 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-11.0.2 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-11.0.1 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-11.0.0 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-9.0.58 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-10.0.2 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-9.0.57 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-10.0.1 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-9.0.56 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-9.0.55 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-9.0.54 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-9.0.53 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-9.0.52 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-8.0.52 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-9.0.51 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-8.0.51 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-7.0.48 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-7.0.47 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-8.0.50 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-8.0.49 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js