Skip to content

Conversation

@jpan-box
Copy link
Collaborator

@jpan-box jpan-box commented Aug 18, 2025

Summary by CodeRabbit

  • New Features

    • Added item-prefixed metadata fields (e.g., item name, type, description, timestamps, quick search content).
    • Added new permission flags (delete, download, edit, preview, rename, resolve, set share access, share, upload, view annotations).
  • Bug Fixes

    • Improved sorting behavior in metadata view v2 so sorting by Name uses the correct item field.
  • Tests

    • Added a visual story/test to exercise header-triggered sorting in the metadata v2 view.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 18, 2025

Walkthrough

Adds item-prefixed metadata field constants and several new permission constants in src/constants.js. Updates ContentExplorer to map FIELD_NAME -> FIELD_ITEM_NAME when metadataViewV2 is enabled for query ordering. Storybook tests rename sorting props, switch sort_byorder_by, and add a V2 header-click sorting interaction story.

Changes

Cohort / File(s) Summary
Item-prefixed fields & permissions
src/constants.js
Introduces ITEM_PREFIX and exports FIELD_ITEM_* constants (type, name, description, extension, owned_by, created_at, modified_at, content_created_at, content_modified_at, quick_search_content). Adds PERMISSION_CAN_* constants (can_delete, can_download, can_edit, can_preview, can_rename, can_resolve, can_set_share_access, can_share, can_upload, can_view_annotations).
Content Explorer ordering logic
src/elements/content-explorer/ContentExplorer.tsx
Imports FIELD_ITEM_NAME. In showMetadataQueryResults, sets order_by[0].field_key to FIELD_ITEM_NAME when metadataViewV2 is enabled and sortBy === FIELD_NAME; otherwise uses sortBy.
Storybook metadata view updates
src/elements/content-explorer/stories/tests/MetadataView-visual.stories.tsx
Renames metadataQuery.sort_byorder_by. Renames column prop allowSortingallowsSorting. Adds metadataViewV2SortsFromHeader story that clicks a header to trigger sorting (with TODO to assert order).

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant ContentExplorer
  participant MDQuery
  User->>ContentExplorer: Open Metadata View (request data)
  ContentExplorer->>ContentExplorer: Compute sortBy, check metadataViewV2 flag
  alt metadataViewV2 && sortBy == FIELD_NAME
    ContentExplorer->>MDQuery: order_by[0].field_key = FIELD_ITEM_NAME, direction = sortDirection
  else
    ContentExplorer->>MDQuery: order_by[0].field_key = sortBy, direction = sortDirection
  end
  MDQuery-->>ContentExplorer: Return ordered results
  ContentExplorer-->>User: Render results
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

ready-to-merge

Suggested reviewers

  • greg-in-a-box
  • tjuanitas
  • tjiang-box

Poem

I hop through constants, nibble a dot or two,
item.name and item.time now join the view.
A header-click sorts, I tumble with glee,
Permissions sprout leaves on my metadata tree.
Thump-thump — code polished, carrot in hand, hooray for V2! 🥕🐇

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

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

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 75761c1 and 6e9c86a.

📒 Files selected for processing (3)
  • src/constants.js (1 hunks)
  • src/elements/content-explorer/ContentExplorer.tsx (2 hunks)
  • src/elements/content-explorer/stories/tests/MetadataView-visual.stories.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/elements/content-explorer/ContentExplorer.tsx
  • src/constants.js
  • src/elements/content-explorer/stories/tests/MetadataView-visual.stories.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: lint_test_build
  • GitHub Check: Summary
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@jpan-box jpan-box marked this pull request as ready for review August 18, 2025 22:43
@jpan-box jpan-box requested a review from a team as a code owner August 18, 2025 22:43
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 (2)
src/elements/content-explorer/ContentExplorer.tsx (1)

455-461: Gate name mapping behind MDV2 flag & preserve caller-provided order_by (optional refactor)

We always overwrite metadataQueryClone.order_by and unconditionally map FIELD_NAMEFIELD_ITEM_NAME, despite the inline note “for metadata view v2 only.” Also, no normalization of order_by.direction was found in our helpers—verify that sortDirection constants ('asc'/'desc') match the API’s expected casing, and add a .toLowerCase() here if they don’t.

• File: src/elements/content-explorer/ContentExplorer.tsx (≈lines 455–461)
• Introduce feature flag check and fallback to existing order_by:

-        metadataQueryClone.order_by = [
-            {
-                // Default to the prefixed name field for metadata view v2 only, while not touching the default sortBy for other views.
-                field_key: sortBy === FIELD_NAME ? FIELD_ITEM_NAME : sortBy,
-                direction: sortDirection,
-            },
-        ];
+        const isV2 = isFeatureEnabled(features, 'contentExplorer.metadataViewV2');
+        metadataQueryClone.order_by = metadataQueryClone.order_by ?? [
+            {
+                // Default to the prefixed name field for metadata view v2 only, while not touching the default sortBy for other views.
+                field_key: sortBy === FIELD_NAME && isV2 ? FIELD_ITEM_NAME : sortBy,
+                direction: sortDirection, // ensure this matches API casing
+            },
+        ];
src/elements/content-explorer/stories/tests/MetadataView-visual.stories.tsx (1)

97-109: Await the click to avoid flakiness in the play function.

userEvent.click is async in modern @testing-library/user-event. Awaiting it improves reliability.

-        userEvent.click(industryHeader);
+        await userEvent.click(industryHeader);

Optional: you can simplify the wait by using findByRole instead of waitFor + getByRole:

  • Replace the waitFor block with:
    const firstRow = await canvas.findByRole('row', { name: /Industry/i });

Do you want me to update the story to use findByRole and add a follow-up assertion once handleSortChange is implemented?

📜 Review details

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

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 4f89946 and 75761c1.

📒 Files selected for processing (3)
  • src/constants.js (1 hunks)
  • src/elements/content-explorer/ContentExplorer.tsx (2 hunks)
  • src/elements/content-explorer/stories/tests/MetadataView-visual.stories.tsx (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/elements/content-explorer/ContentExplorer.tsx (1)
src/constants.js (2)
  • FIELD_ITEM_NAME (174-174)
  • FIELD_ITEM_NAME (174-174)
src/elements/content-explorer/stories/tests/MetadataView-visual.stories.tsx (1)
src/elements/common/__mocks__/mockMetadata.ts (1)
  • mockSchema (226-226)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: lint_test_build
  • GitHub Check: Summary
🔇 Additional comments (5)
src/elements/content-explorer/ContentExplorer.tsx (1)

51-51: Import of FIELD_ITEM_NAME is appropriate for MDV2 sort mapping.

This aligns with the new item-prefixed field constants and is used correctly below.

src/elements/content-explorer/stories/tests/MetadataView-visual.stories.tsx (2)

24-35: Switch to order_by looks correct and aligns with MD Query API.

Using order_by with field_key/direction is the correct structure for the metadata query. Note ContentExplorer currently overrides order_by by default; if you intend the story-provided order_by to take effect initially, see the optional change suggested in ContentExplorer.


52-64: allowSorting fully replaced with allowsSorting
No occurrences of the old allowSorting property were found in .ts or .tsx files—everything has been updated to allowsSorting. All checks pass; no further action needed.

src/constants.js (2)

171-183: Item-prefixed field constants are well-scoped and useful for MD Query v2.

Non-exported ITEM_PREFIX keeps the surface clean. Names follow existing conventions.


185-197: Approve addition of new permission constants

Each of the newly introduced PERMISSION_CAN_* constants is defined exactly once in src/constants.js and no duplicate exports were found.

@mergify mergify bot merged commit 1a86aa5 into box:master Aug 20, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants