This repository was archived by the owner on Sep 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Change useExperimentalFeatures to use the new useSettings API
#48125
Merged
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d254bd9
Change `useExperimentalFeatures` to use the new `useSettings` API
philipp-spiess 28646f6
Remove more leftovers
philipp-spiess 5b8111b
Revert changes to package.json
philipp-spiess d0db1a9
Fix TypeScript issues
philipp-spiess 2f055d5
Provide settings context in Storybook
philipp-spiess 0e5a21d
Default to an empty settings cascade but warn when not in test mode
philipp-spiess 21d2c65
Fix two tests
philipp-spiess c5b5cc1
Use logger API over console.log
philipp-spiess a594675
Merge remote-tracking branch 'origin/main' into ps/change-useExperime…
philipp-spiess File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 21 additions & 16 deletions
37
client/web/src/components/fuzzyFinder/FuzzyFinderFeatureFlag.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,26 @@ | ||
| import { SettingsExperimentalFeatures } from '@sourcegraph/shared/src/schema/settings.schema' | ||
| import { Settings, SettingsCascadeOrError } from '@sourcegraph/shared/src/settings/settings' | ||
| import type { SettingsExperimentalFeatures } from '@sourcegraph/shared/src/schema/settings.schema' | ||
| import { useExperimentalFeatures } from '@sourcegraph/shared/src/settings/settings' | ||
|
|
||
| import { getExperimentalFeatures } from '../../util/get-experimental-features' | ||
|
|
||
| export function getFuzzyFinderFeatureFlags( | ||
| finalSettings?: SettingsCascadeOrError<Settings>['final'] | ||
| ): Pick< | ||
| export function useFuzzyFinderFeatureFlags(): Pick< | ||
| SettingsExperimentalFeatures, | ||
| 'fuzzyFinderAll' | 'fuzzyFinderActions' | 'fuzzyFinderRepositories' | 'fuzzyFinderSymbols' | 'fuzzyFinderNavbar' | ||
| > { | ||
| let { fuzzyFinderAll, fuzzyFinderActions, fuzzyFinderRepositories, fuzzyFinderSymbols, fuzzyFinderNavbar } = | ||
| getExperimentalFeatures(finalSettings) | ||
| // enable fuzzy finder unless it's explicitly disabled in settings | ||
| fuzzyFinderAll = fuzzyFinderAll ?? true | ||
| // Intentionally skip fuzzyFinderActions because we don't have enough actions implemented | ||
| // Intentionally skip fuzzyFinderNavbar because the navbar is already too busy and we need to explore alternative solutions for the discoverability problem | ||
| fuzzyFinderRepositories = fuzzyFinderAll || fuzzyFinderRepositories | ||
| fuzzyFinderSymbols = fuzzyFinderAll || fuzzyFinderSymbols | ||
| return { fuzzyFinderAll, fuzzyFinderActions, fuzzyFinderRepositories, fuzzyFinderSymbols, fuzzyFinderNavbar } | ||
| return useExperimentalFeatures(features => { | ||
| let { fuzzyFinderAll, fuzzyFinderActions, fuzzyFinderRepositories, fuzzyFinderSymbols, fuzzyFinderNavbar } = | ||
| features | ||
|
|
||
| // enable fuzzy finder unless it's explicitly disabled in settings | ||
| fuzzyFinderAll = fuzzyFinderAll ?? true | ||
| // Intentionally skip fuzzyFinderActions because we don't have enough actions implemented | ||
| // Intentionally skip fuzzyFinderNavbar because the navbar is already too busy and we need to explore alternative solutions for the discoverability problem | ||
| fuzzyFinderRepositories = fuzzyFinderAll || fuzzyFinderRepositories | ||
| fuzzyFinderSymbols = fuzzyFinderAll || fuzzyFinderSymbols | ||
| return { | ||
| fuzzyFinderAll, | ||
| fuzzyFinderActions, | ||
| fuzzyFinderRepositories, | ||
| fuzzyFinderSymbols, | ||
| fuzzyFinderNavbar, | ||
| } | ||
| }) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The
console.xmethods are banned so we don't forget them in our PRs and to allow us to control the console output in place, where we potentially can send these logs/errors to other services like Sentry, Honeycomb, etc.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.
Cool. Is there a way to extend the error message here to explain this?
We have a lot of annoying eslint rules so I just try to make them go away quickly. In this case, I wasn't aware that this is for a good reason and the message didn't explain it either.
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.
True, we also have a bunch of duplicate rules because of multiple plugins we use. Let's raise this in #chat-frontend next time it happens so we can remove redundant rules and better document others.
There's no super straightforward way to do it AFAIK. We cannot use
no-restricted-syntaxbecause it already has a warning level. We cannot add a custom message to theno-consolerule, according to the docs. We can probably create a custom rule and add our message there. Let me know if you see a better way. Here's the related section in our documentation that can be used in the custom error message.