Commit 85e973c3 authored by tom's avatar tom

total search result num

parent 40025c02
...@@ -90,6 +90,28 @@ const CodeEditorSearch = ({ monaco, data, onFileSelect, isInputStuck }: Props) = ...@@ -90,6 +90,28 @@ const CodeEditorSearch = ({ monaco, data, onFileSelect, isInputStuck }: Props) =
borderColor: 'transparent', borderColor: 'transparent',
}; };
const searchResultNum = (() => {
if (!debouncedSearchTerm) {
return null;
}
const totalResults = searchResults.map(({ matches }) => matches.length).reduce((result, item) => result + item, 0);
if (!totalResults) {
return (
<Box px="8px" fontSize="13px" lineHeight="18px" mb="8px">
No results found. Review your settings for configured exclusions.
</Box>
);
}
return (
<Box px="8px" fontSize="13px" lineHeight="18px" mb="8px">
{ totalResults } result{ totalResults > 1 ? 's' : '' } in { searchResults.length } file{ searchResults.length > 1 ? 's' : '' }
</Box>
);
})();
return ( return (
<Box> <Box>
<CoderEditorCollapseButton <CoderEditorCollapseButton
...@@ -158,13 +180,13 @@ const CodeEditorSearch = ({ monaco, data, onFileSelect, isInputStuck }: Props) = ...@@ -158,13 +180,13 @@ const CodeEditorSearch = ({ monaco, data, onFileSelect, isInputStuck }: Props) =
/> />
</InputRightElement> </InputRightElement>
</InputGroup> </InputGroup>
{ searchResultNum }
<Accordion <Accordion
key={ debouncedSearchTerm } key={ debouncedSearchTerm }
allowMultiple allowMultiple
index={ expandedSections } index={ expandedSections }
onChange={ handleAccordionStateChange } onChange={ handleAccordionStateChange }
reduceMotion reduceMotion
mt="4px"
> >
{ searchResults.map((item) => <CodeEditorSearchSection key={ item.file_path } data={ item } onItemClick={ handleResultItemClick }/>) } { searchResults.map((item) => <CodeEditorSearchSection key={ item.file_path } data={ item } onItemClick={ handleResultItemClick }/>) }
</Accordion> </Accordion>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment