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

Code insights: Add new repositories UI field #45687

Merged
vovakulikov merged 43 commits into
mainfrom
vk/new-insight-repo-ui
Jan 24, 2023
Merged

Code insights: Add new repositories UI field #45687
vovakulikov merged 43 commits into
mainfrom
vk/new-insight-repo-ui

Conversation

@vovakulikov

@vovakulikov vovakulikov commented Dec 15, 2022

Copy link
Copy Markdown
Contributor

Closes https://github.com/sourcegraph/sourcegraph/issues/45427

Useful links

How to test

Locally

  • Check out this PR branch
  • Run sg start web-standalone or any other command that runs FE locally
  • After that you should be able to see new insight creation UI (by default it's two fields for the repo section)
  • You can change to the "one field approach" by editing codeInsightsRepoUI experimental feature flag in the setting (possible values "single-search-query", "search-query-or-strict-list")

Remote

  • Go to the special staging here
  • You should see the new repo UI there, you can change UI variation in the same way as it's described in the "Local" section above.

Backround

This PR changes the repositories UI field for the insight creation UI (search-based and capture group insight creation forms). It adds a new field UI that can be run in two different modes.

  • Single repositories search UI (you can see this mode with codeInsightsRepoUI: 'single-search-query' in experimentalFeatures setting cascade section)

Screenshot 2022-12-16 at 17 33 00

  • And repositories search UI + direct list URLs field (the one that we had before this PR) (you can see this mode with codeInsightsRepoUI: 'search-query-or-strict-list', in experimentalFeatures setting cascade section)

Screenshot 2022-12-16 at 17 32 22

Todo list

  • Add setting cascade feature flag
  • Implement both modes of UI
  • Add logic for the edit UI (before this PR, we had all repositories mode checkbox, new modes don't have it, in case of all repositories mode is on, we add repo:.* to the search repositories query field which should be fully equivalent to the all repos mode that we had before)
  • Fix 1-click creation flow for the search-based info (now we just put all repo-related filters to the search repo query field and put the rest of the query from the search result page in the first series query field)
  • Connect new UI to the new strat-scoped API handlers - repo query BE validation handler, repositories count info and live preview API
  • Add validation info to the new repositories section in the form (how many repositories were resolved by a given repositories query (search repo query field value)

Test plan

  • Check that the new UI works and looks as expected
  • Check that the 1-click creation flow works as expected
  • Check that editing functionality works as it worked before (especially check that all repositories mode has a proper fallback on the repo:.* value in the search repo field
  • Check that insight templates work as they worked before without any runtime or missing field problems.

App preview:

Check out the client app preview documentation to learn more.

@cla-bot cla-bot Bot added the cla-signed label Dec 15, 2022
@vovakulikov vovakulikov self-assigned this Dec 15, 2022
@sg-e2e-regression-test-bob

sg-e2e-regression-test-bob commented Dec 15, 2022

Copy link
Copy Markdown

Bundle size report 📦

Initial size Total size Async size Modules
0.03% (+0.70 kb) 0.07% (+9.97 kb) 🔺 0.08% (+9.27 kb) 0.14% (+1) 🔺

Look at the Statoscope report for a full comparison between the commits 3437b94 and 936ad3e or learn more.

Open explanation
  • Initial size is the size of the initial bundle (the one that is loaded when you open the page)
  • Total size is the size of the initial bundle + all the async loaded chunks
  • Async size is the size of all the async loaded chunks
  • Modules is the number of modules in the initial bundle

@chwarwick

Copy link
Copy Markdown
Contributor

@vovakulikov I didn't make it all the way though this but did see a small issue in the create. If you have data in both a repo search and a list of repos it sends both to the mutation. The mutation rejects it because it's not sure which one is correct.

@chwarwick

Copy link
Copy Markdown
Contributor

Another thing I noticed is that entering repo: and selecting a repo suggestion doesn't add the regex anchors like it does in the regular search input. So I end up with repo:github.com/sourcegraph/sourcegraph instead of repo:^github\.com/sourcegraph/sourcegraph$

@vovakulikov vovakulikov force-pushed the vk/new-insight-repo-ui branch from ab927a0 to 52ecbe4 Compare December 20, 2022 19:10

@AlicjaSuska AlicjaSuska 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.

Thank you for making those changes @vovakulikov (I love that the repo count works! It's awesome). Here is the design QA page with all the design details I've spotted.

@vovakulikov vovakulikov force-pushed the vk/new-insight-repo-ui branch from 30d9a02 to c9d6caa Compare December 21, 2022 15:54
@vovakulikov vovakulikov force-pushed the vk/new-insight-repo-ui branch from a17bdfa to 4520fac Compare January 3, 2023 19:34
@vovakulikov vovakulikov marked this pull request as ready for review January 11, 2023 22:45
@vovakulikov vovakulikov changed the title Vk/new insight repo UI Code insights: Add new repositories UI field Jan 11, 2023

@valerybugakov valerybugakov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Tested the feature locally and left a couple of optional comments!

// required
const isRepoURLsListRequired = isSearchQueryORUrlsList && isURLsListMode

const validateRepoQuerySyntax = useMemo(() => createValidateRepoQuerySyntax(apolloClient), [apolloClient])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would useLazyQuery work here instead of useApolloClient?

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.

Yeah I think it would work, but I still would have needed wrap it with useMemo because field validator API expects to have boolean from validation function and validators always should be not re-rendered on each render call otherwise it all will fail with recursive error.

Comment thread client/wildcard/src/components/Form/Input/Input.tsx
Comment on lines +15 to +27
InputDescription,
InputErrorMessage,
InputElement,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What are the reasons for exposing these components? Would it be possible to implement the same functionality relying only on the Input component?

Context: we discussed exposing these earlier while we worked on the Wildcard v2 and decided to export only the higher level Input component to keep things consistent in the UI because it would limit the number of combinations that consumers can create (e.g., label + input + error + description). Understanding the motivation behind lowering the abstraction level here would be great.

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.

Yeah, basically I had to have this element, because Input component for example always returns wrapped with LoadingInput component layout. Sometimes it returns wrapped with Label layout. I see that consistency here is already broken. You have to care about different input layout combination every time you use Input element.

For my particular case I use Searchbox Input with standard Input layout (error message, label, etc) The search box itself provides loading state, in order to decouple loading from Input component I extracted Input Element.

Also in my case I need to put preview button in one line with input and that error or description message were below this line with input and preview button, with current Input API this ins't possible, I could extend it but I would have became even more complicated rather than now. So I decide that low-level abstractions here are necessary.

@vovakulikov vovakulikov force-pushed the vk/new-insight-repo-ui branch from f9b5943 to 824b7c3 Compare January 13, 2023 16:56
@sourcegraph-bot

sourcegraph-bot commented Jan 13, 2023

Copy link
Copy Markdown
Contributor

Codenotify: Notifying subscribers in CODENOTIFY files for diff c8f520b...3437b94.

Notify File(s)
@limitedmage client/web/src/enterprise/code-monitoring/components/snapshots/FormActionArea.test.tsx.snap

@sourcegraph-bot

sourcegraph-bot commented Jan 13, 2023

Copy link
Copy Markdown
Contributor

Codenotify: Notifying subscribers in OWNERS files for diff c8f520b...3437b94.

Notify File(s)
@sourcegraph/code-exploration-devs client/common/src/util/string.test.ts
client/common/src/util/strings.ts
client/wildcard/src/components/Combobox/Combobox.tsx
client/wildcard/src/components/Form/Input/Input.module.scss
client/wildcard/src/components/Form/Input/Input.story.tsx
client/wildcard/src/components/Form/Input/Input.test.tsx
client/wildcard/src/components/Form/Input/Input.tsx
client/wildcard/src/components/Form/Input/snapshots/Input.test.tsx.snap
client/wildcard/src/components/index.ts

@github-actions

Copy link
Copy Markdown
Contributor

Problem: the label i-acknowledge-this-goes-into-the-release is absent.
👉 What to do: we're in the next Sourcegraph release code freeze period. If you are 100% sure your changes should get released or provide no risk to the release, add the label your PR with i-acknowledge-this-goes-into-the-release.

@vovakulikov vovakulikov force-pushed the vk/new-insight-repo-ui branch from 9302c29 to b2fcfb0 Compare January 18, 2023 01:47
@vovakulikov vovakulikov force-pushed the vk/new-insight-repo-ui branch from b2fcfb0 to 52e5333 Compare January 23, 2023 23:52
@vovakulikov vovakulikov merged commit d318069 into main Jan 24, 2023
@vovakulikov vovakulikov deleted the vk/new-insight-repo-ui branch January 24, 2023 01:29
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.

Code Insight: New strat scoped insight repo UI prototype

7 participants