Sha256: bf95a2cd555a537d6a54c5fbca28e0321a65b85e5247066d35e194bbe0166039

Contents?: true

Size: 1.29 KB

Versions: 36

Compression:

Stored size: 1.29 KB

Contents

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

36 entries across 36 versions & 1 rubygems

Version Path
foreman_rh_cloud-4.0.36 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-3.0.33 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-4.0.35 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-3.0.32 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-4.0.32 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-4.0.31 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-4.0.30 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-3.0.29 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-4.0.29 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-5.0.29 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-3.0.28 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-5.0.28 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-4.0.27 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-3.0.26 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-4.0.26 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-4.0.25.1 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-3.0.25 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-4.0.25 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-3.0.24.1 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js
foreman_rh_cloud-4.0.24.1 webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js