Skip to content

Conversation

@appflowy
Copy link
Contributor

@appflowy appflowy commented Dec 20, 2025

Description


Checklist

General

  • I've included relevant documentation or comments for the changes introduced.
  • I've tested the changes in multiple environments (e.g., different browsers, operating systems).

Testing

  • I've added or updated tests to validate the changes introduced for AppFlowy Web.

Feature-Specific

  • For feature additions, I've added a preview (video, screenshot, or demo) in the "Feature Preview" section.
  • I've verified that this feature integrates seamlessly with existing functionality.

Summary by Sourcery

Restrict when views can be moved and align web behavior with desktop/Flutter logic for draggable views.

New Features:

  • Introduce a canBeMoved helper to determine whether a view is allowed to be moved based on its type and parent.
  • Add detection of linked database views under documents via isLinkedDatabaseViewUnderDocument.

Enhancements:

  • Update the header more-actions menu to disable the Move To option when a view cannot be moved according to canBeMoved.

Tests:

  • Add comprehensive unit tests for isLinkedDatabaseViewUnderDocument and canBeMoved to cover normal, workaround, and edge cases.
  • Introduce an end-to-end test scaffold for page move restrictions in Cypress.

@sourcery-ai
Copy link

sourcery-ai bot commented Dec 20, 2025

Reviewer's Guide

Implements centralized logic to prevent moving linked database views (and other restricted views) by adding isLinkedDatabaseViewUnderDocument and canBeMoved helpers, wiring them into the header actions, and covering the behavior with unit tests (and starting e2e coverage).

Sequence diagram for the new move restriction logic in MoreActionsContent

sequenceDiagram
  actor User
  participant MoreActionsContent
  participant ViewUtils

  User->>MoreActionsContent: Open more actions menu for viewId
  MoreActionsContent->>MoreActionsContent: useMemo to find view
  MoreActionsContent->>MoreActionsContent: useMemo to find parentView
  MoreActionsContent->>ViewUtils: canBeMoved(view, parentView)
  activate ViewUtils
  ViewUtils->>ViewUtils: isReferencedDatabaseView(view, parentView)
  ViewUtils-->>MoreActionsContent: false or true
  alt Referenced database view
    ViewUtils-->>MoreActionsContent: false
  else Not referenced database view
    ViewUtils->>ViewUtils: isDatabaseContainer(parentView)
    alt Parent is database container
      ViewUtils-->>MoreActionsContent: false
    else Parent is not database container
      ViewUtils->>ViewUtils: isLinkedDatabaseViewUnderDocument(view, parentView)
      ViewUtils->>ViewUtils: isDatabaseLayout(view.layout)
      ViewUtils->>ViewUtils: isDatabaseContainer(view)
      ViewUtils->>ViewUtils: isEmbeddedView(view)
      ViewUtils-->>MoreActionsContent: false or true
    end
  end
  deactivate ViewUtils

  MoreActionsContent->>MoreActionsContent: disabled = !canBeMoved(view, parentView)
  alt disabled is true
    MoreActionsContent-->>User: MoveTo menu item shown as disabled
  else disabled is false
    MoreActionsContent-->>User: MoveTo menu item enabled
  end
Loading

File-Level Changes

Change Details Files
Introduce movement rules for views via canBeMoved and apply them to the Move action in the header menu, with comprehensive unit tests for linked database views and move restrictions.
  • Add isLinkedDatabaseViewUnderDocument helper to classify non-container database views under a Document (including a web-specific embedded-without-children workaround).
  • Add canBeMoved helper that mirrors the Desktop/Flutter canBeDragged rules, blocking referenced database views, children of database containers, and linked database views under documents from being moved.
  • Extend view-utils unit tests to cover isLinkedDatabaseViewUnderDocument and canBeMoved across normal, workaround, and edge cases, including null/empty extras.
  • Update MoreActionsContent to retrieve the full parent view instead of just its layout and to disable the Move action using canBeMoved(view, parentView) instead of a simple layout check.
  • Introduce an e2e spec file stub for page move restrictions in Cypress.
src/application/view-utils.ts
src/application/__tests__/view-utils.test.ts
src/components/app/header/MoreActionsContent.tsx
cypress/e2e/page/move-page-restrictions.cy.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `src/components/app/header/MoreActionsContent.tsx:94` </location>
<code_context>
             e.preventDefault();
           }}
-          disabled={parentLayout !== ViewLayout.Document}
+          disabled={!canBeMoved(view, parentView)}
         >
           <MoveToIcon />
</code_context>

<issue_to_address>
**issue:** Guard against `view` being null/undefined so the Move action doesn’t appear enabled while the view is still loading or missing.

Right now `canBeMoved` is called with `null`/`undefined` while `useView` is loading, so it may return `true` and enable the menu before a valid view exists. Instead, consider:

```tsx
disabled={!view || !canBeMoved(view, parentView)}
```

This keeps the menu state in sync with loading and avoids invoking move logic with an invalid `view`.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

e.preventDefault();
}}
disabled={parentLayout !== ViewLayout.Document}
disabled={!canBeMoved(view, parentView)}
Copy link

Choose a reason for hiding this comment

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

issue: Guard against view being null/undefined so the Move action doesn’t appear enabled while the view is still loading or missing.

Right now canBeMoved is called with null/undefined while useView is loading, so it may return true and enable the menu before a valid view exists. Instead, consider:

disabled={!view || !canBeMoved(view, parentView)}

This keeps the menu state in sync with loading and avoids invoking move logic with an invalid view.

@appflowy appflowy merged commit 88cfcb0 into main Dec 20, 2025
11 of 12 checks passed
@appflowy appflowy deleted the disable_move_linked_view branch December 20, 2025 07:33
josue693 pushed a commit to josue693/AppFlowy-Web that referenced this pull request Dec 21, 2025
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.

2 participants