Merge branch 'VM/RED-7903' into 'master'

RED-7903 - Show dummy redaction/hints while file is still processing

Closes RED-7903

See merge request redactmanager/red-ui!260
This commit is contained in:
Dan Percic 2024-01-16 16:27:49 +01:00
commit 96593d708f

View File

@ -18,33 +18,36 @@ function wrongSuperTypeHandler(): never | undefined {
return undefined;
}
function resolveRedactionType(entry: IEntityLogEntry, hint = false) {
const redaction = hint ? SuperTypes.Hint : SuperTypes.Redaction;
const manualRedaction = hint ? SuperTypes.ManualHint : SuperTypes.ManualRedaction;
const manualChanges = entry.manualChanges;
const hasEngines = entry.engines.length;
const lastRelevantManualChange = manualChanges?.at(-1);
if (!!lastRelevantManualChange && !hasEngines) {
const pending = lastRelevantManualChange && !lastRelevantManualChange.processed;
if (pending && entry.dictionaryEntry) {
return redaction;
}
return manualRedaction;
}
return redaction;
}
/**
* https://knecon.atlassian.net/wiki/spaces/RED/pages/102072322/EntityLog+-+Enum+combinations
*/
export const SuperTypeMapper: Record<EntityType, Record<EntryState, (entry: IEntityLogEntry) => SuperType | undefined>> = {
[EntityTypes.ENTITY]: {
[EntryStates.APPLIED]: entry => {
const hasManualChanges = entry.manualChanges.length;
const hasEngines = entry.engines.length;
if (hasManualChanges && !hasEngines) {
return SuperTypes.ManualRedaction;
}
return SuperTypes.Redaction;
},
[EntryStates.APPLIED]: entry => resolveRedactionType(entry),
[EntryStates.SKIPPED]: () => SuperTypes.Skipped,
[EntryStates.IGNORED]: () => SuperTypes.Skipped,
[EntryStates.REMOVED]: wrongSuperTypeHandler,
},
[EntityTypes.HINT]: {
[EntryStates.APPLIED]: wrongSuperTypeHandler,
[EntryStates.SKIPPED]: entry => {
const hasManualChanges = entry.manualChanges.length;
const hasEngines = entry.engines.length;
if (hasManualChanges && !hasEngines) {
return SuperTypes.ManualHint;
}
return SuperTypes.Hint;
},
[EntryStates.SKIPPED]: entry => resolveRedactionType(entry, true),
[EntryStates.IGNORED]: () => SuperTypes.IgnoredHint,
[EntryStates.REMOVED]: wrongSuperTypeHandler,
},