Sha256: 89071b84c3501270323e1c1de538af221ca0d4a5e6875b48431fe8528f805001

Contents?: true

Size: 1.07 KB

Versions: 5

Compression:

Stored size: 1.07 KB

Contents

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

export const ActionButton = ({ id, name, canDelete, webhookActions }) => {
  const buttons = [];
  if (canDelete) {
    buttons.push({
      title: __('Delete'),
      action: {
        onClick: () => webhookActions.deleteWebhook(id, name),
        id: `webhook-delete-button-${id}`,
      },
    });
  }
  buttons.push({
    title: __('Test webhook'),
    action: {
      onClick: () => webhookActions.testWebhook(id, name),
      id: `webhook-test-button-${id}`,
    },
  });

  return <ActionButtons buttons={buttons} />;
};

ActionButton.propTypes = {
  id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
  name: PropTypes.string.isRequired,
  canDelete: PropTypes.bool,
  webhookActions: PropTypes.shape({
    deleteWebhook: PropTypes.func,
    testWebhook: PropTypes.func,
  }).isRequired,
};

ActionButton.defaultProps = {
  canDelete: false,
};

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
foreman_webhooks-4.0.0 webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/ActionButtons/ActionButton.js
foreman_webhooks-3.2.3 webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/ActionButtons/ActionButton.js
foreman_webhooks-3.2.2 webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/ActionButtons/ActionButton.js
foreman_webhooks-3.2.1 webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/ActionButtons/ActionButton.js
foreman_webhooks-3.2.0 webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/ActionButtons/ActionButton.js