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 (opensearch-project#7859)

* update header for objects

Signed-off-by: tygao <tygao@amazon.com>

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

Signed-off-by: tygao <tygao@amazon.com>

* style: update workspace list button based on latest mockup

Signed-off-by: tygao <tygao@amazon.com>

* fine-tune style for workspace and saved objects

Signed-off-by: tygao <tygao@amazon.com>

* Changeset file for PR opensearch-project#7859 created/updated

* test: update snapshots for feature cards

Signed-off-by: tygao <tygao@amazon.com>

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

Co-authored-by: Yulong Ruan <ruanyu1@gmail.com>
Signed-off-by: Tianyu Gao <tygao@amazon.com>

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

Co-authored-by: Yulong Ruan <ruanyu1@gmail.com>
Signed-off-by: Tianyu Gao <tygao@amazon.com>

* remove extra space in sentence

Signed-off-by: tygao <tygao@amazon.com>

* lint: break line

Signed-off-by: tygao <tygao@amazon.com>

---------

Signed-off-by: tygao <tygao@amazon.com>
Signed-off-by: Tianyu Gao <tygao@amazon.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
4 people authored Sep 3, 2024
1 parent a7024e6 commit cbe74d8
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 cbe74d8

Please sign in to comment.