Skip to content

Commit

Permalink
Merge pull request #747 from hackclub/prevent-deleting-shipped-projects
Browse files Browse the repository at this point in the history
Only allow deletion on staged ships
  • Loading branch information
maxwofford authored Nov 13, 2024
2 parents 6a294e8 + 052aabe commit 663b6aa
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/app/harbor/shipyard/edit-ship-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default function EditShipForm({
}) {
const [deleting, setDeleting] = useState(false)
const [saving, setSaving] = useState(false)
const allowDeletion = ship.shipStatus === 'staged'

const { toast } = useToast()

Expand Down Expand Up @@ -190,14 +191,16 @@ export default function EditShipForm({
Save edits
</Button>

<Button
className={`${buttonVariants({ variant: 'destructive' })} ml-auto`}
onClick={handleDelete}
disabled={deleting}
>
{deleting ? <Icon glyph="more" /> : <Icon glyph="forbidden" />}
Delete Ship
</Button>
{allowDeletion && (
<Button
className={`${buttonVariants({ variant: 'destructive' })} ml-auto`}
onClick={handleDelete}
disabled={deleting}
>
{deleting ? <Icon glyph="more" /> : <Icon glyph="forbidden" />}
Delete Ship
</Button>
)}
</div>
</form>
)
Expand Down

0 comments on commit 663b6aa

Please sign in to comment.