Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

search ui: separate SymbolSearchResult component#42500

Merged
novoselrok merged 3 commits into
rn/result-container-refactorfrom
rn/separate-symbol-search-result-component
Oct 5, 2022
Merged

search ui: separate SymbolSearchResult component#42500
novoselrok merged 3 commits into
rn/result-container-refactorfrom
rn/separate-symbol-search-result-component

Conversation

@novoselrok

@novoselrok novoselrok commented Oct 4, 2022

Copy link
Copy Markdown
Contributor

Part of #42159

Summary

  • The majority of the changes in this PR come from consolidating all the "code link navigation" functions that were in the FileMatchChildren and CodeExcerpt  components (everything is copy-pasted into the codeLinkNavigation.ts file, no changes)
  • The important bit is moving the symbol rendering code from FileMatchChildren to a standalone SymbolSearchResult component
  • The shared SCSS styles are still a mess, I didn't want to take on too much w/ this PR. That's probably material for a separate PR.

Test plan

  • Should be covered by tests, no new functionality added.

App preview:

Check out the client app preview documentation to learn more.

@cla-bot cla-bot Bot added the cla-signed label Oct 4, 2022
@novoselrok novoselrok changed the title Add a separate SymbolSearchResult component. search ui: separate SymbolSearchResult component Oct 4, 2022
@novoselrok novoselrok marked this pull request as ready for review October 4, 2022 12:28
@sourcegraph-bot

sourcegraph-bot commented Oct 4, 2022

Copy link
Copy Markdown
Contributor

Codenotify: Notifying subscribers in CODENOTIFY files for diff adf71b0...70a56a1.

Notify File(s)
@fkling client/search-ui/src/components/CodeExcerpt.tsx
client/search-ui/src/components/FileMatchChildren.module.scss
client/search-ui/src/components/FileMatchChildren.tsx
client/search-ui/src/components/FileSearchResult.tsx
client/search-ui/src/components/ResultContainer.tsx
client/search-ui/src/components/SearchResult.module.scss
client/search-ui/src/components/SymbolSearchResult.module.scss
client/search-ui/src/components/SymbolSearchResult.tsx
client/search-ui/src/components/codeLinkNavigation.ts
client/search-ui/src/components/index.ts
client/search-ui/src/results/StreamingSearchResultsList.tsx
@limitedmage client/search-ui/src/components/CodeExcerpt.tsx
client/search-ui/src/components/FileMatchChildren.module.scss
client/search-ui/src/components/FileMatchChildren.tsx
client/search-ui/src/components/FileSearchResult.tsx
client/search-ui/src/components/ResultContainer.tsx
client/search-ui/src/components/SearchResult.module.scss
client/search-ui/src/components/SymbolSearchResult.module.scss
client/search-ui/src/components/SymbolSearchResult.tsx
client/search-ui/src/components/codeLinkNavigation.ts
client/search-ui/src/components/index.ts
client/search-ui/src/results/StreamingSearchResultsList.tsx
client/web/src/integration/search.test.ts

@novoselrok novoselrok requested review from a team, fkling and limitedmage October 4, 2022 13:09

@limitedmage limitedmage left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good! Left some questions and suggestions.

@@ -0,0 +1,32 @@
.symbols-override {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not sure why it's happening, but the Percy visual tests show regressions with line number alignment on symbol results.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There was a rouge SCSS style applied, I removed it, looks OK now.

index={index}
telemetryService={telemetryService}
result={result}
onSelect={() => logSearchResultClicked(index, 'fileMatch')}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we update this log to be specific to symbol results? (Same with the other. We should probably just log result.type everywhere.)

Comment on lines +191 to +199
<PrefetchableFile
isPrefetchEnabled={prefetchFileEnabled}
prefetch={prefetchFile}
filePath={result.path}
revision={getRevision(result.branches, result.commit)}
repoName={result.repository}
className={resultContainerStyles.resultContainer}
as="li"
>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This wrapper seems to be the same for content, path and symbol matches. An alternative here is to make an extra internal switch statement and have this same wrapper for all three "file-level" results. Another option is to move the prefetchable wrapper into the search result components so that they are always prefetchable.

@@ -14,13 +14,7 @@ import { MatchGroup, MatchItem } from '@sourcegraph/shared/src/components/rankin
import { ZoektRanking } from '@sourcegraph/shared/src/components/ranking/ZoektRanking'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Consider renaming this file/component to FileContentSearchResults?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll do that in a separate PR, I'm planning on refactoring the FileSearchResult/FileMatchChildren components as well.

return (
<Component
className={classNames('test-search-result', styles.resultContainer, className)}
className={classNames('test-search-result', className, styles.resultContainer)}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why reorder here? We usually want the passed-in styles to be able to override the default styles.

@novoselrok

novoselrok commented Oct 5, 2022

Copy link
Copy Markdown
Contributor Author

I'll merge this into the base PR to avoid a large PR stack. I'll work on refactoring the FileSearchResult component in a separate PR. You can still comment on this PR if needed.

@novoselrok novoselrok merged commit 037cf01 into rn/result-container-refactor Oct 5, 2022
@novoselrok novoselrok deleted the rn/separate-symbol-search-result-component branch October 5, 2022 09:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants