Skip to content

add delete functionality#5005

Closed
vansh-commits wants to merge 3 commits intounkeyed:mainfrom
vansh-commits:fix/delete-project-function
Closed

add delete functionality#5005
vansh-commits wants to merge 3 commits intounkeyed:mainfrom
vansh-commits:fix/delete-project-function

Conversation

@vansh-commits
Copy link
Contributor

What does this PR do?

"On project cards, the Delete button does not perform any action when clicked.", fixed, delete button now works

Fixes #4916

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How should this be tested?

  • Try deleting a projects from /[workspace-slug]/projects, this is working now

Checklist

  • Filled out the "How to test" section in this PR
  • Read Contributing Guide
  • Self-reviewed my own code
  • Commented on my code in hard-to-understand areas
  • Ran pnpm build
  • Ran pnpm fmt
  • Checked for warnings, there are none
  • Removed all console.logs
  • Merged the latest changes from main onto my branch with git pull origin main
  • My changes don't cause any responsiveness issues

Copilot AI review requested due to automatic review settings February 11, 2026 20:04
@vercel
Copy link

vercel bot commented Feb 11, 2026

@vansh-commits is attempting to deploy a commit to the Unkey Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 11, 2026

📝 Walkthrough

Walkthrough

Adds end-to-end project deletion: a frontend DeleteProject component and useDeleteProject hook, and updates the server deleteProject procedure to enforce rate limits, validate deleteProtection, cascade-delete related entities, improve error handling, and change the return payload to { projectId }.

Changes

Cohort / File(s) Summary
Frontend — Delete dialog
web/apps/dashboard/app/(app)/[workspaceSlug]/projects/_components/list/delete-project.tsx
New React component rendering a deletion dialog with zod-validated confirmation, local loading/open state, warning UI, and calls the deletion mutation.
Frontend — Action wiring
web/apps/dashboard/app/(app)/[workspaceSlug]/projects/_components/list/project-actions.tsx
Replaces previous DeleteProjectDialog usage with the new DeleteProject component; simplifies ActionComponent to forward props and provide projectId.
Frontend — Deletion hook
web/apps/dashboard/app/(app)/[workspaceSlug]/projects/_components/list/use-delete-project.ts
New useDeleteProject(onSuccess) hook wrapping a TRPC delete mutation; handles cache invalidation, collection cleanup, and detailed error-to-toast mappings (NOT_FOUND, PRECONDITION_FAILED, TOO_MANY_REQUESTS).
Backend — delete procedure
web/apps/dashboard/lib/trpc/routers/deploy/project/delete.ts
Adds named rate limiting, uses ctx.workspace.id to fetch project (id,name,deleteProtection), returns NOT_FOUND when missing, enforces deleteProtection, wraps logic in try/catch with console.error, performs expanded cascade deletions (policies, bindings, instances, sentinels, routes, domains, repo connections, deployments, environment-scoped settings, environments, then project), updates audit log payload, and returns { projectId }.

Sequence Diagram

sequenceDiagram
    participant User
    participant DeleteProject as DeleteProject<br/>Component
    participant Hook as useDeleteProject<br/>Hook
    participant TRPC as TRPC Router
    participant DB as Database
    participant Toast as Toast Service

    User->>DeleteProject: Open dialog / check confirmation
    User->>DeleteProject: Click Confirm Delete
    DeleteProject->>Hook: invoke delete mutation(projectId)
    Hook->>TRPC: call deleteProject RPC
    TRPC->>TRPC: enforce rate limit
    TRPC->>DB: fetch project (id,name,deleteProtection)
    DB-->>TRPC: project row
    TRPC->>TRPC: verify not delete-protected
    TRPC->>DB: delete related entities (policies, bindings, instances, sentinels, routes, domains, repo connections, deployments, env-scoped settings, environments)
    DB-->>TRPC: deletions complete
    TRPC->>TRPC: write audit log, return {projectId}
    TRPC-->>Hook: {projectId}
    Hook->>Toast: show success toast
    Hook->>DeleteProject: call onSuccess (close dialog)
    DeleteProject->>User: dialog closed
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is vague and generic, using non-descriptive phrasing like 'add delete functionality' that doesn't clearly convey the specific change being made. Use a more specific title such as 'Implement project deletion functionality for project cards' to better describe the actual change being made.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description is mostly complete and addresses the issue, including issue reference, type of change, test instructions, and checklist, though some template sections have minimal content.
Linked Issues check ✅ Passed The code changes fully implement the objective from issue #4916 by adding working delete functionality to project cards through new DeleteProject component, mutation hook, and backend deletion logic.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing project deletion functionality; no out-of-scope modifications detected in the PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
web/apps/dashboard/lib/trpc/routers/deploy/project/delete.ts (3)

39-105: Catch block swallows the original error's identity.

If the transaction throws a TRPCError (e.g., from insertAuditLogs), the catch re-wraps it as a generic INTERNAL_SERVER_ERROR, losing the original error code. This is acceptable here since all code inside the try is infra-level, but consider attaching the original error as cause for better debuggability:

Suggested improvement
      throw new TRPCError({
        code: "INTERNAL_SERVER_ERROR",
        message: "Failed to delete project. Please try again later or contact support@unkey.com",
+       cause: err,
      });

94-100: console.error left in production code.

The PR checklist mentions removing console.logs. While console.error is intentional here for error logging, the codebase appears to have structured logging utilities (e.g., logOperation seen in trpc.ts). Consider using the structured logger for consistency and to ensure logs are captured by your observability pipeline.


10-12: Consider tightening projectId validation.

z.string() accepts empty strings. A minimal guard like .min(1) would reject obviously invalid input at the boundary rather than hitting the database.

Suggested fix
-      projectId: z.string(),
+      projectId: z.string().min(1),

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes project deletion from the projects list by wiring the “Delete project” action to a new client-side delete flow and updating the backend delete mutation.

Changes:

  • Update the deploy.project.delete tRPC mutation to perform a more comprehensive delete transaction and improve error handling.
  • Replace the previous delete dialog usage with a new DeleteProject action component and useDeleteProject mutation hook.
  • Add client-side cache invalidation/collection cleanup and user-facing toasts for delete success/failure.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
web/apps/dashboard/lib/trpc/routers/deploy/project/delete.ts Updates server-side delete mutation logic, rate limiting, and error handling.
web/apps/dashboard/app/(app)/[workspaceSlug]/projects/_components/list/use-delete-project.ts Adds a client hook to call the delete mutation and handle cache cleanup + toasts.
web/apps/dashboard/app/(app)/[workspaceSlug]/projects/_components/list/project-actions.tsx Wires the “Delete project” action to the new delete component.
web/apps/dashboard/app/(app)/[workspaceSlug]/projects/_components/list/delete-project.tsx Adds the new delete dialog + confirm popover UI for project deletion.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ogzhanolguncu
Copy link
Contributor

Sorry for the inconvenience but this fixed by core members. We forgot to tag that issue as "core", thats what caused this confusion. Sorry again, thank you for your efforts tho.

@vansh-commits vansh-commits deleted the fix/delete-project-function branch February 12, 2026 15:21
@vansh-commits
Copy link
Contributor Author

vansh-commits commented Feb 12, 2026

no, issues...,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make project card delete button functional

3 participants