feat: add metadata as colum from tree-view#2366
Open
emigun wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- The logic in
TreeBaseComponent.buildDataTree,TreeViewComponent(defaultmetadataPath), andaddAsColumnall hard-code the'scientificMetadata'prefix in slightly different ways; consider centralizing this prefix (or deriving it frommetadataPath) to avoid subtle bugs if the key changes or is reused for other metadata sources. - In
TreeViewComponent.ngOnChanges, when bothmetadataandmetadataPathchange in the same cycle, the tree is rebuilt twice; you could normalize the changes and rebuild once using the updated values to avoid redundant work. - The test setup for
TreeViewComponentrepeats the sameappConfigService.getConfig.and.returnValueconfiguration block multiple times; extracting a helper or shared config constant would keep the tests easier to maintain as this feature evolves.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The logic in `TreeBaseComponent.buildDataTree`, `TreeViewComponent` (default `metadataPath`), and `addAsColumn` all hard-code the `'scientificMetadata'` prefix in slightly different ways; consider centralizing this prefix (or deriving it from `metadataPath`) to avoid subtle bugs if the key changes or is reused for other metadata sources.
- In `TreeViewComponent.ngOnChanges`, when both `metadata` and `metadataPath` change in the same cycle, the tree is rebuilt twice; you could normalize the changes and rebuild once using the updated values to avoid redundant work.
- The test setup for `TreeViewComponent` repeats the same `appConfigService.getConfig.and.returnValue` configuration block multiple times; extracting a helper or shared config constant would keep the tests easier to maintain as this feature evolves.
## Individual Comments
### Comment 1
<location path="src/app/shared/modules/scientific-metadata-tree/tree-view/tree-view.component.scss" line_range="25-31" />
<code_context>
+ display: inline-block;
+ }
+
+ .menu-cell ::ng-deep row-menu .clear {
+ width: 24px;
+ height: 24px;
+ padding: 0;
+ }
+
+ .menu-cell ::ng-deep row-menu .clear mat-icon {
+ color: rgba(0, 0, 0, 0.25);
+ }
</code_context>
<issue_to_address>
**suggestion:** Relying on `::ng-deep` for styling the row menu may cause future maintenance issues as it is deprecated.
Here, `.menu-cell ::ng-deep row-menu .clear` and its `mat-icon` are styled via `::ng-deep`, which applies styles globally and couples this component to `row-menu`’s internals. Prefer an alternative such as adding a dedicated CSS class or input on `row-menu` and styling it through that API, or moving these styles into the `row-menu` component itself so you don’t need to pierce view encapsulation.
Suggested implementation:
```
.menu-cell row-menu {
justify-content: flex-start;
width: 24px;
min-width: 24px;
}
/**
* Styles for the clear button within row-menu when used in a tree-view menu cell.
* Applied via the `menu-cell-clear` class on row-menu to avoid ::ng-deep.
*/
.menu-cell row-menu.menu-cell-clear .clear {
width: 24px;
height: 24px;
padding: 0;
}
.menu-cell row-menu.menu-cell-clear .clear mat-icon {
color: rgba(0, 0, 0, 0.25);
}
```
1. Update the tree-view template where the `row-menu` is used inside `.menu-cell` to add the `menu-cell-clear` class, for example:
- `<row-menu class="menu-cell-clear" ...></row-menu>`
2. If `row-menu` is a component with its own inputs, you may instead expose an API like `[variant]="'menu-cell-clear'"` and bind that to `host` classes inside `row-menu` (e.g. via `@HostBinding('class.menu-cell-clear')`) so the styling hook remains explicit and maintainable.
3. Remove any existing `.menu-cell ::ng-deep row-menu .clear` and `.menu-cell ::ng-deep row-menu .clear mat-icon` rules from this SCSS file if they are still present elsewhere, as they are now superseded by the new class-based selectors.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
c1c2212 to
3ca738f
Compare
Member
Author
These three suggestions have been implemented. |
3ca738f to
1adf2d2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Continuation of #2333. Same configuration now also works for the scientific metadata tree view.
Motivation
Users should be able to configure the dataset table with columns from scientific metadata.
Changes:
Tests included
Summary by Sourcery
Enable adding scientific metadata keys as configurable dataset table columns from the tree view.
New Features:
Enhancements:
Tests: