Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(advanced search): adding advanced search filter component & prereqs for it #6055

Conversation

gabe-lyons
Copy link
Contributor

This PR takes care of:

  • extending graphql model to support values in a single filter
  • adding the advanced search filter component itself which allows you to select a value & condition (negated or not)
  • the condition select component
  • some helper constants

Checklist

  • The PR conforms to DataHub's Contributing Guideline (particularly Commit Message Format)
  • Links to related issues (if applicable)
  • Tests for the changes have been added/updated (if applicable)
  • Docs related to the changes have been added/updated (if applicable). If a new feature has been added a Usage Guide has been added for the same.
  • For any breaking change/potential downtime/deprecation/big changes an entry has been made in Updating DataHub

@github-actions github-actions bot added the product PR or Issue related to the DataHub UI/UX label Sep 26, 2022
Comment on lines 160 to 170
values: [String!]

"""
Value of the field to filter by
"""
value: String!
"""
If the filter should or should not be matched
"""
negated: Boolean

"""
Condition for the values. How to If unset, assumed to be equality
"""
condition: SearchCondition
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this pr reformats things, but this is the only actual change to this file ^ aside from formatting.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the fyi!

@github-actions
Copy link

github-actions bot commented Sep 26, 2022

Unit Test Results (build & test)

584 tests  ±0   580 ✔️ ±0   13m 2s ⏱️ +10s
143 suites ±0       4 💤 ±0 
143 files   ±0       0 ±0 

Results for commit 87951ea. ± Comparison against base commit 6092875.

♻️ This comment has been updated with latest results.

Comment on lines 160 to 170
values: [String!]

"""
Value of the field to filter by
"""
value: String!
"""
If the filter should or should not be matched
"""
negated: Boolean

"""
Condition for the values. How to If unset, assumed to be equality
"""
condition: SearchCondition
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the fyi!

</CloseSpan>
</FieldFilterSection>
<ValueFilterSection>
{TEXT_FILTERS.indexOf(filter.field) === -1 &&
Copy link
Contributor

Choose a reason for hiding this comment

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

can we factor out this TEXT_FILTERS.indexOf(filter.field) === -1 and rename it as a boolean variable? it's a little confusing to read, and we do use it multiple times. I imagine this just means that the filters don't contain that filter field

Copy link
Contributor

Choose a reason for hiding this comment

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

also i think we should just use .includes()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for brining this up-- i realize we didn't need this logic at all

</FieldFilterSection>
<ValueFilterSection>
{TEXT_FILTERS.indexOf(filter.field) === -1 &&
filter?.values?.map((value) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

can this also be moved to not be inline and given a more descriptive name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i can make this its own component

value: '',
values: values as string[],
condition: filter.condition,
negated: filter.negated || false,
Copy link
Contributor

Choose a reason for hiding this comment

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

won't this always be filter.negated? if it's optional you could just do filter?.negated

];

function getLabelsForField(field: string) {
if (FIELDS_WHO_USE_CONTAINS_OPERATOR.indexOf(field) >= 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we just use .includes() here instead of indexOf? I think it makes the code a lot more confusing

const entityRegistry = useEntityRegistry();
const countText = aggregation.count === MAX_COUNT_VAL ? '10000+' : aggregation.count;
const countText = hideCount
Copy link
Contributor

Choose a reason for hiding this comment

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

thanks for refactoring this, it's a little cleaner!

origin: 'Environment',
};

export const FIELDS_WHO_USE_CONTAINS_OPERATOR = ['description', 'fieldDescriptions'];
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe FIELDS_THAT_USE_CONTAINS_OPERATOR?

margin: 4px;
`;

export const AdvancedSearchFilterValuesSection = ({ facet, filter }: Props) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, I think this is much more readable!

@gabe-lyons gabe-lyons merged commit 3eace64 into datahub-project:master Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product PR or Issue related to the DataHub UI/UX
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants