Phi
Delete Resource
@dicehub/phiv1.0.0-beta.1

Delete Resource

A confirmation dialog for safely deleting resources by typing the resource name.

<Button variant="destructive" @click="open = true">
  Delete Zone
</Button>

<DeleteResource
  v-model:open="open"
  resource-type="Zone"
  resource-name="example.com"
  @delete="handleDelete"
/>

Installation

DeleteResource is a package block for critical delete confirmation flows.

1. Install the package

pnpm add @dicehub/phi@beta

2. Import the block

import { DeleteResource } from "@dicehub/phi/blocks/delete-resource";

Why blocks? Blocks are composed experiences for product flows that need predictable behavior, copy, and recovery states.

Usage

<script setup lang="ts">
import { ref } from "vue";
import { Button } from "@dicehub/phi/components/button";
import { DeleteResource } from "@dicehub/phi/blocks/delete-resource";

const open = ref(false);
const isDeleting = ref(false);

async function handleDelete() {
  isDeleting.value = true;
  try {
    await deleteZone("example.com");
    open.value = false;
  } finally {
    isDeleting.value = false;
  }
}
</script>

<template>
  <Button variant="destructive" @click="open = true">
    Delete Zone
  </Button>

  <DeleteResource
    v-model:open="open"
    resource-type="Zone"
    resource-name="example.com"
    :is-deleting="isDeleting"
    @delete="handleDelete"
  />
</template>

Examples

Worker Deletion

Works with any resource type by changing the resource type and resource name props.

<DeleteResource
  v-model:open="open"
  resource-type="Worker"
  resource-name="api-gateway-worker"
  @delete="handleDelete"
/>

Error State

Use the errorMessage prop to show an error message.

<DeleteResource
  v-model:open="open"
  resource-type="Zone"
  resource-name="example.com"
  error-message="Something went wrong"
  @delete="handleDelete"
/>

API Reference

Props

PropTypeDefaultDescription
size"sm" | "base""base"Dialog size variant.
open*boolean-Whether the dialog is open. In Vue, use v-model:open.
resourceType*string-The type of resource being deleted.
resourceName*string-The exact resource name the user must type.
isDeletingbooleanfalseWhether the delete action is in progress.
caseSensitivebooleantrueWhether the confirmation input must match case exactly.
deleteButtonTextstring`Delete ${resourceType}`Custom destructive action label.
classNamestring-Additional class for the dialog.
errorMessagestring-Error message displayed above the confirmation copy.

Events

EventTypeDescription
delete() => voidEmitted when the user confirms deletion.
openChange(open: boolean) => voidEmitted whenever the dialog open state changes.
update:open(open: boolean) => voidUsed by v-model:open for controlled state.