diff --git a/changelogs/fragments/7749.yml b/changelogs/fragments/7749.yml new file mode 100644 index 000000000000..acc4198d0d4a --- /dev/null +++ b/changelogs/fragments/7749.yml @@ -0,0 +1,2 @@ +fix: +- Breadcrumb is not correct when clicking inspect / edit in Assets page ([#7749](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7749)) \ No newline at end of file diff --git a/src/plugins/data_source_management/public/plugin.ts b/src/plugins/data_source_management/public/plugin.ts index 4caf0fe755d1..b415c7744a7c 100644 --- a/src/plugins/data_source_management/public/plugin.ts +++ b/src/plugins/data_source_management/public/plugin.ts @@ -146,17 +146,9 @@ export class DataSourceManagementPlugin }, }); - /** - * The data sources features in observability has the same name as `DSM_APP_ID` - * Add a suffix to avoid duplication - * - * The id is used in src/plugins/workspace/public/plugin.ts and please change that accordingly if you change the id here. - */ - const DSM_APP_ID_FOR_STANDARD_APPLICATION = `${DSM_APP_ID}_core`; - if (core.chrome.navGroup.getNavGroupEnabled()) { core.application.register({ - id: DSM_APP_ID_FOR_STANDARD_APPLICATION, + id: DSM_APP_ID, title: PLUGIN_NAME, order: 100, description: i18n.translate('data_source_management.description', { @@ -184,7 +176,7 @@ export class DataSourceManagementPlugin core.chrome.navGroup.addNavLinksToGroup(DEFAULT_NAV_GROUPS.dataAdministration, [ { - id: DSM_APP_ID_FOR_STANDARD_APPLICATION, + id: DSM_APP_ID, category: DEFAULT_APP_CATEGORIES.manageData, order: 100, }, diff --git a/src/plugins/saved_objects_management/public/management_section/objects_table/components/relationships.test.tsx b/src/plugins/saved_objects_management/public/management_section/objects_table/components/relationships.test.tsx index 1f21e5990c74..8389941c56bf 100644 --- a/src/plugins/saved_objects_management/public/management_section/objects_table/components/relationships.test.tsx +++ b/src/plugins/saved_objects_management/public/management_section/objects_table/components/relationships.test.tsx @@ -32,6 +32,7 @@ import React from 'react'; import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers'; import { httpServiceMock } from '../../../../../../core/public/mocks'; import { Relationships, RelationshipsProps } from './relationships'; +import { render } from '@testing-library/react'; jest.mock('../../../lib/fetch_export_by_type_and_search', () => ({ fetchExportByTypeAndSearch: jest.fn(), @@ -702,4 +703,51 @@ describe('Relationships from legacy app', () => { expect(props.getRelationships).toHaveBeenCalled(); expect(component).toMatchSnapshot(); }); + + it('should replace the url to standard application when new nav group is enabled', async () => { + const props: RelationshipsProps = { + goInspectObject: () => {}, + canGoInApp: () => true, + basePath: httpServiceMock.createSetupContract().basePath, + getRelationships: jest.fn().mockImplementation(() => [ + { + type: 'index-patterns', + id: '1', + relationship: 'child', + meta: { + editUrl: '/management/kibana/objects/savedVisualizations/1', + icon: 'visualizeApp', + inAppUrl: { + path: '/app/management/opensearch-dashboards/indexPatterns#/edit/1', + uiCapabilitiesPath: 'visualize.show', + }, + title: 'My Visualization Title 1', + }, + }, + ]), + savedObject: { + id: '1', + type: 'dashboard', + attributes: {}, + references: [], + meta: { + title: 'MyDashboard', + icon: 'dashboardApp', + editUrl: '/management/kibana/objects/savedDashboards/1', + inAppUrl: { + path: '/dashboard/1', + uiCapabilitiesPath: 'dashboard.show', + }, + }, + }, + close: jest.fn(), + useUpdatedUX: true, + }; + + const { getByTestId, findByText } = render(); + + await findByText('Type of the saved object'); + + expect(getByTestId('relationshipsTitle')).toHaveAttribute('href', '/app/indexPatterns#/edit/1'); + }); }); diff --git a/src/plugins/saved_objects_management/public/management_section/objects_table/components/relationships.tsx b/src/plugins/saved_objects_management/public/management_section/objects_table/components/relationships.tsx index 480cb9758c12..fca4ec1505f7 100644 --- a/src/plugins/saved_objects_management/public/management_section/objects_table/components/relationships.tsx +++ b/src/plugins/saved_objects_management/public/management_section/objects_table/components/relationships.tsx @@ -56,6 +56,7 @@ export interface RelationshipsProps { close: () => void; goInspectObject: (obj: SavedObjectWithMetadata) => void; canGoInApp: (obj: SavedObjectWithMetadata) => boolean; + useUpdatedUX?: boolean; } export interface RelationshipsState { @@ -205,6 +206,10 @@ export class Relationships extends Component { const { path = '' } = object.meta.inAppUrl || {}; const canGoInApp = this.props.canGoInApp(object); + let finalPath = path; + if (this.props.useUpdatedUX && finalPath) { + finalPath = finalPath.replace(/^\/app\/management\/opensearch-dashboards/, '/app'); + } if (!canGoInApp) { return ( @@ -213,7 +218,7 @@ export class Relationships extends Component + {title || getDefaultTitle(object)} ); diff --git a/src/plugins/saved_objects_management/public/management_section/objects_table/components/table.test.tsx b/src/plugins/saved_objects_management/public/management_section/objects_table/components/table.test.tsx index ddf50e68c25a..cc0da7ea775d 100644 --- a/src/plugins/saved_objects_management/public/management_section/objects_table/components/table.test.tsx +++ b/src/plugins/saved_objects_management/public/management_section/objects_table/components/table.test.tsx @@ -38,6 +38,7 @@ import { columnServiceMock } from '../../../services/column_service.mock'; import { SavedObjectsManagementAction } from '../../..'; import { Table, TableProps } from './table'; import { WorkspaceAttribute } from 'opensearch-dashboards/public'; +import { render } from '@testing-library/react'; const defaultProps: TableProps = { basePath: httpServiceMock.createSetupContract().basePath, @@ -257,4 +258,36 @@ describe('Table', () => { duplicateAction.onClick(); expect(onDuplicateSingle).toHaveBeenCalled(); }); + + it('should replace legacy path to standard application path when useUpdatedUX is true', () => { + const showDuplicate = true; + const customizedProps = { + ...defaultProps, + showDuplicate, + useUpdatedUX: true, + items: [ + { + id: '1', + type: 'index-pattern', + attributes: {}, + references: [], + meta: { + title: `MyIndexPattern*`, + icon: 'indexPatternApp', + editUrl: '#/management/opensearch-dashboards/indexPatterns/patterns/1', + inAppUrl: { + path: '/app/management/opensearch-dashboards/indexPatterns/patterns/1', + uiCapabilitiesPath: 'management.opensearchDashboards.indexPatterns', + }, + }, + }, + ], + }; + const { getByTestId } = render(); + expect( + getByTestId('savedObjectsTableRowTitle').querySelector( + '[href="/app/indexPatterns/patterns/1"]' + ) + ).toBeInTheDocument(); + }); }); diff --git a/src/plugins/saved_objects_management/public/management_section/objects_table/components/table.tsx b/src/plugins/saved_objects_management/public/management_section/objects_table/components/table.tsx index fdfd2cea2c28..6642dd61bd0f 100644 --- a/src/plugins/saved_objects_management/public/management_section/objects_table/components/table.tsx +++ b/src/plugins/saved_objects_management/public/management_section/objects_table/components/table.tsx @@ -250,15 +250,19 @@ export class Table extends PureComponent { if (!canGoInApp) { return {title || getDefaultTitle(object)}; } - let inAppUrl = basePath.prepend(path); + let finalPath = path; + if (this.props.useUpdatedUX && finalPath) { + finalPath = finalPath.replace(/^\/app\/management\/opensearch-dashboards/, '/app'); + } + let inAppUrl = basePath.prepend(finalPath); if (object.workspaces?.length) { if (currentWorkspaceId) { - inAppUrl = formatUrlWithWorkspaceId(path, currentWorkspaceId, basePath); + inAppUrl = formatUrlWithWorkspaceId(finalPath, currentWorkspaceId, basePath); } else { // find first workspace user have permission const workspaceId = object.workspaces.find((wsId) => visibleWsIds.includes(wsId)); if (workspaceId) { - inAppUrl = formatUrlWithWorkspaceId(path, workspaceId, basePath); + inAppUrl = formatUrlWithWorkspaceId(finalPath, workspaceId, basePath); } } } diff --git a/src/plugins/saved_objects_management/public/management_section/objects_table/saved_objects_table.tsx b/src/plugins/saved_objects_management/public/management_section/objects_table/saved_objects_table.tsx index 348e20fb257d..191720256024 100644 --- a/src/plugins/saved_objects_management/public/management_section/objects_table/saved_objects_table.tsx +++ b/src/plugins/saved_objects_management/public/management_section/objects_table/saved_objects_table.tsx @@ -832,6 +832,7 @@ export class SavedObjectsTable extends Component ); } diff --git a/src/plugins/saved_objects_management/public/management_section/saved_objects_table_page.tsx b/src/plugins/saved_objects_management/public/management_section/saved_objects_table_page.tsx index f526f7f6c751..e83ae7cab3dc 100644 --- a/src/plugins/saved_objects_management/public/management_section/saved_objects_table_page.tsx +++ b/src/plugins/saved_objects_management/public/management_section/saved_objects_table_page.tsx @@ -109,9 +109,13 @@ const SavedObjectsTablePage = ({ perPageConfig={itemsPerPage} goInspectObject={(savedObject) => { const { editUrl } = savedObject.meta; - if (editUrl) { + let finalEditUrl = editUrl; + if (useUpdatedUX && finalEditUrl) { + finalEditUrl = finalEditUrl.replace(/^\/management\/opensearch-dashboards/, ''); + } + if (finalEditUrl) { return coreStart.application.navigateToUrl( - coreStart.http.basePath.prepend(`/app${editUrl}`) + coreStart.http.basePath.prepend(`/app${finalEditUrl}`) ); } }} diff --git a/src/plugins/workspace/public/services/use_case_service.ts b/src/plugins/workspace/public/services/use_case_service.ts index ec0e973b6dac..ae127f08a5f2 100644 --- a/src/plugins/workspace/public/services/use_case_service.ts +++ b/src/plugins/workspace/public/services/use_case_service.ts @@ -61,7 +61,7 @@ export class UseCaseService { if (navGroupInfo) { setupDeps.chrome.navGroup.addNavLinksToGroup(navGroupInfo, [ { - id: 'dataSources_core', + id: 'dataSources', category: DEFAULT_APP_CATEGORIES.manageWorkspace, order: 100, },