Skip to content

Conversation

@ahorowitz123
Copy link
Contributor

@ahorowitz123 ahorowitz123 commented Dec 3, 2025

  • Added modernized classes to prepare to add styles in EUA. We currently have overridden styles in EUA so as not to affect users who use BUIE without EUA.
  • Added modernized version of more options button using Blueprint IconButton component

Finished product in combination with EUA:

Screenshot 2025-12-03 at 4 43 03 PM

Summary by CodeRabbit

  • New Features

    • Introduced preview modernization capabilities for the versions interface with enhanced styling and improved layout.
  • Improvements

    • Updated version badge appearance and actions menu positioning for refined visual presentation.
  • Tests

    • Expanded test coverage with improved testing methodology for UI components and feature flag functionality.

✏️ Tip: You can customize this high-level summary in your review settings.

@ahorowitz123 ahorowitz123 requested review from a team as code owners December 3, 2025 21:46
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 3, 2025

Walkthrough

The pull request implements a preview modernization feature flag for the versions sidebar components. VersionsItem, VersionsItemBadge, VersionsItemActions, and VersionsList are updated to conditionally render modernized UI elements when the feature is enabled. Tests are migrated from enzyme to React Testing Library.

Changes

Cohort / File(s) Summary
Component Logic Updates
src/elements/content-sidebar/versions/VersionsItem.js, src/elements/content-sidebar/versions/VersionsItemBadge.js, src/elements/content-sidebar/versions/VersionsItemActions.js, src/elements/content-sidebar/versions/VersionsList.js
VersionsItem now passes isCurrent prop to VersionsItemBadge. VersionsItemBadge adds optional isCurrent prop and conditional bcs-VersionsItemBadge--current class. VersionsItemActions uses feature flag to conditionally render IconButton (modernized) vs PlainButton (legacy) toggle. VersionsList applies conditional bcs-VersionsList--modernized class when feature is enabled.
Styling Updates
src/elements/content-sidebar/versions/VersionsItem.scss
Adds .bcs-VersionsItemActions-toggle--modernized rule with absolute positioning for modernized toggle control.
Test Migrations
src/elements/content-sidebar/versions/__tests__/VersionsItemActions.test.js, src/elements/content-sidebar/versions/__tests__/VersionsItemBadge.test.js
Migrated from enzyme shallow rendering to React Testing Library. VersionsItemActions tests added for feature flag behavior, toggle button rendering, and menu item assertions. VersionsItemBadge tests added for text/aria-label verification and parameterized isCurrent class application tests. Removed snapshot assertions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • VersionsItemBadge.js and VersionsItemActions.js: Verify prop type changes, feature flag logic, and conditional rendering branches are correct
  • Test files: Confirm RTL migration is complete and new feature flag test coverage adequately validates both modernized and legacy code paths
  • VersionsList.js and VersionsItem.scss: Verify CSS class application and class name patterns are consistent with modernization theme

Possibly related PRs

  • box/box-ui-elements#4373 — Implements the same previewModernization feature flag pattern across content-sidebar components with similar modernized CSS classes and UI branches.

Suggested labels

ready-to-merge

Suggested reviewers

  • tjuanitas
  • jpan-box

Poem

A rabbit hops through versions past,
With modern UI shining fast! ✨
Feature flags now light the way—
Legacy and new both stay at play. 🐰
Tests hopping over, RTL strong,
This modernization can't go wrong! 🎉

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: modernizing the Versions sidebar component with preview optimizations, which aligns with the primary objectives of adding modernized classes and updating UI components.
Description check ✅ Passed The description adequately explains the purpose and changes (modernized classes, Blueprint IconButton, EUA styling), includes visual context via screenshot, but lacks structured sections matching typical PR templates (What, Why, How, Testing).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • 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

Comment @coderabbitai help to get the list of available commands and usage tips.

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: 1

🧹 Nitpick comments (1)
src/elements/content-sidebar/versions/VersionsItemBadge.js (1)

8-8: isCurrent styling hook is implemented cleanly

Using classNames to gate bcs-VersionsItemBadge--current on the optional isCurrent prop is straightforward and keeps the badge’s aria‑label behavior unchanged. If there’s no use case for omitting versionNumber, you might keep it required in Props to avoid silently rendering an undefined value, but that’s optional.

Also applies to: 14-16, 18-27

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 60eda40 and b84568d.

⛔ Files ignored due to path filters (2)
  • src/elements/content-sidebar/versions/__tests__/__snapshots__/VersionsItemActions.test.js.snap is excluded by !**/*.snap
  • src/elements/content-sidebar/versions/__tests__/__snapshots__/VersionsItemBadge.test.js.snap is excluded by !**/*.snap
📒 Files selected for processing (7)
  • src/elements/content-sidebar/versions/VersionsItem.js (1 hunks)
  • src/elements/content-sidebar/versions/VersionsItem.scss (1 hunks)
  • src/elements/content-sidebar/versions/VersionsItemActions.js (3 hunks)
  • src/elements/content-sidebar/versions/VersionsItemBadge.js (1 hunks)
  • src/elements/content-sidebar/versions/VersionsList.js (3 hunks)
  • src/elements/content-sidebar/versions/__tests__/VersionsItemActions.test.js (1 hunks)
  • src/elements/content-sidebar/versions/__tests__/VersionsItemBadge.test.js (1 hunks)
🧰 Additional context used
🧠 Learnings (8)
📓 Common learnings
Learnt from: rafalmaksymiuk
Repo: box/box-ui-elements PR: 4136
File: src/elements/common/types/SidebarNavigation.ts:16-26
Timestamp: 2025-06-11T16:30:10.431Z
Learning: `VersionSidebarView` intentionally uses the `versionId` field to stay consistent with current URL parameter naming; a potential rename to `fileVersionId` is deferred until React Router is removed.
📚 Learning: 2025-06-11T16:30:10.431Z
Learnt from: rafalmaksymiuk
Repo: box/box-ui-elements PR: 4136
File: src/elements/common/types/SidebarNavigation.ts:16-26
Timestamp: 2025-06-11T16:30:10.431Z
Learning: `VersionSidebarView` intentionally uses the `versionId` field to stay consistent with current URL parameter naming; a potential rename to `fileVersionId` is deferred until React Router is removed.

Applied to files:

  • src/elements/content-sidebar/versions/VersionsItem.js
  • src/elements/content-sidebar/versions/__tests__/VersionsItemBadge.test.js
  • src/elements/content-sidebar/versions/VersionsItemActions.js
  • src/elements/content-sidebar/versions/VersionsItemBadge.js
  • src/elements/content-sidebar/versions/VersionsList.js
📚 Learning: 2025-08-27T17:03:48.322Z
Learnt from: bxie-box
Repo: box/box-ui-elements PR: 4250
File: src/features/classification/applied-by-ai-classification-reason/__tests__/AppliedByAiClassificationReason.test.tsx:44-51
Timestamp: 2025-08-27T17:03:48.322Z
Learning: In test files for bxie-box, prefer using queryByTestId over getByTestId when testing for expected elements that should always exist, as null access serves as validation for regressions or unexpected changes rather than masking issues with defensive assertions.

Applied to files:

  • src/elements/content-sidebar/versions/__tests__/VersionsItemBadge.test.js
  • src/elements/content-sidebar/versions/__tests__/VersionsItemActions.test.js
📚 Learning: 2025-09-15T17:04:28.279Z
Learnt from: bfoxx1906
Repo: box/box-ui-elements PR: 4275
File: src/elements/content-sidebar/activity-feed/comment/__tests__/Comment.test.js:259-260
Timestamp: 2025-09-15T17:04:28.279Z
Learning: When wrapping enzyme mount() tests with IntlProvider for class-based components, use wrapper.find('ComponentName') to access the actual component instance and state, since the wrapper becomes the provider instead of the component.

Applied to files:

  • src/elements/content-sidebar/versions/__tests__/VersionsItemBadge.test.js
📚 Learning: 2025-07-11T14:43:02.677Z
Learnt from: jpan-box
Repo: box/box-ui-elements PR: 4166
File: src/elements/content-sidebar/SidebarNav.js:126-126
Timestamp: 2025-07-11T14:43:02.677Z
Learning: In the box-ui-elements repository, there's a file-type-based pattern for internationalization: TypeScript files (.tsx) predominantly use the modern useIntl hook (41 vs 15 files), while JavaScript files (.js) predominantly use the legacy injectIntl HOC (64 vs 5 files). New TypeScript components should use useIntl, while existing JavaScript components typically continue using injectIntl for consistency.

Applied to files:

  • src/elements/content-sidebar/versions/VersionsItemActions.js
📚 Learning: 2025-08-15T14:42:01.840Z
Learnt from: jpan-box
Repo: box/box-ui-elements PR: 4227
File: src/elements/common/sub-header/SubHeader.tsx:19-19
Timestamp: 2025-08-15T14:42:01.840Z
Learning: In SubHeader.tsx, the bulkItemActionMenuProps prop is intentionally required (not optional) because there will always be a default "Download" action available, ensuring the prop is never undefined in actual usage.

Applied to files:

  • src/elements/content-sidebar/versions/VersionsItemActions.js
📚 Learning: 2025-08-18T20:57:20.993Z
Learnt from: jpan-box
Repo: box/box-ui-elements PR: 4227
File: src/elements/common/sub-header/SubHeaderRight.tsx:0-0
Timestamp: 2025-08-18T20:57:20.993Z
Learning: In the SubHeaderRight component's bulk action menu (src/elements/common/sub-header/SubHeaderRight.tsx), the BulkItemActionMenu trigger should only be shown when there are actual bulk actions available (bulkItemActions exists and has length > 0), not when the actions array is empty.

Applied to files:

  • src/elements/content-sidebar/versions/VersionsItemActions.js
  • src/elements/content-sidebar/versions/__tests__/VersionsItemActions.test.js
📚 Learning: 2025-06-17T13:30:02.172Z
Learnt from: rafalmaksymiuk
Repo: box/box-ui-elements PR: 4144
File: src/elements/content-sidebar/versions/VersionsList.js:24-33
Timestamp: 2025-06-17T13:30:02.172Z
Learning: In the box-ui-elements codebase, Flow components use .flow.js type definition files, not TypeScript .ts files. The InternalSidebarNavigation type is a union type where different variants may have different properties like versionId, and proper type safety is ensured through conditional checks in methods like getSelectedVersionId.

Applied to files:

  • src/elements/content-sidebar/versions/VersionsList.js
🧬 Code graph analysis (4)
src/elements/content-sidebar/versions/VersionsItem.js (1)
src/elements/content-sidebar/versions/VersionsItemBadge.js (1)
  • VersionsItemBadge (18-31)
src/elements/content-sidebar/versions/VersionsItemActions.js (2)
src/elements/content-sidebar/versions/VersionsList.js (1)
  • isPreviewModernizationEnabled (27-27)
src/elements/common/feature-checking/hooks.js (1)
  • useFeatureConfig (6-9)
src/elements/content-sidebar/versions/VersionsList.js (2)
src/elements/content-sidebar/versions/VersionsItemActions.js (1)
  • isPreviewModernizationEnabled (65-65)
src/elements/common/feature-checking/hooks.js (1)
  • useFeatureConfig (6-9)
src/elements/content-sidebar/versions/__tests__/VersionsItemActions.test.js (1)
src/elements/content-sidebar/versions/VersionsItemActions.js (1)
  • VersionsItemActions (50-159)
🪛 Biome (2.1.2)
src/elements/content-sidebar/versions/VersionsItemActions.js

[error] 102-102: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.

TypeScript only syntax

(parse)

src/elements/content-sidebar/versions/VersionsItemBadge.js

[error] 11-16: type alias are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.

TypeScript only syntax

(parse)


[error] 18-18: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.

TypeScript only syntax

(parse)

⏰ 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-sidebar/versions/VersionsItem.scss (1)

31-36: Modernized toggle positioning looks consistent

New .bcs-VersionsItemActions-toggle--modernized is scoped correctly under .bcs-VersionsItem and mirrors the legacy toggle behavior with design‑token spacing, so this looks good.

src/elements/content-sidebar/versions/VersionsItem.js (1)

132-134: Forwarding isCurrent into the badge is correct

Threading isCurrent into VersionsItemBadge matches the new badge API and keeps the current‑version styling in sync with the rest of the item.

src/elements/content-sidebar/versions/VersionsList.js (1)

9-11: Feature‑flagged modernized list class is wired correctly

Using useFeatureConfig('previewModernization') and classNames to conditionally add bcs-VersionsList--modernized keeps behavior identical when the flag is off and opt‑in when on; this integration looks solid.

Also applies to: 27-28, 52-55

src/elements/content-sidebar/versions/VersionsItemActions.js (1)

8-11: Feature‑flagged modernized toggle preserves behavior and a11y

The previewModernization flag cleanly switches between the legacy PlainButton and the new Blueprint IconButton while keeping the analytics attributes and accessible name (versionActionToggle) consistent, so the user‑visible and tracking behavior look preserved.

Also applies to: 65-67, 80-105

src/elements/content-sidebar/versions/__tests__/VersionsItemBadge.test.js (1)

2-2: Badge class assertions target the wrong element

screen.getByText('V1') will match the inner <span> rendered by FormattedMessage, not the outer <div> that actually has the bcs-VersionsItemBadge / --current classes, so the class checks will fail even when the component is correct.

Consider targeting the labeled container instead, e.g.:

-        test.each`
+        test.each`
             isCurrent    | shouldHaveCurrentClass
             ${true}      | ${true}
             ${false}     | ${false}
             ${undefined} | ${false}
         `(
             'should apply current class correctly when isCurrent is $isCurrent',
             ({ isCurrent, shouldHaveCurrentClass }) => {
                 renderComponent({ versionNumber: '1', isCurrent });

-                const badge = screen.getByText('V1');
+                const badge = screen.getByLabelText('Version number 1');
                 expect(badge).toHaveClass('bcs-VersionsItemBadge');
                 if (shouldHaveCurrentClass) {
                     expect(badge).toHaveClass('bcs-VersionsItemBadge--current');
                 } else {
                     expect(badge).not.toHaveClass('bcs-VersionsItemBadge--current');
                 }
             },
         );

Also applies to: 6-6, 9-39

⛔ Skipped due to learnings
Learnt from: bxie-box
Repo: box/box-ui-elements PR: 4250
File: src/features/classification/applied-by-ai-classification-reason/__tests__/AppliedByAiClassificationReason.test.tsx:44-51
Timestamp: 2025-08-27T17:03:48.322Z
Learning: In test files for bxie-box, prefer using queryByTestId over getByTestId when testing for expected elements that should always exist, as null access serves as validation for regressions or unexpected changes rather than masking issues with defensive assertions.

@bfoxx1906 bfoxx1906 self-requested a review December 5, 2025 16:14
@mergify
Copy link
Contributor

mergify bot commented Dec 5, 2025

Merge Queue Status

✅ The pull request has been merged

This pull request spent 10 minutes 57 seconds in the queue, including 10 minutes 47 seconds running CI.
The checks were run in-place.

Required conditions to merge

@mergify mergify bot added the queued label Dec 5, 2025
@mergify mergify bot merged commit 2b136e4 into box:master Dec 5, 2025
7 checks passed
@mergify mergify bot removed the queued label Dec 5, 2025
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