geonetwork-ui 2.10.0-dev.25c2dd4c0 → 2.10.0-dev.3445256ab

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.
@@ -25677,7 +25677,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImpo
25677
25677
  }] } });
25678
25678
 
25679
25679
  var name = "geonetwork-ui";
25680
- var version = "2.10.0-dev.25c2dd4c0";
25680
+ var version = "2.10.0-dev.3445256ab";
25681
25681
  var engines = {
25682
25682
  node: ">=20"
25683
25683
  };
@@ -26660,8 +26660,14 @@ class Gn4Repository {
26660
26660
  }));
26661
26661
  }
26662
26662
  openRecordForDuplication(uniqueIdentifier) {
26663
- return this.gn4RecordsApi
26664
- .create(uniqueIdentifier, '2', 'METADATA', '', false, undefined, true, false, undefined, 'body', false, {
26663
+ return this.platformService.getUserPermissionsByGroup().pipe(map$1((permissions) => {
26664
+ const groupId = permissions.find((p) => p.canApprove)?.groupId?.toString() ??
26665
+ permissions.find((p) => p.canEdit)?.groupId?.toString();
26666
+ if (!groupId)
26667
+ throw new Error('Current user has no writable group to duplicate into');
26668
+ return groupId;
26669
+ }), switchMap((groupId) => this.gn4RecordsApi
26670
+ .create(uniqueIdentifier, groupId, 'METADATA', '', false, undefined, true, false, undefined, 'body', false, {
26665
26671
  httpHeaderAccept: 'application/json',
26666
26672
  httpContentTypeSelected: 'application/json;charset=UTF-8',
26667
26673
  })
@@ -26673,7 +26679,7 @@ class Gn4Repository {
26673
26679
  .then((record) => {
26674
26680
  return [record, xml, true];
26675
26681
  }));
26676
- }));
26682
+ }))));
26677
26683
  }
26678
26684
  saveRecord(record, referenceRecordSource, publishToAll = true) {
26679
26685
  return this.platformService.getApiVersion().pipe(map$1((version) => {
@@ -27413,6 +27419,7 @@ class Gn4PlatformService {
27413
27419
  constructor() {
27414
27420
  this.meApi = inject(MeApiService);
27415
27421
  this.usersApi = inject(UsersApiService);
27422
+ this.groupsApi = inject(GroupsApiService);
27416
27423
  this.mapper = inject(Gn4PlatformMapper);
27417
27424
  this.toolsApiService = inject(ToolsApiService);
27418
27425
  this.registriesApiService = inject(RegistriesApiService);
@@ -27477,6 +27484,48 @@ class Gn4PlatformService {
27477
27484
  getUsers() {
27478
27485
  return this.users$;
27479
27486
  }
27487
+ getUserPermissionsByGroup() {
27488
+ if (this.disableAuth)
27489
+ return of([]);
27490
+ return combineLatest([this.meApi.getMe(), this.groupsApi.getGroups()]).pipe(map$1(([meResponse, groups]) => {
27491
+ if (!meResponse)
27492
+ return [];
27493
+ if (meResponse.admin) {
27494
+ return groups.map((group) => ({
27495
+ groupId: group.id,
27496
+ groupName: group.name,
27497
+ isMember: true,
27498
+ canEdit: true,
27499
+ canApprove: true,
27500
+ canAdministrate: true,
27501
+ }));
27502
+ }
27503
+ const reviewerIds = meResponse.groupsWithReviewer ?? [];
27504
+ const editorIds = meResponse.groupsWithEditor ?? [];
27505
+ const memberIds = meResponse.groupsWithRegisteredUser ?? [];
27506
+ const adminIds = meResponse.groupsWithUserAdmin ?? [];
27507
+ const groupsById = new Map(groups.map((g) => [g.id, g]));
27508
+ return [
27509
+ ...new Set([
27510
+ ...reviewerIds,
27511
+ ...editorIds,
27512
+ ...groups.map((g) => g.id),
27513
+ ]),
27514
+ ]
27515
+ .filter((id) => groupsById.has(id))
27516
+ .map((id) => {
27517
+ const group = groupsById.get(id);
27518
+ return {
27519
+ groupId: group.id,
27520
+ groupName: group.name,
27521
+ isMember: memberIds.includes(id),
27522
+ canEdit: editorIds.includes(id),
27523
+ canApprove: reviewerIds.includes(id),
27524
+ canAdministrate: adminIds.includes(id),
27525
+ };
27526
+ });
27527
+ }));
27528
+ }
27480
27529
  translateKey(key) {
27481
27530
  // if the key is a URI, use the registries API to look for the translation
27482
27531
  if (key.match(/^https?:\/\//)) {