84 lines
2.6 KiB
TypeScript
84 lines
2.6 KiB
TypeScript
import type {
|
|
PrivacyRetentionLimitPermissions,
|
|
PrivacyRetentionPolicy,
|
|
SystemSettingsDeltaSections,
|
|
SystemSettingsItem
|
|
} from "../../api/admin";
|
|
|
|
const defaultAllowLowerLevelLimits: PrivacyRetentionLimitPermissions = {
|
|
store_raw_campaign_json: true,
|
|
raw_campaign_json_retention_days: true,
|
|
generated_eml_retention_days: true,
|
|
stored_report_detail_retention_days: true,
|
|
mock_mailbox_retention_days: true,
|
|
audit_detail_retention_days: true,
|
|
audit_detail_level: true
|
|
};
|
|
|
|
const defaultPrivacyPolicy: PrivacyRetentionPolicy = {
|
|
store_raw_campaign_json: true,
|
|
raw_campaign_json_retention_days: null,
|
|
generated_eml_retention_days: null,
|
|
stored_report_detail_retention_days: null,
|
|
mock_mailbox_retention_days: null,
|
|
audit_detail_retention_days: null,
|
|
audit_detail_level: "full",
|
|
allow_lower_level_limits: defaultAllowLowerLevelLimits
|
|
};
|
|
|
|
export const SYSTEM_SETTINGS_FALLBACK: SystemSettingsItem = {
|
|
default_locale: "de",
|
|
allow_tenant_custom_groups: true,
|
|
allow_tenant_custom_roles: true,
|
|
allow_tenant_api_keys: true,
|
|
privacy_retention_policy: defaultPrivacyPolicy,
|
|
maintenance_mode: { enabled: false, message: "" },
|
|
available_languages: [
|
|
{ code: "de", label: "German", native_label: "Deutsch" },
|
|
{ code: "en", label: "English", native_label: "English" }
|
|
],
|
|
enabled_language_codes: ["de", "en"],
|
|
settings: {},
|
|
navigation: null,
|
|
appearance_palette: "default",
|
|
appearance_palette_locked: false,
|
|
appearance_custom_overrides_allowed: false
|
|
};
|
|
|
|
export function applySystemSettingsSections(
|
|
item: SystemSettingsItem,
|
|
sections: SystemSettingsDeltaSections
|
|
): SystemSettingsItem {
|
|
return {
|
|
...item,
|
|
...(sections.defaults ?? {}),
|
|
...(sections.tenant_capabilities ?? {}),
|
|
...(sections.languages ?? {}),
|
|
...(sections.privacy_retention_policy
|
|
? { privacy_retention_policy: sections.privacy_retention_policy }
|
|
: {}),
|
|
...(sections.maintenance_mode ? { maintenance_mode: sections.maintenance_mode } : {}),
|
|
...(sections.navigation !== undefined ? { navigation: sections.navigation } : {}),
|
|
...(sections.appearance ?? {}),
|
|
...(sections.settings ? { settings: sections.settings } : {})
|
|
};
|
|
}
|
|
|
|
export function normalizeLanguageCode(value: string): string {
|
|
return value
|
|
.trim()
|
|
.toLowerCase()
|
|
.replace(/_/g, "-")
|
|
.split(/[^a-z0-9]+/)
|
|
.filter(Boolean)
|
|
.join("-");
|
|
}
|
|
|
|
export function languageOptionLabel(language: {
|
|
code: string;
|
|
label: string;
|
|
native_label?: string | null;
|
|
}): string {
|
|
return `${language.code.toUpperCase()} - ${language.native_label || language.label}`;
|
|
}
|