Skip to content

Commit

Permalink
Onboarding feature flag (#1398)
Browse files Browse the repository at this point in the history
* refactor: add feature flag

* fix: update dependencies

* add onboarding to env file
  • Loading branch information
tomjeatt authored Jul 4, 2023
1 parent 304517b commit 3473509
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions .env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ REACT_APP_FEATURE_FLAG_AMM=enabled
REACT_APP_FEATURE_FLAG_WALLET=enabled
REACT_APP_FEATURE_FLAG_BANXA=enabled
REACT_APP_FEATURE_FLAG_STRATEGIES=enabled
REACT_APP_FEATURE_FLAG_ONBOARDING=enabled

/* DEVELOPMENT */

Expand Down
9 changes: 6 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const App = (): JSX.Element => {
const isAMMEnabled = useFeatureFlag(FeatureFlags.AMM);
const isWalletEnabled = useFeatureFlag(FeatureFlags.WALLET);
const isStrategiesEnabled = useFeatureFlag(FeatureFlags.STRATEGIES);
const isOnboardingEnabled = useFeatureFlag(FeatureFlags.ONBOARDING);

// Loads the connection to the faucet - only for testnet purposes
const loadFaucet = React.useCallback(async (): Promise<void> => {
Expand Down Expand Up @@ -217,9 +218,11 @@ const App = (): JSX.Element => {
<Strategies />
</Route>
)}
<Route path={PAGES.ONBOARDING}>
<Onboarding />
</Route>
{isOnboardingEnabled && (
<Route path={PAGES.ONBOARDING}>
<Onboarding />
</Route>
)}
<Route path={PAGES.ACTIONS}>
<Actions />
</Route>
Expand Down
5 changes: 3 additions & 2 deletions src/parts/Sidebar/SidebarContent/Navigation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const Navigation = ({
const isAMMEnabled = useFeatureFlag(FeatureFlags.AMM);
const isWalletEnabled = useFeatureFlag(FeatureFlags.WALLET);
const isStrategiesEnabled = useFeatureFlag(FeatureFlags.STRATEGIES);
const isOnboardingEnabled = useFeatureFlag(FeatureFlags.ONBOARDING);

const PRIMARY_NAVIGATION_ITEMS = React.useMemo(
() => [
Expand Down Expand Up @@ -143,7 +144,7 @@ const Navigation = ({
{
name: 'nav_onboarding',
link: PAGES.ONBOARDING,
hidden: false,
hidden: !isOnboardingEnabled
},
{
name: 'nav_use_wrapped',
Expand Down Expand Up @@ -196,7 +197,7 @@ const Navigation = ({
}
}
],
[]
[isOnboardingEnabled]
);

return (
Expand Down
6 changes: 4 additions & 2 deletions src/utils/hooks/use-feature-flag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ enum FeatureFlags {
WALLET = 'wallet',
BANXA = 'banxa',
STRATEGIES = 'strategies',
GEOBLOCK = 'geoblock'
GEOBLOCK = 'geoblock',
ONBOARDING = 'onboarding'
}

const featureFlags: Record<FeatureFlags, string | undefined> = {
Expand All @@ -13,7 +14,8 @@ const featureFlags: Record<FeatureFlags, string | undefined> = {
[FeatureFlags.WALLET]: process.env.REACT_APP_FEATURE_FLAG_WALLET,
[FeatureFlags.BANXA]: process.env.REACT_APP_FEATURE_FLAG_BANXA,
[FeatureFlags.STRATEGIES]: process.env.REACT_APP_FEATURE_FLAG_EARN_STRATEGIES,
[FeatureFlags.GEOBLOCK]: process.env.REACT_APP_FEATURE_FLAG_GEOBLOCK
[FeatureFlags.GEOBLOCK]: process.env.REACT_APP_FEATURE_FLAG_GEOBLOCK,
[FeatureFlags.ONBOARDING]: process.env.REACT_APP_FEATURE_FLAG_ONBOARDING
};

const useFeatureFlag = (feature: FeatureFlags): boolean => featureFlags[feature] === 'enabled';
Expand Down

1 comment on commit 3473509

@vercel
Copy link

@vercel vercel bot commented on 3473509 Jul 4, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.