[WEB-2043] fix: delete action validation and toast alert#5254
[WEB-2043] fix: delete action validation and toast alert#5254SatishGandham merged 6 commits intopreviewfrom
Conversation
WalkthroughRecent changes enhance user feedback and error handling across project and issue management components. A new permission check for project admin actions improves bulk delete functionalities. Error handling has been refined in delete modals to provide specific feedback based on user permissions. These updates significantly enhance the user experience and security by clarifying actions and outcomes related to project management. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CommandPalette
participant DeleteModal
participant UserStore
User->>CommandPalette: Press Delete Key
CommandPalette->>UserStore: Check canPerformProjectAdminActions
alt User has permissions
CommandPalette->>DeleteModal: Open Delete Confirmation
else User lacks permissions
CommandPalette->>User: Show Permission Denied Toast
end
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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 as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (7)
- web/core/components/command-palette/command-palette.tsx (5 hunks)
- web/core/components/cycles/delete-modal.tsx (1 hunks)
- web/core/components/inbox/modals/delete-issue-modal.tsx (2 hunks)
- web/core/components/issues/delete-issue-modal.tsx (1 hunks)
- web/core/components/modules/delete-module-modal.tsx (1 hunks)
- web/core/store/inbox/project-inbox.store.ts (1 hunks)
- web/core/store/user/index.ts (3 hunks)
Additional comments not posted (13)
web/core/components/inbox/modals/delete-issue-modal.tsx (2)
32-39: Enhance user feedback with detailed success message.The promise chain correctly handles successful deletion with a success toast notification.
40-49: Improve error handling with specific messages.The error handling logic correctly distinguishes between permission errors and general errors, providing specific feedback to the user.
web/core/components/issues/delete-issue-modal.tsx (1)
55-65: Improve error handling with specific messages.The error handling logic correctly distinguishes between permission errors and general errors, providing specific feedback to the user.
web/core/components/modules/delete-module-modal.tsx (1)
57-71: Improve error handling with specific messages.The error handling logic correctly distinguishes between permission errors and general errors, providing specific feedback to the user.
web/core/components/cycles/delete-modal.tsx (2)
54-67: Enhanced error handling logic.The changes provide specific feedback for permission errors and general errors, improving user experience.
68-68: Consistent modal behavior.The
finallyblock ensures the modal closes in all scenarios, enhancing control flow consistency.web/core/store/user/index.ts (2)
46-46: Added project admin permissions property to interface.The addition of
canPerformProjectAdminActionsenhances the interface by providing a clear mechanism to check for project admin permissions.
283-289: Added project admin permissions getter method.The
canPerformProjectAdminActionsgetter method checks if the current project role isEUserProjectRoles.ADMIN, enhancing role-based access control.web/core/components/command-palette/command-palette.tsx (4)
49-49: Added project admin permissions variable.The
canPerformProjectAdminActionsvariable is used to determine if the user has the necessary rights to perform bulk delete actions on projects.
117-129: Added project bulk delete actions function.The
performProjectBulkDeleteActionsfunction checks the user's permissions and sets a toast notification if the user lacks the required permissions, enhancing functionality.
Line range hint
227-251:
Enhanced keydown handler for bulk delete actions.The
handleKeyDownfunction now includes a check for the delete key and invokes theperformProjectBulkDeleteActionsfunction, enhancing control flow and user interaction.
288-288: Updated useCallback hook dependencies.The
performProjectBulkDeleteActionsfunction has been added to the dependencies of theuseCallbackhook, ensuring proper reference in the component's lifecycle.web/core/store/inbox/project-inbox.store.ts (1)
458-463: Improved error handling indeleteInboxIssuemethod.The changes improve error visibility by logging the actual error message and re-throwing the error to ensure upstream error handling.
There was a problem hiding this comment.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (5)
- web/core/components/cycles/delete-modal.tsx (2 hunks)
- web/core/components/inbox/modals/delete-issue-modal.tsx (2 hunks)
- web/core/components/issues/delete-issue-modal.tsx (2 hunks)
- web/core/components/modules/delete-module-modal.tsx (2 hunks)
- web/core/constants/project.ts (1 hunks)
Files skipped from review as they are similar to previous changes (4)
- web/core/components/cycles/delete-modal.tsx
- web/core/components/inbox/modals/delete-issue-modal.tsx
- web/core/components/issues/delete-issue-modal.tsx
- web/core/components/modules/delete-module-modal.tsx
Additional comments not posted (1)
web/core/constants/project.ts (1)
172-189: LGTM! But verify the usage of the new constant in the codebase.The code changes are approved.
However, ensure that the new
PROJECT_ERROR_MESSAGESconstant is correctly used throughout the codebase.Verification successful
The new
PROJECT_ERROR_MESSAGESconstant is correctly used throughout the codebase.The constant is imported and utilized in various components, ensuring consistent error messaging for project-related actions.
- Files:
web/core/components/issues/delete-issue-modal.tsxweb/core/components/modules/delete-module-modal.tsxweb/core/components/inbox/modals/delete-issue-modal.tsxweb/core/components/cycles/delete-modal.tsxScripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of the new `PROJECT_ERROR_MESSAGES` constant in the codebase. # Test: Search for the constant usage. Expect: Occurrences of `PROJECT_ERROR_MESSAGES`. rg --type js --type ts -A 5 $'PROJECT_ERROR_MESSAGES'Length of output: 4805
| * @description tells if user has project admin actions permissions | ||
| * @returns {boolean} | ||
| */ | ||
| get canPerformProjectAdminActions() { |
There was a problem hiding this comment.
It should be isProjectAdmin.
| }) | ||
| .catch(() => { | ||
| .catch((errors) => { | ||
| const isPermissionError = errors?.error === "Only admin or creator can delete the module"; |
There was a problem hiding this comment.
Can you write this better, instead of checking on the same condition twice.
Changes:
This PR includes following changes:
Reference:
[WEB-2043]
Summary by CodeRabbit
New Features
Bug Fixes
Documentation