Skip to content

feat: add metadata as colum from tree-view#2366

Open
emigun wants to merge 1 commit into
masterfrom
metadata-add-column-tree
Open

feat: add metadata as colum from tree-view#2366
emigun wants to merge 1 commit into
masterfrom
metadata-add-column-tree

Conversation

@emigun
Copy link
Copy Markdown
Member

@emigun emigun commented May 8, 2026

Description

Continuation of #2333. Same configuration now also works for the scientific metadata tree view.

image

Motivation

Users should be able to configure the dataset table with columns from scientific metadata.

Changes:

  • Added “Add as column” row menu support to the scientific metadata tree view, reusing the shared row-menu component used by metadata tables.
    • Added metadata path tracking in tree nodes so saved columns get correct paths like scientificMetadata.sample.temperature.value.
    • Enabled the feature for dataset scientific metadata tree views, including dynamic detail sections with nested section.source.
    • Adjusted tree row layout so the left-side menu aligns with existing metadata table

Tests included

  • Included for each change/fix?
  • Passing? (Merge will not be approved unless this is checked)

Summary by Sourcery

Enable adding scientific metadata keys as configurable dataset table columns from the tree view.

New Features:

  • Allow scientific metadata tree views to expose an 'add as column' action for leaf nodes when enabled in configuration.
  • Support dynamic metadata path tracking so added scientific metadata columns use correct nested paths in saved column definitions.

Enhancements:

  • Align scientific metadata tree view layout with metadata tables when row menus are enabled for adding columns.

Tests:

  • Extend scientific metadata tree view tests to cover add-as-column visibility, path generation, and delegation to the saved-column service.

@emigun emigun requested a review from a team as a code owner May 8, 2026 09:05
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • 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.
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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@emigun emigun force-pushed the metadata-add-column-tree branch from c1c2212 to 3ca738f Compare May 8, 2026 09:49
@emigun
Copy link
Copy Markdown
Member Author

emigun commented May 8, 2026

Hey - I've found 1 issue, and left some high level feedback:

  • 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.

These three suggestions have been implemented.

@emigun emigun force-pushed the metadata-add-column-tree branch from 3ca738f to 1adf2d2 Compare May 8, 2026 12:00
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.

1 participant