From 97496675247af30ec287c225afd65dad9eeaf8f2 Mon Sep 17 00:00:00 2001 From: Kawika Avilla Date: Tue, 25 Apr 2023 08:55:10 -0700 Subject: [PATCH] [Dashboard listing] update edit url and view url (#416) * [Dashboard listing] update edit url and view url Update to include BASE_URL if basePath is defined. Since create url is just a direct nav and needs the basePath when passing props to the provider, the source code no longer appends the basePath to keep these URLs consistent. A feature should consolidate the basePaths in the dashboard listing service so that createUrl also adds the base path. At which point we no longer need the base path. Also removed some rogue URLs. Core PR: https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3922 --------- Signed-off-by: Kawika Avilla Signed-off-by: Joshua Li Co-authored-by: Joshua Li (cherry picked from commit f94c21e82cd29c55af6073d366d240328c684710) --- .cypress/integration/3_panels.spec.ts | 47 +++++++++++++++---- .../custom_panels/custom_panel_view_so.tsx | 1 - .../requests/dashboard_request_handler.ts | 5 +- public/plugin.ts | 10 ++-- .../ppl/save_as_new_query.ts | 1 - 5 files changed, 44 insertions(+), 20 deletions(-) diff --git a/.cypress/integration/3_panels.spec.ts b/.cypress/integration/3_panels.spec.ts index 4fac68df16..252be657a3 100644 --- a/.cypress/integration/3_panels.spec.ts +++ b/.cypress/integration/3_panels.spec.ts @@ -5,19 +5,16 @@ /// +import { suppressResizeObserverIssue } from '../utils/constants'; import { delay, - TEST_PANEL, - PPL_VISUALIZATIONS, - PPL_VISUALIZATIONS_NAMES, NEW_VISUALIZATION_NAME, PPL_FILTER, - SAMPLE_PANEL, - SAMPLE_VISUALIZATIONS_NAMES, + PPL_VISUALIZATIONS, + PPL_VISUALIZATIONS_NAMES, + TEST_PANEL, } from '../utils/panel_constants'; -import { suppressResizeObserverIssue } from '../utils/constants'; - describe('Adding sample data and visualization', () => { it('Adds sample flights data for visualization paragraph', () => { cy.visit(`${Cypress.env('opensearchDashboards')}/app/home#/tutorial_directory/sampleData`); @@ -226,6 +223,34 @@ describe('Testing panels table', () => { cy.get('button[data-test-subj="popoverModal__deleteButton"]').click(); cy.get('h2[data-test-subj="customPanels__noPanelsHome"]').should('exist'); }); + + it('Redirects to observability dashboard from OSD dashboards', () => { + moveToOsdDashboards(); + cy.location('pathname').should('eq', '/app/dashboards'); + cy.get('[data-test-subj="dashboardListingTitleLink-Test-Panel"]').click(); + cy.location('pathname').should('eq', '/app/observability-dashboards'); + }); + + it('Redirects to observability dashboard from OSD dashboards with edit', () => { + moveToOsdDashboards(); + cy.location('pathname').should('eq', '/app/dashboards'); + cy.get('[data-test-subj="dashboardListingTitleLink-Test-Panel"]') + .closest('tr') + .get('span.euiToolTipAnchor > button.euiButtonIcon') + .eq(0) + .click(); + cy.location('pathname').should('eq', '/app/observability-dashboards'); + cy.location('hash').should('include', '/edit'); + }); + + it('Redirects to observability dashboard from OSD dashboards with create', () => { + moveToOsdDashboards(); + cy.location('pathname').should('eq', '/app/dashboards'); + cy.get('div#createMenuPopover').click(); + cy.get('[data-test-subj="contextMenuItem-observability-panel"]').click(); + cy.location('pathname').should('eq', '/app/observability-dashboards'); + cy.location('hash').should('include', '/create'); + }); }); }); @@ -534,6 +559,11 @@ describe('Clean up all test data', () => { }); }); +const moveToOsdDashboards = () => { + cy.visit(`${Cypress.env('opensearchDashboards')}/app/dashboards#/`); + cy.wait(delay * 3); +}; + const moveToEventsHome = () => { cy.visit(`${Cypress.env('opensearchDashboards')}/app/observability-logs#/`); cy.wait(6000); @@ -614,7 +644,8 @@ const eraseTestPanels = () => { eraseLegacyPanels(); eraseSavedObjectPaenls(); }; -const uuidRx = /[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}/; +const uuidRx = + /[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}/; const clickCreatePanelButton = () => cy.get('a[data-test-subj="customPanels__createNewPanels"]').click(); diff --git a/public/components/custom_panels/custom_panel_view_so.tsx b/public/components/custom_panels/custom_panel_view_so.tsx index 52b19ea1a3..7fa2beac08 100644 --- a/public/components/custom_panels/custom_panel_view_so.tsx +++ b/public/components/custom_panels/custom_panel_view_so.tsx @@ -289,7 +289,6 @@ export const CustomPanelViewSO = (props: CustomPanelViewProps) => { }, [panel]); const cancelEdit = () => { - console.log('cancelEdits'); dispatch(fetchPanel(panelId)); setIsEditing(false); }; diff --git a/public/components/trace_analytics/requests/dashboard_request_handler.ts b/public/components/trace_analytics/requests/dashboard_request_handler.ts index ac29cc9b2d..d25ad03fde 100644 --- a/public/components/trace_analytics/requests/dashboard_request_handler.ts +++ b/public/components/trace_analytics/requests/dashboard_request_handler.ts @@ -191,10 +191,7 @@ export const handleJaegerDashboardRequest = async ( return map; }) .catch((error) => { - console.log("error here") - console.error(error) - - setToast('hello') + console.error(error); }); await handleDslRequest(http, DSL, getJaegerDashboardQuery(), mode, true, setShowTimeoutToast) diff --git a/public/plugin.ts b/public/plugin.ts index 88991af928..bb21d79ae3 100644 --- a/public/plugin.ts +++ b/public/plugin.ts @@ -83,7 +83,6 @@ export class ObservabilityPlugin core: CoreSetup, setupDeps: SetupDependencies ): ObservabilitySetup { - console.log('core: ', core, ', setupDeps: ', setupDeps); uiSettingsService.init(core.uiSettings, core.notifications); const pplService = new PPLService(core.http); const qm = new QueryManager(); @@ -107,16 +106,16 @@ export class ObservabilityPlugin // if (window.location.pathname.includes('application_analytics')) { // window.location.assign(convertLegacyAppAnalyticsUrl(window.location)); // } - + const BASE_URL = core.http.basePath.prepend('/app/observability-dashboards#'); setupDeps.dashboard.registerDashboardProvider({ appId: 'observability-panel', savedObjectsType: 'observability-panel', savedObjectsName: 'Observability', - editUrlPathFn: (obj: SavedObject) => `/app/observability-dashboards#/${obj.id}/edit`, - viewUrlPathFn: (obj: SavedObject) => `/app/observability-dashboards#/${obj.id}`, + editUrlPathFn: (obj: SavedObject) => `${BASE_URL}/${obj.id}/edit`, + viewUrlPathFn: (obj: SavedObject) => `${BASE_URL}/${obj.id}`, createLinkText: 'Observability Dashboard', createSortText: 'Observability Dashboard', - createUrl: '/app/observability-dashboards#/create', + createUrl: `${BASE_URL}/create`, }); const OBSERVABILITY_APP_CATEGORIES: Record = Object.freeze({ @@ -130,7 +129,6 @@ export class ObservabilityPlugin }); const appMountWithStartPage = (startPage: string) => async (params: AppMountParameters) => { - console.log('start page: ', startPage); const { Observability } = await import('./components/index'); const [coreStart, depsStart] = await core.getStartServices(); const dslService = new DSLService(coreStart.http); diff --git a/public/services/saved_objects/saved_object_savers/ppl/save_as_new_query.ts b/public/services/saved_objects/saved_object_savers/ppl/save_as_new_query.ts index b1ada63e4c..fa7b1c7034 100644 --- a/public/services/saved_objects/saved_object_savers/ppl/save_as_new_query.ts +++ b/public/services/saved_objects/saved_object_savers/ppl/save_as_new_query.ts @@ -24,7 +24,6 @@ export class SaveAsNewQuery extends SavedQuerySaver { const { batch, dispatch, changeQuery, updateTabName } = this.dispatchers; const { tabId, history, notifications, showPermissionErrorToast } = this.saveContext; const { name } = this.saveParams; - console.log('this.saveParams: ', this.saveParams); this.saveClient .create({ ...this.saveParams }) .then((res: any) => {