RED-6774 - REVIEWERS should no longer send requests

This commit is contained in:
Valentin Mihai 2023-07-16 22:36:09 +03:00
parent 831ced7ac9
commit 37ee771a1e
12 changed files with 51 additions and 136 deletions

View File

@ -5,50 +5,40 @@ import { Dictionary } from '@red/domain';
export const canUndo = (annotation: AnnotationWrapper, isApprover: boolean) =>
!isApprover && (annotation.isSuggestion || annotation.pending);
export const canAcceptSuggestion = (annotation: AnnotationWrapper, isApprover: boolean, canProcessManualRedaction: boolean) => {
const can = isApprover && (annotation.isSuggestion || annotation.isDeclinedSuggestion);
return annotation.isSuggestionAdd || annotation.isSuggestionRemoveDictionary ? can && canProcessManualRedaction : can;
};
export const canForceHint = (annotation: AnnotationWrapper, canAddRedaction: boolean) =>
canAddRedaction && annotation.isIgnoredHint && !annotation.pending;
export const canRejectSuggestion = (annotation: AnnotationWrapper, isApprover: boolean, canProcessManualRedaction: boolean) => {
const can = isApprover && annotation.isSuggestion;
return annotation.isSuggestionAdd || annotation.isSuggestionRemoveDictionary ? can && canProcessManualRedaction : can;
};
export const canForceHint = (annotation: AnnotationWrapper, canAddOrRequestRedaction: boolean) =>
canAddOrRequestRedaction && annotation.isIgnoredHint && !annotation.pending;
export const canForceRedaction = (annotation: AnnotationWrapper, canAddOrRequestRedaction: boolean) =>
canAddOrRequestRedaction && annotation.isSkipped && !annotation.isFalsePositive && !annotation.pending;
export const canForceRedaction = (annotation: AnnotationWrapper, canAddRedaction: boolean) =>
canAddRedaction && annotation.isSkipped && !annotation.isFalsePositive && !annotation.pending;
export const canAcceptRecommendation = (annotation: AnnotationWrapper) => annotation.isRecommendation && !annotation.pending;
export const canMarkAsFalsePositive = (annotation: AnnotationWrapper, annotationEntity: Dictionary) =>
annotation.canBeMarkedAsFalsePositive && annotationEntity.hasDictionary;
export const canRemoveOrSuggestToRemoveOnlyHere = (annotation: AnnotationWrapper, canAddOrRequestRedaction: boolean) =>
canAddOrRequestRedaction && !annotation.pending && (annotation.isRedacted || (annotation.isHint && !annotation.isImage));
export const canRemoveOnlyHere = (annotation: AnnotationWrapper, canAddRedaction: boolean) =>
canAddRedaction && !annotation.pending && (annotation.isRedacted || (annotation.isHint && !annotation.isImage));
export const canRemoveOrSuggestToRemoveFromDictionary = (annotation: AnnotationWrapper) =>
export const canRemoveFromDictionary = (annotation: AnnotationWrapper) =>
annotation.isModifyDictionary &&
(annotation.isRedacted || annotation.isSkipped || annotation.isHint) &&
!annotation.pending &&
!annotation.hasBeenResized;
export const canRemoveOrSuggestToRemoveRedaction = (annotations: AnnotationWrapper[], permissions: AnnotationPermissions) =>
export const canRemoveRedaction = (annotations: AnnotationWrapper[], permissions: AnnotationPermissions) =>
annotations.length === 1 &&
(permissions.canRemoveOrSuggestToRemoveOnlyHere ||
permissions.canRemoveOrSuggestToRemoveFromDictionary ||
permissions.canMarkAsFalsePositive);
(permissions.canRemoveOnlyHere || permissions.canRemoveFromDictionary || permissions.canMarkAsFalsePositive);
export const canChangeLegalBasis = (annotation: AnnotationWrapper, canAddOrRequestRedaction: boolean) =>
canAddOrRequestRedaction && annotation.isRedacted && !annotation.pending;
export const canChangeLegalBasis = (annotation: AnnotationWrapper, canAddRedaction: boolean) =>
canAddRedaction && annotation.isRedacted && !annotation.pending;
export const canRecategorizeImage = (annotation: AnnotationWrapper) =>
((annotation.isImage && !annotation.isSuggestion) || annotation.isSuggestionRecategorizeImage) && !annotation.pending;
export const canRecategorizeImage = (annotation: AnnotationWrapper, canRecategorize: boolean) =>
canRecategorize &&
((annotation.isImage && !annotation.isSuggestion) || annotation.isSuggestionRecategorizeImage) &&
!annotation.pending;
export const canResizeAnnotation = (annotation: AnnotationWrapper, canAddOrRequestRedaction: boolean) =>
canAddOrRequestRedaction &&
export const canResizeAnnotation = (annotation: AnnotationWrapper, canAddRedaction: boolean) =>
canAddRedaction &&
(((annotation.isRedacted || annotation.isImage) && !annotation.isSuggestion) ||
annotation.isSuggestionResize ||
annotation.isRecommendation) &&

View File

@ -5,16 +5,14 @@ import { IqserPermissionsService } from '@iqser/common-ui';
import { Roles } from '@users/roles';
import {
canAcceptRecommendation,
canAcceptSuggestion,
canChangeLegalBasis,
canForceHint,
canForceRedaction,
canMarkAsFalsePositive,
canRecategorizeImage,
canRejectSuggestion,
canRemoveOrSuggestToRemoveFromDictionary,
canRemoveOrSuggestToRemoveOnlyHere,
canRemoveOrSuggestToRemoveRedaction,
canRemoveFromDictionary,
canRemoveOnlyHere,
canRemoveRedaction,
canResizeAnnotation,
canUndo,
} from './annotation-permissions.utils';
@ -23,11 +21,9 @@ export class AnnotationPermissions {
canUndo = true;
canAcceptRecommendation = true;
canMarkAsFalsePositive = true;
canRemoveOrSuggestToRemoveOnlyHere = true;
canRemoveOrSuggestToRemoveFromDictionary = true;
canRemoveOrSuggestToRemoveRedaction = true;
canAcceptSuggestion = true;
canRejectSuggestion = true;
canRemoveOnlyHere = true;
canRemoveFromDictionary = true;
canRemoveRedaction = true;
canForceRedaction = true;
canChangeLegalBasis = true;
canResizeAnnotation = true;
@ -46,27 +42,23 @@ export class AnnotationPermissions {
const summedPermissions: AnnotationPermissions = new AnnotationPermissions();
const canAddRedaction = permissionsService.has(Roles.redactions.write);
const canRequestRedaction = permissionsService.has(Roles.redactions.request);
const canProcessManualRedaction = permissionsService.has(Roles.redactions.processManualRequest);
const canAddOrRequestRedaction = canAddRedaction || canRequestRedaction;
const canDoAnyApproverAction = canAddRedaction && isApprover;
for (const annotation of annotations) {
const permissions: AnnotationPermissions = new AnnotationPermissions();
const annotationEntity = entities.find(entity => entity.type === annotation.type);
permissions.canUndo = canUndo(annotation, isApprover);
permissions.canAcceptSuggestion = canAcceptSuggestion(annotation, isApprover, canProcessManualRedaction);
permissions.canRejectSuggestion = canRejectSuggestion(annotation, isApprover, canProcessManualRedaction);
permissions.canForceHint = canForceHint(annotation, canAddOrRequestRedaction);
permissions.canForceRedaction = canForceRedaction(annotation, canAddOrRequestRedaction);
permissions.canForceHint = canForceHint(annotation, canDoAnyApproverAction);
permissions.canForceRedaction = canForceRedaction(annotation, canDoAnyApproverAction);
permissions.canAcceptRecommendation = canAcceptRecommendation(annotation);
permissions.canMarkAsFalsePositive = canMarkAsFalsePositive(annotation, annotationEntity);
permissions.canRemoveOrSuggestToRemoveOnlyHere = canRemoveOrSuggestToRemoveOnlyHere(annotation, canAddOrRequestRedaction);
permissions.canRemoveOrSuggestToRemoveFromDictionary = canRemoveOrSuggestToRemoveFromDictionary(annotation);
permissions.canRemoveOrSuggestToRemoveRedaction = canRemoveOrSuggestToRemoveRedaction(annotations, permissions);
permissions.canChangeLegalBasis = canChangeLegalBasis(annotation, canAddOrRequestRedaction);
permissions.canRecategorizeImage = canRecategorizeImage(annotation);
permissions.canResizeAnnotation = canResizeAnnotation(annotation, canAddOrRequestRedaction);
permissions.canRemoveOnlyHere = canRemoveOnlyHere(annotation, canAddRedaction);
permissions.canRemoveFromDictionary = canRemoveFromDictionary(annotation);
permissions.canRemoveRedaction = canRemoveRedaction(annotations, permissions);
permissions.canChangeLegalBasis = canChangeLegalBasis(annotation, canDoAnyApproverAction);
permissions.canRecategorizeImage = canRecategorizeImage(annotation, canDoAnyApproverAction);
permissions.canResizeAnnotation = canResizeAnnotation(annotation, canDoAnyApproverAction);
summedPermissions._merge(permissions);
}

View File

@ -51,15 +51,6 @@
icon="iqser:check"
></iqser-circle-button>
<iqser-circle-button
(action)="annotationActionsService.acceptSuggestion(annotations)"
*ngIf="annotationPermissions.canAcceptSuggestion"
[tooltipPosition]="tooltipPosition"
[tooltip]="'annotation-actions.accept-suggestion.label' | translate"
[type]="buttonType"
icon="iqser:check"
></iqser-circle-button>
<iqser-circle-button
(action)="annotationActionsService.convertHighlights(annotations)"
*ngIf="viewModeService.isEarmarks()"
@ -88,12 +79,12 @@
></iqser-circle-button>
<iqser-circle-button
(action)="annotationActionsService.rejectSuggestion(annotations)"
*ngIf="annotationPermissions.canRejectSuggestion"
(action)="annotationActionsService.undoDirectAction(annotations)"
*allow="roles.redactions.deleteManual; if: annotationPermissions.canUndo"
[tooltipPosition]="tooltipPosition"
[tooltip]="'annotation-actions.reject-suggestion' | translate"
[tooltip]="'annotation-actions.undo' | translate"
[type]="buttonType"
icon="iqser:close"
icon="red:undo"
></iqser-circle-button>
<iqser-circle-button
@ -152,7 +143,7 @@
<iqser-circle-button
(action)="removeOrSuggestRemoveRedaction()"
*ngIf="annotationPermissions.canRemoveOrSuggestToRemoveRedaction"
*ngIf="annotationPermissions.canRemoveRedaction"
[tooltipPosition]="tooltipPosition"
[tooltip]="'annotation-actions.remove-annotation.remove-redaction' | translate"
[type]="buttonType"

View File

@ -177,7 +177,6 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme
addRedactionRequest.addToDictionary = selectedType.hasDictionary;
} else {
addRedactionRequest.addToDictionary = this.isDictionaryRequest && addRedactionRequest.type !== 'dossier_redaction';
addRedactionRequest.addToDossierDictionary = this.isDictionaryRequest && addRedactionRequest.type === 'dossier_redaction';
}
if (!addRedactionRequest.reason) {

View File

@ -198,7 +198,6 @@ export class RedactTextDialogComponent
addRedactionRequest.addToDictionary = selectedType.hasDictionary;
} else {
addRedactionRequest.addToDictionary = this.dictionaryRequest && addRedactionRequest.type !== 'dossier_redaction';
addRedactionRequest.addToDossierDictionary = this.dictionaryRequest && addRedactionRequest.type === 'dossier_redaction';
}
if (!addRedactionRequest.reason) {

View File

@ -16,8 +16,8 @@ const FOLDER_ICON = 'red:folder';
const REMOVE_FROM_DICT_ICON = 'red:remove-from-dict';
export interface RemoveRedactionPermissions {
canRemoveOrSuggestToRemoveOnlyHere: boolean;
canRemoveOrSuggestToRemoveFromDictionary: boolean;
canRemoveOnlyHere: boolean;
canRemoveFromDictionary: boolean;
canMarkAsFalsePositive: boolean;
}
@ -93,7 +93,7 @@ export class RemoveRedactionDialogComponent extends IqserDialogComponent<
#options() {
const options: DetailsRadioOption<RemoveRedactionOption>[] = [];
if (this.#permissions.canRemoveOrSuggestToRemoveOnlyHere) {
if (this.#permissions.canRemoveOnlyHere) {
options.push({
label: this.#translations.ONLY_HERE.label,
description: this.#translations.ONLY_HERE.description,
@ -102,7 +102,7 @@ export class RemoveRedactionDialogComponent extends IqserDialogComponent<
value: RemoveRedactionOptions.ONLY_HERE,
});
}
if (this.#permissions.canRemoveOrSuggestToRemoveFromDictionary) {
if (this.#permissions.canRemoveFromDictionary) {
options.push({
label: this.#translations.IN_DOSSIER.label,
description: this.#translations.IN_DOSSIER.description,

View File

@ -123,8 +123,8 @@ export class AnnotationActionsService {
async removeOrSuggestRemoveRedaction(redaction: AnnotationWrapper, permissions) {
const removePermissions: RemoveRedactionPermissions = {
canRemoveOrSuggestToRemoveOnlyHere: permissions.canRemoveOrSuggestToRemoveOnlyHere,
canRemoveOrSuggestToRemoveFromDictionary: permissions.canRemoveOrSuggestToRemoveFromDictionary,
canRemoveOnlyHere: permissions.canRemoveOnlyHere,
canRemoveFromDictionary: permissions.canRemoveFromDictionary,
canMarkAsFalsePositive: permissions.canMarkAsFalsePositive,
};
const dossierTemplate = this._dossierTemplatesService.find(this._state.dossierTemplateId);

View File

@ -63,15 +63,6 @@ export class PdfAnnotationActionsService {
availableActions.push(recategorizeButton);
}
// if (permissions.canRemoveOrSuggestToRemoveFromDictionary) {
// const removeFromDictButton = this.#getButton(
// 'remove-from-dict',
// _('annotation-actions.remove-annotation.remove-from-dict'),
// () => this.#annotationActionsService.removeOrSuggestRemoveAnnotation(annotations, true),
// );
// availableActions.push(removeFromDictButton);
// }
if (permissions.canAcceptRecommendation) {
const acceptRecommendationButton = this.#getButton('check', _('annotation-actions.accept-recommendation.label'), () =>
this.#annotationActionsService.convertRecommendationToAnnotation(annotations),
@ -79,27 +70,6 @@ export class PdfAnnotationActionsService {
availableActions.push(acceptRecommendationButton);
}
if (permissions.canAcceptSuggestion) {
const acceptSuggestionButton = this.#getButton('check', _('annotation-actions.accept-suggestion.label'), () =>
this.#annotationActionsService.acceptSuggestion(annotations),
);
availableActions.push(acceptSuggestionButton);
}
if (permissions.canUndo) {
const undoButton = this.#getButton('undo', _('annotation-actions.undo'), () =>
this.#annotationActionsService.undoDirectAction(annotations),
);
availableActions.push(undoButton);
}
// if (permissions.canMarkAsFalsePositive) {
// const markAsFalsePositiveButton = this.#getButton('thumb-down', _('annotation-actions.remove-annotation.false-positive'), () =>
// this.#annotationActionsService.markAsFalsePositive(annotations),
// );
// availableActions.push(markAsFalsePositiveButton);
// }
if (permissions.canForceRedaction) {
const forceRedactionButton = this.#getButton('thumb-up', _('annotation-actions.force-redaction.label'), () =>
this.#annotationActionsService.forceAnnotation(annotations),
@ -114,27 +84,11 @@ export class PdfAnnotationActionsService {
availableActions.push(forceHintButton);
}
if (permissions.canRejectSuggestion) {
const rejectSuggestionButton = this.#getButton('close', _('annotation-actions.reject-suggestion'), () =>
this.#annotationActionsService.rejectSuggestion(annotations),
);
availableActions.push(rejectSuggestionButton);
}
// if (permissions.canRemoveOrSuggestToRemoveOnlyHere) {
// const removeOrSuggestToRemoveOnlyHereButton = this.#getButton(
// 'trash',
// _('annotation-actions.remove-annotation.only-here'),
// () => this.#annotationActionsService.removeOrSuggestRemoveAnnotation(annotations, false),
// );
// availableActions.push(removeOrSuggestToRemoveOnlyHereButton);
// }
if (permissions.canRemoveOrSuggestToRemoveRedaction) {
const removeOrSuggestToRemoveButton = this.#getButton('trash', _('annotation-actions.remove-annotation.remove-redaction'), () =>
if (permissions.canRemoveRedaction) {
const removeRedactionButton = this.#getButton('trash', _('annotation-actions.remove-annotation.remove-redaction'), () =>
this.#annotationActionsService.removeOrSuggestRemoveRedaction(annotations[0], permissions),
);
availableActions.push(removeOrSuggestToRemoveButton);
availableActions.push(removeRedactionButton);
}
return availableActions;
@ -158,21 +112,13 @@ export class PdfAnnotationActionsService {
canResize: permissions.length === 1 && permissions[0].canResizeAnnotation,
canChangeLegalBasis: permissions.reduce((acc, next) => acc && next.canChangeLegalBasis, true),
canRecategorizeImage: permissions.reduce((acc, next) => acc && next.canRecategorizeImage, true),
canRemoveOrSuggestToRemoveFromDictionary: permissions.reduce(
(acc, next) => acc && next.canRemoveOrSuggestToRemoveFromDictionary,
true,
),
canRemoveFromDictionary: permissions.reduce((acc, next) => acc && next.canRemoveFromDictionary, true),
canAcceptRecommendation: permissions.reduce((acc, next) => acc && next.canAcceptRecommendation, true),
canAcceptSuggestion: permissions.reduce((acc, next) => acc && next.canAcceptSuggestion, true),
canUndo:
this.#iqserPermissionsService.has(Roles.redactions.deleteManual) &&
permissions.reduce((acc, next) => acc && next.canUndo, true),
canMarkAsFalsePositive: permissions.reduce((acc, next) => acc && next.canMarkAsFalsePositive, true),
canForceRedaction: permissions.reduce((acc, next) => acc && next.canForceRedaction, true),
canForceHint: permissions.reduce((acc, next) => acc && next.canForceHint, true),
canRejectSuggestion: permissions.reduce((acc, next) => acc && next.canRejectSuggestion, true),
canRemoveOrSuggestToRemoveOnlyHere: permissions.reduce((acc, next) => acc && next.canRemoveOrSuggestToRemoveOnlyHere, true),
canRemoveOrSuggestToRemoveRedaction: permissions.reduce((acc, next) => acc && next.canRemoveOrSuggestToRemoveRedaction, true),
canRemoveOnlyHere: permissions.reduce((acc, next) => acc && next.canRemoveOnlyHere, true),
canRemoveRedaction: permissions.reduce((acc, next) => acc && next.canRemoveRedaction, true),
};
}
}

View File

@ -1958,7 +1958,7 @@
},
"in-dossier": {
"description": "Do not {type} \"{value}\" in any document of the current dossier.",
"label": "Remove in dossier"
"label": "Remove from dossier"
},
"only-here": {
"description": "Do not {type} \"{value}\" at this position in the current document.",

View File

@ -1958,7 +1958,7 @@
},
"in-dossier": {
"description": "Do not {type} \"{value}\" in any document of the current dossier.",
"label": "Remove in dossier"
"label": "Remove from dossier"
},
"only-here": {
"description": "Do not {type} \"{value}\" at this position in the current document.",

View File

@ -4,7 +4,6 @@ import { DictionaryEntryType } from './dictionary-entry-types';
export interface IAddRedactionRequest {
addToDictionary?: boolean;
addToDossierDictionary?: boolean;
dictionaryEntryType?: DictionaryEntryType;
comment?: { text: string };
legalBasis?: string;

View File

@ -3,7 +3,6 @@ import { LogEntryStatus } from './types';
export interface IManualRedactionEntry {
addToDictionary?: boolean;
addToDossierDictionary?: boolean;
annotationId?: string;
fileId?: string;
legalBasis?: string;