Skip to content

Commit

Permalink
[7.7] make last stored url space aware (#62264) (#62625)
Browse files Browse the repository at this point in the history
* make last stored url space aware (#62264)

* fix doc type
  • Loading branch information
flash1293 authored Apr 7, 2020
1 parent 80e0b67 commit df192f9
Show file tree
Hide file tree
Showing 11 changed files with 683 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/kibana/public/dashboard/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class DashboardPlugin implements Plugin {
targetAppName === DashboardConstants.DASHBOARD_ID
);
},
storageKey: 'lastUrl:dashboard',
storageKey: `lastUrl:${core.http.basePath.get()}:dashboard`,
navLinkUpdater$: this.appStateUpdater,
toastNotifications: core.notifications.toasts,
stateParams: [
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/kibana/public/discover/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class DiscoverPlugin implements Plugin<void, void> {
} = createKbnUrlTracker({
baseUrl: core.http.basePath.prepend('/app/kibana'),
defaultSubUrl: '#/discover',
storageKey: 'lastUrl:discover',
storageKey: `lastUrl:${core.http.basePath.get()}:discover`,
navLinkUpdater$: this.appStateUpdater,
toastNotifications: core.notifications.toasts,
stateParams: [
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/kibana/public/visualize/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class VisualizePlugin implements Plugin {
const { appMounted, appUnMounted, stop: stopUrlTracker, setActiveUrl } = createKbnUrlTracker({
baseUrl: core.http.basePath.prepend('/app/kibana'),
defaultSubUrl: '#/visualize',
storageKey: 'lastUrl:visualize',
storageKey: `lastUrl:${core.http.basePath.get()}:visualize`,
navLinkUpdater$: this.appStateUpdater,
toastNotifications: core.notifications.toasts,
stateParams: [
Expand Down
1 change: 1 addition & 0 deletions x-pack/test/functional/apps/dashboard/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ export default function({ loadTestFile }: FtrProviderContext) {
this.tags('ciGroup7');

loadTestFile(require.resolve('./feature_controls'));
loadTestFile(require.resolve('./preserve_url'));
});
}
70 changes: 70 additions & 0 deletions x-pack/test/functional/apps/dashboard/preserve_url.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';

export default function({ getService, getPageObjects }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const PageObjects = getPageObjects(['common', 'dashboard', 'spaceSelector', 'header']);
const appsMenu = getService('appsMenu');
const globalNav = getService('globalNav');

describe('preserve url', function() {
before(async function() {
await esArchiver.load('spaces/multi_space');
});

after(function() {
return esArchiver.unload('spaces/multi_space');
});

it('goes back to last opened url', async function() {
await PageObjects.common.navigateToApp('dashboard');
await PageObjects.dashboard.loadSavedDashboard('A Dashboard');
await PageObjects.common.navigateToApp('home');
await appsMenu.clickLink('Dashboard');
await PageObjects.dashboard.loadSavedDashboard('A Dashboard');
await PageObjects.header.waitUntilLoadingHasFinished();
const activeTitle = await globalNav.getLastBreadcrumb();
expect(activeTitle).to.be('A Dashboard');
});

it('remembers url after switching spaces', async function() {
// default space
await PageObjects.common.navigateToApp('dashboard');
await PageObjects.dashboard.loadSavedDashboard('A Dashboard');

await PageObjects.spaceSelector.openSpacesNav();
await PageObjects.spaceSelector.clickSpaceAvatar('another-space');
await PageObjects.spaceSelector.expectHomePage('another-space');

// other space
await appsMenu.clickLink('Dashboard');
await PageObjects.dashboard.loadSavedDashboard('A Dashboard in another space');

await PageObjects.spaceSelector.openSpacesNav();
await PageObjects.spaceSelector.clickSpaceAvatar('default');
await PageObjects.spaceSelector.expectHomePage('default');

// default space
await appsMenu.clickLink('Dashboard');
await PageObjects.dashboard.waitForRenderComplete();
const activeTitleDefaultSpace = await globalNav.getLastBreadcrumb();
expect(activeTitleDefaultSpace).to.be('A Dashboard');

await PageObjects.spaceSelector.openSpacesNav();
await PageObjects.spaceSelector.clickSpaceAvatar('another-space');
await PageObjects.spaceSelector.expectHomePage('another-space');

// other space
await appsMenu.clickLink('Dashboard');
await PageObjects.dashboard.waitForRenderComplete();
const activeTitleOtherSpace = await globalNav.getLastBreadcrumb();
expect(activeTitleOtherSpace).to.be('A Dashboard in another space');
});
});
}
1 change: 1 addition & 0 deletions x-pack/test/functional/apps/discover/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ export default function({ loadTestFile }: FtrProviderContext) {
this.tags('ciGroup8');

loadTestFile(require.resolve('./feature_controls'));
loadTestFile(require.resolve('./preserve_url'));
});
}
69 changes: 69 additions & 0 deletions x-pack/test/functional/apps/discover/preserve_url.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';

export default function({ getService, getPageObjects }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const PageObjects = getPageObjects(['common', 'discover', 'spaceSelector', 'header']);
const appsMenu = getService('appsMenu');
const globalNav = getService('globalNav');

describe('preserve url', function() {
before(async function() {
await esArchiver.load('spaces/multi_space');
});

after(function() {
return esArchiver.unload('spaces/multi_space');
});

it('goes back to last opened url', async function() {
await PageObjects.common.navigateToApp('discover');
await PageObjects.discover.saveSearch('A Search');
await PageObjects.common.navigateToApp('home');
await appsMenu.clickLink('Discover');
await PageObjects.discover.waitUntilSearchingHasFinished();
const activeTitle = await globalNav.getLastBreadcrumb();
expect(activeTitle).to.be('A Search');
});

it('remembers url after switching spaces', async function() {
// default space
await PageObjects.common.navigateToApp('discover');
await PageObjects.discover.loadSavedSearch('A Search');

await PageObjects.spaceSelector.openSpacesNav();
await PageObjects.spaceSelector.clickSpaceAvatar('another-space');
await PageObjects.spaceSelector.expectHomePage('another-space');

// other space
await appsMenu.clickLink('Discover');
await PageObjects.discover.saveSearch('A Search in another space');

await PageObjects.spaceSelector.openSpacesNav();
await PageObjects.spaceSelector.clickSpaceAvatar('default');
await PageObjects.spaceSelector.expectHomePage('default');

// default space
await appsMenu.clickLink('Discover');
await PageObjects.discover.waitUntilSearchingHasFinished();
const activeTitleDefaultSpace = await globalNav.getLastBreadcrumb();
expect(activeTitleDefaultSpace).to.be('A Search');

await PageObjects.spaceSelector.openSpacesNav();
await PageObjects.spaceSelector.clickSpaceAvatar('another-space');
await PageObjects.spaceSelector.expectHomePage('another-space');

// other space
await appsMenu.clickLink('Discover');
await PageObjects.discover.waitUntilSearchingHasFinished();
const activeTitleOtherSpace = await globalNav.getLastBreadcrumb();
expect(activeTitleOtherSpace).to.be('A Search in another space');
});
});
}
1 change: 1 addition & 0 deletions x-pack/test/functional/apps/visualize/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ export default function visualize({ loadTestFile }: FtrProviderContext) {
loadTestFile(require.resolve('./feature_controls/visualize_spaces'));
loadTestFile(require.resolve('./hybrid_visualization'));
loadTestFile(require.resolve('./precalculated_histogram'));
loadTestFile(require.resolve('./preserve_url'));
});
}
69 changes: 69 additions & 0 deletions x-pack/test/functional/apps/visualize/preserve_url.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';

export default function({ getService, getPageObjects }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const PageObjects = getPageObjects(['common', 'visualize', 'spaceSelector', 'visChart']);
const appsMenu = getService('appsMenu');
const globalNav = getService('globalNav');

describe('preserve url', function() {
before(async function() {
await esArchiver.load('spaces/multi_space');
});

after(function() {
return esArchiver.unload('spaces/multi_space');
});

it('goes back to last opened url', async function() {
await PageObjects.common.navigateToApp('visualize');
await PageObjects.visualize.openSavedVisualization('A Pie');
await PageObjects.common.navigateToApp('home');
await appsMenu.clickLink('Visualize');
await PageObjects.visChart.waitForVisualization();
const activeTitle = await globalNav.getLastBreadcrumb();
expect(activeTitle).to.be('A Pie');
});

it('remembers url after switching spaces', async function() {
// default space
await PageObjects.common.navigateToApp('visualize');
await PageObjects.visualize.openSavedVisualization('A Pie');

await PageObjects.spaceSelector.openSpacesNav();
await PageObjects.spaceSelector.clickSpaceAvatar('another-space');
await PageObjects.spaceSelector.expectHomePage('another-space');

// other space
await appsMenu.clickLink('Visualize');
await PageObjects.visualize.openSavedVisualization('A Pie in another space');

await PageObjects.spaceSelector.openSpacesNav();
await PageObjects.spaceSelector.clickSpaceAvatar('default');
await PageObjects.spaceSelector.expectHomePage('default');

// default space
await appsMenu.clickLink('Visualize');
await PageObjects.visChart.waitForVisualization();
const activeTitleDefaultSpace = await globalNav.getLastBreadcrumb();
expect(activeTitleDefaultSpace).to.be('A Pie');

await PageObjects.spaceSelector.openSpacesNav();
await PageObjects.spaceSelector.clickSpaceAvatar('another-space');
await PageObjects.spaceSelector.expectHomePage('another-space');

// other space
await appsMenu.clickLink('Visualize');
await PageObjects.visChart.waitForVisualization();
const activeTitleOtherSpace = await globalNav.getLastBreadcrumb();
expect(activeTitleOtherSpace).to.be('A Pie in another space');
});
});
}
Loading

0 comments on commit df192f9

Please sign in to comment.