From acb95e66390cc7d839b35b071a02b18a197f9a5e Mon Sep 17 00:00:00 2001 From: Hailong Cui Date: Mon, 8 Apr 2024 17:35:20 +0800 Subject: [PATCH] add workspace overview to breadcrum Signed-off-by: Hailong Cui --- src/core/public/chrome/chrome_service.tsx | 17 +++++- src/core/public/core_system.ts | 1 + .../all_get_started_cards.ts | 8 +-- .../components/workspace_overview/index.tsx | 20 ++++--- src/plugins/workspace/public/plugin.ts | 56 ++++++++++--------- 5 files changed, 58 insertions(+), 44 deletions(-) diff --git a/src/core/public/chrome/chrome_service.tsx b/src/core/public/chrome/chrome_service.tsx index 57c9f11d9061..dd8cf75575e9 100644 --- a/src/core/public/chrome/chrome_service.tsx +++ b/src/core/public/chrome/chrome_service.tsx @@ -48,7 +48,7 @@ import { ChromeNavLinks, NavLinksService, ChromeNavLink } from './nav_links'; import { ChromeRecentlyAccessed, RecentlyAccessedService } from './recently_accessed'; import { Header } from './ui'; import { ChromeHelpExtensionMenuLink } from './ui/header/header_help_menu'; -import { Branding } from '../'; +import { Branding, WorkspacesStart } from '../'; import { getLogos } from '../../common'; import type { Logos } from '../../common/types'; @@ -96,6 +96,7 @@ export interface StartDeps { injectedMetadata: InjectedMetadataStart; notifications: NotificationsStart; uiSettings: IUiSettingsClient; + workspaces: WorkspacesStart; } type CollapsibleNavHeaderRender = () => JSX.Element | null; @@ -166,6 +167,7 @@ export class ChromeService { injectedMetadata, notifications, uiSettings, + workspaces, }: StartDeps): Promise { this.initVisibility(application); @@ -316,7 +318,18 @@ export class ChromeService { getBreadcrumbs$: () => breadcrumbs$.pipe(takeUntil(this.stop$)), setBreadcrumbs: (newBreadcrumbs: ChromeBreadcrumb[]) => { - breadcrumbs$.next(newBreadcrumbs); + if (workspaces.currentWorkspace$.getValue()) { + const currentWorkspace = workspaces.currentWorkspace$.getValue()!; + const workspaceCrumb: ChromeBreadcrumb = { + text: currentWorkspace.name, + onClick: () => { + application.navigateToApp('workspace_overview'); + }, + }; + breadcrumbs$.next([workspaceCrumb, ...newBreadcrumbs]); + } else { + breadcrumbs$.next(newBreadcrumbs); + } }, getHelpExtension$: () => helpExtension$.pipe(takeUntil(this.stop$)), diff --git a/src/core/public/core_system.ts b/src/core/public/core_system.ts index e70966620c82..aef58371e337 100644 --- a/src/core/public/core_system.ts +++ b/src/core/public/core_system.ts @@ -235,6 +235,7 @@ export class CoreSystem { injectedMetadata, notifications, uiSettings, + workspaces, }); this.coreApp.start({ application, http, notifications, uiSettings }); diff --git a/src/plugins/workspace/public/components/workspace_overview/all_get_started_cards.ts b/src/plugins/workspace/public/components/workspace_overview/all_get_started_cards.ts index 07bb442eae3c..df373c72d4b1 100644 --- a/src/plugins/workspace/public/components/workspace_overview/all_get_started_cards.ts +++ b/src/plugins/workspace/public/components/workspace_overview/all_get_started_cards.ts @@ -14,12 +14,6 @@ export const getStartCards: GetStartCard[] = [ link: '/app/home#/tutorial_directory', category: DEFAULT_APP_CATEGORIES.getStarted, }, - { - title: 'create a workspace for your team to collaborate', - description: 'with workspace', - link: '/app/workspace_create', - category: DEFAULT_APP_CATEGORIES.getStarted, - }, { appId: 'datasources', title: 'connect to a data source to ingest data', @@ -65,7 +59,7 @@ export const getStartCards: GetStartCard[] = [ }, // investigate { - appId: 'data-explorer', + appId: 'discover', title: 'explore data and events by querying raw documents.', description: 'with discover', link: '/app/data-explorer/discover', diff --git a/src/plugins/workspace/public/components/workspace_overview/index.tsx b/src/plugins/workspace/public/components/workspace_overview/index.tsx index ed5bb6bc8bb1..937ffc8396b1 100644 --- a/src/plugins/workspace/public/components/workspace_overview/index.tsx +++ b/src/plugins/workspace/public/components/workspace_overview/index.tsx @@ -155,15 +155,17 @@ export const WorkspaceOverview = () => { ); })} - - { - setIsModalVisible(true); - }} - > - see more ways to get started - - + {availableCards.length > 5 ? ( + + { + setIsModalVisible(true); + }} + > + see more ways to get started + + + ) : null} ) : null} diff --git a/src/plugins/workspace/public/plugin.ts b/src/plugins/workspace/public/plugin.ts index 7bd24bd08c33..e17df1de710e 100644 --- a/src/plugins/workspace/public/plugin.ts +++ b/src/plugins/workspace/public/plugin.ts @@ -128,6 +128,36 @@ export class WorkspacePlugin implements Plugin<{}, {}> { }); })(); } else { + /** + * register workspace overview page only if we are in a valid workspace + */ + core.application.register({ + id: WORKSPACE_OVERVIEW_APP_ID, + title: i18n.translate('workspace.settings.workspaceOverview', { + defaultMessage: 'Workspace Overview', + }), + navLinkStatus: AppNavLinkStatus.hidden, + async mount(params: AppMountParameters) { + const { renderOverviewApp } = await import('./application'); + return mountWorkspaceApp(params, renderOverviewApp); + }, + }); + + /** + * register workspace update page only if we are in a valid workspace + */ + core.application.register({ + id: WORKSPACE_UPDATE_APP_ID, + title: i18n.translate('workspace.settings.workspaceUpdate', { + defaultMessage: 'Update Workspace', + }), + navLinkStatus: AppNavLinkStatus.hidden, + async mount(params: AppMountParameters) { + const { renderUpdaterApp } = await import('./application'); + return mountWorkspaceApp(params, renderUpdaterApp); + }, + }); + /** * If the workspace id is valid and user is currently on workspace_fatal_error page, * we should redirect user to overview page of workspace. @@ -178,32 +208,6 @@ export class WorkspacePlugin implements Plugin<{}, {}> { }, }); - // update - core.application.register({ - id: WORKSPACE_UPDATE_APP_ID, - title: i18n.translate('workspace.settings.workspaceUpdate', { - defaultMessage: 'Update Workspace', - }), - navLinkStatus: AppNavLinkStatus.hidden, - async mount(params: AppMountParameters) { - const { renderUpdaterApp } = await import('./application'); - return mountWorkspaceApp(params, renderUpdaterApp); - }, - }); - - // overview - core.application.register({ - id: WORKSPACE_OVERVIEW_APP_ID, - title: i18n.translate('workspace.settings.workspaceOverview', { - defaultMessage: 'Workspace Overview', - }), - navLinkStatus: AppNavLinkStatus.hidden, - async mount(params: AppMountParameters) { - const { renderOverviewApp } = await import('./application'); - return mountWorkspaceApp(params, renderOverviewApp); - }, - }); - // workspace fatal error core.application.register({ id: WORKSPACE_FATAL_ERROR_APP_ID,