fix: only allow editing active key
This commit is contained in:
parent
3fa4fda718
commit
540eb94d84
@ -94,6 +94,7 @@ export const VegaWalletConnectButton = ({
|
|||||||
<KeypairRadioGroup
|
<KeypairRadioGroup
|
||||||
pubKey={pubKey}
|
pubKey={pubKey}
|
||||||
pubKeys={pubKeys}
|
pubKeys={pubKeys}
|
||||||
|
activeKey={activeKey?.publicKey}
|
||||||
onSelect={selectPubKey}
|
onSelect={selectPubKey}
|
||||||
/>
|
/>
|
||||||
<TradingDropdownSeparator />
|
<TradingDropdownSeparator />
|
||||||
@ -138,10 +139,12 @@ export const VegaWalletConnectButton = ({
|
|||||||
const KeypairRadioGroup = ({
|
const KeypairRadioGroup = ({
|
||||||
pubKey,
|
pubKey,
|
||||||
pubKeys,
|
pubKeys,
|
||||||
|
activeKey,
|
||||||
onSelect,
|
onSelect,
|
||||||
}: {
|
}: {
|
||||||
pubKey: string | undefined;
|
pubKey: string | undefined;
|
||||||
pubKeys: Key[];
|
pubKeys: Key[];
|
||||||
|
activeKey: string | undefined;
|
||||||
onSelect: (pubKey: string) => void;
|
onSelect: (pubKey: string) => void;
|
||||||
}) => {
|
}) => {
|
||||||
const { data } = usePartyProfilesQuery({
|
const { data } = usePartyProfilesQuery({
|
||||||
@ -157,14 +160,27 @@ const KeypairRadioGroup = ({
|
|||||||
(e) => e.node.partyId === pk.publicKey
|
(e) => e.node.partyId === pk.publicKey
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
<KeypairItem key={pk.publicKey} pk={pk} alias={profile?.node.alias} />
|
<KeypairItem
|
||||||
|
key={pk.publicKey}
|
||||||
|
pk={pk}
|
||||||
|
isActive={activeKey === pk.publicKey}
|
||||||
|
alias={profile?.node.alias}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</TradingDropdownRadioGroup>
|
</TradingDropdownRadioGroup>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const KeypairItem = ({ pk, alias }: { pk: Key; alias: string | undefined }) => {
|
const KeypairItem = ({
|
||||||
|
pk,
|
||||||
|
isActive,
|
||||||
|
alias,
|
||||||
|
}: {
|
||||||
|
pk: Key;
|
||||||
|
alias: string | undefined;
|
||||||
|
isActive: boolean;
|
||||||
|
}) => {
|
||||||
const t = useT();
|
const t = useT();
|
||||||
const [copied, setCopied] = useCopyTimeout();
|
const [copied, setCopied] = useCopyTimeout();
|
||||||
const setOpen = useProfileDialogStore((store) => store.setOpen);
|
const setOpen = useProfileDialogStore((store) => store.setOpen);
|
||||||
@ -201,7 +217,7 @@ const KeypairItem = ({ pk, alias }: { pk: Key; alias: string | undefined }) => {
|
|||||||
className="flex items-center gap-1"
|
className="flex items-center gap-1"
|
||||||
>
|
>
|
||||||
{alias ? alias : t('No alias')}
|
{alias ? alias : t('No alias')}
|
||||||
<VegaIcon name={VegaIconNames.EDIT} />
|
{isActive && <VegaIcon name={VegaIconNames.EDIT} />}
|
||||||
</button>
|
</button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
|
@ -131,16 +131,18 @@ const KeypairListItem = ({
|
|||||||
data-testid={`key-${pk.publicKey}`}
|
data-testid={`key-${pk.publicKey}`}
|
||||||
>
|
>
|
||||||
<span className="truncate">{alias ? alias : t('No alias')}</span>
|
<span className="truncate">{alias ? alias : t('No alias')}</span>
|
||||||
<button
|
{isActive && (
|
||||||
data-testid="alias"
|
<button
|
||||||
onClick={() => {
|
data-testid="alias"
|
||||||
setOpen(pk.publicKey);
|
onClick={() => {
|
||||||
setMenu(null);
|
setOpen(pk.publicKey);
|
||||||
}}
|
setMenu(null);
|
||||||
className="flex items-center gap-1"
|
}}
|
||||||
>
|
className="flex items-center gap-1"
|
||||||
<VegaIcon name={VegaIconNames.EDIT} />
|
>
|
||||||
</button>
|
<VegaIcon name={VegaIconNames.EDIT} />
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user