Sha256: da1f9f944e78b4429ff4df3003da4821203b88824cbbb00a1ca2dd4362bcf194

Contents?: true

Size: 913 Bytes

Versions: 10

Compression:

Stored size: 913 Bytes

Contents

import { STATUS } from 'foremanReact/constants';

export const getHostIds = () => {
  const url = new URL(window.location);
  const hostId = url.searchParams.get('host_id');

  if (hostId) return [hostId];

  const cookie = document.cookie.split('; ')
    .find(row => row.startsWith('_ForemanSelectedhosts'));
  const params = new URLSearchParams(cookie);
  const ids = params.get('_ForemanSelectedhosts');

  if (ids) return JSON.parse(ids);
  return [];
};

export const formIsLoading = (data, contentView, change) => (
  data === STATUS.PENDING ||
  contentView === STATUS.PENDING ||
  change === STATUS.PENDING
);

export const copyToClipboard = (event, textToCopy) => {
  const clipboard = event.currentTarget.parentElement;
  const el = document.createElement('textarea');
  el.value = textToCopy;
  clipboard.appendChild(el);
  el.select();
  document.execCommand('copy');
  clipboard.removeChild(el);
};

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
katello-4.6.2.1 webpack/scenes/Hosts/ChangeContentSource/helpers.js
katello-4.6.2 webpack/scenes/Hosts/ChangeContentSource/helpers.js
katello-4.6.1 webpack/scenes/Hosts/ChangeContentSource/helpers.js
katello-4.5.1 webpack/scenes/Hosts/ChangeContentSource/helpers.js
katello-4.6.0 webpack/scenes/Hosts/ChangeContentSource/helpers.js
katello-4.6.0.rc2 webpack/scenes/Hosts/ChangeContentSource/helpers.js
katello-4.6.0.rc1 webpack/scenes/Hosts/ChangeContentSource/helpers.js
katello-4.5.0 webpack/scenes/Hosts/ChangeContentSource/helpers.js
katello-4.5.0.rc2 webpack/scenes/Hosts/ChangeContentSource/helpers.js
katello-4.5.0.rc1 webpack/scenes/Hosts/ChangeContentSource/helpers.js