Skip to content

Commit

Permalink
add workspace overview to breadcrum
Browse files Browse the repository at this point in the history
Signed-off-by: Hailong Cui <ihailong@amazon.com>
  • Loading branch information
Hailong-am committed Apr 8, 2024
1 parent 8f1f050 commit acb95e6
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 44 deletions.
17 changes: 15 additions & 2 deletions src/core/public/chrome/chrome_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -96,6 +96,7 @@ export interface StartDeps {
injectedMetadata: InjectedMetadataStart;
notifications: NotificationsStart;
uiSettings: IUiSettingsClient;
workspaces: WorkspacesStart;
}

type CollapsibleNavHeaderRender = () => JSX.Element | null;
Expand Down Expand Up @@ -166,6 +167,7 @@ export class ChromeService {
injectedMetadata,
notifications,
uiSettings,
workspaces,
}: StartDeps): Promise<InternalChromeStart> {
this.initVisibility(application);

Expand Down Expand Up @@ -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$)),
Expand Down
1 change: 1 addition & 0 deletions src/core/public/core_system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ export class CoreSystem {
injectedMetadata,
notifications,
uiSettings,
workspaces,
});

this.coreApp.start({ application, http, notifications, uiSettings });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,17 @@ export const WorkspaceOverview = () => {
</EuiFlexItem>
);
})}
<EuiFlexItem key="see_more">
<EuiPanel
onClick={() => {
setIsModalVisible(true);
}}
>
<EuiText>see more ways to get started</EuiText>
</EuiPanel>
</EuiFlexItem>
{availableCards.length > 5 ? (
<EuiFlexItem key="see_more">
<EuiPanel
onClick={() => {
setIsModalVisible(true);
}}
>
<EuiText>see more ways to get started</EuiText>
</EuiPanel>
</EuiFlexItem>
) : null}
</EuiFlexGroup>
</>
) : null}
Expand Down
56 changes: 30 additions & 26 deletions src/plugins/workspace/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit acb95e6

Please sign in to comment.