Sha256: aa259e4935d6a56bd7c99d1ff94580969551051577669ca7c7fe4e0dcd44e871

Contents?: true

Size: 832 Bytes

Versions: 3

Compression:

Stored size: 832 Bytes

Contents

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

export const handleToggle = currentIpsObfuscationEnabled => async dispatch => {
  const toggledIpsObfuscationEnabled = !currentIpsObfuscationEnabled;
  try {
    const {
      data: { ipsObfuscationEnabled },
    } = await API.post(inventoryUrl('ips_obfuscation'), {
      value: toggledIpsObfuscationEnabled,
    });
    dispatch({
      type: IPS_OBFUSCATION_TOGGLE,
      payload: {
        ipsObfuscationEnabled,
      },
    });
  } catch (error) {
    dispatch(
      addToast({
        sticky: true,
        type: 'error',
        message: error.message,
      })
    );
  }
};

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
foreman_rh_cloud-3.0.17 webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcherActions.js
foreman_rh_cloud-3.0.16 webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcherActions.js
foreman_rh_cloud-3.0.15 webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcherActions.js