Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
Signed-off-by: tygao <[email protected]>
  • Loading branch information
raintygao committed Oct 8, 2024
1 parent 588210e commit 5d53cc2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { DataSourceConnectionType } from '../../../common/types';
import * as utilsExports from '../../utils';
import { IntlProvider } from 'react-intl';
import { of } from 'rxjs';

// all applications
const PublicAPPInfoMap = new Map([
['alerting', { id: 'alerting', title: 'alerting' }],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import { i18n } from '@osd/i18n';
import { WorkspacePermissionMode } from '../../../common/constants';
import { PermissionModeId } from '../../../../../core/public';
import { WORKSPACE_ACCESS_LEVEL_NAMES } from '../../constants';

export enum WorkspaceOperationType {
Create = 'create',
Expand Down Expand Up @@ -126,30 +127,15 @@ export const PERMISSION_ACCESS_LEVEL_LABEL_ID = 'workspace-form-permission-acces
export const permissionModeOptions = [
{
value: PermissionModeId.Read,
inputDisplay: i18n.translate(
'workspace.form.permissionSettingPanel.permissionModeOptions.read',
{
defaultMessage: 'Read only',
}
),
inputDisplay: WORKSPACE_ACCESS_LEVEL_NAMES.readOnly,
},
{
value: PermissionModeId.ReadAndWrite,
inputDisplay: i18n.translate(
'workspace.form.permissionSettingPanel.permissionModeOptions.readAndWrite',
{
defaultMessage: 'Read and write',
}
),
inputDisplay: WORKSPACE_ACCESS_LEVEL_NAMES.readAndWrite,
},
{
value: PermissionModeId.Owner,
inputDisplay: i18n.translate(
'workspace.form.permissionSettingPanel.permissionModeOptions.owner',
{
defaultMessage: 'Admin',
}
),
inputDisplay: WORKSPACE_ACCESS_LEVEL_NAMES.admin,
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,26 +267,27 @@ const Actions = ({
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
const { overlays } = useOpenSearchDashboards();

const accessLevelOptions = Object.keys(WORKSPACE_ACCESS_LEVEL_NAMES).map((level) => ({
name: WORKSPACE_ACCESS_LEVEL_NAMES[level as WorkspaceCollaboratorAccessLevel],
const accessLevelOptions = (Object.keys(
WORKSPACE_ACCESS_LEVEL_NAMES
) as WorkspaceCollaboratorAccessLevel[]).map((level) => ({
name: WORKSPACE_ACCESS_LEVEL_NAMES[level],
onClick: async () => {
setIsPopoverOpen(false);
if (selection) {
const modal = overlays.openModal(
<EuiConfirmModal
title="Change access level"
title={i18n.translate('workspace.detail.collaborator.table.change.access.level', {
defaultMessage: 'Change access level',
})}
onCancel={() => modal.close()}
onConfirm={async () => {
onConfirm={() => {
let newSettings = permissionSettings;
selection.forEach(({ id }) => {
newSettings = newSettings.map((item) =>
id === item.id
? {
...item,
modes:
accessLevelNameToWorkspacePermissionModesMap[
level as WorkspaceCollaboratorAccessLevel
],
modes: accessLevelNameToWorkspacePermissionModesMap[level],
}
: item
);
Expand All @@ -299,9 +300,15 @@ const Actions = ({
>
<EuiText>
<p>
Do you want to change access level to {selection.length} collaborator
{`${selection.length > 1 ? 's' : ''}`} to{' '}
{`"${WORKSPACE_ACCESS_LEVEL_NAMES[level as WorkspaceCollaboratorAccessLevel]}"`}?
{i18n.translate('workspace.detail.collaborator.changeAccessLevel.confirmation', {
defaultMessage:
'Do you want to change access level to {numCollaborators} collaborator{pluralSuffix} to "{accessLevel}"?',
values: {
numCollaborators: selection.length,
pluralSuffix: selection.length > 1 ? 's' : '',
accessLevel: WORKSPACE_ACCESS_LEVEL_NAMES[level],
},
})}
</p>
</EuiText>
</EuiConfirmModal>
Expand Down

0 comments on commit 5d53cc2

Please sign in to comment.