From 0e7f24da9a4a4288f3e020a27ede37d726be7f4e Mon Sep 17 00:00:00 2001 From: ravi-kumar-pilla Date: Wed, 24 Apr 2024 19:27:11 -0500 Subject: [PATCH 01/15] merge main from remote Signed-off-by: ravi-kumar-pilla --- demo-project/.version | 0 package.json | 0 package/kedro_viz/server.py | 0 trufflehog-ignore.txt | 0 4 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 demo-project/.version mode change 100644 => 100755 package.json mode change 100644 => 100755 package/kedro_viz/server.py mode change 100644 => 100755 trufflehog-ignore.txt diff --git a/demo-project/.version b/demo-project/.version old mode 100644 new mode 100755 diff --git a/package.json b/package.json old mode 100644 new mode 100755 diff --git a/package/kedro_viz/server.py b/package/kedro_viz/server.py old mode 100644 new mode 100755 diff --git a/trufflehog-ignore.txt b/trufflehog-ignore.txt old mode 100644 new mode 100755 From 9715a24f6ca20e1309a907ee01c2d96ed6c59e8a Mon Sep 17 00:00:00 2001 From: ravi-kumar-pilla Date: Wed, 8 May 2024 21:38:31 -0500 Subject: [PATCH 02/15] add expandAllPipelines to initial state flags Signed-off-by: ravi-kumar-pilla --- src/store/initial-state.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/store/initial-state.js b/src/store/initial-state.js index 8bc03021ea..32ad432683 100644 --- a/src/store/initial-state.js +++ b/src/store/initial-state.js @@ -18,7 +18,7 @@ import { */ export const createInitialState = () => ({ chartSize: {}, - flags: Flags.defaults(), + flags: { ...Flags.defaults(), expandAllPipelines: false }, textLabels: true, theme: 'dark', isPrettyName: settings.isPrettyName.default, From c5c7cd99f372c2508d41917aa51fdae0867601b4 Mon Sep 17 00:00:00 2001 From: ravi-kumar-pilla Date: Wed, 8 May 2024 21:43:34 -0500 Subject: [PATCH 03/15] update file permissions Signed-off-by: ravi-kumar-pilla --- demo-project/.version | 0 package.json | 0 package/kedro_viz/server.py | 0 trufflehog-ignore.txt | 0 4 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 demo-project/.version mode change 100755 => 100644 package.json mode change 100755 => 100644 package/kedro_viz/server.py mode change 100755 => 100644 trufflehog-ignore.txt diff --git a/demo-project/.version b/demo-project/.version old mode 100755 new mode 100644 diff --git a/package.json b/package.json old mode 100755 new mode 100644 diff --git a/package/kedro_viz/server.py b/package/kedro_viz/server.py old mode 100755 new mode 100644 diff --git a/trufflehog-ignore.txt b/trufflehog-ignore.txt old mode 100755 new mode 100644 From 894e0a2b6ef5555b5971e994047e399c5319fda4 Mon Sep 17 00:00:00 2001 From: ravi-kumar-pilla Date: Wed, 8 May 2024 22:16:54 -0500 Subject: [PATCH 04/15] fix tests and add release note Signed-off-by: ravi-kumar-pilla --- RELEASE.md | 1 + src/components/app/app.test.js | 5 ++++- .../flowchart-primary-toolbar.test.js | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/RELEASE.md b/RELEASE.md index 1fa28a68d5..3152570b96 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -15,6 +15,7 @@ Please follow the established format: - Refactor backend integration with Kedro by replacing bootstrap_project with configure_project. (#1796) - Enhance kedro-viz doc integration. (#1874) - Fix Kedro-Viz waiting for valid Kedro project. (#1871) +- Include expandAllPipelines flag in initial state. (#1896) # Release 9.0.0 diff --git a/src/components/app/app.test.js b/src/components/app/app.test.js index 320517cdec..8b6aa95173 100644 --- a/src/components/app/app.test.js +++ b/src/components/app/app.test.js @@ -86,7 +86,10 @@ describe('App', () => { it('it announces flags', () => { const announceFlags = jest.spyOn(App.prototype, 'announceFlags'); shallow(); - expect(announceFlags).toHaveBeenCalledWith(Flags.defaults()); + expect(announceFlags).toHaveBeenCalledWith({ + ...Flags.defaults(), + expandAllPipelines: false, + }); }); }); 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 732389f33c..03b66c3fab 100644 --- a/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.test.js +++ b/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.test.js @@ -70,6 +70,7 @@ describe('PrimaryToolbar', () => { const expectedResult = { disableLayerBtn: expect.any(Boolean), textLabels: expect.any(Boolean), + expandedPipelines: expect.any(Boolean), displaySidebar: true, visible: expect.objectContaining({ exportBtn: expect.any(Boolean), From 499460cdfe8b50c0852dda5bcb1485bb14deea8c Mon Sep 17 00:00:00 2001 From: ravi-kumar-pilla Date: Mon, 13 May 2024 22:49:06 -0500 Subject: [PATCH 05/15] make expandAllPipelines outside of flags Signed-off-by: ravi-kumar-pilla --- src/actions/index.js | 13 +++++++++++++ src/actions/pipelines.js | 10 +++++----- .../flowchart-primary-toolbar.js | 6 +++--- .../flowchart-wrapper/flowchart-wrapper.js | 4 ++-- src/reducers/index.js | 6 ++++++ src/store/initial-state.js | 13 ++++++++++--- src/store/store.js | 1 + 7 files changed, 40 insertions(+), 13 deletions(-) diff --git a/src/actions/index.js b/src/actions/index.js index 973e16d531..a10372ec7b 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -24,6 +24,19 @@ export function toggleLayers(visible) { }; } +export const TOGGLE_EXPAND_ALL_PIPELINES = 'TOGGLE_EXPAND_ALL_PIPELINES'; + +/** + * Toggle whether to expand all modular pipelines or collapse all + * @param {Boolean} shouldExpandAllPipelines + */ +export function toggleExpandAllPipelines(shouldExpandAllPipelines) { + return { + type: TOGGLE_EXPAND_ALL_PIPELINES, + shouldExpandAllPipelines, + }; +} + export const TOGGLE_EXPORT_MODAL = 'TOGGLE_EXPORT_MODAL'; /** diff --git a/src/actions/pipelines.js b/src/actions/pipelines.js index 06e1bc30e6..8882b425d8 100644 --- a/src/actions/pipelines.js +++ b/src/actions/pipelines.js @@ -99,7 +99,7 @@ export function loadInitialPipelineData() { // obtain the status of expandAllPipelines to decide whether it needs to overwrite the // list of visible nodes const expandAllPipelines = - state.display.expandAllPipelines || state.flags.expandAllPipelines; + state.display.expandAllPipelines || state.expandAllPipelines; let newState = await loadJsonData(url).then((data) => preparePipelineState(data, true, expandAllPipelines) ); @@ -122,7 +122,7 @@ export function loadInitialPipelineData() { */ export function loadPipelineData(pipelineID) { return async function (dispatch, getState) { - const { dataSource, pipeline, display, flags } = getState(); + const { dataSource, pipeline, display, expandAllPipelines } = getState(); if (pipelineID && pipelineID === pipeline.active) { return; @@ -136,10 +136,10 @@ export function loadPipelineData(pipelineID) { active: pipelineID, }); - const expandAllPipelines = - display.expandAllPipelines || flags.expandAllPipelines; + const shouldExpandAllPipelines = + display.expandAllPipelines || expandAllPipelines; const newState = await loadJsonData(url).then((data) => - preparePipelineState(data, false, expandAllPipelines) + preparePipelineState(data, false, shouldExpandAllPipelines) ); // Set active pipeline here rather than dispatching two separate actions, diff --git a/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.js b/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.js index 844fc7ec90..d40e6ecfeb 100644 --- a/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.js +++ b/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.js @@ -5,7 +5,7 @@ import { toggleLayers, toggleSidebar, toggleTextLabels, - changeFlag, + toggleExpandAllPipelines, } from '../../actions'; import { loadInitialPipelineData } from '../../actions/pipelines'; import IconButton from '../ui/icon-button'; @@ -110,7 +110,7 @@ export const mapStateToProps = (state) => ({ textLabels: state.textLabels, visible: state.visible, visibleLayers: Boolean(getVisibleLayerIDs(state).length), - expandedPipelines: state.flags.expandAllPipelines, + expandedPipelines: state.expandAllPipelines, }); export const mapDispatchToProps = (dispatch) => ({ @@ -127,7 +127,7 @@ export const mapDispatchToProps = (dispatch) => ({ dispatch(toggleTextLabels(Boolean(value))); }, onToggleExpandAllPipelines: (isExpanded) => { - dispatch(changeFlag('expandAllPipelines', isExpanded)); + dispatch(toggleExpandAllPipelines(isExpanded)); dispatch(loadInitialPipelineData()); }, }); diff --git a/src/components/flowchart-wrapper/flowchart-wrapper.js b/src/components/flowchart-wrapper/flowchart-wrapper.js index b305bc73ea..02750f59fc 100644 --- a/src/components/flowchart-wrapper/flowchart-wrapper.js +++ b/src/components/flowchart-wrapper/flowchart-wrapper.js @@ -110,9 +110,9 @@ export const FlowChartWrapper = ({ disabledKeys && toSetQueryParam(params.types, mappedDisabledNodes); } }, - flags: (value) => { + expandAllPipelines: (value) => { if (!searchParams.has(params.expandAll)) { - toSetQueryParam(params.expandAll, value.expandAllPipelines); + toSetQueryParam(params.expandAll, value); } }, }; diff --git a/src/reducers/index.js b/src/reducers/index.js index af858fdc50..606077d8d9 100644 --- a/src/reducers/index.js +++ b/src/reducers/index.js @@ -20,6 +20,7 @@ import { TOGGLE_THEME, UPDATE_CHART_SIZE, UPDATE_ZOOM, + TOGGLE_EXPAND_ALL_PIPELINES, } from '../actions'; import { TOGGLE_PARAMETERS_HOVERED } from '../actions'; @@ -95,6 +96,11 @@ const combinedReducer = combineReducers({ TOGGLE_HOVERED_FOCUS_MODE, 'hoveredFocusMode' ), + expandAllPipelines: createReducer( + false, + TOGGLE_EXPAND_ALL_PIPELINES, + 'shouldExpandAllPipelines' + ), }); const rootReducer = (state, action) => diff --git a/src/store/initial-state.js b/src/store/initial-state.js index 32ad432683..eefa121c79 100644 --- a/src/store/initial-state.js +++ b/src/store/initial-state.js @@ -18,9 +18,10 @@ import { */ export const createInitialState = () => ({ chartSize: {}, - flags: { ...Flags.defaults(), expandAllPipelines: false }, + flags: { ...Flags.defaults() }, textLabels: true, theme: 'dark', + expandAllPipelines: false, isPrettyName: settings.isPrettyName.default, showFeatureHints: settings.showFeatureHints.default, ignoreLargeWarning: false, @@ -67,6 +68,7 @@ const parseUrlParameters = () => { nodeTagInUrl: search.get(params.tags) ? search.get(params.tags).split(',') : [], + expandAllPipelinesInUrl: search.get(params.expandAll), }; }; @@ -86,6 +88,7 @@ const applyUrlParametersToState = (state, urlParams) => { nodeNameFromUrl, nodeTypeInUrl, nodeTagInUrl, + expandAllPipelinesInUrl, } = urlParams; let newState = { ...state }; @@ -127,6 +130,10 @@ const applyUrlParametersToState = (state, urlParams) => { }); } + if (expandAllPipelinesInUrl) { + newState.expandAllPipelines = JSON.parse(expandAllPipelinesInUrl); + } + return newState; }; @@ -142,7 +149,7 @@ export const mergeLocalStorage = (state) => { localStorageRunsMetadata ); Object.keys(localStorageState).forEach((key) => { - if (!state[key]) { + if (!(key in state)) { delete localStorageState[key]; } }); @@ -214,7 +221,7 @@ const getInitialState = (props = {}) => { const expandAllPipelines = nonPipelineState.display.expandAllPipelines || - nonPipelineState.flags.expandAllPipelines; + nonPipelineState.expandAllPipelines; const pipelineState = preparePipelineState( props.data, diff --git a/src/store/store.js b/src/store/store.js index bbac8d2722..01bf864cf8 100644 --- a/src/store/store.js +++ b/src/store/store.js @@ -58,6 +58,7 @@ const saveStateToLocalStorage = (state) => { isPrettyName: state.isPrettyName, showFeatureHints: state.showFeatureHints, flags: state.flags, + expandAllPipelines: state.expandAllPipelines, }); // Store Run's metadata to localstorage From fc811266e3b82e4672e624ef0c401680a85d2465 Mon Sep 17 00:00:00 2001 From: ravi-kumar-pilla Date: Mon, 13 May 2024 22:55:33 -0500 Subject: [PATCH 06/15] revert previous change Signed-off-by: ravi-kumar-pilla --- src/components/app/app.test.js | 5 +---- src/store/initial-state.js | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/components/app/app.test.js b/src/components/app/app.test.js index 8b6aa95173..320517cdec 100644 --- a/src/components/app/app.test.js +++ b/src/components/app/app.test.js @@ -86,10 +86,7 @@ describe('App', () => { it('it announces flags', () => { const announceFlags = jest.spyOn(App.prototype, 'announceFlags'); shallow(); - expect(announceFlags).toHaveBeenCalledWith({ - ...Flags.defaults(), - expandAllPipelines: false, - }); + expect(announceFlags).toHaveBeenCalledWith(Flags.defaults()); }); }); diff --git a/src/store/initial-state.js b/src/store/initial-state.js index eefa121c79..b42dcec589 100644 --- a/src/store/initial-state.js +++ b/src/store/initial-state.js @@ -18,7 +18,7 @@ import { */ export const createInitialState = () => ({ chartSize: {}, - flags: { ...Flags.defaults() }, + flags: Flags.defaults(), textLabels: true, theme: 'dark', expandAllPipelines: false, From 40a3418df7b01a26750ff5910280d7bc25375676 Mon Sep 17 00:00:00 2001 From: ravi-kumar-pilla Date: Tue, 14 May 2024 12:10:28 -0500 Subject: [PATCH 07/15] add expandAllPipelines to nonPipelineState as before Signed-off-by: ravi-kumar-pilla --- src/store/initial-state.js | 53 +++++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 12 deletions(-) diff --git a/src/store/initial-state.js b/src/store/initial-state.js index b42dcec589..28bb02911f 100644 --- a/src/store/initial-state.js +++ b/src/store/initial-state.js @@ -73,22 +73,21 @@ const parseUrlParameters = () => { }; /** - * Applies URL parameters to the application state. + * Applies URL parameters to the application pipeline state. * This function modifies the state based on URL parameters such as * pipeline ID, node ID, node name, node type presence, and tag presence. * - * @param {Object} state The current application state. + * @param {Object} state The current application pipeline state. * @param {Object} urlParams An object containing parsed URL parameters. * @returns {Object} The new state with modifications applied based on URL parameters. */ -const applyUrlParametersToState = (state, urlParams) => { +const applyUrlParametersToPipelineState = (state, urlParams) => { const { pipelineIdFromURL, nodeIdFromUrl, nodeNameFromUrl, nodeTypeInUrl, nodeTagInUrl, - expandAllPipelinesInUrl, } = urlParams; let newState = { ...state }; @@ -130,10 +129,24 @@ const applyUrlParametersToState = (state, urlParams) => { }); } + return newState; +}; + +/** + * Applies URL parameters to the application non pipeline state. + * This function modifies the state based on URL parameters such as + * expandAllPipelines presence. + * + * @param {Object} state The current application non pipeline state. + * @param {Object} urlParams An object containing parsed URL parameters. + * @returns {Object} The new state with modifications applied based on URL parameters. + */ +const applyUrlParametersToNonPipelineState = (state, urlParams) => { + const { expandAllPipelinesInUrl } = urlParams; + let newState = { ...state }; if (expandAllPipelinesInUrl) { newState.expandAllPipelines = JSON.parse(expandAllPipelinesInUrl); } - return newState; }; @@ -170,9 +183,13 @@ export const mergeLocalStorage = (state) => { * @param {Object} data Data prop passed to App component * @param {Boolean} applyFixes Whether to override initialState */ -export const preparePipelineState = (data, applyFixes, expandAllPipelines) => { +export const preparePipelineState = ( + data, + applyFixes, + expandAllPipelines, + urlParams +) => { let state = mergeLocalStorage(normalizeData(data, expandAllPipelines)); - const urlParams = parseUrlParameters(); if (applyFixes) { // Use main pipeline if active pipeline from localStorage isn't recognised @@ -180,7 +197,10 @@ export const preparePipelineState = (data, applyFixes, expandAllPipelines) => { state.pipeline.active = state.pipeline.main; } } - state = applyUrlParametersToState(state, urlParams); + if (urlParams) { + state = applyUrlParametersToPipelineState(state, urlParams); + } + return state; }; @@ -191,15 +211,22 @@ export const preparePipelineState = (data, applyFixes, expandAllPipelines) => { * @param {object} props Props passed to App component * @return {object} Updated initial state */ -export const prepareNonPipelineState = (props) => { - const state = mergeLocalStorage(createInitialState()); +export const prepareNonPipelineState = (props, urlParams) => { + let state = mergeLocalStorage(createInitialState()); let newVisibleProps = {}; + if (props.display?.sidebar === false || state.display.sidebar === false) { newVisibleProps['sidebar'] = false; } + if (props.display?.minimap === false || state.display.miniMap === false) { newVisibleProps['miniMap'] = false; } + + if (urlParams) { + state = applyUrlParametersToNonPipelineState(state, urlParams); + } + return { ...state, flags: { ...state.flags, ...getFlagsFromUrl() }, @@ -217,7 +244,8 @@ export const prepareNonPipelineState = (props) => { * @return {Object} Initial state */ const getInitialState = (props = {}) => { - const nonPipelineState = prepareNonPipelineState(props); + const urlParams = parseUrlParameters(); + const nonPipelineState = prepareNonPipelineState(props, urlParams); const expandAllPipelines = nonPipelineState.display.expandAllPipelines || @@ -226,7 +254,8 @@ const getInitialState = (props = {}) => { const pipelineState = preparePipelineState( props.data, props.data !== 'json', - expandAllPipelines + expandAllPipelines, + urlParams ); return { From d37c1c90ada700a293d1442e38416376c346d938 Mon Sep 17 00:00:00 2001 From: ravi-kumar-pilla Date: Tue, 14 May 2024 12:43:58 -0500 Subject: [PATCH 08/15] update comments Signed-off-by: ravi-kumar-pilla --- src/actions/index.js | 2 +- .../flowchart-primary-toolbar.test.js | 5 ++--- src/store/initial-state.js | 18 +++++++++++------- src/store/normalize-data.js | 2 +- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/actions/index.js b/src/actions/index.js index a10372ec7b..47e83197af 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -27,7 +27,7 @@ export function toggleLayers(visible) { export const TOGGLE_EXPAND_ALL_PIPELINES = 'TOGGLE_EXPAND_ALL_PIPELINES'; /** - * Toggle whether to expand all modular pipelines or collapse all + * Toggle whether to expand all modular pipelines or collapse * @param {Boolean} shouldExpandAllPipelines */ export function toggleExpandAllPipelines(shouldExpandAllPipelines) { 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 03b66c3fab..a6f328c8a5 100644 --- a/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.test.js +++ b/src/components/flowchart-primary-toolbar/flowchart-primary-toolbar.test.js @@ -128,9 +128,8 @@ describe('PrimaryToolbar', () => { const dispatch = jest.fn(); mapDispatchToProps(dispatch).onToggleExpandAllPipelines(true); expect(dispatch.mock.calls[0][0]).toEqual({ - name: 'expandAllPipelines', - type: 'CHANGE_FLAG', - value: true, + type: 'TOGGLE_EXPAND_ALL_PIPELINES', + shouldExpandAllPipelines: true, }); }); }); diff --git a/src/store/initial-state.js b/src/store/initial-state.js index 28bb02911f..a7761f71ed 100644 --- a/src/store/initial-state.js +++ b/src/store/initial-state.js @@ -74,12 +74,12 @@ const parseUrlParameters = () => { /** * Applies URL parameters to the application pipeline state. - * This function modifies the state based on URL parameters such as + * This function modifies the state based on the URL parameters such as * pipeline ID, node ID, node name, node type presence, and tag presence. * * @param {Object} state The current application pipeline state. * @param {Object} urlParams An object containing parsed URL parameters. - * @returns {Object} The new state with modifications applied based on URL parameters. + * @returns {Object} The new state with modifications applied based on the URL parameters. */ const applyUrlParametersToPipelineState = (state, urlParams) => { const { @@ -133,13 +133,13 @@ const applyUrlParametersToPipelineState = (state, urlParams) => { }; /** - * Applies URL parameters to the application non pipeline state. - * This function modifies the state based on URL parameters such as + * Applies URL parameters to the application non-pipeline state. + * This function modifies the state based on the URL parameters such as * expandAllPipelines presence. * - * @param {Object} state The current application non pipeline state. + * @param {Object} state The current application non-pipeline state. * @param {Object} urlParams An object containing parsed URL parameters. - * @returns {Object} The new state with modifications applied based on URL parameters. + * @returns {Object} The new state with modifications applied based on the URL parameters. */ const applyUrlParametersToNonPipelineState = (state, urlParams) => { const { expandAllPipelinesInUrl } = urlParams; @@ -182,6 +182,9 @@ export const mergeLocalStorage = (state) => { * Exactly when it runs depends on whether the data is loaded asynchronously or not. * @param {Object} data Data prop passed to App component * @param {Boolean} applyFixes Whether to override initialState + * @param {Boolean} expandAllPipelines Whether to expand all the modular pipelines + * @param {Object} urlParams An object containing parsed URL parameters. + * @returns {Object} The new pipeline state with modifications applied. */ export const preparePipelineState = ( data, @@ -209,7 +212,8 @@ export const preparePipelineState = ( * will persist if the pipeline data is reset. * Merge local storage and add custom state overrides from props etc * @param {object} props Props passed to App component - * @return {object} Updated initial state + * @param {Object} urlParams An object containing parsed URL parameters. + * @returns {Object} The new non-pipeline state with modifications applied. */ export const prepareNonPipelineState = (props, urlParams) => { let state = mergeLocalStorage(createInitialState()); diff --git a/src/store/normalize-data.js b/src/store/normalize-data.js index 6ad17baf44..3fc3715855 100644 --- a/src/store/normalize-data.js +++ b/src/store/normalize-data.js @@ -299,7 +299,7 @@ const normalizeData = (data, expandAllPipelines) => { data.modular_pipelines ); - // Case for expandAllPipelines in component props or within flag + // Case for expandAllPipelines in component props or within state if (expandAllPipelines) { // assign all modular pipelines into expanded state state.modularPipeline.expanded = state.modularPipeline.ids; From 9c43280a7fd3e3ab913920854f8b48d10191ed3b Mon Sep 17 00:00:00 2001 From: ravi-kumar-pilla Date: Tue, 14 May 2024 13:21:48 -0500 Subject: [PATCH 09/15] testing strawberry fix Signed-off-by: ravi-kumar-pilla --- package/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/requirements.txt b/package/requirements.txt index f40d3278de..c0bd5d8367 100644 --- a/package/requirements.txt +++ b/package/requirements.txt @@ -12,7 +12,7 @@ plotly>=4.0 pydantic>=2.0.0 secure>=0.3.0 sqlalchemy>=1.4, <3 -strawberry-graphql>=0.192.0, <1.0 +strawberry-graphql>=0.192.0, <0.229.0 uvicorn[standard]~=0.29.0 watchgod~=0.8.2 # [TODO: Need to drop toposort dependency in favor of in-built graphlib] From 1f5f871db6581a078e4ff764a00a0c674c299670 Mon Sep 17 00:00:00 2001 From: ravi-kumar-pilla Date: Tue, 14 May 2024 13:53:53 -0500 Subject: [PATCH 10/15] testing strawberry fix Signed-off-by: ravi-kumar-pilla --- package/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/requirements.txt b/package/requirements.txt index c0bd5d8367..618e5db6d9 100644 --- a/package/requirements.txt +++ b/package/requirements.txt @@ -12,7 +12,7 @@ plotly>=4.0 pydantic>=2.0.0 secure>=0.3.0 sqlalchemy>=1.4, <3 -strawberry-graphql>=0.192.0, <0.229.0 +strawberry-graphql>=0.192.0, <0.228.0 uvicorn[standard]~=0.29.0 watchgod~=0.8.2 # [TODO: Need to drop toposort dependency in favor of in-built graphlib] From 40480a17e065effc7229db674357b0b1675e3f79 Mon Sep 17 00:00:00 2001 From: ravi-kumar-pilla Date: Tue, 14 May 2024 14:19:48 -0500 Subject: [PATCH 11/15] fix strawberry graphql 0.228.0 release doc Signed-off-by: ravi-kumar-pilla --- package/requirements.txt | 2 +- src/apollo/schema.graphql | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package/requirements.txt b/package/requirements.txt index 618e5db6d9..f40d3278de 100644 --- a/package/requirements.txt +++ b/package/requirements.txt @@ -12,7 +12,7 @@ plotly>=4.0 pydantic>=2.0.0 secure>=0.3.0 sqlalchemy>=1.4, <3 -strawberry-graphql>=0.192.0, <0.228.0 +strawberry-graphql>=0.192.0, <1.0 uvicorn[standard]~=0.29.0 watchgod~=0.8.2 # [TODO: Need to drop toposort dependency in favor of in-built graphlib] diff --git a/src/apollo/schema.graphql b/src/apollo/schema.graphql index e48274ebb0..2fd62c4204 100644 --- a/src/apollo/schema.graphql +++ b/src/apollo/schema.graphql @@ -1,7 +1,7 @@ """ -The `JSON` scalar type represents JSON values as specified by [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf). +The `JSON` scalar type represents JSON values as specified by [ECMA-404](https://ecma-international.org/wp-content/uploads/ECMA-404_2nd_edition_december_2017.pdf). """ -scalar JSON @specifiedBy(url: "http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf") +scalar JSON @specifiedBy(url: "https://ecma-international.org/wp-content/uploads/ECMA-404_2nd_edition_december_2017.pdf") """Metric data""" type MetricPlotDataset { From 478031a0ffecb3c21ba22bf0fec4f7da79acb2cd Mon Sep 17 00:00:00 2001 From: ravi-kumar-pilla Date: Tue, 14 May 2024 16:53:52 -0500 Subject: [PATCH 12/15] fix boolean check Signed-off-by: ravi-kumar-pilla --- src/store/initial-state.js | 4 ++-- src/utils/index.js | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/store/initial-state.js b/src/store/initial-state.js index a7761f71ed..9e65f9497f 100644 --- a/src/store/initial-state.js +++ b/src/store/initial-state.js @@ -2,7 +2,7 @@ import deepmerge from 'deepmerge'; import { loadLocalStorage } from './helpers'; import normalizeData from './normalize-data'; import { getFlagsFromUrl, Flags } from '../utils/flags'; -import { mapNodeType } from '../utils'; +import { mapNodeType, isValidBoolean } from '../utils'; import { settings, sidebarWidth, @@ -144,7 +144,7 @@ const applyUrlParametersToPipelineState = (state, urlParams) => { const applyUrlParametersToNonPipelineState = (state, urlParams) => { const { expandAllPipelinesInUrl } = urlParams; let newState = { ...state }; - if (expandAllPipelinesInUrl) { + if (expandAllPipelinesInUrl && isValidBoolean(expandAllPipelinesInUrl)) { newState.expandAllPipelines = JSON.parse(expandAllPipelinesInUrl); } return newState; diff --git a/src/utils/index.js b/src/utils/index.js index b8cd1888bf..d82777c7d2 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -243,3 +243,12 @@ export const mapNodeType = (nodeType) => nodeTypeMapObj[nodeType] || nodeType; export const mapNodeTypes = (nodeTypes) => { return nodeTypes.replace(/task|data/g, (matched) => mapNodeType(matched)); }; + +/** + * Test if the passed string value is valid boolean + * @param {String} inputString + * @returns {Boolean} true if the inputString is a valid boolean + */ +export const isValidBoolean = (inputString) => { + return /^(true|false)$/i.test(inputString); +}; From 0b5a886fc66bd0c10457d65390b380f14920174a Mon Sep 17 00:00:00 2001 From: ravi-kumar-pilla Date: Tue, 14 May 2024 18:06:47 -0500 Subject: [PATCH 13/15] update tests Signed-off-by: ravi-kumar-pilla --- src/actions/actions.test.js | 15 ++++++++++++++- src/reducers/reducers.test.js | 11 +++++++++++ src/store/initial-state.test.js | 15 ++++++++++++++- src/utils/utils.test.js | 18 ++++++++++++++++++ 4 files changed, 57 insertions(+), 2 deletions(-) diff --git a/src/actions/actions.test.js b/src/actions/actions.test.js index 4778ed741b..fde1e1b162 100644 --- a/src/actions/actions.test.js +++ b/src/actions/actions.test.js @@ -16,6 +16,7 @@ import { TOGGLE_CODE, TOGGLE_MODULAR_PIPELINE_FOCUS_MODE, TOGGLE_HOVERED_FOCUS_MODE, + TOGGLE_EXPAND_ALL_PIPELINES, changeFlag, resetData, toggleIgnoreLargeWarning, @@ -32,6 +33,7 @@ import { updateChartSize, toggleFocusMode, toggleHoveredFocusMode, + toggleExpandAllPipelines, } from '../actions'; import { TOGGLE_NODE_CLICKED, @@ -75,7 +77,18 @@ describe('actions', () => { expect(toggleLayers(visible)).toEqual(expectedAction); }); - it('should create an action to toggle whether to show layers', () => { + it('should create an action to toggle whether to expand all modular pipelines or collapse', () => { + const shouldExpandAllPipelines = false; + const expectedAction = { + type: TOGGLE_EXPAND_ALL_PIPELINES, + shouldExpandAllPipelines, + }; + expect(toggleExpandAllPipelines(shouldExpandAllPipelines)).toEqual( + expectedAction + ); + }); + + it('should create an action to toggle whether to show minimap', () => { const visible = false; const expectedAction = { type: TOGGLE_MINIMAP, diff --git a/src/reducers/reducers.test.js b/src/reducers/reducers.test.js index 48aeeb0409..5778001bff 100644 --- a/src/reducers/reducers.test.js +++ b/src/reducers/reducers.test.js @@ -19,6 +19,7 @@ import { TOGGLE_THEME, UPDATE_CHART_SIZE, TOGGLE_HOVERED_FOCUS_MODE, + TOGGLE_EXPAND_ALL_PIPELINES, } from '../actions'; import { TOGGLE_NODE_CLICKED, @@ -241,6 +242,16 @@ describe('Reducer', () => { }); }); + describe('TOGGLE_EXPAND_ALL_PIPELINES', () => { + it('should toggle whether to expand all modular pipelines or collapse', () => { + const newState = reducer(mockState.spaceflights, { + type: TOGGLE_EXPAND_ALL_PIPELINES, + shouldExpandAllPipelines: true, + }); + expect(newState.expandAllPipelines).toEqual(true); + }); + }); + describe('TOGGLE_SIDEBAR', () => { it('should toggle whether the sidebar is open', () => { const newState = reducer(mockState.spaceflights, { diff --git a/src/store/initial-state.test.js b/src/store/initial-state.test.js index 56b3458e93..2ac6a3fb5f 100644 --- a/src/store/initial-state.test.js +++ b/src/store/initial-state.test.js @@ -20,6 +20,7 @@ describe('mergeLocalStorage', () => { textLabels: false, theme: 'light', tag: { enabled: 'medium' }, + expandAllPipelines: true, }; saveLocalStorage(localStorageName, localStorageValues); expect( @@ -27,6 +28,7 @@ describe('mergeLocalStorage', () => { textLabels: true, theme: 'dark', tag: { enabled: 'large' }, + expandAllPipelines: false, }) ).toMatchObject(localStorageValues); window.localStorage.clear(); @@ -70,10 +72,13 @@ describe('preparePipelineState', () => { describe('prepareNonPipelineState', () => { it('applies localStorage values on top of initial state', () => { - const localStorageState = { theme: 'foo' }; + const localStorageState = { theme: 'foo', expandAllPipelines: true }; saveLocalStorage(localStorageName, localStorageState); const state = prepareNonPipelineState({}); expect(state.theme).toEqual(localStorageState.theme); + expect(state.expandAllPipelines).toEqual( + localStorageState.expandAllPipelines + ); window.localStorage.clear(); }); @@ -101,6 +106,13 @@ describe('prepareNonPipelineState', () => { prepareNonPipelineState({ data: spaceflights, ...props }) ).toMatchObject(props); }); + + it('overrides expandAllPipelines with values from URL', () => { + // In this case, location.href is not provided + expect(prepareNonPipelineState({ data: spaceflights })).toMatchObject({ + expandAllPipelines: expect.any(Boolean), + }); + }); }); describe('getInitialState', () => { @@ -119,6 +131,7 @@ describe('getInitialState', () => { chartSize: {}, textLabels: true, theme: 'dark', + expandAllPipelines: false, visible: { exportBtn: true, labelBtn: true, diff --git a/src/utils/utils.test.js b/src/utils/utils.test.js index 9f6c565a0c..d63b9f3e55 100644 --- a/src/utils/utils.test.js +++ b/src/utils/utils.test.js @@ -4,6 +4,7 @@ import { unique, replaceMatches, replaceAngleBracketMatches, + isValidBoolean, } from './index'; describe('utils', () => { @@ -77,4 +78,21 @@ describe('utils', () => { expect(replaceAngleBracketMatches('')).toEqual('<lambda>'); }); }); + + describe('isValidBoolean', () => { + it('validates if the inputString is valid boolean', () => { + // Valid booleans + expect(isValidBoolean('true')).toEqual(true); + expect(isValidBoolean('false')).toEqual(true); + expect(isValidBoolean(true)).toEqual(true); + expect(isValidBoolean(false)).toEqual(true); + + // Invalid booleans + expect(isValidBoolean('0')).toEqual(false); + expect(isValidBoolean('undefined')).toEqual(false); + expect(isValidBoolean(undefined)).toEqual(false); + expect(isValidBoolean('trueTesting')).toEqual(false); + expect(isValidBoolean('Testingfalse')).toEqual(false); + }); + }); }); From 425c92f5b372623dc621a9e69bdf265151cf6d95 Mon Sep 17 00:00:00 2001 From: ravi-kumar-pilla Date: Thu, 16 May 2024 08:58:24 -0500 Subject: [PATCH 14/15] test ci failure Signed-off-by: ravi-kumar-pilla --- demo-project/src/demo_project/requirements.in | 2 +- demo-project/src/docker_requirements.txt | 2 +- package/kedro_viz/server.py | 0 src/actions/actions.test.js | 0 src/actions/index.js | 0 5 files changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 100755 package/kedro_viz/server.py mode change 100644 => 100755 src/actions/actions.test.js mode change 100644 => 100755 src/actions/index.js diff --git a/demo-project/src/demo_project/requirements.in b/demo-project/src/demo_project/requirements.in index af486a91a6..dee6afcbe9 100644 --- a/demo-project/src/demo_project/requirements.in +++ b/demo-project/src/demo_project/requirements.in @@ -16,4 +16,4 @@ wheel>=0.35, <0.37 pillow~=9.0 matplotlib==3.5.0 pre-commit~=1.17 -seaborn~=0.11.2 +seaborn~=0.13.2 diff --git a/demo-project/src/docker_requirements.txt b/demo-project/src/docker_requirements.txt index 407cdfb038..9302ffda4d 100644 --- a/demo-project/src/docker_requirements.txt +++ b/demo-project/src/docker_requirements.txt @@ -2,4 +2,4 @@ kedro>=0.18.0 kedro-datasets[pandas.CSVDataset,pandas.ExcelDataset, pandas.ParquetDataset, plotly.PlotlyDataset, matplotlib.MatplotlibWriter]>=2.1.0 scikit-learn~=1.0 pillow~=9.0 -seaborn~=0.11.2 +seaborn~=0.13.2 diff --git a/package/kedro_viz/server.py b/package/kedro_viz/server.py old mode 100644 new mode 100755 diff --git a/src/actions/actions.test.js b/src/actions/actions.test.js old mode 100644 new mode 100755 diff --git a/src/actions/index.js b/src/actions/index.js old mode 100644 new mode 100755 From d17749facf21024738574245c5ee48ef78fae276 Mon Sep 17 00:00:00 2001 From: ravi-kumar-pilla Date: Thu, 16 May 2024 09:22:26 -0500 Subject: [PATCH 15/15] update release note Signed-off-by: ravi-kumar-pilla --- RELEASE.md | 2 +- package/kedro_viz/server.py | 0 src/actions/actions.test.js | 0 src/actions/index.js | 0 4 files changed, 1 insertion(+), 1 deletion(-) mode change 100755 => 100644 package/kedro_viz/server.py mode change 100755 => 100644 src/actions/actions.test.js mode change 100755 => 100644 src/actions/index.js diff --git a/RELEASE.md b/RELEASE.md index 352420fb71..1afee5d65e 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -15,7 +15,7 @@ Please follow the established format: - Refactor backend integration with Kedro by replacing bootstrap_project with configure_project. (#1796) - Enhance kedro-viz doc integration. (#1874) - Fix Kedro-Viz waiting for valid Kedro project. (#1871) -- Include expandAllPipelines flag in initial state. (#1896) +- Include expandAllPipelines in initial state. (#1896) - Enhance Kedro-Viz documentation by using Kedro-sphinx-theme. (#1898) - Fix for schema change in strawberry-graphql JSON scalar. (#1903) - Fix messaging level when package compatibility is not satisfied. (#1904) diff --git a/package/kedro_viz/server.py b/package/kedro_viz/server.py old mode 100755 new mode 100644 diff --git a/src/actions/actions.test.js b/src/actions/actions.test.js old mode 100755 new mode 100644 diff --git a/src/actions/index.js b/src/actions/index.js old mode 100755 new mode 100644