Skip to content

Conversation

@Holocraft
Copy link
Contributor

@Holocraft Holocraft commented Jun 11, 2025

Description

This changeset adds the main summary view and summary tier list.

Motivation and Context

Resolves BED-5225, BED-5229, and BED-5261
Also resolves BED-5997

How Has This Been Tested?

Unit tests were added.

Screenshots (optional):

Types of changes

  • New feature (non-breaking change which adds functionality

Checklist:

Summary by CodeRabbit

  • New Features

    • Introduced new summary views for zone management with dedicated routes for general, tier, and label summaries.
    • Added a summary list component to display and navigate tiers and labels, featuring filtering, sorting, and selection handling.
    • Implemented a summary page offering detailed information and conditional editing options for selected tiers or labels.
  • Improvements

    • Enhanced tab navigation to dynamically toggle between summary and details views based on the active route.
    • Improved edit button logic for better handling of loading and error states.
    • Made header components consistently available within the zone management context.
  • Tests

    • Added comprehensive tests for the summary list component, covering loading states, error handling, sorting, and user interactions.

@Holocraft Holocraft self-assigned this Jun 11, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 11, 2025

Walkthrough

This update introduces new summary routes and corresponding UI components for zone management, including a Summary view and a SummaryList component with associated tests. Routing logic and context interfaces are updated to support summary views, and functions are refactored for improved export visibility and parameter robustness.

Changes

File(s) Change Summary
.../routes/index.tsx Added three new summary route constants for zone management.
.../ZoneManagement/Details/Details.tsx Exported getSavePath, updated getEditButtonState for optional parameters and safer property access, and replaced fragment with <div>.
.../ZoneManagement/Summary/Summary.tsx Added new Summary component for summary views with data fetching, navigation, and edit button logic.
.../ZoneManagement/Summary/SummaryList.tsx Introduced new SummaryList component for displaying filtered, sorted lists of tags with selection.
.../ZoneManagement/Summary/SummaryList.test.tsx Added tests for SummaryList covering loading, error, rendering, and interaction scenarios.
.../ZoneManagement/ZoneManagement.tsx Integrated summary routes and Summary component, adjusted tab navigation to support summary/details.
.../ZoneManagement/ZoneManagementContext.tsx Made InfoHeader required in context and provided a default empty header component.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Router
    participant ZoneManagement
    participant Summary
    participant DataAPI

    User->>Router: Navigate to /summary or /summary/tier/:tierId
    Router->>ZoneManagement: Render ZoneManagement
    ZoneManagement->>Summary: Render Summary component
    Summary->>DataAPI: Fetch tags and selectors data
    DataAPI-->>Summary: Return data/results
    Summary->>User: Display InfoHeader, SummaryList, SelectedDetails, Edit button
    User->>Summary: Select item in SummaryList
    Summary->>ZoneManagement: Navigate to selected item's summary/details
Loading

Suggested reviewers

  • urangel

Poem

A summary view, so shiny and new,
With lists and tabs for users to pursue.
Routes now expanded, context refined,
Headers and tests so neatly aligned.
From details to summary, navigation’s a breeze—
This bunny’s quite proud, hopping with ease! 🐇✨


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 21aa2b0 and 0e995ca.

📒 Files selected for processing (1)
  • packages/javascript/bh-shared-ui/src/views/ZoneManagement/Summary/SummaryList.test.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/javascript/bh-shared-ui/src/views/ZoneManagement/Summary/SummaryList.test.tsx
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: run-tests
  • GitHub Check: build-ui
  • GitHub Check: run-analysis
✨ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

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

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 generate sequence diagram to generate a sequence diagram of the changes in 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.

@Holocraft Holocraft added enhancement New feature or request user interface A pull request containing changes affecting the UI code. labels Jun 11, 2025
Comment on lines 41 to 43
.sort((a, b) => {
return b.name.localeCompare(a.name);
})
Copy link
Contributor

Choose a reason for hiding this comment

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

Tiers should be sorted by position with tier zero (position 1) at the top instead of by name

Comment on lines 27 to 29
<div className='flex flex-col w-full h-full space-y-4'>
<div className='flex flex-col flex-1 space-y-4'>
<ul>
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this contain the list of items within the height of the page and scroll the list within the container or extend past the page height and scroll the whole page?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Your attention to detail is unmatched!

Copy link
Contributor

Choose a reason for hiding this comment

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

I feel bad for the nits especially since these things get discussed but sometimes don't end up in the ticket 😓 I really appreciate your steadfastness 🙇

@urangel
Copy link
Contributor

urangel commented Jun 12, 2025

Do we need the summary view in CE?
image

@Holocraft
Copy link
Contributor Author

@urangel summary view is BHE only

@elikmiller elikmiller changed the title feat: BED-5225 Draft: feat: BED-5225 Jun 13, 2025
@elikmiller elikmiller marked this pull request as draft June 13, 2025 16:48
@urangel urangel changed the base branch from stage/v7.5.0 to main June 17, 2025 20:19
@Holocraft Holocraft marked this pull request as ready for review June 18, 2025 17:31
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: 4

♻️ Duplicate comments (1)
packages/javascript/bh-shared-ui/src/views/ZoneManagement/Summary/SummaryList.test.tsx (1)

82-82: Fix test ID inconsistency.

The test ID should use 'zone-management_summary-list_loading-skeleton' to be consistent with other test IDs in the file and match the mocked component.

Apply this diff to fix the inconsistency:

-        expect(screen.getAllByTestId('zone-management_tiers-list_loading-skeleton')).toHaveLength(3);
+        expect(screen.getAllByTestId('zone-management_summary-list_loading-skeleton')).toHaveLength(3);
🧹 Nitpick comments (1)
packages/javascript/bh-shared-ui/src/views/ZoneManagement/Summary/SummaryList.tsx (1)

45-45: Consider making the fixed height responsive.

The hardcoded height h-[445px] might not work well across different screen sizes or when the component is used in different contexts.

Consider using a more flexible approach:

-                    <ul className='overflow-y-auto h-[445px]'>
+                    <ul className='overflow-y-auto max-h-[445px] h-full'>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 33316b8 and 8bd80cf.

📒 Files selected for processing (7)
  • packages/javascript/bh-shared-ui/src/routes/index.tsx (1 hunks)
  • packages/javascript/bh-shared-ui/src/views/ZoneManagement/Details/Details.tsx (4 hunks)
  • packages/javascript/bh-shared-ui/src/views/ZoneManagement/Summary/Summary.tsx (1 hunks)
  • packages/javascript/bh-shared-ui/src/views/ZoneManagement/Summary/SummaryList.test.tsx (1 hunks)
  • packages/javascript/bh-shared-ui/src/views/ZoneManagement/Summary/SummaryList.tsx (1 hunks)
  • packages/javascript/bh-shared-ui/src/views/ZoneManagement/ZoneManagement.tsx (5 hunks)
  • packages/javascript/bh-shared-ui/src/views/ZoneManagement/ZoneManagementContext.tsx (1 hunks)
🔇 Additional comments (12)
packages/javascript/bh-shared-ui/src/views/ZoneManagement/ZoneManagementContext.tsx (1)

39-49: LGTM! Clean solution for making InfoHeader required.

The addition of EmptyHeader as a default fallback and changing InfoHeader from optional to required provides a robust solution. This ensures that components consuming the context can rely on InfoHeader being present without additional null checks.

packages/javascript/bh-shared-ui/src/routes/index.tsx (1)

23-25: LGTM! Routes follow established patterns.

The new summary routes are well-structured and maintain consistency with the existing details routes pattern. The parallel structure enables clean navigation between summary and detail views.

packages/javascript/bh-shared-ui/src/views/ZoneManagement/Details/Details.tsx (3)

29-43: LGTM! Good refactoring for reusability.

Exporting getSavePath with explicit multiline parameter formatting improves code reusability and readability. This enables sharing the utility function with the new Summary component.


66-72: LGTM! Improved function robustness.

Making all parameters optional and using optional chaining enhances the function's robustness and consistency with its usage in the Summary component.


108-155: LGTM! Wrapper change for consistency.

The change from fragment to div wrapper maintains consistency with other Zone Management views and may support additional styling requirements.

packages/javascript/bh-shared-ui/src/views/ZoneManagement/ZoneManagement.tsx (3)

42-42: LGTM! Proper lazy loading implementation.

Adding lazy loading for the Summary component follows the established pattern and optimizes bundle size.


55-81: LGTM! Clean routing integration.

The addition of summaryPaths and refactoring of childRoutes using spread operators creates a maintainable and scalable routing structure that properly integrates the new summary functionality.


98-101: LGTM! Smart navigation logic.

The dynamic path detection for summary vs details views in the tab navigation logic elegantly handles the parallel route structure without code duplication.

packages/javascript/bh-shared-ui/src/views/ZoneManagement/Summary/SummaryList.test.tsx (1)

73-134: LGTM! Comprehensive test coverage.

The test suite provides excellent coverage of all component states and behaviors:

  • Loading and error states
  • Data sorting and rendering
  • Conditional rendering based on item type
  • User interaction handling

The mock data is realistic and the test structure follows testing best practices.

packages/javascript/bh-shared-ui/src/views/ZoneManagement/Summary/SummaryList.tsx (1)

38-96: LGTM! Well-structured component with proper error handling.

The component properly handles loading and error states, implements filtering and sorting logic, and provides good user interaction patterns with selection highlighting and callback handling.

packages/javascript/bh-shared-ui/src/views/ZoneManagement/Summary/Summary.tsx (2)

42-46: LGTM! Proper context validation.

Good defensive programming practice to validate context availability and provide a clear error message when the component is used incorrectly.


48-65: LGTM! Well-structured data fetching.

The React Query implementation follows best practices with proper query keys, error handling, and conditional execution for the selectors query.

</li>
{listItem.type === AssetGroupTagTypeTier ? (
<div
key={listItem.id}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Avoid duplicate key usage.

The key prop is used twice in the same React.Fragment - once for the div and once for the parent li element. React requires unique keys at the same level.

-                                            <div
-                                                key={listItem.id}
-                                                className='flex justify-center my-2 pl-6 last:hidden'>
+                                            <div className='flex justify-center my-2 pl-6 last:hidden'>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
key={listItem.id}
- <div
- key={listItem.id}
- className='flex justify-center my-2 pl-6 last:hidden'>
+ <div className='flex justify-center my-2 pl-6 last:hidden'>
🤖 Prompt for AI Agents
In
packages/javascript/bh-shared-ui/src/views/ZoneManagement/Summary/SummaryList.tsx
at line 84, the key prop is assigned to both the div and the parent li element
within the same React.Fragment, causing duplicate keys at the same level. Remove
the key from the inner div or the parent li so that only one unique key is used
per sibling element to satisfy React's requirement for unique keys.

},
});

const showEditButton = !getEditButtonState(memberId, selectorsQuery, tagsQuery);
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix button logic to eliminate double negation.

The current logic creates confusion with double negation. The button is only shown when showEditButton is true, but then immediately disabled.

-    const showEditButton = !getEditButtonState(memberId, selectorsQuery, tagsQuery);
+    const isEditButtonDisabled = shouldDisableEditButton(memberId, selectorsQuery, tagsQuery);

                 <div className='basis-1/3'>
-                    {showEditButton && (
-                        <Button asChild variant={'secondary'} disabled={showEditButton}>
+                    <Button asChild variant={'secondary'} disabled={isEditButtonDisabled}>
                         <Link to={getSavePath(tierId, labelId, selectorId)}>Edit</Link>
                     </Button>
-                    )}
                 </div>

Also applies to: 74-78

🤖 Prompt for AI Agents
In packages/javascript/bh-shared-ui/src/views/ZoneManagement/Summary/Summary.tsx
around lines 67 and 74-78, the button logic uses double negation which causes
confusion and incorrect button state. Refactor the logic to remove the negation
by directly assigning the correct boolean value from getEditButtonState to
showEditButton or a similarly named variable, and adjust the button's disabled
property accordingly to ensure the button is shown and enabled only when
appropriate.

Comment on lines +29 to +35
export const getEditButtonState = (memberId?: string, selectorsQuery?: UseQueryResult, tagsQuery?: UseQueryResult) => {
return (
!!memberId ||
(selectorsQuery?.isLoading && tagsQuery?.isLoading) ||
(selectorsQuery?.isError && tagsQuery?.isError)
);
};
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Fix confusing function naming and logic.

The function name getEditButtonState suggests it returns the button's state, but it actually returns whether the button should be disabled. This creates confusion when used with double negation.

-export const getEditButtonState = (memberId?: string, selectorsQuery?: UseQueryResult, tagsQuery?: UseQueryResult) => {
+export const shouldDisableEditButton = (memberId?: string, selectorsQuery?: UseQueryResult, tagsQuery?: UseQueryResult) => {
     return (
         !!memberId ||
         (selectorsQuery?.isLoading && tagsQuery?.isLoading) ||
         (selectorsQuery?.isError && tagsQuery?.isError)
     );
 };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export const getEditButtonState = (memberId?: string, selectorsQuery?: UseQueryResult, tagsQuery?: UseQueryResult) => {
return (
!!memberId ||
(selectorsQuery?.isLoading && tagsQuery?.isLoading) ||
(selectorsQuery?.isError && tagsQuery?.isError)
);
};
export const shouldDisableEditButton = (
memberId?: string,
selectorsQuery?: UseQueryResult,
tagsQuery?: UseQueryResult
) => {
return (
!!memberId ||
(selectorsQuery?.isLoading && tagsQuery?.isLoading) ||
(selectorsQuery?.isError && tagsQuery?.isError)
);
};
🤖 Prompt for AI Agents
In packages/javascript/bh-shared-ui/src/views/ZoneManagement/Summary/Summary.tsx
around lines 29 to 35, rename the function from getEditButtonState to a name
that clearly indicates it returns whether the edit button should be disabled,
such as isEditButtonDisabled. Also, review and adjust the logic if needed to
ensure it directly reflects the disabled state without requiring double negation
when used.

Copy link
Contributor

@urangel urangel left a comment

Choose a reason for hiding this comment

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

Nice work! 🚀

Thanks for updating with the feedback 🙇

@urangel urangel changed the title Draft: feat: BED-5225 feat: BED-5225 Jun 18, 2025
@Holocraft Holocraft merged commit b4f5ca9 into main Jun 18, 2025
10 of 11 checks passed
@Holocraft Holocraft deleted the cherry-pick-BED-5225 branch June 18, 2025 18:38
@github-actions github-actions bot locked and limited conversation to collaborators Jun 18, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request user interface A pull request containing changes affecting the UI code.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants