Skip to content

Commit

Permalink
Reload the page resets back the default pipeline (#2041)
Browse files Browse the repository at this point in the history
* check pipeline ID in URL and use if it exists

Signed-off-by: Sajid Alam <[email protected]>

* Update flowchart-wrapper.js

Signed-off-by: Sajid Alam <[email protected]>

* fix expanding pipelines error

Signed-off-by: Sajid Alam <[email protected]>

* check for page refresh

Signed-off-by: Sajid Alam <[email protected]>

* undo page refresh check

Signed-off-by: Sajid Alam <[email protected]>

* check if active pipeline is already set

Signed-off-by: Sajid Alam <[email protected]>

* changes based on review

Signed-off-by: Sajid Alam <[email protected]>

* fixed

Signed-off-by: rashidakanchwala <[email protected]>

* revert one change

Signed-off-by: rashidakanchwala <[email protected]>

* fixed child error

Signed-off-by: rashidakanchwala <[email protected]>

* check if it is valid child of the modular pipeline

Signed-off-by: Sajid Alam <[email protected]>

---------

Signed-off-by: Sajid Alam <[email protected]>
Signed-off-by: rashidakanchwala <[email protected]>
Co-authored-by: rashidakanchwala <[email protected]>
  • Loading branch information
SajidAlamQB and rashidakanchwala authored Sep 5, 2024
1 parent 308f93d commit 0ff262e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
7 changes: 4 additions & 3 deletions src/actions/pipelines.js
Original file line number Diff line number Diff line change
@@ -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';

/**
Expand Down Expand Up @@ -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));
Expand Down
7 changes: 4 additions & 3 deletions src/components/flowchart-wrapper/flowchart-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,17 @@ 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 &&
graph.nodes.find(
(node) => node.id === nodeId && node.type === 'parameters'
);

if (hasModularPipeline && !isParameterType) {
if (isModularPipelineChild && !isParameterType) {
onToggleModularPipelineExpanded(modularPipeline);
}
onToggleNodeSelected(nodeId);
Expand Down Expand Up @@ -237,7 +239,6 @@ export const FlowChartWrapper = ({
*/
useEffect(() => {
const isGraphEmpty = Object.keys(graph).length === 0;

if (
(graphRef.current === null || usedNavigationBtn || isInvalidUrl) &&
!isGraphEmpty
Expand Down
3 changes: 1 addition & 2 deletions src/store/initial-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -250,7 +250,6 @@ const getInitialState = (props = {}) => {
props.data,
props.data !== 'json',
expandAllPipelines,
urlParams
);

const initialState = {
Expand Down

0 comments on commit 0ff262e

Please sign in to comment.