From ee8d66ba414df40156d78046c53572b51995992e Mon Sep 17 00:00:00 2001 From: Nicoleta Panaghiu Date: Mon, 8 Apr 2024 15:36:13 +0300 Subject: [PATCH] RED-8907: changed dialog options permissions based on local changes. --- .../file/annotation-permissions.utils.ts | 8 +++-- .../src/app/models/file/annotation.wrapper.ts | 15 +++++---- .../file-preview/utils/dialog-options.ts | 33 ++++++++++--------- .../red-domain/src/lib/redaction-log/types.ts | 7 ++-- 4 files changed, 35 insertions(+), 28 deletions(-) diff --git a/apps/red-ui/src/app/models/file/annotation-permissions.utils.ts b/apps/red-ui/src/app/models/file/annotation-permissions.utils.ts index ec313b6de..e725d852a 100644 --- a/apps/red-ui/src/app/models/file/annotation-permissions.utils.ts +++ b/apps/red-ui/src/app/models/file/annotation-permissions.utils.ts @@ -13,7 +13,10 @@ export const canForceRedaction = (annotation: AnnotationWrapper, canAddRedaction export const canAcceptRecommendation = (annotation: AnnotationWrapper) => annotation.isRecommendation && !annotation.pending; export const canMarkAsFalsePositive = (annotation: AnnotationWrapper, annotationEntity: Dictionary) => - annotation.canBeMarkedAsFalsePositive && !annotation.hasBeenForcedRedaction && annotationEntity?.hasDictionary; + annotation.canBeMarkedAsFalsePositive && + !annotation.hasBeenForcedRedaction && + !annotation.hasBeenResizedLocally && + annotationEntity?.hasDictionary; export const canRemoveOnlyHere = (annotation: AnnotationWrapper, canAddRedaction: boolean, autoAnalysisDisabled: boolean) => canAddRedaction && @@ -24,7 +27,8 @@ export const canRemoveFromDictionary = (annotation: AnnotationWrapper, autoAnaly annotation.isModifyDictionary && (annotation.isRedacted || annotation.isSkipped || annotation.isHint || (annotation.isIgnoredHint && !annotation.isRuleBased)) && (autoAnalysisDisabled || !annotation.pending) && - !annotation.hasBeenResized; + !annotation.hasBeenResizedLocally && + (!annotation.hasBeenForcedHint || !annotation.hasBeenForcedRedaction); export const canRemoveRedaction = (annotation: AnnotationWrapper, permissions: AnnotationPermissions) => (!annotation.isIgnoredHint || !annotation.isRuleBased) && diff --git a/apps/red-ui/src/app/models/file/annotation.wrapper.ts b/apps/red-ui/src/app/models/file/annotation.wrapper.ts index 1a8f5db59..e1985d7bd 100644 --- a/apps/red-ui/src/app/models/file/annotation.wrapper.ts +++ b/apps/red-ui/src/app/models/file/annotation.wrapper.ts @@ -57,6 +57,7 @@ export class AnnotationWrapper implements IListable { isChangeLogEntry = false; engines: LogEntryEngine[] = []; hasBeenResized: boolean; + hasBeenResizedLocally: boolean; hasBeenRecategorized: boolean; hasLegalBasisChanged: boolean; hasBeenForcedHint: boolean; @@ -253,20 +254,20 @@ export class AnnotationWrapper implements IListable { annotationWrapper.section = logEntry.section; annotationWrapper.reference = logEntry.reference || []; annotationWrapper.hasBeenResized = !!logEntry.manualChanges?.find(c => c.manualRedactionType === ManualRedactionTypes.RESIZE); + annotationWrapper.hasBeenResizedLocally = + annotationWrapper.hasBeenResized && annotationWrapper.engines.includes(LogEntryEngines.MANUAL); annotationWrapper.hasBeenRecategorized = !!logEntry.manualChanges?.find( c => c.manualRedactionType === ManualRedactionTypes.RECATEGORIZE, ); annotationWrapper.hasLegalBasisChanged = !!logEntry.manualChanges?.find( c => c.manualRedactionType === ManualRedactionTypes.LEGAL_BASIS_CHANGE, ); - annotationWrapper.hasBeenForcedHint = !!logEntry.manualChanges?.find( - c => c.manualRedactionType === ManualRedactionTypes.FORCE_HINT, - ); + annotationWrapper.hasBeenForcedHint = !!logEntry.manualChanges?.find(c => c.manualRedactionType === ManualRedactionTypes.FORCE); annotationWrapper.hasBeenForcedRedaction = !!logEntry.manualChanges?.find( - c => c.manualRedactionType === ManualRedactionTypes.FORCE_REDACT, + c => c.manualRedactionType === ManualRedactionTypes.FORCE, ); annotationWrapper.hasBeenRemovedByManualOverride = !!logEntry.manualChanges?.find( - c => c.manualRedactionType === ManualRedactionTypes.REMOVE_LOCALLY, + c => c.manualRedactionType === ManualRedactionTypes.REMOVE, ); const content = this.#createContent(annotationWrapper, logEntry, isDocumine); @@ -279,7 +280,9 @@ export class AnnotationWrapper implements IListable { annotationWrapper.superTypeLabel = annotationTypesTranslations[annotationWrapper.superType]; annotationWrapper.isRemoved = logEntry.state === EntryStates.REMOVED; - annotationWrapper.isRemovedLocally = lastRelevantManualChange?.manualRedactionType === ManualRedactionTypes.REMOVE_LOCALLY; + annotationWrapper.isRemovedLocally = + lastRelevantManualChange?.manualRedactionType === ManualRedactionTypes.REMOVE && + logEntry.engines.includes(LogEntryEngines.MANUAL); annotationWrapper.typeLabel = dictionary?.virtual ? undefined : dictionary?.label; diff --git a/apps/red-ui/src/app/modules/file-preview/utils/dialog-options.ts b/apps/red-ui/src/app/modules/file-preview/utils/dialog-options.ts index 82894b5db..c949a3af1 100644 --- a/apps/red-ui/src/app/modules/file-preview/utils/dialog-options.ts +++ b/apps/red-ui/src/app/modules/file-preview/utils/dialog-options.ts @@ -127,22 +127,23 @@ export const getResizeRedactionOptions = ( if (isRss) { return options; } - - const dictBasedType = redaction.isModifyDictionary; - options.push({ - label: translations.inDossier.label, - description: translations.inDossier.description, - descriptionParams: { dossierName: dossier.dossierName }, - disabled: !dictBasedType || redaction.hasBeenRecategorized, - tooltip: !dictBasedType ? translations.inDossier.tooltip : null, - icon: FOLDER_ICON, - value: RedactOrHintOptions.IN_DOSSIER, - extraOption: { - label: translations.inDossier.extraOptionLabel, - checked: applyToAllDossiers, - hidden: !isApprover, - }, - }); + if (!redaction.hasBeenResizedLocally) { + const dictBasedType = redaction.isModifyDictionary; + options.push({ + label: translations.inDossier.label, + description: translations.inDossier.description, + descriptionParams: { dossierName: dossier.dossierName }, + disabled: !dictBasedType || redaction.hasBeenRecategorized, + tooltip: !dictBasedType ? translations.inDossier.tooltip : null, + icon: FOLDER_ICON, + value: RedactOrHintOptions.IN_DOSSIER, + extraOption: { + label: translations.inDossier.extraOptionLabel, + checked: applyToAllDossiers, + hidden: !isApprover, + }, + }); + } return options; }; diff --git a/libs/red-domain/src/lib/redaction-log/types.ts b/libs/red-domain/src/lib/redaction-log/types.ts index 1a6f2abd3..c35068387 100644 --- a/libs/red-domain/src/lib/redaction-log/types.ts +++ b/libs/red-domain/src/lib/redaction-log/types.ts @@ -13,14 +13,13 @@ export type LogEntryEngine = ValuesOf; export const ManualRedactionTypes = { ADD_LOCALLY: 'ADD_LOCALLY', ADD_TO_DICTIONARY: 'ADD_TO_DICTIONARY', - REMOVE_LOCALLY: 'REMOVE_LOCALLY', + REMOVE: 'REMOVE', REMOVE_FROM_DICTIONARY: 'REMOVE_FROM_DICTIONARY', - FORCE_REDACT: 'FORCE_REDACT', - FORCE_HINT: 'FORCE_HINT', + FORCE: 'FORCE', RECATEGORIZE: 'RECATEGORIZE', LEGAL_BASIS_CHANGE: 'LEGAL_BASIS_CHANGE', RESIZE: 'RESIZE', - RESIZE_LOCALLY: 'RESIZE_LOCALLY', + RESIZE_WITH_DICTIONARY: 'RESIZE_WITH_DICTIONARY', } as const; export type ManualRedactionType = ValuesOf;