From 2106a069a734d42cc745d2c008fa87db553c1a9f Mon Sep 17 00:00:00 2001 From: Valentin Mihai Date: Fri, 8 Mar 2024 10:59:52 +0200 Subject: [PATCH] RED-7980 - removed pending option --- libs/common-ui | 2 +- libs/red-domain/src/lib/files/super-types.ts | 33 +++++++++----------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/libs/common-ui b/libs/common-ui index 3ea4e45b8..ecf9c8912 160000 --- a/libs/common-ui +++ b/libs/common-ui @@ -1 +1 @@ -Subproject commit 3ea4e45b87b94868370492c475864390d984f65d +Subproject commit ecf9c8912e366fdcc0a454d112c0f3252245666a diff --git a/libs/red-domain/src/lib/files/super-types.ts b/libs/red-domain/src/lib/files/super-types.ts index cbb9f98a8..02f2c80db 100644 --- a/libs/red-domain/src/lib/files/super-types.ts +++ b/libs/red-domain/src/lib/files/super-types.ts @@ -14,25 +14,20 @@ export const SuperTypes = { export type SuperType = ValuesOf; -interface ResolveTypeOptions { - hint: boolean; - pending: boolean; -} - function wrongSuperTypeHandler(): never | undefined { return undefined; } -function resolveRedactionType(entry: IEntityLogEntry, options?: Partial) { - if (options?.pending && entry.oldState) { +function resolveRedactionType(entry: IEntityLogEntry, hint = false) { + if (entry.state === EntryStates.PENDING && entry.oldState) { return SuperTypeMapper[entry.entryType][entry.oldState](entry); } - const redaction = options?.hint ? SuperTypes.Hint : SuperTypes.Redaction; - const manualRedaction = options?.hint ? SuperTypes.ManualHint : SuperTypes.ManualRedaction; + const redaction = hint ? SuperTypes.Hint : SuperTypes.Redaction; + const manualRedaction = hint ? SuperTypes.ManualHint : SuperTypes.ManualRedaction; if (!entry.engines.length) { - return options?.pending && entry.dictionaryEntry ? redaction : manualRedaction; + return entry.state === EntryStates.PENDING && entry.dictionaryEntry ? redaction : manualRedaction; } return redaction; } @@ -46,56 +41,56 @@ export const SuperTypeMapper: Record SuperTypes.Skipped, [EntryStates.IGNORED]: () => SuperTypes.Skipped, [EntryStates.REMOVED]: wrongSuperTypeHandler, - [EntryStates.PENDING]: entry => resolveRedactionType(entry, { pending: true }), + [EntryStates.PENDING]: entry => resolveRedactionType(entry), }, [EntityTypes.HINT]: { [EntryStates.APPLIED]: wrongSuperTypeHandler, - [EntryStates.SKIPPED]: entry => resolveRedactionType(entry, { hint: true }), + [EntryStates.SKIPPED]: entry => resolveRedactionType(entry, true), [EntryStates.IGNORED]: () => SuperTypes.IgnoredHint, [EntryStates.REMOVED]: wrongSuperTypeHandler, - [EntryStates.PENDING]: entry => resolveRedactionType(entry, { pending: true }), + [EntryStates.PENDING]: entry => resolveRedactionType(entry), }, [EntityTypes.FALSE_POSITIVE]: { [EntryStates.APPLIED]: wrongSuperTypeHandler, [EntryStates.SKIPPED]: wrongSuperTypeHandler, [EntryStates.IGNORED]: wrongSuperTypeHandler, [EntryStates.REMOVED]: wrongSuperTypeHandler, - [EntryStates.PENDING]: entry => resolveRedactionType(entry, { pending: true }), + [EntryStates.PENDING]: entry => resolveRedactionType(entry), }, [EntityTypes.RECOMMENDATION]: { [EntryStates.APPLIED]: wrongSuperTypeHandler, [EntryStates.SKIPPED]: () => SuperTypes.Recommendation, [EntryStates.IGNORED]: wrongSuperTypeHandler, [EntryStates.REMOVED]: wrongSuperTypeHandler, - [EntryStates.PENDING]: entry => resolveRedactionType(entry, { pending: true }), + [EntryStates.PENDING]: entry => resolveRedactionType(entry), }, [EntityTypes.FALSE_RECOMMENDATION]: { [EntryStates.APPLIED]: wrongSuperTypeHandler, [EntryStates.SKIPPED]: wrongSuperTypeHandler, [EntryStates.IGNORED]: wrongSuperTypeHandler, [EntryStates.REMOVED]: wrongSuperTypeHandler, - [EntryStates.PENDING]: entry => resolveRedactionType(entry, { pending: true }), + [EntryStates.PENDING]: entry => resolveRedactionType(entry), }, [EntityTypes.AREA]: { [EntryStates.APPLIED]: () => SuperTypes.Redaction, [EntryStates.SKIPPED]: wrongSuperTypeHandler, [EntryStates.IGNORED]: wrongSuperTypeHandler, [EntryStates.REMOVED]: wrongSuperTypeHandler, - [EntryStates.PENDING]: entry => resolveRedactionType(entry, { pending: true }), + [EntryStates.PENDING]: entry => resolveRedactionType(entry), }, [EntityTypes.IMAGE]: { [EntryStates.APPLIED]: () => SuperTypes.Redaction, [EntryStates.SKIPPED]: () => SuperTypes.Skipped, [EntryStates.IGNORED]: () => SuperTypes.Skipped, [EntryStates.REMOVED]: wrongSuperTypeHandler, - [EntryStates.PENDING]: entry => resolveRedactionType(entry, { pending: true }), + [EntryStates.PENDING]: entry => resolveRedactionType(entry), }, [EntityTypes.IMAGE_HINT]: { [EntryStates.APPLIED]: wrongSuperTypeHandler, [EntryStates.SKIPPED]: () => SuperTypes.Hint, [EntryStates.IGNORED]: () => SuperTypes.IgnoredHint, [EntryStates.REMOVED]: wrongSuperTypeHandler, - [EntryStates.PENDING]: entry => resolveRedactionType(entry, { pending: true }), + [EntryStates.PENDING]: entry => resolveRedactionType(entry), }, };