From 5a0b55342f34d4b2dffcbcd9238a820b70370ca6 Mon Sep 17 00:00:00 2001 From: Waldemar Mazurek Date: Mon, 23 Sep 2024 10:31:07 +0200 Subject: [PATCH] Adds optional renderer for navHeader (#3915) --- core/src/navigation/LeftNav.svelte | 122 +++++++++++++++++------------ 1 file changed, 72 insertions(+), 50 deletions(-) diff --git a/core/src/navigation/LeftNav.svelte b/core/src/navigation/LeftNav.svelte index ba00126c2f..5e4226818f 100644 --- a/core/src/navigation/LeftNav.svelte +++ b/core/src/navigation/LeftNav.svelte @@ -160,6 +160,7 @@ GenericHelpers.requestExperimentalFeature('btpToolLayout', false); let btpNavTopCnt; let toolLayoutSubCatDelimiter = LuigiConfig.getConfigValue('settings.btpToolLayout.subCategoryDelimiter') || '::'; + let navHeaderContainer; const getNodeLabel = node => { return NavigationHelpers.getNodeLabel(node); @@ -248,6 +249,22 @@ } }; + const handleNavHeaderRenderer = () => { + const clickHandler = node => { + if (node) { + handleClick(node); + } + }; + + if (navHeader?.renderer && navHeaderContainer) { + if (navHeader.clearBeforeRender) { + navHeaderContainer.innerHTML = ''; + } + + navHeader.renderer(navHeaderContainer, navParentNode, clickHandler); + } + }; + afterUpdate(() => { if (!window.Luigi.__btpNavTopCntRszObs) { let updateTimeout; @@ -269,6 +286,7 @@ } else { resetNavEntries(); } + handleNavHeaderRenderer(); }); beforeUpdate(() => { @@ -589,35 +607,37 @@ style="width: var(--luigi__left-sidenav--width); height: 100%;" > {#if navHeader} -
- + {/if}
{/if} @@ -933,35 +953,37 @@ class="fd-app__sidebar fd-navigation {hideNavComponent ? 'hideNavComponent' : ''} {footerText || semiCollapsibleButton ? 'hasFooter' : ''} {footerText && !semiCollapsibleButton ? 'hasOnlyFooterText' : ''}" > {#if navHeader} - {/if}