Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure no one can show the chrome if the default setting is hidden. #13250

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/ui/public/chrome/api/controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,20 @@ export default function (chrome, internals) {
* determines if the Kibana chrome should be displayed
*/

let def = true;
internals.setVisibleDefault = (_def) => def = Boolean(_def);
let permanentlyHideChrome = false;
internals.permanentlyHideChrome = () => {
permanentlyHideChrome = true;
internals.visible = false;
};

/**
* @param {boolean} display - should the chrome be displayed
* @return {chrome}
*/
chrome.setVisible = function (display) {
if (permanentlyHideChrome) {
return chrome;
}
internals.visible = Boolean(display);
return chrome;
};
Expand All @@ -27,7 +33,7 @@ export default function (chrome, internals) {
* @return {boolean} - display state of the chrome
*/
chrome.getVisible = function () {
if (_.isUndefined(internals.visible)) return def;
if (_.isUndefined(internals.visible)) return !permanentlyHideChrome;
return internals.visible;
};
}
1 change: 1 addition & 0 deletions src/ui/public/chrome/directives/kbn_chrome.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<div class="content" chrome-context data-test-subj="kibanaChrome">
<global-nav
chrome="chrome"
data-test-subj="globalNav"
is-visible="chrome.getVisible()"
logo-brand="chrome.getBrand('logo')"
small-logo-brand="chrome.getBrand('smallLogo')"
Expand Down
4 changes: 3 additions & 1 deletion src/ui/public/chrome/directives/kbn_chrome.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ export function kbnChromeProvider(chrome, internals) {
const getUnhashableStates = Private(getUnhashableStatesProvider);

// are we showing the embedded version of the chrome?
internals.setVisibleDefault(!$location.search().embed);
if (Boolean($location.search().embed)) {
internals.permanentlyHideChrome();
}

// listen for route changes, propogate to tabs
const onRouteChange = function () {
Expand Down
30 changes: 30 additions & 0 deletions test/functional/apps/dashboard/_dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,36 @@ export default function ({ getService, getPageObjects }) {
});
});

describe('embed mode', () => {
it('hides the chrome', async () => {
let isChromeVisible = await PageObjects.common.isChromeVisible();
expect(isChromeVisible).to.be(true);

const currentUrl = await remote.getCurrentUrl();
const newUrl = currentUrl + '&embed=true';
// Embed parameter only works on a hard refresh.
const useTimeStamp = true;
await remote.get(newUrl.toString(), useTimeStamp);

await retry.try(async () => {
isChromeVisible = await PageObjects.common.isChromeVisible();
expect(isChromeVisible).to.be(false);
});
});

after(async function () {
console.log('showing chrome again');
const currentUrl = await remote.getCurrentUrl();
const newUrl = currentUrl.replace('&embed=true', '');
// First use the timestamp to cause a hard refresh so the new embed parameter works correctly.
let useTimeStamp = true;
await remote.get(newUrl.toString(), useTimeStamp);
// Then get rid of the timestamp so the rest of the tests work with state and app switching.
useTimeStamp = false;
await remote.get(newUrl.toString(), useTimeStamp);
});
});

describe('add new visualization link', () => {
it('adds a new visualization', async () => {
await PageObjects.dashboard.clickAddVisualization();
Expand Down
4 changes: 3 additions & 1 deletion test/functional/page_objects/common_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,9 @@ export function CommonPageProvider({ getService, getPageObjects }) {
}

async isChromeVisible() {
return await testSubjects.exists('kibanaChrome');
const globalNavShown = await testSubjects.exists('globalNav');
const topNavShown = await testSubjects.exists('top-nav');
return globalNavShown && topNavShown;
}

async waitForTopNavToBeVisible() {
Expand Down