2023-03-22 23:33:29 +00:00
|
|
|
import type { ComponentProps, ReactNode } from 'react';
|
2022-12-22 14:24:20 +00:00
|
|
|
import {
|
|
|
|
DApp,
|
|
|
|
NetworkSwitcher,
|
|
|
|
TOKEN_GOVERNANCE,
|
2023-03-22 23:33:29 +00:00
|
|
|
useEnvironment,
|
2022-12-22 14:24:20 +00:00
|
|
|
useLinks,
|
2023-05-17 10:10:31 +00:00
|
|
|
DocsLinks,
|
2022-12-22 14:24:20 +00:00
|
|
|
} from '@vegaprotocol/environment';
|
2023-02-28 18:56:29 +00:00
|
|
|
import { t } from '@vegaprotocol/i18n';
|
2023-02-06 11:18:14 +00:00
|
|
|
import { useGlobalStore } from '../../stores';
|
2022-08-31 04:35:46 +00:00
|
|
|
import { VegaWalletConnectButton } from '../vega-wallet-connect-button';
|
2022-12-06 16:00:37 +00:00
|
|
|
import {
|
2023-03-10 15:46:51 +00:00
|
|
|
Navigation,
|
|
|
|
NavigationList,
|
|
|
|
NavigationItem,
|
|
|
|
NavigationLink,
|
|
|
|
ExternalLink,
|
|
|
|
NavigationBreakpoint,
|
2023-03-22 23:33:29 +00:00
|
|
|
NavigationTrigger,
|
|
|
|
NavigationContent,
|
2023-05-22 20:20:17 +00:00
|
|
|
VegaIconNames,
|
|
|
|
VegaIcon,
|
2022-12-06 16:00:37 +00:00
|
|
|
} from '@vegaprotocol/ui-toolkit';
|
2022-03-14 13:18:11 +00:00
|
|
|
|
2023-03-10 15:46:51 +00:00
|
|
|
import { Links, Routes } from '../../pages/client-router';
|
2023-04-26 15:17:23 +00:00
|
|
|
import { SettingsButton } from '../../client-pages/settings';
|
2023-05-04 07:51:24 +00:00
|
|
|
import {
|
|
|
|
ProtocolUpgradeCountdown,
|
|
|
|
ProtocolUpgradeCountdownMode,
|
|
|
|
} from '@vegaprotocol/proposals';
|
2022-08-31 04:35:46 +00:00
|
|
|
|
2023-03-10 15:46:51 +00:00
|
|
|
export const Navbar = ({
|
|
|
|
theme = 'system',
|
2023-01-17 09:59:12 +00:00
|
|
|
}: {
|
2023-03-10 15:46:51 +00:00
|
|
|
theme: ComponentProps<typeof Navigation>['theme'];
|
2023-01-17 09:59:12 +00:00
|
|
|
}) => {
|
2023-05-17 10:10:31 +00:00
|
|
|
const { GITHUB_FEEDBACK_URL } = useEnvironment();
|
2022-12-22 14:24:20 +00:00
|
|
|
const tokenLink = useLinks(DApp.Token);
|
2023-05-19 21:27:45 +00:00
|
|
|
const marketId = useGlobalStore((store) => store.marketId);
|
|
|
|
|
2022-12-22 14:24:20 +00:00
|
|
|
const tradingPath = marketId
|
|
|
|
? Links[Routes.MARKET](marketId)
|
|
|
|
: Links[Routes.MARKET]();
|
2023-04-06 11:53:08 +00:00
|
|
|
|
2022-03-14 13:18:11 +00:00
|
|
|
return (
|
2023-03-10 15:46:51 +00:00
|
|
|
<Navigation
|
|
|
|
appName="Console"
|
|
|
|
theme={theme}
|
|
|
|
actions={
|
|
|
|
<>
|
2023-05-04 07:51:24 +00:00
|
|
|
<ProtocolUpgradeCountdown
|
|
|
|
mode={ProtocolUpgradeCountdownMode.IN_ESTIMATED_TIME_REMAINING}
|
|
|
|
/>
|
2023-04-26 15:17:23 +00:00
|
|
|
<SettingsButton />
|
2023-03-10 15:46:51 +00:00
|
|
|
<VegaWalletConnectButton />
|
|
|
|
</>
|
2023-01-17 09:59:12 +00:00
|
|
|
}
|
2023-05-04 07:51:24 +00:00
|
|
|
breakpoints={[521, 1122]}
|
2023-01-17 09:59:12 +00:00
|
|
|
>
|
2023-03-10 15:46:51 +00:00
|
|
|
<NavigationList
|
|
|
|
className="[.drawer-content_&]:border-b [.drawer-content_&]:border-b-vega-light-200 dark:[.drawer-content_&]:border-b-vega-dark-200 [.drawer-content_&]:pb-8 [.drawer-content_&]:mb-2"
|
|
|
|
hide={[NavigationBreakpoint.Small]}
|
|
|
|
>
|
|
|
|
<NavigationItem className="[.drawer-content_&]:w-full">
|
|
|
|
<NetworkSwitcher className="[.drawer-content_&]:w-full" />
|
|
|
|
</NavigationItem>
|
|
|
|
</NavigationList>
|
|
|
|
<NavigationList
|
|
|
|
hide={[NavigationBreakpoint.Narrow, NavigationBreakpoint.Small]}
|
|
|
|
>
|
|
|
|
<NavigationItem>
|
|
|
|
<NavigationLink data-testid="Markets" to={Links[Routes.MARKETS]()}>
|
|
|
|
{t('Markets')}
|
|
|
|
</NavigationLink>
|
|
|
|
</NavigationItem>
|
|
|
|
<NavigationItem>
|
2023-05-15 08:08:04 +00:00
|
|
|
<NavigationLink data-testid="Trading" to={tradingPath} end>
|
2023-03-10 15:46:51 +00:00
|
|
|
{t('Trading')}
|
|
|
|
</NavigationLink>
|
|
|
|
</NavigationItem>
|
|
|
|
<NavigationItem>
|
|
|
|
<NavigationLink
|
|
|
|
data-testid="Portfolio"
|
|
|
|
to={Links[Routes.PORTFOLIO]()}
|
|
|
|
>
|
|
|
|
{t('Portfolio')}
|
|
|
|
</NavigationLink>
|
|
|
|
</NavigationItem>
|
|
|
|
<NavigationItem>
|
2023-03-22 23:33:29 +00:00
|
|
|
<NavExternalLink href={tokenLink(TOKEN_GOVERNANCE)}>
|
|
|
|
{t('Governance')}
|
|
|
|
</NavExternalLink>
|
2023-03-10 15:46:51 +00:00
|
|
|
</NavigationItem>
|
2023-05-17 10:10:31 +00:00
|
|
|
{DocsLinks?.NEW_TO_VEGA && GITHUB_FEEDBACK_URL && (
|
2023-03-22 23:33:29 +00:00
|
|
|
<NavigationItem>
|
|
|
|
<NavigationTrigger>{t('Resources')}</NavigationTrigger>
|
|
|
|
<NavigationContent>
|
|
|
|
<NavigationList>
|
|
|
|
<NavigationItem>
|
2023-05-17 10:10:31 +00:00
|
|
|
<NavExternalLink href={DocsLinks.NEW_TO_VEGA}>
|
2023-03-22 23:33:29 +00:00
|
|
|
{t('Docs')}
|
|
|
|
</NavExternalLink>
|
|
|
|
</NavigationItem>
|
|
|
|
<NavigationItem>
|
|
|
|
<NavExternalLink href={GITHUB_FEEDBACK_URL}>
|
|
|
|
{t('Give Feedback')}
|
|
|
|
</NavExternalLink>
|
2023-05-19 21:27:45 +00:00
|
|
|
</NavigationItem>
|
|
|
|
<NavigationItem>
|
|
|
|
<NavigationLink
|
|
|
|
data-testid="Disclaimer"
|
|
|
|
to={Links[Routes.DISCLAIMER]()}
|
|
|
|
>
|
|
|
|
{t('Disclaimer')}
|
|
|
|
</NavigationLink>
|
2023-03-22 23:33:29 +00:00
|
|
|
</NavigationItem>
|
|
|
|
</NavigationList>
|
|
|
|
</NavigationContent>
|
|
|
|
</NavigationItem>
|
|
|
|
)}
|
2023-03-10 15:46:51 +00:00
|
|
|
</NavigationList>
|
|
|
|
<NavigationList
|
2023-04-26 15:17:23 +00:00
|
|
|
className="[.drawer-content_&]:border-t [.drawer-content_&]:border-t-vega-light-200 dark:[.drawer-content_&]:border-t-vega-dark-200 [.drawer-content_&]:pt-4 [.drawer-content_&]:mt-4"
|
2023-03-10 15:46:51 +00:00
|
|
|
hide={[
|
|
|
|
NavigationBreakpoint.Small,
|
|
|
|
NavigationBreakpoint.Narrow,
|
|
|
|
NavigationBreakpoint.Full,
|
|
|
|
]}
|
|
|
|
>
|
2023-04-26 15:17:23 +00:00
|
|
|
<NavigationItem className="[.drawer-content_&]:w-full">
|
|
|
|
<SettingsButton withMobile />
|
2023-03-10 15:46:51 +00:00
|
|
|
</NavigationItem>
|
|
|
|
</NavigationList>
|
|
|
|
</Navigation>
|
2022-03-14 13:18:11 +00:00
|
|
|
);
|
|
|
|
};
|
2023-03-22 23:33:29 +00:00
|
|
|
|
|
|
|
const NavExternalLink = ({
|
|
|
|
children,
|
|
|
|
href,
|
|
|
|
}: {
|
|
|
|
children: ReactNode;
|
|
|
|
href: string;
|
|
|
|
}) => {
|
|
|
|
return (
|
|
|
|
<ExternalLink href={href}>
|
|
|
|
<span className="flex items-center gap-2">
|
|
|
|
<span>{children}</span>
|
2023-05-22 20:20:17 +00:00
|
|
|
<VegaIcon name={VegaIconNames.OPEN_EXTERNAL} />
|
2023-03-22 23:33:29 +00:00
|
|
|
</span>
|
|
|
|
</ExternalLink>
|
|
|
|
);
|
|
|
|
};
|