passbolt-styleguide 5.14.2 → 5.14.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/RELEASE_NOTES.md +6 -2
- package/build/css/help.min.css +2 -2
- package/build/css/public.min.css +2 -2
- package/build/css/themes/default/api_authentication.min.css +2 -2
- package/build/css/themes/default/api_cloud.min.css +2 -2
- package/build/css/themes/default/api_main.min.css +2 -2
- package/build/css/themes/default/api_reports.min.css +2 -2
- package/build/css/themes/default/api_webinstaller.min.css +2 -2
- package/build/css/themes/default/ext_app.min.css +3 -3
- package/build/css/themes/default/ext_authentication.min.css +2 -2
- package/build/css/themes/default/ext_external.min.css +2 -2
- package/build/css/themes/default/ext_in_form_cta.min.css +2 -2
- package/build/css/themes/default/ext_in_form_menu.min.css +2 -2
- package/build/css/themes/default/ext_quickaccess.min.css +2 -2
- package/build/css/themes/midgar/api_authentication.min.css +2 -2
- package/build/css/themes/midgar/api_main.min.css +2 -2
- package/build/css/themes/midgar/api_reports.min.css +2 -2
- package/build/css/themes/midgar/ext_app.min.css +3 -3
- package/build/css/themes/midgar/ext_authentication.min.css +2 -2
- package/build/css/themes/midgar/ext_in_form_cta.min.css +2 -2
- package/build/css/themes/midgar/ext_in_form_menu.min.css +2 -2
- package/build/css/themes/midgar/ext_quickaccess.min.css +2 -2
- package/build/css/themes/solarized_dark/api_authentication.min.css +2 -2
- package/build/css/themes/solarized_dark/api_main.min.css +2 -2
- package/build/css/themes/solarized_dark/api_reports.min.css +2 -2
- package/build/css/themes/solarized_dark/ext_app.min.css +3 -3
- package/build/css/themes/solarized_dark/ext_authentication.min.css +2 -2
- package/build/css/themes/solarized_dark/ext_in_form_cta.min.css +2 -2
- package/build/css/themes/solarized_dark/ext_in_form_menu.min.css +2 -2
- package/build/css/themes/solarized_dark/ext_quickaccess.min.css +2 -2
- package/build/css/themes/solarized_light/api_authentication.min.css +2 -2
- package/build/css/themes/solarized_light/api_main.min.css +2 -2
- package/build/css/themes/solarized_light/api_reports.min.css +2 -2
- package/build/css/themes/solarized_light/ext_app.min.css +3 -3
- package/build/css/themes/solarized_light/ext_authentication.min.css +2 -2
- package/build/css/themes/solarized_light/ext_in_form_cta.min.css +2 -2
- package/build/css/themes/solarized_light/ext_in_form_menu.min.css +2 -2
- package/build/css/themes/solarized_light/ext_quickaccess.min.css +2 -2
- package/build/js/dist/api-app.js +1 -1
- package/build/locales/cs-CZ/common.json +1 -1
- package/build/locales/de-DE/common.json +1 -1
- package/build/locales/en-UK/common.json +1 -1
- package/build/locales/es-ES/common.json +1 -1
- package/build/locales/fr-FR/common.json +1 -1
- package/build/locales/it-IT/common.json +1 -1
- package/build/locales/ja-JP/common.json +1 -1
- package/build/locales/ko-KR/common.json +1 -1
- package/build/locales/lt-LT/common.json +1 -1
- package/build/locales/nl-NL/common.json +1 -1
- package/build/locales/pl-PL/common.json +1 -1
- package/build/locales/pt-BR/common.json +1 -1
- package/build/locales/ro-RO/common.json +1 -1
- package/build/locales/ru-RU/common.json +1 -1
- package/build/locales/sl-SI/common.json +1 -1
- package/build/locales/sv-SE/common.json +1 -1
- package/build/locales/uk-UA/common.json +1 -1
- package/package.json +1 -1
- package/src/locales/cs-CZ/common.json +1 -1
- package/src/locales/de-DE/common.json +1 -1
- package/src/locales/en-UK/common.json +1 -1
- package/src/locales/es-ES/common.json +1 -1
- package/src/locales/fr-FR/common.json +1 -1
- package/src/locales/it-IT/common.json +1 -1
- package/src/locales/ja-JP/common.json +1 -1
- package/src/locales/ko-KR/common.json +1 -1
- package/src/locales/lt-LT/common.json +1 -1
- package/src/locales/nl-NL/common.json +1 -1
- package/src/locales/pl-PL/common.json +1 -1
- package/src/locales/pt-BR/common.json +1 -1
- package/src/locales/ro-RO/common.json +1 -1
- package/src/locales/ru-RU/common.json +1 -1
- package/src/locales/sl-SI/common.json +1 -1
- package/src/locales/sv-SE/common.json +1 -1
- package/src/locales/uk-UA/common.json +1 -1
- package/src/react-extension/components/Administration/DisplaySubscriptionKey/DisplaySubscriptionKey.js +6 -11
- package/src/react-extension/components/Administration/DisplaySubscriptionKey/DisplaySubscriptionKey.test.js +0 -28
- package/src/react-extension/components/Resource/HandlePermissionWorkflow/flows/FolderShareFlow.js +7 -7
- package/src/react-extension/components/Resource/HandlePermissionWorkflow/flows/FolderShareFlow.test.js +2 -2
- package/src/react-extension/components/Resource/HandlePermissionWorkflow/flows/ResourceCreationFlow.js +5 -6
- package/src/react-extension/components/Resource/HandlePermissionWorkflow/flows/ResourceEditFlow.js +13 -3
- package/src/react-extension/components/Resource/HandlePermissionWorkflow/flows/ResourceShareFlow.js +4 -5
- package/src/react-extension/components/Share/GroupPermissionItem.js +12 -19
- package/src/react-extension/components/Share/GroupPermissionItem.test.data.js +0 -1
- package/src/react-extension/components/Share/GroupPermissionItem.test.js +6 -14
- package/src/react-extension/components/Share/GroupPermissionItem.test.stories.js +0 -4
- package/src/react-extension/components/Share/ShareDialog.js +166 -152
- package/src/react-extension/components/Share/ShareDialog.test.data.js +185 -0
- package/src/react-extension/components/Share/ShareDialog.test.js +94 -501
- package/src/react-extension/components/Share/ShareDialog.test.stories.js +0 -3
- package/src/react-extension/contexts/ExtAppContext.js +0 -6
|
@@ -53,31 +53,16 @@ class ShareDialog extends Component {
|
|
|
53
53
|
* ComponentDidMount
|
|
54
54
|
* Invoked immediately after component is inserted into the tree.
|
|
55
55
|
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* collections instead of fetching via the port. Used by the HandlePermissionWorkflow flows
|
|
59
|
-
* to review a permission set before applying it.
|
|
56
|
+
* The dialog seeds itself from those collections instead of fetching via the port.
|
|
57
|
+
* Used by the HandlePermissionWorkflow flows to review a permission set before applying it.
|
|
60
58
|
*
|
|
61
59
|
* @return {void}
|
|
62
60
|
*/
|
|
63
61
|
async componentDidMount() {
|
|
64
|
-
if (this.
|
|
65
|
-
|
|
66
|
-
if (this.props.acoType === PermissionEntity.ACO_FOLDER) {
|
|
67
|
-
this.folders = controlledAcos;
|
|
68
|
-
} else {
|
|
69
|
-
this.resources = controlledAcos;
|
|
70
|
-
}
|
|
62
|
+
if (this.props.acoType === PermissionEntity.ACO_FOLDER) {
|
|
63
|
+
this.folders = this.buildControlledResources(this.props.initialFolders);
|
|
71
64
|
} else {
|
|
72
|
-
|
|
73
|
-
await this.findResourcesDetails();
|
|
74
|
-
}
|
|
75
|
-
if (this.props.context.shareDialogProps.foldersIds) {
|
|
76
|
-
this.folders = await this.props.context.port.request(
|
|
77
|
-
"passbolt.share.get-folders",
|
|
78
|
-
this.props.context.shareDialogProps.foldersIds,
|
|
79
|
-
);
|
|
80
|
-
}
|
|
65
|
+
this.resources = this.buildControlledResources(this.props.initialResources);
|
|
81
66
|
}
|
|
82
67
|
|
|
83
68
|
this.shareChanges = new ShareChanges(this.resources, this.folders);
|
|
@@ -97,14 +82,6 @@ class ShareDialog extends Component {
|
|
|
97
82
|
});
|
|
98
83
|
}
|
|
99
84
|
|
|
100
|
-
/**
|
|
101
|
-
* True when the dialog is operated by the workflow handler with controlled-mode props.
|
|
102
|
-
* @returns {boolean}
|
|
103
|
-
*/
|
|
104
|
-
isControlledMode() {
|
|
105
|
-
return Boolean(this.props.initialResources);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
85
|
/**
|
|
109
86
|
* True when the dialog is displayed read-only: the operator can review the permission set and
|
|
110
87
|
* confirm it as-is but cannot change it. Used by the edit workflow when the operator has update
|
|
@@ -123,7 +100,7 @@ class ShareDialog extends Component {
|
|
|
123
100
|
* real resources. The user/group lookup maps are built once and shared across resources.
|
|
124
101
|
* @returns {Array<object>}
|
|
125
102
|
*/
|
|
126
|
-
buildControlledResources() {
|
|
103
|
+
buildControlledResources(resourcesList) {
|
|
127
104
|
const groupsById = {};
|
|
128
105
|
this.props.initialGroups?.items.forEach((group) => {
|
|
129
106
|
groupsById[group.id] = group.toDto();
|
|
@@ -133,7 +110,7 @@ class ShareDialog extends Component {
|
|
|
133
110
|
usersById[user.id] = user.toDto(this.props.initialUsers.entityClass?.ALL_CONTAIN_OPTIONS);
|
|
134
111
|
});
|
|
135
112
|
|
|
136
|
-
return
|
|
113
|
+
return resourcesList.map((resource) => this.buildControlledResource(resource, groupsById, usersById));
|
|
137
114
|
}
|
|
138
115
|
|
|
139
116
|
/**
|
|
@@ -189,6 +166,8 @@ class ShareDialog extends Component {
|
|
|
189
166
|
|
|
190
167
|
// autocomplete
|
|
191
168
|
autocompleteOpen: false,
|
|
169
|
+
|
|
170
|
+
isFetchingGroupMembers: false,
|
|
192
171
|
};
|
|
193
172
|
}
|
|
194
173
|
|
|
@@ -212,23 +191,6 @@ class ShareDialog extends Component {
|
|
|
212
191
|
this.renderContainer = this.renderContainer.bind(this);
|
|
213
192
|
}
|
|
214
193
|
|
|
215
|
-
/**
|
|
216
|
-
* Find the resources details.
|
|
217
|
-
* Close the dialog in case of error.
|
|
218
|
-
* @returns {Promise<void>}
|
|
219
|
-
*/
|
|
220
|
-
async findResourcesDetails() {
|
|
221
|
-
try {
|
|
222
|
-
this.resources = await this.props.context.port.request(
|
|
223
|
-
"passbolt.resources.find-all-by-ids-for-display-permissions",
|
|
224
|
-
this.props.context.shareDialogProps.resourcesIds,
|
|
225
|
-
);
|
|
226
|
-
} catch (error) {
|
|
227
|
-
this.handleError(error);
|
|
228
|
-
this.props.onClose();
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
194
|
/**
|
|
233
195
|
* Handle close button click.
|
|
234
196
|
* @returns {void}
|
|
@@ -274,6 +236,10 @@ class ShareDialog extends Component {
|
|
|
274
236
|
return;
|
|
275
237
|
}
|
|
276
238
|
|
|
239
|
+
if (this.state.isFetchingGroupMembers) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
|
|
277
243
|
this.setState({ processing: true });
|
|
278
244
|
try {
|
|
279
245
|
await this.shareSave();
|
|
@@ -292,15 +258,8 @@ class ShareDialog extends Component {
|
|
|
292
258
|
* when this dialog closes — so we only close.
|
|
293
259
|
*/
|
|
294
260
|
async handleSaveSuccess() {
|
|
295
|
-
if (this.isControlledMode()) {
|
|
296
|
-
this.props.onClose();
|
|
297
|
-
return;
|
|
298
|
-
}
|
|
299
|
-
await this.props.actionFeedbackContext.displaySuccess(
|
|
300
|
-
this.translate("The permissions have been changed successfully."),
|
|
301
|
-
);
|
|
302
|
-
await this.props.resourceWorkspaceContext.onResourceShared();
|
|
303
261
|
this.props.onClose();
|
|
262
|
+
return;
|
|
304
263
|
}
|
|
305
264
|
|
|
306
265
|
/**
|
|
@@ -333,6 +292,10 @@ class ShareDialog extends Component {
|
|
|
333
292
|
return;
|
|
334
293
|
}
|
|
335
294
|
|
|
295
|
+
if (!aro.profile && !this.hasFetchedGroupMembers(aro.id)) {
|
|
296
|
+
this.fetchGroupMembers(aro.id);
|
|
297
|
+
}
|
|
298
|
+
|
|
336
299
|
// TODO restore to original permission if any
|
|
337
300
|
const permission = this.shareChanges.addAroPermissions(aro);
|
|
338
301
|
permission.updated = this.shareChanges.hasChanges(aro.id);
|
|
@@ -385,12 +348,6 @@ class ShareDialog extends Component {
|
|
|
385
348
|
expandedGroupIds.delete(groupId);
|
|
386
349
|
} else {
|
|
387
350
|
expandedGroupIds.add(groupId);
|
|
388
|
-
// Groups added during the dialog session are not in initialGroups and carry no members yet;
|
|
389
|
-
// fetch them lazily the first time they are expanded. Members render once the fetch resolves.
|
|
390
|
-
const isInitialGroup = this.props.initialGroups?.items.some((item) => item.id === groupId);
|
|
391
|
-
if (!isInitialGroup && !this.state.fetchedGroupMembers[groupId]) {
|
|
392
|
-
this.fetchGroupMembers(groupId);
|
|
393
|
-
}
|
|
394
351
|
}
|
|
395
352
|
this.setState({ expandedGroupIds: [...expandedGroupIds] });
|
|
396
353
|
}
|
|
@@ -401,22 +358,33 @@ class ShareDialog extends Component {
|
|
|
401
358
|
* cache (falling back to the API). A failure leaves the group with no displayed members rather than
|
|
402
359
|
* interrupting the dialog with an error popup.
|
|
403
360
|
* @param {string} groupId The group identifier
|
|
404
|
-
* @returns {Promise<void>}
|
|
405
361
|
*/
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
362
|
+
fetchGroupMembers(groupId) {
|
|
363
|
+
this.setState({ isFetchingGroupMembers: true }, async () => {
|
|
364
|
+
try {
|
|
365
|
+
const groupServiceWorkerService = new GroupServiceWorkerService(this.props.context.port);
|
|
366
|
+
const userServiceWorkerService = new UserServiceWorkerService(this.props.context.port);
|
|
367
|
+
const groupsUsers = await groupServiceWorkerService.getGroupsUsersByGroupId(groupId);
|
|
368
|
+
const memberUserIds = groupsUsers.items.map((groupUser) => groupUser.userId);
|
|
369
|
+
const users = await userServiceWorkerService.getByIds(memberUserIds);
|
|
370
|
+
const members = users.items.map((user) => user.toDto(users.entityClass?.ALL_CONTAIN_OPTIONS));
|
|
371
|
+
this.setState({
|
|
372
|
+
fetchedGroupMembers: { ...this.state.fetchedGroupMembers, [groupId]: members },
|
|
373
|
+
isFetchingGroupMembers: false,
|
|
374
|
+
});
|
|
375
|
+
} catch (error) {
|
|
376
|
+
console.error(error);
|
|
377
|
+
}
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Returns true if the given group has already its members fetched
|
|
383
|
+
* @param {string} groupId
|
|
384
|
+
* @returns {boolean}
|
|
385
|
+
*/
|
|
386
|
+
hasFetchedGroupMembers(groupId) {
|
|
387
|
+
return Boolean(this.state.fetchedGroupMembers[groupId]);
|
|
420
388
|
}
|
|
421
389
|
|
|
422
390
|
/**
|
|
@@ -429,7 +397,7 @@ class ShareDialog extends Component {
|
|
|
429
397
|
*/
|
|
430
398
|
getGroupMembers(groupId) {
|
|
431
399
|
// Groups added during the dialog session have their members fetched on demand and cached.
|
|
432
|
-
if (this.
|
|
400
|
+
if (this.hasFetchedGroupMembers(groupId)) {
|
|
433
401
|
return this.state.fetchedGroupMembers[groupId];
|
|
434
402
|
}
|
|
435
403
|
const group = this.props.initialGroups?.items.find((item) => item.id === groupId);
|
|
@@ -455,7 +423,7 @@ class ShareDialog extends Component {
|
|
|
455
423
|
return;
|
|
456
424
|
}
|
|
457
425
|
displayedPermissions.push({ kind: "group", permission });
|
|
458
|
-
if (this.
|
|
426
|
+
if (this.state.expandedGroupIds.includes(permission.aro.id)) {
|
|
459
427
|
this.getGroupMembers(permission.aro.id).forEach((user) => {
|
|
460
428
|
displayedPermissions.push({ kind: "group-user", user, groupId: permission.aro.id });
|
|
461
429
|
});
|
|
@@ -470,32 +438,14 @@ class ShareDialog extends Component {
|
|
|
470
438
|
* @returns {Promise<void>}
|
|
471
439
|
*/
|
|
472
440
|
async shareSave() {
|
|
473
|
-
if (this.
|
|
474
|
-
|
|
475
|
-
this.props.acoType === PermissionEntity.ACO_FOLDER
|
|
476
|
-
? this.shareChanges.getFoldersChanges()
|
|
477
|
-
: this.shareChanges.getResourcesChanges();
|
|
478
|
-
await this.props.onConfirm(changes);
|
|
441
|
+
if (this.props.acoType === PermissionEntity.ACO_FOLDER) {
|
|
442
|
+
await this.props.onConfirm(this.shareChanges.getFoldersChanges(), this.canOperatorRead());
|
|
479
443
|
return;
|
|
480
444
|
}
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
await this.props.context.port.request(
|
|
486
|
-
"passbolt.share.resources.save",
|
|
487
|
-
this.props.context.shareDialogProps.resourcesIds,
|
|
488
|
-
this.shareChanges.getResourcesChanges(),
|
|
489
|
-
);
|
|
490
|
-
return;
|
|
491
|
-
}
|
|
492
|
-
if (this.props.context.shareDialogProps.foldersIds) {
|
|
493
|
-
await this.props.context.port.request(
|
|
494
|
-
"passbolt.share.folders.save",
|
|
495
|
-
this.props.context.shareDialogProps.foldersIds[0],
|
|
496
|
-
this.shareChanges.getFoldersChanges(),
|
|
497
|
-
);
|
|
498
|
-
}
|
|
445
|
+
|
|
446
|
+
const changes = this.shareChanges.getResourcesChanges();
|
|
447
|
+
const isPersonal = this.state.permissions.length === 1 && Boolean(this.state.permissions[0].aro.profile);
|
|
448
|
+
await this.props.onConfirm(changes, this.canOperatorRead(), isPersonal);
|
|
499
449
|
}
|
|
500
450
|
|
|
501
451
|
/**
|
|
@@ -537,12 +487,7 @@ class ShareDialog extends Component {
|
|
|
537
487
|
* @returns {boolean}
|
|
538
488
|
*/
|
|
539
489
|
isAboutItems() {
|
|
540
|
-
return
|
|
541
|
-
this.props.context.shareDialogProps?.resourcesIds &&
|
|
542
|
-
this.props.context.shareDialogProps?.foldersIds &&
|
|
543
|
-
this.props.context.shareDialogProps.resourcesIds.length &&
|
|
544
|
-
this.props.context.shareDialogProps.foldersIds.length
|
|
545
|
-
);
|
|
490
|
+
return this.props.initialResources?.length && this.props.initialFolders?.length;
|
|
546
491
|
}
|
|
547
492
|
|
|
548
493
|
/**
|
|
@@ -550,9 +495,7 @@ class ShareDialog extends Component {
|
|
|
550
495
|
* @returns {boolean}
|
|
551
496
|
*/
|
|
552
497
|
isAboutResources() {
|
|
553
|
-
return
|
|
554
|
-
this.props.context.shareDialogProps?.resourcesIds && this.props.context.shareDialogProps.resourcesIds.length > 1
|
|
555
|
-
);
|
|
498
|
+
return this.props.initialResources?.length > 1;
|
|
556
499
|
}
|
|
557
500
|
|
|
558
501
|
/**
|
|
@@ -560,7 +503,7 @@ class ShareDialog extends Component {
|
|
|
560
503
|
* @returns {boolean}
|
|
561
504
|
*/
|
|
562
505
|
isAboutFolders() {
|
|
563
|
-
return this.props.
|
|
506
|
+
return this.props.initialFolders?.length > 1;
|
|
564
507
|
}
|
|
565
508
|
|
|
566
509
|
/**
|
|
@@ -568,9 +511,7 @@ class ShareDialog extends Component {
|
|
|
568
511
|
* @returns {boolean}
|
|
569
512
|
*/
|
|
570
513
|
isAboutAFolder() {
|
|
571
|
-
return
|
|
572
|
-
this.props.context.shareDialogProps?.foldersIds && this.props.context.shareDialogProps.foldersIds.length === 1
|
|
573
|
-
);
|
|
514
|
+
return this.props.initialFolders?.length === 1;
|
|
574
515
|
}
|
|
575
516
|
|
|
576
517
|
/**
|
|
@@ -578,9 +519,7 @@ class ShareDialog extends Component {
|
|
|
578
519
|
* @returns {boolean}
|
|
579
520
|
*/
|
|
580
521
|
isAboutAResource() {
|
|
581
|
-
return
|
|
582
|
-
this.props.context.shareDialogProps?.resourcesIds && this.props.context.shareDialogProps.resourcesIds.length === 1
|
|
583
|
-
);
|
|
522
|
+
return this.props.initialResources?.length === 1;
|
|
584
523
|
}
|
|
585
524
|
|
|
586
525
|
/**
|
|
@@ -594,14 +533,9 @@ class ShareDialog extends Component {
|
|
|
594
533
|
if (this.props.isPermissionConfirmationMode) {
|
|
595
534
|
return this.translate("Confirm permissions");
|
|
596
535
|
}
|
|
597
|
-
if (this.isControlledMode()) {
|
|
598
|
-
return this.translate("Share");
|
|
599
|
-
}
|
|
600
536
|
if (this.isAboutItems()) {
|
|
601
537
|
return this.translate("Share {{count}} items", {
|
|
602
|
-
count:
|
|
603
|
-
this.props.context.shareDialogProps.resourcesIds.length +
|
|
604
|
-
this.props.context.shareDialogProps.foldersIds.length,
|
|
538
|
+
count: this.props.initialResources.length + this.props.initialFolders.length,
|
|
605
539
|
});
|
|
606
540
|
}
|
|
607
541
|
if (this.isAboutAResource()) {
|
|
@@ -609,7 +543,7 @@ class ShareDialog extends Component {
|
|
|
609
543
|
}
|
|
610
544
|
if (this.isAboutResources()) {
|
|
611
545
|
return this.translate("Share {{count}} resources", {
|
|
612
|
-
count: this.props.
|
|
546
|
+
count: this.props.initialResources.length,
|
|
613
547
|
});
|
|
614
548
|
}
|
|
615
549
|
if (this.isAboutAFolder()) {
|
|
@@ -617,7 +551,7 @@ class ShareDialog extends Component {
|
|
|
617
551
|
}
|
|
618
552
|
if (this.isAboutFolders()) {
|
|
619
553
|
return this.translate("Share {{count}} folders", {
|
|
620
|
-
count: this.props.
|
|
554
|
+
count: this.props.initialFolders.length,
|
|
621
555
|
});
|
|
622
556
|
}
|
|
623
557
|
}
|
|
@@ -627,14 +561,14 @@ class ShareDialog extends Component {
|
|
|
627
561
|
* @returns {string}
|
|
628
562
|
*/
|
|
629
563
|
getSubtitle() {
|
|
630
|
-
if (this.state.loading
|
|
564
|
+
if (this.state.loading) {
|
|
631
565
|
return;
|
|
632
566
|
}
|
|
633
567
|
if (this.isAboutAResource()) {
|
|
634
568
|
return this.resources[0].metadata.name;
|
|
635
569
|
}
|
|
636
570
|
if (this.isAboutAFolder()) {
|
|
637
|
-
return this.folders[0].name;
|
|
571
|
+
return this.folders[0].metadata.name;
|
|
638
572
|
}
|
|
639
573
|
}
|
|
640
574
|
|
|
@@ -683,13 +617,7 @@ class ShareDialog extends Component {
|
|
|
683
617
|
* @returns {boolean}
|
|
684
618
|
*/
|
|
685
619
|
hasSubmitDisabled() {
|
|
686
|
-
|
|
687
|
-
return true;
|
|
688
|
-
}
|
|
689
|
-
if (this.isControlledMode()) {
|
|
690
|
-
return false;
|
|
691
|
-
}
|
|
692
|
-
return !this.hasChanges();
|
|
620
|
+
return this.hasNoOwner() || this.operatorOwnershipIsInvalid() || this.hasAllInputDisabled();
|
|
693
621
|
}
|
|
694
622
|
|
|
695
623
|
/**
|
|
@@ -717,7 +645,7 @@ class ShareDialog extends Component {
|
|
|
717
645
|
id={permission.aro.id}
|
|
718
646
|
key={permission.aro.id}
|
|
719
647
|
group={permission.aro}
|
|
720
|
-
membersCount={this.
|
|
648
|
+
membersCount={this.getGroupMembers(permission.aro.id).length}
|
|
721
649
|
permissionType={permissionType}
|
|
722
650
|
variesDetails={permission.variesDetails}
|
|
723
651
|
updated={permission.updated}
|
|
@@ -726,7 +654,6 @@ class ShareDialog extends Component {
|
|
|
726
654
|
onDelete={this.handlePermissionDelete}
|
|
727
655
|
onToggleGroupMemberVisibility={this.handleToggleGroupMemberVisibility}
|
|
728
656
|
shouldDisplayGroupMembers={this.state.expandedGroupIds.includes(permission.aro.id)}
|
|
729
|
-
canDisplayGroupMembers={this.isControlledMode()}
|
|
730
657
|
isReadOnly={this.props.readOnly}
|
|
731
658
|
/>
|
|
732
659
|
);
|
|
@@ -762,6 +689,76 @@ class ShareDialog extends Component {
|
|
|
762
689
|
);
|
|
763
690
|
}
|
|
764
691
|
|
|
692
|
+
/**
|
|
693
|
+
* Returns true if the operator ownership requirement is not met.
|
|
694
|
+
* If the props asks to ensure that the current operator must have ownership on the resource
|
|
695
|
+
* then a verification is ensured that the operator has ownership through a direct permission
|
|
696
|
+
* or from at least a group permissions.
|
|
697
|
+
* If the requirement is not enforce by the props this method considers the requirement has met
|
|
698
|
+
* and returns false has there is no error.
|
|
699
|
+
* @returns {boolean}
|
|
700
|
+
*/
|
|
701
|
+
operatorOwnershipIsInvalid() {
|
|
702
|
+
if (!this.props.ensureOperatorIsOwner) {
|
|
703
|
+
return false;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
if (!this.state.permissions?.length) {
|
|
707
|
+
return true;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
const operatorId = this.props.context.loggedInUser?.id;
|
|
711
|
+
const operatorOwnerPermission = this.state.permissions.find((p) => {
|
|
712
|
+
// no need to check non owner permission
|
|
713
|
+
if (p.type !== PermissionEntity.PERMISSION_OWNER) {
|
|
714
|
+
return false;
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
//we are dealing with a direct user permission here
|
|
718
|
+
if (p.aro.profile) {
|
|
719
|
+
if (operatorId === p.aro.id) {
|
|
720
|
+
// the current oeprator has a direct OWNER permission in the list
|
|
721
|
+
return true;
|
|
722
|
+
}
|
|
723
|
+
// we ignore direct user permission that are not the operator user
|
|
724
|
+
return false;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
const groupMembers = this.getGroupMembers(p.aro.id);
|
|
728
|
+
const operatorGroupMember = groupMembers.find((gm) => gm.id === operatorId);
|
|
729
|
+
return Boolean(operatorGroupMember);
|
|
730
|
+
});
|
|
731
|
+
return !operatorOwnerPermission;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
/**
|
|
735
|
+
* Returns true if the operator has permission to at least read the resource
|
|
736
|
+
* @returns {boolean}
|
|
737
|
+
*/
|
|
738
|
+
canOperatorRead() {
|
|
739
|
+
if (!this.state.permissions?.length) {
|
|
740
|
+
return false;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
const operatorId = this.props.context.loggedInUser?.id;
|
|
744
|
+
const operatorPermission = this.state.permissions.find((p) => {
|
|
745
|
+
//we are dealing with a direct user permission here
|
|
746
|
+
if (p.aro.profile) {
|
|
747
|
+
if (operatorId === p.aro.id) {
|
|
748
|
+
// the current oeprator has a permission in the list
|
|
749
|
+
return true;
|
|
750
|
+
}
|
|
751
|
+
// we ignore direct user permission that are not the operator user
|
|
752
|
+
return false;
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
const groupMembers = this.getGroupMembers(p.aro.id);
|
|
756
|
+
const operatorGroupMember = groupMembers.find((gm) => gm.id === operatorId);
|
|
757
|
+
return Boolean(operatorGroupMember);
|
|
758
|
+
});
|
|
759
|
+
return Boolean(operatorPermission);
|
|
760
|
+
}
|
|
761
|
+
|
|
765
762
|
/**
|
|
766
763
|
* Returns true if the feature flag disableUser is enabled.
|
|
767
764
|
* @returns {boolean}
|
|
@@ -785,6 +782,9 @@ class ShareDialog extends Component {
|
|
|
785
782
|
render() {
|
|
786
783
|
// Computed once per render so ReactList's length and itemRenderer read the same list.
|
|
787
784
|
const displayedPermissions = this.state.loading ? [] : this.getDisplayedPermissions();
|
|
785
|
+
const isReadOnly = this.isReadOnly();
|
|
786
|
+
const operatorOwnershipIsInvalid = !isReadOnly && this.operatorOwnershipIsInvalid();
|
|
787
|
+
const hasNoOwner = !isReadOnly && this.hasNoOwner();
|
|
788
788
|
return (
|
|
789
789
|
<DialogWrapper
|
|
790
790
|
className="share-dialog"
|
|
@@ -834,15 +834,24 @@ class ShareDialog extends Component {
|
|
|
834
834
|
/>
|
|
835
835
|
</div>
|
|
836
836
|
)}
|
|
837
|
-
{!
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
837
|
+
{!isReadOnly && (
|
|
838
|
+
<>
|
|
839
|
+
{operatorOwnershipIsInvalid && (
|
|
840
|
+
<div className="message error">
|
|
841
|
+
<Trans>Please make sure you are still owner.</Trans>
|
|
842
|
+
</div>
|
|
843
|
+
)}
|
|
844
|
+
{!operatorOwnershipIsInvalid && hasNoOwner && (
|
|
845
|
+
<div className="message error">
|
|
846
|
+
<Trans>Please make sure there is at least one owner.</Trans>
|
|
847
|
+
</div>
|
|
848
|
+
)}
|
|
849
|
+
{this.hasChanges() && !hasNoOwner && !operatorOwnershipIsInvalid && (
|
|
850
|
+
<div className="message warning">
|
|
851
|
+
<Trans>Click save to apply your pending changes.</Trans>
|
|
852
|
+
</div>
|
|
853
|
+
)}
|
|
854
|
+
</>
|
|
846
855
|
)}
|
|
847
856
|
</div>
|
|
848
857
|
<div className="submit-wrapper">
|
|
@@ -863,6 +872,9 @@ ShareDialog.defaultProps = {
|
|
|
863
872
|
listMinSize: 4,
|
|
864
873
|
isPermissionConfirmationMode: true,
|
|
865
874
|
initialChanges: [],
|
|
875
|
+
ensureOperatorIsOwner: false,
|
|
876
|
+
initialResources: [],
|
|
877
|
+
initialFolders: [],
|
|
866
878
|
};
|
|
867
879
|
|
|
868
880
|
ShareDialog.propTypes = {
|
|
@@ -873,13 +885,15 @@ ShareDialog.propTypes = {
|
|
|
873
885
|
dialogContext: PropTypes.any, // The dialog context
|
|
874
886
|
listMinSize: PropTypes.number, // The minimum size to be renderered in the permission list
|
|
875
887
|
isPermissionConfirmationMode: PropTypes.bool, // Is the dialog used to confirm permissions
|
|
876
|
-
initialResources: PropTypes.array, //
|
|
888
|
+
initialResources: PropTypes.array, // the ACO resources to seed the dialog with instead of fetching from the API, each as { id, metadata, permission, permissions: PermissionsCollection }
|
|
889
|
+
initialFolders: PropTypes.array, // the ACO folders to see the dialog with
|
|
877
890
|
initialChanges: PropTypes.array, // Set of permission to mark them as "modified" in the initial list
|
|
878
|
-
acoType: PropTypes.string, //
|
|
879
|
-
initialGroups: PropTypes.object, //
|
|
880
|
-
initialUsers: PropTypes.object, //
|
|
881
|
-
onConfirm: PropTypes.func, //
|
|
882
|
-
readOnly: PropTypes.bool, //
|
|
891
|
+
acoType: PropTypes.string, // the ACO type of the seeded entries (PermissionEntity.ACO_RESOURCE, default, or ACO_FOLDER)
|
|
892
|
+
initialGroups: PropTypes.object, // GroupsCollection providing the groups referenced by the resources' permissions
|
|
893
|
+
initialUsers: PropTypes.object, // UsersCollection providing the users referenced by the resources' permissions
|
|
894
|
+
onConfirm: PropTypes.func, // callback invoked with the operator-confirmed permission changes instead of saving via the port
|
|
895
|
+
readOnly: PropTypes.bool, // display the permission set read-only (review/confirm only, no edits)
|
|
896
|
+
ensureOperatorIsOwner: PropTypes.bool, // Ensure the operator remains owner of the edited resource
|
|
883
897
|
t: PropTypes.func, // The translation function
|
|
884
898
|
};
|
|
885
899
|
|