Skip to content

[ PE-294 ] fix : route back on page delete#6729

Merged
sriramveeraghanta merged 1 commit intopreviewfrom
fix-redirect_on_delete
Mar 10, 2025
Merged

[ PE-294 ] fix : route back on page delete#6729
sriramveeraghanta merged 1 commit intopreviewfrom
fix-redirect_on_delete

Conversation

@iam-vipin
Copy link
Member

@iam-vipin iam-vipin commented Mar 10, 2025

Description

Deleting a page from within doesn’t redirect the user, leading to a fetch error. This fix ensures proper redirection.

Type of Change

  • Check pageId and redirect user to previous page if needed.

Screenshots and Media (if applicable)

Before

Screen.Recording.2025-03-10.at.4.47.18.PM.mov

After

Screen.Recording.2025-03-10.at.4.46.54.PM.mov

Summary by CodeRabbit

  • New Features
    • Enhanced the page deletion process by automatically navigating back to the previous view after a successful deletion, ensuring a smoother user experience.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 10, 2025

Walkthrough

This pull request updates the DeletePageModal component. The changes introduce two new imports (useParams from next/navigation and useAppRouter from a local hook) to extract a routePageId from the URL. In the handleDelete function, after a successful deletion, the existence of routePageId is checked, and if present, the method router.back() is called to navigate to the previous page. There are no modifications to exported or public entities.

Changes

File(s) Change Summary
web/core/.../delete-page-modal.tsx Added navigation back functionality after page deletion by importing useParams and useAppRouter, and invoking router.back() when a page ID is detected.

Sequence Diagram(s)

sequenceDiagram
    participant Modal as DeletePageModal
    participant Router as AppRouter
    participant API as Server/API

    Modal->>API: Request page deletion
    API-->>Modal: Confirm deletion
    Modal->>Modal: Extract routePageId using useParams
    alt routePageId exists
        Modal->>Router: Execute router.back()
    else
        Modal->>Modal: Skip navigation step
    end
Loading

Possibly related PRs

Suggested labels

🐛bug, 🌐frontend, pages

Suggested reviewers

  • anmolsinghbhatia
  • sriramveeraghanta

Poem

I'm a hopping rabbit with a code delight,
Deleting pages with logic clear and bright.
I check for IDs and then I dash,
Back to the past in a neat flash.
Cheers and carrots for a smooth code flight!
🥕🐇

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 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 generate docstrings to generate docstrings for this 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

@iam-vipin iam-vipin marked this pull request as ready for review March 10, 2025 11:23
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

🧹 Nitpick comments (1)
web/core/components/pages/modals/delete-page-modal.tsx (1)

62-64: Good implementation of navigation after page deletion.

The addition of the conditional navigation logic after successful page deletion addresses the issue where users were experiencing fetch errors after deleting a page. Using router.back() is an appropriate solution as it returns users to their previous location.

Consider adding a fallback navigation path for cases where router.back() might not work as expected (e.g., if users directly navigated to the page via a bookmark or direct URL). For example:

if (routePageId) {
  router.back();
+} else {
+  // Fallback to a safe location like the pages list
+  router.push("/workspace-path/pages");
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d1e462b and f9dddce.

📒 Files selected for processing (1)
  • web/core/components/pages/modals/delete-page-modal.tsx (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)
🔇 Additional comments (1)
web/core/components/pages/modals/delete-page-modal.tsx (1)

6-6: Added navigation imports and hooks look good.

The new imports and hooks provide the necessary functionality to access the router and URL parameters, which are essential for implementing the navigation after page deletion.

Also applies to: 13-13, 41-42

@sriramveeraghanta sriramveeraghanta merged commit 6157900 into preview Mar 10, 2025
5 of 6 checks passed
@sriramveeraghanta sriramveeraghanta deleted the fix-redirect_on_delete branch March 10, 2025 11:49
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.

3 participants