mirror of
https://github.com/ansible/awx.git
synced 2026-05-17 14:27:42 -02:30
adds visualizer button to output toolbar
This commit is contained in:
committed by
Shane McDonald
parent
736cd4df36
commit
cf6b6d831f
@@ -1,9 +1,14 @@
|
|||||||
import React, { useContext } from 'react';
|
import React, { useContext } from 'react';
|
||||||
|
import { useHistory } from 'react-router-dom';
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import { shape } from 'prop-types';
|
import { shape } from 'prop-types';
|
||||||
import { Badge as PFBadge, Button, Tooltip } from '@patternfly/react-core';
|
import { Badge as PFBadge, Button, Tooltip } from '@patternfly/react-core';
|
||||||
import { CompassIcon, WrenchIcon } from '@patternfly/react-icons';
|
|
||||||
|
import {
|
||||||
|
CompassIcon,
|
||||||
|
WrenchIcon,
|
||||||
|
ProjectDiagramIcon,
|
||||||
|
} from '@patternfly/react-icons';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import StatusIcon from '../../../components/StatusIcon';
|
import StatusIcon from '../../../components/StatusIcon';
|
||||||
import {
|
import {
|
||||||
@@ -58,11 +63,15 @@ const StatusIconWithMargin = styled(StatusIcon)`
|
|||||||
|
|
||||||
function WorkflowOutputToolbar({ job }) {
|
function WorkflowOutputToolbar({ job }) {
|
||||||
const dispatch = useContext(WorkflowDispatchContext);
|
const dispatch = useContext(WorkflowDispatchContext);
|
||||||
|
const history = useHistory();
|
||||||
const { nodes, showLegend, showTools } = useContext(WorkflowStateContext);
|
const { nodes, showLegend, showTools } = useContext(WorkflowStateContext);
|
||||||
|
|
||||||
const totalNodes = nodes.reduce((n, node) => n + !node.isDeleted, 0) - 1;
|
const totalNodes = nodes.reduce((n, node) => n + !node.isDeleted, 0) - 1;
|
||||||
|
const navToWorkflow = () => {
|
||||||
|
history.push(
|
||||||
|
`/templates/workflow_job_template/${job.unified_job_template}/visualizer`
|
||||||
|
);
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<Toolbar id="workflow-output-toolbar">
|
<Toolbar id="workflow-output-toolbar">
|
||||||
<ToolbarJob>
|
<ToolbarJob>
|
||||||
@@ -70,6 +79,15 @@ function WorkflowOutputToolbar({ job }) {
|
|||||||
<b>{job.name}</b>
|
<b>{job.name}</b>
|
||||||
</ToolbarJob>
|
</ToolbarJob>
|
||||||
<ToolbarActions>
|
<ToolbarActions>
|
||||||
|
<ActionButton
|
||||||
|
ouiaId="edit-workflow"
|
||||||
|
aria-label={t`Edit workflow`}
|
||||||
|
id="edit-workflow"
|
||||||
|
variant="plain"
|
||||||
|
onClick={navToWorkflow}
|
||||||
|
>
|
||||||
|
<ProjectDiagramIcon />
|
||||||
|
</ActionButton>
|
||||||
<div>{t`Total Nodes`}</div>
|
<div>{t`Total Nodes`}</div>
|
||||||
<Badge isRead>{totalNodes}</Badge>
|
<Badge isRead>{totalNodes}</Badge>
|
||||||
<Tooltip content={t`Toggle Legend`} position="bottom">
|
<Tooltip content={t`Toggle Legend`} position="bottom">
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ const workflowContext = {
|
|||||||
showTools: false,
|
showTools: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function shouldFind(element) {
|
||||||
|
expect(wrapper.find(element)).toHaveLength(1);
|
||||||
|
}
|
||||||
describe('WorkflowOutputToolbar', () => {
|
describe('WorkflowOutputToolbar', () => {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
const nodes = [
|
const nodes = [
|
||||||
@@ -45,6 +48,13 @@ describe('WorkflowOutputToolbar', () => {
|
|||||||
wrapper.unmount();
|
wrapper.unmount();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should render correct toolbar item', () => {
|
||||||
|
shouldFind(`Button[ouiaId="edit-workflow"]`);
|
||||||
|
shouldFind('Button#workflow-output-toggle-legend');
|
||||||
|
shouldFind('Badge');
|
||||||
|
shouldFind('Button#workflow-output-toggle-tools');
|
||||||
|
});
|
||||||
|
|
||||||
test('Shows correct number of nodes', () => {
|
test('Shows correct number of nodes', () => {
|
||||||
// The start node (id=1) and deleted nodes (isDeleted=true) should be ignored
|
// The start node (id=1) and deleted nodes (isDeleted=true) should be ignored
|
||||||
expect(wrapper.find('Badge').text()).toBe('1');
|
expect(wrapper.find('Badge').text()).toBe('1');
|
||||||
|
|||||||
Reference in New Issue
Block a user