|
1 | 1 | // Copyright (c) Cosmo Tech. |
2 | 2 | // Licensed under the MIT license. |
3 | 3 |
|
4 | | -export const getShareScenarioDialogLabels = (t, currentScenarioName, isDirty) => ({ |
5 | | - button: { |
6 | | - title: t('commoncomponents.dialog.share.button.label', 'Share'), |
7 | | - tooltip: isDirty |
8 | | - ? t( |
9 | | - 'commoncomponents.dialog.share.button.editModeTooltip', |
10 | | - 'Please save or discard current modifications before changing the scenario access permissions' |
11 | | - ) |
12 | | - : t('commoncomponents.dialog.share.button.label', 'Share'), |
13 | | - }, |
14 | | - dialog: { |
15 | | - title: t('commoncomponents.dialog.share.dialog.title', 'Share ') + currentScenarioName, |
16 | | - readOnlyTitle: t('commoncomponents.dialog.share.dialog.readOnlyTitle', 'Permissions for ') + currentScenarioName, |
17 | | - addPeople: t('commoncomponents.dialog.share.dialog.select.addPeople', 'Add people'), |
18 | | - cancel: t('commoncomponents.dialog.share.dialog.buttons.cancel', 'Cancel'), |
19 | | - close: t('commoncomponents.dialog.share.dialog.buttons.close', 'Close'), |
20 | | - share: t('commoncomponents.dialog.share.dialog.buttons.share', 'Share'), |
21 | | - noAdminError: t( |
22 | | - 'commoncomponents.dialog.share.dialog.error.noAdmin', |
23 | | - 'The scenario must have at least one administrator' |
24 | | - ), |
25 | | - userSelected: t('commoncomponents.dialog.share.dialog.select.userSelected', 'Selected user'), |
26 | | - usersAccess: t('commoncomponents.dialog.share.dialog.editor.usersAccess', 'Users access'), |
27 | | - generalAccess: t('commoncomponents.dialog.share.dialog.editor.generalAccess', 'General access'), |
28 | | - removeAccess: t('commoncomponents.dialog.share.dialog.editor.removeAccess', 'Remove specific access'), |
29 | | - editor: { |
30 | | - helperText: { |
31 | | - admin: t('commoncomponents.dialog.share.dialog.editor.helperText.admin', 'Anyone in this workspace is admin'), |
32 | | - viewer: t( |
33 | | - 'commoncomponents.dialog.share.dialog.editor.helperText.viewer', |
34 | | - 'Anyone in this workspace is viewer' |
35 | | - ), |
36 | | - validator: t( |
37 | | - 'commoncomponents.dialog.share.dialog.editor.helperText.validator', |
38 | | - 'Anyone in this workspace is validator' |
39 | | - ), |
40 | | - editor: t( |
41 | | - 'commoncomponents.dialog.share.dialog.editor.helperText.editor', |
42 | | - 'Anyone in this workspace is editor' |
43 | | - ), |
44 | | - none: t('commoncomponents.dialog.share.dialog.editor.helperText.none', 'Other users cannot view the scenario'), |
45 | | - }, |
| 4 | +export const getShareScenarioDialogLabels = (t, currentScenarioName, isDirty, hasReadSecurityPermission) => { |
| 5 | + let tooltip = t('commoncomponents.dialog.share.button.label', 'Share'); |
| 6 | + if (!hasReadSecurityPermission) |
| 7 | + tooltip = t( |
| 8 | + 'commoncomponents.dialog.share.button.noReadSecurityPermissionTooltip', |
| 9 | + 'You are not allowed to share or see the security details of this resource' |
| 10 | + ); |
| 11 | + else if (isDirty) |
| 12 | + tooltip = t( |
| 13 | + 'commoncomponents.dialog.share.button.editModeTooltip', |
| 14 | + 'Please save or discard current modifications before changing the scenario access permissions' |
| 15 | + ); |
| 16 | + |
| 17 | + return { |
| 18 | + button: { |
| 19 | + title: t('commoncomponents.dialog.share.button.label', 'Share'), |
| 20 | + tooltip, |
46 | 21 | }, |
47 | | - add: { |
| 22 | + dialog: { |
| 23 | + title: t('commoncomponents.dialog.share.dialog.title', 'Share ') + currentScenarioName, |
| 24 | + readOnlyTitle: t('commoncomponents.dialog.share.dialog.readOnlyTitle', 'Permissions for ') + currentScenarioName, |
| 25 | + addPeople: t('commoncomponents.dialog.share.dialog.select.addPeople', 'Add people'), |
48 | 26 | cancel: t('commoncomponents.dialog.share.dialog.buttons.cancel', 'Cancel'), |
49 | | - deniedPermissions: t('commoncomponents.dialog.share.dialog.add.deniedPermissions', 'Not granted permissions'), |
50 | | - done: t('commoncomponents.dialog.share.dialog.buttons.done', 'Done'), |
51 | | - grantedPermissions: t('commoncomponents.dialog.share.dialog.add.grantedPermissions', 'Granted permissions'), |
52 | | - rolesTitle: t('commoncomponents.dialog.share.dialog.add.rolesTitle', 'Roles'), |
| 27 | + close: t('commoncomponents.dialog.share.dialog.buttons.close', 'Close'), |
| 28 | + share: t('commoncomponents.dialog.share.dialog.buttons.share', 'Share'), |
| 29 | + noAdminError: t( |
| 30 | + 'commoncomponents.dialog.share.dialog.error.noAdmin', |
| 31 | + 'The scenario must have at least one administrator' |
| 32 | + ), |
53 | 33 | userSelected: t('commoncomponents.dialog.share.dialog.select.userSelected', 'Selected user'), |
54 | | - rolesHelperText: t('commoncomponents.dialog.share.dialog.add.rolesHelperText', 'Select one role'), |
| 34 | + usersAccess: t('commoncomponents.dialog.share.dialog.editor.usersAccess', 'Users access'), |
| 35 | + generalAccess: t('commoncomponents.dialog.share.dialog.editor.generalAccess', 'General access'), |
| 36 | + removeAccess: t('commoncomponents.dialog.share.dialog.editor.removeAccess', 'Remove specific access'), |
| 37 | + editor: { |
| 38 | + helperText: { |
| 39 | + admin: t('commoncomponents.dialog.share.dialog.editor.helperText.admin', 'Anyone in this workspace is admin'), |
| 40 | + viewer: t( |
| 41 | + 'commoncomponents.dialog.share.dialog.editor.helperText.viewer', |
| 42 | + 'Anyone in this workspace is viewer' |
| 43 | + ), |
| 44 | + validator: t( |
| 45 | + 'commoncomponents.dialog.share.dialog.editor.helperText.validator', |
| 46 | + 'Anyone in this workspace is validator' |
| 47 | + ), |
| 48 | + editor: t( |
| 49 | + 'commoncomponents.dialog.share.dialog.editor.helperText.editor', |
| 50 | + 'Anyone in this workspace is editor' |
| 51 | + ), |
| 52 | + none: t( |
| 53 | + 'commoncomponents.dialog.share.dialog.editor.helperText.none', |
| 54 | + 'Other users cannot view the scenario' |
| 55 | + ), |
| 56 | + }, |
| 57 | + }, |
| 58 | + add: { |
| 59 | + cancel: t('commoncomponents.dialog.share.dialog.buttons.cancel', 'Cancel'), |
| 60 | + deniedPermissions: t('commoncomponents.dialog.share.dialog.add.deniedPermissions', 'Not granted permissions'), |
| 61 | + done: t('commoncomponents.dialog.share.dialog.buttons.done', 'Done'), |
| 62 | + grantedPermissions: t('commoncomponents.dialog.share.dialog.add.grantedPermissions', 'Granted permissions'), |
| 63 | + rolesTitle: t('commoncomponents.dialog.share.dialog.add.rolesTitle', 'Roles'), |
| 64 | + userSelected: t('commoncomponents.dialog.share.dialog.select.userSelected', 'Selected user'), |
| 65 | + rolesHelperText: t('commoncomponents.dialog.share.dialog.add.rolesHelperText', 'Select one role'), |
| 66 | + }, |
55 | 67 | }, |
56 | | - }, |
57 | | -}); |
| 68 | + }; |
| 69 | +}; |
0 commit comments