Skip to content

Commit

Permalink
Remove "plain" prop from address links and always show a normal link
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaw3d committed Mar 19, 2024
1 parent 9143fe8 commit 243c96f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 63 deletions.
7 changes: 3 additions & 4 deletions src/app/components/Account/AccountLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@ export const AccountLink: FC<{
scope: SearchScope
address: string
alwaysTrim?: boolean
plain?: boolean
}> = ({ scope, address, alwaysTrim, plain }) => {
}> = ({ scope, address, alwaysTrim }) => {
const { isTablet } = useScreenSize()
const to = RouteUtils.getAccountRoute(scope, address)
return (
<Typography variant="mono" component="span">
{alwaysTrim || isTablet ? (
<TrimLinkLabel label={address} to={to} plain={plain} />
<TrimLinkLabel label={address} to={to} />
) : (
<Link component={RouterLink} to={to} sx={{ fontWeight: plain ? 400 : undefined }}>
<Link component={RouterLink} to={to}>
{address}
</Link>
)}
Expand Down
54 changes: 9 additions & 45 deletions src/app/components/RuntimeEvents/RuntimeEventDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,7 @@ export const RuntimeEventDetails: FC<{
<StyledDescriptionList titleWidth={isMobile ? '100px' : '200px'}>
<dt>{t('runtimeEvent.fields.owner')}</dt>
<dd>
<AccountLink
address={event.body.owner}
scope={scope}
plain={addressSwitchOption !== AddressSwitchOption.Oasis}
/>
<AccountLink address={event.body.owner} scope={scope} />
{addressSwitchOption === AddressSwitchOption.Oasis && (
<CopyToClipboard value={event.body.owner} />
)}
Expand All @@ -247,22 +243,14 @@ export const RuntimeEventDetails: FC<{
<MaybeEventErrorLine event={event} />
<dt>{t('common.from')}</dt>
<dd>
<AccountLink
address={event.body.from}
scope={scope}
plain={addressSwitchOption !== AddressSwitchOption.Oasis}
/>
<AccountLink address={event.body.from} scope={scope} />
{addressSwitchOption === AddressSwitchOption.Oasis && (
<CopyToClipboard value={event.body.from} />
)}
</dd>
<dt>{t('common.to')}</dt>
<dd>
<AccountLink
address={event.body.to}
scope={scope}
plain={addressSwitchOption !== AddressSwitchOption.Oasis}
/>
<AccountLink address={event.body.to} scope={scope} />
{addressSwitchOption === AddressSwitchOption.Oasis && <CopyToClipboard value={event.body.to} />}
</dd>
<dt>{t('runtimeEvent.fields.amount')}</dt>
Expand All @@ -283,22 +271,14 @@ export const RuntimeEventDetails: FC<{
<MaybeEventErrorLine event={event} />
<dt>{t('common.from')}</dt>
<dd>
<AccountLink
address={event.body.from}
scope={scope}
plain={addressSwitchOption !== AddressSwitchOption.Oasis}
/>
<AccountLink address={event.body.from} scope={scope} />
{addressSwitchOption === AddressSwitchOption.Oasis && (
<CopyToClipboard value={event.body.from} />
)}
</dd>
<dt>{t('common.to')}</dt>
<dd>
<AccountLink
address={event.body.to}
scope={scope}
plain={addressSwitchOption !== AddressSwitchOption.Oasis}
/>
<AccountLink address={event.body.to} scope={scope} />
{addressSwitchOption === AddressSwitchOption.Oasis && <CopyToClipboard value={event.body.to} />}
</dd>
<dt>{t('runtimeEvent.fields.amount')}</dt>
Expand All @@ -319,22 +299,14 @@ export const RuntimeEventDetails: FC<{
<MaybeEventErrorLine event={event} />
<dt>{t('common.from')}</dt>
<dd>
<AccountLink
address={event.body.from}
scope={scope}
plain={addressSwitchOption !== AddressSwitchOption.Oasis}
/>
<AccountLink address={event.body.from} scope={scope} />
{addressSwitchOption === AddressSwitchOption.Oasis && (
<CopyToClipboard value={event.body.from} />
)}
</dd>
<dt>{t('common.to')}</dt>
<dd>
<AccountLink
address={event.body.to}
scope={scope}
plain={addressSwitchOption !== AddressSwitchOption.Oasis}
/>
<AccountLink address={event.body.to} scope={scope} />
{addressSwitchOption === AddressSwitchOption.Oasis && <CopyToClipboard value={event.body.to} />}
</dd>
<dt>{t('runtimeEvent.fields.activeShares')}</dt>
Expand All @@ -354,22 +326,14 @@ export const RuntimeEventDetails: FC<{
<MaybeEventErrorLine event={event} />
<dt>{t('common.from')}</dt>
<dd>
<AccountLink
address={event.body.from}
scope={scope}
plain={addressSwitchOption !== AddressSwitchOption.Oasis}
/>
<AccountLink address={event.body.from} scope={scope} />
{addressSwitchOption === AddressSwitchOption.Oasis && (
<CopyToClipboard value={event.body.from} />
)}
</dd>
<dt>{t('common.to')}</dt>
<dd>
<AccountLink
address={event.body.to}
scope={scope}
plain={addressSwitchOption !== AddressSwitchOption.Oasis}
/>
<AccountLink address={event.body.to} scope={scope} />
{addressSwitchOption === AddressSwitchOption.Oasis && <CopyToClipboard value={event.body.to} />}
</dd>
<dt>{t('runtimeEvent.fields.amount')}</dt>
Expand Down
7 changes: 3 additions & 4 deletions src/app/components/Transactions/TransactionLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,16 @@ export const TransactionLink: FC<{
alwaysTrim?: boolean
scope: SearchScope
hash: string
plain?: boolean
}> = ({ alwaysTrim, hash, scope, plain }) => {
}> = ({ alwaysTrim, hash, scope }) => {
const { isMobile } = useScreenSize()
const to = RouteUtils.getTransactionRoute(scope, hash)

return (
<Typography variant="mono">
{alwaysTrim || isMobile ? (
<TrimLinkLabel label={hash} to={to} plain={plain} />
<TrimLinkLabel label={hash} to={to} />
) : (
<Link component={RouterLink} to={to} sx={{ fontWeight: plain ? 400 : undefined }}>
<Link component={RouterLink} to={to}>
{hash}
</Link>
)}
Expand Down
13 changes: 6 additions & 7 deletions src/app/components/TrimLinkLabel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,36 @@ import { tooltipDelay } from '../../../styles/theme'
type TrimLinkLabelProps = {
label: string
to: string
plain?: boolean
}

export const TrimLinkLabel: FC<TrimLinkLabelProps> = ({ label, to, plain }) => {
export const TrimLinkLabel: FC<TrimLinkLabelProps> = ({ label, to }) => {
const trimmedLabel = trimLongString(label)
if (!trimmedLabel) {
return null
}
return <TrimLink label={label} to={to} trimmedLabel={trimmedLabel} plain={plain} />
return <TrimLink label={label} to={to} trimmedLabel={trimmedLabel} />
}

type TrimEndLinkLabelProps = TrimLinkLabelProps & {
trimStart: number
}

export const TrimEndLinkLabel: FC<TrimEndLinkLabelProps> = ({ label, to, plain, trimStart }) => {
export const TrimEndLinkLabel: FC<TrimEndLinkLabelProps> = ({ label, to, trimStart }) => {
const trimmedLabel = trimLongString(label, trimStart, 0)
if (!trimmedLabel) {
return null
}
return <TrimLink label={label} to={to} trimmedLabel={trimmedLabel} plain={plain} />
return <TrimLink label={label} to={to} trimmedLabel={trimmedLabel} />
}

type TrimLinkProps = TrimLinkLabelProps & {
trimmedLabel: string
}

const TrimLink: FC<TrimLinkProps> = ({ label, to, trimmedLabel, plain }) => {
const TrimLink: FC<TrimLinkProps> = ({ label, to, trimmedLabel }) => {
return (
<Tooltip arrow placement="top" title={label} enterDelay={tooltipDelay} enterNextDelay={tooltipDelay}>
<Link component={RouterLink} to={to} sx={{ fontWeight: plain ? 400 : undefined }}>
<Link component={RouterLink} to={to}>
{trimmedLabel}
</Link>
</Tooltip>
Expand Down
3 changes: 0 additions & 3 deletions src/app/pages/RuntimeTransactionDetailPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ export const RuntimeTransactionDetailView: FC<{
hash={
hash || ((isOasisAddressFormat ? transaction?.eth_hash : transaction?.hash) as string)
}
plain={!hash}
/>
</TransactionInfoTooltip>
{hash && <CopyToClipboard value={hash} />}
Expand Down Expand Up @@ -286,7 +285,6 @@ export const RuntimeTransactionDetailView: FC<{
from ||
((isOasisAddressFormat ? transaction?.sender_0_eth : transaction?.sender_0) as string)
}
plain={!from}
/>
</TransactionInfoTooltip>
{from && <CopyToClipboard value={from} />}
Expand All @@ -310,7 +308,6 @@ export const RuntimeTransactionDetailView: FC<{
<AccountLink
scope={transaction}
address={to || ((isOasisAddressFormat ? transaction?.to_eth : transaction?.to) as string)}
plain={!to}
/>
</TransactionInfoTooltip>
{to && <CopyToClipboard value={to} />}
Expand Down

0 comments on commit 243c96f

Please sign in to comment.