Skip to content

Commit

Permalink
refactor: add workspace info in index pattern and asset header and up…
Browse files Browse the repository at this point in the history
…date workspace header (#7859) (#7972)

* update header for objects



* remove render component button and add workspace info in index pattern header



* style: update workspace list button based on latest mockup



* fine-tune style for workspace and saved objects



* Changeset file for PR #7859 created/updated

* test: update snapshots for feature cards



* Update src/plugins/index_pattern_management/public/components/index_pattern_table/index_pattern_table.tsx




* Update src/plugins/saved_objects_management/public/management_section/objects_table/components/header.tsx




* remove extra space in sentence



* lint: break line



---------






(cherry picked from commit cbe74d8)

Signed-off-by: tygao <tygao@amazon.com>
Signed-off-by: Tianyu Gao <tygao@amazon.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Co-authored-by: Yulong Ruan <ruanyu1@gmail.com>
Co-authored-by: SuZhou-Joe <suzhou@amazon.com>
  • Loading branch information
5 people committed Sep 4, 2024
1 parent 880634f commit f7a168d
Show file tree
Hide file tree
Showing 18 changed files with 184 additions and 209 deletions.
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

0 comments on commit f7a168d

Please sign in to comment.