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

refactor: add workspace info in index pattern and asset header and update workspace header #7859

Merged
merged 12 commits into from
Sep 3, 2024
Merged
2 changes: 2 additions & 0 deletions changelogs/fragments/7859.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
refactor:
- Add workspace info in index pattern and asset header and update workspace header ([#7859](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7859))
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
import { i18n } from '@osd/i18n';
import { IndexPattern } from '../../../data/public';

export function getListBreadcrumbs() {
export function getListBreadcrumbs(currentWorkspaceName?: string) {
return [
{
text: i18n.translate('indexPatternManagement.indexPatterns.listBreadcrumb', {
defaultMessage: 'Index patterns',
defaultMessage: currentWorkspaceName ? 'Workspace index patterns' : 'Index patterns',
}),
href: `/`,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import { withRouter, RouteComponentProps } from 'react-router-dom';
import { DocLinksStart } from 'src/core/public';
import { StepIndexPattern } from './components/step_index_pattern';
import { StepTimeField } from './components/step_time_field';
import { Header, Description } from './components/header';
import { Header } from './components/header';
import { LoadingState } from './components/loading_state';

import { context as contextType } from '../../../../opensearch_dashboards_react/public';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,30 +37,21 @@ import { EuiPageContent, EuiSpacer, EuiText, EuiFlexItem, EuiFlexGroup } from '@
import { EuiDescriptionListTitle } from '@elastic/eui';
import { EuiDescriptionListDescription, EuiDescriptionList } from '@elastic/eui';
import { EuiLink } from '@elastic/eui';
import { useMount } from 'react-use';
import { getListBreadcrumbs } from '../../breadcrumbs';
import { IndexPatternCreationOption } from '../../types';
import { CreateButton } from '../../create_button';
import { Illustration } from './assets/index_pattern_illustration';
import { ManagementAppMountParams } from '../../../../../management/public';

interface Props {
canSave: boolean;
creationOptions: IndexPatternCreationOption[];
docLinksIndexPatternIntro: string;
setBreadcrumbs: ManagementAppMountParams['setBreadcrumbs'];
}

export const EmptyIndexPatternPrompt = ({
canSave,
creationOptions,
docLinksIndexPatternIntro,
setBreadcrumbs,
}: Props) => {
useMount(() => {
setBreadcrumbs(getListBreadcrumbs());
});

return (
<EuiPageContent
data-test-subj="emptyIndexPatternPrompt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ import { FormattedMessage } from '@osd/i18n/react';
import { withRouter, RouteComponentProps } from 'react-router-dom';
import React, { useState, useEffect } from 'react';
import { i18n } from '@osd/i18n';
import { useEffectOnce, useMount } from 'react-use';
import { useEffectOnce, useObservable } from 'react-use';
import { of } from 'rxjs';
import {
reactRouterNavigate,
useOpenSearchDashboards,
Expand Down Expand Up @@ -105,6 +106,7 @@ export const IndexPatternTable = ({ canSave, history }: Props) => {
getMlCardState,
data,
dataSourceEnabled,
workspaces,
} = useOpenSearchDashboards<IndexPatternManagmentContext>().services;

const [indexPatterns, setIndexPatterns] = useState<IndexPatternTableItem[]>([]);
Expand All @@ -115,11 +117,13 @@ export const IndexPatternTable = ({ canSave, history }: Props) => {
const [isLoadingIndexPatterns, setIsLoadingIndexPatterns] = useState<boolean>(true);
const [isColumnDataLoaded, setIsColumnDataLoaded] = useState(false);

const currentWorkspace = useObservable(workspaces ? workspaces.currentWorkspace$ : of(null));
const { columns: columnRegistry } = indexPatternManagementStart;

useMount(() => {
setBreadcrumbs(getListBreadcrumbs());
});
const useUpdatedUX = uiSettings.get('home:useNewHomePage');
useEffect(() => {
setBreadcrumbs(getListBreadcrumbs(useUpdatedUX ? currentWorkspace?.name : undefined));
}, [chrome, currentWorkspace, setBreadcrumbs, useUpdatedUX]);

useEffect(() => {
(async function () {
Expand Down Expand Up @@ -219,8 +223,6 @@ export const IndexPatternTable = ({ canSave, history }: Props) => {
}),
];

const showActionsInHeader = uiSettings.get('home:useNewHomePage');

const createButton = (() => {
if (!canSave) return null;

Expand All @@ -233,7 +235,7 @@ export const IndexPatternTable = ({ canSave, history }: Props) => {
</CreateButton>
);

return showActionsInHeader ? (
return useUpdatedUX ? (
<HeaderControl
controls={[{ renderComponent: button }]}
setMountPoint={application.setAppRightControls}
Expand All @@ -243,13 +245,22 @@ export const IndexPatternTable = ({ canSave, history }: Props) => {
);
})();

const description = ((
<FormattedMessage
id="indexPatternManagement.indexPatternTable.indexPatternExplanation"
defaultMessage="Create and manage the index patterns that help you retrieve your data from OpenSearch."
/>
) as unknown) as string;
const pageTitleAndDescription = showActionsInHeader ? (
const description = i18n.translate(
'indexPatternManagement.indexPatternTable.indexPatternExplanation',
currentWorkspace
? {
defaultMessage:
'Create and manage the index patterns that help you retrieve your data from OpenSearch for {name} workspace.',
values: {
name: currentWorkspace.name,
},
}
: {
defaultMessage:
'Create and manage the index patterns that help you retrieve your data from OpenSearch.',
}
);
const pageTitleAndDescription = useUpdatedUX ? (
<HeaderControl
controls={[{ description }]}
setMountPoint={application.setAppDescriptionControls}
Expand Down Expand Up @@ -291,7 +302,6 @@ export const IndexPatternTable = ({ canSave, history }: Props) => {
canSave={canSave}
creationOptions={creationOptions}
docLinksIndexPatternIntro={docLinks.links.noDocumentation.indexPatterns.introduction}
setBreadcrumbs={setBreadcrumbs}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,17 @@ export async function mountManagementSection(
dataSource?: DataSourcePluginSetup
) {
const [
{ chrome, application, savedObjects, uiSettings, notifications, overlays, http, docLinks },
{
chrome,
application,
savedObjects,
uiSettings,
notifications,
overlays,
http,
docLinks,
workspaces,
},
{ data, navigation },
indexPatternManagementStart,
] = await getStartServices();
Expand Down Expand Up @@ -94,6 +104,7 @@ export async function mountManagementSection(
getMlCardState,
dataSourceEnabled,
hideLocalCluster,
workspaces,
};

const showActionsInHeader = uiSettings.get('home:useNewHomePage');
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/index_pattern_management/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
DocLinksStart,
HttpSetup,
SavedObjectReference,
WorkspacesStart,
} from 'src/core/public';
import { DataPublicPluginStart } from 'src/plugins/data/public';
import { NavigationPublicPluginStart } from 'src/plugins/navigation/public';
Expand All @@ -62,6 +63,7 @@ export interface IndexPatternManagmentContext {
getMlCardState: () => MlCardState;
dataSourceEnabled: boolean;
hideLocalCluster: boolean;
workspaces: WorkspacesStart;
}

export type IndexPatternManagmentContextValue = OpenSearchDashboardsReactContextValue<
Expand Down

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 @@ -63,15 +63,15 @@ export const FeatureCards = ({
]}
setMountPoint={setAppDescriptionControls}
/>
<EuiPageContent hasShadow={false} hasBorder={false} color="transparent">
<EuiPageContent hasShadow={false} hasBorder={false} color="transparent" paddingSize="m">
{groupedCardForDisplay.map((group) => (
<div key={group.category?.id}>
{group.category && (
<EuiTitle>
<h3>{group.category.label}</h3>
</EuiTitle>
)}
<EuiSpacer />
<EuiSpacer size="m" />
{group.navLinks.map((row, rowIndex) => {
return (
<EuiFlexGroup data-test-subj={`landingPageRow_${rowIndex}`} key={rowIndex}>
Expand Down

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

Loading
Loading