Skip to content

Commit

Permalink
Hide token launch cta elements behind feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
mzparacha committed Oct 8, 2024
1 parent 8e2ccb3 commit 55336a6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { CWIcon } from 'views/components/component_kit/cw_icons/cw_icon';
import { CWText } from 'views/components/component_kit/cw_text';
import CWIconButton from 'views/components/component_kit/new_designs/CWIconButton';

import { useFlag } from 'hooks/useFlag';
import useUserStore from 'state/ui/user';
import './CreateContentDrawer.scss';

Expand All @@ -19,6 +20,8 @@ const CreateContentDrawer = ({ onClose }: CreateContentDrawerProps) => {
const user = useUserStore();
const scopedPage = app.activeChainId();

const tokenizedCommunityEnabled = useFlag('tokenizedCommunity');

const handleCreateThread = () => {
navigate('/new/discussion');
};
Expand Down Expand Up @@ -55,10 +58,12 @@ const CreateContentDrawer = ({ onClose }: CreateContentDrawerProps) => {
<CWIcon iconName="peopleNew" />
<CWText>Create community</CWText>
</div>
<div className="item" onClick={handleCreateTokenCommunity}>
<CWIcon iconName="rocketLaunch" />
<CWText>Launch Token</CWText>
</div>
{tokenizedCommunityEnabled && (
<div className="item" onClick={handleCreateTokenCommunity}>
<CWIcon iconName="rocketLaunch" />
<CWText>Launch Token</CWText>
</div>
)}
</div>
<CWIconButton iconName="close" onClick={onClose} />
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ChainBase, ChainNetwork } from '@hicommonwealth/shared';
import { useFlag } from 'hooks/useFlag';
import { uuidv4 } from 'lib/util';
import { useCommonNavigate } from 'navigation/helpers';
import React from 'react';
Expand Down Expand Up @@ -42,6 +43,7 @@ const getCreateContentMenuItems = (
options?: NavigateOptions & { action?: string },
prefix?: null | string,
) => void,
tokenizedCommunityEnabled: boolean,
createDiscordBotConfig?: ReturnType<
typeof useCreateDiscordBotConfigMutation
>['mutateAsync'],
Expand Down Expand Up @@ -99,10 +101,14 @@ const getCreateContentMenuItems = (
navigate('/createCommunity', {}, null);
},
},
{
type: 'element',
element: <TokenLaunchButton key={2} buttonHeight="sm" />,
},
...(tokenizedCommunityEnabled
? [
{
type: 'element',
element: <TokenLaunchButton key={2} buttonHeight="sm" />,
} as PopoverMenuItem,
]
: []),
];

const getDiscordBotConnectionItems = (): PopoverMenuItem[] => {
Expand Down Expand Up @@ -192,6 +198,8 @@ export const CreateContentSidebar = ({
const { mutateAsync: createDiscordBotConfig } =
useCreateDiscordBotConfigMutation();

const tokenizedCommunityEnabled = useFlag('tokenizedCommunity');

return (
<CWSidebarMenu
className={getClasses<{
Expand All @@ -216,7 +224,11 @@ export const CreateContentSidebar = ({
}, 200);
},
}}
menuItems={getCreateContentMenuItems(navigate, createDiscordBotConfig)}
menuItems={getCreateContentMenuItems(
navigate,
tokenizedCommunityEnabled,
createDiscordBotConfig,
)}
/>
);
};
Expand All @@ -226,6 +238,8 @@ export const CreateContentPopover = () => {
const navigate = useCommonNavigate();
const user = useUserStore();

const tokenizedCommunityEnabled = useFlag('tokenizedCommunity');

if (
!user.isLoggedIn ||
!app.chain ||
Expand All @@ -237,7 +251,7 @@ export const CreateContentPopover = () => {

return (
<PopoverMenu
menuItems={getCreateContentMenuItems(navigate)}
menuItems={getCreateContentMenuItems(navigate, tokenizedCommunityEnabled)}
className="create-content-popover"
renderTrigger={(onClick, isMenuOpen) => (
<CWTooltip
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { notifyInfo } from 'controllers/app/notifications';
import { useBrowserAnalyticsTrack } from 'hooks/useBrowserAnalyticsTrack';
import useBrowserWindow from 'hooks/useBrowserWindow';
import { useFlag } from 'hooks/useFlag';
import useStickyHeader from 'hooks/useStickyHeader';
import { useCommonNavigate } from 'navigation/helpers';
import 'pages/user_dashboard/index.scss';
Expand Down Expand Up @@ -47,6 +48,8 @@ const UserDashboard = ({ type }: UserDashboardProps) => {

const { isAddedToHomeScreen } = useAppStatus();

const tokenizedCommunityEnabled = useFlag('tokenizedCommunity');

useBrowserAnalyticsTrack({
payload: {
event: MixpanelPageViewEvent.DASHBOARD_VIEW,
Expand Down Expand Up @@ -141,12 +144,12 @@ const UserDashboard = ({ type }: UserDashboardProps) => {
</div>
{isWindowExtraSmall ? (
<>
<LaunchTokenCard />
{tokenizedCommunityEnabled && <LaunchTokenCard />}
<TrendingCommunitiesPreview />
</>
) : (
<div className="featured-cards">
<LaunchTokenCard />
{tokenizedCommunityEnabled && <LaunchTokenCard />}
<TrendingCommunitiesPreview />
</div>
)}
Expand Down

0 comments on commit 55336a6

Please sign in to comment.