-
Notifications
You must be signed in to change notification settings - Fork 360
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
Add possibility to override feature flags with environment variable FEATURE_FLAGS #1372
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3c4fd14
Add env variable FEATURE_FLAGS for overriding flags with env
ofreyssinet-ledger e1aefef
Fix styling of LLD feature flags settings, trim input & hide programaβ¦
ofreyssinet-ledger 4723ae4
LLM feature flag settings: trim add flag input & hide programaticallβ¦
ofreyssinet-ledger 64b0e7c
Add hint on how to use the "add missing flag name" input
ofreyssinet-ledger 571ca9a
Fix bad "value" prop in inputs
ofreyssinet-ledger 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 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,5 @@ | ||
--- | ||
"live-mobile": patch | ||
--- | ||
|
||
Feature flags: take into account env variable FEATURE_FLAGS to override feature flags |
This file contains 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,5 @@ | ||
--- | ||
"ledger-live-desktop": patch | ||
--- | ||
|
||
Feature flags: take into account env variable FEATURE_FLAGS to override feature flags |
This file contains 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,6 @@ | ||
--- | ||
"@ledgerhq/live-common": patch | ||
"@ledgerhq/types-live": patch | ||
--- | ||
|
||
Add FEATURE_FLAGS env variable to override feature flags |
This file contains 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
248 changes: 0 additions & 248 deletions
248
...dger-live-desktop/src/renderer/screens/settings/sections/Developer/FeatureFlagsButton.tsx
This file was deleted.
Oops, something went wrong.
74 changes: 74 additions & 0 deletions
74
.../renderer/screens/settings/sections/Developer/FeatureFlagsSettings/FeatureFlagDetails.tsx
This file contains 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,74 @@ | ||
import React, { useCallback } from "react"; | ||
import ButtonV2 from "~/renderer/components/Button"; | ||
import { useFeatureFlags } from "@ledgerhq/live-common/featureFlags/index"; | ||
import { Text, Flex, Tag } from "@ledgerhq/react-ui"; | ||
import { FeatureId } from "@ledgerhq/types-live"; | ||
import { withV2StyleProvider } from "~/renderer/styles/StyleProvider"; | ||
import Box from "~/renderer/components/Box"; | ||
import FeatureFlagEdit from "./FeatureFlagEdit"; | ||
|
||
const OldButton = withV2StyleProvider(ButtonV2); | ||
|
||
type Props = { | ||
flagName: FeatureId; | ||
focused?: boolean; | ||
setFocusedName: (arg0: string | undefined) => void; | ||
}; | ||
|
||
const FeatureFlagDetails: React.FC<Props> = props => { | ||
const { flagName, focused, setFocusedName } = props; | ||
const { getFeature } = useFeatureFlags(); | ||
const flagValue = getFeature(flagName as FeatureId); | ||
|
||
const { | ||
overriddenByEnv, | ||
overridesRemote, | ||
enabledOverriddenForCurrentLanguage, | ||
enabledOverriddenForCurrentDesktopVersion, | ||
} = flagValue || {}; | ||
|
||
const handleClick = useCallback(() => { | ||
focused ? setFocusedName(undefined) : setFocusedName(flagName); | ||
}, [focused, flagName, setFocusedName]); | ||
|
||
if (!flagValue) return null; | ||
|
||
return ( | ||
<> | ||
<OldButton flexDirection="row" py={1} onClick={handleClick}> | ||
<Flex flex={1} mr={3} alignItems="center"> | ||
<Box | ||
bg={flagValue?.enabled ? "success.c100" : "error.c100"} | ||
height={10} | ||
width={10} | ||
mr={2} | ||
borderRadius={999} | ||
/> | ||
<Text mr={1}>{flagName}</Text> | ||
{overriddenByEnv ? ( | ||
<Tag active mx={1} type="opacity" size="small"> | ||
overridden by env | ||
</Tag> | ||
) : overridesRemote ? ( | ||
<Tag active mx={1} type="opacity" size="small"> | ||
overridden locally | ||
</Tag> | ||
) : null} | ||
{enabledOverriddenForCurrentLanguage ? ( | ||
<Tag active mx={1} type="outlinedOpacity" size="small"> | ||
disabled for current language | ||
</Tag> | ||
) : null} | ||
{enabledOverriddenForCurrentDesktopVersion ? ( | ||
<Tag active mx={1} type="outlinedOpacity" size="small"> | ||
disabled for current version | ||
</Tag> | ||
) : null} | ||
</Flex> | ||
</OldButton> | ||
{focused ? <FeatureFlagEdit flagName={flagName} flagValue={flagValue} /> : null} | ||
</> | ||
); | ||
}; | ||
|
||
export default FeatureFlagDetails; |
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.
if it's overriden by env, should remove be false? π€
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 still overrides the remote value, if the name of the variable was different I would have done what you are suggesting