Sha256: 07be9d6caf9373da597b3024ecb7c365744ee45d7c7506c4c53683518d827e1b

Contents?: true

Size: 1.59 KB

Versions: 9

Compression:

Stored size: 1.59 KB

Contents

import React from 'react';
import PropTypes from 'prop-types';
import { translate as __ } from 'foremanReact/common/I18n';
import DefaultEmptyState from 'foremanReact/components/common/EmptyState';

import { useForemanModal } from 'foremanReact/components/ForemanModal/ForemanModalHooks';

import WebhookCreateModal from '../WebhookCreateModal';
import { WEBHOOK_CREATE_MODAL_ID } from '../../../constants';

const EmptyWebhooksIndexPage = ({
  search,
  reloadWithSearch,
  message: { type, text },
}) => {
  const {
    setModalOpen: setCreateModalOpen,
    setModalClosed: setCreateModalClosed,
  } = useForemanModal({
    id: WEBHOOK_CREATE_MODAL_ID,
  });

  return (
    <>
      <WebhookCreateModal
        onSuccess={() => {
          setCreateModalClosed();
          reloadWithSearch(search);
        }}
        onCancel={setCreateModalClosed}
      />
      <DefaultEmptyState
        icon={type === 'error' ? 'error-circle-o' : 'add-circle-o'}
        header={type === 'error' ? __('Error') : __('No Results')}
        description={text}
        documentation={null}
        action={{
          title: __('Create Webhook'),
          onClick: () => setCreateModalOpen(),
        }}
      />
    </>
  );
};

EmptyWebhooksIndexPage.propTypes = {
  message: PropTypes.shape({
    type: PropTypes.oneOf(['empty', 'error']),
    text: PropTypes.string,
  }),
  search: PropTypes.string,
  reloadWithSearch: PropTypes.func.isRequired,
};

EmptyWebhooksIndexPage.defaultProps = {
  message: {
    type: 'empty',
    text: __('Try to create a new Webhook'),
  },
  search: '',
};

export default EmptyWebhooksIndexPage;

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
foreman_webhooks-2.0.3 webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/EmptyWebhooksIndexPage/index.js
foreman_webhooks-2.0.2 webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/EmptyWebhooksIndexPage/index.js
foreman_webhooks-3.0.3 webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/EmptyWebhooksIndexPage/index.js
foreman_webhooks-3.0.2 webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/EmptyWebhooksIndexPage/index.js
foreman_webhooks-3.0.1 webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/EmptyWebhooksIndexPage/index.js
foreman_webhooks-2.0.1 webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/EmptyWebhooksIndexPage/index.js
foreman_webhooks-3.0.0 webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/EmptyWebhooksIndexPage/index.js
foreman_webhooks-2.0.0 webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/EmptyWebhooksIndexPage/index.js
foreman_webhooks-1.1.0 webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/EmptyWebhooksIndexPage/index.js