Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(alerts): remove legacy alert edit modal (#77465)

Matt Pua69f56057d81c
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index a8dd39b4fd46..b23ff7893df1 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -255,7 +255,6 @@ export const FEATURE_FLAGS = {
ALERTS_INLINE_NOTIFICATIONS: 'alerts-inline-notifications', // owner: @vdekrijger
ALERTS_INVESTIGATION_AGENT: 'alerts-investigation-agent', // owner: @andrewm4894, anomaly alerts — investigation agent on firing
ALERTS_REAL_TIME_INTERVAL: 'alerts-real-time-interval', // owner: #team-analytics-platform, gates real-time (2-minute) insight alert interval
- ALERTS_REDESIGNED_EDIT_MODAL: 'alerts-redesigned-edit-modal', // owner: #team-analytics-platform, gates the redesigned alert edit/create modal (wizard for new, sections for edit)
AMPLITUDE_BATCH_IMPORT_OPTIONS: 'amplitude-batch-import-options', // owner: #team-ingestion
APPROVALS: 'approvals', // owner: @yasen-posthog #team-platform-features
AVERAGE_PAGE_VIEW_COLUMN: 'average-page-view-column', // owner: @jordanm-posthog #team-web-analytics
diff --git a/products/alerts/frontend/logic/alertFormLogic.test.ts b/products/alerts/frontend/logic/alertFormLogic.test.ts
index d37206424634..e3dc2c7b8813 100644
--- a/products/alerts/frontend/logic/alertFormLogic.test.ts
+++ b/products/alerts/frontend/logic/alertFormLogic.test.ts
@@ -151,7 +151,6 @@ describe('alertFormLogic', () => {
onEditSuccess,
insightVizDataLogicProps: insightLogicProps,
insightInterval: 'day',
- uiVersion: 'redesigned',
})
logic.mount()
logic.actions.setAlertFormValues({ ...makeFormDefaults(), checks: undefined })
@@ -160,6 +159,13 @@ describe('alertFormLogic', () => {
it.each([
['ordinary', { insightInterval: 'day' as const }, '', AlertCalculationInterval.DAILY, null],
+ [
+ 'ordinary with an insight name',
+ { insightInterval: 'day' as const, insightName: 'Weekly signups' },
+ 'Weekly signups alert',
+ AlertCalculationInterval.DAILY,
+ null,
+ ],
[
'anomaly',
{
@@ -194,24 +200,6 @@ describe('alertFormLogic', () => {
}
)
- it.each([
- ['legacy', 'legacy' as const, '', {}],
- ['redesigned', 'redesigned' as const, 'Weekly signups alert', {}],
- ])('keeps %s creation defaults scoped to its UI', (_name, uiVersion, expectedName, expectedBounds) => {
- const logic = alertFormLogic({
- alert: null,
- insightId: 42,
- onEditSuccess: jest.fn(),
- insightVizDataLogicProps: insightLogicProps,
- insightName: 'Weekly signups',
- uiVersion,
- })
- logic.mount()
-
- expect(logic.values.alertForm.name).toBe(expectedName)
- expect(logic.values.alertForm.threshold.configuration.bounds).toEqual(expectedBounds)
- })
-
it('shows success toast and no error toast when create succeeds', async () => {
const logic = mountForm()
diff --git a/products/alerts/frontend/logic/alertFormLogic.ts b/products/alerts/frontend/logic/alertFormLogic.ts
index daca730fcae8..5f81a79f0a5f 100644
--- a/products/alerts/frontend/logic/alertFormLogic.ts
+++ b/products/alerts/frontend/logic/alertFormLogic.ts
@@ -154,7 +154,6 @@ export interface AlertFormLogicProps {
/** For funnel insights: whether it's a trends (historical) funnel, which alerts on the overall
* conversion rate over time rather than a single step snapshot. Drives the preview shape. */
insightIsTrendsFunnel?: boolean
- uiVersion?: 'legacy' | 'redesigned'
}
const defaultConfigForInsight = (kind: AlertFormLogicProps['insightAlertKind']): AlertConfig => {
@@ -244,7 +243,7 @@ function defaultAlertName(props: AlertFormLogicProps, goalLines?: GoalLine[] | n
if (props.defaultToAnomalyDetection) {
return props.insightName ? `Anomaly in ${props.insightName}` : 'Anomaly alert'
}
- if (props.uiVersion === 'redesigned' && props.insightName) {
+ if (props.insightName) {
return `${props.insightName} alert`
}
return goalLines && goalLines.length > 0 ? `Crossed ${goalLines[0].label}` : ''
@@ -653,7 +652,7 @@ export const alertFormLogic = kea<alertFormLogicType>([
if (isNewAlert) {
posthog.capture('alert creation completed', {
- ui_version: props.uiVersion ?? 'legacy',
+ ui_version: 'redesigned',
})
}
diff --git a/products/alerts/frontend/views/AlertModal.stories.tsx b/products/alerts/frontend/views/AlertModal.stories.tsx
index 978bc17d4275..a915a58a05e1 100644
--- a/products/alerts/frontend/views/AlertModal.stories.tsx
+++ b/products/alerts/frontend/views/AlertModal.stories.tsx
@@ -160,7 +160,7 @@ const meta: Meta<typeof EditAlertModal> = {
layout: 'fullscreen',
viewMode: 'story',
mockDate: '2026-07-16',
- featureFlags: [FEATURE_FLAGS.ALERTS_REDESIGNED_EDIT_MODAL, FEATURE_FLAGS.ALERTS_INLINE_NOTIFICATIONS],
+ featureFlags: [FEATURE_FLAGS.ALERTS_INLINE_NOTIFICATIONS],
testOptions: { viewport: { width: 1300, height: 900 } },
},
}
diff --git a/products/alerts/frontend/views/EditAlertModal.tsx b/products/alerts/frontend/views/EditAlertModal.tsx
index ec8bf2a4cdf4..d78b3c3c0906 100644
--- a/products/alerts/frontend/views/EditAlertModal.tsx
+++ b/products/alerts/frontend/views/EditAlertModal.tsx
@@ -2,39 +2,40 @@ import { useActions, useValues } from 'kea'
import { Form } from 'kea-forms'
import { useCallback, useMemo } from 'react'
-import { LemonDialog, LemonSwitch } from '@posthog/lemon-ui'
-
import { UserActivityIndicator } from 'lib/components/UserActivityIndicator/UserActivityIndicator'
import { dayjs } from 'lib/dayjs'
import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'
-import { LemonButton } from 'lib/lemon-ui/LemonButton'
-import { LemonField } from 'lib/lemon-ui/LemonField'
import { LemonModal } from 'lib/lemon-ui/LemonModal'
import { formatDate } from 'lib/utils/datetime'
+import { insightLogic } from 'scenes/insights/insightLogic'
import { insightVizDataLogic } from 'scenes/insights/insightVizDataLogic'
import { getDisplayNameFromEntityNode } from 'scenes/insights/utils'
import { teamLogic } from 'scenes/teamLogic'
import { trendsDataLogic } from 'scenes/trends/trendsDataLogic'
import { urls } from 'scenes/urls'
-import { AlertCalculationInterval, AlertState } from '~/queries/schema/schema-general'
+import { AlertCalculationInterval, AlertConditionType, InsightThresholdType } from '~/queries/schema/schema-general'
import { isFunnelsQuery, isInsightVizNode } from '~/queries/utils'
import { FunnelVizType, InsightLogicProps, InsightShortId, QueryBasedInsightModel } from '~/types'
import { AlertAdvancedOptionsSection } from 'products/alerts/frontend/components/AlertAdvancedOptionsSection'
-import { AlertTimezoneNotice } from 'products/alerts/frontend/components/AlertDefinition'
+import { AlertStateIndicator, AlertTimezoneNotice } from 'products/alerts/frontend/components/AlertDefinition'
import { AlertDefinitionSection } from 'products/alerts/frontend/components/AlertDefinitionSection'
import {
AlertEditor,
AlertEditorFormDetails,
AlertEditorLoading,
- AlertEditorSection,
} from 'products/alerts/frontend/components/AlertEditor'
import { AlertIntervalRow } from 'products/alerts/frontend/components/AlertIntervalRow'
+import { AlertPreviewCard } from 'products/alerts/frontend/components/AlertPreviewCard'
+import { buildAlertSummary } from 'products/alerts/frontend/components/alertSummary'
+import { AlertWizard } from 'products/alerts/frontend/components/AlertWizard'
+import { ThresholdConditionRow } from 'products/alerts/frontend/components/ThresholdConditionRow'
import { isSubDailyAlertInterval } from 'products/alerts/frontend/logic/alertIntervalHelpers'
+import { quietHoursFormError } from 'products/alerts/frontend/logic/scheduleRestrictionValidation'
+import { deriveAlertCheckPreviewSeries } from 'products/alerts/frontend/logic/trendsAlertPreview'
import { InsightAlertNotificationSection } from 'products/alerts/frontend/views/InsightAlertNotificationSection'
-import { SnoozeButton } from '../components/SnoozeButton'
import { alertFormLogic, canCheckOngoingInterval, insightAlertKindForQuery } from '../logic/alertFormLogic'
import { alertLogic } from '../logic/alertLogic'
import { alertNotificationLogic } from '../logic/alertNotificationLogic'
@@ -43,7 +44,9 @@ import { insightAlertsLogic } from '../logic/insightAlertsLogic'
import { supportsAnomalyDetection, supportsOngoingInterval } from '../types'
import type { AlertType } from '../types'
import { AlertHistorySection } from './AlertHistorySection'
-import { EditAlertModalV2 } from './EditAlertModalV2'
+import { AlertEnabledAction, AlertLeadingActions } from './EditAlertModal/AlertLeadingActions'
+import { buildWizardSteps } from './EditAlertModal/buildWizardSteps'
+import { EditAlertTabs } from './EditAlertModal/EditAlertTabs'
interface AlertModalCommonProps {
isOpen: boolean | undefined
@@ -54,7 +57,7 @@ interface AlertModalCommonProps {
useAlertCheckPreview?: boolean
}
-export type AlertModalProps = AlertModalCommonProps &
+type AlertModalProps = AlertModalCommonProps &
(
| {
alert: AlertType
@@ -72,7 +75,7 @@ export type AlertModalProps = AlertModalCommonProps &
}
)
-export interface ResolvedAlertModalProps extends AlertModalCommonProps {
+interface ResolvedAlertModalProps extends AlertModalCommonProps {
initialAlert?: AlertType
alertId?: AlertType['id']
insightId: QueryBasedInsightModel['id']
@@ -81,9 +84,6 @@ export interface ResolvedAlertModalProps extends AlertModalCommonProps {
}
export function EditAlertModal(props: AlertModalProps): JSX.Element {
- // Redesigned modal (wizard for new alerts, sectioned layout + live preview for edits). The flag
- // is the single switch: off = legacy modal below, on = V2. Consumers don't change.
- const redesigned = useFeatureFlag('ALERTS_REDESIGNED_EDIT_MODAL')
const resolvedProps: ResolvedAlertModalProps = props.alert
? {
...props,
@@ -97,29 +97,24 @@ export function EditAlertModal(props: AlertModalProps): JSX.Element {
},
}
: props
- if (redesigned) {
- return <EditAlertModalV2 {...resolvedProps} />
- }
- return <LegacyEditAlertModal {...resolvedProps} />
-}
-
-function LegacyEditAlertModal({
- initialAlert,
- isOpen,
- alertId,
- insightId,
- insightShortId,
- onClose,
- onEditSuccess,
- insightLogicProps,
- defaultToAnomalyDetection,
- insightName,
-}: ResolvedAlertModalProps): JSX.Element {
+ const {
+ initialAlert,
+ isOpen,
+ alertId,
+ insightId,
+ insightShortId,
+ onClose,
+ onEditSuccess,
+ insightLogicProps,
+ defaultToAnomalyDetection,
+ insightName,
+ useAlertCheckPreview,
+ } = resolvedProps
const _alertLogic = alertLogic({ alertId })
const { alert: loadedAlert, alertLoading } = useValues(_alertLogic)
const alert = initialAlert ?? loadedAlert
+ const { insightLoading } = useValues(insightLogic(insightLogicProps))
- /** Parent callback only (e.g. close modal). `alertLogic` is hydrated from the save response inside `alertFormLogic`. */
const _onEditSuccess = useCallback(
(alertId: AlertType['id'] | undefined) => {
onEditSuccess(alertId)
@@ -134,14 +129,13 @@ function LegacyEditAlertModal({
isBreakdownValid,
formulaNodes,
interval: trendInterval,
+ indexedResults,
+ insightDataLoading,
} = useValues(trendsLogic)
const { query } = useValues(insightVizDataLogic(insightLogicProps))
const funnelSource = !!query && isInsightVizNode(query) && isFunnelsQuery(query.source) ? query.source : null
- // Trends funnels alert on the overall conversion rate over time, so they skip the step picker and
- // the preview reads the latest period instead of a step snapshot. The backend dispatches on the
- // same viz type — see funnel_strategies.py.
const isTrendsFunnel = funnelSource?.funnelsFilter?.funnelVizType === FunnelVizType.Trends
const funnelStepLabels = (funnelSource?.series ?? []).map(
(node, index) => getDisplayNameFromEntityNode(node) ?? `Step ${index + 1}`
@@ -158,13 +152,15 @@ function LegacyEditAlertModal({
defaultToAnomalyDetection: !alertId && !isNonTimeSeriesDisplay && defaultToAnomalyDetection,
insightName,
insightIsTrendsFunnel: isTrendsFunnel,
- uiVersion: 'legacy' as const,
}
const formLogic = alertFormLogic(formLogicProps)
const {
alertForm,
isAlertFormSubmitting,
alertFormChanged,
+ alertFormHasErrors,
+ alertFormValidationErrors,
+ alertFormSubmitAttempted,
simulationResult,
simulationResultLoading,
simulationDateFrom,
@@ -191,8 +187,13 @@ function LegacyEditAlertModal({
const inlineNotificationsEnabled = useFeatureFlag('ALERTS_INLINE_NOTIFICATIONS')
const investigationAgentEnabled = useFeatureFlag('ALERTS_INVESTIGATION_AGENT')
- const { pendingNotifications } = useValues(alertNotificationLogic({ alertId: alertId }))
+ const notificationLogic = alertNotificationLogic({ alertId })
+ const { existingHogFunctions, pendingNotifications, testDeliveryResultLoading } = useValues(notificationLogic)
+ const { sendTestDelivery } = useActions(notificationLogic)
const hasPendingNotifications = inlineNotificationsEnabled && pendingNotifications.length > 0
+ const hasTestDeliveryTargets =
+ (alert?.subscribed_users?.some((user) => Boolean(user.email)) ?? false) ||
+ existingHogFunctions.some((hogFunction) => hogFunction.enabled)
const handleClose = useCallback(() => {
clearSimulation()
@@ -208,7 +209,7 @@ function LegacyEditAlertModal({
}
}, [insightLogicProps, insightId])
- const creatingNewAlert = alertForm.id === undefined
+ const creatingNewAlert = alertId === undefined
const can_check_ongoing_interval = canCheckOngoingInterval(alertForm, { isTrendsFunnel })
const alertMode = alertForm.detector_config ? 'detector' : 'threshold'
const nextPlannedEvaluationStale = useMemo(
@@ -272,57 +273,149 @@ function LegacyEditAlertModal({
can_check_ongoing_interval,
])
+ const subscribedCount = alertForm.subscribed_users?.length ?? 0
+ const destinationCount = existingHogFunctions.length + pendingNotifications.length
+ const summary = useMemo(
+ () => buildAlertSummary(alertForm, subscribedCount, destinationCount),
+ [alertForm, destinationCount, subscribedCount]
+ )
+
+ // The monitored trends series' values, for the live preview sparkline. Picked by the alert's
+ // series_index so the preview matches what the alert actually evaluates.
+ const trendsPreviewValues = useMemo(() => {
+ if (!isTrendsFunnel && alertForm.config?.type === 'TrendsAlertConfig') {
+ const idx = alertForm.config.series_index ?? 0
+ const series = indexedResults?.[idx]
+ return series?.data ?? null
+ }
+ return null
+ }, [alertForm.config, indexedResults, isTrendsFunnel])
+
+ const checkPreview = useMemo(() => {
+ if (!useAlertCheckPreview || !alert) {
+ return undefined
+ }
+ const preview = deriveAlertCheckPreviewSeries(
+ alert.checks ?? [],
+ alertForm.condition?.type ?? AlertConditionType.ABSOLUTE_VALUE,
+ alertForm.threshold?.configuration?.type ?? InsightThresholdType.ABSOLUTE
+ )
+ return {
+ ...preview,
+ labels: preview.labels?.map((label) => formatDate(dayjs(label), 'MMM D, HH:mm')),
+ }
+ }, [alert, alertForm.condition?.type, alertForm.threshold?.configuration?.type, useAlertCheckPreview])
+
const leadingActions = (
- <div className="flex items-center gap-2">
- {!creatingNewAlert ? (
- <LemonButton
- type="secondary"
- status="danger"
- onClick={() => {
- LemonDialog.open({
- title: `Delete "${alertForm.name || 'this alert'}"?`,
- description: 'This alert will be permanently deleted. This action cannot be undone.',
- primaryButton: {
- children: 'Delete',
- type: 'primary',
- status: 'danger',
- onClick: deleteAlert,
- 'data-attr': 'alert-delete-confirm',
- },
- secondaryButton: { children: 'Cancel' },
- })
- }}
- >
- Delete alert
- </LemonButton>
- ) : null}
- {!creatingNewAlert ? (
- <SnoozeButton
- onChange={snoozeAlert}
- value={alert?.snoozed_until}
- disabledReason={
- alert?.state === AlertState.FIRING ? undefined : 'Only firing alerts can be snoozed'
- }
- />
- ) : null}
- {!creatingNewAlert && alert?.state === AlertState.SNOOZED ? (
- <LemonButton
- type="secondary"
- status="default"
- onClick={clearSnooze}
- tooltip={`Currently snoozed until ${formatDate(dayjs(alert?.snoozed_until), 'MMM D, HH:mm')}`}
- >
- Clear snooze
- </LemonButton>
- ) : null}
- <div className="ml-auto mr-2">
- <LemonField name="enabled" className="m-0">
- <LemonSwitch checked={alertForm.enabled} data-attr="alertForm-enabled" label="Enabled" />
- </LemonField>
- </div>
+ <AlertLeadingActions
+ alertForm={alertForm}
+ alert={alert}
+ onDeleteAlert={deleteAlert}
+ onSnoozeAlert={snoozeAlert}
+ onClearSnooze={clearSnooze}
+ onSendTestDelivery={sendTestDelivery}
+ testDeliveryLoading={testDeliveryResultLoading}
+ testDeliveryDisabledReason={
+ alertFormChanged || hasPendingNotifications ? 'Save changes before testing.' : undefined
+ }
+ showTestDelivery={hasTestDeliveryTargets}
+ />
+ )
+
+ const thresholdValidationError =
+ typeof alertFormValidationErrors.threshold === 'string' ? alertFormValidationErrors.threshold : undefined
+
+ const definitionNode = (
+ <AlertDefinitionSection
+ alertForm={alertForm}
+ alertMode={alertMode}
+ thresholdBoundsFormError={thresholdBoundsFormError}
+ isNonTimeSeriesDisplay={isNonTimeSeriesDisplay}
+ trends={{ alertSeries, formulaNodes, isBreakdownValid }}
+ funnel={{
+ stepLabels: funnelStepLabels,
+ preview: funnelAlertPreview,
+ isTrendsFunnel,
+ }}
+ hogql={{
+ preview: hogqlAlertPreview,
+ columns: hogqlResultColumns,
+ valueColumnOptions: hogqlValueColumnOptions,
+ labelColumnOptions: hogqlLabelColumnOptions,
+ }}
+ supportsAnomalyDetection={!isNonTimeSeriesDisplay && supportsAnomalyDetection(alertForm.config)}
+ twoColumnLayout
+ investigationAgentEnabled={investigationAgentEnabled}
+ simulationResult={simulationResult}
+ simulationResultLoading={simulationResultLoading}
+ simulationDateFrom={simulationDateFrom}
+ onSetAlertFormValue={setAlertFormValue}
+ thresholdRowRenderer={(props) => <ThresholdConditionRow {...props} />}
+ onSimulateAlert={simulateAlert}
+ onSetSimulationDateFrom={setSimulationDateFrom}
+ onClearSimulation={clearSimulation}
+ onClearSimulationOverlay={clearSimulationOverlay}
+ />
+ )
+
+ const scheduleNode = (
+ <div className="space-y-2">
+ <AlertIntervalRow
+ alertForm={alertForm}
+ creatingNewAlert={creatingNewAlert}
+ alert={alert}
+ trendInterval={trendInterval}
+ nextPlannedEvaluationStale={nextPlannedEvaluationStale}
+ canCheckOngoingInterval={can_check_ongoing_interval}
+ onSetAlertFormValue={setAlertFormValue}
+ />
+ <AlertTimezoneNotice
+ timezone={projectTimezone}
+ settingsUrl={urls.settings('environment-customization', 'date-and-time')}
+ />
</div>
)
+ const notifyNode = (
+ <InsightAlertNotificationSection
+ alertForm={alertForm}
+ alertId={alertId}
+ insightShortId={insightShortId}
+ inlineNotificationsEnabled={inlineNotificationsEnabled}
+ showSectionTitle={false}
+ onSetAlertFormValue={setAlertFormValue}
+ />
+ )
+
+ const advancedNode = (
+ <AlertAdvancedOptionsSection
+ alertForm={alertForm}
+ canCheckOngoingInterval={can_check_ongoing_interval}
+ projectTimezone={projectTimezone}
+ enabledAdvancedOptionsCount={enabledAdvancedOptionsCount}
+ defaultOpen
+ onSetAlertFormValue={setAlertFormValue}
+ />
+ )
+
+ const previewNode = (
+ <AlertPreviewCard
+ alertForm={alertForm}
+ trendsValues={trendsPreviewValues}
+ trendsLabels={
+ indexedResults?.[
+ alertForm.config?.type === 'TrendsAlertConfig' ? (alertForm.config.series_index ?? 0) : 0
+ ]?.labels ?? null
+ }
+ funnelPreview={funnelAlertPreview}
+ hogqlPreview={hogqlAlertPreview}
+ checkPreview={checkPreview}
+ loading={!useAlertCheckPreview && (insightLoading || insightDataLoading)}
+ />
+ )
+ const nameError = alertFormSubmitAttempted && !alertForm.name ? 'Enter an alert name.' : undefined
+ const scheduleRestrictionFormError = quietHoursFormError(alertForm.schedule_restriction)
+
return (
<LemonModal onClose={handleClose} isOpen={isOpen} width={900} simple title="">
{alertLoading && !alert ? (
@@ -335,104 +428,80 @@ function LegacyEditAlertModal({
enableFormOnSubmit
className="LemonModal__layout"
>
- <AlertEditor
- title={creatingNewAlert ? 'New alert' : 'Edit alert'}
- className="min-h-0 flex-1 overflow-hidden"
- contentClassName="min-h-0 flex-1 overflow-y-auto"
- onBack={handleClose}
- isEditing={!creatingNewAlert}
- isSubmitting={isAlertFormSubmitting}
- hasChanges={alertFormChanged}
- hasPendingChanges={hasPendingNotifications}
- showNoChangesLabel
- onSubmitAttempted={setAlertFormSubmitAttempted}
- leadingActions={leadingActions}
- >
- <div className="deprecated-space-y-6">
- <AlertEditorFormDetails
- activity={
- alert?.created_by ? (
- <UserActivityIndicator
- at={alert.created_at}
- by={alert.created_by}
- prefix="Created"
+ {creatingNewAlert ? (
+ <AlertWizard
+ title="New alert"
+ isSubmitting={isAlertFormSubmitting}
+ hasChanges={alertFormChanged}
+ onBack={handleClose}
+ onSubmitAttempted={setAlertFormSubmitAttempted}
+ steps={buildWizardSteps({
+ nameNode: <AlertEditorFormDetails nameError={nameError} />,
+ definitionNode,
+ previewNode,
+ scheduleNode,
+ notifyNode,
+ advancedNode,
+ summary,
+ thresholdValidationError,
+ scheduleRestrictionFormError,
+ alertFormHasErrors,
+ alertName: alertForm.name,
+ })}
+ />
+ ) : (
+ <AlertEditor
+ title="Edit alert"
+ className="min-h-0 flex-1 overflow-hidden"
+ contentClassName="min-h-0 flex-1 overflow-y-auto"
+ onBack={handleClose}
+ isEditing
+ isSubmitting={isAlertFormSubmitting}
+ hasChanges={alertFormChanged}
+ hasPendingChanges={hasPendingNotifications}
+ onSubmitAttempted={setAlertFormSubmitAttempted}
+ leadingActions={leadingActions}
+ trailingActions={<AlertEnabledAction alertForm={alertForm} />}
+ >
+ <div className="space-y-3">
+ <EditAlertTabs
+ summary={summary}
+ summaryHeader={
+ alert ? (
+ <div className="flex items-center justify-between gap-3">
+ <span className="font-medium">Current status</span>
+ <AlertStateIndicator alert={alert} />
+ </div>
+ ) : undefined
+ }
+ nameNode={
+ <AlertEditorFormDetails
+ nameError={nameError}
+ activity={
+ alert?.created_by ? (
+ <UserActivityIndicator
+ at={alert.created_at}
+ by={alert.created_by}
+ prefix="Created"
+ />
+ ) : undefined
+ }
/>
- ) : undefined
- }
- />
-
- <AlertEditorSection title="Definition">
- <div className="deprecated-space-y-3">
- <AlertDefinitionSection
- alertForm={alertForm}
- alertMode={alertMode}
- thresholdBoundsFormError={thresholdBoundsFormError}
- isNonTimeSeriesDisplay={isNonTimeSeriesDisplay}
- trends={{ alertSeries, formulaNodes, isBreakdownValid }}
- funnel={{
- stepLabels: funnelStepLabels,
- preview: funnelAlertPreview,
- isTrendsFunnel,
- }}
- hogql={{
- preview: hogqlAlertPreview,
- columns: hogqlResultColumns,
- valueColumnOptions: hogqlValueColumnOptions,
- labelColumnOptions: hogqlLabelColumnOptions,
- }}
- supportsAnomalyDetection={
- !isNonTimeSeriesDisplay && supportsAnomalyDetection(alertForm.config)
- }
- investigationAgentEnabled={investigationAgentEnabled}
- simulationResult={simulationResult}
- simulationResultLoading={simulationResultLoading}
- simulationDateFrom={simulationDateFrom}
- onSetAlertFormValue={setAlertFormValue}
- onSimulateAlert={simulateAlert}
- onSetSimulationDateFrom={setSimulationDateFrom}
- onClearSimulation={clearSimulation}
- onClearSimulationOverlay={clearSimulationOverlay}
- />
- <AlertIntervalRow
- alertForm={alertForm}
- creatingNewAlert={creatingNewAlert}
- alert={alert}
- trendInterval={trendInterval}
- nextPlannedEvaluationStale={nextPlannedEvaluationStale}
- canCheckOngoingInterval={can_check_ongoing_interval}
- onSetAlertFormValue={setAlertFormValue}
- />
- </div>
- </AlertEditorSection>
-
- <AlertTimezoneNotice
- timezone={projectTimezone}
- settingsUrl={urls.settings('environment-customization', 'date-and-time')}
- />
-
- <InsightAlertNotificationSection
- alertForm={alertForm}
- alertId={alertId}
- insightShortId={insightShortId}
- inlineNotificationsEnabled={inlineNotificationsEnabled}
- onSetAlertFormValue={setAlertFormValue}
- />
-
- <AlertAdvancedOptionsSection
- alertForm={alertForm}
- canCheckOngoingInterval={can_check_ongoing_interval}
- projectTimezone={projectTimezone}
- enabledAdvancedOptionsCount={enabledAdvancedOptionsCount}
- onSetAlertFormValue={setAlertFormValue}
- />
- </div>
-
- {alertId && alert ? (
- <div className="mt-6">
- <AlertHistorySection alertId={alert.id} />
+ }
+ previewNode={previewNode}
+ definitionNode={definitionNode}
+ scheduleNode={scheduleNode}
+ advancedNode={advancedNode}
+ notifyNode={notifyNode}
+ historyNode={
+ alertId && alert ? (
+ <AlertHistorySection alertId={alert.id} showCurrentStatus={false} />
+ ) : null
+ }
+ />
</div>
- ) : null}
- </AlertEditor>
+ </AlertEditor>
+ )}
</Form>
)}
</LemonModal>
diff --git a/products/alerts/frontend/views/EditAlertModalV2/AlertLeadingActions.tsx b/products/alerts/frontend/views/EditAlertModal/AlertLeadingActions.tsx
similarity index 100%
rename from products/alerts/frontend/views/EditAlertModalV2/AlertLeadingActions.tsx
rename to products/alerts/frontend/views/EditAlertModal/AlertLeadingActions.tsx
diff --git a/products/alerts/frontend/views/EditAlertModalV2/EditAlertTabs.tsx b/products/alerts/frontend/views/EditAlertModal/EditAlertTabs.tsx
similarity index 100%
rename from products/alerts/frontend/views/EditAlertModalV2/EditAlertTabs.tsx
rename to products/alerts/frontend/views/EditAlertModal/EditAlertTabs.tsx
diff --git a/products/alerts/frontend/views/EditAlertModalV2/buildWizardSteps.test.tsx b/products/alerts/frontend/views/EditAlertModal/buildWizardSteps.test.tsx
similarity index 100%
rename from products/alerts/frontend/views/EditAlertModalV2/buildWizardSteps.test.tsx
rename to products/alerts/frontend/views/EditAlertModal/buildWizardSteps.test.tsx
diff --git a/products/alerts/frontend/views/EditAlertModalV2/buildWizardSteps.tsx b/products/alerts/frontend/views/EditAlertModal/buildWizardSteps.tsx
similarity index 100%
rename from products/alerts/frontend/views/EditAlertModalV2/buildWizardSteps.tsx
rename to products/alerts/frontend/views/EditAlertModal/buildWizardSteps.tsx
diff --git a/products/alerts/frontend/views/EditAlertModalV2.tsx b/products/alerts/frontend/views/EditAlertModalV2.tsx
deleted file mode 100644
index f1d897852d7a..000000000000
--- a/products/alerts/frontend/views/EditAlertModalV2.tsx
+++ /dev/null
@@ -1,465 +0,0 @@
-import { useActions, useValues } from 'kea'
-import { Form } from 'kea-forms'
-import { useCallback, useMemo } from 'react'
-
-import { UserActivityIndicator } from 'lib/components/UserActivityIndicator/UserActivityIndicator'
-import { dayjs } from 'lib/dayjs'
-import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'
-import { LemonModal } from 'lib/lemon-ui/LemonModal'
-import { formatDate } from 'lib/utils/datetime'
-import { insightLogic } from 'scenes/insights/insightLogic'
-import { insightVizDataLogic } from 'scenes/insights/insightVizDataLogic'
-import { getDisplayNameFromEntityNode } from 'scenes/insights/utils'
-import { teamLogic } from 'scenes/teamLogic'
-import { trendsDataLogic } from 'scenes/trends/trendsDataLogic'
-import { urls } from 'scenes/urls'
-
-import { AlertCalculationInterval, AlertConditionType, InsightThresholdType } from '~/queries/schema/schema-general'
-import { isFunnelsQuery, isInsightVizNode } from '~/queries/utils'
-import { FunnelVizType } from '~/types'
-
-import { AlertAdvancedOptionsSection } from 'products/alerts/frontend/components/AlertAdvancedOptionsSection'
-import { AlertStateIndicator, AlertTimezoneNotice } from 'products/alerts/frontend/components/AlertDefinition'
-import { AlertDefinitionSection } from 'products/alerts/frontend/components/AlertDefinitionSection'
-import {
- AlertEditor,
- AlertEditorFormDetails,
- AlertEditorLoading,
-} from 'products/alerts/frontend/components/AlertEditor'
-import { AlertIntervalRow } from 'products/alerts/frontend/components/AlertIntervalRow'
-import { AlertPreviewCard } from 'products/alerts/frontend/components/AlertPreviewCard'
-import { buildAlertSummary } from 'products/alerts/frontend/components/alertSummary'
-import { AlertWizard } from 'products/alerts/frontend/components/AlertWizard'
-import { ThresholdConditionRow } from 'products/alerts/frontend/components/ThresholdConditionRow'
-import { isSubDailyAlertInterval } from 'products/alerts/frontend/logic/alertIntervalHelpers'
-import { quietHoursFormError } from 'products/alerts/frontend/logic/scheduleRestrictionValidation'
-import { deriveAlertCheckPreviewSeries } from 'products/alerts/frontend/logic/trendsAlertPreview'
-import { InsightAlertNotificationSection } from 'products/alerts/frontend/views/InsightAlertNotificationSection'
-
-import { alertFormLogic, canCheckOngoingInterval, insightAlertKindForQuery } from '../logic/alertFormLogic'
-import { alertLogic } from '../logic/alertLogic'
-import { alertNotificationLogic } from '../logic/alertNotificationLogic'
-import { isNextPlannedEvaluationStale } from '../logic/alertSchedulingStale'
-import { insightAlertsLogic } from '../logic/insightAlertsLogic'
-import { supportsAnomalyDetection, supportsOngoingInterval } from '../types'
-import type { AlertType } from '../types'
-import { AlertHistorySection } from './AlertHistorySection'
-import type { ResolvedAlertModalProps } from './EditAlertModal'
-import { AlertEnabledAction, AlertLeadingActions } from './EditAlertModalV2/AlertLeadingActions'
-import { buildWizardSteps } from './EditAlertModalV2/buildWizardSteps'
-import { EditAlertTabs } from './EditAlertModalV2/EditAlertTabs'
-
-/** Redesigned alert edit/create modal. New alerts use a 3-step wizard (Monitor → Schedule & notify
- * → Review); editing an existing alert skips the wizard and uses a sectioned layout with a one-line
- * summary and a live preview card. Gated behind the ALERTS_REDESIGNED_EDIT_MODAL feature flag. */
-export function EditAlertModalV2({
- initialAlert,
- isOpen,
- alertId,
- insightId,
- insightShortId,
- onClose,
- onEditSuccess,
- insightLogicProps,
- defaultToAnomalyDetection,
- insightName,
- useAlertCheckPreview,
-}: ResolvedAlertModalProps): JSX.Element {
- const _alertLogic = alertLogic({ alertId })
- const { alert: loadedAlert, alertLoading } = useValues(_alertLogic)
- const alert = initialAlert ?? loadedAlert
- const { insightLoading } = useValues(insightLogic(insightLogicProps))
-
- const _onEditSuccess = useCallback(
- (alertId: AlertType['id'] | undefined) => {
- onEditSuccess(alertId)
- },
- [onEditSuccess]
- )
-
- const trendsLogic = trendsDataLogic(insightLogicProps)
- const {
- alertSeries,
- isNonTimeSeriesDisplay,
- isBreakdownValid,
- formulaNodes,
- interval: trendInterval,
- indexedResults,
- insightDataLoading,
- } = useValues(trendsLogic)
-
- const { query } = useValues(insightVizDataLogic(insightLogicProps))
-
- const funnelSource = !!query && isInsightVizNode(query) && isFunnelsQuery(query.source) ? query.source : null
- const isTrendsFunnel = funnelSource?.funnelsFilter?.funnelVizType === FunnelVizType.Trends
- const funnelStepLabels = (funnelSource?.series ?? []).map(
- (node, index) => getDisplayNameFromEntityNode(node) ?? `Step ${index + 1}`
- )
- const insightAlertKind = insightAlertKindForQuery(query)
-
- const formLogicProps = {
- alert,
- insightId,
- onEditSuccess: _onEditSuccess,
- insightVizDataLogicProps: insightLogicProps,
- insightInterval: trendInterval ?? undefined,
- insightAlertKind,
- defaultToAnomalyDetection: !alertId && !isNonTimeSeriesDisplay && defaultToAnomalyDetection,
- insightName,
- insightIsTrendsFunnel: isTrendsFunnel,
- uiVersion: 'redesigned' as const,
- }
- const formLogic = alertFormLogic(formLogicProps)
- const {
- alertForm,
- isAlertFormSubmitting,
- alertFormChanged,
- alertFormHasErrors,
- alertFormValidationErrors,
- alertFormSubmitAttempted,
- simulationResult,
- simulationResultLoading,
- simulationDateFrom,
- thresholdBoundsFormError,
- hogqlAlertPreview,
- funnelAlertPreview,
- hogqlResultColumns,
- hogqlValueColumnOptions,
- hogqlLabelColumnOptions,
- } = useValues(formLogic)
- const {
- deleteAlert,
- snoozeAlert,
- clearSnooze,
- simulateAlert,
- clearSimulation,
- setSimulationDateFrom,
- setAlertFormSubmitAttempted,
- } = useActions(formLogic)
- const { setAlertFormValue } = useActions(formLogic)
-
- const { currentTeam } = useValues(teamLogic)
- const projectTimezone = currentTeam?.timezone ?? 'UTC'
- const inlineNotificationsEnabled = useFeatureFlag('ALERTS_INLINE_NOTIFICATIONS')
- const investigationAgentEnabled = useFeatureFlag('ALERTS_INVESTIGATION_AGENT')
-
- const notificationLogic = alertNotificationLogic({ alertId })
- const { existingHogFunctions, pendingNotifications, testDeliveryResultLoading } = useValues(notificationLogic)
- const { sendTestDelivery } = useActions(notificationLogic)
- const hasPendingNotifications = inlineNotificationsEnabled && pendingNotifications.length > 0
- const hasTestDeliveryTargets =
- (alert?.subscribed_users?.some((user) => Boolean(user.email)) ?? false) ||
- existingHogFunctions.some((hogFunction) => hogFunction.enabled)
-
- const handleClose = useCallback(() => {
- clearSimulation()
- if (insightLogicProps && insightId) {
- insightAlertsLogic({ insightId, insightLogicProps }).actions.clearSimulationAnomalyPoints()
- }
- onClose?.()
- }, [clearSimulation, insightLogicProps, insightId, onClose])
-
- const clearSimulationOverlay = useCallback(() => {
- if (insightLogicProps && insightId) {
- insightAlertsLogic({ insightId, insightLogicProps }).actions.clearSimulationAnomalyPoints()
- }
- }, [insightLogicProps, insightId])
-
- const creatingNewAlert = alertId === undefined
- const can_check_ongoing_interval = canCheckOngoingInterval(alertForm, { isTrendsFunnel })
- const alertMode = alertForm.detector_config ? 'detector' : 'threshold'
- const nextPlannedEvaluationStale = useMemo(
- () =>
- isNextPlannedEvaluationStale(
- creatingNewAlert,
- alert
- ? {
- calculation_interval: alert.calculation_interval,
- schedule_restriction: alert.schedule_restriction,
- skip_weekend: alert.skip_weekend,
- config: supportsOngoingInterval(alert.config)
- ? { check_ongoing_interval: alert.config.check_ongoing_interval }
- : null,
- }
- : null,
- {
- calculation_interval: alertForm.calculation_interval,
- schedule_restriction: alertForm.schedule_restriction,
- skip_weekend: alertForm.skip_weekend,
- config: supportsOngoingInterval(alertForm.config)
- ? { check_ongoing_interval: alertForm.config.check_ongoing_interval }
- : null,
- }
- ),
- [
- alert,
- alertForm.calculation_interval,
- alertForm.schedule_restriction,
- alertForm.skip_weekend,
- alertForm.config,
- creatingNewAlert,
- ]
- )
-
- const enabledAdvancedOptionsCount = useMemo(() => {
- let n = 0
- if (
- supportsOngoingInterval(alertForm.config) &&
- alertForm.config.check_ongoing_interval &&
- can_check_ongoing_interval
- ) {
- n += 1
- }
- if (
- (alertForm.calculation_interval === AlertCalculationInterval.DAILY ||
- isSubDailyAlertInterval(alertForm.calculation_interval)) &&
- alertForm.skip_weekend
- ) {
- n += 1
- }
- if ((alertForm.schedule_restriction?.blocked_windows?.length ?? 0) > 0) {
- n += 1
- }
- return n
- }, [
- alertForm.calculation_interval,
- alertForm.config,
- alertForm.schedule_restriction?.blocked_windows?.length,
- alertForm.skip_weekend,
- can_check_ongoing_interval,
- ])
-
- const subscribedCount = alertForm.subscribed_users?.length ?? 0
- const destinationCount = existingHogFunctions.length + pendingNotifications.length
- const summary = useMemo(
- () => buildAlertSummary(alertForm, subscribedCount, destinationCount),
- [alertForm, destinationCount, subscribedCount]
- )
-
- // The monitored trends series' values, for the live preview sparkline. Picked by the alert's
- // series_index so the preview matches what the alert actually evaluates.
- const trendsPreviewValues = useMemo(() => {
- if (!isTrendsFunnel && alertForm.config?.type === 'TrendsAlertConfig') {
- const idx = alertForm.config.series_index ?? 0
- const series = indexedResults?.[idx]
- return series?.data ?? null
- }
- return null
- }, [alertForm.config, indexedResults, isTrendsFunnel])
-
- const checkPreview = useMemo(() => {
- if (!useAlertCheckPreview || !alert) {
- return undefined
- }
- const preview = deriveAlertCheckPreviewSeries(
- alert.checks ?? [],
- alertForm.condition?.type ?? AlertConditionType.ABSOLUTE_VALUE,
- alertForm.threshold?.configuration?.type ?? InsightThresholdType.ABSOLUTE
- )
- return {
- ...preview,
- labels: preview.labels?.map((label) => formatDate(dayjs(label), 'MMM D, HH:mm')),
- }
- }, [alert, alertForm.condition?.type, alertForm.threshold?.configuration?.type, useAlertCheckPreview])
-
- const leadingActions = (
- <AlertLeadingActions
- alertForm={alertForm}
- alert={alert}
- onDeleteAlert={deleteAlert}
- onSnoozeAlert={snoozeAlert}
- onClearSnooze={clearSnooze}
- onSendTestDelivery={sendTestDelivery}
- testDeliveryLoading={testDeliveryResultLoading}
- testDeliveryDisabledReason={
- alertFormChanged || hasPendingNotifications ? 'Save changes before testing.' : undefined
- }
- showTestDelivery={hasTestDeliveryTargets}
- />
- )
-
- const thresholdValidationError =
- typeof alertFormValidationErrors.threshold === 'string' ? alertFormValidationErrors.threshold : undefined
-
- const definitionNode = (
- <AlertDefinitionSection
- alertForm={alertForm}
- alertMode={alertMode}
- thresholdBoundsFormError={thresholdBoundsFormError}
- isNonTimeSeriesDisplay={isNonTimeSeriesDisplay}
- trends={{ alertSeries, formulaNodes, isBreakdownValid }}
- funnel={{
- stepLabels: funnelStepLabels,
- preview: funnelAlertPreview,
- isTrendsFunnel,
- }}
- hogql={{
- preview: hogqlAlertPreview,
- columns: hogqlResultColumns,
- valueColumnOptions: hogqlValueColumnOptions,
- labelColumnOptions: hogqlLabelColumnOptions,
- }}
- supportsAnomalyDetection={!isNonTimeSeriesDisplay && supportsAnomalyDetection(alertForm.config)}
- twoColumnLayout
- investigationAgentEnabled={investigationAgentEnabled}
- simulationResult={simulationResult}
- simulationResultLoading={simulationResultLoading}
- simulationDateFrom={simulationDateFrom}
- onSetAlertFormValue={setAlertFormValue}
- thresholdRowRenderer={(props) => <ThresholdConditionRow {...props} />}
- onSimulateAlert={simulateAlert}
- onSetSimulationDateFrom={setSimulationDateFrom}
- onClearSimulation={clearSimulation}
- onClearSimulationOverlay={clearSimulationOverlay}
- />
- )
-
- const scheduleNode = (
- <div className="space-y-2">
- <AlertIntervalRow
- alertForm={alertForm}
- creatingNewAlert={creatingNewAlert}
- alert={alert}
- trendInterval={trendInterval}
- nextPlannedEvaluationStale={nextPlannedEvaluationStale}
- canCheckOngoingInterval={can_check_ongoing_interval}
- onSetAlertFormValue={setAlertFormValue}
- />
- <AlertTimezoneNotice
- timezone={projectTimezone}
- settingsUrl={urls.settings('environment-customization', 'date-and-time')}
- />
- </div>
- )
-
- const notifyNode = (
- <InsightAlertNotificationSection
- alertForm={alertForm}
- alertId={alertId}
- insightShortId={insightShortId}
- inlineNotificationsEnabled={inlineNotificationsEnabled}
- showSectionTitle={false}
- onSetAlertFormValue={setAlertFormValue}
- />
- )
-
- const advancedNode = (
- <AlertAdvancedOptionsSection
- alertForm={alertForm}
- canCheckOngoingInterval={can_check_ongoing_interval}
- projectTimezone={projectTimezone}
- enabledAdvancedOptionsCount={enabledAdvancedOptionsCount}
- defaultOpen
- onSetAlertFormValue={setAlertFormValue}
- />
- )
-
- const previewNode = (
- <AlertPreviewCard
- alertForm={alertForm}
- trendsValues={trendsPreviewValues}
- trendsLabels={
- indexedResults?.[
- alertForm.config?.type === 'TrendsAlertConfig' ? (alertForm.config.series_index ?? 0) : 0
- ]?.labels ?? null
- }
- funnelPreview={funnelAlertPreview}
- hogqlPreview={hogqlAlertPreview}
- checkPreview={checkPreview}
- loading={!useAlertCheckPreview && (insightLoading || insightDataLoading)}
- />
- )
- const nameError = alertFormSubmitAttempted && !alertForm.name ? 'Enter an alert name.' : undefined
- const scheduleRestrictionFormError = quietHoursFormError(alertForm.schedule_restriction)
-
- return (
- <LemonModal onClose={handleClose} isOpen={isOpen} width={900} simple title="">
- {alertLoading && !alert ? (
- <AlertEditorLoading title="Edit alert" onBack={handleClose} />
- ) : (
- <Form
- logic={alertFormLogic}
- props={formLogicProps}
- formKey="alertForm"
- enableFormOnSubmit
- className="LemonModal__layout"
- >
- {creatingNewAlert ? (
- <AlertWizard
- title="New alert"
- isSubmitting={isAlertFormSubmitting}
- hasChanges={alertFormChanged}
- onBack={handleClose}
- onSubmitAttempted={setAlertFormSubmitAttempted}
- steps={buildWizardSteps({
- nameNode: <AlertEditorFormDetails nameError={nameError} />,
- definitionNode,
- previewNode,
- scheduleNode,
- notifyNode,
- advancedNode,
- summary,
- thresholdValidationError,
- scheduleRestrictionFormError,
- alertFormHasErrors,
- alertName: alertForm.name,
- })}
- />
- ) : (
- <AlertEditor
- title="Edit alert"
- className="min-h-0 flex-1 overflow-hidden"
- contentClassName="min-h-0 flex-1 overflow-y-auto"
- onBack={handleClose}
- isEditing
- isSubmitting={isAlertFormSubmitting}
- hasChanges={alertFormChanged}
- hasPendingChanges={hasPendingNotifications}
- onSubmitAttempted={setAlertFormSubmitAttempted}
- leadingActions={leadingActions}
- trailingActions={<AlertEnabledAction alertForm={alertForm} />}
- >
- <div className="space-y-3">
- <EditAlertTabs
- summary={summary}
- summaryHeader={
- alert ? (
- <div className="flex items-center justify-between gap-3">
- <span className="font-medium">Current status</span>
- <AlertStateIndicator alert={alert} />
- </div>
- ) : undefined
- }
- nameNode={
- <AlertEditorFormDetails
- nameError={nameError}
- activity={
- alert?.created_by ? (
- <UserActivityIndicator
- at={alert.created_at}
- by={alert.created_by}
- prefix="Created"
- />
- ) : undefined
- }
- />
- }
- previewNode={previewNode}
- definitionNode={definitionNode}
- scheduleNode={scheduleNode}
- advancedNode={advancedNode}
- notifyNode={notifyNode}
- historyNode={
- alertId && alert ? (
- <AlertHistorySection alertId={alert.id} showCurrentStatus={false} />
- ) : null
- }
- />
- </div>
- </AlertEditor>
- )}
- </Form>
- )}
- </LemonModal>
- )
-}
diff --git a/products/alerts/frontend/views/ManageAlertsModal.stories.tsx b/products/alerts/frontend/views/ManageAlertsModal.stories.tsx
index aa1e88f0cf74..32965f26164e 100644
--- a/products/alerts/frontend/views/ManageAlertsModal.stories.tsx
+++ b/products/alerts/frontend/views/ManageAlertsModal.stories.tsx
@@ -1,7 +1,5 @@
import type { Meta, StoryObj } from '@storybook/react'
-import { FEATURE_FLAGS } from 'lib/constants'
-
import {
AlertCalculationInterval,
AlertConditionType,
@@ -98,7 +96,6 @@ const meta: Meta<typeof ManageAlertsModal> = {
layout: 'fullscreen',
viewMode: 'story',
mockDate: '2026-07-16',
- featureFlags: [FEATURE_FLAGS.ALERTS_REDESIGNED_EDIT_MODAL],
testOptions: { viewport: { width: 1000, height: 700 } },
},
args: {
diff --git a/products/alerts/frontend/views/ManageAlertsModal.tsx b/products/alerts/frontend/views/ManageAlertsModal.tsx
index 760a3e379ebb..2d9256c9ce69 100644
--- a/products/alerts/frontend/views/ManageAlertsModal.tsx
+++ b/products/alerts/frontend/views/ManageAlertsModal.tsx
@@ -4,15 +4,12 @@ import { router } from 'kea-router'
import { Link } from '@posthog/lemon-ui'
import { UserActivityIndicator } from 'lib/components/UserActivityIndicator/UserActivityIndicator'
-import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'
import { LemonButton } from 'lib/lemon-ui/LemonButton'
import { LemonModal } from 'lib/lemon-ui/LemonModal'
-import { ProfileBubbles } from 'lib/lemon-ui/ProfilePicture'
import { Spinner } from 'lib/lemon-ui/Spinner'
import { pluralize } from 'lib/utils/strings'
import { urls } from 'scenes/urls'
-import { InsightThresholdType } from '~/queries/schema/schema-general'
import { InsightShortId } from '~/types'
import { AlertStateIndicator } from '../components/AlertDefinition'
@@ -26,46 +23,6 @@ interface AlertListItemProps {
destinationCount?: number
destinationsLoading?: boolean
onClick: () => void
- redesigned: boolean
-}
-
-function AlertSummary({ alert }: { alert: AlertType }): JSX.Element | null {
- if (!alert.enabled) {
- return <div className="text-secondary pl-3">Disabled</div>
- }
-
- if (alert.detector_config) {
- const config = alert.detector_config as unknown as Record<string, unknown>
- if (config.type === 'ensemble') {
- const detectors = (config.detectors as Array<{ type: string }>) ?? []
- const operator = (config.operator as string)?.toUpperCase() ?? 'AND'
- const labels = detectors.map((d) => (d.type === 'zscore' ? 'Z-Score' : d.type === 'mad' ? 'MAD' : d.type))
- return <div className="text-secondary pl-3">{labels.join(` ${operator} `)}</div>
- }
- const { type, threshold } = config as { type: string; threshold?: number }
- const label = type === 'zscore' ? 'Z-Score' : type === 'mad' ? 'MAD' : type
- return (
- <div className="text-secondary pl-3">
- {label} {threshold != null ? threshold : ''}
- </div>
- )
- }
-
- const bounds = alert.threshold?.configuration?.bounds
- const isPercentage = alert.threshold?.configuration.type === InsightThresholdType.PERCENTAGE
- if (!bounds?.lower && !bounds?.upper) {
- return null
- }
-
- return (
- <div className="text-secondary pl-3">
- {bounds?.lower != null &&
- `Low ${isPercentage ? bounds.lower * 100 : bounds.lower}${isPercentage ? '%' : ''}`}
- {bounds?.lower != null && bounds?.upper != null ? ' · ' : ''}
- {bounds?.upper != null &&
- `High ${isPercentage ? bounds.upper * 100 : bounds.upper}${isPercentage ? '%' : ''}`}
- </div>
- )
}
export function AlertListItem({
@@ -73,40 +30,24 @@ export function AlertListItem({
destinationCount = 0,
destinationsLoading = false,
onClick,
- redesigned,
}: AlertListItemProps): JSX.Element {
- if (redesigned) {
- const summary = buildAlertSummary(alert, alert.subscribed_users?.length ?? 0, destinationCount)
- if (destinationsLoading) {
- summary.notifies = 'Loading…'
- }
- return (
- <LemonButton onClick={onClick} data-attr="alert-list-item" fullWidth>
- <AlertSummaryBanner
- summary={summary}
- header={
- <div className="flex items-center justify-between gap-3">
- <span className="min-w-0 truncate">{alert.name}</span>
- <AlertStateIndicator alert={alert} />
- </div>
- }
- footer={<UserActivityIndicator prefix="Created" at={alert.created_at} by={alert.created_by} />}
- />
- </LemonButton>
- )
+ const summary = buildAlertSummary(alert, alert.subscribed_users?.length ?? 0, destinationCount)
+ if (destinationsLoading) {
+ summary.notifies = 'Loading…'
}
return (
- <LemonButton type="secondary" onClick={onClick} data-attr="alert-list-item" fullWidth>
- <div className="flex justify-between flex-auto items-center p-2">
- <div className="flex flex-row gap-3 items-center">
- <span>{alert.name}</span>
- <AlertStateIndicator alert={alert} />
- <AlertSummary alert={alert} />
- </div>
-
- <ProfileBubbles limit={4} people={alert.subscribed_users?.map(({ email }) => ({ email }))} />
- </div>
+ <LemonButton onClick={onClick} data-attr="alert-list-item" fullWidth>
+ <AlertSummaryBanner
+ summary={summary}
+ header={
+ <div className="flex items-center justify-between gap-3">
+ <span className="min-w-0 truncate">{alert.name}</span>
+ <AlertStateIndicator alert={alert} />
+ </div>
+ }
+ footer={<UserActivityIndicator prefix="Created" at={alert.created_at} by={alert.created_by} />}
+ />
</LemonButton>
)
}
@@ -127,7 +68,6 @@ export function ManageAlertsModal(props: ManageAlertsModalProps): JSX.Element {
const logic = insightAlertsLogic(props)
const { alerts, alertsLoading, alertDestinationCounts, alertDestinationCountsLoading } = useValues(logic)
- const redesigned = useFeatureFlag('ALERTS_REDESIGNED_EDIT_MODAL')
const showDeferredListSpinner = props.deferInitialAlertsLoad && props.isOpen && alertsLoading
const openAlert = (alertId: AlertType['id']): void => {
@@ -181,7 +121,6 @@ export function ManageAlertsModal(props: ManageAlertsModalProps): JSX.Element {
destinationCount={alertDestinationCounts[alert.id] ?? 0}
destinationsLoading={alertDestinationCountsLoading}
onClick={() => openAlert(alert.id)}
- redesigned={redesigned}
/>
))}
</div>