Grida: enhance delete project / rename project ux#513
Conversation
- Implemented a new RPC function `delete_project` to handle project deletions with a fixed statement timeout. - Updated the sidebar component to utilize the new RPC for project deletion, improving error handling. - Added foreign key supporting indexes to optimize project deletion performance. - Created tests to validate the functionality and security of the `delete_project` RPC, ensuring proper access control and behavior for different user roles.
- Updated the `delete_project` RPC to require a confirmation string for project deletions, improving security by ensuring the correct project is being deleted. - Modified the sidebar component to pass the confirmation text when invoking the delete function. - Adjusted related SQL migration to accommodate the new confirmation parameter and updated tests to validate the new functionality and access control for different user roles.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughAdded a typed RPC declaration and server-side RPC to delete projects with confirmation; updated client UI to call the RPC (including confirmation text) instead of direct table deletion; added DB indexes to support cascades; extended client-side rename validation; added/updated RLS tests and AGENTS documentation. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant UI
participant SupabaseClient as Client
participant RPC as delete_project RPC
participant DB
User->>UI: Click "Delete" and enter confirmation text
UI->>Client: client.rpc("delete_project", { p_project_id, p_confirm })
Client->>RPC: Invoke RPC (authenticated)
RPC->>DB: DELETE FROM public.project WHERE id = p_project_id AND p_confirm = 'DELETE ' || name
DB-->>RPC: Boolean result (true/false)
RPC-->>Client: Return boolean
Client-->>UI: Resolve promise (success/failure)
UI-->>User: Show result (deleted / error)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@supabase/tests/test_project_delete_rpc_rls_test.sql`:
- Around line 187-200: The test comment numbers are off; update the inline test
labels in the SQL block so they read sequentially: change the comment label "10)
Alice (acme member) can delete acme project via RPC" to "11) Alice (acme member)
can delete acme project via RPC" and change "11) Acme project is deleted
(service_role sees it)" to "12) Acme project is deleted (service_role sees it)";
locate the labels around the public.delete_project call and the surrounding
test_set_auth / test_reset_auth lines and adjust the numeric prefixes only.
| -- 10) Alice (acme member) can delete acme project via RPC | ||
| SELECT test_set_auth('alice@acme.com'); | ||
| SELECT is( | ||
| public.delete_project( | ||
| current_setting('test.project_id_acme')::bigint, | ||
| 'DELETE ' || | ||
| (select name from public.project where id = current_setting('test.project_id_acme')::bigint) | ||
| ), | ||
| true, | ||
| 'Alice can delete acme project' | ||
| ); | ||
| SELECT test_reset_auth(); | ||
|
|
||
| -- 11) Acme project is deleted (service_role sees it) |
There was a problem hiding this comment.
Fix test comment numbering.
The comment numbering is incorrect:
- Line 187: Says "Test 10" but should be "Test 11" (Alice can delete acme project)
- Line 200: Says "Test 11" but should be "Test 12" (Acme project is deleted)
This creates confusion since Line 178 is already labeled as "Test 10".
📝 Proposed fix for comment numbering
-- 10) Alice (acme member) cannot delete acme project with wrong confirmation
SELECT test_set_auth('alice@acme.com');
SELECT is(
public.delete_project(current_setting('test.project_id_acme')::bigint, 'DELETE wrong'),
false,
'Alice cannot delete acme project with wrong confirmation'
);
SELECT test_reset_auth();
--- 10) Alice (acme member) can delete acme project via RPC
+-- 11) Alice (acme member) can delete acme project via RPC
SELECT test_set_auth('alice@acme.com');
SELECT is(
public.delete_project(
current_setting('test.project_id_acme')::bigint,
'DELETE ' ||
(select name from public.project where id = current_setting('test.project_id_acme')::bigint)
),
true,
'Alice can delete acme project'
);
SELECT test_reset_auth();
--- 11) Acme project is deleted (service_role sees it)
+-- 12) Acme project is deleted (service_role sees it)
SET ROLE service_role;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| -- 10) Alice (acme member) can delete acme project via RPC | |
| SELECT test_set_auth('alice@acme.com'); | |
| SELECT is( | |
| public.delete_project( | |
| current_setting('test.project_id_acme')::bigint, | |
| 'DELETE ' || | |
| (select name from public.project where id = current_setting('test.project_id_acme')::bigint) | |
| ), | |
| true, | |
| 'Alice can delete acme project' | |
| ); | |
| SELECT test_reset_auth(); | |
| -- 11) Acme project is deleted (service_role sees it) | |
| -- 11) Alice (acme member) can delete acme project via RPC | |
| SELECT test_set_auth('alice@acme.com'); | |
| SELECT is( | |
| public.delete_project( | |
| current_setting('test.project_id_acme')::bigint, | |
| 'DELETE ' || | |
| (select name from public.project where id = current_setting('test.project_id_acme')::bigint) | |
| ), | |
| true, | |
| 'Alice can delete acme project' | |
| ); | |
| SELECT test_reset_auth(); | |
| -- 12) Acme project is deleted (service_role sees it) |
🤖 Prompt for AI Agents
In `@supabase/tests/test_project_delete_rpc_rls_test.sql` around lines 187 - 200,
The test comment numbers are off; update the inline test labels in the SQL block
so they read sequentially: change the comment label "10) Alice (acme member) can
delete acme project via RPC" to "11) Alice (acme member) can delete acme project
via RPC" and change "11) Acme project is deleted (service_role sees it)" to "12)
Acme project is deleted (service_role sees it)"; locate the labels around the
public.delete_project call and the surrounding test_set_auth / test_reset_auth
lines and adjust the numeric prefixes only.
- Added optional `nameHint` and `validateName` props to the `RenameDialog` component for improved user guidance and validation. - Implemented validation logic to display user-facing error messages based on the provided validation function. - Updated the submit handler to incorporate validation checks before renaming, ensuring better user experience. - Enhanced error handling to provide more specific feedback during the renaming process.
Summary
New Features
Performance
Tests
Documentation