From 0ff262e79d889c0f0fccb0338186cfd79500ebd0 Mon Sep 17 00:00:00 2001 From: Sajid Alam <90610031+SajidAlamQB@users.noreply.github.com> Date: Thu, 5 Sep 2024 18:04:40 +0100 Subject: [PATCH] Reload the page resets back the default pipeline (#2041) * check pipeline ID in URL and use if it exists Signed-off-by: Sajid Alam <sajid_alam@mckinsey.com> * Update flowchart-wrapper.js Signed-off-by: Sajid Alam <sajid_alam@mckinsey.com> * fix expanding pipelines error Signed-off-by: Sajid Alam <sajid_alam@mckinsey.com> * check for page refresh Signed-off-by: Sajid Alam <sajid_alam@mckinsey.com> * undo page refresh check Signed-off-by: Sajid Alam <sajid_alam@mckinsey.com> * check if active pipeline is already set Signed-off-by: Sajid Alam <sajid_alam@mckinsey.com> * changes based on review Signed-off-by: Sajid Alam <sajid_alam@mckinsey.com> * fixed Signed-off-by: rashidakanchwala <rashida_kanchwala@mckinsey.com> * revert one change Signed-off-by: rashidakanchwala <rashida_kanchwala@mckinsey.com> * fixed child error Signed-off-by: rashidakanchwala <rashida_kanchwala@mckinsey.com> * check if it is valid child of the modular pipeline Signed-off-by: Sajid Alam <sajid_alam@mckinsey.com> --------- Signed-off-by: Sajid Alam <sajid_alam@mckinsey.com> Signed-off-by: rashidakanchwala <rashida_kanchwala@mckinsey.com> Co-authored-by: rashidakanchwala <rashida_kanchwala@mckinsey.com> --- src/actions/pipelines.js | 7 ++++--- src/components/flowchart-wrapper/flowchart-wrapper.js | 7 ++++--- src/store/initial-state.js | 3 +-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/actions/pipelines.js b/src/actions/pipelines.js index aabdf139a8..c93598227a 100644 --- a/src/actions/pipelines.js +++ b/src/actions/pipelines.js @@ -1,6 +1,6 @@ import { getUrl } from '../utils'; import loadJsonData from '../store/load-data'; -import { preparePipelineState } from '../store/initial-state'; +import {parseUrlParameters, preparePipelineState} from '../store/initial-state'; import { resetData } from './index'; /** @@ -99,14 +99,15 @@ export function loadInitialPipelineData() { // obtain the status of expandAllPipelines to decide whether it needs to overwrite the // list of visible nodes const expandAllPipelines = state.expandAllPipelines; + const urlParams = parseUrlParameters(); let newState = await loadJsonData(url).then((data) => - preparePipelineState(data, true, expandAllPipelines) + preparePipelineState(data, true, expandAllPipelines, urlParams) ); // If the active pipeline isn't 'main' then request data from new URL if (requiresSecondRequest(newState.pipeline)) { const url = getPipelineUrl(newState.pipeline); newState = await loadJsonData(url).then((data) => - preparePipelineState(data, false, expandAllPipelines) + preparePipelineState(data, false, expandAllPipelines, urlParams) ); } dispatch(resetData(newState)); diff --git a/src/components/flowchart-wrapper/flowchart-wrapper.js b/src/components/flowchart-wrapper/flowchart-wrapper.js index 1b23a95101..9f3837f71f 100644 --- a/src/components/flowchart-wrapper/flowchart-wrapper.js +++ b/src/components/flowchart-wrapper/flowchart-wrapper.js @@ -168,7 +168,9 @@ export const FlowChartWrapper = ({ if (nodeId) { const modularPipeline = nodes[nodeId]; - const hasModularPipeline = modularPipeline?.length > 0; + const modularPipelineTree = modularPipelinesTree[modularPipeline]; + const isModularPipelineChild = + modularPipelineTree?.children?.includes(nodeId); const isParameterType = graph.nodes && @@ -176,7 +178,7 @@ export const FlowChartWrapper = ({ (node) => node.id === nodeId && node.type === 'parameters' ); - if (hasModularPipeline && !isParameterType) { + if (isModularPipelineChild && !isParameterType) { onToggleModularPipelineExpanded(modularPipeline); } onToggleNodeSelected(nodeId); @@ -237,7 +239,6 @@ export const FlowChartWrapper = ({ */ useEffect(() => { const isGraphEmpty = Object.keys(graph).length === 0; - if ( (graphRef.current === null || usedNavigationBtn || isInvalidUrl) && !isGraphEmpty diff --git a/src/store/initial-state.js b/src/store/initial-state.js index 3bda88b3e0..9dca179a98 100644 --- a/src/store/initial-state.js +++ b/src/store/initial-state.js @@ -57,7 +57,7 @@ export const createInitialState = () => ({ runsMetadata: {}, }); -const parseUrlParameters = () => { +export const parseUrlParameters = () => { const search = new URLSearchParams(window.location.search); return { pipelineIdFromURL: search.get(params.pipeline), @@ -250,7 +250,6 @@ const getInitialState = (props = {}) => { props.data, props.data !== 'json', expandAllPipelines, - urlParams ); const initialState = {