-
Notifications
You must be signed in to change notification settings - Fork 86
Add Beta Features menu #1860
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
Merged
Merged
Add Beta Features menu #1860
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
bb78281
Add Beta Features menu with storage support
wojtekn af7158a
Expose Sites CLI as beta feature
wojtekn e079b42
Fix TS issue popping up during tests
wojtekn cb0ec54
Clean up beta features storage code
wojtekn bb91703
Experiment with menu item label
wojtekn 19244ac
Improve new menu experience on Windows
wojtekn d4e7aaa
Remove unnecessary exports
wojtekn 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import { lockAppdata, unlockAppdata, loadUserData, saveUserData } from 'src/storage/user-data'; | ||
|
|
||
| export interface BetaFeatureDefinition { | ||
| label: string; | ||
| key: string; | ||
| default: boolean; | ||
| description?: string; | ||
| } | ||
|
|
||
| const BETA_FEATURES_DEFINITION: Record< keyof BetaFeatures, BetaFeatureDefinition > = { | ||
| studioSitesCli: { | ||
| label: 'Studio Sites CLI', | ||
| key: 'studioSitesCli', | ||
| default: false, | ||
| description: '"studio site" command to manage local sites from terminal', | ||
| }, | ||
| } as const; | ||
|
|
||
| export const BETA_FEATURES: Record< keyof BetaFeatures, BetaFeatureDefinition > = | ||
| BETA_FEATURES_DEFINITION; | ||
|
|
||
| function buildBetaFeatures( userData: BetaFeatures | undefined ): BetaFeatures { | ||
| const features: Partial< BetaFeatures > = {}; | ||
| const keys = Object.keys( BETA_FEATURES ); | ||
| keys.forEach( ( key ) => { | ||
| const featureKey = key as keyof BetaFeatures; | ||
| const definition = BETA_FEATURES[ featureKey ]; | ||
| ( features as Record< string, boolean > )[ key ] = | ||
| userData?.[ featureKey ] ?? definition.default; | ||
| } ); | ||
| return features as BetaFeatures; | ||
| } | ||
|
|
||
| export async function getBetaFeatures(): Promise< BetaFeatures > { | ||
| const userData = await loadUserData(); | ||
| return buildBetaFeatures( userData.betaFeatures ); | ||
| } | ||
|
|
||
| export async function updateBetaFeature( | ||
| key: keyof BetaFeatures, | ||
| value: boolean | ||
| ): Promise< void > { | ||
| try { | ||
| await lockAppdata(); | ||
| const userData = await loadUserData(); | ||
| const betaFeatures: BetaFeatures = userData.betaFeatures || ( {} as BetaFeatures ); | ||
| betaFeatures[ key ] = value; | ||
| userData.betaFeatures = betaFeatures; | ||
| await saveUserData( userData ); | ||
| } finally { | ||
| await unlockAppdata(); | ||
| } | ||
| } |
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
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.
It seems we don't need it. Also we can remove it from
FeatureFlags.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.
Wasn't it left here to limit the number of changes we need to make when we remove the last feature flag?