From f5a6fe360c08d2b0b434b5f0c5bc44acea36ba73 Mon Sep 17 00:00:00 2001 From: Ryan Long Date: Wed, 8 Jul 2020 08:51:15 -0400 Subject: [PATCH] add focus to settings menu (#865) * add focus to settings menu * lint --- src/js/App/Header/Tools.js | 2 +- src/js/entry.js | 7 +++++++ src/js/utils.js | 14 ++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/js/App/Header/Tools.js b/src/js/App/Header/Tools.js index 5e96d20a3..a4a9925b0 100644 --- a/src/js/App/Header/Tools.js +++ b/src/js/App/Header/Tools.js @@ -84,7 +84,7 @@ const Tools = () => { {/* Show tools on medium and above screens */} { !isSettingsDisabled && - + { } } diff --git a/src/js/entry.js b/src/js/entry.js index 0a91f11bb..937df6818 100644 --- a/src/js/entry.js +++ b/src/js/entry.js @@ -20,6 +20,7 @@ import Cookies from 'js-cookie'; const log = require('./jwt/logger')('entry.js'); const sourceOfTruth = require('./nav/sourceOfTruth'); import { fetchPermissions } from './rbac/fetchPermissions'; +import { getUrl } from './utils'; // used for translating event names exposed publicly to internal event names const PUBLIC_EVENTS = { @@ -134,6 +135,12 @@ export function bootstrap(libjwt, initFunc) { isPenTest: () => { return Cookies.get('x-rh-insights-pentest') ? true : false; }, + getBundle: () => { + return getUrl('bundle'); + }, + getApp: () => { + return getUrl('app'); + }, visibilityFunctions, init: initFunc }, diff --git a/src/js/utils.js b/src/js/utils.js index 60c99d80c..1d8d246da 100644 --- a/src/js/utils.js +++ b/src/js/utils.js @@ -111,3 +111,17 @@ export function bootstrapCache(endpoint, cacheKey) { maxAge: 10 * 60 * 1000 // 10 minutes }); } + +export function getUrl(type) { + + if (window.location.pathname === ('/beta' || '/')) { + return 'landing'; + } + + const sections = window.location.pathname.split('/'); + if (sections[1] === 'beta') { + return type === 'bundle' ? sections[2] : sections[3]; + } + + return type === 'bundle' ? sections[1] : sections[2]; +}