From 25c797655ddbac935c9da7714a49aa7c92a6d6ec Mon Sep 17 00:00:00 2001 From: Sajid Alam Date: Tue, 17 Dec 2024 12:15:04 +0000 Subject: [PATCH 01/12] Update flowchart-primary-toolbar.js Signed-off-by: Sajid Alam --- .../flowchart-primary-toolbar/flowchart-primary-toolbar.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.js b/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.js index c63cc9f186..d36a726fba 100644 --- a/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.js +++ b/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.js @@ -126,7 +126,6 @@ export const mapDispatchToProps = (dispatch) => ({ }, onToggleExpandAllPipelines: (isExpanded) => { dispatch(toggleExpandAllPipelines(isExpanded)); - dispatch(loadInitialPipelineData()); }, }); From 5878705c29f3cba847e0106f66752d3e87e37de0 Mon Sep 17 00:00:00 2001 From: Sajid Alam Date: Thu, 19 Dec 2024 14:52:43 +0000 Subject: [PATCH 02/12] Update disabled.js Signed-off-by: Sajid Alam --- src/selectors/disabled.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/selectors/disabled.js b/src/selectors/disabled.js index 9feae33c13..8a8f1eb36e 100644 --- a/src/selectors/disabled.js +++ b/src/selectors/disabled.js @@ -24,6 +24,7 @@ const getNodeLayer = (state) => state.node.layer; const getNodeModularPipelines = (state) => state.node.modularPipelines; const getVisibleSidebarNodes = (state) => state.modularPipeline.visible; const getSliceApply = (state) => state.slice.apply; +const getExpandAllPipelines = (state) => state.expandAllPipelines; /** * Return all inputs and outputs of currently visible modular pipelines @@ -150,6 +151,7 @@ export const getNodeDisabled = createSelector( getDisabledModularPipeline, getSlicedPipeline, getSliceApply, + getExpandAllPipelines, ], ( nodeIDs, @@ -163,19 +165,23 @@ export const getNodeDisabled = createSelector( visibleModularPipelineInputsOutputs, disabledModularPipeline, slicedPipeline, - isSliceApplied + isSliceApplied, + expandAllPipelines ) => arrayToObject(nodeIDs, (id) => { let isDisabledViaSlicedPipeline = false; if (isSliceApplied && slicedPipeline.length > 0) { isDisabledViaSlicedPipeline = !slicedPipeline.includes(id); } - - const isDisabledViaSidebar = - !visibleSidebarNodes[id] && - !visibleModularPipelineInputsOutputs.has(id); - - const isDisabledViaModularPipeline = nodesDisabledViaModularPipeline[id]; + let isDisabledViaSidebar = false; + let isDisabledViaModularPipeline = false; + if (!expandAllPipelines) { + isDisabledViaSidebar = + !visibleSidebarNodes[id] && + !visibleModularPipelineInputsOutputs.has(id); + + isDisabledViaModularPipeline = nodesDisabledViaModularPipeline[id]; + } return [ nodeDisabledNode[id], From b5bae99afe834981194d58d7076862d0e6ffd435 Mon Sep 17 00:00:00 2001 From: Sajid Alam Date: Thu, 19 Dec 2024 14:56:31 +0000 Subject: [PATCH 03/12] Update flowchart-primary-toolbar.js Signed-off-by: Sajid Alam --- .../flowchart-primary-toolbar/flowchart-primary-toolbar.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.js b/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.js index d36a726fba..12951a6fc9 100644 --- a/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.js +++ b/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.js @@ -7,7 +7,6 @@ import { toggleTextLabels, toggleExpandAllPipelines, } from '../../actions'; -import { loadInitialPipelineData } from '../../actions/pipelines'; import IconButton from '../ui/icon-button'; import LabelIcon from '../icons/label'; import ExportIcon from '../icons/export'; From 2dc948e64f2db387bdcb752939e91ca9bcba1b19 Mon Sep 17 00:00:00 2001 From: Sajid Alam Date: Thu, 9 Jan 2025 14:56:49 +0000 Subject: [PATCH 04/12] use toggleModularPipelineExpanded action Signed-off-by: Sajid Alam --- .../flowchart-primary-toolbar.js | 13 ++++++++ src/selectors/disabled.js | 32 ++++++++++++------- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.js b/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.js index 12951a6fc9..5e8a282f98 100644 --- a/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.js +++ b/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.js @@ -7,6 +7,7 @@ import { toggleTextLabels, toggleExpandAllPipelines, } from '../../actions'; +import { toggleModularPipelinesExpanded } from '../../actions/modular-pipelines'; import IconButton from '../ui/icon-button'; import LabelIcon from '../icons/label'; import ExportIcon from '../icons/export'; @@ -23,6 +24,7 @@ import { useGeneratePathname } from '../../utils/hooks/use-generate-pathname'; * @param {Boolean} textLabels Whether text labels are displayed */ export const FlowchartPrimaryToolbar = ({ + modularPipelineIDs, disableLayerBtn, onToggleExportModal, onToggleLayers, @@ -33,12 +35,19 @@ export const FlowchartPrimaryToolbar = ({ display, visibleLayers, expandedPipelines, + onToggleExpandPipelines, onToggleExpandAllPipelines, }) => { const { toSetQueryParam } = useGeneratePathname(); + console.log(modularPipelineIDs); + const handleToggleExpandAllPipelines = () => { const isExpanded = !expandedPipelines; + + // Pass an empty array when collapsing all pipelines + onToggleExpandPipelines(isExpanded ? [] : modularPipelineIDs); + onToggleExpandAllPipelines(isExpanded); toSetQueryParam('expandAllPipelines', isExpanded.toString()); }; @@ -102,6 +111,7 @@ export const FlowchartPrimaryToolbar = ({ }; export const mapStateToProps = (state) => ({ + modularPipelineIDs: state?.modularPipeline?.ids, disableLayerBtn: !state.layer.ids.length, textLabels: state.textLabels, visible: state.visible, @@ -123,6 +133,9 @@ export const mapDispatchToProps = (dispatch) => ({ onToggleTextLabels: (value) => { dispatch(toggleTextLabels(Boolean(value))); }, + onToggleExpandPipelines: (ids) => { + dispatch(toggleModularPipelinesExpanded(ids)); + }, onToggleExpandAllPipelines: (isExpanded) => { dispatch(toggleExpandAllPipelines(isExpanded)); }, diff --git a/src/selectors/disabled.js b/src/selectors/disabled.js index 8a8f1eb36e..f480ff5ec6 100644 --- a/src/selectors/disabled.js +++ b/src/selectors/disabled.js @@ -24,7 +24,6 @@ const getNodeLayer = (state) => state.node.layer; const getNodeModularPipelines = (state) => state.node.modularPipelines; const getVisibleSidebarNodes = (state) => state.modularPipeline.visible; const getSliceApply = (state) => state.slice.apply; -const getExpandAllPipelines = (state) => state.expandAllPipelines; /** * Return all inputs and outputs of currently visible modular pipelines @@ -151,7 +150,7 @@ export const getNodeDisabled = createSelector( getDisabledModularPipeline, getSlicedPipeline, getSliceApply, - getExpandAllPipelines, + getModularPipelinesTree, ], ( nodeIDs, @@ -166,23 +165,32 @@ export const getNodeDisabled = createSelector( disabledModularPipeline, slicedPipeline, isSliceApplied, - expandAllPipelines + modularPipelinesTree ) => arrayToObject(nodeIDs, (id) => { + const rootChildren = modularPipelinesTree?.['__root__']?.children || []; + const isRootChild = rootChildren.some((child) => child.id === id); + + // Check the node's type: + const isTaskNode = nodeType[id] === 'task'; + + if (isRootChild && isTaskNode) { + // Hardcode "not disabled": + // so it can never vanish even when pipelines collapse + console.log('[DEBUG] Overriding root-task node => enabling node', id); + return false; + } + let isDisabledViaSlicedPipeline = false; if (isSliceApplied && slicedPipeline.length > 0) { isDisabledViaSlicedPipeline = !slicedPipeline.includes(id); } - let isDisabledViaSidebar = false; - let isDisabledViaModularPipeline = false; - if (!expandAllPipelines) { - isDisabledViaSidebar = - !visibleSidebarNodes[id] && - !visibleModularPipelineInputsOutputs.has(id); - - isDisabledViaModularPipeline = nodesDisabledViaModularPipeline[id]; - } + const isDisabledViaSidebar = + !visibleSidebarNodes[id] && + !visibleModularPipelineInputsOutputs.has(id); + + const isDisabledViaModularPipeline = nodesDisabledViaModularPipeline[id]; return [ nodeDisabledNode[id], nodeDisabledTag[id], From cc8cb4fa15c786c8d61b8dfe5bb7004d7e75900d Mon Sep 17 00:00:00 2001 From: Sajid Alam Date: Fri, 10 Jan 2025 10:08:41 +0000 Subject: [PATCH 05/12] fix test Signed-off-by: Sajid Alam --- .../flowchart-primary-toolbar/flowchart-primary-toolbar.js | 2 -- .../flowchart-primary-toolbar/flowchart-primary-toolbar.test.js | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.js b/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.js index 5e8a282f98..071046af7e 100644 --- a/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.js +++ b/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.js @@ -40,8 +40,6 @@ export const FlowchartPrimaryToolbar = ({ }) => { const { toSetQueryParam } = useGeneratePathname(); - console.log(modularPipelineIDs); - const handleToggleExpandAllPipelines = () => { const isExpanded = !expandedPipelines; diff --git a/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.test.js b/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.test.js index 5eb97c2d94..b5a781bea5 100644 --- a/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.test.js +++ b/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.test.js @@ -59,6 +59,7 @@ describe('PrimaryToolbar', () => { visible: mockState.spaceflights.visible, display: mockState.spaceflights.display, [callback]: mockFn, + onToggleExpandPipelines: jest.fn(), }; const wrapper = setup.mount(); expect(mockFn.mock.calls.length).toBe(0); @@ -72,6 +73,7 @@ describe('PrimaryToolbar', () => { disableLayerBtn: expect.any(Boolean), textLabels: expect.any(Boolean), expandedPipelines: expect.any(Boolean), + modularPipelineIDs: expect.any(Array), visible: expect.objectContaining({ exportModal: expect.any(Boolean), metadataModal: expect.any(Boolean), From e1168a110019defc14ebd2b1e599da37ea64c3d1 Mon Sep 17 00:00:00 2001 From: Sajid Alam Date: Fri, 10 Jan 2025 10:15:56 +0000 Subject: [PATCH 06/12] Update disabled.js Signed-off-by: Sajid Alam --- src/selectors/disabled.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/selectors/disabled.js b/src/selectors/disabled.js index f480ff5ec6..9f969e6889 100644 --- a/src/selectors/disabled.js +++ b/src/selectors/disabled.js @@ -175,9 +175,6 @@ export const getNodeDisabled = createSelector( const isTaskNode = nodeType[id] === 'task'; if (isRootChild && isTaskNode) { - // Hardcode "not disabled": - // so it can never vanish even when pipelines collapse - console.log('[DEBUG] Overriding root-task node => enabling node', id); return false; } From 9172ffc721ab91eed310fd520599a793deba653a Mon Sep 17 00:00:00 2001 From: Sajid Alam Date: Fri, 10 Jan 2025 10:50:56 +0000 Subject: [PATCH 07/12] Update flowchart-primary-toolbar.js Signed-off-by: Sajid Alam --- .../flowchart-primary-toolbar/flowchart-primary-toolbar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.js b/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.js index 071046af7e..e8d0915b86 100644 --- a/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.js +++ b/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.js @@ -44,7 +44,7 @@ export const FlowchartPrimaryToolbar = ({ const isExpanded = !expandedPipelines; // Pass an empty array when collapsing all pipelines - onToggleExpandPipelines(isExpanded ? [] : modularPipelineIDs); + onToggleExpandPipelines(isExpanded ? modularPipelineIDs : []); onToggleExpandAllPipelines(isExpanded); toSetQueryParam('expandAllPipelines', isExpanded.toString()); From 3eb1ba8c6852cbb75d4172144784cdef73858814 Mon Sep 17 00:00:00 2001 From: Sajid Alam Date: Fri, 10 Jan 2025 11:23:06 +0000 Subject: [PATCH 08/12] add check for modularpipelinefocus Signed-off-by: Sajid Alam --- src/selectors/disabled.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/selectors/disabled.js b/src/selectors/disabled.js index 9f969e6889..072776ec29 100644 --- a/src/selectors/disabled.js +++ b/src/selectors/disabled.js @@ -24,6 +24,7 @@ const getNodeLayer = (state) => state.node.layer; const getNodeModularPipelines = (state) => state.node.modularPipelines; const getVisibleSidebarNodes = (state) => state.modularPipeline.visible; const getSliceApply = (state) => state.slice.apply; +const modularPipelineFocusMode = (state) => state.modularPipelineFocusMode; /** * Return all inputs and outputs of currently visible modular pipelines @@ -150,6 +151,7 @@ export const getNodeDisabled = createSelector( getDisabledModularPipeline, getSlicedPipeline, getSliceApply, + modularPipelineFocusMode, getModularPipelinesTree, ], ( @@ -165,6 +167,7 @@ export const getNodeDisabled = createSelector( disabledModularPipeline, slicedPipeline, isSliceApplied, + isModularPipelineFocusMode, modularPipelinesTree ) => arrayToObject(nodeIDs, (id) => { @@ -174,7 +177,7 @@ export const getNodeDisabled = createSelector( // Check the node's type: const isTaskNode = nodeType[id] === 'task'; - if (isRootChild && isTaskNode) { + if (!isModularPipelineFocusMode && isRootChild && isTaskNode) { return false; } From 4842ef31093deddac1ee58e26056dc31c3e81664 Mon Sep 17 00:00:00 2001 From: Sajid Alam Date: Mon, 13 Jan 2025 10:01:37 +0000 Subject: [PATCH 09/12] exclude root from modularPipelineIDs Signed-off-by: Sajid Alam --- .../flowchart-primary-toolbar.js | 8 +++++--- src/selectors/disabled.js | 17 +---------------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.js b/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.js index e8d0915b86..88de1bb5e9 100644 --- a/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.js +++ b/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.js @@ -42,10 +42,12 @@ export const FlowchartPrimaryToolbar = ({ const handleToggleExpandAllPipelines = () => { const isExpanded = !expandedPipelines; - + // Exclude root from modularPipelineIDs + const filteredModularPipelineIDs = modularPipelineIDs.filter( + (id) => id !== '__root__' + ); // Pass an empty array when collapsing all pipelines - onToggleExpandPipelines(isExpanded ? modularPipelineIDs : []); - + onToggleExpandPipelines(isExpanded ? filteredModularPipelineIDs : []); onToggleExpandAllPipelines(isExpanded); toSetQueryParam('expandAllPipelines', isExpanded.toString()); }; diff --git a/src/selectors/disabled.js b/src/selectors/disabled.js index 072776ec29..9ec45c92ec 100644 --- a/src/selectors/disabled.js +++ b/src/selectors/disabled.js @@ -24,7 +24,6 @@ const getNodeLayer = (state) => state.node.layer; const getNodeModularPipelines = (state) => state.node.modularPipelines; const getVisibleSidebarNodes = (state) => state.modularPipeline.visible; const getSliceApply = (state) => state.slice.apply; -const modularPipelineFocusMode = (state) => state.modularPipelineFocusMode; /** * Return all inputs and outputs of currently visible modular pipelines @@ -151,8 +150,6 @@ export const getNodeDisabled = createSelector( getDisabledModularPipeline, getSlicedPipeline, getSliceApply, - modularPipelineFocusMode, - getModularPipelinesTree, ], ( nodeIDs, @@ -166,21 +163,9 @@ export const getNodeDisabled = createSelector( visibleModularPipelineInputsOutputs, disabledModularPipeline, slicedPipeline, - isSliceApplied, - isModularPipelineFocusMode, - modularPipelinesTree + isSliceApplied ) => arrayToObject(nodeIDs, (id) => { - const rootChildren = modularPipelinesTree?.['__root__']?.children || []; - const isRootChild = rootChildren.some((child) => child.id === id); - - // Check the node's type: - const isTaskNode = nodeType[id] === 'task'; - - if (!isModularPipelineFocusMode && isRootChild && isTaskNode) { - return false; - } - let isDisabledViaSlicedPipeline = false; if (isSliceApplied && slicedPipeline.length > 0) { isDisabledViaSlicedPipeline = !slicedPipeline.includes(id); From 1a37fc15f5dae2e8d48b452624565b553c433a5d Mon Sep 17 00:00:00 2001 From: Sajid Alam Date: Mon, 13 Jan 2025 10:08:52 +0000 Subject: [PATCH 10/12] Update flowchart-primary-toolbar.test.js Signed-off-by: Sajid Alam --- .../flowchart-primary-toolbar/flowchart-primary-toolbar.test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.test.js b/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.test.js index b5a781bea5..71869b20a3 100644 --- a/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.test.js +++ b/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.test.js @@ -59,6 +59,7 @@ describe('PrimaryToolbar', () => { visible: mockState.spaceflights.visible, display: mockState.spaceflights.display, [callback]: mockFn, + modularPipelineIDs: ['pipeline1', '__root__'], onToggleExpandPipelines: jest.fn(), }; const wrapper = setup.mount(); From 87dbafc07b872d86fd4fdb103d724aa228e3af0e Mon Sep 17 00:00:00 2001 From: Sajid Alam Date: Mon, 13 Jan 2025 10:11:12 +0000 Subject: [PATCH 11/12] revert disabled Signed-off-by: Sajid Alam --- src/selectors/disabled.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/selectors/disabled.js b/src/selectors/disabled.js index 9ec45c92ec..9feae33c13 100644 --- a/src/selectors/disabled.js +++ b/src/selectors/disabled.js @@ -176,6 +176,7 @@ export const getNodeDisabled = createSelector( !visibleModularPipelineInputsOutputs.has(id); const isDisabledViaModularPipeline = nodesDisabledViaModularPipeline[id]; + return [ nodeDisabledNode[id], nodeDisabledTag[id], From c0c5a2039e0eccab1d1f80bea2ccf7b01e5e4ddf Mon Sep 17 00:00:00 2001 From: Huong Nguyen Date: Tue, 14 Jan 2025 23:18:21 +0700 Subject: [PATCH 12/12] Add new reducer to hanlde update state for when toggle expanding all pipelines Signed-off-by: Huong Nguyen --- src/actions/modular-pipelines.js | 9 ++++++ .../flowchart-primary-toolbar.js | 12 +++---- src/reducers/modular-pipelines.js | 32 +++++++++++++++++++ 3 files changed, 46 insertions(+), 7 deletions(-) diff --git a/src/actions/modular-pipelines.js b/src/actions/modular-pipelines.js index add0e75eb9..217a954277 100644 --- a/src/actions/modular-pipelines.js +++ b/src/actions/modular-pipelines.js @@ -55,3 +55,12 @@ export function toggleModularPipelinesExpanded(expandedIDs) { expandedIDs, }; } + +export const TOGGLE_ALL_MODULAR_PIPELINES_EXPANDED = + 'TOGGLE_ALL_MODULAR_PIPELINES_EXPANDED'; +export function toggleAllModularPipelinesExpanded(expandAllPipelines) { + return { + type: TOGGLE_ALL_MODULAR_PIPELINES_EXPANDED, + expandAllPipelines, + }; +} diff --git a/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.js b/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.js index 88de1bb5e9..7ab383aca9 100644 --- a/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.js +++ b/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.js @@ -7,7 +7,10 @@ import { toggleTextLabels, toggleExpandAllPipelines, } from '../../actions'; -import { toggleModularPipelinesExpanded } from '../../actions/modular-pipelines'; +import { + toggleModularPipelinesExpanded, + toggleAllModularPipelinesExpanded, +} from '../../actions/modular-pipelines'; import IconButton from '../ui/icon-button'; import LabelIcon from '../icons/label'; import ExportIcon from '../icons/export'; @@ -42,12 +45,6 @@ export const FlowchartPrimaryToolbar = ({ const handleToggleExpandAllPipelines = () => { const isExpanded = !expandedPipelines; - // Exclude root from modularPipelineIDs - const filteredModularPipelineIDs = modularPipelineIDs.filter( - (id) => id !== '__root__' - ); - // Pass an empty array when collapsing all pipelines - onToggleExpandPipelines(isExpanded ? filteredModularPipelineIDs : []); onToggleExpandAllPipelines(isExpanded); toSetQueryParam('expandAllPipelines', isExpanded.toString()); }; @@ -138,6 +135,7 @@ export const mapDispatchToProps = (dispatch) => ({ }, onToggleExpandAllPipelines: (isExpanded) => { dispatch(toggleExpandAllPipelines(isExpanded)); + dispatch(toggleAllModularPipelinesExpanded(isExpanded)); }, }); diff --git a/src/reducers/modular-pipelines.js b/src/reducers/modular-pipelines.js index 8698eace98..d42c98de38 100644 --- a/src/reducers/modular-pipelines.js +++ b/src/reducers/modular-pipelines.js @@ -3,6 +3,7 @@ import { TOGGLE_MODULAR_PIPELINES_EXPANDED, TOGGLE_SINGLE_MODULAR_PIPELINE_EXPANDED, TOGGLE_MODULAR_PIPELINE_DISABLED, + TOGGLE_ALL_MODULAR_PIPELINES_EXPANDED, } from '../actions/modular-pipelines'; function modularPipelineReducer(modularPipelineState = {}, action) { @@ -110,6 +111,37 @@ function modularPipelineReducer(modularPipelineState = {}, action) { visible: newVisibleState, }); } + case TOGGLE_ALL_MODULAR_PIPELINES_EXPANDED: { + let newVisibleState = {}; + + // Determine which IDs should be expanded based on the action + const expandedIDs = action.expandAllPipelines + ? modularPipelineState.ids + : []; + + if (action.expandAllPipelines) { + // If expanding all pipelines, set visibility for each pipeline and its children + modularPipelineState.ids.forEach((modularPipelineID) => { + newVisibleState[modularPipelineID] = false; + modularPipelineState.tree[modularPipelineID].children.forEach( + (child) => (newVisibleState[child.id] = true) + ); + }); + } else { + // If not expanding all, only set visibility for the children of the root pipeline + if (modularPipelineState.tree['__root__']) { + for (const child of modularPipelineState.tree['__root__'].children || + []) { + newVisibleState[child.id] = true; + } + } + } + + return updateState({ + expanded: expandedIDs, + visible: newVisibleState, + }); + } default: return modularPipelineState;