From da8efe51301d20926ab1b219c63cbbb3a5cc8134 Mon Sep 17 00:00:00 2001 From: sgiannopoulos Date: Tue, 30 Apr 2024 14:06:24 +0300 Subject: [PATCH] description authz changes --- .../opencdmp/authorization/Permission.java | 2 ++ .../src/main/resources/config/permissions.yml | 24 ++++++++++++++ .../app/core/common/enum/permission.enum.ts | 3 ++ ...ion-template-preview-dialog.component.html | 4 +-- ...late-editor-composite-field.component.html | 2 +- .../final-preview.component.html | 2 +- ...ate-editor-section-fieldset.component.html | 2 +- ...description-template-editor.component.html | 32 +++++++++---------- .../editor/description-editor.component.html | 3 +- .../editor/description-editor.component.ts | 22 +++++++------ .../editor/description-editor.resolver.ts | 1 + .../form-field-set.component.html | 2 +- .../form-field-set.component.ts | 1 + .../form-section/form-section.component.html | 3 +- .../form-section/form-section.component.ts | 1 + .../description-form.component.html | 2 +- .../description-form.component.ts | 1 + .../description-overview.component.html | 2 +- .../description-overview.component.ts | 5 +++ 19 files changed, 78 insertions(+), 36 deletions(-) diff --git a/backend/core/src/main/java/org/opencdmp/authorization/Permission.java b/backend/core/src/main/java/org/opencdmp/authorization/Permission.java index 865cb5981..0f0fe754f 100644 --- a/backend/core/src/main/java/org/opencdmp/authorization/Permission.java +++ b/backend/core/src/main/java/org/opencdmp/authorization/Permission.java @@ -73,6 +73,7 @@ public final class Permission { //Dmp public static String BrowseDmp = "BrowseDmp"; public static String EditDmp = "EditDmp"; + public static String ReviewDmp = "ReviewDmp"; public static String NewDmp = "NewDmp"; public static String DepositDmp = "DepositDmp"; public static String DeleteDmp = "DeleteDmp"; @@ -105,6 +106,7 @@ public final class Permission { //Description public static String BrowseDescription = "BrowseDescription"; + public static String ReviewDescription = "ReviewDescription"; public static String EditDescription = "EditDescription"; public static String FinalizeDescription = "FinalizeDescription"; public static String DeleteDescription = "DeleteDescription"; diff --git a/backend/web/src/main/resources/config/permissions.yml b/backend/web/src/main/resources/config/permissions.yml index ad762d454..476f465f6 100644 --- a/backend/web/src/main/resources/config/permissions.yml +++ b/backend/web/src/main/resources/config/permissions.yml @@ -179,6 +179,18 @@ permissions: clients: [ ] allowAnonymous: false allowAuthenticated: false + ReviewDescription: + roles: + - TenantAdmin + dmp: + roles: + - Owner + - User + - DescriptionContributor + - Reviewer + clients: [ ] + allowAnonymous: false + allowAuthenticated: false EditDescription: roles: - TenantAdmin @@ -408,6 +420,18 @@ permissions: clients: [ ] allowAnonymous: false allowAuthenticated: false + ReviewDmp: + roles: + - TenantAdmin + dmp: + roles: + - Owner + - User + - DescriptionContributor + - Reviewer + clients: [ ] + allowAnonymous: false + allowAuthenticated: false NewDmp: roles: - TenantAdmin diff --git a/dmp-frontend/src/app/core/common/enum/permission.enum.ts b/dmp-frontend/src/app/core/common/enum/permission.enum.ts index 93c1d3aac..c0e3a1c2f 100644 --- a/dmp-frontend/src/app/core/common/enum/permission.enum.ts +++ b/dmp-frontend/src/app/core/common/enum/permission.enum.ts @@ -71,6 +71,7 @@ export enum AppPermission { //Dmp BrowseDmp = "BrowseDmp", EditDmp = "EditDmp", + ReviewDmp = "ReviewDmp", NewDmp = "NewDmp", DepositDmp = "DepositDmp", DeleteDmp = "DeleteDmp", @@ -103,10 +104,12 @@ export enum AppPermission { //Description BrowseDescription = "BrowseDescription", + ReviewDescription = "ReviewDescription", EditDescription = "EditDescription", FinalizeDescription = "FinalizeDescription", DeleteDescription = "DeleteDescription", CloneDescription = "CloneDescription", + ExportDescription = "ExportDescription", //DescriptionTag BrowseDescriptionTag = "BrowseDescriptionTag", diff --git a/dmp-frontend/src/app/ui/admin/description-template/description-template-preview/description-template-preview-dialog.component.html b/dmp-frontend/src/app/ui/admin/description-template/description-template-preview/description-template-preview-dialog.component.html index dab92703a..72a8e7a9e 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/description-template-preview/description-template-preview-dialog.component.html +++ b/dmp-frontend/src/app/ui/admin/description-template/description-template-preview/description-template-preview-dialog.component.html @@ -8,11 +8,11 @@
- +
- \ No newline at end of file + diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.html b/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.html index f30af7926..3370f2a0c 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.html +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.html @@ -104,7 +104,7 @@
- +
diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/final-preview/final-preview.component.html b/dmp-frontend/src/app/ui/admin/description-template/editor/components/final-preview/final-preview.component.html index 5e1e459ff..0250b3eb9 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/final-preview/final-preview.component.html +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/final-preview/final-preview.component.html @@ -1 +1 @@ - \ No newline at end of file + diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/section-fieldset/description-template-editor-section-fieldset.component.html b/dmp-frontend/src/app/ui/admin/description-template/editor/components/section-fieldset/description-template-editor-section-fieldset.component.html index 626f7ef13..84d5723b6 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/section-fieldset/description-template-editor-section-fieldset.component.html +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/section-fieldset/description-template-editor-section-fieldset.component.html @@ -123,4 +123,4 @@ - \ No newline at end of file + diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.html b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.html index f2753c4eb..8e6fde3c0 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.html +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.html @@ -176,14 +176,14 @@
-
@@ -210,7 +210,7 @@
- {{selectedTocEntry.form.get('title').getError('backendError').message}} + {{selectedTocEntry.form.get('title').getError('backendError').message}} {{'GENERAL.VALIDATION.REQUIRED' | translate}}
@@ -223,11 +223,11 @@
- @@ -270,7 +270,7 @@
- +
@@ -340,4 +340,4 @@ {{'DESCRIPTION-TEMPLATE-EDITOR.ACTIONS.FINALIZE' | translate}}
- \ No newline at end of file + diff --git a/dmp-frontend/src/app/ui/description/editor/description-editor.component.html b/dmp-frontend/src/app/ui/description/editor/description-editor.component.html index 08bf45631..e1dd3c981 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-editor.component.html +++ b/dmp-frontend/src/app/ui/description/editor/description-editor.component.html @@ -103,7 +103,7 @@
- +
@@ -150,6 +150,7 @@ [linkToScroll]="linkToScroll" [validationErrorModel]="editorModel.validationErrorModel" [isNew]="isNew || isCopy" + [canReview]="canReview" (fieldsetFocusChange)="fieldsetIdWithFocus = $event" >
diff --git a/dmp-frontend/src/app/ui/description/editor/description-editor.component.ts b/dmp-frontend/src/app/ui/description/editor/description-editor.component.ts index 2f2062643..39615e8f7 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-editor.component.ts +++ b/dmp-frontend/src/app/ui/description/editor/description-editor.component.ts @@ -63,6 +63,7 @@ export class DescriptionEditorComponent extends BaseEditor { if (result) { - this.titleService.setTitle(result.label); + this.titleService.setTitle(result.label); result.dmp = this.item.dmp; result.dmpDescriptionTemplate = this.item.dmpDescriptionTemplate; @@ -582,19 +583,20 @@ export class DescriptionEditorComponent extends BaseEditor { const canedit = permissionPerSection && permissionPerSection[this.item.dmpDescriptionTemplate.sectionId.toString()] && permissionPerSection[this.item.dmpDescriptionTemplate.sectionId.toString()].some(x => x === AppPermission.EditDescription); + this.canReview = permissionPerSection && permissionPerSection[this.item.dmpDescriptionTemplate.sectionId.toString()] && permissionPerSection[this.item.dmpDescriptionTemplate.sectionId.toString()].some(x => x === AppPermission.ReviewDescription); this.formGroup = this.editorModel.buildForm(null, this.isDeleted || !canedit); if (this.item.descriptionTemplate?.definition) this.visibilityRulesService.setContext(this.item.descriptionTemplate.definition, this.formGroup.get('properties')); if (this.item.descriptionTemplate?.definition) this.pageToFieldSetMap = this.mapPageToFieldSet(this.item.descriptionTemplate);; // this.selectedSystemFields = this.selectedSystemFieldDisabled(); this.descriptionEditorService.setValidationErrorModel(this.editorModel.validationErrorModel); - if (this.editorModel.status == DescriptionStatus.Finalized || this.isDeleted) { + if (this.editorModel.status == DescriptionStatus.Finalized || this.isDeleted || !canedit) { this.viewOnly = true; this.isFinalized = true; this.formGroup.disable(); @@ -943,7 +945,7 @@ export class DescriptionEditorComponent extends BaseEditor(x => x.label), nameof(x => x.descriptionTemplateId)]; baseInfoControlNames.forEach((name: string) => { if (this.formGroup.get(name)?.touched && !this.formGroup.get(name)?.valid) errorsCount += 1; @@ -1034,7 +1036,7 @@ export class DescriptionEditorComponent extends BaseEditor this.tocValidationService.validateForm()); - + // // const labelSubscription = // this.formGroup.get('label').valueChanges // .pipe(takeUntil(this._destroyed)) @@ -1089,7 +1091,7 @@ export class DescriptionEditorComponent extends BaseEditor { const pageToFieldSetMap = new Map(); @@ -1103,7 +1105,7 @@ export class DescriptionEditorComponent extends BaseEditor { let fieldsets = this.getNestedSectionFieldsets(section); let fieldsBySection: DescriptionFieldIndicator[] = fieldsets?.flatMap((fieldset: DescriptionTemplateFieldSet) => @@ -1126,7 +1128,7 @@ export class DescriptionEditorComponent extends BaseEditor this.getNestedSectionIdsByField(subsection, fieldSetId))]; diff --git a/dmp-frontend/src/app/ui/description/editor/description-editor.resolver.ts b/dmp-frontend/src/app/ui/description/editor/description-editor.resolver.ts index aae8d7592..0deabe44c 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-editor.resolver.ts +++ b/dmp-frontend/src/app/ui/description/editor/description-editor.resolver.ts @@ -55,6 +55,7 @@ export class DescriptionEditorResolver extends BaseEditorResolver { [nameof(x => x.authorizationFlags), AppPermission.EditDescription].join('.'), [nameof(x => x.authorizationFlags), AppPermission.DeleteDescription].join('.'), [nameof(x => x.authorizationFlags), AppPermission.FinalizeDescription].join('.'), + [nameof(x => x.authorizationFlags), AppPermission.ReviewDescription].join('.'), [nameof(x => x.dmpDescriptionTemplate), nameof(x => x.id)].join('.'), [nameof(x => x.dmpDescriptionTemplate), nameof(x => x.sectionId)].join('.'), diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.html b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.html index f46c03ee3..982dfc2da 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.html +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.html @@ -6,7 +6,7 @@
-
diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.ts b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.ts index c43d5567b..d3b200ff9 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.ts +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.ts @@ -28,6 +28,7 @@ export class DescriptionFormFieldSetComponent extends BaseComponent { @Input() propertiesFormGroup: UntypedFormGroup; @Input() descriptionId: Guid; @Input() hideAnnotations: boolean = false; + @Input() canReview: boolean = false; get isMultiplicityEnabled() { return this.fieldSet.hasMultiplicity && this.fieldSet.multiplicity != null; diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-section/form-section.component.html b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-section/form-section.component.html index d984cfad9..11d7a32fe 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-section/form-section.component.html +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-section/form-section.component.html @@ -23,6 +23,7 @@ [validationErrorModel]="validationErrorModel" [isChild]="false" [hideAnnotations]="isNew" + [canReview]="canReview" > @@ -32,7 +33,7 @@
- +
diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-section/form-section.component.ts b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-section/form-section.component.ts index f8b9ac8b2..135098f79 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-section/form-section.component.ts +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-section/form-section.component.ts @@ -19,6 +19,7 @@ import { Guid } from '@common/types/guid'; export class DescriptionFormSectionComponent extends BaseComponent implements OnInit, OnChanges { @Input() isNew: boolean = false; + @Input() canReview: boolean = false; @Input() section: DescriptionTemplateSection; @Input() propertiesFormGroup: UntypedFormGroup; @Input() visibilityRulesService: VisibilityRulesService; diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/description-form.component.html b/dmp-frontend/src/app/ui/description/editor/description-form/description-form.component.html index 000bf1ecf..6dc8589bc 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-form/description-form.component.html +++ b/dmp-frontend/src/app/ui/description/editor/description-form/description-form.component.html @@ -15,7 +15,7 @@
- +
diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/description-form.component.ts b/dmp-frontend/src/app/ui/description/editor/description-form/description-form.component.ts index 68c9cb807..3250073ac 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-form/description-form.component.ts +++ b/dmp-frontend/src/app/ui/description/editor/description-form/description-form.component.ts @@ -21,6 +21,7 @@ export class DescriptionFormComponent extends BaseComponent implements OnInit, A @Input() visibilityRulesService: VisibilityRulesService; @Input() descriptionId: Guid; @Input() isNew: boolean = false; + @Input() canReview: boolean = false; // @ViewChild('stepper', { static: false }) stepper: MatStepper; @Input() path: string; diff --git a/dmp-frontend/src/app/ui/description/overview/description-overview.component.html b/dmp-frontend/src/app/ui/description/overview/description-overview.component.html index 0cc7d971d..0c1d0bb5a 100644 --- a/dmp-frontend/src/app/ui/description/overview/description-overview.component.html +++ b/dmp-frontend/src/app/ui/description/overview/description-overview.component.html @@ -37,7 +37,7 @@
-
+
diff --git a/dmp-frontend/src/app/ui/description/overview/description-overview.component.ts b/dmp-frontend/src/app/ui/description/overview/description-overview.component.ts index d5f5e6227..91048c53c 100644 --- a/dmp-frontend/src/app/ui/description/overview/description-overview.component.ts +++ b/dmp-frontend/src/app/ui/description/overview/description-overview.component.ts @@ -68,6 +68,7 @@ export class DescriptionOverviewComponent extends BaseComponent implements OnIni canEdit = false; canDelete = false; canFinalize = false; + canReview = false; canInviteDmpUsers = false; constructor( @@ -123,6 +124,9 @@ export class DescriptionOverviewComponent extends BaseComponent implements OnIni this.canEdit = (this.authService.hasPermission(AppPermission.EditDescription) || this.description.authorizationFlags?.some(x => x === AppPermission.EditDescription)) && this.description.belongsToCurrentTenant != false; + this.canReview = (this.authService.hasPermission(AppPermission.ReviewDescription) || + this.description.authorizationFlags?.some(x => x === AppPermission.ReviewDescription)) && this.description.belongsToCurrentTenant != false; + this.canFinalize = (this.authService.hasPermission(AppPermission.FinalizeDescription) || this.description.authorizationFlags?.some(x => x === AppPermission.FinalizeDescription)) && this.description.belongsToCurrentTenant != false; @@ -479,6 +483,7 @@ export class DescriptionOverviewComponent extends BaseComponent implements OnIni [nameof(x => x.authorizationFlags), AppPermission.DeleteDescription].join('.'), [nameof(x => x.authorizationFlags), AppPermission.FinalizeDescription].join('.'), [nameof(x => x.authorizationFlags), AppPermission.InviteDmpUsers].join('.'), + [nameof(x => x.authorizationFlags), AppPermission.ReviewDescription].join('.'), [nameof(x => x.descriptionTemplate), nameof(x => x.id)].join('.'), [nameof(x => x.descriptionTemplate), nameof(x => x.label)].join('.'),