From 2b881eccf534373f136f001b1ccb41d905ac8432 Mon Sep 17 00:00:00 2001 From: Nelson Osacky Date: Tue, 7 Apr 2026 16:31:32 +0200 Subject: [PATCH] feat(preprod): Add snapshot PR comments toggle to project settings (EME-999) Add a toggle on the Snapshots tab in project settings to enable/disable snapshot PR comments, matching the existing build distribution toggle. Gated behind the preprod-snapshot-pr-comments feature flag. --- static/app/types/project.tsx | 1 + .../views/settings/project/preprod/index.tsx | 10 ++- .../preprod/snapshotPrCommentsToggle.tsx | 64 +++++++++++++++++++ 3 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 static/app/views/settings/project/preprod/snapshotPrCommentsToggle.tsx diff --git a/static/app/types/project.tsx b/static/app/types/project.tsx index 91692954341d04..616bcb36d108f7 100644 --- a/static/app/types/project.tsx +++ b/static/app/types/project.tsx @@ -88,6 +88,7 @@ export type Project = { preprodSizeEnabledQuery?: string | null; preprodSizeStatusChecksEnabled?: boolean; preprodSizeStatusChecksRules?: unknown[]; + preprodSnapshotPrCommentsEnabled?: boolean; preprodSnapshotStatusChecksEnabled?: boolean; preprodSnapshotStatusChecksFailOnAdded?: boolean; preprodSnapshotStatusChecksFailOnRemoved?: boolean; diff --git a/static/app/views/settings/project/preprod/index.tsx b/static/app/views/settings/project/preprod/index.tsx index 79cfa76313cd9d..bb82587d6e3f0f 100644 --- a/static/app/views/settings/project/preprod/index.tsx +++ b/static/app/views/settings/project/preprod/index.tsx @@ -17,6 +17,7 @@ import {SettingsPageHeader} from 'sentry/views/settings/components/settingsPageH import {FeatureFilter} from './featureFilter'; import {PrCommentsToggle} from './prCommentsToggle'; +import {SnapshotPrCommentsToggle} from './snapshotPrCommentsToggle'; import {SnapshotStatusChecks} from './snapshotStatusChecks'; import {StatusCheckRules} from './statusCheckRules'; @@ -111,7 +112,14 @@ export default function PreprodSettings() { )} - {tab === 'snapshots' && } + {tab === 'snapshots' && ( + + + + + + + )} ); diff --git a/static/app/views/settings/project/preprod/snapshotPrCommentsToggle.tsx b/static/app/views/settings/project/preprod/snapshotPrCommentsToggle.tsx new file mode 100644 index 00000000000000..39aaaf41c0ad6e --- /dev/null +++ b/static/app/views/settings/project/preprod/snapshotPrCommentsToggle.tsx @@ -0,0 +1,64 @@ +import {Flex, Stack} from '@sentry/scraps/layout'; +import {Switch} from '@sentry/scraps/switch'; +import {Text} from '@sentry/scraps/text'; + +import { + addErrorMessage, + addLoadingMessage, + addSuccessMessage, +} from 'sentry/actionCreators/indicator'; +import {Panel} from 'sentry/components/panels/panel'; +import {PanelBody} from 'sentry/components/panels/panelBody'; +import {PanelHeader} from 'sentry/components/panels/panelHeader'; +import {t} from 'sentry/locale'; +import {useUpdateProject} from 'sentry/utils/project/useUpdateProject'; +import {useProjectSettingsOutlet} from 'sentry/views/settings/project/projectSettingsLayout'; + +const READ_KEY = 'sentry:preprod_snapshot_pr_comments_enabled'; +const WRITE_KEY = 'preprodSnapshotPrCommentsEnabled'; + +export function SnapshotPrCommentsToggle() { + const {project} = useProjectSettingsOutlet(); + const {mutate: updateProject} = useUpdateProject(project); + + const enabled = (project[WRITE_KEY] ?? project.options?.[READ_KEY]) !== false; + + function handleToggle() { + addLoadingMessage(t('Saving...')); + updateProject( + {[WRITE_KEY]: !enabled}, + { + onSuccess: () => { + addSuccessMessage(t('PR comment settings updated')); + }, + onError: () => { + addErrorMessage(t('Failed to save changes. Please try again.')); + }, + } + ); + } + + return ( + + {t('Snapshots - Pull Request Comments')} + + + + + {t('Snapshot Pull Request Comments')} + + + {t('Post snapshot comparison results as comments on pull requests.')} + + + + + + + ); +}