From 8481b0a07377d7b991d1df0bd57eff0c73a7ad77 Mon Sep 17 00:00:00 2001 From: miloschwartz Date: Wed, 22 Apr 2026 17:52:31 -0700 Subject: [PATCH] dont filter admin role in role selector for alerts --- src/components/UptimeAlertSection.tsx | 5 +- .../alert-rule-editor/AlertRuleFields.tsx | 140 +++++++++++------- 2 files changed, 88 insertions(+), 57 deletions(-) diff --git a/src/components/UptimeAlertSection.tsx b/src/components/UptimeAlertSection.tsx index 96a6dc286..e959c985b 100644 --- a/src/components/UptimeAlertSection.tsx +++ b/src/components/UptimeAlertSection.tsx @@ -97,10 +97,7 @@ export default function UptimeAlertSection({ ); const allRoles = useMemo( - () => - orgRoles - .map((r) => ({ id: String(r.roleId), text: r.name })) - .filter((r) => r.text !== "Admin"), + () => orgRoles.map((r) => ({ id: String(r.roleId), text: r.name })), [orgRoles] ); diff --git a/src/components/alert-rule-editor/AlertRuleFields.tsx b/src/components/alert-rule-editor/AlertRuleFields.tsx index e9056256b..1d420f433 100644 --- a/src/components/alert-rule-editor/AlertRuleFields.tsx +++ b/src/components/alert-rule-editor/AlertRuleFields.tsx @@ -30,10 +30,7 @@ import { SelectTrigger, SelectValue } from "@app/components/ui/select"; -import { - RadioGroup, - RadioGroupItem -} from "@app/components/ui/radio-group"; +import { RadioGroup, RadioGroupItem } from "@app/components/ui/radio-group"; import { Label } from "@app/components/ui/label"; import { StrategySelect } from "@app/components/StrategySelect"; import { TagInput, type Tag } from "@app/components/tags/tag-input"; @@ -59,7 +56,6 @@ export function AddActionPanel({ }) { const t = useTranslations(); - const EXTERNAL_INTEGRATIONS = [ { id: "pagerduty", @@ -247,9 +243,7 @@ function HealthCheckMultiSelect({ const shown = useMemo(() => { const query = debounced.trim().toLowerCase(); const base = query - ? healthChecks.filter((hc) => - hc.name.toLowerCase().includes(query) - ) + ? healthChecks.filter((hc) => hc.name.toLowerCase().includes(query)) : healthChecks; // Always keep already-selected items visible even if they fall outside the search if (query && value.length > 0) { @@ -323,9 +317,7 @@ function HealthCheckMultiSelect({ aria-hidden tabIndex={-1} /> - - {hc.name} - + {hc.name} ))} @@ -510,8 +502,12 @@ function NotifyActionFields({ number | null >(null); - const { data: orgUsers = [], isLoading: isLoadingUsers } = useQuery(orgQueries.users({ orgId })); - const { data: orgRoles = [], isLoading: isLoadingRoles } = useQuery(orgQueries.roles({ orgId })); + const { data: orgUsers = [], isLoading: isLoadingUsers } = useQuery( + orgQueries.users({ orgId }) + ); + const { data: orgRoles = [], isLoading: isLoadingRoles } = useQuery( + orgQueries.roles({ orgId }) + ); const allUsers = useMemo( () => @@ -527,10 +523,7 @@ function NotifyActionFields({ ); const allRoles = useMemo( - () => - orgRoles - .map((r) => ({ id: String(r.roleId), text: r.name })) - .filter((r) => r.text !== "Admin"), + () => orgRoles.map((r) => ({ id: String(r.roleId), text: r.name })), [orgRoles] ); @@ -578,9 +571,18 @@ function NotifyActionFields({ hasResolvedTagsRef.current = true; }, [isLoadingUsers, isLoadingRoles, allUsers, allRoles]); - const userTags = (useWatch({ control, name: `actions.${index}.userTags` }) ?? []) as Tag[]; - const roleTags = (useWatch({ control, name: `actions.${index}.roleTags` }) ?? []) as Tag[]; - const emailTags = (useWatch({ control, name: `actions.${index}.emailTags` }) ?? []) as Tag[]; + const userTags = (useWatch({ + control, + name: `actions.${index}.userTags` + }) ?? []) as Tag[]; + const roleTags = (useWatch({ + control, + name: `actions.${index}.roleTags` + }) ?? []) as Tag[]; + const emailTags = (useWatch({ + control, + name: `actions.${index}.emailTags` + }) ?? []) as Tag[]; return (
@@ -788,7 +790,9 @@ function WebhookActionFields({ {t("httpDestAuthNoneTitle")}

- {t("httpDestAuthNoneDescription")} + {t( + "httpDestAuthNoneDescription" + )}

@@ -806,10 +810,14 @@ function WebhookActionFields({ htmlFor={`auth-bearer-${index}`} className="cursor-pointer font-medium" > - {t("httpDestAuthBearerTitle")} + {t( + "httpDestAuthBearerTitle" + )}

- {t("httpDestAuthBearerDescription")} + {t( + "httpDestAuthBearerDescription" + )}

{field.value === "bearer" && ( @@ -821,7 +829,9 @@ function WebhookActionFields({ @@ -845,10 +855,14 @@ function WebhookActionFields({ htmlFor={`auth-basic-${index}`} className="cursor-pointer font-medium" > - {t("httpDestAuthBasicTitle")} + {t( + "httpDestAuthBasicTitle" + )}

- {t("httpDestAuthBasicDescription")} + {t( + "httpDestAuthBasicDescription" + )}

{field.value === "basic" && ( @@ -860,7 +874,9 @@ function WebhookActionFields({ @@ -884,10 +900,14 @@ function WebhookActionFields({ htmlFor={`auth-custom-${index}`} className="cursor-pointer font-medium" > - {t("httpDestAuthCustomTitle")} + {t( + "httpDestAuthCustomTitle" + )}

- {t("httpDestAuthCustomDescription")} + {t( + "httpDestAuthCustomDescription" + )}

{field.value === "custom" && ( @@ -895,12 +915,16 @@ function WebhookActionFields({ ( + render={({ + field: f + }) => ( @@ -910,12 +934,16 @@ function WebhookActionFields({ ( + render={({ + field: f + }) => ( @@ -949,7 +977,7 @@ function WebhookHeadersField({ }) { const t = useTranslations(); const headers = - (useWatch({ control, name: `actions.${index}.headers` as const }) ?? []); + useWatch({ control, name: `actions.${index}.headers` as const }) ?? []; return (
{t("alertingWebhookHeaders")} @@ -961,7 +989,12 @@ function WebhookHeadersField({ render={({ field }) => ( - + )} @@ -972,7 +1005,12 @@ function WebhookHeadersField({ render={({ field }) => ( - + )} @@ -984,9 +1022,8 @@ function WebhookHeadersField({ className="shrink-0" onClick={() => { const cur = - form.getValues( - `actions.${index}.headers` - ) ?? []; + form.getValues(`actions.${index}.headers`) ?? + []; form.setValue( `actions.${index}.headers`, cur.filter((__, i) => i !== hi), @@ -1005,10 +1042,11 @@ function WebhookHeadersField({ onClick={() => { const cur = form.getValues(`actions.${index}.headers`) ?? []; - form.setValue(`actions.${index}.headers`, [ - ...cur, - { key: "", value: "" } - ], { shouldDirty: true }); + form.setValue( + `actions.${index}.headers`, + [...cur, { key: "", value: "" }], + { shouldDirty: true } + ); }} > @@ -1111,22 +1149,18 @@ export function AlertRuleSourceFields({ curTrigger !== "resource_unhealthy" && curTrigger !== "resource_toggle" ) { - setValue( - "trigger", - "resource_toggle", - { shouldValidate: true } - ); + setValue("trigger", "resource_toggle", { + shouldValidate: true + }); } } else if ( curTrigger !== "health_check_healthy" && curTrigger !== "health_check_unhealthy" && curTrigger !== "health_check_toggle" ) { - setValue( - "trigger", - "health_check_toggle", - { shouldValidate: true } - ); + setValue("trigger", "health_check_toggle", { + shouldValidate: true + }); } }} >