Add retention policy option regression coverage
This commit is contained in:
@@ -21,6 +21,7 @@ import FormField from "../../components/FormField";
|
||||
import ToggleSwitch from "../../components/ToggleSwitch";
|
||||
import { useUnsavedDraftGuard } from "../../components/UnsavedChangesGuard";
|
||||
import {
|
||||
privacyRetentionAuditDetailOptionDisabled,
|
||||
privacyRetentionLocalAllowsLowerLevel,
|
||||
privacyRetentionParentAllowsField } from
|
||||
"./policyLogic";
|
||||
@@ -70,8 +71,6 @@ type FieldDefinition = {
|
||||
type RawJsonValue = "inherit" | "keep" | "disable";
|
||||
type AuditDetailValue = "inherit" | PrivacyRetentionPolicy["audit_detail_level"];
|
||||
|
||||
const auditDetailOrder: Record<PrivacyRetentionPolicy["audit_detail_level"], number> = { full: 0, redacted: 1, minimal: 2 };
|
||||
|
||||
const defaultAllowLowerLevelLimits: PrivacyRetentionLimitPermissions = {
|
||||
store_raw_campaign_json: true,
|
||||
raw_campaign_json_retention_days: true,
|
||||
@@ -517,9 +516,8 @@ function RetentionDaysField({ value, disabled, placeholder, max, onChange }: {va
|
||||
}
|
||||
|
||||
function AuditDetailSelect({ value, includeInherit, parentValue, disabled, onChange }: {value: AuditDetailValue;includeInherit: boolean;parentValue?: PrivacyRetentionPolicy["audit_detail_level"] | null;disabled: boolean;onChange: (value: AuditDetailValue) => void;}) {
|
||||
const minimumOrder = parentValue ? auditDetailOrder[parentValue] : 0;
|
||||
function optionDisabled(option: PrivacyRetentionPolicy["audit_detail_level"]): boolean {
|
||||
return auditDetailOrder[option] < minimumOrder;
|
||||
return privacyRetentionAuditDetailOptionDisabled(option, parentValue);
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -11,6 +11,10 @@ export type RetentionPolicyLimitCarrier = {
|
||||
allow_lower_level_limits?: Partial<Record<PrivacyRetentionPolicyFieldKey, boolean>> | null;
|
||||
};
|
||||
|
||||
export type PrivacyRetentionAuditDetailLevel = "full" | "redacted" | "minimal";
|
||||
|
||||
const auditDetailOrder: Record<PrivacyRetentionAuditDetailLevel, number> = { full: 0, redacted: 1, minimal: 2 };
|
||||
|
||||
export function privacyRetentionParentAllowsField(parentPolicy: RetentionPolicyLimitCarrier | null, key: PrivacyRetentionPolicyFieldKey): boolean {
|
||||
return !parentPolicy || parentPolicy.allow_lower_level_limits?.[key] !== false;
|
||||
}
|
||||
@@ -27,3 +31,11 @@ export function privacyRetentionLocalAllowsLowerLevel(
|
||||
if (localValue !== undefined) return localValue && privacyRetentionParentAllowsField(parentPolicy, key);
|
||||
return privacyRetentionParentAllowsField(parentPolicy, key);
|
||||
}
|
||||
|
||||
export function privacyRetentionAuditDetailOptionDisabled(
|
||||
option: PrivacyRetentionAuditDetailLevel,
|
||||
parentValue?: PrivacyRetentionAuditDetailLevel | null
|
||||
): boolean {
|
||||
const minimumOrder = parentValue ? auditDetailOrder[parentValue] : 0;
|
||||
return auditDetailOrder[option] < minimumOrder;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user