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

chore(extension): Finalise porting of solution from webapp [LW-11677] #1609

Merged
Changes from 1 commit
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
Prev Previous commit
chore(extension): add dapp explorer feature flag [LW-11677]
  • Loading branch information
DominikGuzei committed Dec 20, 2024
commit 99d015a60a1174677e84db181a1d8986b5642d6d
Original file line number Diff line number Diff line change
@@ -7,7 +7,8 @@ export const getDefaultFeatureFlags = (): FallbackConfiguration => ({
[ExperimentName.SHARED_WALLETS]: false,
[ExperimentName.WEBSOCKET_API]: false,
[ExperimentName.BLOCKFROST_ASSET_PROVIDER]: false,
[ExperimentName.EXTENSION_STORAGE]: false
[ExperimentName.EXTENSION_STORAGE]: false,
[ExperimentName.DAPP_EXPLORER]: false
});

export const experiments: ExperimentsConfig = {
@@ -38,5 +39,9 @@ export const experiments: ExperimentsConfig = {
[ExperimentName.EXTENSION_STORAGE]: {
value: false,
default: false
},
[ExperimentName.DAPP_EXPLORER]: {
value: false,
default: false
}
};
Original file line number Diff line number Diff line change
@@ -12,7 +12,8 @@ export enum ExperimentName {
SHARED_WALLETS = 'shared-wallets',
WEBSOCKET_API = 'websocket-api',
BLOCKFROST_ASSET_PROVIDER = 'blockfrost-asset-provider',
EXTENSION_STORAGE = 'extension-storage'
EXTENSION_STORAGE = 'extension-storage',
DAPP_EXPLORER = 'dapp-explorer'
}

interface FeatureFlag {
Original file line number Diff line number Diff line change
@@ -25,14 +25,7 @@ import { ExperimentName } from '@providers/ExperimentsProvider/types';
import { BehaviorSubject, distinctUntilChanged, Observable, Subscription } from 'rxjs';
import { PostHogAction, PostHogProperties } from '@lace/common';

type FeatureFlag =
| 'create-paper-wallet'
| 'restore-paper-wallet'
| 'shared-wallets'
| 'use-switch-to-nami-mode'
| 'websocket-api'
| ExperimentName.BLOCKFROST_ASSET_PROVIDER
| ExperimentName.EXTENSION_STORAGE;
type FeatureFlag = `${ExperimentName}`;

type FeatureFlags = {
[key in FeatureFlag]: boolean;
Original file line number Diff line number Diff line change
@@ -8,6 +8,8 @@ import { sideMenuConfig } from './side-menu-config';
import { SideMenuContent } from './SideMenuContent';
import { walletRoutePaths as routes } from '@routes/wallet-paths';
import { useWalletStore } from '@stores';
import { ExperimentName } from '@providers/ExperimentsProvider/types';
import { usePostHogClientContext } from '@providers/PostHogClientProvider';

const isPathAvailable = (path: string) => Object.values(routes).includes(path);

@@ -18,6 +20,9 @@ export const SideMenu = (): React.ReactElement => {
listen
} = useHistory();
const analytics = useAnalyticsContext();
const posthog = usePostHogClientContext();
const isDappExplorerEnabled = posthog.isFeatureEnabled(ExperimentName.DAPP_EXPLORER);

const { isSharedWallet } = useWalletStore();

const [currentHoveredItem, setCurrentHoveredItem] = useState<MenuItemList | undefined>();
@@ -62,8 +67,14 @@ export const SideMenu = (): React.ReactElement => {
// eslint-disable-next-line unicorn/no-useless-undefined
const onMouseLeaveItem = () => setCurrentHoveredItem(undefined);

const menuItems = isSharedWallet ? sideMenuConfig.filter((item) => item.id !== MenuItemList.STAKING) : sideMenuConfig;

const excludeItems: MenuItemList[] = [];
if (isSharedWallet) {
excludeItems.push(MenuItemList.STAKING);
}
if (!isDappExplorerEnabled) {
excludeItems.push(MenuItemList.DAPPS);
}
const menuItems = sideMenuConfig.filter((item) => !excludeItems.includes(item.id));
return (
<SideMenuContent
menuItems={menuItems}
Loading