From cd49a010a784472c381ac49d5b9ebc3b5f2ac096 Mon Sep 17 00:00:00 2001
From: David Colon <38386583+Da-Colon@users.noreply.github.com>
Date: Thu, 29 Aug 2024 16:31:24 -0400
Subject: [PATCH] add feature flag for streams
---
.env | 3 ++
src/components/pages/Roles/RoleCard.tsx | 6 ++-
.../pages/Roles/RolesDetailsDrawer.tsx | 3 +-
.../pages/Roles/RolesDetailsDrawerMobile.tsx | 3 +-
src/components/pages/Roles/RolesTable.tsx | 25 +++++++----
.../pages/Roles/forms/RoleFormTabs.tsx | 42 ++++++++++---------
src/constants/common.ts | 9 ++++
7 files changed, 58 insertions(+), 33 deletions(-)
diff --git a/.env b/.env
index 8ae7441dca..853666f44c 100644
--- a/.env
+++ b/.env
@@ -54,3 +54,6 @@ VITE_APP_SITE_URL="https://app.dev.decentdao.org"
# WalletConnect Cloud Project ID
VITE_APP_WALLET_CONNECT_PROJECT_ID=""
+
+# FEATURE FLAGS (Must equal "ON")
+VITE_APP_FLAG_STREAMS=""
diff --git a/src/components/pages/Roles/RoleCard.tsx b/src/components/pages/Roles/RoleCard.tsx
index 94c3aef0d1..c97a243ab2 100644
--- a/src/components/pages/Roles/RoleCard.tsx
+++ b/src/components/pages/Roles/RoleCard.tsx
@@ -3,6 +3,7 @@ import { CaretCircleRight, CaretRight } from '@phosphor-icons/react';
import { formatDuration, intervalToDuration } from 'date-fns';
import { useTranslation } from 'react-i18next';
import { getAddress, zeroAddress } from 'viem';
+import { isFeatureEnabled } from '../../../constants/common';
import { useGetDAOName } from '../../../hooks/DAO/useGetDAOName';
import useAvatar from '../../../hooks/utils/useAvatar';
import { useNetworkConfig } from '../../../providers/NetworkConfig/NetworkConfigProvider';
@@ -61,7 +62,7 @@ export function AvatarAndRoleName({
>
{wearerAddress ? accountDisplayName : t('unassigned')}
- {paymentsCount !== undefined && (
+ {isFeatureEnabled('STREAMS') && paymentsCount !== undefined && (
- {payments &&
+ {isFeatureEnabled('STREAMS') &&
+ payments &&
payments.map((payment, index) => (
- {roleHat.payments && (
+ {isFeatureEnabled('STREAMS') && roleHat.payments && (
<>
- {roleHat.payments && (
+ {isFeatureEnabled('STREAMS') && roleHat.payments && (
<>
{t('member')} |
-
- {t('activePayments')}
- |
+ {isFeatureEnabled('STREAMS') && (
+
+ {t('activePayments')}
+ |
+ )}
);
@@ -191,7 +194,7 @@ export function RolesRow({
{name}
-
+ {isFeatureEnabled('STREAMS') && }
);
}
@@ -221,7 +224,11 @@ export function RolesRowEdit({
editStatus={editStatus}
/>
- p.isStreaming()).length || undefined} />
+ {isFeatureEnabled('STREAMS') && (
+ p.isStreaming()).length || undefined}
+ />
+ )}
);
}
diff --git a/src/components/pages/Roles/forms/RoleFormTabs.tsx b/src/components/pages/Roles/forms/RoleFormTabs.tsx
index d037cbfddb..d5ebfbfdd5 100644
--- a/src/components/pages/Roles/forms/RoleFormTabs.tsx
+++ b/src/components/pages/Roles/forms/RoleFormTabs.tsx
@@ -4,7 +4,7 @@ import { useEffect, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import { useNavigate } from 'react-router-dom';
import { Hex } from 'viem';
-import { TOOLTIP_MAXW } from '../../../../constants/common';
+import { isFeatureEnabled, TOOLTIP_MAXW } from '../../../../constants/common';
import { DAO_ROUTES } from '../../../../constants/routes';
import { useFractal } from '../../../../providers/App/AppProvider';
import { useNetworkConfig } from '../../../../providers/NetworkConfig/NetworkConfigProvider';
@@ -67,30 +67,32 @@ export default function RoleFormTabs({
{t('roleInfo')}
-
- {!hatsTree ? (
-
- {t('payments')}
-
- ) : (
- t('payments')
- )}
-
+ {isFeatureEnabled('STREAMS') && (
+
+ {!hatsTree ? (
+
+ {t('payments')}
+
+ ) : (
+ t('payments')
+ )}
+
+ )}
- {!!hatsTree && (
+ {isFeatureEnabled('STREAMS') && !!hatsTree && (
diff --git a/src/constants/common.ts b/src/constants/common.ts
index a98cd92ff5..7b530a1e25 100644
--- a/src/constants/common.ts
+++ b/src/constants/common.ts
@@ -46,3 +46,12 @@ export const ADDRESS_MULTISIG_METADATA = '0xdA0000000000000000000000000000000000
export const SIDEBAR_WIDTH = '4.25rem';
export const MAX_CONTENT_WIDTH = '80rem';
+
+export const isFeatureEnabled = (feature: string) => {
+ const featureStatus = import.meta.env[`VITE_APP_FLAG_${feature}`];
+ if (featureStatus === 'ON') {
+ return true;
+ } else {
+ return false;
+ }
+};