Skip to content

Commit 17ee19e

Browse files
committed
fix: [PROD-14244] remove dataset & scenario sharing button for viewer role
Since versions 3.3.2 and 4.1.0, the Cosmo Tech API has disabled the possibility for the role "viewer" to enumerate users and their roles when fetching resources and their security data. This commit hides the dataset & scenario sharing buttons for users when their role on the resource is "viewer", to prevent having a dialog with an empty access-control list. (cherry picked from commit 45de6bc)
1 parent a4598d6 commit 17ee19e

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

src/services/config/ApiConstants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export const DATASET_SOURCES = [
9191
];
9292

9393
export const DATASET_PERMISSIONS_MAPPING = {
94-
viewer: ['read', 'read_security'],
94+
viewer: ['read'],
9595
editor: ['read', 'read_security', 'write'],
9696
admin: ['read', 'read_security', 'write', 'write_security', 'delete'],
9797
};

src/state/commons/DatasetConstants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const DATASET_TWINGRAPH_QUERIES_RESULTS_ACTIONS = {
2626
RESET: 'RESET_DATASET_TWINGRAPH_QUERIES_RESULTS',
2727
};
2828
export const DATASET_PERMISSIONS_MAPPING = {
29-
viewer: ['read', 'read_security'],
29+
viewer: ['read'],
3030
editor: ['read', 'read_security', 'write'],
3131
admin: ['read', 'read_security', 'write', 'write_security', 'delete'],
3232
};

src/state/sagas/datasets/CreateDataset/CreateDataset.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { dispatchSetApplicationErrorMessage } from '../../../dispatchers/app/App
1111

1212
// TODO: replace by data from redux when dataset roles-permissions mapping is added in back-end /permissions endpoint
1313
const DATASET_PERMISSIONS_MAPPING = {
14-
viewer: ['read', 'read_security'],
14+
viewer: ['read'],
1515
editor: ['read', 'read_security', 'write'],
1616
admin: ['read', 'read_security', 'write', 'write_security', 'delete'],
1717
};

src/state/sagas/datasets/FindAllDatasets/FindAllDatasets.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { dispatchSetApplicationErrorMessage } from '../../../dispatchers/app/App
1212

1313
// TODO: replace by data from redux when dataset roles-permissions mapping is added in back-end /permissions endpoint
1414
const DATASET_PERMISSIONS_MAPPING = {
15-
viewer: ['read', 'read_security'],
15+
viewer: ['read'],
1616
editor: ['read', 'read_security', 'write'],
1717
admin: ['read', 'read_security', 'write', 'write_security', 'delete'],
1818
};

src/utils/__test__/fixtures/OrganizationPermissions.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const ORGANIZATION_PERMISSIONS = [
66
component: 'organization',
77
roles: {
88
none: [],
9-
viewer: ['read', 'read_security'],
9+
viewer: ['read'],
1010
user: ['read', 'read_security', 'create_children'],
1111
editor: ['read', 'read_security', 'create_children', 'write'],
1212
admin: ['read', 'read_security', 'create_children', 'write', 'write_security', 'delete'],
@@ -16,7 +16,7 @@ export const ORGANIZATION_PERMISSIONS = [
1616
component: 'workspace',
1717
roles: {
1818
none: [],
19-
viewer: ['read', 'read_security'],
19+
viewer: ['read'],
2020
user: ['read', 'read_security', 'create_children'],
2121
editor: ['read', 'read_security', 'create_children', 'write'],
2222
admin: ['read', 'read_security', 'create_children', 'write', 'write_security', 'delete'],
@@ -26,7 +26,7 @@ export const ORGANIZATION_PERMISSIONS = [
2626
component: 'scenario',
2727
roles: {
2828
none: [],
29-
viewer: ['read', 'read_security'],
29+
viewer: ['read'],
3030
editor: ['read', 'read_security', 'launch', 'write'],
3131
validator: ['read', 'read_security', 'launch', 'write', 'validate'],
3232
admin: ['read', 'read_security', 'launch', 'write', 'validate', 'write_security', 'delete'],
@@ -37,21 +37,21 @@ export const ORGANIZATION_PERMISSIONS = [
3737
export const EXPECTED_PERMISSIONS_MAPPING = {
3838
organization: {
3939
none: [],
40-
viewer: ['read', 'read_security'],
40+
viewer: ['read'],
4141
user: ['read', 'read_security', 'create_children'],
4242
editor: ['read', 'read_security', 'create_children', 'write'],
4343
admin: ['read', 'read_security', 'create_children', 'write', 'write_security', 'delete'],
4444
},
4545
workspace: {
4646
none: [],
47-
viewer: ['read', 'read_security'],
47+
viewer: ['read'],
4848
user: ['read', 'read_security', 'create_children'],
4949
editor: ['read', 'read_security', 'create_children', 'write'],
5050
admin: ['read', 'read_security', 'create_children', 'write', 'write_security', 'delete'],
5151
},
5252
scenario: {
5353
none: [],
54-
viewer: ['read', 'read_security'],
54+
viewer: ['read'],
5555
editor: ['read', 'read_security', 'launch', 'write'],
5656
validator: ['read', 'read_security', 'launch', 'write', 'validate'],
5757
admin: ['read', 'read_security', 'launch', 'write', 'validate', 'write_security', 'delete'],

0 commit comments

Comments
 (0)