Skip to content

Commit

Permalink
feat: split the accounts from the list into two (#8186)
Browse files Browse the repository at this point in the history
* feat: split the accounts from the list into two WIP

* fix: remove index of accounts

* fix: improve styles

* fix: main account space

* fix: pending accounts space

* fix: missing return type on  isSelected function

---------

Co-authored-by: Begoña Álvarez de la Cruz <[email protected]>
  • Loading branch information
cpl121 and begonaalvarezd authored Mar 19, 2024
1 parent c9c4800 commit 0fc02c9
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 60 deletions.
3 changes: 1 addition & 2 deletions packages/desktop/components/AccountManagementDetails.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import { PopupId, openPopup } from '@auxiliary/popup'
export let selectedOutput: OutputData
export let index: number
let modal: Modal
let address: string = ''
Expand Down Expand Up @@ -128,7 +127,7 @@
<right-pane-title class="flex flex-col space-y-1">
<title-container class="flex justify-between w-full items-center">
<title-wrapper class="flex items-center space-x-2 py-1">
<Text type={TextType.h2}>{localize('views.accountManagement.list.tile.title')} {index}</Text>
<Text type={TextType.h2}>{localize('views.accountManagement.list.tile.title')}</Text>
{#if isImplicitAccount}
<Pill backgroundColor="yellow-200" textColor="yellow-900"
>{localize('views.accountManagement.list.tile.pill.pending')}</Pill
Expand Down
96 changes: 60 additions & 36 deletions packages/desktop/components/AccountManagementList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,22 @@
import { AccountAddress, AccountOutput, Output, OutputData } from '@iota/sdk/out/types'
import { Height, Pane, TextType, Text, ClickableTile, FontWeight, Pill } from '@ui'
import { localize } from '@core/i18n'
import { AddressConverter, isAccountOutput, isImplicitAccountOutput } from '@core/wallet/utils'
import { selectedWalletMainAccountId } from '@core/wallet'
import { AddressConverter } from '@core/wallet/utils'
import { selectedWalletMainAccountId, selectedWallet } from '@core/wallet'
export let onAccountClick: (account: OutputData) => void
export let allOutputs: OutputData[] = []
export let selectedOutput: OutputData
$: isSelected = (output: OutputData) => output.outputId === selectedOutput.outputId
$: isSelected = (output: OutputData): boolean => output.outputId === selectedOutput.outputId
$: accountsOrdered = $selectedWallet.accountOutputs.sort((a, b) =>
(a.output as AccountOutput).accountId > (b.output as AccountOutput).accountId ? 1 : -1
)
$: implicitAccountsOrdered = $selectedWallet.implicitAccountOutputs.sort((a, b) =>
a.outputId > b.outputId ? 1 : -1
)
function getAccountId(output: OutputData): string | undefined {
return isAccountOutput(output) ? (output.output as AccountOutput)?.accountId : undefined
function iMainAccount(output: Output): boolean {
return (output as AccountOutput).accountId === $selectedWalletMainAccountId
}
function formatAndTruncateAccount(output: Output): string {
Expand All @@ -27,42 +32,61 @@

<left-pane class="flex flex-col w-1/3">
<Pane height={Height.Full}>
<left-pane-container class="flex flex-col space-y-10 h-full">
<Text type={TextType.h2}>{localize('views.accountManagement.list.title')}</Text>
<list-wrapper class="flex flex-col space-y-2">
{#each allOutputs as output, index}
<ClickableTile onClick={() => onAccountClick(output)} selected={isSelected(output)}>
<div class="flex flex-col space-y-4">
<div class="flex space-x-2">
<Text
type={TextType.h5}
color="gray-800"
darkColor="gray-500"
fontWeight={FontWeight.semibold}
<left-pane-container class="flex flex-col space-y-4 h-full scrollable-y">
{#if accountsOrdered.length > 0}
<Text type={TextType.h2}>{localize('views.accountManagement.list.accountTitle')}</Text>
<list-wrapper class="flex flex-col space-y-2 px-2">
{#each accountsOrdered as output}
<ClickableTile onClick={() => onAccountClick(output)} selected={isSelected(output)}>
<div class="flex flex-col space-y-2">
<div class="flex space-x-2">
<Text
type={TextType.h5}
color="gray-800"
darkColor="gray-500"
fontWeight={FontWeight.semibold}
>
{localize('views.accountManagement.list.tile.title')}
</Text>
{#if iMainAccount(output.output)}
<Pill backgroundColor="blue-200" textColor="blue-600"
>{localize('views.accountManagement.list.tile.pill.main')}</Pill
>
{/if}
</div>
<Text type={TextType.p} fontSize="13" lineHeight="leading-140" color="gray-600"
>{formatAndTruncateAccount(output.output)}</Text
>
{localize('views.accountManagement.list.tile.title')}
{index + 1}
</Text>
{#if getAccountId(output) === $selectedWalletMainAccountId}
<Pill backgroundColor="blue-200" textColor="blue-600"
>{localize('views.accountManagement.list.tile.pill.main')}</Pill
</div>
</ClickableTile>
{/each}
</list-wrapper>
{/if}
<hr />
{#if implicitAccountsOrdered.length > 0}
<Text type={TextType.h2}>{localize('views.accountManagement.list.implicitTitle')}</Text>
<list-wrapper class="flex flex-col space-y-2 px-2">
{#each implicitAccountsOrdered as output}
<ClickableTile onClick={() => onAccountClick(output)} selected={isSelected(output)}>
<div class="flex flex-col space-y-4">
<div class="flex space-x-2">
<Text
type={TextType.h5}
color="gray-800"
darkColor="gray-500"
fontWeight={FontWeight.semibold}
>
{/if}
{#if isImplicitAccountOutput(output)}
{localize('views.accountManagement.list.tile.title')}
</Text>
<Pill backgroundColor="yellow-200" textColor="yellow-900"
>{localize('views.accountManagement.list.tile.pill.pending')}</Pill
>
{/if}
</div>
</div>
{#if isAccountOutput(output)}
<Text type={TextType.p} fontSize="13" lineHeight="leading-140" color="gray-600"
>{formatAndTruncateAccount(output.output)}</Text
>
{/if}
</div>
</ClickableTile>
{/each}
</list-wrapper>
</ClickableTile>
{/each}
</list-wrapper>
{/if}
</left-pane-container>
</Pane>
</left-pane>
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
processAndAddToActivities,
selectedWallet,
updateSelectedWallet,
AddressConverter,
} from '@core/wallet'
import { UnlockConditionType, PreparedTransaction, AccountOutput } from '@iota/sdk/out/types'
import { closePopup } from '@auxiliary/popup'
import { onMount } from 'svelte'
import { handleError } from '@core/error/handlers/handleError'
import { plainToInstance } from 'class-transformer'
import { api } from '@core/api'
import { getClient } from '@core/wallet/actions/getClient'
export let _onMount: (..._: any[]) => Promise<void> = async () => {}
Expand All @@ -25,7 +25,7 @@
$: address = {
type: 0,
pubKeyHash: api.bech32ToHex($selectedWallet.depositAddress),
pubKeyHash: AddressConverter.parseBech32Address($selectedWallet.depositAddress),
}
$: accountOutput = address
? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,19 @@
import features from '@features/features'
import { AccountManagementDetails, AccountManagementList } from '@components'
import { AccountOutput, OutputData } from '@iota/sdk/out/types'
import { isAccountOutput, isImplicitAccountOutput } from '@core/wallet'
import { Text } from '@ui'
import { localize } from '@core/i18n'
$: allAccountOutputs =
$selectedWallet?.walletUnspentOutputs?.filter(
(output) => isAccountOutput(output) || isImplicitAccountOutput(output)
) || []
let selectedOutput =
$selectedWallet?.walletUnspentOutputs?.find(
(output) => (output.output as AccountOutput)?.accountId === $selectedWallet.mainAccountId
) || allAccountOutputs?.[0]
$selectedWallet?.accountOutputs.find(
(output) => (output.output as AccountOutput)?.accountId === $selectedWallet?.mainAccountId
) ||
$selectedWallet?.accountOutputs?.[0] ||
$selectedWallet?.implicitAccountOutputs?.[0]
function handleAccountClick(account: OutputData): void {
selectedOutput = account
}
function setAccountOutputIndex(account: OutputData): number {
return allAccountOutputs.indexOf(account) + 1
}
</script>

{#if $selectedWallet}
Expand All @@ -34,14 +26,10 @@
{#if selectedOutput}
{#key $selectedWallet?.id}
{#if features.accountManagement.accountList.enabled}
<AccountManagementList
onAccountClick={handleAccountClick}
allOutputs={allAccountOutputs}
{selectedOutput}
/>
<AccountManagementList onAccountClick={handleAccountClick} {selectedOutput} />
{/if}
{#if features.accountManagement.accountDetails.enabled}
<AccountManagementDetails {selectedOutput} index={setAccountOutputIndex(selectedOutput)} />
<AccountManagementDetails {selectedOutput} />
{/if}
{/key}
{:else}
Expand Down
3 changes: 2 additions & 1 deletion packages/shared/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,8 @@
},
"accountManagement":{
"list": {
"title": "Your Accounts",
"accountTitle": " Accounts",
"implicitTitle": "Pending Accounts",
"tile": {
"title": "Account",
"pill": {
Expand Down

0 comments on commit 0fc02c9

Please sign in to comment.