mirror of
https://github.com/ansible/awx.git
synced 2026-01-22 15:08:03 -03:30
adds visualizer button to output toolbar
This commit is contained in:
parent
736cd4df36
commit
cf6b6d831f
@ -1,9 +1,14 @@
|
||||
import React, { useContext } from 'react';
|
||||
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import { t } from '@lingui/macro';
|
||||
import { shape } from 'prop-types';
|
||||
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 StatusIcon from '../../../components/StatusIcon';
|
||||
import {
|
||||
@ -58,11 +63,15 @@ const StatusIconWithMargin = styled(StatusIcon)`
|
||||
|
||||
function WorkflowOutputToolbar({ job }) {
|
||||
const dispatch = useContext(WorkflowDispatchContext);
|
||||
|
||||
const history = useHistory();
|
||||
const { nodes, showLegend, showTools } = useContext(WorkflowStateContext);
|
||||
|
||||
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 (
|
||||
<Toolbar id="workflow-output-toolbar">
|
||||
<ToolbarJob>
|
||||
@ -70,6 +79,15 @@ function WorkflowOutputToolbar({ job }) {
|
||||
<b>{job.name}</b>
|
||||
</ToolbarJob>
|
||||
<ToolbarActions>
|
||||
<ActionButton
|
||||
ouiaId="edit-workflow"
|
||||
aria-label={t`Edit workflow`}
|
||||
id="edit-workflow"
|
||||
variant="plain"
|
||||
onClick={navToWorkflow}
|
||||
>
|
||||
<ProjectDiagramIcon />
|
||||
</ActionButton>
|
||||
<div>{t`Total Nodes`}</div>
|
||||
<Badge isRead>{totalNodes}</Badge>
|
||||
<Tooltip content={t`Toggle Legend`} position="bottom">
|
||||
|
||||
@ -18,6 +18,9 @@ const workflowContext = {
|
||||
showTools: false,
|
||||
};
|
||||
|
||||
function shouldFind(element) {
|
||||
expect(wrapper.find(element)).toHaveLength(1);
|
||||
}
|
||||
describe('WorkflowOutputToolbar', () => {
|
||||
beforeAll(() => {
|
||||
const nodes = [
|
||||
@ -45,6 +48,13 @@ describe('WorkflowOutputToolbar', () => {
|
||||
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', () => {
|
||||
// The start node (id=1) and deleted nodes (isDeleted=true) should be ignored
|
||||
expect(wrapper.find('Badge').text()).toBe('1');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user