Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[navigation-next]fix: breadcrumb issue found in data source management and other similar cases. #7401

Merged
2 changes: 2 additions & 0 deletions changelogs/fragments/7401.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- Breadcrumb issue in the new application. ([#7401](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7401))
SuZhou-Joe marked this conversation as resolved.
Show resolved Hide resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export function CollapsibleNavGroupEnabled({
basePath,
id,
isLocked,
isNavOpen: isNavOpenProps,
isNavOpen,
storage = window.localStorage,
onIsLockedUpdate,
closeNav,
Expand Down Expand Up @@ -263,18 +263,6 @@ export function CollapsibleNavGroupEnabled({
return fulfillRegistrationLinksToChromeNavLinks(navLinksForAll, navLinks);
}, [navLinks, navGroupsMap, currentNavGroup]);

const isNavOpen = useMemo(() => {
// For now, only home page need to always collapse left navigation
// when workspace is enabled.
// If there are more pages need to collapse left navigation in the future
// need to come up with a mechanism to register.
if (capabilities.workspaces.enabled && appId === 'home') {
return false;
}

return isNavOpenProps;
}, [isNavOpenProps, capabilities.workspaces.enabled, appId]);

const width = useMemo(() => {
if (!isNavOpen) {
return 50;
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/advanced_settings/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import { AdvancedSettingsSetup, AdvancedSettingsStart, AdvancedSettingsPluginSetup } from './types';
import { setupTopNavThemeButton } from './register_nav_control';
import { DEFAULT_NAV_GROUPS, AppNavLinkStatus, WorkspaceAvailability } from '../../../core/public';
import { getScopedBreadcrumbs } from '../../opensearch_dashboards_react/public';

const component = new ComponentRegistry();

Expand Down Expand Up @@ -81,7 +82,8 @@
{
...params,
basePath: core.http.basePath.get(),
setBreadcrumbs: coreStart.chrome.setBreadcrumbs,
setBreadcrumbs: (breadCrumbs) =>
coreStart.chrome.setBreadcrumbs(getScopedBreadcrumbs(breadCrumbs, params.history)),

Check warning on line 86 in src/plugins/advanced_settings/public/plugin.ts

View check run for this annotation

Codecov / codecov/patch

src/plugins/advanced_settings/public/plugin.ts#L86

Added line #L86 was not covered by tests
wrapInPage: true,
},
component.start
Expand Down
14 changes: 8 additions & 6 deletions src/plugins/data_source_management/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import { AccelerationDetailsFlyout } from './components/direct_query_data_sources_components/acceleration_management/acceleration_details_flyout';
import { CreateAcceleration } from './components/direct_query_data_sources_components/acceleration_creation/create/create_acceleration';
import { AssociatedObjectsDetailsFlyout } from './components/direct_query_data_sources_components/associated_object_management/associated_objects_details_flyout';
import { getScopedBreadcrumbs } from '../../opensearch_dashboards_react/public';

export const [
getRenderAccelerationDetailsFlyout,
Expand Down Expand Up @@ -141,11 +142,6 @@
},
});

// when the feature flag is disabled, we don't need to register any of the mds components
if (!this.featureFlagStatus) {
return undefined;
}

/**
* The data sources features in observability has the same name as `DSM_APP_ID`
* Add a suffix to avoid duplication
Expand All @@ -166,7 +162,8 @@
{
...params,
basePath: core.http.basePath.get(),
setBreadcrumbs: coreStart.chrome.setBreadcrumbs,
setBreadcrumbs: (breadCrumbs) =>
coreStart.chrome.setBreadcrumbs(getScopedBreadcrumbs(breadCrumbs, params.history)),

Check warning on line 166 in src/plugins/data_source_management/public/plugin.ts

View check run for this annotation

Codecov / codecov/patch

src/plugins/data_source_management/public/plugin.ts#L166

Added line #L166 was not covered by tests
wrapInPage: true,
},
this.authMethodsRegistry,
Expand Down Expand Up @@ -224,6 +221,11 @@
},
]);

// when the feature flag is disabled, we don't need to register any of the mds components
if (!this.featureFlagStatus) {
return undefined;
}

const registerAuthenticationMethod = (authMethod: AuthenticationMethod) => {
if (this.started) {
throw new Error(
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/index_pattern_management/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@

import { ManagementSetup } from '../../management/public';
import { DEFAULT_NAV_GROUPS, AppStatus, DEFAULT_APP_CATEGORIES } from '../../../core/public';
import { getScopedBreadcrumbs } from '../../opensearch_dashboards_react/public';

export interface IndexPatternManagementSetupDependencies {
management: ManagementSetup;
Expand Down Expand Up @@ -148,7 +149,8 @@
{
...params,
basePath: core.http.basePath.get(),
setBreadcrumbs: coreStart.chrome.setBreadcrumbs,
setBreadcrumbs: (breadCrumbs) =>
coreStart.chrome.setBreadcrumbs(getScopedBreadcrumbs(breadCrumbs, params.history)),

Check warning on line 153 in src/plugins/index_pattern_management/public/plugin.ts

View check run for this annotation

Codecov / codecov/patch

src/plugins/index_pattern_management/public/plugin.ts#L153

Added line #L153 was not covered by tests
wrapInPage: true,
},
() => this.indexPatternManagementService.environmentService.getEnvironment().ml(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@
* under the License.
*/

export { reactRouterNavigate, reactRouterOnClickHandler } from './react_router_navigate';
export {
reactRouterNavigate,
reactRouterOnClickHandler,
getScopedBreadcrumbs,
} from './react_router_navigate';
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { scopedHistoryMock } from '../../../../core/public/mocks';
import { getScopedBreadcrumbs } from './react_router_navigate';

describe('getScopedBreadcrumbs', () => {
it('should return scoped bread crumbs when given an array', () => {
const history = scopedHistoryMock.create({
pathname: '/base',
});
history.createHref.mockImplementation((location) => `/base${location.pathname}`);
const scopedBreadcrumbs = getScopedBreadcrumbs(
[
{
text: 'Home',
href: '/',
},
{
text: 'Dashboard',
href: '/dashboard',
},
],
history
);
expect(scopedBreadcrumbs[0]).toEqual(
expect.objectContaining({
href: '/base/',
text: 'Home',
})
);
expect(scopedBreadcrumbs[1]).toEqual(
expect.objectContaining({
href: '/base/dashboard',
text: 'Dashboard',
})
);
});
});
Loading
Loading