Skip to content
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

feat: add feature flag to arbitrary transactions #3799

Open
wants to merge 1 commit into
base: feat/3732-meatball-arbitrary-txs
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/components/v5/common/ActionSidebar/hooks/useActionsList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ import { useMemo } from 'react';

import { Action } from '~constants/actions.ts';
import { useColonyContext } from '~context/ColonyContext/ColonyContext.ts';
import { useFeatureFlagsContext } from '~context/FeatureFlagsContext/FeatureFlagsContext.ts';
import useEnabledExtensions from '~hooks/useEnabledExtensions.ts';
import { type SearchSelectOptionProps } from '~v5/shared/SearchSelect/types.ts';

const useActionsList = () => {
const { colony } = useColonyContext();
const { isStagedExpenditureEnabled } = useEnabledExtensions();

const featureFlags = useFeatureFlagsContext();
const isFeatureFlagArbitraryTxsEnabled =
featureFlags.ARBITRARY_TXS_ACTION?.isLoading ||
featureFlags.ARBITRARY_TXS_ACTION?.isEnabled;

return useMemo((): SearchSelectOptionProps[] => {
const actionsListOptions: SearchSelectOptionProps[] = [
{
Expand Down Expand Up @@ -133,7 +139,9 @@ const useActionsList = () => {
// },
],
},
{
];
if (isFeatureFlagArbitraryTxsEnabled) {
actionsListOptions.push({
key: '6',
isAccordion: true,
title: { id: 'actions.transactions' },
Expand All @@ -144,8 +152,8 @@ const useActionsList = () => {
isNew: true,
},
],
},
];
});
}
if (!isStagedExpenditureEnabled) {
const stagedPaymentIndex = actionsListOptions[0].options.findIndex(
({ value }) => value === Action.StagedPayment,
Expand All @@ -160,7 +168,7 @@ const useActionsList = () => {
actionsListOptions[2].options[2].isDisabled = true;
}
return actionsListOptions;
}, [colony, isStagedExpenditureEnabled]);
}, [colony, isStagedExpenditureEnabled, isFeatureFlagArbitraryTxsEnabled]);
};

export default useActionsList;
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const FeatureFlagsContextProvider: FC<PropsWithChildren> = ({ children }) => {
const cryptoToFiatWithdrawalsFeature = useFeatureFlag(
FeatureFlag.CRYPTO_TO_FIAT_WITHDRAWALS,
);
const arbitraryTxsAction = useFeatureFlag(FeatureFlag.ARBITRARY_TXS_ACTION);

const featureFlags: Record<
FeatureFlag,
Expand All @@ -42,8 +43,9 @@ const FeatureFlagsContextProvider: FC<PropsWithChildren> = ({ children }) => {
() => ({
[FeatureFlag.CRYPTO_TO_FIAT]: cryptoToFiatFeature,
[FeatureFlag.CRYPTO_TO_FIAT_WITHDRAWALS]: cryptoToFiatWithdrawalsFeature,
[FeatureFlag.ARBITRARY_TXS_ACTION]: arbitraryTxsAction,
}),
[cryptoToFiatFeature, cryptoToFiatWithdrawalsFeature],
[cryptoToFiatFeature, cryptoToFiatWithdrawalsFeature, arbitraryTxsAction],
);

return (
Expand Down
1 change: 1 addition & 0 deletions src/context/FeatureFlagsContext/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export enum FeatureFlag {
CRYPTO_TO_FIAT = 'CRYPTO_TO_FIAT',
CRYPTO_TO_FIAT_WITHDRAWALS = 'CRYPTO_TO_FIAT_WITHDRAWALS',
ARBITRARY_TXS_ACTION = 'ARBITRARY_TXS_ACTION',
}

export interface FeatureFlagValue {
Expand Down