mirror of
https://github.com/ansible/awx.git
synced 2026-03-01 00:38:45 -03:30
Fixes bug where navigating from one output route to another was breaking
This commit is contained in:
@@ -135,7 +135,7 @@ function WorkflowNodeHelp({ node, i18n }) {
|
|||||||
<b>{i18n._(t`Job Status`)}</b>
|
<b>{i18n._(t`Job Status`)}</b>
|
||||||
</dt>
|
</dt>
|
||||||
<dd id="workflow-node-help-status">{jobStatus}</dd>
|
<dd id="workflow-node-help-status">{jobStatus}</dd>
|
||||||
{node.job.elapsed && (
|
{typeof node.job.elapsed === 'number' && (
|
||||||
<>
|
<>
|
||||||
<dt>
|
<dt>
|
||||||
<b>{i18n._(t`Elapsed`)}</b>
|
<b>{i18n._(t`Elapsed`)}</b>
|
||||||
@@ -159,7 +159,7 @@ function WorkflowNodeHelp({ node, i18n }) {
|
|||||||
<dd id="workflow-node-help-type">{nodeType}</dd>
|
<dd id="workflow-node-help-type">{nodeType}</dd>
|
||||||
</GridDL>
|
</GridDL>
|
||||||
)}
|
)}
|
||||||
{node.job && (
|
{node.job && node.job.type !== 'workflow_approval' && (
|
||||||
<p css="margin-top: 10px">{i18n._(t`Click to view job details`)}</p>
|
<p css="margin-top: 10px">{i18n._(t`Click to view job details`)}</p>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -1,5 +1,18 @@
|
|||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
|
|
||||||
|
export function initReducer() {
|
||||||
|
return {
|
||||||
|
contentError: null,
|
||||||
|
isLoading: true,
|
||||||
|
links: [],
|
||||||
|
nextNodeId: 0,
|
||||||
|
nodePositions: null,
|
||||||
|
nodes: [],
|
||||||
|
showLegend: false,
|
||||||
|
showTools: false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export default function visualizerReducer(state, action) {
|
export default function visualizerReducer(state, action) {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case 'CREATE_LINK':
|
case 'CREATE_LINK':
|
||||||
@@ -25,6 +38,8 @@ export default function visualizerReducer(state, action) {
|
|||||||
return deleteNode(state);
|
return deleteNode(state);
|
||||||
case 'GENERATE_NODES_AND_LINKS':
|
case 'GENERATE_NODES_AND_LINKS':
|
||||||
return generateNodesAndLinks(state, action.nodes, action.i18n);
|
return generateNodesAndLinks(state, action.nodes, action.i18n);
|
||||||
|
case 'RESET':
|
||||||
|
return initReducer();
|
||||||
case 'SELECT_SOURCE_FOR_LINKING':
|
case 'SELECT_SOURCE_FOR_LINKING':
|
||||||
return selectSourceForLinking(state, action.node);
|
return selectSourceForLinking(state, action.node);
|
||||||
case 'SET_ADD_LINK_SOURCE_NODE':
|
case 'SET_ADD_LINK_SOURCE_NODE':
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ class Job extends Component {
|
|||||||
exact
|
exact
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
key="details"
|
key="workflow-details"
|
||||||
path="/jobs/workflow/:id/details"
|
path="/jobs/workflow/:id/details"
|
||||||
render={() =>
|
render={() =>
|
||||||
job &&
|
job &&
|
||||||
@@ -131,7 +131,7 @@ class Job extends Component {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
key="output"
|
key="workflow-output"
|
||||||
path="/jobs/workflow/:id/output"
|
path="/jobs/workflow/:id/output"
|
||||||
render={() =>
|
render={() =>
|
||||||
job &&
|
job &&
|
||||||
|
|||||||
@@ -10,7 +10,9 @@ import {
|
|||||||
import { layoutGraph } from '@components/Workflow/WorkflowUtils';
|
import { layoutGraph } from '@components/Workflow/WorkflowUtils';
|
||||||
import ContentError from '@components/ContentError';
|
import ContentError from '@components/ContentError';
|
||||||
import ContentLoading from '@components/ContentLoading';
|
import ContentLoading from '@components/ContentLoading';
|
||||||
import workflowReducer from '@components/Workflow/workflowReducer';
|
import workflowReducer, {
|
||||||
|
initReducer,
|
||||||
|
} from '@components/Workflow/workflowReducer';
|
||||||
import { WorkflowJobsAPI } from '@api';
|
import { WorkflowJobsAPI } from '@api';
|
||||||
import WorkflowOutputGraph from './WorkflowOutputGraph';
|
import WorkflowOutputGraph from './WorkflowOutputGraph';
|
||||||
import WorkflowOutputToolbar from './WorkflowOutputToolbar';
|
import WorkflowOutputToolbar from './WorkflowOutputToolbar';
|
||||||
@@ -41,17 +43,7 @@ const fetchWorkflowNodes = async (jobId, pageNo = 1, nodes = []) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function WorkflowOutput({ job, i18n }) {
|
function WorkflowOutput({ job, i18n }) {
|
||||||
const [state, dispatch] = useReducer(workflowReducer, {
|
const [state, dispatch] = useReducer(workflowReducer, {}, initReducer);
|
||||||
contentError: null,
|
|
||||||
isLoading: true,
|
|
||||||
links: [],
|
|
||||||
nextNodeId: 0,
|
|
||||||
nodePositions: null,
|
|
||||||
nodes: [],
|
|
||||||
showLegend: false,
|
|
||||||
showTools: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
const { contentError, isLoading, links, nodePositions, nodes } = state;
|
const { contentError, isLoading, links, nodePositions, nodes } = state;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -69,6 +61,7 @@ function WorkflowOutput({ job, i18n }) {
|
|||||||
dispatch({ type: 'SET_IS_LOADING', value: false });
|
dispatch({ type: 'SET_IS_LOADING', value: false });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
dispatch({ type: 'RESET' });
|
||||||
fetchData();
|
fetchData();
|
||||||
}, [job.id, i18n]);
|
}, [job.id, i18n]);
|
||||||
|
|
||||||
@@ -84,7 +77,7 @@ function WorkflowOutput({ job, i18n }) {
|
|||||||
|
|
||||||
dispatch({ type: 'SET_NODE_POSITIONS', value: newNodePositions });
|
dispatch({ type: 'SET_NODE_POSITIONS', value: newNodePositions });
|
||||||
}
|
}
|
||||||
}, [links, nodes]);
|
}, [job.id, links, nodes]);
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -11,7 +11,10 @@ import { secondsToHHMMSS } from '@util/dates';
|
|||||||
import { constants as wfConstants } from '@components/Workflow/WorkflowUtils';
|
import { constants as wfConstants } from '@components/Workflow/WorkflowUtils';
|
||||||
|
|
||||||
const NodeG = styled.g`
|
const NodeG = styled.g`
|
||||||
cursor: ${props => (props.job ? 'pointer' : 'default')};
|
cursor: ${props =>
|
||||||
|
props.job && props.job.type !== 'workflow_approval'
|
||||||
|
? 'pointer'
|
||||||
|
: 'default'};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const JobTopLine = styled.div`
|
const JobTopLine = styled.div`
|
||||||
@@ -75,7 +78,7 @@ function WorkflowOutputNode({ i18n, mouseEnter, mouseLeave, node }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleNodeClick = () => {
|
const handleNodeClick = () => {
|
||||||
if (node.job) {
|
if (node.job && node.job.type !== 'workflow_aproval') {
|
||||||
history.push(`/jobs/${node.job.id}/details`);
|
history.push(`/jobs/${node.job.id}/details`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user