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

[Search Result]: Add new layout page and file preview panel #58311

Merged
merged 13 commits into from Nov 27, 2023

Conversation

vovakulikov
Copy link
Contributor

@vovakulikov vovakulikov commented Nov 14, 2023

Closes #57800
Closes #57798

This PR does a few things on the search results page

  • Changes layout of the page (filters panel isn't scrollable with content anymore but scrolls independently within its own scroll block)
  • Search info panel is sticky and stays on top
  • But most important change is new file preview panel
With filters Without filters panel
Screenshot 2023-11-16 at 22 54 00 Screenshot 2023-11-16 at 22 54 09

Further steps

  • File panel preview uses inline search box to highlight search matches. This solution actually doesn't cover all cases (for example if query contains and or or operator file preview doesn't find any matches) Ideally we should use range info from the result block and highlight symbols in file preview by this data, but it requires a bit more attention and will be done in the follow PRs later. cc @fkling since you have more context on this I was hoping that we could work on this together.
  • Binary files currently fails with error since we don't support them, we shouldn't render "Preview" button in their result block.
  • Search box doesn't go with caseSensitive and regex button types from the main search box. (Meaning that if your query has pattern type regex file preview search box will show up without it). There is a problem with state management of this search panel cc @fkling maybe you can help me here.

cc @taiyab all changes are behind feature flag, I checked that the current UI hasn't got any regressions from these changes. Hence I don't believe we're blocked by design here. But if you have time and have any suggestions here please share it and I can either make it here or address in follow up PRs.

Test plan

  • Enable newSearchNavigationUI experimental feature flag
  • Check the search result page (you should be able to see and interact with filters, aggregation UI with no regressions)
  • Check file preview by clicking on preview button next to filename link in the result block

@vovakulikov vovakulikov self-assigned this Nov 14, 2023
@cla-bot cla-bot bot added the cla-signed label Nov 14, 2023
@vovakulikov vovakulikov force-pushed the vk/add-new-search-results-filters branch from 9cc534b to 81bac02 Compare November 17, 2023 01:52
@vovakulikov vovakulikov requested review from fkling and a team November 17, 2023 01:53
@vovakulikov vovakulikov marked this pull request as ready for review November 17, 2023 02:02
@sourcegraph-bot
Copy link
Contributor

sourcegraph-bot commented Nov 17, 2023

Codenotify: Notifying subscribers in CODENOTIFY files for diff 6ec6c7d...a5845c4.

Notify File(s)
@fkling client/branded/src/search-ui/components/FileContentSearchResult.tsx
client/branded/src/search-ui/components/FilePathSearchResult.tsx
client/branded/src/search-ui/components/ResultContainer.module.scss
client/branded/src/search-ui/components/ResultContainer.tsx
client/branded/src/search-ui/components/SearchResultPreviewButton.tsx
client/web/src/search/SearchConsolePage.tsx
client/web/src/search/results/CreateActions.module.scss
client/web/src/search/results/CreateActionsMenu.tsx
client/web/src/search/results/StreamingSearchResults.story.tsx
client/web/src/search/results/StreamingSearchResults.test.tsx
client/web/src/search/results/StreamingSearchResults.tsx
client/web/src/search/results/components/SearchActionsMenu.tsx
client/web/src/search/results/components/SearchAlert.tsx
client/web/src/search/results/components/UnownedResultsAlert.tsx
client/web/src/search/results/components/new-search-content/NewSearchContent.module.scss
client/web/src/search/results/components/new-search-content/NewSearchContent.tsx
client/web/src/search/results/components/search-content/SearchContent.module.scss
client/web/src/search/results/components/search-content/SearchContent.tsx
client/web/src/search/results/components/search-results-info-bar/SearchResultsInfoBar.module.scss
client/web/src/search/results/components/search-results-info-bar/SearchResultsInfoBar.test.tsx
client/web/src/search/results/components/search-results-info-bar/SearchResultsInfoBar.tsx
client/web/src/search/results/components/search-results-info-bar/snapshots/SearchResultsInfoBar.test.tsx.snap
client/web/src/search/results/components/search-results-info-bar/createActions.ts
client/web/src/search/results/components/utils.ts
client/web/src/search/results/sidebar/SearchFiltersSidebar.tsx
client/web/src/search/results/useStreamingSearchPings.ts

@sourcegraph-bot
Copy link
Contributor

sourcegraph-bot commented Nov 17, 2023

Codenotify: Notifying subscribers in OWNERS files for diff 6ec6c7d...a5845c4.

Notify File(s)
@sourcegraph/code-exploration-devs client/wildcard/BUILD.bazel
client/wildcard/src/components/Panel/useResizablePanel.ts
client/wildcard/src/hooks/index.ts
client/wildcard/src/hooks/useScrollManager/index.ts
client/wildcard/src/hooks/useScrollManager/mutationObserverWithTimeout.ts
client/wildcard/src/hooks/useScrollManager/useScrollManager.test.tsx
client/wildcard/src/hooks/useScrollManager/useScrollManager.ts

@sourcegraph-bot
Copy link
Contributor

sourcegraph-bot commented Nov 17, 2023

📖 Storybook live preview

Copy link
Contributor

@taiyab taiyab left a comment

Choose a reason for hiding this comment

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

Looks great @vovakulikov. Incredible work!

Not too fussed with design on it as of yet considering it's behind a feature flag.

I'm currently working on search results. I'll add an updated concept for this panel with any ideas I have to the designs in a second pass for this.

Amazing work.

Copy link
Contributor

@fkling fkling left a comment

Choose a reason for hiding this comment

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

Implementation seems fine (as always). From a UX perspective I'm worried that with the preview panel open I see even less search results. Also I think it would make more useful if the preview could be opened at a particular search result, not at the top of the file.

But I assume that's somewhere on the roadmap and this is the initial version.

client/web/src/repo/blob/codemirror/types.ts Outdated Show resolved Hide resolved
Comment on lines +213 to +277
return !newSearchNavigation ? (
<SearchContent
submittedURLQuery={submittedURLQuery}
queryState={queryState}
liveQuery={liveQuery}
allExpanded={allExpanded}
searchMode={searchMode}
trace={!!trace}
searchContextsEnabled={props.searchContextsEnabled}
patternType={patternType}
results={results}
showAggregationPanel={showAggregationPanel}
selectedSearchContextSpec={props.selectedSearchContextSpec}
aggregationUIMode={aggregationUIMode}
caseSensitive={caseSensitive}
authenticatedUser={authenticatedUser}
isSourcegraphDotCom={isSourcegraphDotCom}
enableRepositoryMetadata={enableRepositoryMetadata}
options={options}
codeMonitoringEnabled={codeMonitoringEnabled}
fetchHighlightedFileLineRanges={props.fetchHighlightedFileLineRanges}
onNavbarQueryChange={setQueryState}
onSearchSubmit={handleSidebarSearchSubmit}
onQuerySubmit={handleSearchAggregationBarClick}
onExpandAllResultsToggle={onExpandAllResultsToggle}
onSearchAgain={onSearchAgain}
onDisableSmartSearch={onDisableSmartSearch}
onLogSearchResultClick={logSearchResultClicked}
settingsCascade={props.settingsCascade}
telemetryService={telemetryService}
platformContext={platformContext}
/>
) : (
<NewSearchContent
submittedURLQuery={submittedURLQuery}
queryState={queryState}
liveQuery={liveQuery}
allExpanded={allExpanded}
searchMode={searchMode}
trace={!!trace}
searchContextsEnabled={props.searchContextsEnabled}
patternType={patternType}
results={results}
showAggregationPanel={showAggregationPanel}
selectedSearchContextSpec={props.selectedSearchContextSpec}
aggregationUIMode={aggregationUIMode}
caseSensitive={caseSensitive}
authenticatedUser={authenticatedUser}
isSourcegraphDotCom={isSourcegraphDotCom}
enableRepositoryMetadata={enableRepositoryMetadata}
options={options}
codeMonitoringEnabled={codeMonitoringEnabled}
fetchHighlightedFileLineRanges={props.fetchHighlightedFileLineRanges}
onNavbarQueryChange={setQueryState}
onSearchSubmit={handleSidebarSearchSubmit}
onQuerySubmit={handleSearchAggregationBarClick}
onExpandAllResultsToggle={onExpandAllResultsToggle}
onSearchAgain={onSearchAgain}
onDisableSmartSearch={onDisableSmartSearch}
onLogSearchResultClick={logSearchResultClicked}
settingsCascade={props.settingsCascade}
telemetryService={telemetryService}
platformContext={platformContext}
extensionsController={extensionsController}
/>
Copy link
Contributor

Choose a reason for hiding this comment

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

Any chance this could be done without having to create two separate components? (I don't have high hopes but I still want to ask 😆 )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hehe, I tried inline changes behind the feature flag, but since this PR has layout and logic changes, I found it very complex to unwrap these behind-feature-flag changes combined with the main logic. Having two components adds some legacy I think but it would be very easy for us to either migrate to a new one or revert to the old version when the time comes.

@vovakulikov vovakulikov force-pushed the vk/add-new-search-results-filters branch from e231782 to 13bb4fb Compare November 27, 2023 15:27
@vovakulikov
Copy link
Contributor Author

Thanks for the review @fkling

Also I think it would be more useful if the preview could be opened at a particular search result, not at the top of the file.

Agreed, at the moment, it should work in some query cases since we open inline-search in the blob UI automatically as we render the blob UI component, it should focus on the first matches and scroll to its match's line, but it doesn't work in all cases; basically, it could be the case when query resolves some matches that are not presented in the query. (basically any OR and AND operator will do this)

In theory we could just use matches info from the search blob components and make matches jump in the blob UI based on this info but this will require further improvements in the blob UI (this is something that I wanted to talk about earlier)

@vovakulikov vovakulikov merged commit e55d854 into main Nov 27, 2023
14 checks passed
@vovakulikov vovakulikov deleted the vk/add-new-search-results-filters branch November 27, 2023 16:09
vovakulikov added a commit that referenced this pull request Dec 12, 2023
* Extract search result page layout into separate component

* Create new search result page layout

* Fix styles problem

* Connect file preview UI with preview preview button in the results blocks UI

* Add active by default inline search for file preview panel

* Sync file preview and info bar header heights

* Close the panel on query re-submit

* Make side blob lazy loaded

* Fix ts problem in no results page

* Fix ts problems

* Fix eslint problems

* Update search result info bar snapshots

* Add comments to Search Panel View Modes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Search results]: Add preview panel UI [Search Results]: Visual changes, preparation for further features
4 participants