Skip to content

Commit 4023b4b

Browse files
feat(preprod): Show 'Auto-approved' label with tooltip for auto-approved snapshots
1 parent 213987e commit 4023b4b

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

src/sentry/preprod/api/endpoints/preprod_artifact_snapshot.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,9 +394,11 @@ def get(self, request: Request, organization: Organization, snapshot_id: str) ->
394394
source="github",
395395
)
396396
)
397+
is_auto_approved = any((a.extras or {}).get("auto_approval") is True for a in approved)
397398
approval_info = SnapshotApprovalInfo(
398399
status="approved",
399400
approvers=approver_list,
401+
is_auto_approved=is_auto_approved,
400402
)
401403
elif all_approvals:
402404
# If records exist but none are APPROVED, they must be NEEDS_APPROVAL

src/sentry/preprod/api/models/snapshots/project_preprod_snapshot_models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class SnapshotApprover(BaseModel):
5959
class SnapshotApprovalInfo(BaseModel):
6060
status: Literal["approved", "requires_approval"]
6161
approvers: list[SnapshotApprover] = []
62+
is_auto_approved: bool = False
6263

6364

6465
class SnapshotDetailsApiResponse(BaseModel):

static/app/views/preprod/snapshots/header/snapshotHeaderActions.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ import {Client} from 'sentry/api';
1111
import {ConfirmDelete} from 'sentry/components/confirmDelete';
1212
import {DropdownMenu} from 'sentry/components/dropdownMenu';
1313
import type {MenuItemProps} from 'sentry/components/dropdownMenu';
14+
import {Tooltip} from 'sentry/components/tooltip';
1415
import {
1516
IconCheckmark,
1617
IconDelete,
1718
IconEllipsis,
19+
IconInfo,
1820
IconRefresh,
1921
IconThumb,
2022
IconTimer,
@@ -47,6 +49,7 @@ export function SnapshotHeaderActions({
4749
const [isDeleting, setIsDeleting] = useState(false);
4850

4951
const isApproved = data.approval_info?.status === 'approved';
52+
const isAutoApproved = data.approval_info?.is_auto_approved ?? false;
5053
const approvers: AvatarUser[] = (data.approval_info?.approvers ?? []).map((a, i) => ({
5154
id: a.id ?? `approver-${i}`,
5255
name: a.name ?? '',
@@ -148,9 +151,20 @@ export function SnapshotHeaderActions({
148151
{data.approval_info &&
149152
(isApproved ? (
150153
<Flex align="center" gap="xl">
151-
<Tag variant="success" icon={<IconCheckmark />}>
152-
{t('Approved')}
153-
</Tag>
154+
<Flex align="center" gap="xs">
155+
<Tag variant="success" icon={<IconCheckmark />}>
156+
{isAutoApproved ? t('Auto-approved') : t('Approved')}
157+
</Tag>
158+
{isAutoApproved && (
159+
<Tooltip
160+
title={t(
161+
'Automatically approved because the changes match a previously approved build on this PR.'
162+
)}
163+
>
164+
<IconInfo size="sm" />
165+
</Tooltip>
166+
)}
167+
</Flex>
154168
{approvers.length > 0 && (
155169
<AvatarList users={approvers} avatarSize={24} maxVisibleAvatars={2} />
156170
)}

static/app/views/preprod/types/snapshotTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export interface SnapshotApprover {
3636
export interface SnapshotApprovalInfo {
3737
approvers: SnapshotApprover[];
3838
status: 'approved' | 'requires_approval';
39+
is_auto_approved?: boolean;
3940
}
4041

4142
export interface SnapshotDetailsApiResponse {

0 commit comments

Comments
 (0)