Sha256: 455a672b551350bff5e30ba1f475ff3e3f5b173293bfe6037dfda5ffd5c637e8

Contents?: true

Size: 939 Bytes

Versions: 7

Compression:

Stored size: 939 Bytes

Contents

import React from 'react';
import PropTypes from 'prop-types';
import { CancelButton } from './CancelButton';
import { ResumeButton } from './ResumeButton';

export const ActionButton = ({ id, name, availableActions, taskActions }) => {
  const isResume = availableActions.resumable;
  if (isResume) {
    return (
      <ResumeButton
        id={id}
        name={name}
        onClick={taskActions.resume}
        disabled={false}
      />
    );
  }
  return (
    <CancelButton
      id={id}
      name={name}
      disabled={!availableActions.cancellable}
      onClick={taskActions.cancel}
    />
  );
};

ActionButton.propTypes = {
  id: PropTypes.string.isRequired,
  name: PropTypes.string.isRequired,
  availableActions: PropTypes.shape({
    cancellable: PropTypes.bool,
    resumable: PropTypes.bool,
  }).isRequired,
  taskActions: PropTypes.shape({
    cancel: PropTypes.func,
    resume: PropTypes.func,
  }).isRequired,
};

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
foreman-tasks-0.17.6 webpack/ForemanTasks/Components/common/ActionButtons/ActionButton.js
foreman-tasks-1.0.0 webpack/ForemanTasks/Components/common/ActionButtons/ActionButton.js
foreman-tasks-0.17.5 webpack/ForemanTasks/Components/common/ActionButtons/ActionButton.js
foreman-tasks-0.17.4 webpack/ForemanTasks/Components/common/ActionButtons/ActionButton.js
foreman-tasks-0.17.3 webpack/ForemanTasks/Components/common/ActionButtons/ActionButton.js
foreman-tasks-0.17.2 webpack/ForemanTasks/Components/common/ActionButtons/ActionButton.js
foreman-tasks-0.17.1 webpack/ForemanTasks/Components/common/ActionButtons/ActionButton.js