diff --git a/src/plugins/workspace/public/components/workspace_form/utils.ts b/src/plugins/workspace/public/components/workspace_form/utils.ts index 8f06581b7ab0..d613101bdb0b 100644 --- a/src/plugins/workspace/public/components/workspace_form/utils.ts +++ b/src/plugins/workspace/public/components/workspace_form/utils.ts @@ -136,7 +136,7 @@ export const convertPermissionsToPermissionSettings = (permissions: SavedObjectP if (!isWorkspacePermissionMode(mode)) { return; } - if (permissions[mode].users) { + if (permissions[mode].users || permissions[mode].groups) { permissions[mode].users?.forEach((userId) => { const settingTypeKey = `userId-${userId}`; const modes = settingType2Modes[settingTypeKey] ? settingType2Modes[settingTypeKey] : []; @@ -157,11 +157,12 @@ export const convertPermissionsToPermissionSettings = (permissions: SavedObjectP modes.push(mode); if (modes.length === 1) { - userPermissionSettings.push({ + groupPermissionSettings.push({ type: WorkspacePermissionItemType.Group, group, modes, }); + settingType2Modes[settingTypeKey] = modes; } }); } diff --git a/src/plugins/workspace/public/components/workspace_overview/getting_start_modal.tsx b/src/plugins/workspace/public/components/workspace_overview/getting_start_modal.tsx index e94506719376..92f9c6775ad0 100644 --- a/src/plugins/workspace/public/components/workspace_overview/getting_start_modal.tsx +++ b/src/plugins/workspace/public/components/workspace_overview/getting_start_modal.tsx @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import React, { ReactNode, useState } from 'react'; +import React, { ReactNode, useRef, useState } from 'react'; import { EuiFlexItem, EuiText, @@ -30,20 +30,28 @@ interface Props extends Omit { } export const WorkspaceOverviewGettingStartModal = (props: Props) => { - const [selectedItemName, setSelectedItem] = useState('all'); + const ALL = 'all'; + const [selectedItemName, setSelectedItem] = useState(ALL); + const scrollToRefs = useRef({} as Record); + const allRef = useRef(null as HTMLDivElement | null); const { onCloseModal, availableCards } = props; - const selectItem = (name: string) => { - setSelectedItem(name); - }; - const createItem = (name: string, data = {}) => { return { id: slugify(name), name, isSelected: selectedItemName === name, - onClick: () => selectItem(name), + onClick: () => { + setSelectedItem(name); + if (name === ALL && allRef.current) { + allRef.current.scrollIntoView(true); + return; + } + if (scrollToRefs.current[slugify(name)]) { + scrollToRefs.current[slugify(name)]?.scrollIntoView(true); + } + }, ...data, }; }; @@ -56,7 +64,7 @@ export const WorkspaceOverviewGettingStartModal = (props: Props) => { ), ]; - const sideNav = ['all', ...categories].map((category) => createItem(category)); + const sideNav = [ALL, ...categories].map((category) => createItem(category)); const cardList: ReactNode[] = categories.map((category) => { const cards = availableCards.filter((card) => { @@ -64,8 +72,7 @@ export const WorkspaceOverviewGettingStartModal = (props: Props) => { }); return ( -
- +
(scrollToRefs.current[slugify(category)] = ref)}>

{category}

@@ -79,6 +86,7 @@ export const WorkspaceOverviewGettingStartModal = (props: Props) => { ); })} +
); }); @@ -99,7 +107,7 @@ export const WorkspaceOverviewGettingStartModal = (props: Props) => { - {cardList} +
{cardList}
diff --git a/src/plugins/workspace/public/components/workspace_overview/index.tsx b/src/plugins/workspace/public/components/workspace_overview/index.tsx index 9b4c9f182a46..ed5bb6bc8bb1 100644 --- a/src/plugins/workspace/public/components/workspace_overview/index.tsx +++ b/src/plugins/workspace/public/components/workspace_overview/index.tsx @@ -101,21 +101,21 @@ export const WorkspaceOverview = () => { { id: 'overview', name: i18n.translate('workspace.overview.title', { - defaultMessage: 'overview', + defaultMessage: 'Overview', }), content: , }, { id: 'library', name: i18n.translate('workspace.library.title', { - defaultMessage: 'library', + defaultMessage: 'Library', }), content: , }, { id: 'settings', name: i18n.translate('workspace.setting.title', { - defaultMessage: 'setting', + defaultMessage: 'Setting', }), content: , }, diff --git a/src/plugins/workspace/public/components/workspace_overview/workspace_overview_content.tsx b/src/plugins/workspace/public/components/workspace_overview/workspace_overview_content.tsx index af16db3c90eb..232f794fd027 100644 --- a/src/plugins/workspace/public/components/workspace_overview/workspace_overview_content.tsx +++ b/src/plugins/workspace/public/components/workspace_overview/workspace_overview_content.tsx @@ -3,10 +3,11 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { EuiFlexGrid, EuiTitle, EuiFlexItem, EuiCard, EuiSpacer } from '@elastic/eui'; +import { EuiTitle, EuiFlexItem, EuiCard, EuiSpacer, EuiPanel, EuiFlexGroup } from '@elastic/eui'; import React from 'react'; import { useObservable } from 'react-use'; import { of } from 'rxjs'; +import { i18n } from '@osd/i18n'; import { useOpenSearchDashboards } from '../../../../../plugins/opensearch_dashboards_react/public'; export const WorkspaceOverviewContent = () => { @@ -17,22 +18,32 @@ export const WorkspaceOverviewContent = () => { const currentWorkspace = useObservable(workspaces ? workspaces.currentWorkspace$ : of(null)); return ( - <> + -
Overview
+ + {i18n.translate('workspace.overview.title', { + defaultMessage: 'Overview', + })} +
- - + + {}} title="about" titleSize="xs" description={currentWorkspace?.description || ''} /> - - + + + + recent items + + + + +
); };