Skip to content

Commit

Permalink
Merge pull request #3799 from JoinColony/feat/3797-arbitrary-txs-feat…
Browse files Browse the repository at this point in the history
…ure-flag

feat: add feature flag to arbitrary transactions
  • Loading branch information
Nortsova authored Dec 2, 2024
2 parents 61c1112 + 224719f commit b529875
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
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

0 comments on commit b529875

Please sign in to comment.