diff --git a/libs/features/dynamic-navigation/dynamic-navigation.js b/libs/features/dynamic-navigation/dynamic-navigation.js index 7354518a58..7d943cc597 100644 --- a/libs/features/dynamic-navigation/dynamic-navigation.js +++ b/libs/features/dynamic-navigation/dynamic-navigation.js @@ -14,16 +14,30 @@ export function foundDisableValues() { return foundValues.length ? foundValues : false; } +function dynamicNavGroupMatches(groupMetaData) { + const storedGroup = window.sessionStorage.getItem('dynamicNavGroup'); + if (groupMetaData && storedGroup) { + return storedGroup.toLowerCase() === groupMetaData.toLowerCase(); + } + return false; +} + export default function dynamicNav(url, key) { if (foundDisableValues()) return url; const metadataContent = getMetadata('dynamic-nav'); + const dynamicNavGroup = getMetadata('dynamic-nav-group'); if (metadataContent === 'entry') { window.sessionStorage.setItem('gnavSource', url); window.sessionStorage.setItem('dynamicNavKey', key); + if (dynamicNavGroup) window.sessionStorage.setItem('dynamicNavGroup', dynamicNavGroup); return url; } + if (metadataContent === 'on' && dynamicNavGroup) { + if (!dynamicNavGroupMatches(dynamicNavGroup)) return url; + } + if (metadataContent !== 'on' || key !== window.sessionStorage.getItem('dynamicNavKey')) return url; return window.sessionStorage.getItem('gnavSource') || url; diff --git a/libs/features/dynamic-navigation/status.js b/libs/features/dynamic-navigation/status.js index 792f586765..3321459581 100644 --- a/libs/features/dynamic-navigation/status.js +++ b/libs/features/dynamic-navigation/status.js @@ -80,7 +80,11 @@ const createStatusWidget = (dynamicNavKey) => { const currentSource = getCurrentSource(dynamicNavSetting, storedSource, authoredSource); const dynamicNavDisableValues = getMetadata('dynamic-nav-disable'); const foundValues = foundDisableValues(); - const status = getStatus(dynamicNavSetting, foundValues.length >= 1, storedSource); + const groupMetaSetting = getMetadata('dynamic-nav-group') || 'Group not set'; + const groupsMatch = groupMetaSetting.toLowerCase() === window.sessionStorage.getItem('dynamicNavGroup').toLowerCase(); + const groupsMatchMessage = groupsMatch ? 'Yes' : 'No'; + const isDisabled = foundValues.length >= 1 || (!groupsMatch && groupMetaSetting !== 'Group not set'); + const status = getStatus(dynamicNavSetting, isDisabled, storedSource); const statusWidget = createTag('div', { class: 'dynamic-nav-status' }); statusWidget.innerHTML = ` @@ -94,6 +98,8 @@ const createStatusWidget = (dynamicNavKey) => {

Status: ${status}

Setting: ${dynamicNavSetting}

+

Group: ${groupMetaSetting}

+

Group matches stored group: ${groupsMatchMessage}

Consumer key: ${dynamicNavKey}