From 456a4cf8db7d1971308183cd91a40d5912af3523 Mon Sep 17 00:00:00 2001 From: evavirseda Date: Wed, 30 Oct 2024 12:50:34 +0100 Subject: [PATCH] feat(wallet-dashboard): add feature flags for migration & supply increase vesting (#3670) * feat: add features flags * feat: add growthbook * feat:add redirects if feature flag are disabled * feat: call init outside function * feat: rename anum and variabel * fix * feat: remove comment --- .../src/features/features.controller.ts | 6 +++ apps/core/src/constants/features.enum.ts | 2 + .../components/sidebar/Sidebar.tsx | 13 ++++- .../app/(protected)/migrations/page.tsx | 15 ++++++ .../app/(protected)/vesting/page.tsx | 13 +++++ apps/wallet-dashboard/app/layout.tsx | 50 ++++++++++--------- apps/wallet-dashboard/lib/utils/growthbook.ts | 11 ++++ apps/wallet-dashboard/lib/utils/index.ts | 1 + apps/wallet-dashboard/package.json | 2 + pnpm-lock.yaml | 6 +++ 10 files changed, 94 insertions(+), 25 deletions(-) create mode 100644 apps/wallet-dashboard/lib/utils/growthbook.ts diff --git a/apps/apps-backend/src/features/features.controller.ts b/apps/apps-backend/src/features/features.controller.ts index e1400b1d57a..e71e4b326a4 100644 --- a/apps/apps-backend/src/features/features.controller.ts +++ b/apps/apps-backend/src/features/features.controller.ts @@ -64,6 +64,12 @@ export class FeaturesController { [Feature.AccountFinder]: { defaultValue: false, }, + [Feature.WalletDashboardMigration]: { + defaultValue: false, + }, + [Feature.WalletDashboardSupplyIncreaseVesting]: { + defaultValue: false, + }, }, dateUpdated: new Date().toISOString(), }; diff --git a/apps/core/src/constants/features.enum.ts b/apps/core/src/constants/features.enum.ts index 615c80386e3..3670db4edc1 100644 --- a/apps/core/src/constants/features.enum.ts +++ b/apps/core/src/constants/features.enum.ts @@ -18,4 +18,6 @@ export enum Feature { NetworkOutageOverride = 'network-outage-override', ModuleSourceVerification = 'module-source-verification', WalletEffectsOnlySharedTransaction = 'wallet-effects-only-shared-transaction', + StardustMigration = 'migration', + SupplyIncreaseVesting = 'supply-increase-vesting', } diff --git a/apps/wallet-dashboard/app/(protected)/components/sidebar/Sidebar.tsx b/apps/wallet-dashboard/app/(protected)/components/sidebar/Sidebar.tsx index 0f49225192d..03742f9e8e4 100644 --- a/apps/wallet-dashboard/app/(protected)/components/sidebar/Sidebar.tsx +++ b/apps/wallet-dashboard/app/(protected)/components/sidebar/Sidebar.tsx @@ -4,13 +4,24 @@ import { PROTECTED_ROUTES } from '@/lib/constants/routes.constants'; import { IotaLogoMark } from '@iota/ui-icons'; import { SidebarItem } from './SidebarItem'; +import { Feature } from '@iota/core'; +import { useFeature } from '@growthbook/growthbook-react'; export function Sidebar() { + const featureFlags = { + Migrations: useFeature(Feature.StardustMigration).value, + Vesting: useFeature(Feature.SupplyIncreaseVesting).value, + }; + + const filteredRoutes = PROTECTED_ROUTES.filter(({ title }) => { + return title in featureFlags ? featureFlags[title as keyof typeof featureFlags] : true; + }); + return (