Sha256: 1efa037966fef59294a50f30f16c19b0add02db58d3687f0e5cc8183fd4559d3

Contents?: true

Size: 1.66 KB

Versions: 7

Compression:

Stored size: 1.66 KB

Contents

import React from 'react';
import { Button, Icon } from 'patternfly-react';

import { sprintf, translate as __ } from 'foremanReact/common/I18n';

import './snapshotList.scss';

export const renderListEntryButtons = (
  canDelete,
  canRevert,
  canUpdate,
  host,
  snapshotRollbackAction,
  snapshotDeleteAction,
  inlineEditController
) => disabled => (value, additionalData) => {
  const buttons = [];

  // Edit Button
  if (canUpdate) {
    buttons.push(
      <Button
        key="edit-button"
        bsStyle="default"
        disabled={disabled}
        onClick={() => inlineEditController.onActivate(additionalData)}
      >
        <Icon type="pf" name="edit" title={__('edit entry')} />
      </Button>
    );
  }

  // Rollback button
  if (canRevert) {
    buttons.push(
      <Button
        key="rollback-button"
        bsStyle="default"
        disabled={disabled}
        onClick={() =>
          window.confirm(
            sprintf(__('Rollback to "%s"?'), additionalData.rowData.name)
          ) && snapshotRollbackAction(host, additionalData.rowData)
        }
      >
        <Icon type="pf" name="history" title={__('Rollback')} />
      </Button>
    );
  }

  // Delete Button
  if (canDelete) {
    buttons.push(
      <Button
        key="delete-button"
        bsStyle="default"
        disabled={disabled}
        onClick={() =>
          window.confirm(
            sprintf(__('Delete Snapshot "%s"?'), additionalData.rowData.name)
          ) && snapshotDeleteAction(host, additionalData.rowData)
        }
      >
        <Icon type="pf" name="delete" title={__('Delete')} />
      </Button>
    );
  }

  return <td className="action-buttons">{buttons}</td>;
};

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
foreman_snapshot_management-4.0.0 webpack/components/SnapshotManagement/components/SnapshotList/SnapshotListHelper.js
foreman_snapshot_management-3.0.1 webpack/components/SnapshotManagement/components/SnapshotList/SnapshotListHelper.js
foreman_snapshot_management-3.0.0 webpack/components/SnapshotManagement/components/SnapshotList/SnapshotListHelper.js
foreman_snapshot_management-2.0.3 webpack/components/SnapshotManagement/components/SnapshotList/SnapshotListHelper.js
foreman_snapshot_management-2.0.2 webpack/components/SnapshotManagement/components/SnapshotList/SnapshotListHelper.js
foreman_snapshot_management-2.0.1 webpack/components/SnapshotManagement/components/SnapshotList/SnapshotListHelper.js
foreman_snapshot_management-2.0.0 webpack/components/SnapshotManagement/components/SnapshotList/SnapshotListHelper.js