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(schema) Add search filter to Schema tab #5845

Conversation

chriscollins3456
Copy link
Collaborator

Adds the ability to filter search in the schema tab for datasets. Now you can type in the search bar and it will find fields where either their fieldPath, their glossary terms, or their tags match the filter text. Highlight what is matched in the UI.

Also, when making changes to the filter text we set a new query param in the url so that you can link someone to a filtered schema.

Here's what it looks like!

image

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

TableOutlined,
} from '@ant-design/icons';
import styled from 'styled-components';
import styled from 'styled-components/macro';
Copy link
Contributor

Choose a reason for hiding this comment

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

whats up with this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is what I mentioned to you some time back where if you import from /macro and look in the browser dev tools and check out the html, styled component names are shown, making it much easier to find what styled component is what

Copy link
Contributor

Choose a reason for hiding this comment

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

aahhh right! gotta start doing this myself

@@ -182,6 +194,12 @@ export default function SchemaHeader({
};
const schemaAuditToggleText = showSchemaAuditView ? 'Close column history' : 'View column history';

const debouncedSetFilterText = debounce(
(e: React.ChangeEvent<HTMLInputElement>) => setFilterText(e.target.value),
numRows > 50 ? 500 : 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

this can be named constants at the top rather than magic numbers

) : (
<ShowVersionButton onClick={() => setEditMode?.(true)}>Back</ShowVersionButton>
))}
<ShowVersionButton onClick={() => setEditMode?.(false)}>Version Blame</ShowVersionButton>
Copy link
Contributor

Choose a reason for hiding this comment

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

this diff intentional?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

no it's not! so sorry about that this is my bad - was just testing out how this looked with the button there - thanks for catching this

@@ -54,7 +56,9 @@ export default function useSchemaTitleRenderer(
return (
<>
<FieldPathContainer>
<FieldPathText>{pathToDisplay}</FieldPathText>
<FieldPathText>
<Highlight search={filterText}>{pathToDisplay}</Highlight>
Copy link
Contributor

Choose a reason for hiding this comment

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

fancy! bummer that it doesn't work on nested components though :/ i think we'll need to build that for our search cards otherwise we'll need to render like a zillion of these.

@github-actions
Copy link

github-actions bot commented Sep 6, 2022

Unit Test Results (build & test)

571 tests  ±0   571 ✔️ ±0   14m 31s ⏱️ +3s
141 suites ±0       0 💤 ±0 
141 files   ±0       0 ±0 

Results for commit d1f400c. ± Comparison against base commit 980e181.

♻️ This comment has been updated with latest results.

import { filterSchemaRows } from '../utils/filterSchemaRows';

describe('filterSchemaRows', () => {
it('should properly filter schema rows');
Copy link
Contributor

Choose a reason for hiding this comment

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

?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

wow i started this test and completely forgot about it - filling this out rn

setExpandedRows((previousRows) => new Set(previousRows.add(record.fieldPath)));
} else {
setExpandedRows((previousRows) => {
previousRows.delete(record.fieldPath);
Copy link
Contributor

Choose a reason for hiding this comment

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

tricky!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ugh i know - updating Sets in state isn't as simple as you'd want it to be

filterText: string,
filteredFieldPathsByMetadata: any,
) {
return fieldName.toLocaleLowerCase().includes(filterText) || filteredFieldPathsByMetadata.includes(fullFieldPath);
Copy link
Contributor

Choose a reason for hiding this comment

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

are we also toLowerCasing filterText?

Copy link
Collaborator Author

@chriscollins3456 chriscollins3456 Sep 7, 2022

Choose a reason for hiding this comment

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

yup! on line 45 right when we call filterSchemaRows i lowercase it and pass that around to these functions and other places so it's always lowercase comparisons

Comment on lines +62 to +68
// if we match specifically on this field (not just its parent), add and expand all parents
splitFieldPath.reduce((previous, current) => {
finalFieldPaths.add(previous);
expandedRowsFromFilter.add(previous);
return `${previous}.${current}`;
});
}
Copy link
Contributor

Choose a reason for hiding this comment

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

fancy!

@chriscollins3456 chriscollins3456 merged commit 3fb4fc3 into datahub-project:master Sep 9, 2022
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.

2 participants