Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

[quick-filter] use internal id path from filter field and not require it in the data source #1647

Closed
lukasholzer opened this issue Sep 22, 2020 · 2 comments · Fixed by #1662
Assignees
Labels
has-pr quick-filter Label for Quick filter issues

Comments

@lukasholzer
Copy link
Contributor

No description provided.

@lukasholzer
Copy link
Contributor Author

Currently, the quick-filter component requires a name property in the data source to build a unique id for the path. The filter-field already has an internal id property that is built up so we should leverage it instead of requireing the user to provide one.

export interface DtQuickFilterDefaultDataSourceSimpleOption {
  name: string;
}

The name is currently used to identify a option by its path. https://github.com/dynatrace-oss/barista/blob/master/libs/barista-components/experimental/quick-filter/src/state/reducer.ts#L151

      // if the option is distinct we only have to check for the groups name because
      // there can only be one distinct option selected so we know immediately if it is selected
      if (distinct && parts[0] === path[0].name) {
        return true;
      }

      // if it is not distinct we have to build the full path out of the current filters to check
      // wether the path matches them provided node definition
      const dataPath = path.reduce(
        (previousValue, currentValue) =>
          `${previousValue.name}${DELIMITER}${currentValue.name}${DELIMITER}`,
      );

      // if the built path for the filters inside the array is equal to the option
      // in the provided nodeDef then we found our selected option
      if (item.option.uid === dataPath) {
        return true;
      }

and where the paths are built for the filters to set the activeFilters input on the quick-filter-group: https://github.com/dynatrace-oss/barista/blob/master/libs/barista-components/experimental/quick-filter/src/quick-filter-utils.ts

import { DELIMITER } from '@dynatrace/barista-components/filter-field';

export function buildIdPathsFromFilters(filters: any[][]): string[] {
  return filters.map((path) =>
    path.reduce(
      (previousValue, currentValue) =>
        `${previousValue.name}${DELIMITER}${currentValue.name}${DELIMITER}`,
    ),
  );
}

Maybe @thomaspink can provide some insights on how to handle it for the filter-field.

@thomaspink
Copy link
Contributor

The filter field creates a DtOptionDef via the dtGroupDef function. This function is called in the Datasource and can also take an uid. Only if no uid is provided the function creates it's own id based on the name and path.

@lukasholzer lukasholzer added the quick-filter Label for Quick filter issues label Sep 22, 2020
lukasholzer pushed a commit that referenced this issue Sep 25, 2020
This issue should be a further step to make the quick filter stable.

Fixes #1647
Fixes #1522
lukasholzer pushed a commit that referenced this issue Sep 25, 2020
This issue should be a further step to make the quick filter stable.

Fixes #1647
Fixes #1522
lukasholzer pushed a commit that referenced this issue Sep 28, 2020
This issue should be a further step to make the quick filter stable.

Fixes #1647
Fixes #1522
lukasholzer pushed a commit that referenced this issue Sep 28, 2020
This issue should be a further step to make the quick filter stable.

Fixes #1647
Fixes #1522
lukasholzer pushed a commit that referenced this issue Sep 29, 2020
This issue should be a further step to make the quick filter stable.

Fixes #1647
Fixes #1522
@lukasholzer lukasholzer self-assigned this Sep 29, 2020
lukasholzer pushed a commit that referenced this issue Sep 29, 2020
This issue should be a further step to make the quick filter stable.

Fixes #1647
Fixes #1522
lukasholzer pushed a commit that referenced this issue Oct 1, 2020
This issue should be a further step to make the quick filter stable.

Fixes #1647
Fixes #1522
github-actions bot pushed a commit that referenced this issue Oct 1, 2020
This issue should be a further step to make the quick filter stable.

Fixes #1647
Fixes #1522
github-actions bot pushed a commit that referenced this issue Oct 1, 2020
This issue should be a further step to make the quick filter stable.

Fixes #1647
Fixes #1522
yngrdyn pushed a commit to yngrdyn/barista that referenced this issue Nov 9, 2020
This issue should be a further step to make the quick filter stable.

Fixes dynatrace-oss#1647
Fixes dynatrace-oss#1522
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
has-pr quick-filter Label for Quick filter issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants