From 4d3f68908c9d2d9c8855bc7ce8a5c878915298d3 Mon Sep 17 00:00:00 2001 From: Johannes Doberer Date: Wed, 6 Dec 2023 15:11:34 +0100 Subject: [PATCH] Fix addNavHrefs for CtxSwitcher and TopNavDropDown (#3544) --- core/src/TopNavDropDown.svelte | 2 +- core/src/navigation/ContextSwitcher.svelte | 42 +++++++++++----------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/core/src/TopNavDropDown.svelte b/core/src/TopNavDropDown.svelte index cf31988bec..7ba5e7ae68 100644 --- a/core/src/TopNavDropDown.svelte +++ b/core/src/TopNavDropDown.svelte @@ -23,7 +23,7 @@ 'getUnsavedChangesModalPromise' ); let openViewInModal = getContext('openViewInModal'); - let addNavHrefForAnchor; + export let addNavHrefForAnchor; const getNodeSubtitle = () => {}; //TODO refactor diff --git a/core/src/navigation/ContextSwitcher.svelte b/core/src/navigation/ContextSwitcher.svelte index 20c14dd12b..8ea339f24c 100644 --- a/core/src/navigation/ContextSwitcher.svelte +++ b/core/src/navigation/ContextSwitcher.svelte @@ -42,13 +42,13 @@ export let defaultLabel; let preserveSubPathOnSwitch; let getUnsavedChangesModalPromise = getContext( - 'getUnsavedChangesModalPromise' + 'getUnsavedChangesModalPromise', ); let store = getContext('store'); let getTranslation = getContext('getTranslation'); let prevContextSwitcherToggle = false; let selectedNodePath; - let addNavHrefForAnchor; + export let addNavHrefForAnchor; let isContextSwitcherDropdownShown; onMount(async () => { @@ -56,7 +56,7 @@ store, async () => { const contextSwitcherConfig = LuigiConfig.getConfigValue( - 'navigation.contextSwitcher' + 'navigation.contextSwitcher', ); contextSwitcherEnabled = !!contextSwitcherConfig; if (!contextSwitcherEnabled) { @@ -64,13 +64,13 @@ } customOptionsRenderer = GenericHelpers.isFunction( - contextSwitcherConfig.customOptionsRenderer + contextSwitcherConfig.customOptionsRenderer, ) ? contextSwitcherConfig.customOptionsRenderer : undefined; customSelectedOptionRenderer = GenericHelpers.isFunction( - contextSwitcherConfig.customSelectedOptionRenderer + contextSwitcherConfig.customSelectedOptionRenderer, ) ? contextSwitcherConfig.customSelectedOptionRenderer : undefined; @@ -80,7 +80,7 @@ alwaysShowDropdown = contextSwitcherConfig.alwaysShowDropdown !== false; // default is true actions = await LuigiConfig.getConfigValueAsync( - 'navigation.contextSwitcher.actions' + 'navigation.contextSwitcher.actions', ); const currentPath = Routing.getCurrentPath(); @@ -95,14 +95,14 @@ if ( ContextSwitcherHelpers.isContextSwitcherDetailsView( currentPath, - contextSwitcherConfig.parentNodePath + contextSwitcherConfig.parentNodePath, ) ) { await setSelectedContext(currentPath); } } }, - ['navigation.contextSwitcher'] + ['navigation.contextSwitcher'], ); RoutingHelpers.addRouteChangeListener((path) => setSelectedContext(path)); @@ -155,18 +155,18 @@ selectedOption = await ContextSwitcherHelpers.getSelectedOption( currentPath, options, - parentNodePath + parentNodePath, ); selectedLabel = await ContextSwitcherHelpers.getSelectedLabel( currentPath, options, parentNodePath, - fallbackLabelResolver + fallbackLabelResolver, ); selectedNodePath = await ContextSwitcherHelpers.getSelectedNode( currentPath, options, - parentNodePath + parentNodePath, ); preserveSubPathOnSwitch = conf.preserveSubPathOnSwitch; } @@ -178,18 +178,18 @@ selectedOption = await ContextSwitcherHelpers.getSelectedOption( currentPath, options, - parentNodePath + parentNodePath, ); selectedLabel = await ContextSwitcherHelpers.getSelectedLabel( currentPath, options, parentNodePath, - fallbackLabelResolver + fallbackLabelResolver, ); selectedNodePath = await ContextSwitcherHelpers.getSelectedNode( currentPath, options, - parentNodePath + parentNodePath, ); } @@ -216,7 +216,7 @@ () => { Routing.navigateTo(path); }, - () => {} + () => {}, ); } @@ -229,8 +229,8 @@ Routing.navigateTo( ContextSwitcherHelpers.getNodePathFromCurrentPath( option, - selectedOption - ) + selectedOption, + ), ); } else { Routing.navigateTo(option.link); @@ -239,7 +239,7 @@ dispatch('toggleDropdownState'); } }, - () => {} + () => {}, ); } @@ -261,7 +261,7 @@
{}}> {#if addNavHrefForAnchor && selectedOption !== config.defaultLabel}