mirror of
https://github.com/ansible/awx.git
synced 2026-05-17 06:17:36 -02:30
Use delete item hook for job output delete
This commit is contained in:
@@ -2,7 +2,7 @@ import React from 'react';
|
|||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { withI18n } from '@lingui/react';
|
import { withI18n } from '@lingui/react';
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import { shape, func } from 'prop-types';
|
import { bool, shape, func } from 'prop-types';
|
||||||
import {
|
import {
|
||||||
MinusCircleIcon,
|
MinusCircleIcon,
|
||||||
DownloadIcon,
|
DownloadIcon,
|
||||||
@@ -62,7 +62,14 @@ const OUTPUT_NO_COUNT_JOB_TYPES = [
|
|||||||
'inventory_update',
|
'inventory_update',
|
||||||
];
|
];
|
||||||
|
|
||||||
const OutputToolbar = ({ i18n, job, jobStatus, onDelete, onCancel }) => {
|
const OutputToolbar = ({
|
||||||
|
i18n,
|
||||||
|
job,
|
||||||
|
jobStatus,
|
||||||
|
onDelete,
|
||||||
|
onCancel,
|
||||||
|
isDeleteDisabled,
|
||||||
|
}) => {
|
||||||
const hideCounts = OUTPUT_NO_COUNT_JOB_TYPES.includes(job.type);
|
const hideCounts = OUTPUT_NO_COUNT_JOB_TYPES.includes(job.type);
|
||||||
|
|
||||||
const playCount = job?.playbook_counts?.play_count;
|
const playCount = job?.playbook_counts?.play_count;
|
||||||
@@ -178,7 +185,6 @@ const OutputToolbar = ({ i18n, job, jobStatus, onDelete, onCancel }) => {
|
|||||||
</Button>
|
</Button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{job.summary_fields.user_capabilities.delete &&
|
{job.summary_fields.user_capabilities.delete &&
|
||||||
['new', 'successful', 'failed', 'error', 'canceled'].includes(
|
['new', 'successful', 'failed', 'error', 'canceled'].includes(
|
||||||
jobStatus
|
jobStatus
|
||||||
@@ -189,6 +195,7 @@ const OutputToolbar = ({ i18n, job, jobStatus, onDelete, onCancel }) => {
|
|||||||
modalTitle={i18n._(t`Delete Job`)}
|
modalTitle={i18n._(t`Delete Job`)}
|
||||||
onConfirm={onDelete}
|
onConfirm={onDelete}
|
||||||
variant="plain"
|
variant="plain"
|
||||||
|
isDisabled={isDeleteDisabled}
|
||||||
>
|
>
|
||||||
<TrashAltIcon />
|
<TrashAltIcon />
|
||||||
</DeleteButton>
|
</DeleteButton>
|
||||||
@@ -199,8 +206,13 @@ const OutputToolbar = ({ i18n, job, jobStatus, onDelete, onCancel }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
OutputToolbar.propTypes = {
|
OutputToolbar.propTypes = {
|
||||||
|
isDeleteDisabled: bool,
|
||||||
job: shape({}).isRequired,
|
job: shape({}).isRequired,
|
||||||
onDelete: func.isRequired,
|
onDelete: func.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
OutputToolbar.defaultProps = {
|
||||||
|
isDeleteDisabled: false,
|
||||||
|
};
|
||||||
|
|
||||||
export default withI18n()(OutputToolbar);
|
export default withI18n()(OutputToolbar);
|
||||||
|
|||||||
Reference in New Issue
Block a user