Sha256: 0c07e97f3f9624116269e92fabe6e655e816901dfd51fc00fac6033ff44f75fc

Contents?: true

Size: 1.7 KB

Versions: 18

Compression:

Stored size: 1.7 KB

Contents

import React from 'react';
import { useAPI } from 'foremanReact/common/hooks/API/APIHooks';
import PropTypes from 'prop-types';

import Skeleton from 'react-loading-skeleton';
import EmptyState from 'foremanReact/components/common/EmptyState/EmptyStatePattern';
import { STATUS } from 'foremanReact/constants';
import { EmptyStateIcon } from '@patternfly/react-core';
import { ExclamationCircleIcon } from '@patternfly/react-icons';
import { global_danger_color_200 as dangerColor } from '@patternfly/react-tokens';
import { translate as __ } from 'foremanReact/common/I18n';
import { ENCTab } from './ENCTab';

const ENCPreview = ({ hostName }) => {
  const options = {
    params: { name: hostName, format: 'yml' },
    key: 'PUPPET_ENC_PREVIEW',
  };
  const url = `${window.location.origin.toString()}/foreman_puppet/hosts/${hostName}/externalNodes`;
  const { response, status } = useAPI('get', url, options);

  if (status === STATUS.PENDING) {
    return <Skeleton count={5} />;
  }

  if (status === STATUS.ERROR || !hostName) {
    const description = !hostName
      ? __("Couldn't find any ENC data for this host")
      : response?.response?.data?.message;
    const icon = (
      <EmptyStateIcon icon={ExclamationCircleIcon} color={dangerColor.value} />
    );
    return (
      <EmptyState header={__('Error!')} icon={icon} description={description} />
    );
  }
  if (response !== '' || response !== undefined) {
    return (
      <div className="enc-preview-tab" style={{ padding: '16px 24px' }}>
        <ENCTab encData={response} />
      </div>
    );
  }

  return null;
};

ENCPreview.propTypes = {
  hostName: PropTypes.string,
};

ENCPreview.defaultProps = {
  hostName: undefined,
};

export default ENCPreview;

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
foreman_puppet-8.1.0 webpack/src/Extends/Host/PuppetTab/SubTabs/ENCPreview/index.js
foreman_puppet-8.0.0 webpack/src/Extends/Host/PuppetTab/SubTabs/ENCPreview/index.js
foreman_puppet-6.4.0 webpack/src/Extends/Host/PuppetTab/SubTabs/ENCPreview/index.js
foreman_puppet-7.0.0 webpack/src/Extends/Host/PuppetTab/SubTabs/ENCPreview/index.js
foreman_puppet-6.3.0 webpack/src/Extends/Host/PuppetTab/SubTabs/ENCPreview/index.js
foreman_puppet-6.2.0 webpack/src/Extends/Host/PuppetTab/SubTabs/ENCPreview/index.js
foreman_puppet-6.1.1 webpack/src/Extends/Host/PuppetTab/SubTabs/ENCPreview/index.js
foreman_puppet-5.1.3 webpack/src/Extends/Host/PuppetTab/SubTabs/ENCPreview/index.js
foreman_puppet-6.1.0 webpack/src/Extends/Host/PuppetTab/SubTabs/ENCPreview/index.js
foreman_puppet-6.0.1 webpack/src/Extends/Host/PuppetTab/SubTabs/ENCPreview/index.js
foreman_puppet-6.0.0 webpack/src/Extends/Host/PuppetTab/SubTabs/ENCPreview/index.js
foreman_puppet-5.1.2 webpack/src/Extends/Host/PuppetTab/SubTabs/ENCPreview/index.js
foreman_puppet-4.1.1 webpack/src/Extends/Host/PuppetTab/SubTabs/ENCPreview/index.js
foreman_puppet-5.1.1 webpack/src/Extends/Host/PuppetTab/SubTabs/ENCPreview/index.js
foreman_puppet-5.1.0 webpack/src/Extends/Host/PuppetTab/SubTabs/ENCPreview/index.js
foreman_puppet-4.1.0 webpack/src/Extends/Host/PuppetTab/SubTabs/ENCPreview/index.js
foreman_puppet-4.0.4 webpack/src/Extends/Host/PuppetTab/SubTabs/ENCPreview/index.js
foreman_puppet-5.0.0 webpack/src/Extends/Host/PuppetTab/SubTabs/ENCPreview/index.js