mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
# Backport This will backport the following commits from `main` to `8.8`: - [[Dashboard] Fix styling of top nav bar (#159754)](https://github.com/elastic/kibana/pull/159754) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Hannah Mudge","email":"Heenawter@users.noreply.github.com"},"sourceCommit":{"committedDate":"2023-06-20T22:23:06Z","message":"[Dashboard] Fix styling of top nav bar (#159754)\n\nCloses https://github.com/elastic/kibana/issues/159353\r\nCloses https://github.com/elastic/kibana/issues/159756\r\n\r\n## Summary\r\n\r\nThis PR adds styling so that, when the dashboard's chrome is hidden or\r\nwhen there is a header banner present, the dashboard's top navigation\r\nbar's `top` position is adjusted as necessary - this prevents it from\r\neither (a) getting hidden behind the Kibana chrome or (b) floating in\r\nthe wrong position and overlapping the dashboard content, regardless of\r\nif the dashboard is in embed mode (i.e. `embed=true` is present in the\r\nURL) or not (i.e. `embed=false` is present in the URL **or**, more\r\ncommonly, there is no `embed` parameter in the URL).\r\n\r\n### Embed Mode\r\n\r\n- #### Before:\r\n\r\n\r\n76d3c70c
-936c-4bcc-985c-4fb433f0cff3\r\n\r\n- #### After:\r\n\r\n\r\n137bc103
-666b-4fdd-ab4e-8994345e21b4\r\n\r\nIt also resolves a bug where the `isEmbeddedExternally` component state\r\nwas never actually being set, which meant that the\r\n`ExitFullScreenButton` was always receiving `toggleChrome=true`. This\r\nmade it so that entering and exiting fullscreen mode in an embedded\r\ndashboard would force the chrome to be visible (which should never\r\nhappen in embed mode).\r\n\r\n#### How to Test\r\nThe easiest way to test this PR is to simply add `embed=true` to your\r\ndashboard URL - because this PR also fixes\r\nhttps://github.com/elastic/kibana/issues/159756, this will essentially\r\nmimic the embedded experience.\r\n\r\nAlternatively, if you want to test this in an actual iframe...\r\n\r\n1. Start and login to Kibana with the default `kibana.yml` settings\r\n2. Create and embed a dashboard using an iframe in an HTML file and open\r\nthat file in your browser - the iframe will show a prompt to login, but\r\nyou won't be able to. Instead...\r\n3. Add the following settings to your `kibana.yml` file:<br><Br>\r\n ```\r\n xpack.security.secureCookies: true\r\n xpack.security.sameSiteCookies: 'None'\r\n ```\r\n4. Wait for Kibana to re-load\r\n5. Refresh the HTML page from step 2\r\n6. The embedded dashboard should now be available for you to test 👍 \r\n\r\n#### Scenarios Tested\r\n\r\n- **Non-fullscreen mode**\r\n\r\n <details>\r\n<summary>✅ Without filter pill, without header banner <i>(click to see\r\nscreenshot)</i></summary>\r\n<img\r\nsrc=\"f68bbcfb
-74d8-497c-a2ae-33e8e0c02660\"/>\r\n </details>\r\n\r\n <details>\r\n<summary>✅ Without filter pill, with header banner <i>(click to see\r\nscreenshot)</i></summary>\r\n<img\r\nsrc=\"7c19711c
-61dc-499a-b1d0-01fab639a27e\"/>\r\n </details>\r\n\r\n <details>\r\n<summary>✅ With filter pill, without header banner <i>(click to see\r\nscreenshot)</i></summary>\r\n<img\r\nsrc=\"36e848bd
-f0d9-41e3-8a8a-a48571ad5cd2\"/>\r\n </details>\r\n\r\n <details>\r\n<summary>✅ With filter pill, with header banner <i>(click to see\r\nscreenshot)</i></summary>\r\n<img\r\nsrc=\"cd7489f6
-3f34-439a-a30e-3ef39f3970b5\"/>\r\n </details>\r\n \r\n <details>\r\n<summary>✅ With filter pill, with header banner <b>and</b> notification\r\nbanner <i>(click to see GIF)</i></summary>\r\n<img\r\nsrc=\"bd67b4eb
-4f68-4d9b-9e22-4d1b2d2e4d90\"/>\r\n </details>\r\n\r\n- **Fullscreen mode**\r\n\r\n <details>\r\n<summary>✅ Without filter pill, without banner <i>(click to see\r\nscreenshot)</i></summary>\r\n<img\r\nsrc=\"d7d15560
-7698-424f-b761-59b5557abe37\"/>\r\n </details>\r\n\r\n <details>\r\n<summary>✅ Without filter pill, with header banner <i>(click to see\r\nscreenshot)</i></summary>\r\n<img\r\nsrc=\"311b6f3d
-5152-4d16-ba39-160978c60c96\"/>\r\n </details>\r\n\r\n <details>\r\n<summary>✅ With filter pill, without header banner <i>(click to see\r\nscreenshot)</i></summary>\r\n<img\r\nsrc=\"bff9e040
-8169-40c7-a086-13a19e870383\"/>\r\n </details>\r\n\r\n <details>\r\n<summary>✅ With filter pill, with header banner <i>(click to see\r\nscreenshot)</i></summary>\r\n<img\r\nsrc=\"3f453811
-e65d-4ac4-9524-c396f9efdbdd\"/>\r\n </details>\r\n\r\n <details>\r\n<summary>✅ With filter pill, with header banner <b>and</b> notification\r\nbanner <i>(click to see GIF)</i></summary>\r\n<img\r\nsrc=\"f79673e7
-03f2-49fa-be56-b67bf7a12976\"/>\r\n </details>\r\n\r\n### Non-Embed Mode\r\n\r\n- #### Before:\r\n\r\n\r\n71ffc964
-2844-41a6-98d6-353e84d674be\r\n\r\n- #### After:\r\n\r\n\r\n894aa292
-b611-4e5e-a0d7-fe3d256fc3ba\r\n\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [x] This was checked for [cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n### For maintainers\r\n\r\n- [ ] This was checked for breaking API changes and was [labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"a4d5209a9f66c798e7e8d7bb4bbdc008aa7676ff","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["blocker","Feature:Dashboard","release_note:fix","Team:Presentation","loe:days","impact:critical","backport:prev-minor","v8.9.0","v8.8.2"],"number":159754,"url":"https://github.com/elastic/kibana/pull/159754","mergeCommit":{"message":"[Dashboard] Fix styling of top nav bar (#159754)\n\nCloses https://github.com/elastic/kibana/issues/159353\r\nCloses https://github.com/elastic/kibana/issues/159756\r\n\r\n## Summary\r\n\r\nThis PR adds styling so that, when the dashboard's chrome is hidden or\r\nwhen there is a header banner present, the dashboard's top navigation\r\nbar's `top` position is adjusted as necessary - this prevents it from\r\neither (a) getting hidden behind the Kibana chrome or (b) floating in\r\nthe wrong position and overlapping the dashboard content, regardless of\r\nif the dashboard is in embed mode (i.e. `embed=true` is present in the\r\nURL) or not (i.e. `embed=false` is present in the URL **or**, more\r\ncommonly, there is no `embed` parameter in the URL).\r\n\r\n### Embed Mode\r\n\r\n- #### Before:\r\n\r\n\r\n76d3c70c
-936c-4bcc-985c-4fb433f0cff3\r\n\r\n- #### After:\r\n\r\n\r\n137bc103
-666b-4fdd-ab4e-8994345e21b4\r\n\r\nIt also resolves a bug where the `isEmbeddedExternally` component state\r\nwas never actually being set, which meant that the\r\n`ExitFullScreenButton` was always receiving `toggleChrome=true`. This\r\nmade it so that entering and exiting fullscreen mode in an embedded\r\ndashboard would force the chrome to be visible (which should never\r\nhappen in embed mode).\r\n\r\n#### How to Test\r\nThe easiest way to test this PR is to simply add `embed=true` to your\r\ndashboard URL - because this PR also fixes\r\nhttps://github.com/elastic/kibana/issues/159756, this will essentially\r\nmimic the embedded experience.\r\n\r\nAlternatively, if you want to test this in an actual iframe...\r\n\r\n1. Start and login to Kibana with the default `kibana.yml` settings\r\n2. Create and embed a dashboard using an iframe in an HTML file and open\r\nthat file in your browser - the iframe will show a prompt to login, but\r\nyou won't be able to. Instead...\r\n3. Add the following settings to your `kibana.yml` file:<br><Br>\r\n ```\r\n xpack.security.secureCookies: true\r\n xpack.security.sameSiteCookies: 'None'\r\n ```\r\n4. Wait for Kibana to re-load\r\n5. Refresh the HTML page from step 2\r\n6. The embedded dashboard should now be available for you to test 👍 \r\n\r\n#### Scenarios Tested\r\n\r\n- **Non-fullscreen mode**\r\n\r\n <details>\r\n<summary>✅ Without filter pill, without header banner <i>(click to see\r\nscreenshot)</i></summary>\r\n<img\r\nsrc=\"f68bbcfb
-74d8-497c-a2ae-33e8e0c02660\"/>\r\n </details>\r\n\r\n <details>\r\n<summary>✅ Without filter pill, with header banner <i>(click to see\r\nscreenshot)</i></summary>\r\n<img\r\nsrc=\"7c19711c
-61dc-499a-b1d0-01fab639a27e\"/>\r\n </details>\r\n\r\n <details>\r\n<summary>✅ With filter pill, without header banner <i>(click to see\r\nscreenshot)</i></summary>\r\n<img\r\nsrc=\"36e848bd
-f0d9-41e3-8a8a-a48571ad5cd2\"/>\r\n </details>\r\n\r\n <details>\r\n<summary>✅ With filter pill, with header banner <i>(click to see\r\nscreenshot)</i></summary>\r\n<img\r\nsrc=\"cd7489f6
-3f34-439a-a30e-3ef39f3970b5\"/>\r\n </details>\r\n \r\n <details>\r\n<summary>✅ With filter pill, with header banner <b>and</b> notification\r\nbanner <i>(click to see GIF)</i></summary>\r\n<img\r\nsrc=\"bd67b4eb
-4f68-4d9b-9e22-4d1b2d2e4d90\"/>\r\n </details>\r\n\r\n- **Fullscreen mode**\r\n\r\n <details>\r\n<summary>✅ Without filter pill, without banner <i>(click to see\r\nscreenshot)</i></summary>\r\n<img\r\nsrc=\"d7d15560
-7698-424f-b761-59b5557abe37\"/>\r\n </details>\r\n\r\n <details>\r\n<summary>✅ Without filter pill, with header banner <i>(click to see\r\nscreenshot)</i></summary>\r\n<img\r\nsrc=\"311b6f3d
-5152-4d16-ba39-160978c60c96\"/>\r\n </details>\r\n\r\n <details>\r\n<summary>✅ With filter pill, without header banner <i>(click to see\r\nscreenshot)</i></summary>\r\n<img\r\nsrc=\"bff9e040
-8169-40c7-a086-13a19e870383\"/>\r\n </details>\r\n\r\n <details>\r\n<summary>✅ With filter pill, with header banner <i>(click to see\r\nscreenshot)</i></summary>\r\n<img\r\nsrc=\"3f453811
-e65d-4ac4-9524-c396f9efdbdd\"/>\r\n </details>\r\n\r\n <details>\r\n<summary>✅ With filter pill, with header banner <b>and</b> notification\r\nbanner <i>(click to see GIF)</i></summary>\r\n<img\r\nsrc=\"f79673e7
-03f2-49fa-be56-b67bf7a12976\"/>\r\n </details>\r\n\r\n### Non-Embed Mode\r\n\r\n- #### Before:\r\n\r\n\r\n71ffc964
-2844-41a6-98d6-353e84d674be\r\n\r\n- #### After:\r\n\r\n\r\n894aa292
-b611-4e5e-a0d7-fe3d256fc3ba\r\n\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [x] This was checked for [cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n### For maintainers\r\n\r\n- [ ] This was checked for breaking API changes and was [labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"a4d5209a9f66c798e7e8d7bb4bbdc008aa7676ff"}},"sourceBranch":"main","suggestedTargetBranches":["8.8"],"targetPullRequestStates":[{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/159754","number":159754,"mergeCommit":{"message":"[Dashboard] Fix styling of top nav bar (#159754)\n\nCloses https://github.com/elastic/kibana/issues/159353\r\nCloses https://github.com/elastic/kibana/issues/159756\r\n\r\n## Summary\r\n\r\nThis PR adds styling so that, when the dashboard's chrome is hidden or\r\nwhen there is a header banner present, the dashboard's top navigation\r\nbar's `top` position is adjusted as necessary - this prevents it from\r\neither (a) getting hidden behind the Kibana chrome or (b) floating in\r\nthe wrong position and overlapping the dashboard content, regardless of\r\nif the dashboard is in embed mode (i.e. `embed=true` is present in the\r\nURL) or not (i.e. `embed=false` is present in the URL **or**, more\r\ncommonly, there is no `embed` parameter in the URL).\r\n\r\n### Embed Mode\r\n\r\n- #### Before:\r\n\r\n\r\n76d3c70c
-936c-4bcc-985c-4fb433f0cff3\r\n\r\n- #### After:\r\n\r\n\r\n137bc103
-666b-4fdd-ab4e-8994345e21b4\r\n\r\nIt also resolves a bug where the `isEmbeddedExternally` component state\r\nwas never actually being set, which meant that the\r\n`ExitFullScreenButton` was always receiving `toggleChrome=true`. This\r\nmade it so that entering and exiting fullscreen mode in an embedded\r\ndashboard would force the chrome to be visible (which should never\r\nhappen in embed mode).\r\n\r\n#### How to Test\r\nThe easiest way to test this PR is to simply add `embed=true` to your\r\ndashboard URL - because this PR also fixes\r\nhttps://github.com/elastic/kibana/issues/159756, this will essentially\r\nmimic the embedded experience.\r\n\r\nAlternatively, if you want to test this in an actual iframe...\r\n\r\n1. Start and login to Kibana with the default `kibana.yml` settings\r\n2. Create and embed a dashboard using an iframe in an HTML file and open\r\nthat file in your browser - the iframe will show a prompt to login, but\r\nyou won't be able to. Instead...\r\n3. Add the following settings to your `kibana.yml` file:<br><Br>\r\n ```\r\n xpack.security.secureCookies: true\r\n xpack.security.sameSiteCookies: 'None'\r\n ```\r\n4. Wait for Kibana to re-load\r\n5. Refresh the HTML page from step 2\r\n6. The embedded dashboard should now be available for you to test 👍 \r\n\r\n#### Scenarios Tested\r\n\r\n- **Non-fullscreen mode**\r\n\r\n <details>\r\n<summary>✅ Without filter pill, without header banner <i>(click to see\r\nscreenshot)</i></summary>\r\n<img\r\nsrc=\"f68bbcfb
-74d8-497c-a2ae-33e8e0c02660\"/>\r\n </details>\r\n\r\n <details>\r\n<summary>✅ Without filter pill, with header banner <i>(click to see\r\nscreenshot)</i></summary>\r\n<img\r\nsrc=\"7c19711c
-61dc-499a-b1d0-01fab639a27e\"/>\r\n </details>\r\n\r\n <details>\r\n<summary>✅ With filter pill, without header banner <i>(click to see\r\nscreenshot)</i></summary>\r\n<img\r\nsrc=\"36e848bd
-f0d9-41e3-8a8a-a48571ad5cd2\"/>\r\n </details>\r\n\r\n <details>\r\n<summary>✅ With filter pill, with header banner <i>(click to see\r\nscreenshot)</i></summary>\r\n<img\r\nsrc=\"cd7489f6
-3f34-439a-a30e-3ef39f3970b5\"/>\r\n </details>\r\n \r\n <details>\r\n<summary>✅ With filter pill, with header banner <b>and</b> notification\r\nbanner <i>(click to see GIF)</i></summary>\r\n<img\r\nsrc=\"bd67b4eb
-4f68-4d9b-9e22-4d1b2d2e4d90\"/>\r\n </details>\r\n\r\n- **Fullscreen mode**\r\n\r\n <details>\r\n<summary>✅ Without filter pill, without banner <i>(click to see\r\nscreenshot)</i></summary>\r\n<img\r\nsrc=\"d7d15560
-7698-424f-b761-59b5557abe37\"/>\r\n </details>\r\n\r\n <details>\r\n<summary>✅ Without filter pill, with header banner <i>(click to see\r\nscreenshot)</i></summary>\r\n<img\r\nsrc=\"311b6f3d
-5152-4d16-ba39-160978c60c96\"/>\r\n </details>\r\n\r\n <details>\r\n<summary>✅ With filter pill, without header banner <i>(click to see\r\nscreenshot)</i></summary>\r\n<img\r\nsrc=\"bff9e040
-8169-40c7-a086-13a19e870383\"/>\r\n </details>\r\n\r\n <details>\r\n<summary>✅ With filter pill, with header banner <i>(click to see\r\nscreenshot)</i></summary>\r\n<img\r\nsrc=\"3f453811
-e65d-4ac4-9524-c396f9efdbdd\"/>\r\n </details>\r\n\r\n <details>\r\n<summary>✅ With filter pill, with header banner <b>and</b> notification\r\nbanner <i>(click to see GIF)</i></summary>\r\n<img\r\nsrc=\"f79673e7
-03f2-49fa-be56-b67bf7a12976\"/>\r\n </details>\r\n\r\n### Non-Embed Mode\r\n\r\n- #### Before:\r\n\r\n\r\n71ffc964
-2844-41a6-98d6-353e84d674be\r\n\r\n- #### After:\r\n\r\n\r\n894aa292
-b611-4e5e-a0d7-fe3d256fc3ba\r\n\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [x] This was checked for [cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n### For maintainers\r\n\r\n- [ ] This was checked for breaking API changes and was [labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"a4d5209a9f66c798e7e8d7bb4bbdc008aa7676ff"}},{"branch":"8.8","label":"v8.8.2","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT-->
This commit is contained in:
parent
43ff0befa1
commit
78d76d8481
10 changed files with 114 additions and 45 deletions
|
@ -160,9 +160,11 @@ export function DashboardApp({
|
|||
},
|
||||
getInitialInput,
|
||||
validateLoadedSavedObject: validateOutcome,
|
||||
isEmbeddedExternally: Boolean(embedSettings), // embed settings are only sent if the dashboard URL has `embed=true`
|
||||
});
|
||||
}, [
|
||||
history,
|
||||
embedSettings,
|
||||
validateOutcome,
|
||||
getScopedHistory,
|
||||
isScreenshotMode,
|
||||
|
|
|
@ -90,16 +90,16 @@ export async function mountApp({ core, element, appUnMounted, mountContext }: Da
|
|||
routeParams: ParsedQuery<string>
|
||||
): DashboardEmbedSettings | undefined => {
|
||||
return {
|
||||
forceShowTopNavMenu: Boolean(routeParams[dashboardUrlParams.showTopMenu]),
|
||||
forceShowQueryInput: Boolean(routeParams[dashboardUrlParams.showQueryInput]),
|
||||
forceShowDatePicker: Boolean(routeParams[dashboardUrlParams.showTimeFilter]),
|
||||
forceHideFilterBar: Boolean(routeParams[dashboardUrlParams.hideFilterBar]),
|
||||
forceShowTopNavMenu: routeParams[dashboardUrlParams.showTopMenu] === 'true',
|
||||
forceShowQueryInput: routeParams[dashboardUrlParams.showQueryInput] === 'true',
|
||||
forceShowDatePicker: routeParams[dashboardUrlParams.showTimeFilter] === 'true',
|
||||
forceHideFilterBar: routeParams[dashboardUrlParams.hideFilterBar] === 'true',
|
||||
};
|
||||
};
|
||||
|
||||
const renderDashboard = (routeProps: RouteComponentProps<{ id?: string }>) => {
|
||||
const routeParams = parse(routeProps.history.location.search);
|
||||
if (routeParams.embed && !globalEmbedSettings) {
|
||||
if (routeParams.embed === 'true' && !globalEmbedSettings) {
|
||||
globalEmbedSettings = getDashboardEmbedSettings(routeParams);
|
||||
}
|
||||
return (
|
||||
|
|
|
@ -1,11 +1,26 @@
|
|||
.dashboardTopNav {
|
||||
width: 100%;
|
||||
position: sticky;
|
||||
z-index: $euiZLevel2;
|
||||
background: $euiPageBackgroundColor;
|
||||
.kbnBody {
|
||||
.dashboardTopNav {
|
||||
width: 100%;
|
||||
position: sticky;
|
||||
z-index: $euiZLevel2;
|
||||
background: $euiPageBackgroundColor;
|
||||
}
|
||||
|
||||
top: $kbnHeaderOffset;
|
||||
&.dashboardTopNav-fullscreenMode {
|
||||
top: 0;
|
||||
&.kbnBody--noHeaderBanner {
|
||||
&.kbnBody--chromeVisible .dashboardTopNav {
|
||||
top: $kbnHeaderOffset;
|
||||
}
|
||||
&.kbnBody--chromeHidden .dashboardTopNav {
|
||||
top: 0;
|
||||
}
|
||||
}
|
||||
|
||||
&.kbnBody--hasHeaderBanner {
|
||||
&.kbnBody--chromeVisible .dashboardTopNav {
|
||||
top: $kbnHeaderOffsetWithBanner;
|
||||
}
|
||||
&.kbnBody--chromeHidden .dashboardTopNav {
|
||||
top: $kbnHeaderBannerHeight;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,7 +6,6 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import classNames from 'classnames';
|
||||
import UseUnmount from 'react-use/lib/useUnmount';
|
||||
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
||||
|
||||
|
@ -77,6 +76,7 @@ export function DashboardTopNav({ embedSettings, redirectTo }: DashboardTopNavPr
|
|||
const fullScreenMode = dashboard.select((state) => state.componentState.fullScreenMode);
|
||||
const savedQueryId = dashboard.select((state) => state.componentState.savedQueryId);
|
||||
const lastSavedId = dashboard.select((state) => state.componentState.lastSavedId);
|
||||
|
||||
const viewMode = dashboard.select((state) => state.explicitInput.viewMode);
|
||||
const query = dashboard.select((state) => state.explicitInput.query);
|
||||
const title = dashboard.select((state) => state.explicitInput.title);
|
||||
|
@ -207,11 +207,7 @@ export function DashboardTopNav({ embedSettings, redirectTo }: DashboardTopNavPr
|
|||
});
|
||||
|
||||
return (
|
||||
<div
|
||||
className={classNames('dashboardTopNav', {
|
||||
'dashboardTopNav-fullscreenMode': fullScreenMode,
|
||||
})}
|
||||
>
|
||||
<div className="dashboardTopNav">
|
||||
<h1
|
||||
id="dashboardTitle"
|
||||
className="euiScreenReaderOnly"
|
||||
|
|
|
@ -172,6 +172,7 @@ export class DashboardContainer extends Container<InheritedChildInput, Dashboard
|
|||
...DEFAULT_DASHBOARD_INPUT,
|
||||
id: initialInput.id,
|
||||
},
|
||||
isEmbeddedExternally: creationOptions?.isEmbeddedExternally,
|
||||
animatePanelTransforms: false, // set panel transforms to false initially to avoid panels animating on initial render.
|
||||
hasUnsavedChanges: false, // if there is initial unsaved changes, the initial diff will catch them.
|
||||
lastSavedId: savedObjectId,
|
||||
|
|
|
@ -56,6 +56,7 @@ export interface DashboardCreationOptions {
|
|||
unifiedSearchSettings?: { kbnUrlStateStorage: IKbnUrlStateStorage };
|
||||
|
||||
validateLoadedSavedObject?: (result: LoadDashboardFromSavedObjectReturn) => boolean;
|
||||
isEmbeddedExternally?: boolean;
|
||||
}
|
||||
|
||||
export class DashboardContainerFactoryDefinition
|
||||
|
|
|
@ -10,13 +10,19 @@ import expect from '@kbn/expect';
|
|||
|
||||
import { FtrProviderContext } from '../../../ftr_provider_context';
|
||||
|
||||
export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
||||
export default function ({
|
||||
getService,
|
||||
getPageObjects,
|
||||
updateBaselines,
|
||||
}: FtrProviderContext & { updateBaselines: boolean }) {
|
||||
const testSubjects = getService('testSubjects');
|
||||
const retry = getService('retry');
|
||||
const kibanaServer = getService('kibanaServer');
|
||||
const PageObjects = getPageObjects(['dashboard', 'common']);
|
||||
const browser = getService('browser');
|
||||
const globalNav = getService('globalNav');
|
||||
const screenshot = getService('screenshots');
|
||||
const log = getService('log');
|
||||
|
||||
describe('embed mode', () => {
|
||||
const urlParamExtensions = [
|
||||
|
@ -36,40 +42,88 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
});
|
||||
await PageObjects.common.navigateToApp('dashboard');
|
||||
await PageObjects.dashboard.preserveCrossAppState();
|
||||
await PageObjects.dashboard.loadSavedDashboard('few panels');
|
||||
await PageObjects.dashboard.loadSavedDashboard('dashboard with everything');
|
||||
|
||||
await browser.setWindowSize(1300, 900);
|
||||
});
|
||||
|
||||
it('hides the chrome', async () => {
|
||||
const globalNavShown = await globalNav.exists();
|
||||
expect(globalNavShown).to.be(true);
|
||||
describe('default URL params', () => {
|
||||
it('hides the chrome', async () => {
|
||||
const globalNavShown = await globalNav.exists();
|
||||
expect(globalNavShown).to.be(true);
|
||||
|
||||
const currentUrl = await browser.getCurrentUrl();
|
||||
const newUrl = currentUrl + '&embed=true';
|
||||
// Embed parameter only works on a hard refresh.
|
||||
const useTimeStamp = true;
|
||||
await browser.get(newUrl.toString(), useTimeStamp);
|
||||
const currentUrl = await browser.getCurrentUrl();
|
||||
const newUrl = currentUrl + '&embed=true';
|
||||
// Embed parameter only works on a hard refresh.
|
||||
const useTimeStamp = true;
|
||||
await browser.get(newUrl.toString(), useTimeStamp);
|
||||
|
||||
await retry.try(async () => {
|
||||
const globalNavHidden = !(await globalNav.exists());
|
||||
expect(globalNavHidden).to.be(true);
|
||||
await retry.try(async () => {
|
||||
const globalNavHidden = !(await globalNav.exists());
|
||||
expect(globalNavHidden).to.be(true);
|
||||
});
|
||||
});
|
||||
|
||||
it('expected elements are rendered and/or hidden', async () => {
|
||||
await testSubjects.missingOrFail('top-nav');
|
||||
await testSubjects.missingOrFail('queryInput');
|
||||
await testSubjects.missingOrFail('superDatePickerToggleQuickMenuButton');
|
||||
await testSubjects.existOrFail('globalQueryBar');
|
||||
});
|
||||
|
||||
/**
|
||||
* Skipping all render tests for now - there is a problem where the locally generated screenshots do not align with the
|
||||
* CI screenshots due to (possibly) pixel density or something similar. This fix is super important to get in so we will
|
||||
* have to resolve the issue with these new tests *after* FF for 8.9/8.8.2
|
||||
*/
|
||||
it.skip('renders as expected', async () => {
|
||||
await PageObjects.dashboard.waitForRenderComplete();
|
||||
const percentDifference = await screenshot.compareAgainstBaseline(
|
||||
'dashboard_embed_mode',
|
||||
updateBaselines
|
||||
);
|
||||
expect(percentDifference).to.be.lessThan(0.02);
|
||||
});
|
||||
});
|
||||
|
||||
it('shows or hides elements based on URL params', async () => {
|
||||
await testSubjects.missingOrFail('top-nav');
|
||||
await testSubjects.missingOrFail('queryInput');
|
||||
await testSubjects.missingOrFail('superDatePickerToggleQuickMenuButton');
|
||||
await testSubjects.existOrFail('showQueryBarMenu');
|
||||
describe('non-default URL params', () => {
|
||||
it('shows or hides elements based on URL params', async () => {
|
||||
const currentUrl = await browser.getCurrentUrl();
|
||||
const newUrl = [currentUrl].concat(urlParamExtensions).join('&');
|
||||
// Embed parameter only works on a hard refresh.
|
||||
const useTimeStamp = true;
|
||||
await browser.get(newUrl.toString(), useTimeStamp);
|
||||
|
||||
const currentUrl = await browser.getCurrentUrl();
|
||||
const newUrl = [currentUrl].concat(urlParamExtensions).join('&');
|
||||
// Embed parameter only works on a hard refresh.
|
||||
const useTimeStamp = true;
|
||||
await browser.get(newUrl.toString(), useTimeStamp);
|
||||
await testSubjects.existOrFail('top-nav');
|
||||
await testSubjects.existOrFail('queryInput');
|
||||
await testSubjects.existOrFail('superDatePickerToggleQuickMenuButton');
|
||||
});
|
||||
|
||||
await testSubjects.existOrFail('top-nav');
|
||||
await testSubjects.existOrFail('queryInput');
|
||||
await testSubjects.existOrFail('superDatePickerToggleQuickMenuButton');
|
||||
it.skip('renders as expected', async () => {
|
||||
await PageObjects.dashboard.waitForRenderComplete();
|
||||
const percentDifference = await screenshot.compareAgainstBaseline(
|
||||
'dashboard_embed_mode_with_url_params',
|
||||
updateBaselines
|
||||
);
|
||||
expect(percentDifference).to.be.lessThan(0.02);
|
||||
});
|
||||
|
||||
it.skip('renders as expected when scrolling', async () => {
|
||||
const panels = await PageObjects.dashboard.getDashboardPanels();
|
||||
const lastPanel = panels[panels.length - 1];
|
||||
const lastPanelHeight = -parseInt(await lastPanel.getComputedStyle('height'), 10);
|
||||
log.debug(
|
||||
`scrolling to panel ${await lastPanel.getAttribute(
|
||||
'data-test-embeddable-id'
|
||||
)} with offset ${lastPanelHeight}...`
|
||||
);
|
||||
await lastPanel.scrollIntoViewIfNecessary(lastPanelHeight);
|
||||
const percentDifference = await screenshot.compareAgainstBaseline(
|
||||
'dashboard_embed_mode_scrolling',
|
||||
updateBaselines
|
||||
);
|
||||
expect(percentDifference).to.be.lessThan(0.02);
|
||||
});
|
||||
});
|
||||
|
||||
after(async function () {
|
||||
|
|
BIN
test/functional/screenshots/baseline/dashboard_embed_mode.png
Normal file
BIN
test/functional/screenshots/baseline/dashboard_embed_mode.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 124 KiB |
Binary file not shown.
After Width: | Height: | Size: 83 KiB |
Binary file not shown.
After Width: | Height: | Size: 135 KiB |
Loading…
Add table
Add a link
Reference in a new issue