Skip to content

Conversation

@Nefaris
Copy link

@Nefaris Nefaris commented Jan 16, 2026

Passes the isRedesignEnabled feature flag through the Content Insights component tree so child components can conditionally render Blueprint vs BUIE variants. This keeps the toggle controlled by the end‑user app and enables gradual migration to Blueprint across the Content Insights UI.

Changes

  • Add isRedesignEnabled prop to SidebarContentInsights and pass it through ContentInsightsSummaryGraphCardPreviewsSummaryMetricSummaryHeaderWithCount / CompactCount / OpenContentInsightsButton
  • Render Blueprint Button and Text variants when redesign is enabled
  • Adjust Content Insights spacing for redesigned layout
  • Add VRT stories for ContentInsightsSummary
  • Fix flaky Metadata sidebar story (SuggestionForNewlyCreatedTemplateInstance) with waitFor

Usage

<SidebarContentInsights
  contentInsights={contentInsights}
  onContentInsightsClick={handleClick}
  isRedesignEnabled={true}  // enables Blueprint components
/>

Screenshot

Without redesign flag With redesign flag With modernized flag

Summary by CodeRabbit

  • New Features

    • Added an optional "redesign" flag for Content Insights that toggles updated visuals and propagates to related UI elements; redesigned layouts, counts, and charts render when enabled.
    • Insights action now uses localized messaging and a redesigned button variant under the flag.
  • Tests

    • Added Storybook visual scenarios for default, redesigned, loading, error, and trend states.
    • Updated an async UI test to use a polling wait strategy.
  • Style

    • Adjusted spacing and CSS variants to support the redesigned appearance.

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

@Nefaris Nefaris requested review from a team as code owners January 16, 2026 16:06
@CLAassistant
Copy link

CLAassistant commented Jan 16, 2026

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 16, 2026

Walkthrough

Adds an optional isRedesignEnabled?: boolean prop across content-insights and sidebar components, forwarding the flag to nested components and toggling redesigned rendering (class modifiers, Text/BlueprintButton usage, conditional classNames). Also adds Storybook visual stories and minor style/text adjustments. (≤50 words)

Changes

Cohort / File(s) Summary
Sidebar → Summary → Button
src/elements/content-sidebar/SidebarContentInsights.tsx, src/features/content-insights/ContentInsightsSummary.tsx, src/features/content-insights/OpenContentInsightsButton.tsx
Introduces isRedesignEnabled?: boolean on Props and forwards it Sidebar → ContentInsightsSummary → OpenContentInsightsButton. OpenContentInsightsButton now uses useIntl and conditionally renders a BlueprintButton when redesigned, otherwise the legacy Button + FormattedMessage.
Metric / Header / Count / Graph components
src/features/content-insights/MetricSummary.tsx, src/features/content-insights/HeaderWithCount.tsx, src/features/content-insights/CompactCount.tsx, src/features/content-insights/GraphCardPreviewsSummary.tsx
Adds isRedesignEnabled?: boolean prop and conditional rendering paths: redesigned UI uses Text, classNames, updated DOM and formatted counts; flag is forwarded to nested components and toggles class modifiers (e.g., chart class).
Styles (redesign variants)
src/features/content-insights/ContentInsightsSummary.scss, src/features/content-insights/GraphCardPreviewsSummary.scss, src/features/content-insights/HeaderWithCount.scss, src/features/content-insights/MetricSummary.scss
Adds/adjusts --redesigned selectors and spacing/color tweaks to apply redesigned spacing and exclude redesigned elements from legacy rules.
Messages
src/features/content-insights/messages.ts
Minor copy change: previewGraphType defaultMessage updated from 'PREVIEWS' to 'Previews'.
Stories / Tests
src/features/content-insights/stories/tests/ContentInsightsSummary-visual.stories.tsx, src/elements/content-sidebar/stories/tests/MetadataSidebarRedesign-visual.stories.tsx
Adds Storybook visual stories exercising default/redesign/loading/error/trend states for ContentInsightsSummary; updates one test to use waitFor for an async assertion.

Sequence Diagram(s)

sequenceDiagram
    participant Sidebar as SidebarContentInsights
    participant Summary as ContentInsightsSummary
    participant Graphs as GraphCardPreviewsSummary
    participant Metric as MetricSummary
    participant Header as HeaderWithCount
    participant Count as CompactCount
    participant ButtonCmp as OpenContentInsightsButton

    Sidebar->>Summary: render(isRedesignEnabled)
    Summary->>Graphs: render(isRedesignEnabled)
    Summary->>Metric: render(isRedesignEnabled)
    Metric->>Header: render(isRedesignEnabled)
    Header->>Count: render(isRedesignEnabled)
    Summary->>ButtonCmp: render(isRedesignEnabled)
    alt isRedesignEnabled == true
        ButtonCmp->>ButtonCmp: useIntl() -> formatMessage()
        Note right of ButtonCmp: render BlueprintButton and redesigned classes/Text
    else isRedesignEnabled == false
        Note right of ButtonCmp: render legacy Button and legacy span/Text paths
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

ready-to-merge

Suggested reviewers

  • tjuanitas
  • jpan-box

Poem

🐰 I hop a flag from pane to view,
I whisper "redesign" and colors skew,
A button wears Blueprint, counts stand tall,
Stories sprout cases, watching it all,
Hooray — insights prance in something new!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding an isRedesignEnabled flag to enable Blueprint button variants in Content Insights components.
Description check ✅ Passed The PR description provides clear context about the feature flag propagation, component tree changes, usage examples, and includes visual regression test coverage. However, it does not follow the repository's description template structure.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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

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

@loonskai
Copy link
Contributor

Can we add some VRT tests here?

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/features/content-insights/OpenContentInsightsButton.tsx (1)

14-35: Correct the BlueprintButton size prop value.

The implementation correctly follows React hooks rules by calling useIntl unconditionally at the component top. The early return pattern provides clean separation between the two rendering paths while maintaining consistent className for styling and test selectors.

However, the size="small" prop is incorrect. According to the @box/blueprint-web Button API, valid size values are 'sm', 'default', or 'lg'. Change size="small" to size="sm" on line 20. The variant="secondary" prop is correct.

tjiang-box
tjiang-box previously approved these changes Jan 20, 2026
tjiang-box
tjiang-box previously approved these changes Jan 20, 2026

export interface Props {
contentInsights?: ContentInsights;
isRedesignEnabled?: boolean;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of a prop isRedesignEnabled, can we change it to split or feature flag here which is better and easier to control and toggle?

Copy link
Collaborator

Choose a reason for hiding this comment

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

here is one of the example for reference -

const isMetadataViewV2Feature = isFeatureEnabled(features, 'contentExplorer.metadataViewV2');

Copy link
Author

@Nefaris Nefaris Jan 21, 2026

Choose a reason for hiding this comment

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

I'm not sure this approach would work well here, since the redesign should be controlled from the end-user app and enabled only within a specific scope, not globally. It is controlled by feature flag in eua.

@tjiang-box tjiang-box dismissed their stale review January 20, 2026 17:46

left some new comments

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

🤖 Fix all issues with AI agents
In `@src/features/content-insights/CompactCount.tsx`:
- Line 24: CompactCount.tsx passes a redundant string into the classNames call
causing a leading space; remove the unnecessary `' '` argument so the JSX uses
classNames(className) (locate the className={classNames(' ', className)} usage
in the CompactCount component and replace it with a single-argument call to
classNames or equivalent handling of className).
🧹 Nitpick comments (4)
src/features/content-insights/messages.ts (1)

78-82: Inconsistent casing with other message defaults.

previewGraphType now uses title case ('Previews') while similar messages like downloadGraphType ('DOWNLOADS') and peopleTitle ('PEOPLE') remain in all caps. If the redesign requires title case, consider updating all related messages for consistency, or ensure the casing is handled via CSS text-transform to avoid divergence.

src/features/content-insights/CompactCount.tsx (1)

34-37: Reuse formattedCount in the non-redesigned branch.

formattedCount is already computed at line 18 but the non-redesigned path calls formatCount(count, intl) again. Reuse the variable for consistency and to avoid redundant computation.

Proposed fix
     return (
         <span className={classNames('CompactCount', className)} {...rest}>
-            {formatCount(count, intl)}
+            {formattedCount}
         </span>
     );
src/features/content-insights/stories/tests/ContentInsightsSummary-visual.stories.tsx (1)

65-74: Consider adding a WithErrorRedesign story.

The error state is only tested without the redesign flag. For comprehensive VRT coverage, consider adding a story that tests the error state with isRedesignEnabled={true} to ensure the error UI renders correctly in the redesigned layout.

Suggested addition
export const WithErrorRedesign = {
    render: () => (
        <Wrapper>
            <ContentInsightsSummary
                {...defaultProps}
                error={Object.assign(new Error('An error occurred'), { status: 500 })}
                isRedesignEnabled
            />
        </Wrapper>
    ),
};
src/features/content-insights/MetricSummary.tsx (1)

3-4: Pre-existing: Shadowing of global isFinite and isNaN.

Static analysis flags these imports as shadowing global names. While this is intentional (lodash versions handle edge cases like isNaN(undefined) differently), consider aliasing them to avoid confusion:

import isFiniteLodash from 'lodash/isFinite';
import isNaNLodash from 'lodash/isNaN';

This is pre-existing code and not blocking for this PR.

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.

4 participants