This commit is contained in:
parent
6d6a4867c5
commit
05d248127f
|
@ -9,6 +9,7 @@
|
|||
export const APP_NAME = 'visualize';
|
||||
|
||||
export const VisualizeConstants = {
|
||||
VISUALIZE_BASE_PATH: '/app/visualize',
|
||||
LANDING_PAGE_PATH: '/',
|
||||
WIZARD_STEP_1_PAGE_PATH: '/new',
|
||||
WIZARD_STEP_2_PAGE_PATH: '/new/configure',
|
||||
|
|
|
@ -78,6 +78,7 @@ export class VisualizePlugin
|
|||
private appStateUpdater = new BehaviorSubject<AppUpdater>(() => ({}));
|
||||
private stopUrlTracking: (() => void) | undefined = undefined;
|
||||
private currentHistory: ScopedHistory | undefined = undefined;
|
||||
private isLinkedToOriginatingApp: (() => boolean) | undefined = undefined;
|
||||
|
||||
private readonly visEditorsRegistry = createVisEditorsRegistry();
|
||||
|
||||
|
@ -94,7 +95,7 @@ export class VisualizePlugin
|
|||
setActiveUrl,
|
||||
restorePreviousUrl,
|
||||
} = createKbnUrlTracker({
|
||||
baseUrl: core.http.basePath.prepend('/app/visualize'),
|
||||
baseUrl: core.http.basePath.prepend(VisualizeConstants.VISUALIZE_BASE_PATH),
|
||||
defaultSubUrl: '#/',
|
||||
storageKey: `lastUrl:${core.http.basePath.get()}:visualize`,
|
||||
navLinkUpdater$: this.appStateUpdater,
|
||||
|
@ -114,6 +115,15 @@ export class VisualizePlugin
|
|||
},
|
||||
],
|
||||
getHistory: () => this.currentHistory!,
|
||||
onBeforeNavLinkSaved: (urlToSave: string) => {
|
||||
if (
|
||||
!urlToSave.includes(`${VisualizeConstants.EDIT_PATH}/`) &&
|
||||
this.isLinkedToOriginatingApp?.()
|
||||
) {
|
||||
return core.http.basePath.prepend(VisualizeConstants.VISUALIZE_BASE_PATH);
|
||||
}
|
||||
return urlToSave;
|
||||
},
|
||||
});
|
||||
this.stopUrlTracking = () => {
|
||||
stopUrlTracker();
|
||||
|
@ -134,6 +144,13 @@ export class VisualizePlugin
|
|||
const [coreStart, pluginsStart] = await core.getStartServices();
|
||||
this.currentHistory = params.history;
|
||||
|
||||
// allows the urlTracker to only save URLs that are not linked to an originatingApp
|
||||
this.isLinkedToOriginatingApp = () => {
|
||||
return Boolean(
|
||||
pluginsStart.embeddable.getStateTransfer().getIncomingEditorState()?.originatingApp
|
||||
);
|
||||
};
|
||||
|
||||
// make sure the index pattern list is up to date
|
||||
pluginsStart.data.indexPatterns.clearCache();
|
||||
// make sure a default index pattern exists
|
||||
|
|
|
@ -12,6 +12,7 @@ export default function ({ getService, getPageObjects }) {
|
|||
const PageObjects = getPageObjects(['dashboard', 'header', 'visualize', 'common', 'visEditor']);
|
||||
const esArchiver = getService('esArchiver');
|
||||
const testSubjects = getService('testSubjects');
|
||||
const appsMenu = getService('appsMenu');
|
||||
const kibanaServer = getService('kibanaServer');
|
||||
const dashboardPanelActions = getService('dashboardPanelActions');
|
||||
const dashboardVisualizations = getService('dashboardVisualizations');
|
||||
|
@ -25,10 +26,14 @@ export default function ({ getService, getPageObjects }) {
|
|||
await PageObjects.visualize.clickMarkdownWidget();
|
||||
await PageObjects.visEditor.setMarkdownTxt(originalMarkdownText);
|
||||
await PageObjects.visEditor.clickGo();
|
||||
await PageObjects.visualize.saveVisualizationExpectSuccess(title, {
|
||||
saveAsNew: true,
|
||||
redirectToOrigin: true,
|
||||
});
|
||||
if (title) {
|
||||
await PageObjects.visualize.saveVisualizationExpectSuccess(title, {
|
||||
saveAsNew: true,
|
||||
redirectToOrigin: true,
|
||||
});
|
||||
} else {
|
||||
await PageObjects.visualize.saveVisualizationAndReturn();
|
||||
}
|
||||
};
|
||||
|
||||
const editMarkdownVis = async () => {
|
||||
|
@ -86,5 +91,22 @@ export default function ({ getService, getPageObjects }) {
|
|||
const markdownText = await testSubjects.find('markdownBody');
|
||||
expect(await markdownText.getVisibleText()).to.eql(originalMarkdownText);
|
||||
});
|
||||
|
||||
it('visualize app menu navigates to the visualize listing page if the last opened visualization was by value', async () => {
|
||||
await PageObjects.dashboard.gotoDashboardLandingPage();
|
||||
await PageObjects.dashboard.clickNewDashboard();
|
||||
|
||||
// Create markdown by value.
|
||||
await createMarkdownVis();
|
||||
|
||||
// Edit then save and return
|
||||
await editMarkdownVis();
|
||||
await PageObjects.visualize.saveVisualizationAndReturn();
|
||||
|
||||
await PageObjects.header.waitUntilLoadingHasFinished();
|
||||
await appsMenu.clickLink('Visualize');
|
||||
await PageObjects.common.clickConfirmOnModal();
|
||||
expect(await testSubjects.exists('visualizationLandingPage')).to.be(true);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue