mirror of
https://github.com/ansible/awx.git
synced 2026-02-26 15:36:04 -03:30
Merge pull request #8019 from mabashian/7663-workflow-viz-button
Adds visualizer button to workflow template rows on templates list Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
@@ -15,6 +15,7 @@ import { withI18n } from '@lingui/react';
|
|||||||
import {
|
import {
|
||||||
ExclamationTriangleIcon,
|
ExclamationTriangleIcon,
|
||||||
PencilAltIcon,
|
PencilAltIcon,
|
||||||
|
ProjectDiagramIcon,
|
||||||
RocketIcon,
|
RocketIcon,
|
||||||
} from '@patternfly/react-icons';
|
} from '@patternfly/react-icons';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
@@ -32,7 +33,7 @@ const DataListAction = styled(_DataListAction)`
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-gap: 16px;
|
grid-gap: 16px;
|
||||||
grid-template-columns: repeat(3, 40px);
|
grid-template-columns: repeat(4, 40px);
|
||||||
`;
|
`;
|
||||||
|
|
||||||
function TemplateListItem({
|
function TemplateListItem({
|
||||||
@@ -104,6 +105,20 @@ function TemplateListItem({
|
|||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
<DataListAction aria-label="actions" aria-labelledby={labelId}>
|
<DataListAction aria-label="actions" aria-labelledby={labelId}>
|
||||||
|
{template.type === 'workflow_job_template' && (
|
||||||
|
<Tooltip content={i18n._(t`Visualizer`)} position="top">
|
||||||
|
<Button
|
||||||
|
isDisabled={isDisabled}
|
||||||
|
aria-label={i18n._(t`Visualizer`)}
|
||||||
|
css="grid-column: 1"
|
||||||
|
variant="plain"
|
||||||
|
component={Link}
|
||||||
|
to={`/templates/workflow_job_template/${template.id}/visualizer`}
|
||||||
|
>
|
||||||
|
<ProjectDiagramIcon />
|
||||||
|
</Button>
|
||||||
|
</Tooltip>
|
||||||
|
)}
|
||||||
{template.summary_fields.user_capabilities.start && (
|
{template.summary_fields.user_capabilities.start && (
|
||||||
<Tooltip content={i18n._(t`Launch Template`)} position="top">
|
<Tooltip content={i18n._(t`Launch Template`)} position="top">
|
||||||
<LaunchButton resource={template}>
|
<LaunchButton resource={template}>
|
||||||
@@ -111,7 +126,7 @@ function TemplateListItem({
|
|||||||
<Button
|
<Button
|
||||||
isDisabled={isDisabled}
|
isDisabled={isDisabled}
|
||||||
aria-label={i18n._(t`Launch template`)}
|
aria-label={i18n._(t`Launch template`)}
|
||||||
css="grid-column: 1"
|
css="grid-column: 2"
|
||||||
variant="plain"
|
variant="plain"
|
||||||
onClick={handleLaunch}
|
onClick={handleLaunch}
|
||||||
>
|
>
|
||||||
@@ -126,7 +141,7 @@ function TemplateListItem({
|
|||||||
<Button
|
<Button
|
||||||
isDisabled={isDisabled}
|
isDisabled={isDisabled}
|
||||||
aria-label={i18n._(t`Edit Template`)}
|
aria-label={i18n._(t`Edit Template`)}
|
||||||
css="grid-column: 2"
|
css="grid-column: 3"
|
||||||
variant="plain"
|
variant="plain"
|
||||||
component={Link}
|
component={Link}
|
||||||
to={`/templates/${template.type}/${template.id}/edit`}
|
to={`/templates/${template.type}/${template.id}/edit`}
|
||||||
|
|||||||
@@ -239,4 +239,29 @@ describe('<TemplateListItem />', () => {
|
|||||||
);
|
);
|
||||||
expect(wrapper.find('CopyButton').length).toBe(0);
|
expect(wrapper.find('CopyButton').length).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should render visualizer button for workflow', async () => {
|
||||||
|
const wrapper = mountWithContexts(
|
||||||
|
<TemplateListItem
|
||||||
|
isSelected={false}
|
||||||
|
detailUrl="/templates/job_template/1/details"
|
||||||
|
template={{
|
||||||
|
...mockJobTemplateData,
|
||||||
|
type: 'workflow_job_template',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
expect(wrapper.find('ProjectDiagramIcon').length).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should not render visualizer button for job template', async () => {
|
||||||
|
const wrapper = mountWithContexts(
|
||||||
|
<TemplateListItem
|
||||||
|
isSelected={false}
|
||||||
|
detailUrl="/templates/job_template/1/details"
|
||||||
|
template={mockJobTemplateData}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
expect(wrapper.find('ProjectDiagramIcon').length).toBe(0);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user