From e1f298f300e738cf836372563e6d4efd24287415 Mon Sep 17 00:00:00 2001 From: Albrecht Degering Date: Tue, 21 Jul 2026 12:34:39 +0200 Subject: [PATCH] refactor(webui): use central profile selection --- .../features/mail/MailProfileManagement.tsx | 29 +++++++--------- webui/src/styles/mail-profiles.css | 34 ------------------- 2 files changed, 12 insertions(+), 51 deletions(-) diff --git a/webui/src/features/mail/MailProfileManagement.tsx b/webui/src/features/mail/MailProfileManagement.tsx index 1b7703d..55bfce9 100644 --- a/webui/src/features/mail/MailProfileManagement.tsx +++ b/webui/src/features/mail/MailProfileManagement.tsx @@ -1,5 +1,5 @@ import { useEffect, useMemo, useState, type ReactNode } from "react"; -import { ConnectionTree, FieldLabel, LoadingFrame, MailServerSettingsPanel, PolicyLockedHint, PolicyPathHelp, PolicyRow, PolicySourcePath, PolicyTable, StatusBadge, TableActionGroup, ToggleSwitch, hasMailImapSettings, mailImapSettingsPayload, mailServerSecurityOptions, mailSmtpSettingsPayload, mailTextOrNull, mailTransportCredentialsPayload, mergeDeltaRows, normalizeMailServerSecurity, normalizePolicySourcePathItems, useDeltaWatermarks, type ConnectionTreeColumn, type MailServerConnectionTestResult, type MailServerCredentialSettings, type MailServerImapSettings, type MailServerSmtpSettings, type NormalizedPolicySourcePathItem, type PolicySourcePathItem } from "@govoplan/core-webui"; +import { AdminSelectionList, ConnectionTree, FieldLabel, LoadingFrame, MailServerSettingsPanel, PolicyLockedHint, PolicyPathHelp, PolicyRow, PolicySourcePath, PolicyTable, StatusBadge, TableActionGroup, ToggleSwitch, hasMailImapSettings, mailImapSettingsPayload, mailServerSecurityOptions, mailSmtpSettingsPayload, mailTextOrNull, mailTransportCredentialsPayload, mergeDeltaRows, normalizeMailServerSecurity, normalizePolicySourcePathItems, useDeltaWatermarks, type ConnectionTreeColumn, type MailServerConnectionTestResult, type MailServerCredentialSettings, type MailServerImapSettings, type MailServerSmtpSettings, type NormalizedPolicySourcePathItem, type PolicySourcePathItem } from "@govoplan/core-webui"; import { Pencil, Plus, Trash2 } from "lucide-react"; import type { ApiSettings } from "../../types"; import { @@ -579,13 +579,6 @@ export function MailProfilePolicyEditor({ setPolicy((current) => normalizePolicy({ ...current, ...patch })); } - function toggleAllowedProfile(profileId: string, checked: boolean) { - const next = new Set(policy.allowed_profile_ids ?? []); - if (checked) next.add(profileId);else - next.delete(profileId); - patchPolicy({ allowed_profile_ids: [...next].sort() }); - } - function setFlag(key: "allow_user_profiles" | "allow_group_profiles" | "allow_campaign_profiles", value: PolicyFlagValue) { patchPolicy({ [key]: flagToBoolean(value) }); } @@ -655,15 +648,17 @@ export function MailProfilePolicyEditor({

{selectedProfileIds.size === 0 ? "i18n:govoplan-mail.no_local_profile_allow_list_is_set.31072e39" : i18nMessage("i18n:govoplan-mail.value_profile_s_allowed_by_this_scope.6fe9ba44", { value0: selectedProfileIds.size })}

-
- {candidateProfiles.map((profile) => - - )} - {candidateProfiles.length === 0 &&

i18n:govoplan-mail.no_profiles_are_visible_for_this_policy_scope.1ec7bd85

} -
+ ({ + id: profile.id, + label: profile.name, + description: `${scopeLabel(profile)} · ${transportLabel(profile.smtp)}`, + disabled: disabled || profileAllowListLocked || Boolean(parentAllowedProfileIds && !parentAllowedProfileIds.has(profile.id) && !selectedProfileIds.has(profile.id)) + }))} + selected={[...selectedProfileIds]} + onChange={(allowedProfileIds) => patchPolicy({ allowed_profile_ids: [...allowedProfileIds].sort() })} + emptyText="i18n:govoplan-mail.no_profiles_are_visible_for_this_policy_scope.1ec7bd85" + /> {parentAllowedProfileIds &&

i18n:govoplan-mail.an_ancestor_allow_list_limits_selectable_profile.499ec179 {parentAllowedProfileIds.size} i18n:govoplan-mail.profile_s.742e9200

} diff --git a/webui/src/styles/mail-profiles.css b/webui/src/styles/mail-profiles.css index 5c4e720..10e7292 100644 --- a/webui/src/styles/mail-profiles.css +++ b/webui/src/styles/mail-profiles.css @@ -87,40 +87,6 @@ margin: 0; } -.mail-profile-checkbox-grid { - display: grid; - grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); - gap: 10px; -} - -.mail-profile-checkbox { - display: grid; - grid-template-columns: auto minmax(0, 1fr); - align-items: start; - gap: 10px; - padding: 10px 12px; - border: var(--border-line); - border-radius: var(--radius-sm); - background: var(--surface); -} - -.mail-profile-checkbox input { - width: auto; - margin-top: 3px; - box-shadow: none; -} - -.mail-profile-checkbox span { - display: grid; - gap: 2px; - min-width: 0; -} - -.mail-profile-checkbox small { - color: var(--muted); - overflow-wrap: anywhere; -} - .mail-policy-row { grid-template-columns: minmax(190px, .9fr) minmax(210px, .75fr); }