feat: ability to delete a project #37
Reference in New Issue
Block a user
No description provided.
Delete Branch "feat/project-delete"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Style
Selffor type references in error handling implementations.Chores
Walkthrough
The changes introduce a new feature for deleting projects within the
ProjectFormcomponent, enhancing its existing capabilities for creating and editing projects. An asynchronousdelete_projectfunction has been implemented in the server module, and error handling has been updated across various error modules. Additionally, the layout of theProjectFormhas been adjusted for improved button alignment, and handling of optional project references has been refined.Changes
src/components/project_form.rssrc/errors/error.rsFromtrait implementation for convertingdiesel::result::Errorto a customErrortype. ModifiedDisplayandFromStrimplementations to useSelffor improved readability.src/errors/project_error.rsFromandFromStrimplementations to useSelfinstead of explicit type references, enhancing code clarity.src/errors/task_error.rsFromandFromStrimplementations to useSelffor type references, improving readability and consistency.src/server/projects.rsdelete_projectto handle project deletion byproject_id, including error handling for database operations.migrations/2024-08-19-105140_create_tasks/up.sqlproject_idin thetaskstable to includeON DELETE SET NULL, preventing loss of task records when a project is deleted.Possibly related PRs
BottomPanelcomponent's enhancements for task editing, sharing a context of form modifications.TaskListcomponent for task completion are relevant due to their involvement with asynchronous operations, similar to the new delete functionality in theProjectForm.Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Share
Tips
Chat
There are 3 ways to chat with CodeRabbit:
I pushed a fix in commit <commit_id>.Generate unit testing code for this file.Open a follow-up GitHub issue for this discussion.@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai generate unit testing code for this file.@coderabbitai modularize this function.@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai generate interesting stats about this repository and render them as a table.@coderabbitai show all the console.log statements in this repository.@coderabbitai read src/utils.ts and generate unit testing code.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.Other keywords and placeholders
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed.@coderabbitai summaryto generate the high-level summary at a specific location in the PR description.@coderabbitaianywhere in the PR title to generate the title automatically.CodeRabbit Configuration File (
.coderabbit.yaml).coderabbit.yamlfile to the root of your repository.# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.jsonDocumentation and Community
Actionable comments posted: 3
Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Commits
Files that changed from the base of the PR and between
0299092fa7andd63fb0f28d.Files selected for processing (5)
Additional comments not posted (7)
Approve the integration of delete functionality with a suggestion for improvement.
The integration of the
delete_projectfunction in theProjectFormcomponent is well-implemented. The use of asynchronous handling and query invalidation after deletion ensures that the UI remains consistent with the backend state.However, consider adding error handling for the delete operation to provide feedback to the user in case of failure.
Add error handling for the delete operation:
@@ -10,0 +10,4 @@impl From<diesel::result::Error> for Error {fn from(_: diesel::result::Error) -> Self {Self::ServerInternal}Refine error mapping in
Fromimplementation.The current implementation maps all
diesel::result::Errortypes toError::ServerInternal. Consider refining this to differentiate between different types of database errors, such as constraint violations or connection issues, to provide more specific error messages to the client.@@ -74,0 +84,4 @@.map_err::<ErrorVec<Error>, _>(|error| vec![error.into()].into())?;Ok(())}Approve the implementation of
delete_projectwith a suggestion for enhancement.The implementation of
delete_projectis correct and aligns well with the existing codebase. The error handling is consistent and uses the application's custom error types effectively.However, consider enhancing the database operation by wrapping it in a transaction. This ensures that any related operations that need to be atomic with the deletion are handled correctly.
Consider adding transaction handling to ensure atomicity:
@@ -74,0 +84,4 @@.map_err::<ErrorVec<Error>, _>(|error| vec![error.into()].into())?;Ok(())}What's the point of a transaction when only one query is being executed?
@@ -74,0 +84,4 @@.map_err::<ErrorVec<Error>, _>(|error| vec![error.into()].into())?;Ok(())}@matous-volf, you're right that a transaction is typically more useful when multiple queries are involved. In this case, since only one query is being executed, a transaction might seem unnecessary.
However, there are a few reasons why it could still be beneficial:
That said, if you're confident that this single query is sufficient and no future operations will be added, the transaction may not be necessary in this specific case.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Commits
Files that changed from the base of the PR and between
d63fb0f28dandca1f862499.Files selected for processing (1)
Additional comments not posted (1)