Skip to content

Commit

Permalink
chore: remove account type selection buttons from some account creati…
Browse files Browse the repository at this point in the history
…on screens
  • Loading branch information
chidg committed Dec 30, 2024
1 parent 1f03050 commit b629b54
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,21 @@ const Content = () => {
const urlParamType = (params.get("type") ?? undefined) as AccountAddressType | undefined
const { setAddress } = useSelectAccountAndNavigate("/portfolio")

const accountTypeString = () => {
switch (urlParamType) {
case "ethereum":
return " Ethereum"
case "sr25519":
return " Polkadot"
default:
return ""
}
}

return (
<>
<HeaderBlock
title={t("Create a new account")}
title={t(`Create a new${accountTypeString()} account`)}
text={!urlParamType && t("What type of account would you like to create?")}
/>
<Spacer small />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,21 @@ export const Content = () => {
const urlParamType = (params.get("type") ?? undefined) as AccountAddressType | undefined
const { setAddress } = useSelectAccountAndNavigate("/portfolio")

const accountTypeString = () => {
switch (urlParamType) {
case "ethereum":
return " Ethereum"
case "sr25519":
return " Polkadot"
default:
return ""
}
}

return (
<>
<HeaderBlock
title={t("Add a watched account")}
title={t(`Add a watched${accountTypeString()} account`)}
text={!urlParamType && t("What type of account would you like to create?")}
/>
<Spacer small />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ const AccountAddDerivedFormInner: FC<AccountAddPageProps> = ({ onSuccess }) => {
// get type paramter from url
const [params] = useSearchParams()
const urlParamType = (params.get("type") ?? undefined) as UiAccountAddressType | undefined
const disableOtherTypes = params.has("disableOtherTypes")
const mnemonics = useMnemonics()
const allAccounts = useAccounts()
const accountNames = useMemo(() => allAccounts.map((a) => a.name), [allAccounts])
Expand Down Expand Up @@ -255,11 +254,9 @@ const AccountAddDerivedFormInner: FC<AccountAddPageProps> = ({ onSuccess }) => {

return (
<form onSubmit={handleSubmit(submit)}>
<AccountTypeSelector
defaultType={urlParamType}
disableOtherTypes={disableOtherTypes}
onChange={handleTypeChange}
/>
{!urlParamType && (
<AccountTypeSelector defaultType={urlParamType} onChange={handleTypeChange} />
)}
<Spacer small />
<div className={classNames("transition-opacity", type ? "opacity-100" : "opacity-0")}>
{!!mnemonics.length && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export const AccountAddWatchedForm = ({ onSuccess }: AccountAddPageProps) => {
// get type paramter from url
const [params] = useSearchParams()
const urlParamType = (params.get("type") ?? undefined) as UiAccountAddressType | undefined
const disableOtherTypes = params.has("disableOtherTypes")
const allAccounts = useAccounts()
const accountNames = useMemo(() => allAccounts.map((a) => a.name), [allAccounts])

Expand Down Expand Up @@ -152,11 +151,9 @@ export const AccountAddWatchedForm = ({ onSuccess }: AccountAddPageProps) => {
return (
<form onSubmit={handleSubmit(submit)}>
<div className="flex flex-col gap-16">
<AccountTypeSelector
defaultType={urlParamType}
disableOtherTypes={disableOtherTypes}
onChange={handleTypeChange}
/>
{!urlParamType && (
<AccountTypeSelector defaultType={urlParamType} onChange={handleTypeChange} />
)}
<div className={classNames("transition-opacity", type ? "opacity-100" : "opacity-0")}>
<div>
<p className="text-body-secondary">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ function NewAccountMethodButtons() {
/>
}
type="ethereum"
to={`/accounts/add/derived?type=ethereum${accountType ? "&disableOtherTypes" : ""}`}
to={`/accounts/add/derived?type=ethereum`}
/>
<AccountTypeMethodButton
disabled={accountType === "ethereum"}
Expand All @@ -134,7 +134,7 @@ function NewAccountMethodButtons() {
/>
}
type="polkadot"
to={`/accounts/add/derived?type=sr25519${accountType ? "&disableOtherTypes" : ""}`}
to={`/accounts/add/derived?type=sr25519`}
/>
</>
)
Expand Down Expand Up @@ -218,7 +218,7 @@ function WatchedAccountMethodButtons() {
/>
}
type="ethereum"
to={`/accounts/add/watched?type=ethereum${accountType ? "&disableOtherTypes" : ""}`}
to={`/accounts/add/watched?type=ethereum`}
/>
<AccountTypeMethodButton
disabled={accountType === "ethereum"}
Expand All @@ -231,7 +231,7 @@ function WatchedAccountMethodButtons() {
/>
}
type="polkadot"
to={`/accounts/add/watched?type=sr25519${accountType ? "&disableOtherTypes" : ""}`}
to={`/accounts/add/watched?type=sr25519`}
/>
</>
)
Expand Down
4 changes: 0 additions & 4 deletions apps/extension/src/ui/domains/Account/AccountTypeSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,12 @@ const AccountTypeButton: FC<{

type AccountTypeSelectorProps = {
defaultType?: UiAccountAddressType
disableOtherTypes?: boolean
onChange: (type: UiAccountAddressType) => void
className?: string
}

export const AccountTypeSelector = ({
defaultType,
disableOtherTypes,
onChange,
className,
}: AccountTypeSelectorProps) => {
Expand Down Expand Up @@ -70,7 +68,6 @@ export const AccountTypeSelector = ({
{t("Ethereum, Base, zkSync, Arbitrum, BSC, and all EVM chains")}
</div>
}
disabled={disableOtherTypes && defaultType !== "ethereum"}
onClick={handleClick("ethereum")}
/>
<AccountTypeButton
Expand All @@ -85,7 +82,6 @@ export const AccountTypeSelector = ({
{t("Relay Chain, Asset Hub, Bittensor, and most Polkadot chains")}
</div>
}
disabled={disableOtherTypes && defaultType !== "sr25519"}
onClick={handleClick("sr25519")}
/>
</div>
Expand Down

0 comments on commit b629b54

Please sign in to comment.