Skip to content

Commit f94c21e

Browse files
kavillajoshuali925
andauthored
[Dashboard listing] update edit url and view url (opensearch-project#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: opensearch-project/OpenSearch-Dashboards#3922 --------- Signed-off-by: Kawika Avilla <kavilla414@gmail.com> Signed-off-by: Joshua Li <joshuali925@gmail.com> Co-authored-by: Joshua Li <joshuali925@gmail.com>
1 parent a4cb6d1 commit f94c21e

File tree

5 files changed

+52
-28
lines changed

5 files changed

+52
-28
lines changed

.cypress/integration/3_panels.spec.ts

+47-16
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,16 @@
55

66
/// <reference types="cypress" />
77

8+
import { suppressResizeObserverIssue } from '../utils/constants';
89
import {
910
delay,
10-
TEST_PANEL,
11-
PPL_VISUALIZATIONS,
12-
PPL_VISUALIZATIONS_NAMES,
1311
NEW_VISUALIZATION_NAME,
1412
PPL_FILTER,
15-
SAMPLE_PANEL,
16-
SAMPLE_VISUALIZATIONS_NAMES,
13+
PPL_VISUALIZATIONS,
14+
PPL_VISUALIZATIONS_NAMES,
15+
TEST_PANEL,
1716
} from '../utils/panel_constants';
1817

19-
import { suppressResizeObserverIssue } from '../utils/constants';
20-
2118
describe('Adding sample data and visualization', () => {
2219
it('Adds sample flights data for visualization paragraph', () => {
2320
cy.visit(`${Cypress.env('opensearchDashboards')}/app/home#/tutorial_directory/sampleData`);
@@ -195,6 +192,34 @@ describe('Testing panels table', () => {
195192
cy.get('button[data-test-subj="popoverModal__deleteButton"]').click();
196193
cy.get('h2[data-test-subj="customPanels__noPanelsHome"]').should('exist');
197194
});
195+
196+
it('Redirects to observability dashboard from OSD dashboards', () => {
197+
moveToOsdDashboards();
198+
cy.location('pathname').should('eq', '/app/dashboards');
199+
cy.get('[data-test-subj="dashboardListingTitleLink-Test-Panel"]').click();
200+
cy.location('pathname').should('eq', '/app/observability-dashboards');
201+
});
202+
203+
it('Redirects to observability dashboard from OSD dashboards with edit', () => {
204+
moveToOsdDashboards();
205+
cy.location('pathname').should('eq', '/app/dashboards');
206+
cy.get('[data-test-subj="dashboardListingTitleLink-Test-Panel"]')
207+
.closest('tr')
208+
.get('span.euiToolTipAnchor > button.euiButtonIcon')
209+
.eq(0)
210+
.click();
211+
cy.location('pathname').should('eq', '/app/observability-dashboards');
212+
cy.location('hash').should('include', '/edit');
213+
});
214+
215+
it('Redirects to observability dashboard from OSD dashboards with create', () => {
216+
moveToOsdDashboards();
217+
cy.location('pathname').should('eq', '/app/dashboards');
218+
cy.get('div#createMenuPopover').click();
219+
cy.get('[data-test-subj="contextMenuItem-observability-panel"]').click();
220+
cy.location('pathname').should('eq', '/app/observability-dashboards');
221+
cy.location('hash').should('include', '/create');
222+
});
198223
});
199224

200225
it('Searches existing panel', () => {
@@ -274,7 +299,7 @@ describe('Testing a panel', () => {
274299

275300
cy.get(`input.euiFieldText[value="${TEST_PANEL} (copy)"]`)
276301
.focus()
277-
.clear({force: true})
302+
.clear({ force: true })
278303
.focus()
279304
.type('Renamed Panel', {
280305
delay: 200,
@@ -347,9 +372,9 @@ describe('Testing a panel', () => {
347372

348373
cy.get('h5[data-test-subj="visualizationHeader"]')
349374
.contains(PPL_VISUALIZATIONS_NAMES[1])
350-
.trigger('mousedown', {which: 1})
351-
.trigger('mousemove', {clientX: 1100, clientY: 0})
352-
.trigger('mouseup', {force: true});
375+
.trigger('mousedown', { which: 1 })
376+
.trigger('mousemove', { clientX: 1100, clientY: 0 })
377+
.trigger('mouseup', { force: true });
353378

354379
cy.get('button[data-test-subj="savePanelButton"]').click();
355380
cy.wait(delay * 3);
@@ -364,9 +389,9 @@ describe('Testing a panel', () => {
364389

365390
cy.get('.react-resizable-handle')
366391
.eq(1)
367-
.trigger('mousedown', {which: 1})
368-
.trigger('mousemove', {clientX: 2000, clientY: 800})
369-
.trigger('mouseup', {force: true});
392+
.trigger('mousedown', { which: 1 })
393+
.trigger('mousemove', { clientX: 2000, clientY: 800 })
394+
.trigger('mouseup', { force: true });
370395

371396
cy.get('button[data-test-subj="savePanelButton"]').click();
372397
cy.wait(delay * 3);
@@ -481,7 +506,7 @@ describe('Testing a panel', () => {
481506
cy.get('[data-test-subj="eventExplorer__saveManagementPopover"]').trigger('mouseover').click();
482507
cy.wait(1000);
483508
cy.get('[data-test-subj="eventExplorer__querySaveName"]')
484-
.clear({force: true})
509+
.clear({ force: true })
485510
.type(NEW_VISUALIZATION_NAME, {
486511
delay: 200,
487512
});
@@ -535,6 +560,11 @@ describe('Clean up all test data', () => {
535560
});
536561
});
537562

563+
const moveToOsdDashboards = () => {
564+
cy.visit(`${Cypress.env('opensearchDashboards')}/app/dashboards#/`);
565+
cy.wait(delay * 3);
566+
};
567+
538568
const moveToEventsHome = () => {
539569
cy.visit(`${Cypress.env('opensearchDashboards')}/app/observability-logs#/`);
540570
cy.wait(delay * 3);
@@ -615,7 +645,8 @@ const eraseTestPanels = () => {
615645
eraseLegacyPanels();
616646
eraseSavedObjectPaenls();
617647
};
618-
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}/;
648+
const uuidRx =
649+
/[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}/;
619650

620651
const clickCreatePanelButton = () =>
621652
cy.get('a[data-test-subj="customPanels__createNewPanels"]').click();

public/components/custom_panels/custom_panel_view_so.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ export const CustomPanelViewSO = (props: CustomPanelViewProps) => {
255255
}, [panel]);
256256

257257
const cancelEdit = () => {
258-
console.log('cancelEdits');
259258
dispatch(fetchPanel(panelId));
260259
setIsEditing(false);
261260
};

public/components/trace_analytics/requests/dashboard_request_handler.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,7 @@ export const handleJaegerDashboardRequest = async (
191191
return map;
192192
})
193193
.catch((error) => {
194-
console.log("error here")
195-
console.error(error)
196-
197-
setToast('hello')
194+
console.error(error);
198195
});
199196

200197
await handleDslRequest(http, DSL, getJaegerDashboardQuery(), mode, true, setShowTimeoutToast)

public/plugin.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ export class ObservabilityPlugin
8383
core: CoreSetup<AppPluginStartDependencies>,
8484
setupDeps: SetupDependencies
8585
): ObservabilitySetup {
86-
console.log('core: ', core, ', setupDeps: ', setupDeps);
8786
uiSettingsService.init(core.uiSettings, core.notifications);
8887
const pplService = new PPLService(core.http);
8988
const qm = new QueryManager();
@@ -107,16 +106,16 @@ export class ObservabilityPlugin
107106
// if (window.location.pathname.includes('application_analytics')) {
108107
// window.location.assign(convertLegacyAppAnalyticsUrl(window.location));
109108
// }
110-
109+
const BASE_URL = core.http.basePath.prepend('/app/observability-dashboards#');
111110
setupDeps.dashboard.registerDashboardProvider({
112111
appId: 'observability-panel',
113112
savedObjectsType: 'observability-panel',
114113
savedObjectsName: 'Observability',
115-
editUrlPathFn: (obj: SavedObject) => `/app/observability-dashboards#/${obj.id}/edit`,
116-
viewUrlPathFn: (obj: SavedObject) => `/app/observability-dashboards#/${obj.id}`,
114+
editUrlPathFn: (obj: SavedObject) => `${BASE_URL}/${obj.id}/edit`,
115+
viewUrlPathFn: (obj: SavedObject) => `${BASE_URL}/${obj.id}`,
117116
createLinkText: 'Observability Dashboard',
118117
createSortText: 'Observability Dashboard',
119-
createUrl: '/app/observability-dashboards#/create',
118+
createUrl: `${BASE_URL}/create`,
120119
});
121120

122121
const OBSERVABILITY_APP_CATEGORIES: Record<string, AppCategory> = Object.freeze({
@@ -130,7 +129,6 @@ export class ObservabilityPlugin
130129
});
131130

132131
const appMountWithStartPage = (startPage: string) => async (params: AppMountParameters) => {
133-
console.log('start page: ', startPage);
134132
const { Observability } = await import('./components/index');
135133
const [coreStart, depsStart] = await core.getStartServices();
136134
const dslService = new DSLService(coreStart.http);

public/services/saved_objects/saved_object_savers/ppl/save_as_new_query.ts

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ export class SaveAsNewQuery extends SavedQuerySaver {
2424
const { batch, dispatch, changeQuery, updateTabName } = this.dispatchers;
2525
const { tabId, history, notifications, showPermissionErrorToast } = this.saveContext;
2626
const { name } = this.saveParams;
27-
console.log('this.saveParams: ', this.saveParams);
2827
this.saveClient
2928
.create({ ...this.saveParams })
3029
.then((res: any) => {

0 commit comments

Comments
 (0)