From c3f130ae303fc29c1bdf1a54d4a0cbcb5f66168e Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Thu, 18 Jul 2024 14:20:41 +0200 Subject: [PATCH] remove action button experiment --- lib/growthbook/init.ts | 1 - ui/shared/AppActionButton/useAppActionData.tsx | 2 +- ui/token/TokenDetails.tsx | 7 ++----- ui/token/TokenNftMarketplaces.tsx | 7 +++---- ui/tokenInstance/TokenInstanceDetails.pw.tsx | 3 +-- ui/tokenInstance/TokenInstanceDetails.tsx | 7 ++----- ui/tx/TxSubHeading.pw.tsx | 12 ++++-------- ui/tx/TxSubHeading.tsx | 6 ++---- 8 files changed, 15 insertions(+), 30 deletions(-) diff --git a/lib/growthbook/init.ts b/lib/growthbook/init.ts index 4aef06e705..d98b2b94b7 100644 --- a/lib/growthbook/init.ts +++ b/lib/growthbook/init.ts @@ -7,7 +7,6 @@ import { STORAGE_KEY, STORAGE_LIMIT } from './consts'; export interface GrowthBookFeatures { test_value: string; - action_button_exp: boolean; } export const growthBook = (() => { diff --git a/ui/shared/AppActionButton/useAppActionData.tsx b/ui/shared/AppActionButton/useAppActionData.tsx index 8f0df387e4..de0be18a74 100644 --- a/ui/shared/AppActionButton/useAppActionData.tsx +++ b/ui/shared/AppActionButton/useAppActionData.tsx @@ -2,7 +2,7 @@ import { useMemo } from 'react'; import useAddressMetadataInfoQuery from 'lib/address/useAddressMetadataInfoQuery'; -export default function useAppActionData(address: string | undefined = '', isEnabled = false) { +export default function useAppActionData(address: string | undefined = '', isEnabled = true) { const memoizedArray = useMemo(() => address ? [ address ] : [], [ address ]); const { data } = useAddressMetadataInfoQuery(memoizedArray, isEnabled); const metadata = data?.addresses[address?.toLowerCase()]; diff --git a/ui/token/TokenDetails.tsx b/ui/token/TokenDetails.tsx index 223f1f974a..e689d8e646 100644 --- a/ui/token/TokenDetails.tsx +++ b/ui/token/TokenDetails.tsx @@ -12,7 +12,6 @@ import type { ResourceError } from 'lib/api/resources'; import useApiQuery from 'lib/api/useApiQuery'; import throwOnResourceLoadError from 'lib/errors/throwOnResourceLoadError'; import getCurrencyValue from 'lib/getCurrencyValue'; -import useFeatureValue from 'lib/growthbook/useFeatureValue'; import useIsMounted from 'lib/hooks/useIsMounted'; import { TOKEN_COUNTERS } from 'stubs/token'; import type { TokenTabs } from 'ui/pages/Token'; @@ -31,7 +30,6 @@ interface Props { const TokenDetails = ({ tokenQuery }: Props) => { const router = useRouter(); const isMounted = useIsMounted(); - const { value: isActionButtonExperiment } = useFeatureValue('action_button_exp', false); const hash = router.query.hash?.toString(); @@ -40,7 +38,7 @@ const TokenDetails = ({ tokenQuery }: Props) => { queryOptions: { enabled: Boolean(router.query.hash), placeholderData: TOKEN_COUNTERS }, }); - const appActionData = useAppActionData(hash, isActionButtonExperiment); + const appActionData = useAppActionData(hash); const changeUrlAndScroll = useCallback((tab: TokenTabs) => () => { router.push( @@ -200,11 +198,10 @@ const TokenDetails = ({ tokenQuery }: Props) => { isLoading={ tokenQuery.isPlaceholderData } appActionData={ appActionData } source="NFT collection" - isActionButtonExperiment={ isActionButtonExperiment } /> ) } - { (type !== 'ERC-20' && config.UI.views.nft.marketplaces.length === 0 && appActionData && isActionButtonExperiment) && ( + { (type !== 'ERC-20' && config.UI.views.nft.marketplaces.length === 0 && appActionData) && ( <> { +const TokenNftMarketplaces = ({ hash, id, isLoading, appActionData, source }: Props) => { if (!hash || config.UI.views.nft.marketplaces.length === 0) { return null; } @@ -31,7 +30,7 @@ const TokenNftMarketplaces = ({ hash, id, isLoading, appActionData, source, isAc Marketplaces { config.UI.views.nft.marketplaces.map((item) => { @@ -52,7 +51,7 @@ const TokenNftMarketplaces = ({ hash, id, isLoading, appActionData, source, isAc ); }) } - { (appActionData && isActionButtonExperiment) && ( + { appActionData && ( <> diff --git a/ui/tokenInstance/TokenInstanceDetails.pw.tsx b/ui/tokenInstance/TokenInstanceDetails.pw.tsx index 17658a89d2..84ea79091e 100644 --- a/ui/tokenInstance/TokenInstanceDetails.pw.tsx +++ b/ui/tokenInstance/TokenInstanceDetails.pw.tsx @@ -55,8 +55,7 @@ test('base view +@dark-mode +@mobile', async({ render, page }) => { }); test.describe('action button', () => { - test.beforeEach(async({ mockFeatures, mockApiResponse, mockAssetResponse }) => { - await mockFeatures([ [ 'action_button_exp', true ] ]); + test.beforeEach(async({ mockApiResponse, mockAssetResponse }) => { const metadataResponse = generateAddressMetadataResponse(protocolTagWithMeta); await mockApiResponse('address_metadata_info', metadataResponse, { queryParams: addressMetadataQueryParams }); await mockAssetResponse(protocolTagWithMeta?.meta?.appLogoURL as string, './playwright/mocks/image_s.jpg'); diff --git a/ui/tokenInstance/TokenInstanceDetails.tsx b/ui/tokenInstance/TokenInstanceDetails.tsx index 68e774fd3e..cac82c8ace 100644 --- a/ui/tokenInstance/TokenInstanceDetails.tsx +++ b/ui/tokenInstance/TokenInstanceDetails.tsx @@ -4,7 +4,6 @@ import React from 'react'; import type { TokenInfo, TokenInstance } from 'types/api/token'; import config from 'configs/app'; -import useFeatureValue from 'lib/growthbook/useFeatureValue'; import useIsMounted from 'lib/hooks/useIsMounted'; import AppActionButton from 'ui/shared/AppActionButton/AppActionButton'; import useAppActionData from 'ui/shared/AppActionButton/useAppActionData'; @@ -29,8 +28,7 @@ interface Props { } const TokenInstanceDetails = ({ data, token, scrollRef, isLoading }: Props) => { - const { value: isActionButtonExperiment } = useFeatureValue('action_button_exp', false); - const appActionData = useAppActionData(token?.address, isActionButtonExperiment && !isLoading); + const appActionData = useAppActionData(token?.address, !isLoading); const isMounted = useIsMounted(); const handleCounterItemClick = React.useCallback(() => { @@ -96,10 +94,9 @@ const TokenInstanceDetails = ({ data, token, scrollRef, isLoading }: Props) => { id={ data.id } appActionData={ appActionData } source="NFT item" - isActionButtonExperiment={ isActionButtonExperiment } /> - { (config.UI.views.nft.marketplaces.length === 0 && appActionData && isActionButtonExperiment) && ( + { (config.UI.views.nft.marketplaces.length === 0 && appActionData) && ( <> { await expect(component).toHaveScreenshot(); }); - test('with interpretation and action button +@mobile +@dark-mode', async({ render, mockApiResponse, mockAssetResponse, mockFeatures }) => { - await mockFeatures([ [ 'action_button_exp', true ] ]); + test('with interpretation and action button +@mobile +@dark-mode', async({ render, mockApiResponse, mockAssetResponse }) => { const metadataResponse = generateAddressMetadataResponse(protocolTagWithMeta); await mockApiResponse('address_metadata_info', metadataResponse, { queryParams: addressMetadataQueryParams }); await mockAssetResponse(protocolTagWithMeta?.meta?.appLogoURL as string, './playwright/mocks/image_s.jpg'); @@ -76,9 +75,8 @@ test.describe('blockscout provider', () => { }); test('with interpretation and view all link, and action button (external link) +@mobile', async({ - render, mockApiResponse, mockAssetResponse, mockFeatures, + render, mockApiResponse, mockAssetResponse, }) => { - await mockFeatures([ [ 'action_button_exp', true ] ]); delete protocolTagWithMeta?.meta?.appID; const metadataResponse = generateAddressMetadataResponse(protocolTagWithMeta); await mockApiResponse('address_metadata_info', metadataResponse, { queryParams: addressMetadataQueryParams }); @@ -92,9 +90,8 @@ test.describe('blockscout provider', () => { await expect(component).toHaveScreenshot(); }); - test('no interpretation, has method called', async({ render, mockApiResponse, mockFeatures }) => { + test('no interpretation, has method called', async({ render, mockApiResponse }) => { // the action button should not render if there is no interpretation - await mockFeatures([ [ 'action_button_exp', true ] ]); const metadataResponse = generateAddressMetadataResponse(protocolTagWithMeta); await mockApiResponse('address_metadata_info', metadataResponse, { queryParams: addressMetadataQueryParams }); @@ -103,9 +100,8 @@ test.describe('blockscout provider', () => { await expect(component).toHaveScreenshot(); }); - test('no interpretation', async({ render, mockApiResponse, mockFeatures }) => { + test('no interpretation', async({ render, mockApiResponse }) => { // the action button should not render if there is no interpretation - await mockFeatures([ [ 'action_button_exp', true ] ]); const metadataResponse = generateAddressMetadataResponse(protocolTagWithMeta); await mockApiResponse('address_metadata_info', metadataResponse, { queryParams: addressMetadataQueryParams }); diff --git a/ui/tx/TxSubHeading.tsx b/ui/tx/TxSubHeading.tsx index 278bcc137d..dcfcf76837 100644 --- a/ui/tx/TxSubHeading.tsx +++ b/ui/tx/TxSubHeading.tsx @@ -3,7 +3,6 @@ import React from 'react'; import config from 'configs/app'; import useApiQuery from 'lib/api/useApiQuery'; -import useFeatureValue from 'lib/growthbook/useFeatureValue'; import { NOVES_TRANSLATE } from 'stubs/noves/NovesTranslate'; import { TX_INTERPRETATION } from 'stubs/txInterpretation'; import AccountActionsMenu from 'ui/shared/AccountActionsMenu/AccountActionsMenu'; @@ -29,8 +28,7 @@ const TxSubHeading = ({ hash, hasTag, txQuery }: Props) => { const hasInterpretationFeature = feature.isEnabled; const isNovesInterpretation = hasInterpretationFeature && feature.provider === 'noves'; - const { value: isActionButtonExperiment } = useFeatureValue('action_button_exp', false); - const appActionData = useAppActionData(txQuery.data?.to?.hash, isActionButtonExperiment && !txQuery.isPlaceholderData); + const appActionData = useAppActionData(txQuery.data?.to?.hash, !txQuery.isPlaceholderData); const txInterpretationQuery = useApiQuery('tx_interpretation', { pathParams: { hash }, @@ -127,7 +125,7 @@ const TxSubHeading = ({ hash, hasTag, txQuery }: Props) => { mt={{ base: 3, lg: 0 }} > { !hasTag && } - { (appActionData && isActionButtonExperiment && hasAnyInterpretation) && ( + { (appActionData && hasAnyInterpretation) && ( ) }