passbolt-styleguide 5.14.2 → 5.14.5

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.
Files changed (101) hide show
  1. package/RELEASE_NOTES.md +6 -2
  2. package/build/css/help.min.css +2 -2
  3. package/build/css/public.min.css +2 -2
  4. package/build/css/themes/default/api_authentication.min.css +2 -2
  5. package/build/css/themes/default/api_cloud.min.css +2 -2
  6. package/build/css/themes/default/api_main.min.css +2 -2
  7. package/build/css/themes/default/api_reports.min.css +2 -2
  8. package/build/css/themes/default/api_webinstaller.min.css +2 -2
  9. package/build/css/themes/default/ext_app.min.css +3 -3
  10. package/build/css/themes/default/ext_authentication.min.css +2 -2
  11. package/build/css/themes/default/ext_external.min.css +2 -2
  12. package/build/css/themes/default/ext_in_form_cta.min.css +2 -2
  13. package/build/css/themes/default/ext_in_form_menu.min.css +2 -2
  14. package/build/css/themes/default/ext_quickaccess.min.css +2 -2
  15. package/build/css/themes/midgar/api_authentication.min.css +2 -2
  16. package/build/css/themes/midgar/api_main.min.css +2 -2
  17. package/build/css/themes/midgar/api_reports.min.css +2 -2
  18. package/build/css/themes/midgar/ext_app.min.css +3 -3
  19. package/build/css/themes/midgar/ext_authentication.min.css +2 -2
  20. package/build/css/themes/midgar/ext_in_form_cta.min.css +2 -2
  21. package/build/css/themes/midgar/ext_in_form_menu.min.css +2 -2
  22. package/build/css/themes/midgar/ext_quickaccess.min.css +2 -2
  23. package/build/css/themes/solarized_dark/api_authentication.min.css +2 -2
  24. package/build/css/themes/solarized_dark/api_main.min.css +2 -2
  25. package/build/css/themes/solarized_dark/api_reports.min.css +2 -2
  26. package/build/css/themes/solarized_dark/ext_app.min.css +3 -3
  27. package/build/css/themes/solarized_dark/ext_authentication.min.css +2 -2
  28. package/build/css/themes/solarized_dark/ext_in_form_cta.min.css +2 -2
  29. package/build/css/themes/solarized_dark/ext_in_form_menu.min.css +2 -2
  30. package/build/css/themes/solarized_dark/ext_quickaccess.min.css +2 -2
  31. package/build/css/themes/solarized_light/api_authentication.min.css +2 -2
  32. package/build/css/themes/solarized_light/api_main.min.css +2 -2
  33. package/build/css/themes/solarized_light/api_reports.min.css +2 -2
  34. package/build/css/themes/solarized_light/ext_app.min.css +3 -3
  35. package/build/css/themes/solarized_light/ext_authentication.min.css +2 -2
  36. package/build/css/themes/solarized_light/ext_in_form_cta.min.css +2 -2
  37. package/build/css/themes/solarized_light/ext_in_form_menu.min.css +2 -2
  38. package/build/css/themes/solarized_light/ext_quickaccess.min.css +2 -2
  39. package/build/js/dist/api-app.js +1 -1
  40. package/build/locales/cs-CZ/common.json +1 -1
  41. package/build/locales/de-DE/common.json +1 -1
  42. package/build/locales/en-UK/common.json +1 -1
  43. package/build/locales/es-ES/common.json +1 -1
  44. package/build/locales/fr-FR/common.json +1 -1
  45. package/build/locales/it-IT/common.json +1 -1
  46. package/build/locales/ja-JP/common.json +1 -1
  47. package/build/locales/ko-KR/common.json +1 -1
  48. package/build/locales/lt-LT/common.json +1 -1
  49. package/build/locales/nl-NL/common.json +1 -1
  50. package/build/locales/pl-PL/common.json +1 -1
  51. package/build/locales/pt-BR/common.json +1 -1
  52. package/build/locales/ro-RO/common.json +1 -1
  53. package/build/locales/ru-RU/common.json +1 -1
  54. package/build/locales/sl-SI/common.json +1 -1
  55. package/build/locales/sv-SE/common.json +1 -1
  56. package/build/locales/uk-UA/common.json +1 -1
  57. package/package.json +1 -1
  58. package/src/locales/cs-CZ/common.json +1 -1
  59. package/src/locales/de-DE/common.json +1 -1
  60. package/src/locales/en-UK/common.json +1 -1
  61. package/src/locales/es-ES/common.json +1 -1
  62. package/src/locales/fr-FR/common.json +1 -1
  63. package/src/locales/it-IT/common.json +1 -1
  64. package/src/locales/ja-JP/common.json +1 -1
  65. package/src/locales/ko-KR/common.json +1 -1
  66. package/src/locales/lt-LT/common.json +1 -1
  67. package/src/locales/nl-NL/common.json +1 -1
  68. package/src/locales/pl-PL/common.json +1 -1
  69. package/src/locales/pt-BR/common.json +1 -1
  70. package/src/locales/ro-RO/common.json +1 -1
  71. package/src/locales/ru-RU/common.json +1 -1
  72. package/src/locales/sl-SI/common.json +1 -1
  73. package/src/locales/sv-SE/common.json +1 -1
  74. package/src/locales/uk-UA/common.json +1 -1
  75. package/src/react-extension/components/Administration/DisplaySubscriptionKey/DisplaySubscriptionKey.js +6 -11
  76. package/src/react-extension/components/Administration/DisplaySubscriptionKey/DisplaySubscriptionKey.test.js +0 -28
  77. package/src/react-extension/components/Resource/HandlePermissionWorkflow/flows/FolderShareFlow.js +7 -7
  78. package/src/react-extension/components/Resource/HandlePermissionWorkflow/flows/FolderShareFlow.test.js +6 -9
  79. package/src/react-extension/components/Resource/HandlePermissionWorkflow/flows/ResourceCreationFlow.js +17 -24
  80. package/src/react-extension/components/Resource/HandlePermissionWorkflow/flows/ResourceCreationFlow.test.js +15 -17
  81. package/src/react-extension/components/Resource/HandlePermissionWorkflow/flows/ResourceEditFlow.js +23 -17
  82. package/src/react-extension/components/Resource/HandlePermissionWorkflow/flows/ResourceEditFlow.test.js +18 -31
  83. package/src/react-extension/components/Resource/HandlePermissionWorkflow/flows/ResourceShareFlow.js +4 -5
  84. package/src/react-extension/components/Resource/HandlePermissionWorkflow/flows/ResourceShareFlow.test.js +14 -22
  85. package/src/react-extension/components/Share/GroupPermissionItem.js +12 -19
  86. package/src/react-extension/components/Share/GroupPermissionItem.test.data.js +0 -1
  87. package/src/react-extension/components/Share/GroupPermissionItem.test.js +6 -14
  88. package/src/react-extension/components/Share/GroupPermissionItem.test.stories.js +0 -4
  89. package/src/react-extension/components/Share/ShareDialog.js +176 -159
  90. package/src/react-extension/components/Share/ShareDialog.test.data.js +241 -8
  91. package/src/react-extension/components/Share/ShareDialog.test.js +108 -505
  92. package/src/react-extension/components/Share/ShareDialog.test.stories.js +0 -3
  93. package/src/react-extension/contexts/ExtAppContext.js +0 -6
  94. package/src/react-extension/contexts/WorkflowContext.js +4 -0
  95. package/src/shared/models/entity/groupUser/groupUserEntity.js +52 -6
  96. package/src/shared/models/entity/groupUser/groupUserEntity.test.data.js +5 -0
  97. package/src/shared/models/entity/groupUser/groupUserEntity.test.js +54 -0
  98. package/src/shared/services/permission/permissionSnapshotService.js +20 -20
  99. package/src/shared/services/permission/permissionSnapshotService.test.js +77 -53
  100. package/src/shared/services/serviceWorker/group/groupServiceWorkerService.js +6 -18
  101. package/src/shared/services/serviceWorker/group/groupServiceWorkerService.test.js +13 -27
@@ -822,7 +822,6 @@
822
822
  "Move": "Flytta",
823
823
  "Multi factor authentication": "Multi-faktor autentisering",
824
824
  "Multi Factor Authentication": "Multi-faktor autentisering",
825
- "Multi resource and folder share is not implemented.": "Multi-resurs och mappdelning är inte implementerat.",
826
825
  "Multi-factor authentication (MFA) is a method of confirming a user's identity that requires presenting two or more pieces of evidence (or factor).": "Multi-faktor autentisering (MFA) är en metod för att bekräfta en användares identitet som kräver att två eller fler bevis(eller faktorer) presenteras.",
827
826
  "Multi-factor authentication has been disabled successfully": "Multi-faktor autentisering har inaktiverats framgångsrikt",
828
827
  "My Profile": "Min profil",
@@ -1011,6 +1010,7 @@
1011
1010
  "Please install the browser extension.": "Vänligen installera tillägget till webbläsaren.",
1012
1011
  "Please make sure there is at least one group manager.": "Vänligen se till att det finns minst en gruppchef.",
1013
1012
  "Please make sure there is at least one owner.": "Vänligen se till att det finns minst en ägare.",
1013
+ "Please make sure you are still owner.": "Kontrollera att du fortfarande är ägare.",
1014
1014
  "Please review carefully this configuration as it will not be trivial to change this later.": "Granska konfigurationen noggrant eftersom den inte blir enkel att ändra senare.",
1015
1015
  "Please review carefully this configuration.": "Granska konfigurationen noggrant.",
1016
1016
  "Please save the settings to disable the feature.": "Spara inställningarna för att inaktivera funktionen.",
@@ -822,7 +822,6 @@
822
822
  "Move": "Перемістити",
823
823
  "Multi factor authentication": "Багатофакторна автентифікація",
824
824
  "Multi Factor Authentication": "Багатофакторна автентифікація",
825
- "Multi resource and folder share is not implemented.": "Спільне використання декількох ресурсів та тек не реалізовано.",
826
825
  "Multi-factor authentication (MFA) is a method of confirming a user's identity that requires presenting two or more pieces of evidence (or factor).": "Багатофакторна автентифікація (MFA) — це метод підтвердження особи користувача, який потребує два або більше факторів аутентифікації.",
827
826
  "Multi-factor authentication has been disabled successfully": "Багатофакторна автентифікація була успішно вимкнена",
828
827
  "My Profile": "Мій профіль",
@@ -1011,6 +1010,7 @@
1011
1010
  "Please install the browser extension.": "Будь ласка, встановіть розширення для браузера.",
1012
1011
  "Please make sure there is at least one group manager.": "Будь ласка, переконайтеся, що є принаймні один менеджер групи.",
1013
1012
  "Please make sure there is at least one owner.": "Будь ласка, переконайтеся, що є принаймні один власник.",
1013
+ "Please make sure you are still owner.": "Будь ласка, переконайтеся, що ви все ще є власником.",
1014
1014
  "Please review carefully this configuration as it will not be trivial to change this later.": "Будь ласка, ретельно перевірте цю конфігурацію, оскільки пізніше її не буде просто змінити.",
1015
1015
  "Please review carefully this configuration.": "Будь ласка, ретельно перевірте цю конфігурацію.",
1016
1016
  "Please save the settings to disable the feature.": "Будь ласка, збережіть налаштування, щоб вимкнути функцію.",
@@ -102,16 +102,11 @@ class DisplaySubscriptionKey extends React.Component {
102
102
  * Open the EditSubscriptionKey dialog to upload a new subscription key (CE to PRO upgrade).
103
103
  */
104
104
  handleAddSubscriptionKey() {
105
- if (this.hasEditionPlugin()) {
106
- this.props.dialogContext.open(EditSubscriptionKey, {
107
- title: this.props.t("New subscription key"),
108
- onSave: this.handleSaveSubscriptionKey,
109
- warning: this.translate("You and your team will be disconnected at the end of the process."),
110
- });
111
- } else {
112
- // Backward compatibility with API < v5.13.0
113
- this.handleUpdateKey();
114
- }
105
+ this.props.dialogContext.open(EditSubscriptionKey, {
106
+ title: this.props.t("New subscription key"),
107
+ onSave: this.handleSaveSubscriptionKey,
108
+ warning: this.translate("You and your team will be disconnected at the end of the process."),
109
+ });
115
110
  }
116
111
 
117
112
  /**
@@ -382,7 +377,7 @@ class DisplaySubscriptionKey extends React.Component {
382
377
  </button>
383
378
  </>
384
379
  )}
385
- {this.props.context.siteSettings.isCommunityEdition && (
380
+ {this.props.context.siteSettings.isCommunityEdition && this.hasEditionPlugin() && (
386
381
  <>
387
382
  <button className="button primary form" type="button" onClick={this.handleAddSubscriptionKey}>
388
383
  <Trans>Upload subscription key</Trans>
@@ -378,34 +378,6 @@ describe("DisplaySubscriptionKeyPage", () => {
378
378
  expect(page.downgradeToCommunityButton).toBeNull();
379
379
  });
380
380
 
381
- it("As CE AD the Upload subscription key button should be rendered", async () => {
382
- expect.assertions(2);
383
-
384
- const noPluginProps = propsWithoutEditionPlugin();
385
- jest.spyOn(noPluginProps.context.siteSettings, "isCommunityEdition", "get").mockReturnValue(true);
386
- page = new DisplaySubscriptionKeyPage(noPluginProps.context, noPluginProps);
387
- await screen.findByText("Details");
388
-
389
- expect(page.toolbarActionsUpdateButton).not.toBeNull();
390
- expect(page.toolbarActionsUpdateButton.textContent.trim()).toBe("Upload subscription key");
391
- });
392
-
393
- it("As CE AD clicking Upload subscription key should fallback to the legacy update flow", async () => {
394
- expect.assertions(2);
395
-
396
- const noPluginProps = propsWithoutEditionPlugin();
397
- jest.spyOn(noPluginProps.context.siteSettings, "isCommunityEdition", "get").mockReturnValue(true);
398
- page = new DisplaySubscriptionKeyPage(noPluginProps.context, noPluginProps);
399
- await screen.findByText("Details");
400
-
401
- await page.updateKey();
402
-
403
- expect(noPluginProps.dialogContext.open).toHaveBeenCalledWith(EditSubscriptionKey);
404
- expect(noPluginProps.context.setContext).toHaveBeenCalledWith({
405
- editSubscriptionKey: { key: mockSubscription.data },
406
- });
407
- });
408
-
409
381
  it("As AD the Details and Plans sections should still be rendered", async () => {
410
382
  expect.assertions(3);
411
383
 
@@ -97,10 +97,10 @@ export class FolderShareFlow extends AbstractPermissionFlow {
97
97
  */
98
98
  openShareDialog() {
99
99
  this.props.dialogContext.open(ShareDialog, {
100
- initialResources: [
100
+ initialFolders: [
101
101
  {
102
102
  id: this.folderId,
103
- metadata: { name: this.props.folder.metadata?.name ?? this.props.folder.name ?? "" },
103
+ metadata: { name: this.props.folder.name ?? "" },
104
104
  permission: this.props.folder.permission,
105
105
  permissions: this.state.folderSnapshot.permissions,
106
106
  },
@@ -110,6 +110,7 @@ export class FolderShareFlow extends AbstractPermissionFlow {
110
110
  initialUsers: this.state.folderSnapshot.users,
111
111
  onConfirm: this.handleShareDialogConfirm,
112
112
  onClose: this.handleShareDialogClose,
113
+ isPermissionConfirmationMode: false,
113
114
  });
114
115
  this.setState({ status: FOLDER_SHARE_FLOW_STATUS.SHARE_DIALOG_OPEN });
115
116
  }
@@ -120,9 +121,10 @@ export class FolderShareFlow extends AbstractPermissionFlow {
120
121
  * the operator confirmed the existing permissions as-is: nothing is sent. The extension re-derives
121
122
  * the propagation to the folder's content.
122
123
  * @param {Array<object>} folderPermissionChanges The DTO-shape folder permission changes.
124
+ * @param {boolean} canOperatorRead true if the operator can still read the modified folder
123
125
  * @returns {Promise<void>}
124
126
  */
125
- async handleShareDialogConfirm(folderPermissionChanges) {
127
+ async handleShareDialogConfirm(folderPermissionChanges, canOperatorRead) {
126
128
  this.shareConfirmed = true;
127
129
  try {
128
130
  const currentSnapshot = await this.permissionSnapshotService.buildSnapshotForFolderShare(this.folderId);
@@ -136,10 +138,8 @@ export class FolderShareFlow extends AbstractPermissionFlow {
136
138
  if (folderPermissionChanges.length) {
137
139
  await this.permissionServiceWorkerService.saveFoldersPermissions(this.folderId, folderPermissionChanges);
138
140
  }
139
- await this.finalizeSuccess(
140
- this.props.t("The permissions have been changed successfully."),
141
- `/app/folders/view/${this.folderId}`,
142
- );
141
+ const redirectUrl = canOperatorRead ? `/app/folders/view/${this.folderId}` : `/app/passwords/`;
142
+ await this.finalizeSuccess(this.props.t("The permissions have been changed successfully."), redirectUrl);
143
143
  } catch (error) {
144
144
  this.handleError(error);
145
145
  }
@@ -26,8 +26,7 @@ import {
26
26
  PERMISSIONS_FIND_ACO_PERMISSIONS_FOR_DISPLAY,
27
27
  SHARE_FOLDERS_SAVE,
28
28
  } from "../../../../../shared/services/serviceWorker/permission/permissionServiceWorkerService";
29
- import { GROUPS_GET_BY_IDS } from "../../../../../shared/services/serviceWorker/group/groupServiceWorkerService";
30
- import { USERS_GET_BY_IDS } from "../../../../../shared/services/serviceWorker/user/userServiceWorkerService";
29
+ import { GROUPS_FIND_BY_IDS_FOR_SHARE } from "../../../../../shared/services/serviceWorker/group/groupServiceWorkerService";
31
30
 
32
31
  beforeEach(() => {
33
32
  jest.clearAllMocks();
@@ -49,13 +48,12 @@ function permissionDto(aco, acoForeignKey, aroForeignKey, type = PermissionEntit
49
48
 
50
49
  /**
51
50
  * Wire the folder-snapshot port events. `folderPermissions` answers the folder permission fetch;
52
- * groups/users resolve to empty by default.
51
+ * groups resolve to empty by default.
53
52
  */
54
53
  function wireSnapshotListeners(port, { folderPermissions = [] } = {}) {
55
54
  port.addRequestListener(KEYRING_SYNC_EVENT, () => {});
56
55
  port.addRequestListener(PERMISSIONS_FIND_ACO_PERMISSIONS_FOR_DISPLAY, () => folderPermissions);
57
- port.addRequestListener(GROUPS_GET_BY_IDS, () => []);
58
- port.addRequestListener(USERS_GET_BY_IDS, () => []);
56
+ port.addRequestListener(GROUPS_FIND_BY_IDS_FOR_SHARE, () => []);
59
57
  }
60
58
 
61
59
  /**
@@ -103,8 +101,8 @@ describe("FolderShareFlow", () => {
103
101
  expect(shareProps.acoType).toStrictEqual(PermissionEntity.ACO_FOLDER);
104
102
  // The single dialog sets and validates at once: editable, not read-only.
105
103
  expect(shareProps.readOnly).toBeUndefined();
106
- expect(shareProps.initialResources).toHaveLength(1);
107
- expect(shareProps.initialResources[0].id).toStrictEqual(folderId);
104
+ expect(shareProps.initialFolders).toHaveLength(1);
105
+ expect(shareProps.initialFolders[0].id).toStrictEqual(folderId);
108
106
  });
109
107
 
110
108
  it("As LU confirming the folder permissions should save them (extension propagates to content) without a second dialog", async () => {
@@ -173,8 +171,7 @@ describe("FolderShareFlow", () => {
173
171
  folderFindCount += 1;
174
172
  return folderFindCount === 1 ? initialFolderPermissions : driftedFolderPermissions;
175
173
  });
176
- props.context.port.addRequestListener(GROUPS_GET_BY_IDS, () => []);
177
- props.context.port.addRequestListener(USERS_GET_BY_IDS, () => []);
174
+ props.context.port.addRequestListener(GROUPS_FIND_BY_IDS_FOR_SHARE, () => []);
178
175
 
179
176
  await mountUntilShareOpen(props);
180
177
 
@@ -82,21 +82,10 @@ export class ResourceCreationFlow extends AbstractPermissionFlow {
82
82
  }
83
83
 
84
84
  /**
85
- * Component did mount: build the snapshot (when applicable) and open the resource-creation form.
86
- * @returns {Promise<void>}
85
+ * Component did mount: open the resource-creation form.
87
86
  */
88
- async componentDidMount() {
89
- try {
90
- if (this.props.folderParentId) {
91
- const snapshot = await this.permissionSnapshotService.buildSnapshotForResourceCreation(
92
- this.props.folderParentId,
93
- );
94
- this.setState({ snapshot });
95
- }
96
- this.openCreateResourceDialog();
97
- } catch (error) {
98
- this.handleError(error);
99
- }
87
+ componentDidMount() {
88
+ this.openCreateResourceDialog();
100
89
  }
101
90
 
102
91
  /**
@@ -140,8 +129,10 @@ export class ResourceCreationFlow extends AbstractPermissionFlow {
140
129
 
141
130
  /**
142
131
  * Handle the operator's submission of the resource-creation form.
143
- * If the parent folder is shared, dispatches ShareDialog so the operator confirms the permission
144
- * set first. Otherwise creates the resource immediately.
132
+ * Captures the parent folder's permission snapshot (when there is one) now that the operator has
133
+ * committed, so the fetch runs while the form dialog's submit button spins. If the parent folder is
134
+ * shared, dispatches ShareDialog so the operator confirms the permission set first. Otherwise
135
+ * creates the resource immediately.
145
136
  * @param {ResourceFormEntity} resourceFormEntity The validated form entity.
146
137
  * @returns {Promise<void>}
147
138
  */
@@ -149,8 +140,11 @@ export class ResourceCreationFlow extends AbstractPermissionFlow {
149
140
  this.formSubmitted = true;
150
141
  this.pendingResourceFormEntity = resourceFormEntity;
151
142
  try {
152
- if (this.isShared(this.state.snapshot)) {
153
- this.openShareDialog();
143
+ const snapshot = this.props.folderParentId
144
+ ? await this.permissionSnapshotService.buildSnapshotForResourceCreation(this.props.folderParentId)
145
+ : null;
146
+ if (this.isShared(snapshot)) {
147
+ this.setState({ snapshot }, () => this.openShareDialog());
154
148
  return;
155
149
  }
156
150
  const created = await this.createResource(resourceFormEntity);
@@ -181,9 +175,10 @@ export class ResourceCreationFlow extends AbstractPermissionFlow {
181
175
  * delegate the operator-only create + share orchestration to the extension via a single
182
176
  * `passbolt.resources.create` call carrying both the secret and the permission changes.
183
177
  * @param {Array<object>} permissionChanges The DTO-shape permission changes ShareDialog emits.
178
+ * @param {boolean} canOperatorRead true if the operator can still read the modified resource
184
179
  * @returns {Promise<void>}
185
180
  */
186
- async handleShareDialogConfirm(permissionChanges) {
181
+ async handleShareDialogConfirm(permissionChanges, canOperatorRead) {
187
182
  this.shareConfirmed = true;
188
183
  try {
189
184
  const currentSnapshot = await this.permissionSnapshotService.buildSnapshotForResourceCreation(
@@ -205,10 +200,8 @@ export class ResourceCreationFlow extends AbstractPermissionFlow {
205
200
  null,
206
201
  );
207
202
  const created = await this.createResource(this.pendingResourceFormEntity, finalChanges);
208
- await this.finalizeSuccess(
209
- this.props.t("The resource has been added successfully"),
210
- `/app/passwords/view/${created.id}`,
211
- );
203
+ const redirectUrl = canOperatorRead ? `/app/passwords/view/${created.id}` : `/app/passwords/`;
204
+ await this.finalizeSuccess(this.props.t("The resource has been added successfully"), redirectUrl);
212
205
  this.closeCreateResourceDialog();
213
206
  this.terminate();
214
207
  } catch (error) {
@@ -256,7 +249,7 @@ export class ResourceCreationFlow extends AbstractPermissionFlow {
256
249
  createResource(resourceFormEntity, permissionChanges) {
257
250
  const resourceDto = resourceFormEntity.toResourceDto();
258
251
  const resourceType = resourceFormEntity.resourceTypeId
259
- ? this.props.context.resourceTypesCollection?.getFirstById(resourceFormEntity.resourceTypeId)
252
+ ? resourceFormEntity.resourceTypes?.getFirstById(resourceFormEntity.resourceTypeId)
260
253
  : null;
261
254
  const isV4PasswordString = resourceType?.slug === RESOURCE_TYPE_PASSWORD_STRING_SLUG;
262
255
  const secretDto = isV4PasswordString ? resourceFormEntity.toSecretDto().password : resourceFormEntity.toSecretDto();
@@ -23,27 +23,24 @@ import ShareDialog from "../../../Share/ShareDialog";
23
23
  import NotifyError from "../../../Common/Error/NotifyError/NotifyError";
24
24
  import { KEYRING_SYNC_EVENT } from "../../../../../shared/services/serviceWorker/keyring/keyringServiceWorkerService";
25
25
  import { PERMISSIONS_FIND_ACO_PERMISSIONS_FOR_DISPLAY } from "../../../../../shared/services/serviceWorker/permission/permissionServiceWorkerService";
26
- import { GROUPS_GET_BY_IDS } from "../../../../../shared/services/serviceWorker/group/groupServiceWorkerService";
27
- import { USERS_GET_BY_IDS } from "../../../../../shared/services/serviceWorker/user/userServiceWorkerService";
26
+ import { GROUPS_FIND_BY_IDS_FOR_SHARE } from "../../../../../shared/services/serviceWorker/group/groupServiceWorkerService";
28
27
 
29
28
  beforeEach(() => {
30
29
  jest.clearAllMocks();
31
30
  });
32
31
 
33
32
  /**
34
- * Wire the four port events the snapshot service relies on. Returns the listener stubs so the
33
+ * Wire the three port events the snapshot service relies on. Returns the listener stubs so the
35
34
  * test can override one (e.g. throw an error) before mounting the workflow.
36
35
  * @param {object} port The MockPort from defaultAppContext.
37
36
  * @param {object} options
38
37
  * @param {Array} [options.permissions] The permissions DTO array returned by findPermissions.
39
38
  * @param {Array} [options.groups]
40
- * @param {Array} [options.users]
41
39
  */
42
- function wireSnapshotListeners(port, { permissions = [], groups = [], users = [] } = {}) {
40
+ function wireSnapshotListeners(port, { permissions = [], groups = [] } = {}) {
43
41
  port.addRequestListener(KEYRING_SYNC_EVENT, () => {});
44
42
  port.addRequestListener(PERMISSIONS_FIND_ACO_PERMISSIONS_FOR_DISPLAY, () => permissions);
45
- port.addRequestListener(GROUPS_GET_BY_IDS, () => groups);
46
- port.addRequestListener(USERS_GET_BY_IDS, () => users);
43
+ port.addRequestListener(GROUPS_FIND_BY_IDS_FOR_SHARE, () => groups);
47
44
  }
48
45
 
49
46
  /**
@@ -87,10 +84,6 @@ describe("ResourceCreationFlow", () => {
87
84
  type: 1,
88
85
  },
89
86
  ],
90
- users: [
91
- { id: operatorId, username: "operator@passbolt.com" },
92
- { id: readerId, username: "reader@passbolt.com" },
93
- ],
94
87
  });
95
88
 
96
89
  let page;
@@ -210,11 +203,7 @@ describe("ResourceCreationFlow", () => {
210
203
  permissionsFindCallCount += 1;
211
204
  return permissionsFindCallCount === 1 ? initialPermissionsDto : driftedPermissionsDto;
212
205
  });
213
- props.context.port.addRequestListener(GROUPS_GET_BY_IDS, () => []);
214
- props.context.port.addRequestListener(USERS_GET_BY_IDS, () => [
215
- { id: operatorId, username: "operator@passbolt.com" },
216
- { id: uuidv4(), username: "reader@passbolt.com" },
217
- ]);
206
+ props.context.port.addRequestListener(GROUPS_FIND_BY_IDS_FOR_SHARE, () => []);
218
207
 
219
208
  let page;
220
209
  await act(() => (page = new ResourceCreationFlowTestPage(props)));
@@ -261,7 +250,6 @@ describe("ResourceCreationFlow", () => {
261
250
  const operatorId = props.context.loggedInUser.id;
262
251
  wireSnapshotListeners(props.context.port, {
263
252
  permissions: [operatorOwnerPermissionDto(operatorId, props.folderParentId)],
264
- users: [{ id: operatorId, username: "operator@passbolt.com" }],
265
253
  });
266
254
 
267
255
  let page;
@@ -401,6 +389,16 @@ describe("ResourceCreationFlow", () => {
401
389
 
402
390
  let page;
403
391
  await act(() => (page = new ResourceCreationFlowTestPage(props)));
392
+ await waitFor(() => {
393
+ if (page._instance.state.status !== RESOURCE_CREATION_FLOW_STATUS.CREATE_RESOURCE_OPEN) {
394
+ throw new Error("CreateResource not yet opened");
395
+ }
396
+ });
397
+
398
+ // The snapshot is built on submit, so the keyring-sync failure surfaces there.
399
+ const createProps = dialogPropsFor(props.dialogContext, CreateResource);
400
+ const fakeResourceFormEntity = { toResourceDto: () => ({}), toSecretDto: () => ({}) };
401
+ await act(() => createProps.onSubmit(fakeResourceFormEntity));
404
402
  await waitFor(() => {
405
403
  if (page._instance.state.status !== RESOURCE_CREATION_FLOW_STATUS.ERROR) {
406
404
  throw new Error("Workflow not yet in error state");
@@ -95,17 +95,10 @@ export class ResourceEditFlow extends AbstractPermissionFlow {
95
95
  }
96
96
 
97
97
  /**
98
- * Component did mount: build the snapshot from the resource and open the edition form.
99
- * @returns {Promise<void>}
98
+ * Component did mount: open the edition form.
100
99
  */
101
- async componentDidMount() {
102
- try {
103
- const snapshot = await this.permissionSnapshotService.buildSnapshotForResourceEdition(this.props.resource.id);
104
- this.setState({ snapshot });
105
- this.openEditResourceDialog();
106
- } catch (error) {
107
- this.handleError(error);
108
- }
100
+ componentDidMount() {
101
+ this.openEditResourceDialog();
109
102
  }
110
103
 
111
104
  /**
@@ -140,14 +133,17 @@ export class ResourceEditFlow extends AbstractPermissionFlow {
140
133
  readOnly: this.isShareReadOnly,
141
134
  onConfirm: this.handleShareDialogConfirm,
142
135
  onClose: this.handleShareDialogClose,
136
+ ensureOperatorIsOwner: !this.isShareReadOnly,
143
137
  });
144
138
  this.setState({ status: RESOURCE_EDIT_FLOW_STATUS.SHARE_DIALOG_OPEN });
145
139
  }
146
140
 
147
141
  /**
148
142
  * Handle the operator's submission of the resource-edition form.
149
- * If the resource is shared, dispatches ShareDialog so the operator confirms the recipient set
150
- * first (the secret is re-encrypted for them). Otherwise updates the resource immediately.
143
+ * Captures the resource's permission snapshot now that the operator has committed, so the fetch
144
+ * runs while the form dialog's submit button spins. If the resource is shared, dispatches
145
+ * ShareDialog so the operator confirms the recipient set first (the secret is re-encrypted for
146
+ * them). Otherwise updates the resource immediately.
151
147
  * @param {ResourceFormEntity} resourceFormEntity The validated form entity.
152
148
  * @returns {Promise<void>}
153
149
  */
@@ -156,8 +152,9 @@ export class ResourceEditFlow extends AbstractPermissionFlow {
156
152
  this.pendingResourceFormEntity = resourceFormEntity;
157
153
  this.pendingResourceSecret = secretDto;
158
154
  try {
159
- if (this.isShared(this.state.snapshot)) {
160
- this.openShareDialog();
155
+ const snapshot = await this.permissionSnapshotService.buildSnapshotForResourceEdition(this.props.resource.id);
156
+ if (this.isShared(snapshot)) {
157
+ this.setState({ snapshot }, () => this.openShareDialog());
161
158
  return;
162
159
  }
163
160
  await this.updateResource(resourceFormEntity, secretDto);
@@ -190,9 +187,10 @@ export class ResourceEditFlow extends AbstractPermissionFlow {
190
187
  * read-only mode the deltas are empty, so the resource is simply re-encrypted for its existing
191
188
  * recipients.
192
189
  * @param {Array<object>} permissionChanges The DTO-shape permission changes ShareDialog emits.
190
+ * @param {boolean} isPersonal true if the resource must be marked as personal
193
191
  * @returns {Promise<void>}
194
192
  */
195
- async handleShareDialogConfirm(permissionChanges) {
193
+ async handleShareDialogConfirm(permissionChanges, _, isPersonal) {
196
194
  this.shareConfirmed = true;
197
195
  try {
198
196
  const currentSnapshot = await this.permissionSnapshotService.buildSnapshotForResourceEdition(
@@ -205,7 +203,12 @@ export class ResourceEditFlow extends AbstractPermissionFlow {
205
203
  ),
206
204
  );
207
205
  }
208
- await this.updateResource(this.pendingResourceFormEntity, this.pendingResourceSecret, permissionChanges);
206
+ await this.updateResource(
207
+ this.pendingResourceFormEntity,
208
+ this.pendingResourceSecret,
209
+ permissionChanges,
210
+ isPersonal,
211
+ );
209
212
  await this.finalizeSuccess(
210
213
  this.props.t("The resource has been updated successfully"),
211
214
  `/app/passwords/view/${this.props.resource.id}`,
@@ -252,11 +255,14 @@ export class ResourceEditFlow extends AbstractPermissionFlow {
252
255
  * `permissionChanges` is non-empty the extension re-encrypts the secret and runs the share
253
256
  * orchestration in the same call (single passphrase prompt, single progress dialog).
254
257
  * @param {ResourceFormEntity} resourceFormEntity
258
+ * @param {Object|null} secretDto the updated secret is any
255
259
  * @param {Array<object>} [permissionChanges] Operator-confirmed permission changes.
260
+ * @param {boolean} [isPersonal=true] must be true when the resource is actually personal
256
261
  * @returns {Promise<Object>} The updated resource DTO.
257
262
  */
258
- updateResource(resourceFormEntity, secretDto, permissionChanges) {
263
+ updateResource(resourceFormEntity, secretDto, permissionChanges, isPersonal = true) {
259
264
  const resourceDto = resourceFormEntity.toResourceDto();
265
+ resourceDto.personal = isPersonal;
260
266
  return this.permissionServiceWorkerService.updateResource(resourceDto, secretDto, permissionChanges);
261
267
  }
262
268
  }
@@ -24,21 +24,19 @@ import NotifyError from "../../../Common/Error/NotifyError/NotifyError";
24
24
  import PermissionEntity from "../../../../../shared/models/entity/permission/permissionEntity";
25
25
  import { KEYRING_SYNC_EVENT } from "../../../../../shared/services/serviceWorker/keyring/keyringServiceWorkerService";
26
26
  import { PERMISSIONS_FIND_ACO_PERMISSIONS_FOR_DISPLAY } from "../../../../../shared/services/serviceWorker/permission/permissionServiceWorkerService";
27
- import { GROUPS_GET_BY_IDS } from "../../../../../shared/services/serviceWorker/group/groupServiceWorkerService";
28
- import { USERS_GET_BY_IDS } from "../../../../../shared/services/serviceWorker/user/userServiceWorkerService";
27
+ import { GROUPS_FIND_BY_IDS_FOR_SHARE } from "../../../../../shared/services/serviceWorker/group/groupServiceWorkerService";
29
28
 
30
29
  beforeEach(() => {
31
30
  jest.clearAllMocks();
32
31
  });
33
32
 
34
33
  /**
35
- * Wire the four port events the snapshot service relies on.
34
+ * Wire the three port events the snapshot service relies on.
36
35
  */
37
- function wireSnapshotListeners(port, { permissions = [], groups = [], users = [] } = {}) {
36
+ function wireSnapshotListeners(port, { permissions = [], groups = [] } = {}) {
38
37
  port.addRequestListener(KEYRING_SYNC_EVENT, () => {});
39
38
  port.addRequestListener(PERMISSIONS_FIND_ACO_PERMISSIONS_FOR_DISPLAY, () => permissions);
40
- port.addRequestListener(GROUPS_GET_BY_IDS, () => groups);
41
- port.addRequestListener(USERS_GET_BY_IDS, () => users);
39
+ port.addRequestListener(GROUPS_FIND_BY_IDS_FOR_SHARE, () => groups);
42
40
  }
43
41
 
44
42
  /**
@@ -92,23 +90,12 @@ describe("ResourceEditFlow", () => {
92
90
  resourcePermissionDto(operatorId, props.resource.id),
93
91
  resourcePermissionDto(readerId, props.resource.id, PermissionEntity.PERMISSION_READ),
94
92
  ],
95
- users: [
96
- { id: operatorId, username: "operator@passbolt.com" },
97
- { id: readerId, username: "reader@passbolt.com" },
98
- ],
99
93
  });
100
94
 
101
- // Spy before mounting: the snapshot is built during componentDidMount.
95
+ // Spy before submitting: the snapshot is built when the operator submits the form.
102
96
  jest.spyOn(props.context.port, "request");
103
97
  const page = await mountUntilEditOpen(props);
104
98
 
105
- // The snapshot must be built from the resource itself (ACO_RESOURCE), not a parent folder.
106
- expect(props.context.port.request).toHaveBeenCalledWith(
107
- PERMISSIONS_FIND_ACO_PERMISSIONS_FOR_DISPLAY,
108
- props.resource.id,
109
- PermissionEntity.ACO_RESOURCE,
110
- );
111
-
112
99
  // Submit the form: ShareDialog must follow because the resource is shared.
113
100
  const editProps = dialogPropsFor(props.dialogContext, EditResource);
114
101
  await act(() => editProps.onSubmit(fakeResourceFormEntity, fakeSecretDto));
@@ -118,6 +105,13 @@ describe("ResourceEditFlow", () => {
118
105
  }
119
106
  });
120
107
 
108
+ // The snapshot must be built from the resource itself (ACO_RESOURCE), not a parent folder.
109
+ expect(props.context.port.request).toHaveBeenCalledWith(
110
+ PERMISSIONS_FIND_ACO_PERMISSIONS_FOR_DISPLAY,
111
+ props.resource.id,
112
+ PermissionEntity.ACO_RESOURCE,
113
+ );
114
+
121
115
  // Owner → the dialog is editable (not read-only), seeded from the snapshot.
122
116
  const shareProps = dialogPropsFor(props.dialogContext, ShareDialog);
123
117
  expect(shareProps.readOnly).toBe(false);
@@ -161,11 +155,7 @@ describe("ResourceEditFlow", () => {
161
155
  findCallCount += 1;
162
156
  return findCallCount === 1 ? initialPermissionsDto : driftedPermissionsDto;
163
157
  });
164
- props.context.port.addRequestListener(GROUPS_GET_BY_IDS, () => []);
165
- props.context.port.addRequestListener(USERS_GET_BY_IDS, () => [
166
- { id: operatorId, username: "operator@passbolt.com" },
167
- { id: uuidv4(), username: "reader@passbolt.com" },
168
- ]);
158
+ props.context.port.addRequestListener(GROUPS_FIND_BY_IDS_FOR_SHARE, () => []);
169
159
 
170
160
  const page = await mountUntilEditOpen(props);
171
161
  const editProps = dialogPropsFor(props.dialogContext, EditResource);
@@ -207,10 +197,6 @@ describe("ResourceEditFlow", () => {
207
197
  resourcePermissionDto(ownerId, props.resource.id),
208
198
  resourcePermissionDto(operatorId, props.resource.id, PermissionEntity.PERMISSION_UPDATE),
209
199
  ],
210
- users: [
211
- { id: ownerId, username: "owner@passbolt.com" },
212
- { id: operatorId, username: "operator@passbolt.com" },
213
- ],
214
200
  });
215
201
 
216
202
  const page = await mountUntilEditOpen(props);
@@ -248,7 +234,6 @@ describe("ResourceEditFlow", () => {
248
234
  const operatorId = props.context.loggedInUser.id;
249
235
  wireSnapshotListeners(props.context.port, {
250
236
  permissions: [resourcePermissionDto(operatorId, props.resource.id)],
251
- users: [{ id: operatorId, username: "operator@passbolt.com" }],
252
237
  });
253
238
 
254
239
  await mountUntilEditOpen(props);
@@ -276,7 +261,6 @@ describe("ResourceEditFlow", () => {
276
261
  const operatorId = props.context.loggedInUser.id;
277
262
  wireSnapshotListeners(props.context.port, {
278
263
  permissions: [resourcePermissionDto(operatorId, props.resource.id)],
279
- users: [{ id: operatorId, username: "operator@passbolt.com" }],
280
264
  });
281
265
 
282
266
  await mountUntilEditOpen(props);
@@ -340,8 +324,11 @@ describe("ResourceEditFlow", () => {
340
324
  throw new Error("Keyring sync failed");
341
325
  });
342
326
 
343
- let page;
344
- await act(() => (page = new ResourceEditFlowTestPage(props)));
327
+ const page = await mountUntilEditOpen(props);
328
+
329
+ // The snapshot is built on submit, so the keyring-sync failure surfaces there.
330
+ const editProps = dialogPropsFor(props.dialogContext, EditResource);
331
+ await act(() => editProps.onSubmit(fakeResourceFormEntity, fakeSecretDto));
345
332
  await waitFor(() => {
346
333
  if (page._instance.state.status !== RESOURCE_EDIT_FLOW_STATUS.ERROR) {
347
334
  throw new Error("Workflow not yet in error state");
@@ -113,9 +113,10 @@ export class ResourceShareFlow extends AbstractPermissionFlow {
113
113
  * dialog emits deltas already targeting the real resources, so they are saved as-is. An empty
114
114
  * delta set means the operator confirmed the existing permissions as-is: nothing is sent.
115
115
  * @param {Array<object>} permissionChanges The DTO-shape permission changes ShareDialog emits.
116
+ * @param {boolean} canOperatorRead true if the operator can still read the modified resource
116
117
  * @returns {Promise<void>}
117
118
  */
118
- async handleShareDialogConfirm(permissionChanges) {
119
+ async handleShareDialogConfirm(permissionChanges, canOperatorRead) {
119
120
  this.shareConfirmed = true;
120
121
  try {
121
122
  const currentSnapshots = await this.permissionSnapshotService.buildSnapshotForResourcesShare(this.resourcesIds);
@@ -130,10 +131,8 @@ export class ResourceShareFlow extends AbstractPermissionFlow {
130
131
  if (permissionChanges.length) {
131
132
  await this.permissionServiceWorkerService.saveResourcesPermissions(this.resourcesIds, permissionChanges);
132
133
  }
133
- await this.finalizeSuccess(
134
- this.props.t("The permissions have been changed successfully."),
135
- `/app/passwords/view/${this.resourcesIds[0]}`,
136
- );
134
+ const redirectUrl = canOperatorRead ? `/app/passwords/view/${this.resourcesIds[0]}` : `/app/passwords/`;
135
+ await this.finalizeSuccess(this.props.t("The permissions have been changed successfully."), redirectUrl);
137
136
  } catch (error) {
138
137
  this.handleError(error);
139
138
  }