Skip to content

Commit abb3d43

Browse files
refactor(ui): share connected and available account row layout
1 parent ea4b48d commit abb3d43

3 files changed

Lines changed: 26 additions & 50 deletions

File tree

‎packages/ui/src/mosaic/user-profile/user-profile-connect-account-row.view.tsx‎

Lines changed: 0 additions & 45 deletions
This file was deleted.

‎packages/ui/src/mosaic/user-profile/user-profile-connected-account-row.view.tsx‎

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { useState } from 'react';
22

33
import { Badge } from '../components/badge';
4+
import { Button } from '../components/button';
5+
import { Icon } from '../components/icon';
46
import { Section } from '../components/section';
57
import type { UserProfileMenuAction } from './user-profile-action-menu';
68
import { UserProfileActionMenu } from './user-profile-action-menu';
@@ -12,10 +14,12 @@ import { UserProfileRemoveConnectedAccountDialog } from './user-profile-remove-c
1214

1315
export function UserProfileConnectedAccountRowView({
1416
account,
17+
onConnect,
1518
onReconnect,
1619
onRemove,
1720
}: {
1821
account: UserProfileConnectedAccount;
22+
onConnect?: (id: string) => void;
1923
onReconnect?: (id: string) => void;
2024
onRemove?: (id: string) => void;
2125
}) {
@@ -28,7 +32,7 @@ export function UserProfileConnectedAccountRowView({
2832
actions.push({ label: m.remove, color: 'negative', onClick: () => setOpen(true) });
2933
}
3034
return (
31-
<Section.Row>
35+
<Section.Row xstyle={onConnect && styles.connectRow}>
3236
<Section.Item>
3337
<Section.Media size='lg'>
3438
<UserProfileConnectedProviderIcon {...account} />
@@ -47,7 +51,24 @@ export function UserProfileConnectedAccountRowView({
4751
</Section.Description>
4852
) : null}
4953
</Section.Content>
50-
{actions.length > 0 ? (
54+
{onConnect ? (
55+
<Section.Actions>
56+
<Button
57+
size='sm'
58+
variant='outline'
59+
color='neutral'
60+
aria-label={`${m.connect} ${account.provider}`}
61+
onClick={() => onConnect(account.id)}
62+
>
63+
{m.connect}
64+
<Icon
65+
name='arrow-right-top'
66+
placement='inline-end'
67+
size='sm'
68+
/>
69+
</Button>
70+
</Section.Actions>
71+
) : actions.length > 0 ? (
5172
<Section.Actions>
5273
<UserProfileActionMenu
5374
label={`${m.manage} ${account.provider}`}
@@ -67,6 +88,7 @@ export function UserProfileConnectedAccountRowView({
6788
</Section.Actions>
6889
) : null}
6990
</Section.Item>
91+
{account.connectError ? <Section.Error>{account.connectError}</Section.Error> : null}
7092
{account.reconnectError ? <Section.Error>{account.reconnectError}</Section.Error> : null}
7193
{account.status === 'error' && account.verificationError ? (
7294
<Section.Error>{account.verificationError}</Section.Error>

‎packages/ui/src/mosaic/user-profile/user-profile-connected-accounts-section.view.tsx‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Section } from '../components/section';
2-
import { UserProfileConnectAccountRowView } from './user-profile-connect-account-row.view';
32
import { UserProfileConnectedAccountRowView } from './user-profile-connected-account-row.view';
43
import { userProfileConnectedAccountsMessages as m } from './user-profile-connected-accounts.messages';
54

@@ -50,9 +49,9 @@ export function UserProfileConnectedAccountsSectionView({
5049
))}
5150
{onConnect
5251
? availableProviders.map(provider => (
53-
<UserProfileConnectAccountRowView
52+
<UserProfileConnectedAccountRowView
5453
key={provider.id}
55-
provider={provider}
54+
account={provider}
5655
onConnect={onConnect}
5756
/>
5857
))

0 commit comments

Comments
 (0)