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

UX: added badge status in account list #23006

Merged
merged 41 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
fac11dd
added badge status component
NidhiKJha Feb 15, 2024
17216c5
updated test
NidhiKJha Feb 15, 2024
c3d40e8
updated badge status default for non connected state
NidhiKJha Feb 16, 2024
cb51a13
lint fix
NidhiKJha Feb 16, 2024
f1ba90a
lint fix
NidhiKJha Feb 19, 2024
a00a313
updated className
NidhiKJha Feb 21, 2024
fb8f6dc
converted components to typescript
NidhiKJha Feb 21, 2024
f28f25f
fixed story and lint errors
NidhiKJha Feb 21, 2024
88547e4
converted js to ts
NidhiKJha Feb 21, 2024
c44b404
added badge status in account list
NidhiKJha Feb 16, 2024
41bfe82
updated tests
NidhiKJha Feb 19, 2024
e355150
lint fix
NidhiKJha Feb 19, 2024
cd3b242
lint fix
NidhiKJha Feb 19, 2024
9c88195
lint fix
NidhiKJha Feb 19, 2024
aabfb33
added connected status component as parent for Badge Status
NidhiKJha Feb 19, 2024
ffca065
updated badge status stories
NidhiKJha Feb 19, 2024
ab380bc
import oytside of fencing
NidhiKJha Feb 20, 2024
d91168e
lint fix
NidhiKJha Feb 20, 2024
0910475
updated tests
NidhiKJha Feb 20, 2024
da3aea5
updated account picker test
NidhiKJha Feb 20, 2024
1db23f3
converted connected-status to ts
NidhiKJha Feb 21, 2024
95d9c89
moved connected-status back to js
NidhiKJha Feb 21, 2024
962ccf0
removed snaps condition
NidhiKJha Feb 21, 2024
e6d172f
fixed naming
NidhiKJha Feb 21, 2024
59ea9cf
updated lint errors and comments
NidhiKJha Feb 21, 2024
e4112ec
updated connected status to ts
NidhiKJha Feb 21, 2024
65eb0ac
added badge status in account list
NidhiKJha Feb 16, 2024
c3b36cc
updated tests
NidhiKJha Feb 19, 2024
c5b792e
lint fix
NidhiKJha Feb 19, 2024
312eebd
added connected status component as parent for Badge Status
NidhiKJha Feb 19, 2024
10d3b89
updated badge status stories
NidhiKJha Feb 19, 2024
605ca41
import oytside of fencing
NidhiKJha Feb 20, 2024
8ca5fcb
converted connected-status to ts
NidhiKJha Feb 21, 2024
1bde644
moved connected-status back to js
NidhiKJha Feb 21, 2024
d390ae5
fixed naming
NidhiKJha Feb 21, 2024
ae3e663
lint fix
zone-live Feb 21, 2024
a1e58fd
lint fix
NidhiKJha Feb 22, 2024
7238ad3
updated story
NidhiKJha Feb 22, 2024
056bd2c
added multichain flag for account badge
NidhiKJha Feb 23, 2024
04d8a10
lint fix
NidhiKJha Feb 23, 2024
58f9090
updates types
NidhiKJha Feb 26, 2024
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
3 changes: 3 additions & 0 deletions app/_locales/en/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,49 @@ exports[`AccountListItem renders AccountListItem component and shows account nam
class="mm-box multichain-account-list-item mm-box--padding-4 mm-box--display-flex mm-box--background-color-transparent"
>
<div
class="mm-box mm-text mm-avatar-base mm-avatar-base--size-sm mm-avatar-account mm-text--body-sm mm-text--text-transform-uppercase mm-box--margin-inline-end-2 mm-box--display-flex mm-box--justify-content-center mm-box--align-items-center mm-box--color-text-default mm-box--background-color-background-alternative mm-box--rounded-full mm-box--border-color-transparent box--border-style-solid box--border-width-1"
class="mm-box mm-box--display-none mm-box--sm:display-flex"
>
<div
class="mm-avatar-account__jazzicon"
class="mm-box mm-text mm-avatar-base mm-avatar-base--size-md mm-avatar-account mm-text--body-sm mm-text--text-transform-uppercase mm-box--margin-inline-end-2 mm-box--display-flex mm-box--justify-content-center mm-box--align-items-center mm-box--color-text-default mm-box--background-color-background-alternative mm-box--rounded-full mm-box--border-color-transparent box--border-style-solid box--border-width-1"
>
<div
style="border-radius: 50px; overflow: hidden; padding: 0px; margin: 0px; width: 24px; height: 24px; display: inline-block; background: rgb(250, 58, 0);"
class="mm-avatar-account__jazzicon"
>
<svg
height="24"
width="24"
x="0"
y="0"
<div
style="border-radius: 50px; overflow: hidden; padding: 0px; margin: 0px; width: 32px; height: 32px; display: inline-block; background: rgb(250, 58, 0);"
>
<rect
fill="#18CDF2"
height="24"
transform="translate(-0.786295127845455 -2.478213052095374) rotate(328.9 12 12)"
width="24"
x="0"
y="0"
/>
<rect
fill="#035E56"
height="24"
transform="translate(-13.723846281624033 7.94434640381145) rotate(176.2 12 12)"
width="24"
<svg
height="32"
width="32"
x="0"
y="0"
/>
<rect
fill="#F26602"
height="24"
transform="translate(12.500881513667943 -10.653854792247811) rotate(468.9 12 12)"
width="24"
x="0"
y="0"
/>
</svg>
>
<rect
fill="#18CDF2"
height="32"
transform="translate(-1.04839350379394 -3.3042840694604987) rotate(328.9 16 16)"
width="32"
x="0"
y="0"
/>
<rect
fill="#035E56"
height="32"
transform="translate(-18.298461708832043 10.5924618717486) rotate(176.2 16 16)"
width="32"
x="0"
y="0"
/>
<rect
fill="#F26602"
height="32"
transform="translate(16.667842018223922 -14.205139722997082) rotate(468.9 16 16)"
width="32"
x="0"
y="0"
/>
</svg>
</div>
</div>
</div>
</div>
Expand Down
40 changes: 28 additions & 12 deletions ui/components/multichain/account-list-item/account-list-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import {
} from '../../../selectors';
import { useAccountTotalFiatBalance } from '../../../hooks/useAccountTotalFiatBalance';
import { TEST_NETWORKS } from '../../../../shared/constants/network';
import { ConnectedStatus } from '../connected-status/connected-status';

const MAXIMUM_CURRENCY_DECIMALS = 3;
const MAXIMUM_CHARACTERS_WITHOUT_TOOLTIP = 17;
Expand All @@ -71,14 +72,15 @@ export const AccountListItem = ({
showOptions = false,
isHidden = false,
currentTabOrigin,
isActive = false,
}) => {
const t = useI18nContext();
const [accountOptionsMenuOpen, setAccountOptionsMenuOpen] = useState(false);
const [accountListItemMenuElement, setAccountListItemMenuElement] =
useState();

const useBlockie = useSelector(getUseBlockie);
const currentNetwork = useSelector(getCurrentNetwork);

const setAccountListItemMenuRef = (ref) => {
setAccountListItemMenuElement(ref);
};
Expand Down Expand Up @@ -140,17 +142,27 @@ export const AccountListItem = ({
backgroundColor={Color.primaryDefault}
/>
)}
<AvatarAccount
borderColor={BorderColor.transparent}
size={Size.SM}
address={identity.address}
variant={
useBlockie
? AvatarAccountVariant.Blockies
: AvatarAccountVariant.Jazzicon
}
marginInlineEnd={2}
/>
{process.env.MULTICHAIN && (
<Box
display={[Display.Flex, Display.None]}
data-testid="account-list-item-badge"
>
<ConnectedStatus address={identity.address} isActive={isActive} />
</Box>
)}
<Box display={[Display.None, Display.Flex]}>
<AvatarAccount
borderColor={BorderColor.transparent}
size={Size.MD}
address={identity.address}
variant={
useBlockie
? AvatarAccountVariant.Blockies
: AvatarAccountVariant.Jazzicon
}
marginInlineEnd={2}
/>
</Box>
<Box
display={Display.Flex}
flexDirection={FlexDirection.Column}
Expand Down Expand Up @@ -380,6 +392,10 @@ AccountListItem.propTypes = {
* Represents current tab origin
*/
currentTabOrigin: PropTypes.string,
/**
* Represents active accounts
*/
isActive: PropTypes.bool,
};

AccountListItem.displayName = 'AccountListItem';
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ const render = (props = {}) => {
...mockState.metamask,
},
activeTab: {
origin: 'https://uniswap.org/',
id: 113,
title: 'E2E Test Dapp',
origin: 'https://metamask.github.io',
protocol: 'https:',
url: 'https://metamask.github.io/test-dapp/',
},
});
const allProps = { ...DEFAULT_PROPS, ...props };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ export const AccountListMenu = ({
isPinned={Boolean(account.pinned)}
isHidden={Boolean(account.hidden)}
currentTabOrigin={currentTabOrigin}
isActive={Boolean(account.active)}
{...accountListItemProps}
/>
</Box>
Expand Down
137 changes: 137 additions & 0 deletions ui/components/multichain/account-list-menu/account-list-menu.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,44 @@ jest.mock('../../../../app/scripts/lib/util', () => ({
const render = (props = { onClose: () => jest.fn() }) => {
const store = configureStore({
...mockState,
metamask: {
...mockState.metamask,
permissionHistory: {
'https://test.dapp': {
eth_accounts: {
accounts: {
'0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc': 1596681857076,
},
},
},
},
subjects: {
'https://test.dapp': {
permissions: {
eth_accounts: {
caveats: [
{
type: 'restrictReturnedAccounts',
value: ['0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc'],
},
],
invoker: 'https://test.dapp',
parentCapability: 'eth_accounts',
},
},
},
},
},
activeTab: {
id: 113,
title: 'E2E Test Dapp',
origin: 'https://metamask.github.io',
protocol: 'https:',
url: 'https://metamask.github.io/test-dapp/',
},
unconnectedAccount: {
state: 'OPEN',
},
});
return renderWithProvider(<AccountListMenu {...props} />, store);
};
Expand Down Expand Up @@ -96,8 +127,36 @@ describe('AccountListMenu', () => {
protocol: 'https:',
url: 'https://remix.ethereum.org/',
},
unconnectedAccount: {
state: 'OPEN',
},
metamask: {
...mockState.metamask,
permissionHistory: {
'https://test.dapp': {
eth_accounts: {
accounts: {
'0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc': 1596681857076,
},
},
},
},
subjects: {
'https://test.dapp': {
permissions: {
eth_accounts: {
caveats: [
{
type: 'restrictReturnedAccounts',
value: ['0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc'],
},
],
invoker: 'https://test.dapp',
parentCapability: 'eth_accounts',
},
},
},
},
accounts: {
'0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc': {
balance: '0x346ba7725f412cbfdb',
Expand Down Expand Up @@ -200,6 +259,31 @@ describe('AccountListMenu', () => {
metamask: {
...mockState.metamask,
...state,
permissionHistory: {
'https://test.dapp': {
eth_accounts: {
accounts: {
'0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc': 1596681857076,
},
},
},
},
subjects: {
'https://test.dapp': {
permissions: {
eth_accounts: {
caveats: [
{
type: 'restrictReturnedAccounts',
value: ['0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc'],
},
],
invoker: 'https://test.dapp',
parentCapability: 'eth_accounts',
},
},
},
},
},
},
activeTab: {
Expand Down Expand Up @@ -273,8 +357,36 @@ describe('AccountListMenu', () => {
protocol: 'https:',
url: 'https://remix.ethereum.org/',
},
unconnectedAccount: {
state: 'OPEN',
},
metamask: {
...mockState.metamask,
permissionHistory: {
'https://test.dapp': {
eth_accounts: {
accounts: {
'0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc': 1596681857076,
},
},
},
},
subjects: {
'https://test.dapp': {
permissions: {
eth_accounts: {
caveats: [
{
type: 'restrictReturnedAccounts',
value: ['0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc'],
},
],
invoker: 'https://test.dapp',
parentCapability: 'eth_accounts',
},
},
},
},
internalAccounts: {
...mockState.metamask.internalAccounts,
accounts: {
Expand Down Expand Up @@ -312,6 +424,31 @@ describe('AccountListMenu', () => {
},
metamask: {
...mockState.metamask,
permissionHistory: {
'https://test.dapp': {
eth_accounts: {
accounts: {
'0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc': 1596681857076,
},
},
},
},
subjects: {
'https://test.dapp': {
permissions: {
eth_accounts: {
caveats: [
{
type: 'restrictReturnedAccounts',
value: ['0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc'],
},
],
invoker: 'https://test.dapp',
parentCapability: 'eth_accounts',
},
},
},
},
internalAccounts: {
...mockState.metamask.internalAccounts,
accounts: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`Badge Status should render correctly 1`] = `
<div>
<button
class="mm-box multichain-badge-status mm-box--display-flex mm-box--justify-content-center mm-box--align-items-center mm-box--background-color-background-default"
class="mm-box multichain-badge-status mm-box--display-flex mm-box--justify-content-center mm-box--align-items-center mm-box--background-color-transparent"
data-testid="multichain-badge-status"
>
<div>
Expand Down
2 changes: 1 addition & 1 deletion ui/components/multichain/badge-status/badge-status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const BadgeStatus: React.FC<BadgeStatusProps> = ({
display={Display.Flex}
alignItems={AlignItems.center}
justifyContent={JustifyContent.center}
backgroundColor={BackgroundColor.backgroundDefault}
backgroundColor={BackgroundColor.transparent}
{...(props as BoxProps<'div'>)}
>
<Tooltip
Expand Down
3 changes: 2 additions & 1 deletion ui/components/multichain/badge-status/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
z-index: 1;
}

.mm-badge-wrapper__badge-container { //Need to override the zIndex, can't do it with badgeProps.
.mm-badge-wrapper__badge-container {
//Need to override the zIndex, can't do it with badgeProps.
z-index: 1;
}

Expand Down
Loading
Loading