Sha256: 991f1f7edfca1acf522b86bbf446a211b37218ef520d78d91f2bd10e67c31eaf

Contents?: true

Size: 1.01 KB

Versions: 33

Compression:

Stored size: 1.01 KB

Contents

import API from 'foremanReact/API';
import { translate as __ } from 'foremanReact/common/I18n';
import { foremanUrl } from '../../ForemanRhCloudHelpers';
import { inventoryUrl } from '../ForemanInventoryHelpers';

export const subscriptionCountListener = (itemsCount, unsubscribe) => {
  const showToast = autoUploadEnabled => {
    !autoUploadEnabled &&
      window.tfm.toastNotifications.notify({
        message: __('Now you can enable Red Hat inventory upload'),
        type: 'info',
        link: {
          children: __('Go to inventory upload settings'),
          href: foremanUrl('foreman_rh_cloud/inventory_upload'),
        },
      });

    unsubscribe();
  };

  itemsCount && fetchInventoryAutoUploadSetting(showToast);
};

const fetchInventoryAutoUploadSetting = async processApiResponse => {
  let settingValue;
  try {
    const {
      data: { autoUploadEnabled },
    } = await API.get(inventoryUrl('auto_upload'));
    settingValue = autoUploadEnabled;
  } finally {
    processApiResponse(settingValue);
  }
};

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
foreman_rh_cloud-2.0.18.1 webpack/ForemanInventoryUpload/SubscriptionsPageExtension/SubscriptionsPageExtensionActions.js
foreman_rh_cloud-1.0.18 webpack/ForemanInventoryUpload/SubscriptionsPageExtension/SubscriptionsPageExtensionActions.js
foreman_rh_cloud-2.0.18 webpack/ForemanInventoryUpload/SubscriptionsPageExtension/SubscriptionsPageExtensionActions.js
foreman_rh_cloud-1.0.17 webpack/ForemanInventoryUpload/SubscriptionsPageExtension/SubscriptionsPageExtensionActions.js
foreman_rh_cloud-2.0.17 webpack/ForemanInventoryUpload/SubscriptionsPageExtension/SubscriptionsPageExtensionActions.js
foreman_rh_cloud-2.0.16 webpack/ForemanInventoryUpload/SubscriptionsPageExtension/SubscriptionsPageExtensionActions.js
foreman_rh_cloud-1.0.16 webpack/ForemanInventoryUpload/SubscriptionsPageExtension/SubscriptionsPageExtensionActions.js
foreman_rh_cloud-1.0.15 webpack/ForemanInventoryUpload/SubscriptionsPageExtension/SubscriptionsPageExtensionActions.js
foreman_rh_cloud-2.0.15 webpack/ForemanInventoryUpload/SubscriptionsPageExtension/SubscriptionsPageExtensionActions.js
foreman_rh_cloud-2.0.14 webpack/ForemanInventoryUpload/SubscriptionsPageExtension/SubscriptionsPageExtensionActions.js
foreman_rh_cloud-1.0.14 webpack/ForemanInventoryUpload/SubscriptionsPageExtension/SubscriptionsPageExtensionActions.js
foreman_rh_cloud-0.9.14 webpack/ForemanInventoryUpload/SubscriptionsPageExtension/SubscriptionsPageExtensionActions.js
foreman_rh_cloud-0.9.13.1 webpack/ForemanInventoryUpload/SubscriptionsPageExtension/SubscriptionsPageExtensionActions.js
foreman_rh_cloud-1.0.13.1 webpack/ForemanInventoryUpload/SubscriptionsPageExtension/SubscriptionsPageExtensionActions.js
foreman_rh_cloud-2.0.13.1 webpack/ForemanInventoryUpload/SubscriptionsPageExtension/SubscriptionsPageExtensionActions.js
foreman_rh_cloud-0.9.13 webpack/ForemanInventoryUpload/SubscriptionsPageExtension/SubscriptionsPageExtensionActions.js
foreman_rh_cloud-1.0.13 webpack/ForemanInventoryUpload/SubscriptionsPageExtension/SubscriptionsPageExtensionActions.js
foreman_rh_cloud-2.0.13 webpack/ForemanInventoryUpload/SubscriptionsPageExtension/SubscriptionsPageExtensionActions.js
foreman_rh_cloud-0.9.12 webpack/ForemanInventoryUpload/SubscriptionsPageExtension/SubscriptionsPageExtensionActions.js
foreman_rh_cloud-1.0.12 webpack/ForemanInventoryUpload/SubscriptionsPageExtension/SubscriptionsPageExtensionActions.js