Sha256: 1ae8bc802212ce0ac13c8f25ef1b7e8152e37e2c265ca7c76871cb4eab3be192

Contents?: true

Size: 833 Bytes

Versions: 3

Compression:

Stored size: 833 Bytes

Contents

import { API } from 'foremanReact/redux/API';
import { addToast } from 'foremanReact/redux/actions/toasts';
import { inventoryUrl } from '../../ForemanInventoryHelpers';
import { HOST_OBFUSCATION_TOGGLE } from './HostObfuscationSwitcherConstants';

export const handleToggle = currentHostObfuscationEnabled => async dispatch => {
  const toggledHostObfuscationEnabled = !currentHostObfuscationEnabled;
  try {
    const {
      data: { hostObfuscationEnabled },
    } = await API.post(inventoryUrl('host_obfuscation'), {
      value: toggledHostObfuscationEnabled,
    });
    dispatch({
      type: HOST_OBFUSCATION_TOGGLE,
      payload: {
        hostObfuscationEnabled,
      },
    });
  } catch ({ message }) {
    dispatch(
      addToast({
        sticky: true,
        type: 'error',
        message,
      })
    );
  }
};

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
foreman_rh_cloud-3.0.17 webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcherActions.js
foreman_rh_cloud-3.0.16 webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcherActions.js
foreman_rh_cloud-3.0.15 webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcherActions.js