Skip to content

[WEB-2190] fix: unauthorised delete and redirections#5342

Merged
SatishGandham merged 2 commits intopreviewfrom
fix-unauthorised-delete-and-redirections
Aug 9, 2024
Merged

[WEB-2190] fix: unauthorised delete and redirections#5342
SatishGandham merged 2 commits intopreviewfrom
fix-unauthorised-delete-and-redirections

Conversation

@anmolsinghbhatia
Copy link
Collaborator

@anmolsinghbhatia anmolsinghbhatia commented Aug 9, 2024

Changes:

This PR includes the following updates:

  • Fixed an issue with unauthorised delete actions in Project Intake, where an unwanted redirection occurred when an unauthorised user attempted to delete an intake issue. I have also applied similar fixes to the cycle delete action to prevent this behavior.

Reference:

[WEB-2190]

Media:

Before After
WEB-2190 Before (2) WEB-2190 After (2)
WEB-2190 Before (1) WEB-2190 After (1)

Summary by CodeRabbit

  • New Features

    • Enhanced navigation handling after the successful deletion of cycles and inbox issues, ensuring users only navigate upon confirmed deletions.
  • Bug Fixes

    • Improved control flow for inbox issue deletions, preventing premature navigation on failure and ensuring state updates occur post-deletion confirmation.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 9, 2024

Walkthrough

This update enhances the reliability of the application's deletion processes by ensuring that navigation only occurs after successful deletions of cycles and inbox issues. The asynchronous control flow has been refined in multiple components, allowing for smoother user experiences by preventing premature routing in case of failures, thus maintaining better state consistency.

Changes

File Change Summary
.../cycles/delete-modal.tsx Integrated navigation into the promise chain of cycle deletion for reliability.
.../inbox/content/inbox-issue-header.tsx Altered promise handling to navigate only after successful deletion of an inbox issue, improving user flow.
.../inbox/project-inbox.store.ts Updated inbox issue removal method to synchronize state updates with successful deletion, simplifying error handling.

Poem

🐰 In the meadow where we play,
Changes flutter like the day.
Deleting cycles, bids adieu,
With every hop, we start anew!
Sweet navigator, take your time,
Reliability in every rhyme! 🌼


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:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in 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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (1)
web/core/store/inbox/project-inbox.store.ts (1)

487-500: Consider enhancing error handling for deletion failures.

The current implementation lacks specific error handling for the deletion process, which could lead to state inconsistencies if a deletion fails. It is recommended to implement a catch block for the deletion operation to ensure robust error handling and maintain state consistency.

  • Review the deletion operation in project-inbox.store.ts to include error handling.
  • Implement state restoration or error logging to handle failures gracefully.
Analysis chain

Consider reviewing error handling strategy.

The changes ensure state updates occur only after successful deletion, improving reliability. However, the removal of error handling for state restoration could lead to inconsistencies if deletion fails.

Ensure that the error handling strategy is robust enough to handle deletion failures without causing state inconsistencies.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify error handling strategy for deletion failures.

# Test: Search for error handling related to `deleteInboxIssue`. Expect: Robust handling of errors.
rg --type javascript -A 5 $'catch'

Length of output: 68


Script:

#!/bin/bash
# Corrected script to verify error handling strategy for deletion failures.

# Search for error handling using `catch` blocks in the specified TypeScript file.
rg --type js -A 5 'catch' web/core/store/inbox/project-inbox.store.ts

Length of output: 923

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f54e1b9 and a170a9f.

Files selected for processing (3)
  • web/core/components/cycles/delete-modal.tsx (2 hunks)
  • web/core/components/inbox/content/inbox-issue-header.tsx (1 hunks)
  • web/core/store/inbox/project-inbox.store.ts (1 hunks)
Additional comments not posted (2)
web/core/components/cycles/delete-modal.tsx (1)

45-45: LGTM! But verify the function usage in the codebase.

The changes ensure navigation only occurs after successful deletion, which is a good improvement.

Ensure that all function calls to deleteCycle handle the promise correctly.

Verification successful

Function Usage Verified: deleteCycle Handles Promise Correctly

The deleteCycle function is used in the CycleDeleteModal component, and the promise is appropriately handled with .then(). Navigation occurs only after successful deletion, confirming the implementation aligns with the review comment's requirements.

  • Verified in CycleDeleteModal component.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `deleteCycle` handle the promise correctly.

# Test: Search for the function usage. Expect: Proper handling of the promise.
rg --type javascript -A 5 $'deleteCycle'

Length of output: 74


Script:

#!/bin/bash
# Description: Verify all function calls to `deleteCycle` handle the promise correctly.

# Test: Search for the function usage. Expect: Proper handling of the promise.
rg --type js -A 5 $'deleteCycle'

Length of output: 31


Script:

#!/bin/bash
# Description: Search for the definition of the `deleteCycle` function to verify its existence and usage.

# Test: Search for the function definition.
rg --type js 'function deleteCycle' -A 3

Length of output: 42


Script:

#!/bin/bash
# Description: Search for `deleteCycle` as an import or alternative naming conventions in the codebase.

# Test: Search for imports or alternative naming patterns related to `deleteCycle`.
rg --type js 'import .*deleteCycle' -A 3

Length of output: 42


Script:

#!/bin/bash
# Description: Search for any function or method related to cycle deletion within the `delete-modal.tsx` file.

# Test: Search for functions or methods in the `delete-modal.tsx` file.
fd delete-modal.tsx --exec rg 'function|const|let|var' -A 3

Length of output: 3770

web/core/components/inbox/content/inbox-issue-header.tsx (1)

143-143: LGTM! But verify the function usage in the codebase.

The changes ensure navigation only occurs after successful deletion, which improves user experience.

Ensure that all function calls to deleteInboxIssue handle the promise correctly.

Verification successful

Function Calls to deleteInboxIssue Handle Promises Correctly

The function deleteInboxIssue is used in the codebase with proper promise handling using .then(). This ensures that actions are taken after the promise resolves, confirming correct implementation.

  • File: web/core/components/inbox/content/inbox-issue-header.tsx
  • File: web/core/store/inbox/project-inbox.store.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `deleteInboxIssue` handle the promise correctly.

# Test: Search for the function usage. Expect: Proper handling of the promise.
rg --type javascript -A 5 $'deleteInboxIssue'

Length of output: 79


Script:

#!/bin/bash
# Description: Verify all function calls to `deleteInboxIssue` handle the promise correctly.

# Search for the function usage and capture enough context to check promise handling.
rg 'deleteInboxIssue' -A 10

Length of output: 4783

@anmolsinghbhatia anmolsinghbhatia marked this pull request as draft August 9, 2024 11:16
@anmolsinghbhatia anmolsinghbhatia marked this pull request as ready for review August 9, 2024 12:59
@SatishGandham SatishGandham merged commit 6d0cf1b into preview Aug 9, 2024
@SatishGandham SatishGandham deleted the fix-unauthorised-delete-and-redirections branch August 9, 2024 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants