Add voltage-level band filtering to NAD#4029
Conversation
Allow filtering the Network Area Diagram by voltage-level bands from a sidebar, reusing the geographic map's NominalVoltageFilter. Bands are hidden via CSS classes on the rendered SVG, without refetching the diagram. - Extract the filtering logic into a useNadVoltageLevelFilter hook deriving present bands from the SVG metadata CSS classes. - Turn NominalVoltageFilter's two select-all/none buttons into a single master checkbox with an indeterminate state, and expose per-element style overrides so it blends into the NAD sidebar. - Make NavigationSidebar own its collapse state internally, keyed by section id, with disabled sections forced collapsed. - Rename our components' `disabled` prop to `isDisabled` to disambiguate from MUI's native `disabled`. Signed-off-by: Florent MILLOT <florent.millot_externe@rte-france.com>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThis PR adds a voltage-level band filter to the Network Area Diagram (NAD) panel. It refactors ChangesNAD Voltage-Level Band Filter
Suggested Reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/components/workspace/diagrams/common/navigation-sidebar.tsx (2)
162-165: 💤 Low valueSection title color doesn't reflect disabled state.
The icon receives disabled color via
styles.icon(theme, enabled), but the Typography text remains unchanged whenenabledis false. Consider adding consistent disabled styling:🎨 Proposed fix
- <Typography variant="caption" sx={{ ml: 1, fontWeight: 'medium' }}> + <Typography + variant="caption" + sx={{ + ml: 1, + fontWeight: 'medium', + color: enabled ? 'text.primary' : 'text.disabled', + }} + >🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/components/workspace/diagrams/common/navigation-sidebar.tsx` around lines 162 - 165, The Typography component displaying the section title does not reflect the disabled state styling even though the icon does via styles.icon(theme, enabled). Add consistent disabled styling to the Typography component by passing the enabled parameter to its sx prop, following the same pattern used for the icon styling. Create or use an appropriate styles function (similar to styles.icon) that applies disabled color/opacity to the Typography variant when enabled is false, ensuring both the icon and title text have matching visual treatment for the disabled state.
153-171: ⚡ Quick winExpanded section header is not keyboard accessible.
The clickable
Boxat lines 158-166 lackstabIndex,role="button", andonKeyDownhandling. Users who expand a section via keyboard cannot collapse it without a mouse.Consider using
ButtonBaseor adding accessibility attributes:♿ Proposed fix using ButtonBase
+import { ButtonBase } from '`@mui/material`'; ... - <Box - onClick={enabled ? () => toggleExpand(section.id) : undefined} - sx={styles.headerExpanded(theme, enabled)} - > + <ButtonBase + onClick={enabled ? () => toggleExpand(section.id) : undefined} + disabled={!enabled} + sx={styles.headerExpanded(theme, enabled)} + > <Box sx={styles.icon(theme, enabled)}>{section.icon}</Box> <Typography variant="caption" sx={{ ml: 1, fontWeight: 'medium' }}> {intl.formatMessage({ id: section.titleId })} </Typography> - </Box> + </ButtonBase>🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/components/workspace/diagrams/common/navigation-sidebar.tsx` around lines 153 - 171, The clickable Box element used as the section header (which calls toggleExpand(section.id) on click) lacks keyboard accessibility. Add keyboard support by either replacing the Box with a ButtonBase component from Material-UI, or by adding tabIndex="0", role="button", and an onKeyDown handler to the Box that triggers toggleExpand(section.id) when the Enter or Space keys are pressed, ensuring the behavior mirrors the existing onClick handling and respects the enabled conditional logic already present.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/components/workspace/diagrams/nad/use-nad-voltage-level-filter.ts`:
- Around line 56-61: The setSelectedNominalVoltages state update in the
useEffect hook only initializes when prev is undefined, causing stale voltage
selections to persist when switching between different NADs. Replace the
conditional logic (prev ?? presentNominalVoltages) with a direct assignment to
presentNominalVoltages so that selected voltages are reset whenever the
available nominal voltages change, preventing stale selections from hiding bands
or producing incorrect unselectedVlNames.
---
Nitpick comments:
In `@src/components/workspace/diagrams/common/navigation-sidebar.tsx`:
- Around line 162-165: The Typography component displaying the section title
does not reflect the disabled state styling even though the icon does via
styles.icon(theme, enabled). Add consistent disabled styling to the Typography
component by passing the enabled parameter to its sx prop, following the same
pattern used for the icon styling. Create or use an appropriate styles function
(similar to styles.icon) that applies disabled color/opacity to the Typography
variant when enabled is false, ensuring both the icon and title text have
matching visual treatment for the disabled state.
- Around line 153-171: The clickable Box element used as the section header
(which calls toggleExpand(section.id) on click) lacks keyboard accessibility.
Add keyboard support by either replacing the Box with a ButtonBase component
from Material-UI, or by adding tabIndex="0", role="button", and an onKeyDown
handler to the Box that triggers toggleExpand(section.id) when the Enter or
Space keys are pressed, ensuring the behavior mirrors the existing onClick
handling and respects the enabled conditional logic already present.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ada0bf48-d825-425a-96b1-d742899ab829
📒 Files selected for processing (10)
src/components/grid-layout/cards/diagrams/networkAreaDiagram/network-area-diagram-content.tsxsrc/components/network/network-map-panel.tsxsrc/components/network/nominal-voltage-filter.tsxsrc/components/workspace/diagrams/common/navigation-sidebar.tsxsrc/components/workspace/diagrams/nad/nad-navigation-sidebar.tsxsrc/components/workspace/diagrams/nad/use-nad-voltage-level-filter.tssrc/components/workspace/diagrams/sld/sld-navigation-sidebar.tsxsrc/components/workspace/panel-contents/diagrams/nad/nad-panel-content.tsxsrc/translations/en.jsonsrc/translations/fr.json
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Florent MILLOT <florent.millot_externe@rte-france.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Florent MILLOT <florent.millot_externe@rte-france.com>
Signed-off-by: Florent MILLOT <florent.millot_externe@rte-france.com>
|
… icons Signed-off-by: Florent MILLOT <florent.millot_externe@rte-france.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Florent MILLOT <florent.millot_externe@rte-france.com>
Meklo
left a comment
There was a problem hiding this comment.
When a new nominal voltage is added in the NAD (e.g. expanding voltage levels, adding a specific voltage level..) shouldn't its nominal voltage be preselected by default if All was ticked ? It would prevent confusion why the data doesn't show up
Rename the NAD navigation sidebar props to allNominalVoltages, selectedNominalVoltages and onNominalVoltagesChange (plus the checkedNominalVoltages callback param and the hasNominalVoltages local), and import the renamed NominalVoltageIcon from commons-ui. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Florent MILLOT <florent.millot_externe@rte-france.com>
When a nominal voltage appears in the NAD (e.g. after expanding or adding a voltage level), automatically add it to the current selection so its data shows up by default, even when not all voltages are ticked. Voltages explicitly unticked by the user stay hidden. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Florent MILLOT <florent.millot_externe@rte-france.com>
I didn't know it was possible but indeed if it's possible you're right. I Changed it. edit : finally after discussion with the PO we dont change them |
Keep the voltage selection across node, root-network and filter changes, and never auto-check newly-present voltages. The selection is reset to 'all shown' only when a different NAD is loaded (its config uuid changes). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Florent MILLOT <florent.millot_externe@rte-france.com>



Overview
Adds voltage-level band filtering to the Network Area Diagram (NAD), mirroring the geographic map's existing nominal-voltage filter. The user can show/hide voltage-level bands from a sidebar; bands are masked via CSS classes on the already-rendered SVG, without refetching the diagram.
Changes
useNadVoltageLevelFilterhook — derives the voltage-level bands present in the current diagram from the SVG metadata CSS classes (nad-voltage-level-*), and tracks the selected bands. Returns the unselected band names so the diagram can hide them.network-area-diagram-content.tsxturns the unselected bands intodisplay: nonerules targeting thenad-*classes, merged into the diagram containersx.NominalVoltageFilter— the two select-all / select-none buttons are replaced by a single master checkbox with anindeterminatestate. Added per-element style overrides so the filter blends into the NAD sidebar instead of floating like the map overlay.Need gridsuite/commons-ui#1203