mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-11-30 17:42:32 +01:00
Fix dark-mode contrast and a11y on alert destinations and history (#5441)
Fix dark-mode white-flash hover defects, missing button and ARIA state semantics, NaN rate-limit state corruption, and sub-44px phone touch targets across unclaimed /alerts/destinations and /alerts/history controls: - Replace light-only hover:bg-slate-100 on WebhookConfigForm's Test button (1.00:1 invisible white-on-white hover in dark mode) and CollapsibleSection's SectionActionButton default variant with theme-safe hover:bg-surface-hover (9.45:1 dark hover contrast, 17.06:1 light). - Add explicit type="button" across WebhookConfig, WebhookConfigForm, and WebhookConfigList controls, aria-pressed on webhook Enabled toggles and IncidentEventFilters chips, aria-expanded on webhook Service Type, Email setup/advanced disclosures, and Resource Incidents event toggles, and focus-visible keyboard rings. - Guard EmailProviderSelect's Rate limit input against empty/NaN edits so clearing the field while editing does not overwrite the saved value with the 60-second fallback; restore the saved value on blur if invalid. - Stack AlertHistoryAdministrationCard cleanly on narrow viewports and ensure 44px phone touch targets (min-h-11 sm:min-h-0) on External watchdog Remove, Clear All History, IncidentEventFilters chips/actions, and Resource Incidents controls while keeping desktop compact and reducing Total JS by 0.05 kB via hoisted shared class constants. Contract-Neutral: UI-only dark-mode contrast, ARIA/button semantics, numeric input editing guard, and narrow-viewport touch-target polish with no API, backend, schema, or subsystem contract delta. --- Fleet candidate `20261128T201010Z-web-product` from the `web-product` lane. Reviewed tip `cb9baa08a7bf74dd1cee29bb4fdb8bc21d306a76` on `main`. [How Pulse handles triage](https://github.com/rcourtman/Pulse/blob/main/docs/AI_TRANSPARENCY.md)
This commit is contained in:
53
frontend-modern/browser-verification/2f22582b3c428f43.json
Normal file
53
frontend-modern/browser-verification/2f22582b3c428f43.json
Normal file
@@ -0,0 +1,53 @@
|
||||
{
|
||||
"version": 1,
|
||||
"base_sha": "f1d9e7a2a94e4551998d23b19e5864ccf1553be1",
|
||||
"verified_at": "2026-11-28T18:53:14Z",
|
||||
"result": "passed",
|
||||
"changed_paths": [
|
||||
"frontend-modern/src/components/Alerts/EmailProviderSelect.tsx",
|
||||
"frontend-modern/src/components/Alerts/IncidentEventFilters.tsx",
|
||||
"frontend-modern/src/components/Alerts/Thresholds/sections/CollapsibleSection.tsx",
|
||||
"frontend-modern/src/components/Alerts/WebhookConfig.tsx",
|
||||
"frontend-modern/src/components/Alerts/WebhookConfigForm.tsx",
|
||||
"frontend-modern/src/components/Alerts/WebhookConfigList.tsx",
|
||||
"frontend-modern/src/features/alerts/AlertDeadManDestinationSection.tsx",
|
||||
"frontend-modern/src/features/alerts/AlertHistoryAdministrationCard.tsx",
|
||||
"frontend-modern/src/features/alerts/AlertResourceIncidentsPanel.tsx"
|
||||
],
|
||||
"content_sha256": {
|
||||
"frontend-modern/src/components/Alerts/EmailProviderSelect.tsx": "9e81c2fce5db1d346a99ac23c1c98195975e6d6913fa530cffffe9e0d7b84c09",
|
||||
"frontend-modern/src/components/Alerts/IncidentEventFilters.tsx": "a948c944de88eba2a994784ae624a0e80fb889220096703e0610752f17932855",
|
||||
"frontend-modern/src/components/Alerts/Thresholds/sections/CollapsibleSection.tsx": "14fc5d885bc416b46c689f31a8bd50f9506c6743e2d75a99b611cec349f1c177",
|
||||
"frontend-modern/src/components/Alerts/WebhookConfig.tsx": "c6250529e1da033ebb825ad783661206c5c3b9d91dcbee8dc412430adecf85ad",
|
||||
"frontend-modern/src/components/Alerts/WebhookConfigForm.tsx": "f21015da35a7163523cf4fd4bde1d5256aa4600a7899af1286884b4edd5280c6",
|
||||
"frontend-modern/src/components/Alerts/WebhookConfigList.tsx": "6a9876ed4dec2c8543785cfa4e8ef2a97be759b7a1cf989233bc4590a8cfbcde",
|
||||
"frontend-modern/src/features/alerts/AlertDeadManDestinationSection.tsx": "1436bb0e5af3c8cf9304bfa31fe37d4ab44a2e1396460141be2eea0977546cc4",
|
||||
"frontend-modern/src/features/alerts/AlertHistoryAdministrationCard.tsx": "881908a9681e1630f9ca93c57f969fda39c09d691527e97480efe8af9b2533f6",
|
||||
"frontend-modern/src/features/alerts/AlertResourceIncidentsPanel.tsx": "bb1c61c0b247792fd1c13fcbbeb660a3cd9040525868f61047f1e73053291305"
|
||||
},
|
||||
"routes": [
|
||||
"/alerts/destinations",
|
||||
"/alerts/history"
|
||||
],
|
||||
"viewports": [
|
||||
{
|
||||
"width": 1440,
|
||||
"height": 940
|
||||
},
|
||||
{
|
||||
"width": 360,
|
||||
"height": 820
|
||||
}
|
||||
],
|
||||
"states": [
|
||||
"Paired production dist builds of base f1d9e7a2a9 and patched Alert Destinations & History served over loopback HTTP via pulse-worker-browser in desktop Chromium (1440x940 dark and light) and touch phone WebKit (360x820 dark, isMobile=true, hasTouch=true) with 0 console errors, 0 page errors, 0 unexpected HTTP>=400 responses, and 0px horizontal overflow across all 12 captures (all 12 PNGs inspected natively).",
|
||||
"/alerts/destinations Webhook edit form Test button hover in desktop Chromium dark mode: background changes from light slate-100 rgb(241, 245, 249) with 1.00:1 contrast (blank white rectangle hiding light text) to dark surface-hover rgb(51, 65, 85) with 9.45:1 contrast; light mode improves from 16.30:1 to 17.06:1.",
|
||||
"/alerts/destinations Email notifications and Webhook controls: Webhook Enabled toggle gains type=\"button\" and aria-pressed=\"true\", Service Type picker gains aria-expanded, Email Show/Hide advanced options and phone Show setup instructions disclosures gain aria-expanded, and clearing Rate limit leaves the input empty without overwriting saved 45 with 60 on blur.",
|
||||
"/alerts/destinations and /alerts/history touch phone WebKit (360x820 dark): External watchdog Remove grows from 38px to 44px, Administrative Actions stacks cleanly with Clear All History growing from 34px to 44px, and the mobile Resource incidents drawer Refresh (26px -> 44px), Fired filter chip (21px -> 44px, aria-pressed=\"true\"), and Events (2) toggle (26px -> 44px, aria-expanded) all meet 44px touch targets with 0px overflow while desktop layout stays compact."
|
||||
],
|
||||
"interactions": [
|
||||
"Opened Ops Discord webhook editor on /alerts/destinations in desktop Chromium dark and light modes, hovered the form Test button, verified contrast ratio improved from 1.00:1 to 9.45:1 in dark mode and 16.30:1 to 17.06:1 in light mode, and checked explicit button/ARIA attributes.",
|
||||
"Expanded Email advanced options on /alerts/destinations (aria-expanded false -> true), cleared Rate limit from 45 to empty string, and blurred to verify saved 45 was restored instead of snapping to 60.",
|
||||
"Opened Resource incidents on /alerts/history in desktop Chromium dark mode and touch phone WebKit (360x820 dark), verified Fired filter chip aria-pressed=\"true\" and toggled Events (2) -> Hide events (aria-expanded false -> true)."
|
||||
]
|
||||
}
|
||||
@@ -832,4 +832,53 @@ describe('EmailProviderSelect', () => {
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('tracks aria-expanded on disclosures and ignores empty/NaN rate limit edits without corrupting state', async () => {
|
||||
const [config, setConfig] = createSignal(makeConfig({ provider: 'Gmail', rateLimit: 45 }));
|
||||
|
||||
render(() => (
|
||||
<EmailProviderSelect
|
||||
config={config()}
|
||||
onChange={(next) => {
|
||||
setConfig(next);
|
||||
onChangeMock(next);
|
||||
}}
|
||||
onTest={onTestMock}
|
||||
/>
|
||||
));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(getEmailProvidersMock).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
const instructionsToggle = screen.getByRole('button', { name: 'Show setup instructions' });
|
||||
expect(instructionsToggle).toHaveAttribute('aria-expanded', 'false');
|
||||
fireEvent.click(instructionsToggle);
|
||||
expect(screen.getByRole('button', { name: 'Hide setup instructions' })).toHaveAttribute(
|
||||
'aria-expanded',
|
||||
'true',
|
||||
);
|
||||
|
||||
const advancedToggle = screen.getByRole('button', { name: 'Show advanced options' });
|
||||
expect(advancedToggle).toHaveAttribute('aria-expanded', 'false');
|
||||
fireEvent.click(advancedToggle);
|
||||
expect(screen.getByRole('button', { name: 'Hide advanced options' })).toHaveAttribute(
|
||||
'aria-expanded',
|
||||
'true',
|
||||
);
|
||||
|
||||
const rateLimitInput = screen.getByRole('spinbutton', {
|
||||
name: 'Rate limit',
|
||||
}) as HTMLInputElement;
|
||||
onChangeMock.mockClear();
|
||||
fireEvent.input(rateLimitInput, { target: { value: '' } });
|
||||
expect(onChangeMock).not.toHaveBeenCalled();
|
||||
expect(config().rateLimit).toBe(45);
|
||||
|
||||
fireEvent.blur(rateLimitInput);
|
||||
expect(rateLimitInput.value).toBe('45');
|
||||
|
||||
fireEvent.input(rateLimitInput, { target: { value: '25' } });
|
||||
expect(config().rateLimit).toBe(25);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -55,6 +55,11 @@ interface EmailProviderSelectProps extends EmailProviderSelectStateProps {
|
||||
testing?: boolean;
|
||||
}
|
||||
|
||||
const EMAIL_LABEL_CLASS = labelClass();
|
||||
const EMAIL_CONTROL_CLASS = controlClass('px-2 py-1.5');
|
||||
const EMAIL_INSTRUCTION_BOX_CLASS =
|
||||
'mt-2 rounded-sm border border-blue-200 bg-blue-50 px-3 py-2 text-xs leading-relaxed text-blue-900 dark:border-blue-700 dark:bg-blue-900/25 dark:text-blue-200';
|
||||
|
||||
export function EmailProviderSelect(props: EmailProviderSelectProps) {
|
||||
const state = useEmailProviderSelectState(props);
|
||||
const fieldIdPrefix = `alert-email-${createUniqueId()}`;
|
||||
@@ -72,8 +77,6 @@ export function EmailProviderSelect(props: EmailProviderSelectProps) {
|
||||
brandName: `${fieldIdPrefix}-brand-name`,
|
||||
footerNote: `${fieldIdPrefix}-footer-note`,
|
||||
};
|
||||
const instructionBoxClass =
|
||||
'mt-2 rounded-sm border border-blue-200 bg-blue-50 px-3 py-2 text-xs leading-relaxed text-blue-900 dark:border-blue-700 dark:bg-blue-900/25 dark:text-blue-200';
|
||||
|
||||
return (
|
||||
<div class="space-y-4 text-sm overflow-hidden">
|
||||
@@ -84,7 +87,7 @@ export function EmailProviderSelect(props: EmailProviderSelectProps) {
|
||||
label={ALERT_EMAIL_PROVIDER_LABEL}
|
||||
value={props.config.provider}
|
||||
onChange={(e) => state.handleProviderChange(e.currentTarget.value)}
|
||||
selectBaseClass={controlClass('px-2 py-1.5')}
|
||||
selectBaseClass={EMAIL_CONTROL_CLASS}
|
||||
selectClass="sm:w-auto sm:min-w-[180px]"
|
||||
>
|
||||
<option value="">{ALERT_EMAIL_MANUAL_CONFIGURATION_LABEL}</option>
|
||||
@@ -113,23 +116,24 @@ export function EmailProviderSelect(props: EmailProviderSelectProps) {
|
||||
<div class="sm:hidden w-full">
|
||||
<button
|
||||
type="button"
|
||||
aria-expanded={state.showInstructions()}
|
||||
onClick={state.toggleShowInstructions}
|
||||
class="min-h-11 text-xs font-medium text-blue-600 hover:underline sm:min-h-0 dark:text-blue-300"
|
||||
class="min-h-11 rounded-xs text-xs font-medium text-blue-600 hover:underline focus:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-500 sm:min-h-0 dark:text-blue-300"
|
||||
>
|
||||
{getAlertEmailSetupInstructionsToggleLabel(state.showInstructions())}
|
||||
</button>
|
||||
<Show when={state.showInstructions()}>
|
||||
<div class={instructionBoxClass}>{state.currentProvider()!.instructions}</div>
|
||||
<div class={EMAIL_INSTRUCTION_BOX_CLASS}>{state.currentProvider()!.instructions}</div>
|
||||
</Show>
|
||||
</div>
|
||||
<div class="hidden w-full sm:block">
|
||||
<div class={instructionBoxClass}>{state.currentProvider()!.instructions}</div>
|
||||
<div class={EMAIL_INSTRUCTION_BOX_CLASS}>{state.currentProvider()!.instructions}</div>
|
||||
</div>
|
||||
</Show>
|
||||
|
||||
<div class="grid w-full gap-3 sm:grid-cols-2">
|
||||
<div class={formField}>
|
||||
<label for={fieldIds.smtpServer} class={labelClass()}>
|
||||
<label for={fieldIds.smtpServer} class={EMAIL_LABEL_CLASS}>
|
||||
{ALERT_EMAIL_SMTP_SERVER_LABEL}
|
||||
</label>
|
||||
<input
|
||||
@@ -138,12 +142,12 @@ export function EmailProviderSelect(props: EmailProviderSelectProps) {
|
||||
value={props.config.server}
|
||||
onInput={(e) => props.onChange({ ...props.config, server: e.currentTarget.value })}
|
||||
placeholder={ALERT_EMAIL_SMTP_SERVER_PLACEHOLDER}
|
||||
class={controlClass('px-2 py-1.5')}
|
||||
class={EMAIL_CONTROL_CLASS}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class={formField}>
|
||||
<label for={fieldIds.smtpPort} class={labelClass()}>
|
||||
<label for={fieldIds.smtpPort} class={EMAIL_LABEL_CLASS}>
|
||||
{ALERT_EMAIL_SMTP_PORT_LABEL}
|
||||
</label>
|
||||
<input
|
||||
@@ -166,12 +170,12 @@ export function EmailProviderSelect(props: EmailProviderSelectProps) {
|
||||
}
|
||||
}}
|
||||
placeholder={ALERT_EMAIL_SMTP_PORT_PLACEHOLDER}
|
||||
class={controlClass('px-2 py-1.5')}
|
||||
class={EMAIL_CONTROL_CLASS}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class={`${formField} sm:col-span-2`}>
|
||||
<label for={fieldIds.fromAddress} class={labelClass()}>
|
||||
<label for={fieldIds.fromAddress} class={EMAIL_LABEL_CLASS}>
|
||||
{ALERT_EMAIL_FROM_ADDRESS_LABEL}
|
||||
</label>
|
||||
<input
|
||||
@@ -180,12 +184,12 @@ export function EmailProviderSelect(props: EmailProviderSelectProps) {
|
||||
value={props.config.from}
|
||||
onInput={(e) => props.onChange({ ...props.config, from: e.currentTarget.value })}
|
||||
placeholder={ALERT_EMAIL_FROM_ADDRESS_PLACEHOLDER}
|
||||
class={controlClass('px-2 py-1.5')}
|
||||
class={EMAIL_CONTROL_CLASS}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class={formField}>
|
||||
<label for={fieldIds.username} class={labelClass()}>
|
||||
<label for={fieldIds.username} class={EMAIL_LABEL_CLASS}>
|
||||
{ALERT_EMAIL_USERNAME_LABEL}
|
||||
</label>
|
||||
<input
|
||||
@@ -194,13 +198,13 @@ export function EmailProviderSelect(props: EmailProviderSelectProps) {
|
||||
value={props.config.username}
|
||||
onInput={(e) => props.onChange({ ...props.config, username: e.currentTarget.value })}
|
||||
placeholder={getAlertEmailUsernamePlaceholder(props.config.provider)}
|
||||
class={controlClass('px-2 py-1.5')}
|
||||
class={EMAIL_CONTROL_CLASS}
|
||||
autocomplete="off"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class={formField}>
|
||||
<label for={fieldIds.password} class={labelClass()}>
|
||||
<label for={fieldIds.password} class={EMAIL_LABEL_CLASS}>
|
||||
{ALERT_EMAIL_PASSWORD_LABEL}
|
||||
</label>
|
||||
<input
|
||||
@@ -209,7 +213,7 @@ export function EmailProviderSelect(props: EmailProviderSelectProps) {
|
||||
value={props.config.password}
|
||||
onInput={(e) => props.onChange({ ...props.config, password: e.currentTarget.value })}
|
||||
placeholder={ALERT_EMAIL_PASSWORD_PLACEHOLDER}
|
||||
class={controlClass('px-2 py-1.5')}
|
||||
class={EMAIL_CONTROL_CLASS}
|
||||
autocomplete="new-password"
|
||||
/>
|
||||
</div>
|
||||
@@ -245,7 +249,7 @@ export function EmailProviderSelect(props: EmailProviderSelectProps) {
|
||||
|
||||
<div class="space-y-2 border-t border-border pt-3">
|
||||
<div>
|
||||
<div class={labelClass()}>Resource tag routing</div>
|
||||
<div class={EMAIL_LABEL_CLASS}>Resource tag routing</div>
|
||||
<p class={formHelpText + ' mt-1'}>
|
||||
Leave empty to receive all alerts. Add tags to deliver only alerts from matching
|
||||
resources.
|
||||
@@ -268,7 +272,7 @@ export function EmailProviderSelect(props: EmailProviderSelectProps) {
|
||||
tagFilterMode: event.currentTarget.value === 'any' ? 'any' : 'all',
|
||||
})
|
||||
}
|
||||
selectBaseClass={controlClass('px-2 py-1.5')}
|
||||
selectBaseClass={EMAIL_CONTROL_CLASS}
|
||||
>
|
||||
<option value="all">Match all tags</option>
|
||||
<option value="any">Match any tag</option>
|
||||
@@ -279,8 +283,9 @@ export function EmailProviderSelect(props: EmailProviderSelectProps) {
|
||||
<div class="border-t border-border pt-3">
|
||||
<button
|
||||
type="button"
|
||||
aria-expanded={state.showAdvanced()}
|
||||
onClick={state.toggleShowAdvanced}
|
||||
class="min-h-11 text-xs font-semibold uppercase tracking-wide transition-colors hover:text-muted sm:min-h-0"
|
||||
class="min-h-11 rounded-xs text-xs font-semibold uppercase tracking-wide transition-colors hover:text-muted focus:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-500 sm:min-h-0"
|
||||
>
|
||||
{getAlertEmailAdvancedToggleLabel(state.showAdvanced())}
|
||||
</button>
|
||||
@@ -322,9 +327,15 @@ export function EmailProviderSelect(props: EmailProviderSelectProps) {
|
||||
type="number"
|
||||
min="1"
|
||||
value={props.config.rateLimit || 60}
|
||||
onInput={(e) =>
|
||||
props.onChange({ ...props.config, rateLimit: parseInt(e.currentTarget.value) })
|
||||
}
|
||||
onInput={(e) => {
|
||||
const n = parseInt(e.currentTarget.value, 10);
|
||||
if (n >= 1) props.onChange({ ...props.config, rateLimit: n });
|
||||
}}
|
||||
onBlur={(e) => {
|
||||
if (!(parseInt(e.currentTarget.value, 10) >= 1)) {
|
||||
e.currentTarget.value = String(props.config.rateLimit || 60);
|
||||
}
|
||||
}}
|
||||
class={`${controlClass('px-2 py-1 text-sm')} w-20`}
|
||||
/>
|
||||
<span class={formHelpText}>{ALERT_EMAIL_RATE_LIMIT_SUFFIX}</span>
|
||||
@@ -335,12 +346,12 @@ export function EmailProviderSelect(props: EmailProviderSelectProps) {
|
||||
|
||||
<div class="space-y-3 border-t border-border pt-3">
|
||||
<div>
|
||||
<div class={labelClass()}>{ALERT_EMAIL_BRANDING_HEADING}</div>
|
||||
<div class={EMAIL_LABEL_CLASS}>{ALERT_EMAIL_BRANDING_HEADING}</div>
|
||||
<p class={formHelpText + ' mt-1'}>{ALERT_EMAIL_BRANDING_HELP}</p>
|
||||
</div>
|
||||
<div class="grid w-full gap-3 sm:grid-cols-2">
|
||||
<div class={formField}>
|
||||
<label for={fieldIds.subjectPrefix} class={labelClass()}>
|
||||
<label for={fieldIds.subjectPrefix} class={EMAIL_LABEL_CLASS}>
|
||||
{ALERT_EMAIL_SUBJECT_PREFIX_LABEL}
|
||||
</label>
|
||||
<input
|
||||
@@ -352,11 +363,11 @@ export function EmailProviderSelect(props: EmailProviderSelectProps) {
|
||||
props.onChange({ ...props.config, subjectPrefix: e.currentTarget.value })
|
||||
}
|
||||
placeholder={ALERT_EMAIL_SUBJECT_PREFIX_PLACEHOLDER}
|
||||
class={controlClass('px-2 py-1.5')}
|
||||
class={EMAIL_CONTROL_CLASS}
|
||||
/>
|
||||
</div>
|
||||
<div class={formField}>
|
||||
<label for={fieldIds.brandName} class={labelClass()}>
|
||||
<label for={fieldIds.brandName} class={EMAIL_LABEL_CLASS}>
|
||||
{ALERT_EMAIL_BRAND_NAME_LABEL}
|
||||
</label>
|
||||
<input
|
||||
@@ -368,11 +379,11 @@ export function EmailProviderSelect(props: EmailProviderSelectProps) {
|
||||
props.onChange({ ...props.config, brandName: e.currentTarget.value })
|
||||
}
|
||||
placeholder={ALERT_EMAIL_BRAND_NAME_PLACEHOLDER}
|
||||
class={controlClass('px-2 py-1.5')}
|
||||
class={EMAIL_CONTROL_CLASS}
|
||||
/>
|
||||
</div>
|
||||
<div class={`${formField} sm:col-span-2`}>
|
||||
<label for={fieldIds.footerNote} class={labelClass()}>
|
||||
<label for={fieldIds.footerNote} class={EMAIL_LABEL_CLASS}>
|
||||
{ALERT_EMAIL_FOOTER_NOTE_LABEL}
|
||||
</label>
|
||||
<input
|
||||
@@ -384,7 +395,7 @@ export function EmailProviderSelect(props: EmailProviderSelectProps) {
|
||||
props.onChange({ ...props.config, footerNote: e.currentTarget.value })
|
||||
}
|
||||
placeholder={ALERT_EMAIL_FOOTER_NOTE_PLACEHOLDER}
|
||||
class={controlClass('px-2 py-1.5')}
|
||||
class={EMAIL_CONTROL_CLASS}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -45,7 +45,7 @@ export function IncidentEventFilters(props: IncidentEventFiltersProps) {
|
||||
{(action) => (
|
||||
<button
|
||||
type="button"
|
||||
class={getAlertIncidentEventFilterActionButtonClass()}
|
||||
class={`${getAlertIncidentEventFilterActionButtonClass()} min-h-11 focus:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-500 sm:min-h-0`}
|
||||
onClick={() =>
|
||||
props.setFilters(action.id === 'all' ? new Set(INCIDENT_EVENT_TYPES) : new Set())
|
||||
}
|
||||
@@ -60,7 +60,8 @@ export function IncidentEventFilters(props: IncidentEventFiltersProps) {
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
class={getAlertIncidentEventFilterChipClass(selected(), props.variant)}
|
||||
aria-pressed={selected()}
|
||||
class={`${getAlertIncidentEventFilterChipClass(selected(), props.variant)} min-h-11 focus:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-500 sm:min-h-0`}
|
||||
onClick={() => toggleFilter(type)}
|
||||
>
|
||||
{getAlertTimelineEventTypeLabel(type)}
|
||||
|
||||
@@ -218,7 +218,7 @@ export interface SectionActionButtonProps {
|
||||
}
|
||||
export const SectionActionButton: Component<SectionActionButtonProps> = (props) => {
|
||||
const variantClasses = {
|
||||
default: 'text-slate-600 hover:text-base-content hover:bg-slate-100',
|
||||
default: 'text-muted hover:text-base-content hover:bg-surface-hover',
|
||||
primary:
|
||||
'text-blue-600 hover:text-blue-700 hover:bg-blue-50 dark:text-blue-400 dark:hover:text-blue-300 dark:hover:bg-blue-900/25',
|
||||
danger:
|
||||
@@ -233,10 +233,7 @@ export const SectionActionButton: Component<SectionActionButtonProps> = (props)
|
||||
}}
|
||||
disabled={props.disabled}
|
||||
title={props.title}
|
||||
class={`inline-flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-sm font-medium
|
||||
transition-colors duration-150
|
||||
${variantClasses[props.variant || 'default']}
|
||||
${props.disabled ? 'opacity-50 cursor-not-allowed' : 'cursor-pointer'}`}
|
||||
class={`inline-flex min-h-11 items-center gap-1.5 rounded-md px-2.5 py-1.5 text-sm font-medium transition-colors duration-150 focus:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-500 sm:min-h-0 ${variantClasses[props.variant || 'default']} ${props.disabled ? 'cursor-not-allowed opacity-50' : 'cursor-pointer'}`}
|
||||
>
|
||||
<Show when={props.icon}>{props.icon}</Show>
|
||||
{props.label}
|
||||
|
||||
@@ -445,7 +445,10 @@ describe('SectionActionButton', () => {
|
||||
it('renders with default variant classes', () => {
|
||||
render(() => <SectionActionButton label="Action" onClick={() => {}} />);
|
||||
const button = screen.getByRole('button');
|
||||
expect(button.className).toContain('text-slate-600');
|
||||
expect(button.className).toContain('text-muted');
|
||||
expect(button.className).toContain('hover:bg-surface-hover');
|
||||
expect(button.className).not.toContain('hover:bg-slate-100');
|
||||
expect(button.className).toContain('min-h-11');
|
||||
});
|
||||
|
||||
it('renders with primary variant classes', () => {
|
||||
|
||||
@@ -1573,6 +1573,44 @@ describe('WebhookConfig', () => {
|
||||
const payloadTextareaAfter = document.querySelector('textarea') as HTMLTextAreaElement;
|
||||
expect(payloadTextareaAfter.value).toBe('');
|
||||
});
|
||||
|
||||
it('uses explicit button semantics, ARIA states, and theme-safe hover classes on webhook controls', async () => {
|
||||
render(() => (
|
||||
<WebhookConfig
|
||||
webhooks={[makeWebhook({ enabled: true })]}
|
||||
onAdd={onAddMock}
|
||||
onUpdate={onUpdateMock}
|
||||
onDelete={onDeleteMock}
|
||||
onTest={onTestMock}
|
||||
/>
|
||||
));
|
||||
|
||||
const toggleButton = screen.getByRole('button', { name: 'Enabled' });
|
||||
expect(toggleButton).toHaveAttribute('type', 'button');
|
||||
expect(toggleButton).toHaveAttribute('aria-pressed', 'true');
|
||||
|
||||
for (const label of ['Disable All', 'Enable All', 'Test', 'Edit', 'Delete', '+ Add Webhook']) {
|
||||
expect(screen.getByRole('button', { name: label })).toHaveAttribute('type', 'button');
|
||||
}
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Edit' }));
|
||||
|
||||
const serviceButton = screen.getByRole('button', { name: /Generic →/ });
|
||||
expect(serviceButton).toHaveAttribute('aria-expanded', 'false');
|
||||
fireEvent.click(serviceButton);
|
||||
expect(serviceButton).toHaveAttribute('aria-expanded', 'true');
|
||||
|
||||
const formTestButtons = screen.getAllByRole('button', { name: 'Test' });
|
||||
const formTestButton = formTestButtons[formTestButtons.length - 1];
|
||||
expect(formTestButton).toHaveAttribute('type', 'button');
|
||||
expect(formTestButton.className).toContain('hover:bg-surface-hover');
|
||||
expect(formTestButton.className).not.toContain('hover:bg-slate-100');
|
||||
expect(screen.getByRole('button', { name: 'Cancel' })).toHaveAttribute('type', 'button');
|
||||
expect(screen.getByRole('button', { name: 'Update Webhook' })).toHaveAttribute(
|
||||
'type',
|
||||
'button',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('webhook test/save parity', () => {
|
||||
|
||||
@@ -77,9 +77,10 @@ export function WebhookConfig(props: WebhookConfigProps) {
|
||||
|
||||
<Show when={!state.adding()}>
|
||||
<button
|
||||
type="button"
|
||||
onClick={state.openAddForm}
|
||||
disabled={state.saving()}
|
||||
class="min-h-11 w-full border border-dashed border-border px-2 py-1 text-xs text-muted hover:bg-surface-hover sm:min-h-0"
|
||||
class="min-h-11 w-full border border-dashed border-border px-2 py-1 text-xs text-muted hover:bg-surface-hover focus:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-500 sm:min-h-0"
|
||||
>
|
||||
+ {ALERT_WEBHOOK_ADD_LABEL}
|
||||
</button>
|
||||
|
||||
@@ -78,7 +78,15 @@ interface WebhookConfigFormProps {
|
||||
saveError: Accessor<string | null>;
|
||||
}
|
||||
|
||||
const WEBHOOK_LABEL_CLASS = labelClass();
|
||||
const WEBHOOK_INPUT_CLASS = controlClass('px-2 py-1.5');
|
||||
const WEBHOOK_PAIR_INPUT_CLASS = controlClass('w-full flex-1 px-2 py-1.5 text-xs font-mono');
|
||||
const WEBHOOK_SECONDARY_BUTTON_CLASS =
|
||||
'min-h-11 rounded-sm border border-border px-3 py-1.5 text-xs hover:bg-surface-hover focus:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-500 sm:min-h-0';
|
||||
|
||||
export function WebhookConfigForm(props: WebhookConfigFormProps) {
|
||||
const isTestingForm = () => props.testing === (props.editingId() || 'temp-new-webhook');
|
||||
|
||||
return (
|
||||
<fieldset
|
||||
class="min-w-0 space-y-4 border-0 p-0 text-sm"
|
||||
@@ -94,8 +102,9 @@ export function WebhookConfigForm(props: WebhookConfigFormProps) {
|
||||
<span class="text-sm font-medium text-base-content">Service Type</span>
|
||||
<button
|
||||
type="button"
|
||||
aria-expanded={props.showServiceDropdown()}
|
||||
onClick={() => props.setShowServiceDropdown((open) => !open)}
|
||||
class="min-h-11 text-sm text-blue-600 hover:text-blue-700 sm:min-h-0 dark:text-blue-400"
|
||||
class="min-h-11 rounded-xs text-sm text-blue-600 hover:text-blue-700 focus:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-500 sm:min-h-0 dark:text-blue-400"
|
||||
>
|
||||
{getAlertWebhookServiceLabelFromTemplates(props.formData().service, props.templates())}{' '}
|
||||
→
|
||||
@@ -135,7 +144,7 @@ export function WebhookConfigForm(props: WebhookConfigFormProps) {
|
||||
|
||||
<div class="grid w-full grid-cols-1 gap-3 md:grid-cols-2">
|
||||
<div class={formField}>
|
||||
<label for="alert-webhook-name" class={labelClass()}>
|
||||
<label for="alert-webhook-name" class={WEBHOOK_LABEL_CLASS}>
|
||||
Name
|
||||
</label>
|
||||
<input
|
||||
@@ -144,7 +153,7 @@ export function WebhookConfigForm(props: WebhookConfigFormProps) {
|
||||
value={props.formData().name}
|
||||
onInput={(e) => props.setFormData((prev) => ({ ...prev, name: e.currentTarget.value }))}
|
||||
placeholder={getAlertWebhookNamePlaceholder(props.currentTemplate()?.name)}
|
||||
class={controlClass('px-2 py-1.5')}
|
||||
class={WEBHOOK_INPUT_CLASS}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -164,7 +173,7 @@ export function WebhookConfigForm(props: WebhookConfigFormProps) {
|
||||
</div>
|
||||
|
||||
<div class={formField}>
|
||||
<label for="alert-webhook-url" class={labelClass()}>
|
||||
<label for="alert-webhook-url" class={WEBHOOK_LABEL_CLASS}>
|
||||
Webhook URL
|
||||
</label>
|
||||
<input
|
||||
@@ -199,7 +208,7 @@ export function WebhookConfigForm(props: WebhookConfigFormProps) {
|
||||
|
||||
<div class="space-y-2 border-t border-border pt-3">
|
||||
<div>
|
||||
<div class={labelClass()}>Resource tag routing</div>
|
||||
<div class={WEBHOOK_LABEL_CLASS}>Resource tag routing</div>
|
||||
<p class={formHelpText + ' mt-1'}>
|
||||
Leave empty to receive all alerts. Add tags to route only alerts from matching resources
|
||||
to this webhook.
|
||||
@@ -222,7 +231,7 @@ export function WebhookConfigForm(props: WebhookConfigFormProps) {
|
||||
tagFilterMode: event.currentTarget.value === 'any' ? 'any' : 'all',
|
||||
}))
|
||||
}
|
||||
selectBaseClass={controlClass('px-2 py-1.5')}
|
||||
selectBaseClass={WEBHOOK_INPUT_CLASS}
|
||||
>
|
||||
<option value="all">Match all tags</option>
|
||||
<option value="any">Match any tag</option>
|
||||
@@ -252,7 +261,7 @@ export function WebhookConfigForm(props: WebhookConfigFormProps) {
|
||||
props.formData().service,
|
||||
props.templates(),
|
||||
)}
|
||||
class={controlClass('px-2 py-1.5')}
|
||||
class={WEBHOOK_INPUT_CLASS}
|
||||
/>
|
||||
<Show
|
||||
when={getAlertWebhookMentionHelpFromTemplates(
|
||||
@@ -320,7 +329,7 @@ export function WebhookConfigForm(props: WebhookConfigFormProps) {
|
||||
}
|
||||
placeholder={ALERT_WEBHOOK_CUSTOM_FIELD_KEY_PLACEHOLDER}
|
||||
aria-label={`Custom field ${index + 1} key`}
|
||||
class={controlClass('w-full flex-1 px-2 py-1.5 text-xs font-mono')}
|
||||
class={WEBHOOK_PAIR_INPUT_CLASS}
|
||||
/>
|
||||
</div>
|
||||
<input
|
||||
@@ -333,7 +342,7 @@ export function WebhookConfigForm(props: WebhookConfigFormProps) {
|
||||
field().placeholder || ALERT_WEBHOOK_CUSTOM_FIELD_VALUE_PLACEHOLDER
|
||||
}
|
||||
aria-label={`Custom field ${index + 1} value`}
|
||||
class={controlClass('w-full flex-1 px-2 py-1.5 text-xs font-mono')}
|
||||
class={WEBHOOK_PAIR_INPUT_CLASS}
|
||||
/>
|
||||
<Show when={!field().required}>
|
||||
<button
|
||||
@@ -374,7 +383,7 @@ export function WebhookConfigForm(props: WebhookConfigFormProps) {
|
||||
onInput={(e) => props.updateHeaderInput(index, { key: e.currentTarget.value })}
|
||||
placeholder={ALERT_WEBHOOK_HEADER_KEY_PLACEHOLDER}
|
||||
aria-label={`Custom header ${index + 1} name`}
|
||||
class={controlClass('w-full flex-1 px-2 py-1.5 text-xs font-mono')}
|
||||
class={WEBHOOK_PAIR_INPUT_CLASS}
|
||||
/>
|
||||
<input
|
||||
type="text"
|
||||
@@ -382,7 +391,7 @@ export function WebhookConfigForm(props: WebhookConfigFormProps) {
|
||||
onInput={(e) => props.updateHeaderInput(index, { value: e.currentTarget.value })}
|
||||
placeholder={ALERT_WEBHOOK_HEADER_VALUE_PLACEHOLDER}
|
||||
aria-label={`Custom header ${index + 1} value`}
|
||||
class={controlClass('w-full flex-1 px-2 py-1.5 text-xs font-mono')}
|
||||
class={WEBHOOK_PAIR_INPUT_CLASS}
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
@@ -426,28 +435,24 @@ export function WebhookConfigForm(props: WebhookConfigFormProps) {
|
||||
</Show>
|
||||
|
||||
<div class="flex justify-end gap-2 text-xs">
|
||||
<button
|
||||
onClick={props.cancelForm}
|
||||
class="min-h-11 px-3 py-1.5 border border-border rounded-sm text-xs hover:bg-surface-hover sm:min-h-0"
|
||||
>
|
||||
<button type="button" onClick={props.cancelForm} class={WEBHOOK_SECONDARY_BUTTON_CLASS}>
|
||||
{ALERT_WEBHOOK_CANCEL_LABEL}
|
||||
</button>
|
||||
<Show when={props.formData().url && props.formData().name}>
|
||||
<button
|
||||
type="button"
|
||||
onClick={props.testWebhookForm}
|
||||
disabled={props.testing === (props.editingId() || 'temp-new-webhook')}
|
||||
class="min-h-11 px-3 py-1.5 border border-border rounded-sm text-xs hover:bg-slate-100 sm:min-h-0"
|
||||
disabled={isTestingForm()}
|
||||
class={WEBHOOK_SECONDARY_BUTTON_CLASS}
|
||||
>
|
||||
{getAlertWebhookTestLabel(
|
||||
props.testing === (props.editingId() || 'temp-new-webhook'),
|
||||
true,
|
||||
)}
|
||||
{getAlertWebhookTestLabel(isTestingForm(), true)}
|
||||
</button>
|
||||
</Show>
|
||||
<button
|
||||
type="button"
|
||||
onClick={props.saveWebhook}
|
||||
disabled={props.saving() || !props.formData().name || !props.formData().url}
|
||||
class="min-h-11 px-3 py-1.5 bg-blue-600 text-white text-xs rounded-sm hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed sm:min-h-0"
|
||||
class="min-h-11 rounded-sm bg-blue-600 px-3 py-1.5 text-xs text-white hover:bg-blue-700 focus:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-500 disabled:cursor-not-allowed disabled:opacity-50 sm:min-h-0"
|
||||
>
|
||||
{props.saving() ? 'Saving…' : getAlertWebhookSubmitLabel(Boolean(props.editingId()))}
|
||||
</button>
|
||||
|
||||
@@ -27,6 +27,11 @@ interface WebhookConfigListProps {
|
||||
onDeleteWebhook: (webhook: Webhook) => void;
|
||||
}
|
||||
|
||||
const WEBHOOK_LIST_BTN_BASE =
|
||||
'min-h-11 rounded-sm border px-3 py-1 text-xs transition-colors focus:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-500 sm:min-h-0';
|
||||
const WEBHOOK_GREEN_TONE =
|
||||
'border-green-500 text-green-700 hover:bg-green-50 dark:border-green-600 dark:text-green-400 dark:hover:bg-green-900/25';
|
||||
|
||||
export function WebhookConfigList(props: WebhookConfigListProps) {
|
||||
return (
|
||||
<div class="space-y-3 w-full">
|
||||
@@ -39,16 +44,18 @@ export function WebhookConfigList(props: WebhookConfigListProps) {
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-2 sm:flex-nowrap">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => props.toggleAllWebhooks(false)}
|
||||
disabled={props.saving || !props.someEnabled()}
|
||||
class="min-h-11 w-full rounded-sm border px-3 py-1 text-xs transition-colors hover:bg-surface-hover sm:min-h-0 sm:w-auto"
|
||||
class={`${WEBHOOK_LIST_BTN_BASE} w-full border-border hover:bg-surface-hover sm:w-auto`}
|
||||
>
|
||||
{getAlertWebhookToggleAllLabel(false)}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => props.toggleAllWebhooks(true)}
|
||||
disabled={props.saving || props.allEnabled()}
|
||||
class="min-h-11 w-full rounded-sm border border-green-500 px-3 py-1 text-xs text-green-700 transition-colors hover:bg-green-50 sm:min-h-0 sm:w-auto dark:border-green-600 dark:text-green-400 dark:hover:bg-green-900/25"
|
||||
class={`${WEBHOOK_LIST_BTN_BASE} w-full sm:w-auto ${WEBHOOK_GREEN_TONE}`}
|
||||
>
|
||||
{getAlertWebhookToggleAllLabel(true)}
|
||||
</button>
|
||||
@@ -61,9 +68,11 @@ export function WebhookConfigList(props: WebhookConfigListProps) {
|
||||
<div class="flex flex-wrap items-center justify-between gap-2">
|
||||
<span class="font-medium text-base-content">{webhook.name}</span>
|
||||
<button
|
||||
type="button"
|
||||
aria-pressed={webhook.enabled}
|
||||
onClick={() => props.onToggleWebhook(webhook)}
|
||||
disabled={props.saving}
|
||||
class={`min-h-11 rounded-sm border px-3 py-1 text-xs font-medium transition-colors sm:min-h-0 ${webhook.enabled ? 'border-green-500 text-green-700 hover:bg-green-50 dark:border-green-600 dark:text-green-400 dark:hover:bg-green-900/25' : 'border-border text-muted hover:bg-surface-hover'}`}
|
||||
class={`${WEBHOOK_LIST_BTN_BASE} font-medium ${webhook.enabled ? WEBHOOK_GREEN_TONE : 'border-border text-muted hover:bg-surface-hover'}`}
|
||||
>
|
||||
{getAlertWebhookToggleLabel(webhook.enabled)}
|
||||
</button>
|
||||
@@ -101,23 +110,26 @@ export function WebhookConfigList(props: WebhookConfigListProps) {
|
||||
<p class="mt-2 break-all text-[11px] font-mono text-muted sm:text-xs">{webhook.url}</p>
|
||||
<div class="mt-3 flex flex-wrap gap-2 border-t border-border-subtle pt-2 sm:justify-end w-full">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => props.onTestWebhook(webhook)}
|
||||
disabled={props.saving || props.testing === webhook.id || !webhook.enabled}
|
||||
class="min-h-11 rounded-sm border px-3 py-1 text-xs text-base-content transition-colors hover:bg-surface-hover disabled:opacity-50 sm:min-h-0"
|
||||
class={`${WEBHOOK_LIST_BTN_BASE} border-border text-base-content hover:bg-surface-hover disabled:opacity-50`}
|
||||
>
|
||||
{getAlertWebhookTestLabel(props.testing === webhook.id)}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => props.onEditWebhook(webhook)}
|
||||
disabled={props.saving}
|
||||
class="min-h-11 rounded-sm border border-blue-300 px-3 py-1 text-xs text-blue-600 transition-colors hover:bg-blue-50 sm:min-h-0 dark:border-blue-500 dark:text-blue-300 dark:hover:bg-blue-900/25"
|
||||
class={`${WEBHOOK_LIST_BTN_BASE} border-blue-300 text-blue-600 hover:bg-blue-50 dark:border-blue-500 dark:text-blue-300 dark:hover:bg-blue-900/25`}
|
||||
>
|
||||
{ALERT_WEBHOOK_EDIT_LABEL}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => props.onDeleteWebhook(webhook)}
|
||||
disabled={props.saving}
|
||||
class="min-h-11 rounded-sm border border-red-300 px-3 py-1 text-xs text-red-600 transition-colors hover:bg-red-50 sm:min-h-0 dark:border-red-500 dark:text-red-300 dark:hover:bg-red-900/25"
|
||||
class={`${WEBHOOK_LIST_BTN_BASE} border-red-300 text-red-600 hover:bg-red-50 focus-visible:ring-red-500 dark:border-red-500 dark:text-red-300 dark:hover:bg-red-900/25`}
|
||||
>
|
||||
{ALERT_WEBHOOK_DELETE_LABEL}
|
||||
</button>
|
||||
|
||||
@@ -24,14 +24,19 @@ describe('IncidentEventFilters', () => {
|
||||
expect(screen.getByText('Filters')).toBeInTheDocument();
|
||||
expect(screen.getByText('All')).toBeInTheDocument();
|
||||
expect(screen.getByText('None')).toBeInTheDocument();
|
||||
expect(screen.getByRole('button', { name: 'Fired' })).toHaveAttribute('aria-pressed', 'true');
|
||||
expect(screen.getByRole('button', { name: 'Ack' })).toHaveAttribute('aria-pressed', 'false');
|
||||
expect(screen.getByRole('button', { name: 'Fired' })).toHaveClass('min-h-11', 'sm:min-h-0');
|
||||
|
||||
fireEvent.click(screen.getByText('None'));
|
||||
expect(filters().size).toBe(0);
|
||||
expect(screen.getByRole('button', { name: 'Fired' })).toHaveAttribute('aria-pressed', 'false');
|
||||
|
||||
fireEvent.click(screen.getByText('All'));
|
||||
expect(filters().has('alert_fired')).toBe(true);
|
||||
expect(filters().has('note')).toBe(true);
|
||||
expect(filters().has('runbook')).toBe(true);
|
||||
expect(screen.getByRole('button', { name: 'Ack' })).toHaveAttribute('aria-pressed', 'true');
|
||||
});
|
||||
|
||||
it('renders panel filters without quick selection controls', () => {
|
||||
|
||||
@@ -231,7 +231,7 @@ export function AlertDeadManDestinationSection(props: AlertDeadManDestinationSec
|
||||
fallback={
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-md border border-red-300 px-3 py-2 text-sm font-medium text-red-700 hover:bg-red-50 dark:border-red-800 dark:text-red-300 dark:hover:bg-red-950/25"
|
||||
class="min-h-11 rounded-md border border-red-300 px-3 py-2 text-sm font-medium text-red-700 hover:bg-red-50 focus:outline-hidden focus-visible:ring-2 focus-visible:ring-red-500 sm:min-h-0 dark:border-red-800 dark:text-red-300 dark:hover:bg-red-950/25"
|
||||
onClick={() => {
|
||||
props.setPingUrl('');
|
||||
props.setHasUnsavedChanges(true);
|
||||
|
||||
@@ -17,7 +17,7 @@ export function AlertHistoryAdministrationCard(props: AlertHistoryAdministration
|
||||
<Show when={props.state.alertHistory().length > 0}>
|
||||
<div class="mt-8 border-t border-border pt-6">
|
||||
<div class="rounded-md bg-surface-alt p-4">
|
||||
<div class="flex items-start justify-between">
|
||||
<div class="flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between">
|
||||
<div>
|
||||
<h4 class="mb-1 text-sm font-medium text-base-content">
|
||||
{getAlertAdministrationSectionTitle()}
|
||||
@@ -29,7 +29,7 @@ export function AlertHistoryAdministrationCard(props: AlertHistoryAdministration
|
||||
onClick={() => {
|
||||
void props.state.clearAlertHistory();
|
||||
}}
|
||||
class="shrink-0 rounded-md border border-red-300 px-3 py-2 text-xs text-red-600 transition-colors hover:bg-red-50 dark:border-red-600 dark:text-red-400 dark:hover:bg-red-900/25"
|
||||
class="min-h-11 shrink-0 self-start rounded-md border border-red-300 px-3 py-2 text-xs text-red-600 transition-colors hover:bg-red-50 focus:outline-hidden focus-visible:ring-2 focus-visible:ring-red-500 sm:min-h-0 dark:border-red-600 dark:text-red-400 dark:hover:bg-red-900/25"
|
||||
>
|
||||
{getAlertAdministrationClearHistoryLabel()}
|
||||
</button>
|
||||
|
||||
@@ -45,6 +45,9 @@ interface AlertResourceIncidentsPanelProps {
|
||||
showTitle?: boolean;
|
||||
}
|
||||
|
||||
const RESOURCE_INCIDENT_HEADER_ACTION_CLASS =
|
||||
'min-h-11 rounded-md border border-border px-2 py-1 text-xs text-muted hover:bg-surface-hover focus:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-500 sm:min-h-0';
|
||||
|
||||
export function AlertResourceIncidentsPanel(props: AlertResourceIncidentsPanelProps) {
|
||||
// The live reading turns stale when evaluations stop, so it rechecks on the
|
||||
// shared clock rather than only when the alert changes.
|
||||
@@ -99,7 +102,7 @@ export function AlertResourceIncidentsPanel(props: AlertResourceIncidentsPanelPr
|
||||
<div class="flex items-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="px-2 py-1 text-xs border rounded-md border-border text-muted hover:bg-surface-hover disabled:opacity-50"
|
||||
class={`${RESOURCE_INCIDENT_HEADER_ACTION_CLASS} disabled:opacity-50`}
|
||||
disabled={isLoading()}
|
||||
onClick={() => {
|
||||
void props.state.refreshResourceIncidentPanel();
|
||||
@@ -110,7 +113,7 @@ export function AlertResourceIncidentsPanel(props: AlertResourceIncidentsPanelPr
|
||||
<Show when={props.showCloseAction ?? true}>
|
||||
<button
|
||||
type="button"
|
||||
class="px-2 py-1 text-xs border rounded-md border-border text-muted hover:bg-surface-hover"
|
||||
class={RESOURCE_INCIDENT_HEADER_ACTION_CLASS}
|
||||
onClick={() =>
|
||||
props.onClose ? props.onClose() : props.state.setResourceIncidentPanel(null)
|
||||
}
|
||||
@@ -268,7 +271,8 @@ export function AlertResourceIncidentsPanel(props: AlertResourceIncidentsPanelPr
|
||||
</Show>
|
||||
<button
|
||||
type="button"
|
||||
class={getAlertResourceIncidentToggleButtonClass()}
|
||||
aria-expanded={isExpanded()}
|
||||
class={`${getAlertResourceIncidentToggleButtonClass()} min-h-11 focus:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-500 sm:min-h-0`}
|
||||
onClick={() =>
|
||||
props.state.toggleResourceIncidentDetails(incident.id)
|
||||
}
|
||||
|
||||
@@ -66,7 +66,9 @@ describe('AlertDeadManDestinationSection', () => {
|
||||
expect(screen.getByText('5 min (unexpected stop)')).toBeInTheDocument();
|
||||
expect(screen.getByText('0')).toBeInTheDocument();
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Remove' }));
|
||||
const removeButton = screen.getByRole('button', { name: 'Remove' });
|
||||
expect(removeButton).toHaveClass('min-h-11', 'sm:min-h-0');
|
||||
fireEvent.click(removeButton);
|
||||
expect(pingUrl()).toBe('');
|
||||
expect(setHasUnsavedChanges).toHaveBeenCalledWith(true);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import { AlertHistoryAdministrationCard } from '../AlertHistoryAdministrationCard';
|
||||
import type { AlertHistoryState } from '../useAlertHistoryState';
|
||||
|
||||
describe('AlertHistoryAdministrationCard', () => {
|
||||
afterEach(cleanup);
|
||||
|
||||
it('stacks cleanly on narrow viewports with a 44px touch target and invokes clearAlertHistory', () => {
|
||||
const clearAlertHistory = vi.fn().mockResolvedValue(undefined);
|
||||
render(() => (
|
||||
<AlertHistoryAdministrationCard
|
||||
state={
|
||||
{
|
||||
alertHistory: () => [{ id: 'alert-1' }],
|
||||
clearAlertHistory,
|
||||
} as unknown as AlertHistoryState
|
||||
}
|
||||
/>
|
||||
));
|
||||
|
||||
const clearButton = screen.getByRole('button', { name: 'Clear All History' });
|
||||
expect(clearButton).toHaveAttribute('type', 'button');
|
||||
expect(clearButton).toHaveClass('min-h-11', 'sm:min-h-0');
|
||||
|
||||
fireEvent.click(clearButton);
|
||||
expect(clearAlertHistory).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
@@ -347,17 +347,24 @@ describe('AlertResourceIncidentsPanel', () => {
|
||||
|
||||
expect(screen.queryByText('Connectivity incident opened')).not.toBeInTheDocument();
|
||||
|
||||
await fireEvent.click(screen.getByRole('button', { name: 'Events (2)' }));
|
||||
const eventsToggle = screen.getByRole('button', { name: 'Events (2)' });
|
||||
expect(eventsToggle).toHaveAttribute('aria-expanded', 'false');
|
||||
expect(eventsToggle).toHaveClass('min-h-11', 'sm:min-h-0');
|
||||
expect(screen.getByRole('button', { name: 'Refresh' })).toHaveClass('min-h-11', 'sm:min-h-0');
|
||||
expect(screen.getByRole('button', { name: 'Close' })).toHaveClass('min-h-11', 'sm:min-h-0');
|
||||
|
||||
await fireEvent.click(eventsToggle);
|
||||
|
||||
expect(toggleResourceIncidentDetails).toHaveBeenCalledWith('incident-1');
|
||||
expect(screen.getByRole('button', { name: 'Hide events' })).toBeInTheDocument();
|
||||
const hideToggle = screen.getByRole('button', { name: 'Hide events' });
|
||||
expect(hideToggle).toHaveAttribute('aria-expanded', 'true');
|
||||
expect(screen.getByText('Connectivity incident opened')).toBeVisible();
|
||||
|
||||
setEventFilters(new Set<string>(['resolved']));
|
||||
expect(screen.queryByText('Connectivity incident opened')).not.toBeInTheDocument();
|
||||
expect(screen.getByText('Connectivity restored')).toBeVisible();
|
||||
|
||||
await fireEvent.click(screen.getByRole('button', { name: 'Hide events' }));
|
||||
await fireEvent.click(hideToggle);
|
||||
expect(screen.queryByText('Connectivity incident opened')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user