diff --git a/src/core/public/chrome/nav_links/nav_links_service.ts b/src/core/public/chrome/nav_links/nav_links_service.ts index 3094cdccd7c4..b6ef2e6e771e 100644 --- a/src/core/public/chrome/nav_links/nav_links_service.ts +++ b/src/core/public/chrome/nav_links/nav_links_service.ts @@ -151,8 +151,8 @@ export class NavLinksService { return linkUpdaters.reduce((links, updater) => updater(links), appLinks); }) ) - .subscribe((navlinks) => { - navLinks$.next(navlinks); + .subscribe((navLinks) => { + navLinks$.next(navLinks); }); const forceAppSwitcherNavigation$ = new BehaviorSubject(false); diff --git a/src/core/public/chrome/ui/header/collapsible_nav.tsx b/src/core/public/chrome/ui/header/collapsible_nav.tsx index b1c6b918f87e..9a7667e365f1 100644 --- a/src/core/public/chrome/ui/header/collapsible_nav.tsx +++ b/src/core/public/chrome/ui/header/collapsible_nav.tsx @@ -270,42 +270,6 @@ export function CollapsibleNav({ )} - {/* Alerts and Favorites */} - {/* ( - <> - - - -

- {i18n.translate('core.ui.EmptyFavoriteList', { - defaultMessage: 'No Favorites', - })} -

-
- -

- {i18n.translate('core.ui.SeeMoreFavorite', { - defaultMessage: 'SEE MORE', - })} -

-
-
- - ) */} - {/* merged NavLinks */} {mergedNavLinks.map((item, i) => { if (typeof item === 'string') { diff --git a/src/plugins/workspace/common/constants.ts b/src/plugins/workspace/common/constants.ts index 878a0ca9441e..ed48d8b11ec4 100644 --- a/src/plugins/workspace/common/constants.ts +++ b/src/plugins/workspace/common/constants.ts @@ -6,9 +6,10 @@ import { i18n } from '@osd/i18n'; import { AppCategory } from '../../../core/types'; -export const WORKSPACE_APP_ID = 'workspace'; -export const WORKSPACE_APP_NAME = 'Workspace'; - +export const WORKSPACE_CREATE_APP_ID = 'workspace_create'; +export const WORKSPACE_LIST_APP_ID = 'workspace_list'; +export const WORKSPACE_UPDATE_APP_ID = 'workspace_update'; +export const WORKSPACE_OVERVIEW_APP_ID = 'workspace_overview'; export const PATHS = { create: '/create', overview: '/overview', diff --git a/src/plugins/workspace/public/application.tsx b/src/plugins/workspace/public/application.tsx index 6715450ca693..9772390f7118 100644 --- a/src/plugins/workspace/public/application.tsx +++ b/src/plugins/workspace/public/application.tsx @@ -5,22 +5,68 @@ import React from 'react'; import ReactDOM from 'react-dom'; -import { Router } from 'react-router-dom'; - import { AppMountParameters, CoreStart } from '../../../core/public'; -import { OpenSearchDashboardsContextProvider } from '../../../plugins/opensearch_dashboards_react/public'; -import { WorkspaceApp } from './components/workspace_app'; +import { OpenSearchDashboardsContextProvider } from '../../opensearch_dashboards_react/public'; +import { WorkspaceListApp } from './components/workspace_list_app'; +import { WorkspaceCreatorApp } from './components/workspace_creator_app'; +import { WorkspaceUpdaterApp } from './components/workspace_updater_app'; +import { WorkspaceOverviewApp } from './components/workspace_overview_app'; + +export const renderListApp = ( + { element, history, appBasePath }: AppMountParameters, + services: CoreStart +) => { + ReactDOM.render( + + + , + element + ); + + return () => { + ReactDOM.unmountComponentAtNode(element); + }; +}; +export const renderCreatorApp = ( + { element, history, appBasePath }: AppMountParameters, + services: CoreStart +) => { + ReactDOM.render( + + + , + element + ); + + return () => { + ReactDOM.unmountComponentAtNode(element); + }; +}; + +export const renderUpdateApp = ( + { element, history, appBasePath }: AppMountParameters, + services: CoreStart +) => { + ReactDOM.render( + + + , + element + ); + + return () => { + ReactDOM.unmountComponentAtNode(element); + }; +}; -export const renderApp = ( +export const renderOverviewApp = ( { element, history, appBasePath }: AppMountParameters, services: CoreStart ) => { ReactDOM.render( - - - - - , + + + , element ); diff --git a/src/plugins/workspace/public/components/utils/breadcrumbs.test.ts b/src/plugins/workspace/public/components/utils/breadcrumbs.test.ts deleted file mode 100644 index 229fcde96055..000000000000 --- a/src/plugins/workspace/public/components/utils/breadcrumbs.test.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { createBreadcrumbsFromPath } from './breadcrumbs'; - -describe('breadcrumbs utils', () => { - const ROUTES = [ - { - path: '/create', - Component: jest.fn(), - label: 'Create', - }, - { - path: '/manage', - Component: jest.fn(), - label: 'Manage Workspaces', - }, - { - path: '/manage/access', - Component: jest.fn(), - label: 'Manage Access', - }, - ]; - - it('should create breadcrumbs with matched route', () => { - const breadcrumbs = createBreadcrumbsFromPath('/create', ROUTES, '/'); - expect(breadcrumbs).toEqual([{ href: '/', text: 'Workspace' }, { text: 'Create' }]); - }); - - it('should create breadcrumbs with only root route if path did not match any route', () => { - const breadcrumbs = createBreadcrumbsFromPath('/unknown', ROUTES, '/'); - expect(breadcrumbs).toEqual([{ href: '/', text: 'Workspace' }]); - }); - - it('should create breadcrumbs with all matched routes', () => { - const breadcrumbs = createBreadcrumbsFromPath('/manage/access', ROUTES, '/'); - expect(breadcrumbs).toEqual([ - { href: '/', text: 'Workspace' }, - { href: '/manage', text: 'Manage Workspaces' }, - { text: 'Manage Access' }, - ]); - }); - - it('should create breadcrumbs with only matched routes', () => { - const breadcrumbs = createBreadcrumbsFromPath('/manage/not-matched', ROUTES, '/'); - expect(breadcrumbs).toEqual([{ href: '/', text: 'Workspace' }, { text: 'Manage Workspaces' }]); - }); -}); diff --git a/src/plugins/workspace/public/components/utils/breadcrumbs.ts b/src/plugins/workspace/public/components/utils/breadcrumbs.ts deleted file mode 100644 index d6d302a9c6fc..000000000000 --- a/src/plugins/workspace/public/components/utils/breadcrumbs.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { matchPath } from 'react-router-dom'; - -import { RouteConfig } from '../routes'; -import { ChromeBreadcrumb } from '../../../../../core/public'; -import { WORKSPACE_APP_NAME } from '../../../common/constants'; -import { join } from './path'; - -export const createBreadcrumbsFromPath = ( - pathname: string, - routeConfig: RouteConfig[], - appBasePath: string -): ChromeBreadcrumb[] => { - const breadcrumbs: ChromeBreadcrumb[] = []; - while (pathname !== '/') { - const matchedRoute = routeConfig.find((route) => - matchPath(pathname, { path: route.path, exact: true }) - ); - if (matchedRoute) { - if (breadcrumbs.length === 0) { - breadcrumbs.unshift({ text: matchedRoute.label }); - } else { - breadcrumbs.unshift({ - text: matchedRoute.label, - href: join(appBasePath, matchedRoute.path), - }); - } - } - const pathArr = pathname.split('/'); - pathArr.pop(); - pathname = pathArr.join('/') ? pathArr.join('/') : '/'; - } - breadcrumbs.unshift({ text: WORKSPACE_APP_NAME, href: appBasePath }); - return breadcrumbs; -}; diff --git a/src/plugins/workspace/public/components/utils/workspace.ts b/src/plugins/workspace/public/components/utils/workspace.ts index 7ad9a43bf72c..fa38e29fdc61 100644 --- a/src/plugins/workspace/public/components/utils/workspace.ts +++ b/src/plugins/workspace/public/components/utils/workspace.ts @@ -3,15 +3,14 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { WORKSPACE_APP_ID, PATHS } from '../../../common/constants'; +import { WORKSPACE_OVERVIEW_APP_ID } from '../../../common/constants'; import { CoreStart } from '../../../../../core/public'; type Core = Pick; export const switchWorkspace = ({ workspaces, application }: Core, id: string) => { const newUrl = workspaces?.formatUrlWithWorkspaceId( - application.getUrlForApp(WORKSPACE_APP_ID, { - path: PATHS.update, + application.getUrlForApp(WORKSPACE_OVERVIEW_APP_ID, { absolute: true, }), id diff --git a/src/plugins/workspace/public/components/workspace_app.tsx b/src/plugins/workspace/public/components/workspace_app.tsx deleted file mode 100644 index ec31f511da96..000000000000 --- a/src/plugins/workspace/public/components/workspace_app.tsx +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import React, { useEffect } from 'react'; -import { I18nProvider } from '@osd/i18n/react'; -import { Route, Switch, Redirect, useLocation } from 'react-router-dom'; -import { ROUTES } from './routes'; -import { useOpenSearchDashboards } from '../../../opensearch_dashboards_react/public'; -import { createBreadcrumbsFromPath } from './utils/breadcrumbs'; -import { PATHS } from '../../common/constants'; - -export const WorkspaceApp = ({ appBasePath }: { appBasePath: string }) => { - const { - services: { chrome }, - } = useOpenSearchDashboards(); - const location = useLocation(); - - /** - * map the current pathname to breadcrumbs - */ - useEffect(() => { - const breadcrumbs = createBreadcrumbsFromPath(location.pathname, ROUTES, appBasePath); - chrome?.setBreadcrumbs(breadcrumbs); - }, [appBasePath, location.pathname, chrome]); - - return ( - - - {ROUTES.map(({ path, Component, exact }) => ( - } exact={exact ?? false} /> - ))} - - - - ); -}; diff --git a/src/plugins/workspace/public/components/workspace_creator/workspace_creator.tsx b/src/plugins/workspace/public/components/workspace_creator/workspace_creator.tsx index bbea2d2aa0a2..f2bc86c9f4cf 100644 --- a/src/plugins/workspace/public/components/workspace_creator/workspace_creator.tsx +++ b/src/plugins/workspace/public/components/workspace_creator/workspace_creator.tsx @@ -10,7 +10,7 @@ import { i18n } from '@osd/i18n'; import { useOpenSearchDashboards } from '../../../../../plugins/opensearch_dashboards_react/public'; import { WorkspaceForm, WorkspaceFormData } from './workspace_form'; -import { PATHS, WORKSPACE_APP_ID, WORKSPACE_OP_TYPE_CREATE } from '../../../common/constants'; +import { WORKSPACE_OVERVIEW_APP_ID, WORKSPACE_OP_TYPE_CREATE } from '../../../common/constants'; export const WorkspaceCreator = () => { const { @@ -39,8 +39,7 @@ export const WorkspaceCreator = () => { }); if (application && workspaces) { window.location.href = workspaces.formatUrlWithWorkspaceId( - application.getUrlForApp(WORKSPACE_APP_ID, { - path: PATHS.overview, + application.getUrlForApp(WORKSPACE_OVERVIEW_APP_ID, { absolute: true, }), result.result.id diff --git a/src/plugins/workspace/public/components/workspace_creator_app.tsx b/src/plugins/workspace/public/components/workspace_creator_app.tsx new file mode 100644 index 000000000000..a292d21b18da --- /dev/null +++ b/src/plugins/workspace/public/components/workspace_creator_app.tsx @@ -0,0 +1,35 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import React, { useEffect } from 'react'; +import { I18nProvider } from '@osd/i18n/react'; +import { i18n } from '@osd/i18n'; +import { useOpenSearchDashboards } from '../../../opensearch_dashboards_react/public'; +import { WorkspaceCreator } from './workspace_creator'; + +export const WorkspaceCreatorApp = () => { + const { + services: { chrome }, + } = useOpenSearchDashboards(); + + /** + * set breadcrumbs to chrome + */ + useEffect(() => { + chrome?.setBreadcrumbs([ + { + text: i18n.translate('workspace.workspaceCreateTitle', { + defaultMessage: 'Workspace Create', + }), + }, + ]); + }, [chrome]); + + return ( + + + + ); +}; diff --git a/src/plugins/workspace/public/components/workspace_list_app.tsx b/src/plugins/workspace/public/components/workspace_list_app.tsx new file mode 100644 index 000000000000..ec2fb6875bba --- /dev/null +++ b/src/plugins/workspace/public/components/workspace_list_app.tsx @@ -0,0 +1,35 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import React, { useEffect } from 'react'; +import { I18nProvider } from '@osd/i18n/react'; +import { i18n } from '@osd/i18n'; +import { useOpenSearchDashboards } from '../../../opensearch_dashboards_react/public'; +import { WorkspaceList } from './workspace_list'; + +export const WorkspaceListApp = () => { + const { + services: { chrome }, + } = useOpenSearchDashboards(); + + /** + * set breadcrumbs to chrome + */ + useEffect(() => { + chrome?.setBreadcrumbs([ + { + text: i18n.translate('workspace.workspaceCreateTitle', { + defaultMessage: 'Workspace Create', + }), + }, + ]); + }, [chrome]); + + return ( + + + + ); +}; diff --git a/src/plugins/workspace/public/components/workspace_overview_app.tsx b/src/plugins/workspace/public/components/workspace_overview_app.tsx new file mode 100644 index 000000000000..d452600648b4 --- /dev/null +++ b/src/plugins/workspace/public/components/workspace_overview_app.tsx @@ -0,0 +1,35 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import React, { useEffect } from 'react'; +import { I18nProvider } from '@osd/i18n/react'; +import { i18n } from '@osd/i18n'; +import { useOpenSearchDashboards } from '../../../opensearch_dashboards_react/public'; +import { WorkspaceOverview } from './workspace_overview'; + +export const WorkspaceOverviewApp = () => { + const { + services: { chrome }, + } = useOpenSearchDashboards(); + + /** + * set breadcrumbs to chrome + */ + useEffect(() => { + chrome?.setBreadcrumbs([ + { + text: i18n.translate('workspace.workspaceOverviewTitle', { + defaultMessage: 'Workspace Overview', + }), + }, + ]); + }, [chrome]); + + return ( + + + + ); +}; diff --git a/src/plugins/workspace/public/components/workspace_updater/workspace_updater.tsx b/src/plugins/workspace/public/components/workspace_updater/workspace_updater.tsx index 278ed962966f..a3f0ae1914f8 100644 --- a/src/plugins/workspace/public/components/workspace_updater/workspace_updater.tsx +++ b/src/plugins/workspace/public/components/workspace_updater/workspace_updater.tsx @@ -19,7 +19,7 @@ import { WorkspaceAttribute } from 'opensearch-dashboards/public'; import { useOpenSearchDashboards } from '../../../../opensearch_dashboards_react/public'; import { PATHS } from '../../../common/constants'; import { WorkspaceForm, WorkspaceFormData } from '../workspace_creator/workspace_form'; -import { WORKSPACE_APP_ID, WORKSPACE_OP_TYPE_UPDATE } from '../../../common/constants'; +import { WORKSPACE_OVERVIEW_APP_ID, WORKSPACE_OP_TYPE_UPDATE } from '../../../common/constants'; import { ApplicationStart } from '../../../../../core/public'; import { DeleteWorkspaceModal } from '../delete_workspace_modal'; @@ -76,8 +76,7 @@ export const WorkspaceUpdater = () => { }); window.location.href = workspaces?.formatUrlWithWorkspaceId( - application.getUrlForApp(WORKSPACE_APP_ID, { - path: PATHS.overview, + application.getUrlForApp(WORKSPACE_OVERVIEW_APP_ID, { absolute: true, }), currentWorkspace.id diff --git a/src/plugins/workspace/public/components/workspace_updater_app.tsx b/src/plugins/workspace/public/components/workspace_updater_app.tsx new file mode 100644 index 000000000000..89ad15028f82 --- /dev/null +++ b/src/plugins/workspace/public/components/workspace_updater_app.tsx @@ -0,0 +1,35 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import React, { useEffect } from 'react'; +import { I18nProvider } from '@osd/i18n/react'; +import { i18n } from '@osd/i18n'; +import { useOpenSearchDashboards } from '../../../opensearch_dashboards_react/public'; +import { WorkspaceUpdater } from './workspace_updater'; + +export const WorkspaceUpdaterApp = () => { + const { + services: { chrome }, + } = useOpenSearchDashboards(); + + /** + * set breadcrumbs to chrome + */ + useEffect(() => { + chrome?.setBreadcrumbs([ + { + text: i18n.translate('workspace.workspaceUpdateTitle', { + defaultMessage: 'Workspace Update', + }), + }, + ]); + }, [chrome]); + + return ( + + + + ); +}; diff --git a/src/plugins/workspace/public/containers/workspace_dropdown_list/workspace_dropdown_list.tsx b/src/plugins/workspace/public/containers/workspace_dropdown_list/workspace_dropdown_list.tsx index a53e39cf1647..60bbed924d42 100644 --- a/src/plugins/workspace/public/containers/workspace_dropdown_list/workspace_dropdown_list.tsx +++ b/src/plugins/workspace/public/containers/workspace_dropdown_list/workspace_dropdown_list.tsx @@ -8,7 +8,7 @@ import React, { useState, useCallback, useMemo, useEffect } from 'react'; import { EuiButton, EuiComboBox, EuiComboBoxOptionOption } from '@elastic/eui'; import useObservable from 'react-use/lib/useObservable'; import { ApplicationStart, WorkspaceAttribute, WorkspacesStart } from '../../../../../core/public'; -import { WORKSPACE_APP_ID, PATHS } from '../../../common/constants'; +import { WORKSPACE_CREATE_APP_ID } from '../../../common/constants'; import { switchWorkspace } from '../../components/utils/workspace'; type WorkspaceOption = EuiComboBoxOptionOption; @@ -64,7 +64,7 @@ export function WorkspaceDropdownList(props: WorkspaceDropdownListProps) { ); const onCreateWorkspaceClick = () => { - props.application.navigateToApp(WORKSPACE_APP_ID, { path: PATHS.create }); + props.application.navigateToApp(WORKSPACE_CREATE_APP_ID); }; useEffect(() => { diff --git a/src/plugins/workspace/public/plugin.ts b/src/plugins/workspace/public/plugin.ts index 0bd94c897fbc..0e21fca9d112 100644 --- a/src/plugins/workspace/public/plugin.ts +++ b/src/plugins/workspace/public/plugin.ts @@ -19,7 +19,13 @@ import { WorkspacesStart, DEFAULT_APP_CATEGORIES, } from '../../../core/public'; -import { PATHS, WORKSPACE_APP_ID, WORKSPACE_NAV_CATEGORY } from '../common/constants'; +import { + WORKSPACE_LIST_APP_ID, + WORKSPACE_UPDATE_APP_ID, + WORKSPACE_CREATE_APP_ID, + WORKSPACE_OVERVIEW_APP_ID, + WORKSPACE_NAV_CATEGORY, +} from '../common/constants'; import { mountDropdownList } from './mount'; import { SavedObjectsManagementPluginSetup } from '../../saved_objects_management/public'; import { getWorkspaceColumn } from './components/utils/workspace_column'; @@ -84,22 +90,70 @@ export class WorkspacesPlugin implements Plugin<{}, {}, WorkspacesPluginSetupDep */ savedObjectsManagement?.columns.register(getWorkspaceColumn(core)); + type WorkspaceAppType = (params: AppMountParameters, services: CoreStart) => () => void; + const mountWorkspaceApp = async (params: AppMountParameters, renderApp: WorkspaceAppType) => { + const [coreStart] = await core.getStartServices(); + const services = { + ...coreStart, + }; + + return renderApp(params, services); + }; + + // create core.application.register({ - id: WORKSPACE_APP_ID, - title: i18n.translate('workspace.settings.title', { - defaultMessage: 'Workspace', + id: WORKSPACE_CREATE_APP_ID, + title: i18n.translate('workspace.settings.workspaceCreate', { + defaultMessage: 'Create Workspace', }), - // order: 6010, navLinkStatus: AppNavLinkStatus.hidden, - // updater$: this.appUpdater, async mount(params: AppMountParameters) { - const { renderApp } = await import('./application'); - const [coreStart] = await core.getStartServices(); - const services = { - ...coreStart, - }; + const { renderCreatorApp } = await import('./application'); + return mountWorkspaceApp(params, renderCreatorApp); + }, + }); + + // overview + core.application.register({ + id: WORKSPACE_OVERVIEW_APP_ID, + title: i18n.translate('workspace.settings.workspaceOverview', { + defaultMessage: 'Home', + }), + order: 0, + euiIconType: 'home', + navLinkStatus: AppNavLinkStatus.default, + async mount(params: AppMountParameters) { + const { renderOverviewApp } = await import('./application'); + return mountWorkspaceApp(params, renderOverviewApp); + }, + }); + + // update + core.application.register({ + id: WORKSPACE_UPDATE_APP_ID, + title: i18n.translate('workspace.settings.workspaceUpdate', { + defaultMessage: 'Workspace Settings', + }), + euiIconType: 'managementApp', + navLinkStatus: AppNavLinkStatus.default, + async mount(params: AppMountParameters) { + const { renderUpdateApp } = await import('./application'); + return mountWorkspaceApp(params, renderUpdateApp); + }, + }); - return renderApp(params, services); + // list + core.application.register({ + id: WORKSPACE_LIST_APP_ID, + title: i18n.translate('workspace.settings.workspaceList', { + defaultMessage: 'See More', + }), + euiIconType: 'folderClosed', + category: WORKSPACE_NAV_CATEGORY, + navLinkStatus: workspaceId ? AppNavLinkStatus.hidden : AppNavLinkStatus.default, + async mount(params: AppMountParameters) { + const { renderListApp } = await import('./application'); + return mountWorkspaceApp(params, renderListApp); }, }); @@ -109,12 +163,12 @@ export class WorkspacesPlugin implements Plugin<{}, {}, WorkspacesPluginSetupDep private workspaceToChromeNavLink( workspace: WorkspaceAttribute, workspacesStart: WorkspacesStart, - application: ApplicationStart + application: ApplicationStart, + index: number ): ChromeNavLink { - const id = WORKSPACE_APP_ID + '/' + workspace.id; + const id = WORKSPACE_OVERVIEW_APP_ID + '/' + workspace.id; const url = workspacesStart?.formatUrlWithWorkspaceId( - application.getUrlForApp(WORKSPACE_APP_ID, { - path: '/', + application.getUrlForApp(WORKSPACE_OVERVIEW_APP_ID, { absolute: true, }), workspace.id @@ -122,6 +176,7 @@ export class WorkspacesPlugin implements Plugin<{}, {}, WorkspacesPluginSetupDep return { id, url, + order: index, hidden: false, disabled: false, baseUrl: url, @@ -166,82 +221,17 @@ export class WorkspacesPlugin implements Plugin<{}, {}, WorkspacesPluginSetupDep const filteredNavLinks = new Map(); chromeNavLinks = this.filterByWorkspace(currentWorkspace, chromeNavLinks); chromeNavLinks.forEach((chromeNavLink) => { - if (chromeNavLink.id === 'home') { - // set hidden, icon and order for home nav link - const homeNavLink: ChromeNavLink = { - ...chromeNavLink, - hidden: currentWorkspace !== null, - euiIconType: 'logoOpenSearch', - order: 0, - }; - filteredNavLinks.set(chromeNavLink.id, homeNavLink); - } else { - filteredNavLinks.set(chromeNavLink.id, chromeNavLink); - } + filteredNavLinks.set(chromeNavLink.id, chromeNavLink); }); - if (currentWorkspace) { - // Overview only inside workspace - const overviewId = WORKSPACE_APP_ID + PATHS.update; - const overviewUrl = core.workspaces.formatUrlWithWorkspaceId( - core.application.getUrlForApp(WORKSPACE_APP_ID, { - path: PATHS.update, - absolute: true, - }), - currentWorkspace.id - ); - const overviewNavLink: ChromeNavLink = { - id: overviewId, - title: i18n.translate('core.ui.workspaceNavList.overview', { - defaultMessage: 'Overview', - }), - hidden: false, - disabled: false, - baseUrl: overviewUrl, - href: overviewUrl, - euiIconType: 'grid', - order: 0, - }; - filteredNavLinks.set(overviewId, overviewNavLink); - } else { + if (!currentWorkspace) { workspaceList .filter((workspace, index) => index < 5) - .map((workspace) => - this.workspaceToChromeNavLink(workspace, core.workspaces, core.application) + .map((workspace, index) => + this.workspaceToChromeNavLink(workspace, core.workspaces, core.application, index) ) .forEach((workspaceNavLink) => filteredNavLinks.set(workspaceNavLink.id, workspaceNavLink) ); - // See more - const seeMoreId = WORKSPACE_APP_ID + PATHS.list; - const seeMoreUrl = WORKSPACE_APP_ID + PATHS.list; - const seeMoreNavLink: ChromeNavLink = { - id: seeMoreId, - title: i18n.translate('core.ui.workspaceNavList.seeMore', { - defaultMessage: 'SEE MORE', - }), - hidden: false, - disabled: false, - baseUrl: seeMoreUrl, - href: seeMoreUrl, - category: WORKSPACE_NAV_CATEGORY, - }; - filteredNavLinks.set(seeMoreId, seeMoreNavLink); - // Admin - const adminId = 'admin'; - const adminUrl = '/app/admin'; - const adminNavLink: ChromeNavLink = { - id: adminId, - title: i18n.translate('core.ui.workspaceNavList.admin', { - defaultMessage: 'Admin', - }), - hidden: false, - disabled: true, - baseUrl: adminUrl, - href: adminUrl, - euiIconType: 'managementApp', - order: 9000, - }; - filteredNavLinks.set(adminId, adminNavLink); } navLinksService.setFilteredNavLinks(filteredNavLinks); });