Sha256: b9e3b50e2744efb77a170c5e7fe871bd76924b349ef6ae541798b6e1be5256ae

Contents?: true

Size: 657 Bytes

Versions: 6

Compression:

Stored size: 657 Bytes

Contents

import API from 'foremanReact/API';
import {
  AUTO_UPLOAD_TOGGLE,
  AUTO_UPLOAD_TOGGLE_ERROR,
} from './AutoUploadSwitcherConstants';

export const handleToggle = currentAutoUploadEnabled => async dispatch => {
  const toggledAutoUploadEnabled = !currentAutoUploadEnabled;
  try {
    const {
      data: { autoUploadEnabled },
    } = await API.post('auto_upload', { value: toggledAutoUploadEnabled });
    dispatch({
      type: AUTO_UPLOAD_TOGGLE,
      payload: {
        autoUploadEnabled,
      },
    });
  } catch (error) {
    dispatch({
      type: AUTO_UPLOAD_TOGGLE_ERROR,
      payload: {
        error: error.message,
      },
    });
  }
};

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
foreman_rh_cloud-0.9.6 webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcherActions.js
foreman_rh_cloud-1.0.6 webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcherActions.js
foreman_rh_cloud-2.0.6 webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcherActions.js
foreman_rh_cloud-0.9.5 webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcherActions.js
foreman_rh_cloud-1.0.5 webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcherActions.js
foreman_rh_cloud-2.0.5 webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcherActions.js