chore(trading): refactor docs links resolver (#3782)

This commit is contained in:
Maciek 2023-05-17 12:10:31 +02:00 committed by GitHub
parent 68ede90609
commit 0a6e3cb6f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
39 changed files with 189 additions and 281 deletions

View File

@ -3,6 +3,7 @@ import { Header } from './header';
import { MemoryRouter } from 'react-router-dom'; import { MemoryRouter } from 'react-router-dom';
jest.mock('@vegaprotocol/environment', () => ({ jest.mock('@vegaprotocol/environment', () => ({
...jest.requireActual('@vegaprotocol/environment'),
NetworkSwitcher: () => ( NetworkSwitcher: () => (
<div data-testid="network-switcher">NetworkSwitcher</div> <div data-testid="network-switcher">NetworkSwitcher</div>
), ),

View File

@ -1,6 +1,6 @@
import { Link } from '@vegaprotocol/ui-toolkit'; import { Link } from '@vegaprotocol/ui-toolkit';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { ExternalLinks } from '@vegaprotocol/utils'; import { ExternalLinks } from '@vegaprotocol/environment';
export const DownloadWalletPrompt = () => { export const DownloadWalletPrompt = () => {
const { t } = useTranslation(); const { t } = useTranslation();

View File

@ -12,7 +12,8 @@ import { useRefreshAfterEpoch } from '../../hooks/use-refresh-after-epoch';
import { ProposalsListItem } from '../proposals/components/proposals-list-item'; import { ProposalsListItem } from '../proposals/components/proposals-list-item';
import { ProtocolUpgradeProposalsListItem } from '../proposals/components/protocol-upgrade-proposals-list-item/protocol-upgrade-proposals-list-item'; import { ProtocolUpgradeProposalsListItem } from '../proposals/components/protocol-upgrade-proposals-list-item/protocol-upgrade-proposals-list-item';
import Routes from '../routes'; import Routes from '../routes';
import { ExternalLinks, removePaginationWrapper } from '@vegaprotocol/utils'; import { ExternalLinks } from '@vegaprotocol/environment';
import { removePaginationWrapper } from '@vegaprotocol/utils';
import { useNodesQuery } from '../staking/home/__generated__/Nodes'; import { useNodesQuery } from '../staking/home/__generated__/Nodes';
import { useProposalsQuery } from '../proposals/proposals/__generated__/Proposals'; import { useProposalsQuery } from '../proposals/proposals/__generated__/Proposals';
import { import {

View File

@ -8,12 +8,11 @@ import { ProposalsListFilter } from '../proposals-list-filter';
import Routes from '../../../routes'; import Routes from '../../../routes';
import { Button, VegaIcon, VegaIconNames } from '@vegaprotocol/ui-toolkit'; import { Button, VegaIcon, VegaIconNames } from '@vegaprotocol/ui-toolkit';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import { createDocsLinks, ExternalLinks } from '@vegaprotocol/utils';
import { ExternalLink } from '@vegaprotocol/ui-toolkit'; import { ExternalLink } from '@vegaprotocol/ui-toolkit';
import type { ProposalQuery } from '../../proposal/__generated__/Proposal'; import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals'; import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals';
import type { ProtocolUpgradeProposalFieldsFragment } from '@vegaprotocol/proposals'; import type { ProtocolUpgradeProposalFieldsFragment } from '@vegaprotocol/proposals';
import { useEnvironment } from '@vegaprotocol/environment'; import { DocsLinks, ExternalLinks } from '@vegaprotocol/environment';
interface ProposalsListProps { interface ProposalsListProps {
proposals: Array<ProposalFieldsFragment | ProposalQuery['proposal']>; proposals: Array<ProposalFieldsFragment | ProposalQuery['proposal']>;
@ -36,7 +35,6 @@ export const ProposalsList = ({
protocolUpgradeProposals, protocolUpgradeProposals,
lastBlockHeight, lastBlockHeight,
}: ProposalsListProps) => { }: ProposalsListProps) => {
const { VEGA_DOCS_URL } = useEnvironment();
const { t } = useTranslation(); const { t } = useTranslation();
const [filterString, setFilterString] = useState(''); const [filterString, setFilterString] = useState('');
const sortedProposals = proposals.reduce( const sortedProposals = proposals.reduce(
@ -83,9 +81,9 @@ export const ProposalsList = ({
marginBottom={false} marginBottom={false}
title={t('pageTitleProposals')} title={t('pageTitleProposals')}
/> />
{VEGA_DOCS_URL && ( {DocsLinks && (
<div className="xs:justify-self-end" data-testid="new-proposal-link"> <div className="xs:justify-self-end" data-testid="new-proposal-link">
<ExternalLink href={createDocsLinks(VEGA_DOCS_URL).PROPOSALS_GUIDE}> <ExternalLink href={DocsLinks.PROPOSALS_GUIDE}>
<Button variant="primary" size="sm"> <Button variant="primary" size="sm">
<div className="flex items-center gap-1"> <div className="flex items-center gap-1">
{t('NewProposal')} {t('NewProposal')}

View File

@ -2,9 +2,10 @@ import { render, screen } from '@testing-library/react';
import { ProposalFormTerms } from './proposal-form-terms'; import { ProposalFormTerms } from './proposal-form-terms';
jest.mock('@vegaprotocol/environment', () => ({ jest.mock('@vegaprotocol/environment', () => ({
useEnvironment: () => ({ ...jest.requireActual('@vegaprotocol/environment'),
VEGA_DOCS_URL: 'https://docs.vega.xyz', DocsLinks: {
}), PROPOSALS_GUIDE: 'https://docs.vega.xyz/tutorials/proposals',
},
})); }));
const renderComponent = () => { const renderComponent = () => {

View File

@ -5,8 +5,7 @@ import {
ExternalLink, ExternalLink,
TextArea, TextArea,
} from '@vegaprotocol/ui-toolkit'; } from '@vegaprotocol/ui-toolkit';
import { createDocsLinks } from '@vegaprotocol/utils'; import { DocsLinks } from '@vegaprotocol/environment';
import { useEnvironment } from '@vegaprotocol/environment';
import type { UseFormRegisterReturn } from 'react-hook-form'; import type { UseFormRegisterReturn } from 'react-hook-form';
interface ProposalFormTermsProps { interface ProposalFormTermsProps {
@ -22,23 +21,20 @@ export const ProposalFormTerms = ({
labelOverride, labelOverride,
docsLink, docsLink,
}: ProposalFormTermsProps) => { }: ProposalFormTermsProps) => {
const { VEGA_DOCS_URL } = useEnvironment();
const { t } = useTranslation(); const { t } = useTranslation();
return ( return (
<FormGroup <FormGroup
label={labelOverride || t('ProposalTerms')} label={labelOverride || t('ProposalTerms')}
labelFor="proposal-terms" labelFor="proposal-terms"
> >
{docsLink && VEGA_DOCS_URL && ( {docsLink && DocsLinks && (
<div className="mt-[-4px] mb-2 text-sm font-light"> <div className="mt-[-4px] mb-2 text-sm font-light">
<span className="mr-1">{t('ProposalTermsText')}</span> <span className="mr-1">{t('ProposalTermsText')}</span>
<ExternalLink <ExternalLink
href={`${ href={`${DocsLinks.PROPOSALS_GUIDE}${docsLink}`}
createDocsLinks(VEGA_DOCS_URL).PROPOSALS_GUIDE
}${docsLink}`}
target="_blank" target="_blank"
> >
{`${createDocsLinks(VEGA_DOCS_URL).PROPOSALS_GUIDE}${docsLink}`} {`${DocsLinks.PROPOSALS_GUIDE}${docsLink}`}
</ExternalLink> </ExternalLink>
</div> </div>
)} )}

View File

@ -10,9 +10,10 @@ import type { MockedResponse } from '@apollo/client/testing';
import { NetworkParamsDocument } from '@vegaprotocol/network-parameters'; import { NetworkParamsDocument } from '@vegaprotocol/network-parameters';
jest.mock('@vegaprotocol/environment', () => ({ jest.mock('@vegaprotocol/environment', () => ({
useEnvironment: () => ({ ...jest.requireActual('@vegaprotocol/environment'),
VEGA_DOCS_URL: 'https://docs.vega.xyz', DocsLinks: {
}), PROPOSALS_GUIDE: 'https://docs.vega.xyz/tutorials/proposals',
},
})); }));
const updateMarketNetworkParamsQueryMock: MockedResponse<NetworkParamsQuery> = { const updateMarketNetworkParamsQueryMock: MockedResponse<NetworkParamsQuery> = {

View File

@ -5,7 +5,7 @@ import {
useProposalSubmit, useProposalSubmit,
deadlineToRoundedHours, deadlineToRoundedHours,
} from '@vegaprotocol/proposals'; } from '@vegaprotocol/proposals';
import { useEnvironment } from '@vegaprotocol/environment'; import { useEnvironment, DocsLinks } from '@vegaprotocol/environment';
import { import {
ProposalFormDescription, ProposalFormDescription,
ProposalFormSubheader, ProposalFormSubheader,
@ -17,7 +17,6 @@ import {
import { ProposalMinRequirements } from '../../components/shared'; import { ProposalMinRequirements } from '../../components/shared';
import { AsyncRenderer, ExternalLink } from '@vegaprotocol/ui-toolkit'; import { AsyncRenderer, ExternalLink } from '@vegaprotocol/ui-toolkit';
import { Heading } from '../../../../components/heading'; import { Heading } from '../../../../components/heading';
import { createDocsLinks } from '@vegaprotocol/utils';
import { import {
NetworkParams, NetworkParams,
useNetworkParams, useNetworkParams,
@ -42,7 +41,7 @@ export const ProposeFreeform = () => {
NetworkParams.governance_proposal_freeform_minProposerBalance, NetworkParams.governance_proposal_freeform_minProposerBalance,
NetworkParams.spam_protection_proposal_min_tokens, NetworkParams.spam_protection_proposal_min_tokens,
]); ]);
const { VEGA_DOCS_URL, VEGA_EXPLORER_URL } = useEnvironment(); const { VEGA_EXPLORER_URL } = useEnvironment();
const { t } = useTranslation(); const { t } = useTranslation();
const { const {
register, register,
@ -111,17 +110,13 @@ export const ProposeFreeform = () => {
userAction={ProposalUserAction.CREATE} userAction={ProposalUserAction.CREATE}
/> />
{VEGA_DOCS_URL && ( {DocsLinks && (
<p className="text-sm" data-testid="proposal-docs-link"> <p className="text-sm" data-testid="proposal-docs-link">
<span className="mr-1">{t('ProposalTermsText')}</span> <span className="mr-1">{t('ProposalTermsText')}</span>
<ExternalLink <ExternalLink
href={`${ href={`${DocsLinks.PROPOSALS_GUIDE}${DOCS_LINK}`}
createDocsLinks(VEGA_DOCS_URL).PROPOSALS_GUIDE
}${DOCS_LINK}`}
target="_blank" target="_blank"
>{`${ >{`${DocsLinks.PROPOSALS_GUIDE}${DOCS_LINK}`}</ExternalLink>
createDocsLinks(VEGA_DOCS_URL).PROPOSALS_GUIDE
}${DOCS_LINK}`}</ExternalLink>
</p> </p>
)} )}

View File

@ -10,9 +10,10 @@ import { NetworkParamsDocument } from '@vegaprotocol/network-parameters';
import type { MockedResponse } from '@apollo/client/testing'; import type { MockedResponse } from '@apollo/client/testing';
jest.mock('@vegaprotocol/environment', () => ({ jest.mock('@vegaprotocol/environment', () => ({
useEnvironment: () => ({ ...jest.requireActual('@vegaprotocol/environment'),
VEGA_DOCS_URL: 'https://docs.vega.xyz', DocsLinks: {
}), PROPOSALS_GUIDE: 'https://docs.vega.xyz/tutorials/proposals',
},
})); }));
const updateMarketNetworkParamsQueryMock: MockedResponse<NetworkParamsQuery> = { const updateMarketNetworkParamsQueryMock: MockedResponse<NetworkParamsQuery> = {

View File

@ -1,10 +1,7 @@
import { useState } from 'react'; import { useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useForm } from 'react-hook-form'; import { useForm } from 'react-hook-form';
import { import { suitableForSyntaxHighlighter } from '@vegaprotocol/utils';
createDocsLinks,
suitableForSyntaxHighlighter,
} from '@vegaprotocol/utils';
import { useNetworkParams } from '@vegaprotocol/network-parameters'; import { useNetworkParams } from '@vegaprotocol/network-parameters';
import { import {
getClosingTimestamp, getClosingTimestamp,
@ -12,7 +9,7 @@ import {
useProposalSubmit, useProposalSubmit,
doesValueEquateToParam, doesValueEquateToParam,
} from '@vegaprotocol/proposals'; } from '@vegaprotocol/proposals';
import { useEnvironment } from '@vegaprotocol/environment'; import { useEnvironment, DocsLinks } from '@vegaprotocol/environment';
import { import {
ProposalFormDescription, ProposalFormDescription,
ProposalFormSubheader, ProposalFormSubheader,
@ -84,7 +81,7 @@ export const ProposeNetworkParameter = () => {
loading: networkParamsLoading, loading: networkParamsLoading,
error: networkParamsError, error: networkParamsError,
} = useNetworkParams(); } = useNetworkParams();
const { VEGA_EXPLORER_URL, VEGA_DOCS_URL } = useEnvironment(); const { VEGA_EXPLORER_URL } = useEnvironment();
const { t } = useTranslation(); const { t } = useTranslation();
const { const {
register, register,
@ -175,17 +172,13 @@ export const ProposeNetworkParameter = () => {
userAction={ProposalUserAction.CREATE} userAction={ProposalUserAction.CREATE}
/> />
{VEGA_DOCS_URL && ( {DocsLinks && (
<p className="text-sm" data-testid="proposal-docs-link"> <p className="text-sm" data-testid="proposal-docs-link">
<span className="mr-1">{t('ProposalTermsText')}</span> <span className="mr-1">{t('ProposalTermsText')}</span>
<ExternalLink <ExternalLink
href={`${ href={`${DocsLinks.PROPOSALS_GUIDE}${DOCS_LINK}`}
createDocsLinks(VEGA_DOCS_URL).PROPOSALS_GUIDE
}${DOCS_LINK}`}
target="_blank" target="_blank"
>{`${ >{`${DocsLinks.PROPOSALS_GUIDE}${DOCS_LINK}`}</ExternalLink>
createDocsLinks(VEGA_DOCS_URL).PROPOSALS_GUIDE
}${DOCS_LINK}`}</ExternalLink>
</p> </p>
)} )}

View File

@ -10,9 +10,10 @@ import type { MockedResponse } from '@apollo/client/testing';
import { NetworkParamsDocument } from '@vegaprotocol/network-parameters'; import { NetworkParamsDocument } from '@vegaprotocol/network-parameters';
jest.mock('@vegaprotocol/environment', () => ({ jest.mock('@vegaprotocol/environment', () => ({
useEnvironment: () => ({ ...jest.requireActual('@vegaprotocol/environment'),
VEGA_DOCS_URL: 'https://docs.vega.xyz', DocsLinks: {
}), PROPOSALS_GUIDE: 'https://docs.vega.xyz/tutorials/proposals',
},
})); }));
const newAssetNetworkParamsQueryMock: MockedResponse<NetworkParamsQuery> = { const newAssetNetworkParamsQueryMock: MockedResponse<NetworkParamsQuery> = {

View File

@ -7,8 +7,8 @@ import {
useProposalSubmit, useProposalSubmit,
doesValueEquateToParam, doesValueEquateToParam,
} from '@vegaprotocol/proposals'; } from '@vegaprotocol/proposals';
import { useEnvironment } from '@vegaprotocol/environment'; import { useEnvironment, DocsLinks } from '@vegaprotocol/environment';
import { createDocsLinks, validateJson } from '@vegaprotocol/utils'; import { validateJson } from '@vegaprotocol/utils';
import { import {
NetworkParams, NetworkParams,
useNetworkParams, useNetworkParams,
@ -53,7 +53,7 @@ export const ProposeNewAsset = () => {
NetworkParams.governance_proposal_asset_minProposerBalance, NetworkParams.governance_proposal_asset_minProposerBalance,
NetworkParams.spam_protection_proposal_min_tokens, NetworkParams.spam_protection_proposal_min_tokens,
]); ]);
const { VEGA_EXPLORER_URL, VEGA_DOCS_URL } = useEnvironment(); const { VEGA_EXPLORER_URL } = useEnvironment();
const { t } = useTranslation(); const { t } = useTranslation();
const { const {
register, register,
@ -142,17 +142,13 @@ export const ProposeNewAsset = () => {
userAction={ProposalUserAction.CREATE} userAction={ProposalUserAction.CREATE}
/> />
{VEGA_DOCS_URL && ( {DocsLinks && (
<p className="text-sm" data-testid="proposal-docs-link"> <p className="text-sm" data-testid="proposal-docs-link">
<span className="mr-1">{t('ProposalTermsText')}</span> <span className="mr-1">{t('ProposalTermsText')}</span>
<ExternalLink <ExternalLink
href={`${ href={`${DocsLinks.PROPOSALS_GUIDE}${DOCS_LINK}`}
createDocsLinks(VEGA_DOCS_URL).PROPOSALS_GUIDE
}${DOCS_LINK}`}
target="_blank" target="_blank"
>{`${ >{`${DocsLinks.PROPOSALS_GUIDE}${DOCS_LINK}`}</ExternalLink>
createDocsLinks(VEGA_DOCS_URL).PROPOSALS_GUIDE
}${DOCS_LINK}`}</ExternalLink>
</p> </p>
)} )}

View File

@ -10,9 +10,10 @@ import type { NetworkParamsQuery } from '@vegaprotocol/network-parameters';
import { NetworkParamsDocument } from '@vegaprotocol/network-parameters'; import { NetworkParamsDocument } from '@vegaprotocol/network-parameters';
jest.mock('@vegaprotocol/environment', () => ({ jest.mock('@vegaprotocol/environment', () => ({
useEnvironment: () => ({ ...jest.requireActual('@vegaprotocol/environment'),
VEGA_DOCS_URL: 'https://docs.vega.xyz', DocsLinks: {
}), PROPOSALS_GUIDE: 'https://docs.vega.xyz/tutorials/proposals',
},
})); }));
const newMarketNetworkParamsQueryMock: MockedResponse<NetworkParamsQuery> = { const newMarketNetworkParamsQueryMock: MockedResponse<NetworkParamsQuery> = {

View File

@ -6,8 +6,8 @@ import {
useProposalSubmit, useProposalSubmit,
doesValueEquateToParam, doesValueEquateToParam,
} from '@vegaprotocol/proposals'; } from '@vegaprotocol/proposals';
import { useEnvironment } from '@vegaprotocol/environment'; import { useEnvironment, DocsLinks } from '@vegaprotocol/environment';
import { createDocsLinks, validateJson } from '@vegaprotocol/utils'; import { validateJson } from '@vegaprotocol/utils';
import { import {
NetworkParams, NetworkParams,
useNetworkParams, useNetworkParams,
@ -51,7 +51,7 @@ export const ProposeNewMarket = () => {
NetworkParams.governance_proposal_market_minProposerBalance, NetworkParams.governance_proposal_market_minProposerBalance,
NetworkParams.spam_protection_proposal_min_tokens, NetworkParams.spam_protection_proposal_min_tokens,
]); ]);
const { VEGA_EXPLORER_URL, VEGA_DOCS_URL } = useEnvironment(); const { VEGA_EXPLORER_URL } = useEnvironment();
const { t } = useTranslation(); const { t } = useTranslation();
const { const {
register, register,
@ -132,17 +132,13 @@ export const ProposeNewMarket = () => {
userAction={ProposalUserAction.CREATE} userAction={ProposalUserAction.CREATE}
/> />
{VEGA_DOCS_URL && ( {DocsLinks && (
<p className="text-sm" data-testid="proposal-docs-link"> <p className="text-sm" data-testid="proposal-docs-link">
<span className="mr-1">{t('ProposalTermsText')}</span> <span className="mr-1">{t('ProposalTermsText')}</span>
<ExternalLink <ExternalLink
href={`${ href={`${DocsLinks.PROPOSALS_GUIDE}${DOCS_LINK}`}
createDocsLinks(VEGA_DOCS_URL).PROPOSALS_GUIDE
}${DOCS_LINK}`}
target="_blank" target="_blank"
>{`${ >{`${DocsLinks.PROPOSALS_GUIDE}${DOCS_LINK}`}</ExternalLink>
createDocsLinks(VEGA_DOCS_URL).PROPOSALS_GUIDE
}${DOCS_LINK}`}</ExternalLink>
</p> </p>
)} )}

View File

@ -2,12 +2,11 @@ import Routes from '../../routes';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import { ExternalLink } from '@vegaprotocol/ui-toolkit'; import { ExternalLink } from '@vegaprotocol/ui-toolkit';
import { useEnvironment } from '@vegaprotocol/environment'; import { useEnvironment, DocsLinks } from '@vegaprotocol/environment';
import { Heading } from '../../../components/heading'; import { Heading } from '../../../components/heading';
import { createDocsLinks } from '@vegaprotocol/utils';
export const Propose = () => { export const Propose = () => {
const { VEGA_DOCS_URL, VEGA_EXPLORER_URL } = useEnvironment(); const { VEGA_EXPLORER_URL } = useEnvironment();
const { t } = useTranslation(); const { t } = useTranslation();
return ( return (
@ -15,14 +14,11 @@ export const Propose = () => {
<section className="pb-6"> <section className="pb-6">
<Heading title={t('NewProposal')} /> <Heading title={t('NewProposal')} />
<div className="text-sm"> <div className="text-sm">
{VEGA_DOCS_URL && ( {DocsLinks && (
<p> <p>
<span className="mr-1">{t('ProposalTermsText')}</span> <span className="mr-1">{t('ProposalTermsText')}</span>
<ExternalLink <ExternalLink href={DocsLinks.PROPOSALS_GUIDE} target="_blank">
href={createDocsLinks(VEGA_DOCS_URL).PROPOSALS_GUIDE} {DocsLinks.PROPOSALS_GUIDE}
target="_blank"
>
{createDocsLinks(VEGA_DOCS_URL).PROPOSALS_GUIDE}
</ExternalLink> </ExternalLink>
</p> </p>
)} )}

View File

@ -1,6 +1,6 @@
import { useForm } from 'react-hook-form'; import { useForm } from 'react-hook-form';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useEnvironment } from '@vegaprotocol/environment'; import { useEnvironment, DocsLinks } from '@vegaprotocol/environment';
import { Heading } from '../../../../components/heading'; import { Heading } from '../../../../components/heading';
import { import {
AsyncRenderer, AsyncRenderer,
@ -9,7 +9,7 @@ import {
InputError, InputError,
TextArea, TextArea,
} from '@vegaprotocol/ui-toolkit'; } from '@vegaprotocol/ui-toolkit';
import { createDocsLinks, validateJson } from '@vegaprotocol/utils'; import { validateJson } from '@vegaprotocol/utils';
import { import {
NetworkParams, NetworkParams,
useNetworkParams, useNetworkParams,
@ -39,7 +39,7 @@ export const ProposeRaw = () => {
NetworkParams.governance_proposal_freeform_minProposerBalance, NetworkParams.governance_proposal_freeform_minProposerBalance,
NetworkParams.spam_protection_proposal_min_tokens, NetworkParams.spam_protection_proposal_min_tokens,
]); ]);
const { VEGA_EXPLORER_URL, VEGA_DOCS_URL } = useEnvironment(); const { VEGA_EXPLORER_URL } = useEnvironment();
const { t } = useTranslation(); const { t } = useTranslation();
const { const {
register, register,
@ -79,14 +79,11 @@ export const ProposeRaw = () => {
spamProtectionMin={params.spam_protection_proposal_min_tokens} spamProtectionMin={params.spam_protection_proposal_min_tokens}
/> />
{VEGA_DOCS_URL && ( {DocsLinks && (
<p className="text-sm" data-testid="proposal-docs-link"> <p className="text-sm" data-testid="proposal-docs-link">
<span className="mr-1">{t('ProposalTermsText')}</span> <span className="mr-1">{t('ProposalTermsText')}</span>
<ExternalLink <ExternalLink href={DocsLinks.PROPOSALS_GUIDE} target="_blank">
href={createDocsLinks(VEGA_DOCS_URL).PROPOSALS_GUIDE} {DocsLinks.PROPOSALS_GUIDE}
target="_blank"
>
{createDocsLinks(VEGA_DOCS_URL).PROPOSALS_GUIDE}
</ExternalLink> </ExternalLink>
</p> </p>
)} )}

View File

@ -10,9 +10,10 @@ import type { MockedResponse } from '@apollo/client/testing';
import { NetworkParamsDocument } from '@vegaprotocol/network-parameters'; import { NetworkParamsDocument } from '@vegaprotocol/network-parameters';
jest.mock('@vegaprotocol/environment', () => ({ jest.mock('@vegaprotocol/environment', () => ({
useEnvironment: () => ({ ...jest.requireActual('@vegaprotocol/environment'),
VEGA_DOCS_URL: 'https://docs.vega.xyz', DocsLinks: {
}), PROPOSALS_GUIDE: 'https://docs.vega.xyz/tutorials/proposals',
},
})); }));
const updateAssetNetworkParamsQueryMock: MockedResponse<NetworkParamsQuery> = { const updateAssetNetworkParamsQueryMock: MockedResponse<NetworkParamsQuery> = {

View File

@ -6,8 +6,8 @@ import {
useProposalSubmit, useProposalSubmit,
doesValueEquateToParam, doesValueEquateToParam,
} from '@vegaprotocol/proposals'; } from '@vegaprotocol/proposals';
import { useEnvironment } from '@vegaprotocol/environment'; import { useEnvironment, DocsLinks } from '@vegaprotocol/environment';
import { createDocsLinks, validateJson } from '@vegaprotocol/utils'; import { validateJson } from '@vegaprotocol/utils';
import { import {
NetworkParams, NetworkParams,
useNetworkParams, useNetworkParams,
@ -51,7 +51,7 @@ export const ProposeUpdateAsset = () => {
NetworkParams.governance_proposal_updateAsset_minProposerBalance, NetworkParams.governance_proposal_updateAsset_minProposerBalance,
NetworkParams.spam_protection_proposal_min_tokens, NetworkParams.spam_protection_proposal_min_tokens,
]); ]);
const { VEGA_EXPLORER_URL, VEGA_DOCS_URL } = useEnvironment(); const { VEGA_EXPLORER_URL } = useEnvironment();
const { t } = useTranslation(); const { t } = useTranslation();
const { const {
register, register,
@ -132,17 +132,13 @@ export const ProposeUpdateAsset = () => {
userAction={ProposalUserAction.CREATE} userAction={ProposalUserAction.CREATE}
/> />
{VEGA_DOCS_URL && ( {DocsLinks && (
<p className="text-sm" data-testid="proposal-docs-link"> <p className="text-sm" data-testid="proposal-docs-link">
<span className="mr-1">{t('ProposalTermsText')}</span> <span className="mr-1">{t('ProposalTermsText')}</span>
<ExternalLink <ExternalLink
href={`${ href={`${DocsLinks.PROPOSALS_GUIDE}${DOCS_LINK}`}
createDocsLinks(VEGA_DOCS_URL).PROPOSALS_GUIDE
}${DOCS_LINK}`}
target="_blank" target="_blank"
>{`${ >{`${DocsLinks.PROPOSALS_GUIDE}${DOCS_LINK}`}</ExternalLink>
createDocsLinks(VEGA_DOCS_URL).PROPOSALS_GUIDE
}${DOCS_LINK}`}</ExternalLink>
</p> </p>
)} )}

View File

@ -7,8 +7,8 @@ import {
getEnactmentTimestamp, getEnactmentTimestamp,
useProposalSubmit, useProposalSubmit,
} from '@vegaprotocol/proposals'; } from '@vegaprotocol/proposals';
import { useEnvironment } from '@vegaprotocol/environment'; import { useEnvironment, DocsLinks } from '@vegaprotocol/environment';
import { createDocsLinks, validateJson } from '@vegaprotocol/utils'; import { validateJson } from '@vegaprotocol/utils';
import { import {
NetworkParams, NetworkParams,
useNetworkParams, useNetworkParams,
@ -98,7 +98,7 @@ export const ProposeUpdateMarket = () => {
const [selectedMarket, setSelectedMarket] = useState<string | undefined>( const [selectedMarket, setSelectedMarket] = useState<string | undefined>(
undefined undefined
); );
const { VEGA_EXPLORER_URL, VEGA_DOCS_URL } = useEnvironment(); const { VEGA_EXPLORER_URL } = useEnvironment();
const { t } = useTranslation(); const { t } = useTranslation();
const { const {
register, register,
@ -181,17 +181,13 @@ export const ProposeUpdateMarket = () => {
userAction={ProposalUserAction.CREATE} userAction={ProposalUserAction.CREATE}
/> />
{VEGA_DOCS_URL && ( {DocsLinks && (
<p className="text-sm" data-testid="proposal-docs-link"> <p className="text-sm" data-testid="proposal-docs-link">
<span className="mr-1">{t('ProposalTermsText')}</span> <span className="mr-1">{t('ProposalTermsText')}</span>
<ExternalLink <ExternalLink
href={`${ href={`${DocsLinks.PROPOSALS_GUIDE}${DOCS_LINK}`}
createDocsLinks(VEGA_DOCS_URL).PROPOSALS_GUIDE
}${DOCS_LINK}`}
target="_blank" target="_blank"
>{`${ >{`${DocsLinks.PROPOSALS_GUIDE}${DOCS_LINK}`}</ExternalLink>
createDocsLinks(VEGA_DOCS_URL).PROPOSALS_GUIDE
}${DOCS_LINK}`}</ExternalLink>
</p> </p>
)} )}

View File

@ -11,7 +11,6 @@ import {
ExternalLink, ExternalLink,
} from '@vegaprotocol/ui-toolkit'; } from '@vegaprotocol/ui-toolkit';
import { useVegaWallet } from '@vegaprotocol/wallet'; import { useVegaWallet } from '@vegaprotocol/wallet';
import { createDocsLinks } from '@vegaprotocol/utils';
import { import {
useNetworkParams, useNetworkParams,
NetworkParams, NetworkParams,
@ -21,7 +20,7 @@ import { EpochCountdown } from '../../../components/epoch-countdown';
import { Heading, SubHeading } from '../../../components/heading'; import { Heading, SubHeading } from '../../../components/heading';
import { EpochIndividualRewards } from '../epoch-individual-rewards/epoch-individual-rewards'; import { EpochIndividualRewards } from '../epoch-individual-rewards/epoch-individual-rewards';
import { useRefreshAfterEpoch } from '../../../hooks/use-refresh-after-epoch'; import { useRefreshAfterEpoch } from '../../../hooks/use-refresh-after-epoch';
import { useEnvironment } from '@vegaprotocol/environment'; import { DocsLinks } from '@vegaprotocol/environment';
import { ConnectToSeeRewards } from '../connect-to-see-rewards'; import { ConnectToSeeRewards } from '../connect-to-see-rewards';
import { EpochTotalRewards } from '../epoch-total-rewards/epoch-total-rewards'; import { EpochTotalRewards } from '../epoch-total-rewards/epoch-total-rewards';
@ -29,7 +28,6 @@ type RewardsView = 'total' | 'individual';
export const RewardsPage = () => { export const RewardsPage = () => {
const { t } = useTranslation(); const { t } = useTranslation();
const { VEGA_DOCS_URL } = useEnvironment();
const { pubKey, pubKeys } = useVegaWallet(); const { pubKey, pubKeys } = useVegaWallet();
const [toggleRewardsView, setToggleRewardsView] = const [toggleRewardsView, setToggleRewardsView] =
useState<RewardsView>('total'); useState<RewardsView>('total');
@ -68,9 +66,9 @@ export const RewardsPage = () => {
<Heading title={t('pageTitleRewards')} /> <Heading title={t('pageTitleRewards')} />
<p className="mb-12"> <p className="mb-12">
{t('rewardsIntro')}{' '} {t('rewardsIntro')}{' '}
{VEGA_DOCS_URL && ( {DocsLinks && (
<ExternalLink <ExternalLink
href={createDocsLinks(VEGA_DOCS_URL).REWARDS_GUIDE} href={DocsLinks.REWARDS_GUIDE}
target="_blank" target="_blank"
data-testid="rewards-guide-link" data-testid="rewards-guide-link"
className="text-white" className="text-white"

View File

@ -1,14 +1,12 @@
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { EpochData } from './epoch-data'; import { EpochData } from './epoch-data';
import { useEnvironment } from '@vegaprotocol/environment'; import { DocsLinks } from '@vegaprotocol/environment';
import { ExternalLink } from '@vegaprotocol/ui-toolkit'; import { ExternalLink } from '@vegaprotocol/ui-toolkit';
import { createDocsLinks } from '@vegaprotocol/utils';
import { Heading } from '../../../components/heading'; import { Heading } from '../../../components/heading';
import React from 'react'; import React from 'react';
export const Staking = () => { export const Staking = () => {
const { t } = useTranslation(); const { t } = useTranslation();
const { VEGA_DOCS_URL } = useEnvironment();
return ( return (
<> <>
@ -16,9 +14,9 @@ export const Staking = () => {
<section> <section>
<p className="mb-12"> <p className="mb-12">
{t('stakingIntro')}{' '} {t('stakingIntro')}{' '}
{VEGA_DOCS_URL && ( {DocsLinks && (
<ExternalLink <ExternalLink
href={createDocsLinks(VEGA_DOCS_URL).STAKING_GUIDE} href={DocsLinks.STAKING_GUIDE}
target="_blank" target="_blank"
data-testid="staking-guide-link" data-testid="staking-guide-link"
className="text-white" className="text-white"

View File

@ -2,12 +2,8 @@ import { useMemo, useState } from 'react';
import { Trans, useTranslation } from 'react-i18next'; import { Trans, useTranslation } from 'react-i18next';
import BigNumber from 'bignumber.js'; import BigNumber from 'bignumber.js';
import * as Schema from '@vegaprotocol/types'; import * as Schema from '@vegaprotocol/types';
import { import { removePaginationWrapper, toBigNum } from '@vegaprotocol/utils';
createDocsLinks, import { DocsLinks } from '@vegaprotocol/environment';
removePaginationWrapper,
toBigNum,
} from '@vegaprotocol/utils';
import { useEnvironment } from '@vegaprotocol/environment';
import { Link as UTLink, Toggle } from '@vegaprotocol/ui-toolkit'; import { Link as UTLink, Toggle } from '@vegaprotocol/ui-toolkit';
import { formatNumber } from '../../../../lib/format-number'; import { formatNumber } from '../../../../lib/format-number';
@ -42,7 +38,6 @@ export const ValidatorTables = ({
previousEpochData, previousEpochData,
}: ValidatorsTableProps) => { }: ValidatorsTableProps) => {
const { t } = useTranslation(); const { t } = useTranslation();
const { VEGA_DOCS_URL } = useEnvironment();
const { const {
appState: { decimals }, appState: { decimals },
} = useAppState(); } = useAppState();
@ -213,12 +208,12 @@ export const ValidatorTables = ({
<> <>
<SubHeading title={t('status-pending')} /> <SubHeading title={t('status-pending')} />
<p> <p>
{VEGA_DOCS_URL && ( {DocsLinks && (
<> <>
<span>{t('pendingDescription1')} </span> <span>{t('pendingDescription1')} </span>
<span> <span>
<UTLink <UTLink
href={createDocsLinks(VEGA_DOCS_URL).STAKING_GUIDE} href={DocsLinks.STAKING_GUIDE}
target="_blank" target="_blank"
data-testid="validator-forum-link" data-testid="validator-forum-link"
> >

View File

@ -1,7 +1,11 @@
import React, { useMemo } from 'react'; import React, { useMemo } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useEnvironment } from '@vegaprotocol/environment'; import {
import { createDocsLinks, ExternalLinks, toBigNum } from '@vegaprotocol/utils'; useEnvironment,
DocsLinks,
ExternalLinks,
} from '@vegaprotocol/environment';
import { toBigNum } from '@vegaprotocol/utils';
import * as Schema from '@vegaprotocol/types'; import * as Schema from '@vegaprotocol/types';
import { import {
Link as UTLink, Link as UTLink,
@ -64,7 +68,7 @@ export const ValidatorTable = ({
stakedTotal, stakedTotal,
previousEpochData, previousEpochData,
}: ValidatorTableProps) => { }: ValidatorTableProps) => {
const { ETHERSCAN_URL, VEGA_DOCS_URL } = useEnvironment(); const { ETHERSCAN_URL } = useEnvironment();
const { t } = useTranslation(); const { t } = useTranslation();
const { const {
appState: { decimals }, appState: { decimals },
@ -90,9 +94,9 @@ export const ValidatorTable = ({
<> <>
<p className="mb-12"> <p className="mb-12">
{t('validatorFormIntro')}{' '} {t('validatorFormIntro')}{' '}
{VEGA_DOCS_URL && ( {DocsLinks && (
<ExternalLink <ExternalLink
href={createDocsLinks(VEGA_DOCS_URL).STAKING_GUIDE} href={DocsLinks.STAKING_GUIDE}
target="_blank" target="_blank"
data-testid="validator-table-staking-guide-link" data-testid="validator-table-staking-guide-link"
className="text-white" className="text-white"

View File

@ -3,7 +3,8 @@ import { Trans, useTranslation } from 'react-i18next';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import { Heading, SubHeading } from '../../components/heading'; import { Heading, SubHeading } from '../../components/heading';
import { ExternalLinks, toBigNum } from '@vegaprotocol/utils'; import { ExternalLinks } from '@vegaprotocol/environment';
import { toBigNum } from '@vegaprotocol/utils';
import { useAppState } from '../../contexts/app-state/app-state-context'; import { useAppState } from '../../contexts/app-state/app-state-context';
import { useDocumentTitle } from '../../hooks/use-document-title'; import { useDocumentTitle } from '../../hooks/use-document-title';
import type { RouteChildProps } from '..'; import type { RouteChildProps } from '..';

View File

@ -8,7 +8,6 @@ import {
import { tooltipMapping } from '@vegaprotocol/market-info'; import { tooltipMapping } from '@vegaprotocol/market-info';
import { import {
addDecimalsFormatNumber, addDecimalsFormatNumber,
createDocsLinks,
formatNumberPercentage, formatNumberPercentage,
} from '@vegaprotocol/utils'; } from '@vegaprotocol/utils';
import { t } from '@vegaprotocol/i18n'; import { t } from '@vegaprotocol/i18n';
@ -39,7 +38,7 @@ import { Link, useParams } from 'react-router-dom';
import { Links, Routes } from '../../pages/client-router'; import { Links, Routes } from '../../pages/client-router';
import { useMarket, useStaticMarketData } from '@vegaprotocol/market-list'; import { useMarket, useStaticMarketData } from '@vegaprotocol/market-list';
import { useEnvironment } from '@vegaprotocol/environment'; import { DocsLinks } from '@vegaprotocol/environment';
const enum LiquidityTabs { const enum LiquidityTabs {
Active = 'active', Active = 'active',
@ -147,7 +146,6 @@ const LiquidityViewHeader = memo(({ marketId }: { marketId?: string }) => {
market?.tradableInstrument.instrument.product.settlementAsset.decimals || 0; market?.tradableInstrument.instrument.product.settlementAsset.decimals || 0;
const symbol = const symbol =
market?.tradableInstrument.instrument.product.settlementAsset.symbol; market?.tradableInstrument.instrument.product.settlementAsset.symbol;
const { VEGA_DOCS_URL } = useEnvironment();
const { params } = useNetworkParams([ const { params } = useNetworkParams([
NetworkParams.market_liquidity_stakeToCcyVolume, NetworkParams.market_liquidity_stakeToCcyVolume,
@ -216,10 +214,12 @@ const LiquidityViewHeader = memo(({ marketId }: { marketId?: string }) => {
<div className="break-word">{marketId}</div> <div className="break-word">{marketId}</div>
</HeaderStat> </HeaderStat>
<HeaderStat heading={t('Learn more')}> <HeaderStat heading={t('Learn more')}>
{VEGA_DOCS_URL && ( {DocsLinks ? (
<ExternalLink href={createDocsLinks(VEGA_DOCS_URL).LIQUIDITY}> <ExternalLink href={DocsLinks.LIQUIDITY}>
{t('Providing liquidity')} {t('Providing liquidity')}
</ExternalLink> </ExternalLink>
) : (
(null as React.ReactNode)
)} )}
</HeaderStat> </HeaderStat>
</Header> </Header>

View File

@ -19,11 +19,10 @@ import { useCheckLiquidityStatus } from '@vegaprotocol/liquidity';
import { AuctionTrigger, MarketTradingMode } from '@vegaprotocol/types'; import { AuctionTrigger, MarketTradingMode } from '@vegaprotocol/types';
import { import {
addDecimalsFormatNumber, addDecimalsFormatNumber,
createDocsLinks,
formatNumberPercentage, formatNumberPercentage,
} from '@vegaprotocol/utils'; } from '@vegaprotocol/utils';
import { t } from '@vegaprotocol/i18n'; import { t } from '@vegaprotocol/i18n';
import { useEnvironment } from '@vegaprotocol/environment'; import { DocsLinks } from '@vegaprotocol/environment';
interface Props { interface Props {
marketId?: string; marketId?: string;
@ -47,8 +46,6 @@ export const MarketLiquiditySupplied = ({
params.market_liquidity_targetstake_triggering_ratio params.market_liquidity_targetstake_triggering_ratio
); );
const { VEGA_DOCS_URL } = useEnvironment();
const variables = useMemo( const variables = useMemo(
() => ({ () => ({
marketId: marketId || '', marketId: marketId || '',
@ -131,11 +128,8 @@ export const MarketLiquiditySupplied = ({
<Link href={`/#/liquidity/${marketId}`} data-testid="view-liquidity-link"> <Link href={`/#/liquidity/${marketId}`} data-testid="view-liquidity-link">
{t('View liquidity provision table')} {t('View liquidity provision table')}
</Link> </Link>
{VEGA_DOCS_URL && ( {DocsLinks && (
<ExternalLink <ExternalLink href={DocsLinks.LIQUIDITY} className="mt-2">
href={createDocsLinks(VEGA_DOCS_URL).LIQUIDITY}
className="mt-2"
>
{t('Learn about providing liquidity')} {t('Learn about providing liquidity')}
</ExternalLink> </ExternalLink>
)} )}

View File

@ -5,6 +5,7 @@ import {
TOKEN_GOVERNANCE, TOKEN_GOVERNANCE,
useEnvironment, useEnvironment,
useLinks, useLinks,
DocsLinks,
} from '@vegaprotocol/environment'; } from '@vegaprotocol/environment';
import { t } from '@vegaprotocol/i18n'; import { t } from '@vegaprotocol/i18n';
import { useGlobalStore } from '../../stores'; import { useGlobalStore } from '../../stores';
@ -22,7 +23,6 @@ import {
} from '@vegaprotocol/ui-toolkit'; } from '@vegaprotocol/ui-toolkit';
import { Links, Routes } from '../../pages/client-router'; import { Links, Routes } from '../../pages/client-router';
import { createDocsLinks } from '@vegaprotocol/utils';
import { SettingsButton } from '../../client-pages/settings'; import { SettingsButton } from '../../client-pages/settings';
import { import {
ProtocolUpgradeCountdown, ProtocolUpgradeCountdown,
@ -34,7 +34,7 @@ export const Navbar = ({
}: { }: {
theme: ComponentProps<typeof Navigation>['theme']; theme: ComponentProps<typeof Navigation>['theme'];
}) => { }) => {
const { VEGA_DOCS_URL, GITHUB_FEEDBACK_URL } = useEnvironment(); const { GITHUB_FEEDBACK_URL } = useEnvironment();
const tokenLink = useLinks(DApp.Token); const tokenLink = useLinks(DApp.Token);
const { marketId } = useGlobalStore((store) => ({ const { marketId } = useGlobalStore((store) => ({
marketId: store.marketId, marketId: store.marketId,
@ -92,15 +92,13 @@ export const Navbar = ({
{t('Governance')} {t('Governance')}
</NavExternalLink> </NavExternalLink>
</NavigationItem> </NavigationItem>
{VEGA_DOCS_URL && GITHUB_FEEDBACK_URL && ( {DocsLinks?.NEW_TO_VEGA && GITHUB_FEEDBACK_URL && (
<NavigationItem> <NavigationItem>
<NavigationTrigger>{t('Resources')}</NavigationTrigger> <NavigationTrigger>{t('Resources')}</NavigationTrigger>
<NavigationContent> <NavigationContent>
<NavigationList> <NavigationList>
<NavigationItem> <NavigationItem>
<NavExternalLink <NavExternalLink href={DocsLinks.NEW_TO_VEGA}>
href={createDocsLinks(VEGA_DOCS_URL).NEW_TO_VEGA}
>
{t('Docs')} {t('Docs')}
</NavExternalLink> </NavExternalLink>
</NavigationItem> </NavigationItem>

View File

@ -8,11 +8,10 @@ import {
import { RISK_ACCEPTED_KEY } from '../constants'; import { RISK_ACCEPTED_KEY } from '../constants';
import { TelemetryApproval } from './telemetry-approval'; import { TelemetryApproval } from './telemetry-approval';
import { import {
DOCS_VEGA_WALLET,
GET_VEGA_WALLET_URL,
Networks, Networks,
useDocsLink,
useEnvironment, useEnvironment,
DocsLinks,
ExternalLinks,
} from '@vegaprotocol/environment'; } from '@vegaprotocol/environment';
import { useLocalStorage } from '@vegaprotocol/react-helpers'; import { useLocalStorage } from '@vegaprotocol/react-helpers';
@ -53,8 +52,6 @@ export const RiskNoticeDialog = ({ onClose, network }: Props) => {
const TestnetContent = ({ network }: { network: Networks }) => { const TestnetContent = ({ network }: { network: Networks }) => {
const { GITHUB_FEEDBACK_URL } = useEnvironment(); const { GITHUB_FEEDBACK_URL } = useEnvironment();
const docsLink = useDocsLink();
return ( return (
<> <>
<p className="mb-4"> <p className="mb-4">
@ -69,16 +66,16 @@ const TestnetContent = ({ network }: { network: Networks }) => {
[network] [network]
)} )}
</p> </p>
{GITHUB_FEEDBACK_URL && GET_VEGA_WALLET_URL && docsLink && ( {GITHUB_FEEDBACK_URL && DocsLinks && (
<ul className="list-disc pl-4"> <ul className="list-disc pl-4">
<li className="mb-1"> <li className="mb-1">
<Link href={GET_VEGA_WALLET_URL} target="_blank"> <Link href={ExternalLinks.VEGA_WALLET_URL} target="_blank">
<span className="underline">{t('Get a Vega Wallet')}</span>{' '} <span className="underline">{t('Get a Vega Wallet')}</span>{' '}
<VegaIcon name={VegaIconNames.OPEN_EXTERNAL} /> <VegaIcon name={VegaIconNames.OPEN_EXTERNAL} />
</Link> </Link>
</li> </li>
<li className="mb-1"> <li className="mb-1">
<Link href={docsLink(DOCS_VEGA_WALLET)} target="_blank"> <Link href={DocsLinks.VEGA_WALLET_TOOLS_URL} target="_blank">
<span className="underline">{t('Learn about Vega Wallet')}</span>{' '} <span className="underline">{t('Learn about Vega Wallet')}</span>{' '}
<VegaIcon name={VegaIconNames.OPEN_EXTERNAL} /> <VegaIcon name={VegaIconNames.OPEN_EXTERNAL} />
</Link> </Link>

View File

@ -1,13 +1,13 @@
import { ExternalLink } from '@vegaprotocol/ui-toolkit'; import { ExternalLink } from '@vegaprotocol/ui-toolkit';
import { t } from '@vegaprotocol/i18n'; import { t } from '@vegaprotocol/i18n';
import { import {
BLOG,
DApp, DApp,
Networks, Networks,
TOKEN_NEW_MARKET_PROPOSAL, TOKEN_NEW_MARKET_PROPOSAL,
TOKEN_PROPOSALS, TOKEN_PROPOSALS,
useEnvironment, useEnvironment,
useLinks, useLinks,
ExternalLinks,
} from '@vegaprotocol/environment'; } from '@vegaprotocol/environment';
import { ProposedMarkets } from './proposed-markets'; import { ProposedMarkets } from './proposed-markets';
@ -52,7 +52,7 @@ export const WelcomeNoticeDialog = () => {
</ExternalLink> </ExternalLink>
</li> </li>
<li> <li>
<ExternalLink target="_blank" href={BLOG}> <ExternalLink target="_blank" href={ExternalLinks.BLOG}>
{t('Read about the mainnet launch')} {t('Read about the mainnet launch')}
</ExternalLink> </ExternalLink>
</li> </li>

View File

@ -2,8 +2,8 @@ import { useMemo } from 'react';
import { parseISO, isValid, isAfter } from 'date-fns'; import { parseISO, isValid, isAfter } from 'date-fns';
import classNames from 'classnames'; import classNames from 'classnames';
import { useProposalOfMarketQuery } from '@vegaprotocol/proposals'; import { useProposalOfMarketQuery } from '@vegaprotocol/proposals';
import { useEnvironment } from '@vegaprotocol/environment'; import { DocsLinks } from '@vegaprotocol/environment';
import { createDocsLinks, getDateTimeFormat } from '@vegaprotocol/utils'; import { getDateTimeFormat } from '@vegaprotocol/utils';
import { t } from '@vegaprotocol/i18n'; import { t } from '@vegaprotocol/i18n';
import * as Schema from '@vegaprotocol/types'; import * as Schema from '@vegaprotocol/types';
import { ExternalLink, SimpleGrid } from '@vegaprotocol/ui-toolkit'; import { ExternalLink, SimpleGrid } from '@vegaprotocol/ui-toolkit';
@ -23,7 +23,6 @@ export const TradingModeTooltip = ({
skip, skip,
skipGrid, skipGrid,
}: TradingModeTooltipProps) => { }: TradingModeTooltipProps) => {
const { VEGA_DOCS_URL } = useEnvironment();
const { data: market } = useMarket(marketId); const { data: market } = useMarket(marketId);
const { data: marketData } = useStaticMarketData(marketId, skip); const { data: marketData } = useStaticMarketData(marketId, skip);
const { marketTradingMode, trigger } = marketData || {}; const { marketTradingMode, trigger } = marketData || {};
@ -102,9 +101,9 @@ export const TradingModeTooltip = ({
</span> </span>
</> </>
)} )}
{VEGA_DOCS_URL && ( {DocsLinks && (
<ExternalLink <ExternalLink
href={createDocsLinks(VEGA_DOCS_URL).AUCTION_TYPE_OPENING} href={DocsLinks.AUCTION_TYPE_OPENING}
className="ml-1" className="ml-1"
> >
{t('Find out more')} {t('Find out more')}
@ -126,12 +125,9 @@ export const TradingModeTooltip = ({
'This market is in auction until it reaches sufficient liquidity.' 'This market is in auction until it reaches sufficient liquidity.'
)} )}
</span> </span>
{VEGA_DOCS_URL && ( {DocsLinks && (
<ExternalLink <ExternalLink
href={ href={DocsLinks.AUCTION_TYPE_LIQUIDITY_MONITORING}
createDocsLinks(VEGA_DOCS_URL)
.AUCTION_TYPE_LIQUIDITY_MONITORING
}
className="ml-1" className="ml-1"
> >
{t('Find out more')} {t('Find out more')}
@ -151,12 +147,9 @@ export const TradingModeTooltip = ({
'This market may have sufficient liquidity but there are not enough priced limit orders in the order book, which are required to deploy liquidity commitment pegged orders.' 'This market may have sufficient liquidity but there are not enough priced limit orders in the order book, which are required to deploy liquidity commitment pegged orders.'
)} )}
</span> </span>
{VEGA_DOCS_URL && ( {DocsLinks && (
<ExternalLink <ExternalLink
href={ href={DocsLinks.AUCTION_TYPE_LIQUIDITY_MONITORING}
createDocsLinks(VEGA_DOCS_URL)
.AUCTION_TYPE_LIQUIDITY_MONITORING
}
className="ml-1" className="ml-1"
> >
{t('Find out more')} {t('Find out more')}
@ -174,12 +167,9 @@ export const TradingModeTooltip = ({
<span> <span>
{t('This market is in auction due to high price volatility.')} {t('This market is in auction due to high price volatility.')}
</span>{' '} </span>{' '}
{VEGA_DOCS_URL && ( {DocsLinks && (
<ExternalLink <ExternalLink
href={ href={DocsLinks.AUCTION_TYPE_PRICE_MONITORING}
createDocsLinks(VEGA_DOCS_URL)
.AUCTION_TYPE_PRICE_MONITORING
}
className="ml-1" className="ml-1"
> >
{t('Find out more')} {t('Find out more')}

View File

@ -4,6 +4,8 @@ import { Networks } from '../types';
import { useEnvironment } from './use-environment'; import { useEnvironment } from './use-environment';
import { stripFullStops } from '@vegaprotocol/utils'; import { stripFullStops } from '@vegaprotocol/utils';
const VEGA_DOCS_URL = process.env['NX_VEGA_DOCS_URL'] || '';
type Net = Exclude<Networks, 'CUSTOM'>; type Net = Exclude<Networks, 'CUSTOM'>;
export enum DApp { export enum DApp {
Explorer = 'Explorer', Explorer = 'Explorer',
@ -50,6 +52,25 @@ const Links: { [k in DApp]: DAppLinks } = {
[DApp.Token]: TokenLinks, [DApp.Token]: TokenLinks,
}; };
export const DocsLinks = VEGA_DOCS_URL
? {
NEW_TO_VEGA: `${VEGA_DOCS_URL}/concepts/new-to-vega`,
AUCTION_TYPE_OPENING: `${VEGA_DOCS_URL}/concepts/trading-on-vega/trading-modes#auction-type-opening`,
AUCTION_TYPE_LIQUIDITY_MONITORING: `${VEGA_DOCS_URL}/concepts/trading-on-vega/trading-modes#auction-type-liquidity-monitoring`,
AUCTION_TYPE_PRICE_MONITORING: `${VEGA_DOCS_URL}/concepts/trading-on-vega/trading-modes#auction-type-price-monitoring`,
AUCTION_TYPE_CLOSING: `${VEGA_DOCS_URL}/concepts/trading-on-vega/trading-modes#auction-type-closing`,
STAKING_GUIDE: `${VEGA_DOCS_URL}/concepts/vega-chain/#staking-on-vega`,
REWARDS_GUIDE: `${VEGA_DOCS_URL}/concepts/trading-on-vega/fees-rewards#trading-rewards`,
VEGA_WALLET_CONCEPTS_URL: `${VEGA_DOCS_URL}/concepts/vega-wallet`,
VEGA_WALLET_TOOLS_URL: `${VEGA_DOCS_URL}/tools/vega-wallet`,
PROPOSALS_GUIDE: `${VEGA_DOCS_URL}/tutorials/proposals`,
NODE_OPERATORS: `${VEGA_DOCS_URL}/node-operators`,
LOSS_SOCIALIZATION: `${VEGA_DOCS_URL}/concepts/trading-on-vega/market-protections#loss-socialisation`,
POSITION_RESOLUTION: `${VEGA_DOCS_URL}/concepts/trading-on-vega/market-protections#position-resolution`,
LIQUIDITY: `${VEGA_DOCS_URL}/concepts/liquidity/provision`,
}
: undefined;
export const useLinks = (dapp: DApp, network?: Net) => { export const useLinks = (dapp: DApp, network?: Net) => {
const { VEGA_ENV, VEGA_EXPLORER_URL, VEGA_TOKEN_URL } = useEnvironment(); const { VEGA_ENV, VEGA_EXPLORER_URL, VEGA_TOKEN_URL } = useEnvironment();
const fallback = { const fallback = {
@ -84,19 +105,6 @@ export const useEtherscanLink = () => {
return link; return link;
}; };
export const useDocsLink = () => {
const { VEGA_DOCS_URL } = useEnvironment();
const baseUrl = trim(VEGA_DOCS_URL, '/');
const link = useCallback(
(url?: string) => `${baseUrl}/${trim(url, '/') || ''}`,
[baseUrl]
);
return link;
};
// Vega blog
export const BLOG = 'https://blog.vega.xyz/';
// Governance pages // Governance pages
export const TOKEN_NEW_MARKET_PROPOSAL = '/proposals/propose/new-market'; export const TOKEN_NEW_MARKET_PROPOSAL = '/proposals/propose/new-market';
export const TOKEN_NEW_NETWORK_PARAM_PROPOSAL = export const TOKEN_NEW_NETWORK_PARAM_PROPOSAL =
@ -130,14 +138,20 @@ export const EXPLORER_ORACLE = '/oracles/:id';
export const ETHERSCAN_ADDRESS = '/address/:hash'; export const ETHERSCAN_ADDRESS = '/address/:hash';
export const ETHERSCAN_TX = '/tx/:hash'; export const ETHERSCAN_TX = '/tx/:hash';
// Console pages export const ExternalLinks = {
export const CONSOLE_MARKET = '/markets/:marketId'; FEEDBACK: 'https://github.com/vegaprotocol/feedback/discussions',
export const CONSOLE_MARKETS = '/markets/all'; GITHUB: 'https://github.com/vegaprotocol/token-frontend',
export const CONSOLE_PORTFOLIO = '/portfolio'; DISCORD: 'https://vega.xyz/discord',
export const CONSOLE_LIQUIDITY = 'liquidity/:marketId'; GOVERNANCE_PAGE: 'https://vega.xyz/governance',
VALIDATOR_FORUM: 'https://community.vega.xyz/c/mainnet-validator-candidates',
MARGIN_CREDIT_RISK:
'https://vega.xyz/papers/margins-and-credit-risk.pdf#page=7',
VEGA_WALLET_URL: 'https://vega.xyz/wallet',
VEGA_WALLET_HOSTED_URL: 'https://vega-hosted-wallet.on.fleek.co/',
BLOG: 'https://blog.vega.xyz/',
};
// Vega XYZ export const TokenStaticLinks = {
export const GET_VEGA_WALLET_URL = 'https://vega.xyz/wallet/'; PROPOSAL_PAGE: ':tokenUrl/proposals/:proposalId',
UPDATE_PROPOSAL_PAGE: ':tokenUrl/proposals/propose/update-market',
// Docs };
export const DOCS_VEGA_WALLET = '/tools/vega-wallet';

View File

@ -1,5 +1,5 @@
import { useEnvironment } from '@vegaprotocol/environment'; import { TokenStaticLinks, useEnvironment } from '@vegaprotocol/environment';
import { removePaginationWrapper, TokenLinks } from '@vegaprotocol/utils'; import { removePaginationWrapper } from '@vegaprotocol/utils';
import { t } from '@vegaprotocol/i18n'; import { t } from '@vegaprotocol/i18n';
import { useDataProvider } from '@vegaprotocol/data-provider'; import { useDataProvider } from '@vegaprotocol/data-provider';
import * as Schema from '@vegaprotocol/types'; import * as Schema from '@vegaprotocol/types';
@ -236,7 +236,7 @@ export const MarketInfoAccordion = ({
{VEGA_TOKEN_URL && ( {VEGA_TOKEN_URL && (
<ExternalLink <ExternalLink
className="mb-2 w-full" className="mb-2 w-full"
href={generatePath(TokenLinks.PROPOSAL_PAGE, { href={generatePath(TokenStaticLinks.PROPOSAL_PAGE, {
tokenUrl: VEGA_TOKEN_URL, tokenUrl: VEGA_TOKEN_URL,
proposalId: market.proposal?.id || '', proposalId: market.proposal?.id || '',
})} })}
@ -252,7 +252,7 @@ export const MarketInfoAccordion = ({
{VEGA_TOKEN_URL && ( {VEGA_TOKEN_URL && (
<ExternalLink <ExternalLink
className="w-full" className="w-full"
href={generatePath(TokenLinks.UPDATE_PROPOSAL_PAGE, { href={generatePath(TokenStaticLinks.UPDATE_PROPOSAL_PAGE, {
tokenUrl: VEGA_TOKEN_URL, tokenUrl: VEGA_TOKEN_URL,
})} })}
title={ title={

View File

@ -1,4 +1,4 @@
import { ExternalLinks } from '@vegaprotocol/utils'; import { ExternalLinks } from '@vegaprotocol/environment';
import { ExternalLink } from '@vegaprotocol/ui-toolkit'; import { ExternalLink } from '@vegaprotocol/ui-toolkit';
import { t } from '@vegaprotocol/i18n'; import { t } from '@vegaprotocol/i18n';
import type { ReactNode } from 'react'; import type { ReactNode } from 'react';

View File

@ -30,7 +30,6 @@ import {
formatNumber, formatNumber,
getDateTimeFormat, getDateTimeFormat,
addDecimalsFormatNumber, addDecimalsFormatNumber,
createDocsLinks,
} from '@vegaprotocol/utils'; } from '@vegaprotocol/utils';
import { t } from '@vegaprotocol/i18n'; import { t } from '@vegaprotocol/i18n';
import { AgGridColumn } from 'ag-grid-react'; import { AgGridColumn } from 'ag-grid-react';
@ -39,7 +38,7 @@ import type { Position } from './positions-data-providers';
import * as Schema from '@vegaprotocol/types'; import * as Schema from '@vegaprotocol/types';
import { getRowId } from './use-positions-data'; import { getRowId } from './use-positions-data';
import { PositionStatus, PositionStatusMapping } from '@vegaprotocol/types'; import { PositionStatus, PositionStatusMapping } from '@vegaprotocol/types';
import { useEnvironment } from '@vegaprotocol/environment'; import { DocsLinks } from '@vegaprotocol/environment';
interface Props extends TypedDataAgGrid<Position> { interface Props extends TypedDataAgGrid<Position> {
onClose?: (data: Position) => void; onClose?: (data: Position) => void;
@ -397,9 +396,7 @@ export const PNLCell = ({
valueFormatted, valueFormatted,
data, data,
}: VegaICellRendererParams<Position, 'realisedPNL'>) => { }: VegaICellRendererParams<Position, 'realisedPNL'>) => {
const { VEGA_DOCS_URL } = useEnvironment(); const LOSS_SOCIALIZATION_LINK = DocsLinks?.LOSS_SOCIALIZATION ?? '';
const LOSS_SOCIALIZATION_LINK =
VEGA_DOCS_URL && createDocsLinks(VEGA_DOCS_URL).LOSS_SOCIALIZATION;
if (!data) { if (!data) {
return <>-</>; return <>-</>;
@ -423,7 +420,7 @@ export const PNLCell = ({
<p className="mb-2"> <p className="mb-2">
{t('Lifetime loss socialisation deductions: %s', lossesFormatted)} {t('Lifetime loss socialisation deductions: %s', lossesFormatted)}
</p> </p>
{VEGA_DOCS_URL && ( {LOSS_SOCIALIZATION_LINK && (
<ExternalLink href={LOSS_SOCIALIZATION_LINK}> <ExternalLink href={LOSS_SOCIALIZATION_LINK}>
{t('Read more about loss socialisation')} {t('Read more about loss socialisation')}
</ExternalLink> </ExternalLink>
@ -440,8 +437,6 @@ export const OpenVolumeCell = ({
valueFormatted, valueFormatted,
data, data,
}: VegaICellRendererParams<Position, 'openVolume'>) => { }: VegaICellRendererParams<Position, 'openVolume'>) => {
const { VEGA_DOCS_URL } = useEnvironment();
if (!data) { if (!data) {
return <>-</>; return <>-</>;
} }
@ -451,8 +446,7 @@ export const OpenVolumeCell = ({
return <>{valueFormatted}</>; return <>{valueFormatted}</>;
} }
const POSITION_RESOLUTION_LINK = const POSITION_RESOLUTION_LINK = DocsLinks?.POSITION_RESOLUTION ?? '';
VEGA_DOCS_URL && createDocsLinks(VEGA_DOCS_URL).POSITION_RESOLUTION;
return ( return (
<WarningCell <WarningCell
@ -469,7 +463,7 @@ export const OpenVolumeCell = ({
] ]
)} )}
</p> </p>
{VEGA_DOCS_URL && ( {POSITION_RESOLUTION_LINK && (
<ExternalLink href={POSITION_RESOLUTION_LINK}> <ExternalLink href={POSITION_RESOLUTION_LINK}>
{t('Read more about position resolution')} {t('Read more about position resolution')}
</ExternalLink> </ExternalLink>

View File

@ -6,7 +6,6 @@ export * from './lib/get-user-locale';
export * from './lib/helpers'; export * from './lib/helpers';
export * from './lib/is-asset-erc20'; export * from './lib/is-asset-erc20';
export * from './lib/is-valid-url'; export * from './lib/is-valid-url';
export * from './lib/links';
export * from './lib/local-logger'; export * from './lib/local-logger';
export * from './lib/local-storage'; export * from './lib/local-storage';
export * from './lib/markets'; export * from './lib/markets';

View File

@ -1,36 +0,0 @@
/** createDocsLinks returns external documentation links that are specific to an environment
* @param {string} docsUrl - the documentation URL for the environment ex. https://docs.vega.xyz/testnet or https://docs.vega.xyz/mainnet (NX_VEGA_DOCS_URL)
*/
export const createDocsLinks = (docsUrl: string) => ({
NEW_TO_VEGA: `${docsUrl}/concepts/new-to-vega`,
AUCTION_TYPE_OPENING: `${docsUrl}/concepts/trading-on-vega/trading-modes#auction-type-opening`,
AUCTION_TYPE_LIQUIDITY_MONITORING: `${docsUrl}/concepts/trading-on-vega/trading-modes#auction-type-liquidity-monitoring`,
AUCTION_TYPE_PRICE_MONITORING: `${docsUrl}/concepts/trading-on-vega/trading-modes#auction-type-price-monitoring`,
AUCTION_TYPE_CLOSING: `${docsUrl}/concepts/trading-on-vega/trading-modes#auction-type-closing`,
STAKING_GUIDE: `${docsUrl}/concepts/vega-chain/#staking-on-vega`,
REWARDS_GUIDE: `${docsUrl}/concepts/trading-on-vega/fees-rewards#trading-rewards`,
VEGA_WALLET_CONCEPTS_URL: `${docsUrl}/concepts/vega-wallet`,
PROPOSALS_GUIDE: `${docsUrl}/tutorials/proposals`,
NODE_OPERATORS: `${docsUrl}/node-operators`,
LOSS_SOCIALIZATION: `${docsUrl}/concepts/trading-on-vega/market-protections#loss-socialisation`,
POSITION_RESOLUTION: `${docsUrl}/concepts/trading-on-vega/market-protections#position-resolution`,
LIQUIDITY: `${docsUrl}/concepts/liquidity/provision`,
});
export const ExternalLinks = {
FEEDBACK: 'https://github.com/vegaprotocol/feedback/discussions',
GITHUB: 'https://github.com/vegaprotocol/token-frontend',
DISCORD: 'https://vega.xyz/discord',
GOVERNANCE_PAGE: 'https://vega.xyz/governance',
VALIDATOR_FORUM: 'https://community.vega.xyz/c/mainnet-validator-candidates',
MARGIN_CREDIT_RISK:
'https://vega.xyz/papers/margins-and-credit-risk.pdf#page=7',
VEGA_WALLET_URL: 'https://vega.xyz/wallet',
VEGA_WALLET_HOSTED_URL: 'https://vega-hosted-wallet.on.fleek.co/',
};
export const TokenLinks = {
PROPOSAL_PAGE: ':tokenUrl/proposals/:proposalId',
UPDATE_PROPOSAL_PAGE: ':tokenUrl/proposals/propose/update-market',
};

View File

@ -1,5 +1,4 @@
import { useEnvironment } from '@vegaprotocol/environment'; import { DocsLinks, ExternalLinks } from '@vegaprotocol/environment';
import { createDocsLinks, ExternalLinks } from '@vegaprotocol/utils';
import { t } from '@vegaprotocol/i18n'; import { t } from '@vegaprotocol/i18n';
import { Link } from '@vegaprotocol/ui-toolkit'; import { Link } from '@vegaprotocol/ui-toolkit';
import type { ReactNode } from 'react'; import type { ReactNode } from 'react';
@ -20,7 +19,6 @@ export const ConnectDialogContent = ({ children }: { children: ReactNode }) => {
}; };
export const ConnectDialogFooter = ({ children }: { children?: ReactNode }) => { export const ConnectDialogFooter = ({ children }: { children?: ReactNode }) => {
const { VEGA_DOCS_URL } = useEnvironment();
return ( return (
<footer className="flex justify-center gap-4 px-4 md:px-8 pt-4 md:pt-6 -mx-4 md:-mx-8 border-t border-neutral-500 text-neutral-500 dark:text-neutral-400"> <footer className="flex justify-center gap-4 px-4 md:px-8 pt-4 md:pt-6 -mx-4 md:-mx-8 border-t border-neutral-500 text-neutral-500 dark:text-neutral-400">
{children ? ( {children ? (
@ -31,10 +29,8 @@ export const ConnectDialogFooter = ({ children }: { children?: ReactNode }) => {
{t('Get a Vega Wallet')} {t('Get a Vega Wallet')}
</Link> </Link>
{' | '} {' | '}
{VEGA_DOCS_URL && ( {DocsLinks && (
<Link <Link href={DocsLinks.VEGA_WALLET_CONCEPTS_URL}>
href={createDocsLinks(VEGA_DOCS_URL).VEGA_WALLET_CONCEPTS_URL}
>
{t('Having trouble?')} {t('Having trouble?')}
</Link> </Link>
)} )}

View File

@ -10,14 +10,17 @@ import {
} from '@vegaprotocol/ui-toolkit'; } from '@vegaprotocol/ui-toolkit';
import { useCallback, useState } from 'react'; import { useCallback, useState } from 'react';
import type { WalletClientError } from '@vegaprotocol/wallet-client'; import type { WalletClientError } from '@vegaprotocol/wallet-client';
import { ExternalLinks } from '@vegaprotocol/utils';
import { t } from '@vegaprotocol/i18n'; import { t } from '@vegaprotocol/i18n';
import type { VegaConnector } from '../connectors'; import type { VegaConnector } from '../connectors';
import { ViewConnector } from '../connectors'; import { ViewConnector } from '../connectors';
import { JsonRpcConnector, RestConnector } from '../connectors'; import { JsonRpcConnector, RestConnector } from '../connectors';
import { RestConnectorForm } from './rest-connector-form'; import { RestConnectorForm } from './rest-connector-form';
import { JsonRpcConnectorForm } from './json-rpc-connector-form'; import { JsonRpcConnectorForm } from './json-rpc-connector-form';
import { Networks, useEnvironment } from '@vegaprotocol/environment'; import {
Networks,
useEnvironment,
ExternalLinks,
} from '@vegaprotocol/environment';
import { import {
ConnectDialogContent, ConnectDialogContent,
ConnectDialogFooter, ConnectDialogFooter,

View File

@ -1,5 +1,4 @@
import capitalize from 'lodash/capitalize'; import capitalize from 'lodash/capitalize';
import { createDocsLinks } from '@vegaprotocol/utils';
import { t } from '@vegaprotocol/i18n'; import { t } from '@vegaprotocol/i18n';
import { import {
ButtonLink, ButtonLink,
@ -14,7 +13,7 @@ import type { JsonRpcConnector } from '../connectors';
import { ClientErrors } from '../connectors'; import { ClientErrors } from '../connectors';
import { ConnectDialogTitle } from './connect-dialog-elements'; import { ConnectDialogTitle } from './connect-dialog-elements';
import { Status } from '../use-json-rpc-connect'; import { Status } from '../use-json-rpc-connect';
import { useEnvironment } from '@vegaprotocol/environment'; import { DocsLinks } from '@vegaprotocol/environment';
export const ServiceErrors = { export const ServiceErrors = {
NO_HEALTHY_NODE: 1000, NO_HEALTHY_NODE: 1000,
@ -153,7 +152,6 @@ const Error = ({
<ButtonLink onClick={onTryAgain}>{t('Try again')}</ButtonLink> <ButtonLink onClick={onTryAgain}>{t('Try again')}</ButtonLink>
</p> </p>
); );
const { VEGA_DOCS_URL } = useEnvironment();
if (error) { if (error) {
if (error.code === ClientErrors.NO_SERVICE.code) { if (error.code === ClientErrors.NO_SERVICE.code) {
@ -173,10 +171,8 @@ const Error = ({
<> <>
{capitalize(error.message)} {capitalize(error.message)}
{'. '} {'. '}
{VEGA_DOCS_URL && ( {DocsLinks && (
<Link <Link href={DocsLinks.VEGA_WALLET_CONCEPTS_URL}>
href={createDocsLinks(VEGA_DOCS_URL).VEGA_WALLET_CONCEPTS_URL}
>
{t('Read the docs to troubleshoot')} {t('Read the docs to troubleshoot')}
</Link> </Link>
)} )}