-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Highlighted the description text on search #6400
Conversation
@@ -161,6 +169,9 @@ export default function DescriptionField({ description, onUpdate, isEdited = fal | |||
} | |||
suffix={EditButton} | |||
> | |||
{/* <Highlight matchStyle={highlightMatchStyle} search={highlightText}> |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this 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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed and committed!!
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 |
There was a problem hiding this comment.
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.
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 |
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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
{ fieldPath: 'customer', description: 'customer description', globalTags: null, glossaryTerms: null }, | ||
], | ||
}; | ||
const filterText = sampleTag.properties.name; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
matchesEditableTagsOrTermsOrDescription(row, filteredFieldPathsByEditableMetadata) || | ||
matchesEditableTagsOrTermsOrDescription(row, filteredFieldPathsByEditableMetadata) || | ||
matchesTagsOrTermsOrDescription(row, formattedFilterText, entityRegistry) || // non-editable tags and terms | ||
matchesDescription(row.description, formattedFilterText) // non-editable description |
There was a problem hiding this comment.
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
matchesEditableTagsOrTermsOrDescription(row, filteredFieldPathsByEditableMetadata) || | ||
matchesEditableTagsOrTermsOrDescription(row, filteredFieldPathsByEditableMetadata) || | ||
matchesTagsOrTermsOrDescription(row, formattedFilterText, entityRegistry) || // non-editable tags and terms | ||
matchesDescription(row.description, formattedFilterText) // non-editable description |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment here
There was a problem hiding this 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'; |
There was a problem hiding this comment.
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)
Checklist