feat(wallet): tighten up the flow for "view as vega user" (#2934)
This commit is contained in:
parent
d4ecb88fb4
commit
4286bc37b3
@ -7,7 +7,7 @@ export const ConnectDialogTitle = ({ children }: { children: ReactNode }) => {
|
|||||||
return (
|
return (
|
||||||
<h1
|
<h1
|
||||||
data-testid="wallet-dialog-title"
|
data-testid="wallet-dialog-title"
|
||||||
className="text-2xl uppercase mb-6 text-center"
|
className="text-2xl uppercase mb-6 text-center font-alpha"
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</h1>
|
</h1>
|
||||||
|
@ -229,6 +229,7 @@ const ConnectorList = ({
|
|||||||
</li>
|
</li>
|
||||||
)}
|
)}
|
||||||
<li className="mb-4 last:mb-0">
|
<li className="mb-4 last:mb-0">
|
||||||
|
<div className="my-4 text-center text-vega-dark-400">{t('OR')}</div>
|
||||||
<ConnectionOption
|
<ConnectionOption
|
||||||
type="view"
|
type="view"
|
||||||
text={t('View as vega user')}
|
text={t('View as vega user')}
|
||||||
@ -264,6 +265,13 @@ const SelectedForm = ({
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ConnectDialogContent>
|
<ConnectDialogContent>
|
||||||
|
<button
|
||||||
|
onClick={reset}
|
||||||
|
className="absolute p-2 top-0 left-0 md:top-2 md:left-2"
|
||||||
|
data-testid="back-button"
|
||||||
|
>
|
||||||
|
<Icon name={'chevron-left'} ariaLabel="back" size={4} />
|
||||||
|
</button>
|
||||||
<ConnectDialogTitle>{t('Connect')}</ConnectDialogTitle>
|
<ConnectDialogTitle>{t('Connect')}</ConnectDialogTitle>
|
||||||
<div className="mb-2">
|
<div className="mb-2">
|
||||||
<RestConnectorForm connector={connector} onConnect={onConnect} />
|
<RestConnectorForm connector={connector} onConnect={onConnect} />
|
||||||
@ -315,7 +323,11 @@ const SelectedForm = ({
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ConnectDialogContent>
|
<ConnectDialogContent>
|
||||||
<ViewConnectorForm connector={connector} onConnect={onConnect} />
|
<ViewConnectorForm
|
||||||
|
connector={connector}
|
||||||
|
onConnect={onConnect}
|
||||||
|
reset={reset}
|
||||||
|
/>
|
||||||
</ConnectDialogContent>
|
</ConnectDialogContent>
|
||||||
<ConnectDialogFooter />
|
<ConnectDialogFooter />
|
||||||
</>
|
</>
|
||||||
|
@ -1,5 +1,11 @@
|
|||||||
import { t } from '@vegaprotocol/react-helpers';
|
import { t } from '@vegaprotocol/react-helpers';
|
||||||
import { Button, FormGroup, Input, InputError } from '@vegaprotocol/ui-toolkit';
|
import {
|
||||||
|
Button,
|
||||||
|
FormGroup,
|
||||||
|
Icon,
|
||||||
|
Input,
|
||||||
|
InputError,
|
||||||
|
} from '@vegaprotocol/ui-toolkit';
|
||||||
import { useForm } from 'react-hook-form';
|
import { useForm } from 'react-hook-form';
|
||||||
import type { ViewConnector } from '../connectors';
|
import type { ViewConnector } from '../connectors';
|
||||||
import { useVegaWallet } from '../use-vega-wallet';
|
import { useVegaWallet } from '../use-vega-wallet';
|
||||||
@ -11,11 +17,13 @@ interface FormFields {
|
|||||||
interface RestConnectorFormProps {
|
interface RestConnectorFormProps {
|
||||||
connector: ViewConnector;
|
connector: ViewConnector;
|
||||||
onConnect: (connector: ViewConnector) => void;
|
onConnect: (connector: ViewConnector) => void;
|
||||||
|
reset: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ViewConnectorForm({
|
export function ViewConnectorForm({
|
||||||
connector,
|
connector,
|
||||||
onConnect,
|
onConnect,
|
||||||
|
reset,
|
||||||
}: RestConnectorFormProps) {
|
}: RestConnectorFormProps) {
|
||||||
const { connect } = useVegaWallet();
|
const { connect } = useVegaWallet();
|
||||||
const {
|
const {
|
||||||
@ -41,24 +49,46 @@ export function ViewConnectorForm({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={handleSubmit(onSubmit)} data-testid="view-connector-form">
|
<>
|
||||||
<FormGroup label={t('Vega Pubkey')} labelFor="address">
|
<button
|
||||||
<Input
|
onClick={reset}
|
||||||
{...register('address', {
|
className="absolute p-2 top-0 left-0 md:top-2 md:left-2"
|
||||||
required: t('Required'),
|
data-testid="back-button"
|
||||||
validate: validatePubkey,
|
>
|
||||||
})}
|
<Icon name={'chevron-left'} ariaLabel="back" size={4} />
|
||||||
id="address"
|
</button>
|
||||||
data-testid="address"
|
<form onSubmit={handleSubmit(onSubmit)} data-testid="view-connector-form">
|
||||||
type="text"
|
<h1 className="text-2xl uppercase mb-6 text-center font-alpha">
|
||||||
/>
|
{t('VIEW AS VEGA USER')}
|
||||||
{errors.address?.message && (
|
</h1>
|
||||||
<InputError intent="danger">{errors.address.message}</InputError>
|
<p className="mb-4">
|
||||||
)}
|
{t(
|
||||||
</FormGroup>
|
'Browse from the perspective of another Vega user in read-only mode.'
|
||||||
<Button data-testid="connect" variant="primary" type="submit" fill={true}>
|
)}
|
||||||
{t('Connect')}
|
</p>
|
||||||
</Button>
|
<FormGroup label={t('Vega Pubkey')} labelFor="address">
|
||||||
</form>
|
<Input
|
||||||
|
{...register('address', {
|
||||||
|
required: t('Required'),
|
||||||
|
validate: validatePubkey,
|
||||||
|
})}
|
||||||
|
id="address"
|
||||||
|
data-testid="address"
|
||||||
|
type="text"
|
||||||
|
/>
|
||||||
|
{errors.address?.message && (
|
||||||
|
<InputError intent="danger">{errors.address.message}</InputError>
|
||||||
|
)}
|
||||||
|
</FormGroup>
|
||||||
|
<Button
|
||||||
|
data-testid="connect"
|
||||||
|
variant="primary"
|
||||||
|
type="submit"
|
||||||
|
fill={true}
|
||||||
|
>
|
||||||
|
{t('Browse network')}
|
||||||
|
</Button>
|
||||||
|
</form>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user