Skip to content

Commit

Permalink
Add note about disks to instance delete confirm (#2185)
Browse files Browse the repository at this point in the history
add note about disks to instance delete confirm
  • Loading branch information
david-crespo authored Apr 23, 2024
1 parent e649e7b commit 2b6d0f7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/pages/project/instances/actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export const useMakeInstanceActions = (
}),
label: instance.name,
resourceKind: 'instance',
extraContent: 'Any attached disks will be detached but not deleted.',
}),
disabled: !instanceCan.delete(instance) && (
<>Only {fancifyStates(instanceCan.delete.states)} instances can be deleted</>
Expand Down
9 changes: 7 additions & 2 deletions app/stores/confirm-delete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,22 @@ type DeleteConfig = {
*/
label: React.ReactNode
resourceKind?: string
extraContent?: React.ReactNode
}

export const confirmDelete =
({ doDelete, label, resourceKind }: DeleteConfig) =>
({ doDelete, label, resourceKind, extraContent }: DeleteConfig) =>
() => {
const displayLabel = typeof label === 'string' ? <HL>{label}</HL> : label
const modalTitle = resourceKind ? `Confirm delete ${resourceKind}` : 'Confirm delete'
useConfirmAction.setState({
actionConfig: {
doAction: doDelete,
modalContent: <p>Are you sure you want to delete {displayLabel}?</p>,
modalContent: (
<p>
Are you sure you want to delete {displayLabel}? {extraContent}
</p>
),
errorTitle: 'Could not delete resource',
modalTitle,
actionType: 'danger',
Expand Down

0 comments on commit 2b6d0f7

Please sign in to comment.