Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove "Decoded" column from events to improve mobile layout #672

Merged
merged 3 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .changelog/672.internal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove "Decoded" column from events to improve mobile layout
80 changes: 35 additions & 45 deletions src/app/components/Transactions/LogEvent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const EvmLogRow: FC<{
)
}

const DecodedLogEvent: FC<{
const LogEvent: FC<{
scope: SearchScope
event: RuntimeEvent
addressSwitchOption: AddressSwitchOption
Expand Down Expand Up @@ -136,34 +136,30 @@ const DecodedLogEvent: FC<{
<dd>
<b>{event.evm_log_name}</b>
</dd>
{event.evm_log_params && event.evm_log_params.length > 0 && (
<>
{/*<dt>Params</dt>*/}
<dd>
<Table sx={{ border: '1px solid lightgray' }}>
<TableHead>
<TableRow>
<TableCell>{t('common.name')}</TableCell>
<TableCell>{t('common.type')}</TableCell>
<TableCell>{t('common.data')}</TableCell>
<TableCell />
</TableRow>
</TableHead>
<TableBody>
{event.evm_log_params.map((param, index) => (
<EvmLogRow
scope={scope}
key={`param-${index}`}
param={param}
addressSwitchOption={addressSwitchOption}
/>
))}
</TableBody>
</Table>
</dd>
</>
)}
</StyledDescriptionList>

{event.evm_log_params && event.evm_log_params.length > 0 && (
<Table sx={{ border: '1px solid lightgray' }}>
<TableHead>
<TableRow>
<TableCell>{t('common.name')}</TableCell>
<TableCell>{t('common.type')}</TableCell>
<TableCell>{t('common.data')}</TableCell>
<TableCell />
</TableRow>
</TableHead>
<TableBody>
{event.evm_log_params.map((param, index) => (
<EvmLogRow
scope={scope}
key={`param-${index}`}
param={param}
addressSwitchOption={addressSwitchOption}
/>
))}
</TableBody>
</Table>
)}
</div>
)

Expand All @@ -179,8 +175,11 @@ const DecodedLogEvent: FC<{
<AccountLink
address={event.body.owner}
scope={scope}
plain={addressSwitchOption === AddressSwitchOption.ETH}
plain={addressSwitchOption !== AddressSwitchOption.Oasis}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the point of this change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just more accurate: "We have oasis address, so plain when addressSwitchOption isn't what we have"

instead of "We have oasis address, so plain when addressSwitchOption is ETH"

/>
{addressSwitchOption === AddressSwitchOption.Oasis && (
<CopyToClipboard value={event.body.owner} />
)}
</dd>
<dt>{t('transactionEvent.fields.amount')}</dt>
<dd>
Expand All @@ -205,16 +204,20 @@ const DecodedLogEvent: FC<{
<AccountLink
address={event.body.from}
scope={scope}
plain={addressSwitchOption === AddressSwitchOption.ETH}
plain={addressSwitchOption !== AddressSwitchOption.Oasis}
/>
{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.ETH}
plain={addressSwitchOption !== AddressSwitchOption.Oasis}
/>
{addressSwitchOption === AddressSwitchOption.Oasis && <CopyToClipboard value={event.body.to} />}
</dd>
<dt>{t('transactionEvent.fields.amount')}</dt>
<dd>
Expand Down Expand Up @@ -244,23 +247,10 @@ export const TransactionLogEvent: FC<{
isFirst: boolean
addressSwitchOption: AddressSwitchOption
}> = ({ scope, event, isFirst, addressSwitchOption }) => {
const { t } = useTranslation()
const { isMobile } = useScreenSize()
const decoded = true // TODO: how do I know if this has been successfully decoded?

return (
<>
{!isFirst && <Divider variant="card" />}
<StyledDescriptionList titleWidth={isMobile ? '100px' : '200px'}>
{decoded && (
<>
<dt>{t('transactionEvent.decoded')}</dt>
<dd>
<DecodedLogEvent scope={scope} event={event} addressSwitchOption={addressSwitchOption} />
</dd>
</>
)}
</StyledDescriptionList>
<LogEvent scope={scope} event={event} addressSwitchOption={addressSwitchOption} />
</>
)
}