diff --git a/blocks/adp-header/adp-header.js b/blocks/adp-header/adp-header.js index e25e6719..b3eafe7c 100644 --- a/blocks/adp-header/adp-header.js +++ b/blocks/adp-header/adp-header.js @@ -325,22 +325,24 @@ async function initQuickLinks() { const quickLinks = document.querySelector('.adp-header .nav-bottom .quick-links'); // decorate quick links quickLinksConfig.forEach((item) => { - const itemEl = document.createElement('div'); - itemEl.className = 'item'; - const itemLinkEl = document.createElement('a'); - if (item.page.startsWith('/') && isUrlPathNonRoot()) { - itemLinkEl.href = createLinkHref(getBaseConfigPath() + item.page); - } else { - itemLinkEl.href = createLinkHref(item.page); - } - itemLinkEl.dataset.page = item.page; - if (item.page.startsWith('http')) { - itemLinkEl.target = '_blank'; - itemLinkEl.rel = 'noopener'; + if (item.hide!=='true'){ + const itemEl = document.createElement('div'); + itemEl.className = 'item'; + const itemLinkEl = document.createElement('a'); + if (item.page.startsWith('/') && isUrlPathNonRoot()) { + itemLinkEl.href = createLinkHref(getBaseConfigPath() + item.page); + } else { + itemLinkEl.href = createLinkHref(item.page); + } + itemLinkEl.dataset.page = item.page; + if (item.page.startsWith('http')) { + itemLinkEl.target = '_blank'; + itemLinkEl.rel = 'noopener'; + } + itemLinkEl.textContent = item.title; + itemEl.append(itemLinkEl); + quickLinks.append(itemEl); } - itemLinkEl.textContent = item.title; - itemEl.append(itemLinkEl); - quickLinks.append(itemEl); }); if (await checkAddAssetsAccess()) { diff --git a/scripts/security.js b/scripts/security.js index af8ebbc5..edbe7458 100644 --- a/scripts/security.js +++ b/scripts/security.js @@ -105,11 +105,15 @@ export async function checkUserAccess() { if (isPublicPage()) { return true; } - const isIMSUser = await imsLibSecurityModule.isUserInSecurityGroup(imsUserGroup, await getBearerToken()); if (isIMSUser) { //Check if current page is present in the array of pages returned by function getQuickLinkConfig() - const presentInQuickLinks = (await getQuickLinkConfig()).some((grp) => grp.page === (window.location.pathname.replace(getBaseConfigPath((window.location.pathname)),''))); + //Split the URL into parts + const currentUrlParts=window.location.pathname.replace(getBaseConfigPath((window.location.pathname)),'').split('/'); + //Current url beginning with / + const currentURL = '/'+currentUrlParts[1]; + const presentInQuickLinks = (await getQuickLinkConfig()).some((grp) => grp.page === (currentURL)); + return presentInQuickLinks; } else diff --git a/scripts/site-config.js b/scripts/site-config.js index 79f1e876..268a74f0 100644 --- a/scripts/site-config.js +++ b/scripts/site-config.js @@ -288,17 +288,12 @@ export async function getQuickLinkConfig() { const response = await getConfig('site-config.json'); for (const row of response.quicklinks?.data || []) { - if (row.Title && row.Page && (row.Group ?? '') === '') { - result.push({ - title: row.Title, - page: row.Page, - }); - } else if (row.Title && row.Page && row.Group) { - if (await checkPageGroupAccess(row.Group)) - { + if (row.Title && row.Page) { + if (!row.Group || (await checkPageGroupAccess(row.Group))) { result.push({ title: row.Title, page: row.Page, + hide: row.Hide, }); } }