Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,17 @@ const DeleteVariantContent = ({revisionIds, forceVariantIds = [], onClose}: Prop
const totalSelectedCount = uniqueRevisionIds.length
const isBulkDelete = deletionPlan.variants.length > 0 || totalSelectedCount > 1

// Check if this would delete the last revision of the app
const isLastRevision = useMemo(() => {
// Count total visible revisions across all variants
let totalRevisions = 0
Object.values(variantGroups).forEach((group) => {
totalRevisions += group.totalIds.length
})
// If we're deleting all revisions, this is the last one
return totalRevisions > 0 && totalSelectedCount >= totalRevisions
}, [variantGroups, totalSelectedCount])

const onDeleteVariant = useCallback(async () => {
setIsMutating(true)
try {
Expand Down Expand Up @@ -277,13 +288,19 @@ const DeleteVariantContent = ({revisionIds, forceVariantIds = [], onClose}: Prop
type="primary"
danger
loading={isMutating}
disabled={isMutating || totalSelectedCount === 0}
disabled={isMutating || totalSelectedCount === 0 || isLastRevision}
icon={<Trash size={14} />}
onClick={onDeleteVariant}
title={isLastRevision ? "Cannot delete the only revision. Delete the app instead." : undefined}
>
{isBulkDelete ? "Delete selected" : "Delete"}
</Button>
</div>
{isLastRevision && (
<Text type="secondary" className="text-center">
Cannot delete the only revision. Delete the app instead.
</Text>
)}
</section>
)
}
Expand Down