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

Highlighted the description text on search #6400

Conversation

Ankit-Keshari-Vituity
Copy link
Contributor

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 Nov 10, 2022
@github-actions
Copy link

github-actions bot commented Nov 10, 2022

Unit Test Results (build & test)

622 tests  +9   618 ✔️ +9   15m 49s ⏱️ + 3m 51s
157 suites +6       4 💤 ±0 
157 files   +6       0 ±0 

Results for commit 8f38f4c. ± Comparison against base commit ae2ea52.

♻️ This comment has been updated with latest results.

@@ -161,6 +169,9 @@ export default function DescriptionField({ description, onUpdate, isEdited = fal
}
suffix={EditButton}
>
{/* <Highlight matchStyle={highlightMatchStyle} search={highlightText}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this here? Can we remove

@@ -69,7 +69,7 @@ export default function SchemaTable({
const [selectedFkFieldPath, setSelectedFkFieldPath] =
useState<null | { fieldPath: string; constraint?: ForeignKeyConstraint | null }>(null);

const descriptionRender = useDescriptionRenderer(editableSchemaMetadata);
const descriptionRender = useDescriptionRenderer(editableSchemaMetadata, filterText);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Where do we actually search the fields for this text?

Copy link
Collaborator

@chriscollins3456 chriscollins3456 left a comment

Choose a reason for hiding this comment

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

nice! i have a suggestion on how to clean this up a bit, though, which should also improve filtering performance (minimize the number of times we need to loop through the list of rows)

could you also add tests to filterSchemaRows.test.ts?

@@ -47,14 +71,19 @@ export function filterSchemaRows(
entityRegistry,
formattedFilterText,
);

const filteredEditableDescription = getDescriptionFieldPathsByMetadata(editableSchemaMetadata, formattedFilterText);
Copy link
Collaborator

Choose a reason for hiding this comment

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

since we need to do slightly more work for checking things inside of editableSchemaMetadata and we're already doing that in getFilteredFieldPathsByMetadata, how do you feel about moving the edited description filter check inside of that function? that way we just have one checking for things in editableSchemaMetadata.

We could then just have one filter function for matchesDescription like you already have that is reused between that function and down below similar to how matchesTagsOrTerms is being used twice

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Worked on that and committed the changes. Please check.

Copy link
Collaborator

@chriscollins3456 chriscollins3456 left a comment

Choose a reason for hiding this comment

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

nice! this is looking real close, just a few changes requested

function matchesDescription(fieldDescription: any, filterText: string) {
return fieldDescription?.toLocaleLowerCase().includes(filterText);
}

function matchesEditableTagsOrTerms(field: SchemaField, filteredFieldPathsByEditableMetadata: any) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

now that filteredFieldPathsByEditableMetadata is also checking by description, you can rename this function matchesEditableTagsOrTermsOrDescription

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed and committed!!

Comment on lines 66 to 69
matchesEditableTagsOrTerms(row, filteredFieldPathsByEditableMetadata) ||
matchesTagsOrTerms(row, formattedFilterText, entityRegistry) // non-editable tags and terms
matchesEditableDescription(row, filteredFieldPathsByEditableMetadata) ||
matchesTagsOrTermsOrDescription(row, formattedFilterText, entityRegistry) || // non-editable tags and terms
matchesDescription(row.description, formattedFilterText) // non-editable description
Copy link
Collaborator

Choose a reason for hiding this comment

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

since we can rename matchesEditableTagsOrTerms to matchesEditableTagsOrTermsOrDescription with the new functionality change, we don't need matchedEditableDescription here. also, since you're calling matchesTagsOrTermsOrDescription for non-editable info, you don't need matchesDescription either.

Comment on lines 77 to 80
matchesEditableTagsOrTerms(row, filteredFieldPathsByEditableMetadata) ||
matchesTagsOrTerms(row, formattedFilterText, entityRegistry)
matchesEditableDescription(row, filteredFieldPathsByEditableMetadata) ||
matchesTagsOrTermsOrDescription(row, formattedFilterText, entityRegistry) || // non-editable tags and terms
matchesDescription(row.description, formattedFilterText) // non-editable description
Copy link
Collaborator

Choose a reason for hiding this comment

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

same thing here, we can just check matchesFieldName, matchesEditableTagsOrTermsOrDescription, and matchesTagsOrTermsOrDescription

@@ -35,6 +39,52 @@ describe('filterSchemaRows', () => {
expect(expandedRowsFromFilter).toMatchObject(new Set());
});

it('should properly filter schema rows based on description', () => {
const filterText = 'test';
Copy link
Collaborator

Choose a reason for hiding this comment

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

"test" here will actually also match on the fieldPath. can you make this more specific to test that we're only matching on description? so you could just change this to const filterText = 'testing description';


it('should properly filter schema rows based on description regardless of capitalization', () => {
const editableSchemaMetadata = { editableSchemaFieldInfo: [] };
const filterText = 'TeSt';
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here, can you change to 'TeSting DesCriptioN'? or to that effect

Comment on lines 73 to 76
{ fieldPath: 'customer', description: 'customer description', globalTags: null, glossaryTerms: null },
],
};
const filterText = sampleTag.properties.name;
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you make this description in editableSchemaFieldInfo something different to make sure we're testing that it's matching specifically on that? so you can change it to description: 'editable customer description' and then make the filter text editable customer description

Copy link
Collaborator

Choose a reason for hiding this comment

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

then can you add one more test that's just like this but checking that we're filtering regardless of capitalization?

Comment on lines 62 to 65
matchesEditableTagsOrTermsOrDescription(row, filteredFieldPathsByEditableMetadata) ||
matchesEditableTagsOrTermsOrDescription(row, filteredFieldPathsByEditableMetadata) ||
matchesTagsOrTermsOrDescription(row, formattedFilterText, entityRegistry) || // non-editable tags and terms
matchesDescription(row.description, formattedFilterText) // non-editable description
Copy link
Collaborator

Choose a reason for hiding this comment

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

so you don't need matchesEditableTagsOrTermsOrDescription twice, you can remove one of them.

Also you can remove matchesDescription since we're already checking for that in matchesTagsOrTermsOrDescription

Comment on lines 73 to 76
matchesEditableTagsOrTermsOrDescription(row, filteredFieldPathsByEditableMetadata) ||
matchesEditableTagsOrTermsOrDescription(row, filteredFieldPathsByEditableMetadata) ||
matchesTagsOrTermsOrDescription(row, formattedFilterText, entityRegistry) || // non-editable tags and terms
matchesDescription(row.description, formattedFilterText) // non-editable description
Copy link
Collaborator

Choose a reason for hiding this comment

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

same comment here

Copy link
Collaborator

@chriscollins3456 chriscollins3456 left a comment

Choose a reason for hiding this comment

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

nice! i have one minor comment on one of your test cases, but otherwise this is good to go

},
],
};
const filterText = 'EdiTable CuStoMer DesCriptioN';
Copy link
Collaborator

Choose a reason for hiding this comment

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

isn't the point of this test to check that capitalization doesn't matter? I'd just make this all lowercase to actually test that (as opposed to the same piece of text that's in the description)

@chriscollins3456 chriscollins3456 merged commit 7ff765e into datahub-project:master Nov 17, 2022
cccs-Dustin pushed a commit to CybercentreCanada/datahub that referenced this pull request Feb 1, 2023
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.

3 participants