Skip to content

Commit e4e8c07

Browse files
committed
refactor(ui): name the UserButton account line by identifier, not email
1 parent 35b52a9 commit e4e8c07

2 files changed

Lines changed: 13 additions & 12 deletions

File tree

‎packages/ui/src/mosaic/user-button/__tests__/user-button.view.test.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import { userButtonBusyKeys, UserButtonView } from '../user-button.view';
1212
// this is the only place the three surfaces can be told apart. One describe per mode covers what
1313
// each carries and withholds; the describes after them cover what the modes share.
1414

15-
const alice = { sessionId: 'sess_1', name: 'Alice Smith', email: 'alice@example.com' };
16-
const bob = { sessionId: 'sess_2', name: 'Bob Jones', email: 'bob@example.com' };
15+
const alice = { sessionId: 'sess_1', name: 'Alice Smith', identifier: 'alice@example.com' };
16+
const bob = { sessionId: 'sess_2', name: 'Bob Jones', identifier: 'bob@example.com' };
1717

1818
const foundry = {
1919
kind: 'membership',
@@ -82,7 +82,7 @@ const scrollClasses = stylex.props(...scrollAreaViewport('auto')).className?.spl
8282
/** The workspace list: the one group in the popup that scrolls. */
8383
const workspaceList = () => groups().find(group => scrollClasses.every(name => group.classList.contains(name)));
8484

85-
/** The accounts group: the one whose rows are titled by email rather than by workspace name. */
85+
/** The accounts group: the one whose rows are titled by identifier rather than by workspace name. */
8686
const accountsList = () =>
8787
groups().find(group => group !== workspaceList() && titles(group).some(title => title.includes('@')));
8888

‎packages/ui/src/mosaic/user-button/user-button.view.tsx‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ import { styles, triggerShapes } from './user-button.styles';
2929
export interface UserButtonSession {
3030
sessionId: string;
3131
name: string;
32-
email: string;
32+
/** Whatever the account is addressed by: username, email, phone, or wallet. */
33+
identifier: string;
3334
imageUrl?: string;
3435
}
3536

@@ -446,9 +447,9 @@ function HeaderActionButton({ label, icon, onClick, busyKey }: HeaderAction) {
446447
function Header() {
447448
const data = useUserButtonContext();
448449
const signOutSession = data.onSignOutSession;
449-
const { sessionId, email } = data.activeSession;
450+
const { sessionId, identifier } = data.activeSession;
450451
const { name, imageUrl, shape, organization } = leadWorkspace(data);
451-
const subtitle = organization ? membershipSubtitle(organization) : email;
452+
const subtitle = organization ? membershipSubtitle(organization) : identifier;
452453
// Inviting belongs to whichever organization is active, even where the account is what heads the
453454
// surface. The gear manages whatever the header names.
454455
const invitable = showsOrganizations(data) ? data.activeOrganization : null;
@@ -537,13 +538,13 @@ function ActionMenu({ label, actions, disabled }: { label: string; actions: Acco
537538
}
538539

539540
/**
540-
* The active account, identified by its email. It heads the workspaces that belong to it and
541+
* The active account, named by its identifier. It heads the workspaces that belong to it and
541542
* carries the account-wide actions, the way the "Accounts" row heads the other accounts.
542543
*/
543544
function ActiveAccountRow() {
544545
const data = useUserButtonContext();
545546
const signOutSession = data.onSignOutSession;
546-
const { email, sessionId } = data.activeSession;
547+
const { identifier, sessionId } = data.activeSession;
547548
// Its actions live in a menu that closes on click, so the row itself carries their spinner.
548549
const { busy, disabled } = useBusy(userButtonBusyKeys.signOutSession(sessionId));
549550

@@ -570,7 +571,7 @@ function ActiveAccountRow() {
570571
fontWeight: fontWeightVars['--cl-font-medium'],
571572
}}
572573
>
573-
{email}
574+
{identifier}
574575
</Item.Description>
575576
</Item.Content>
576577
{busy ? (
@@ -579,7 +580,7 @@ function ActiveAccountRow() {
579580
</Trailing>
580581
) : (
581582
<ActionMenu
582-
label={`Actions for ${email}`}
583+
label={`Actions for ${identifier}`}
583584
actions={actions}
584585
disabled={disabled}
585586
/>
@@ -787,8 +788,8 @@ function AccountRow({ session, active }: { session: UserButtonSession; active?:
787788
/>
788789
</Item.Media>
789790
<Item.Content>
790-
{/* Identified by email, like the active account's row, so the two read as the same kind. */}
791-
<Item.Title>{session.email}</Item.Title>
791+
{/* Named by its identifier, like the active account's row, so the two read as the same kind. */}
792+
<Item.Title>{session.identifier}</Item.Title>
792793
</Item.Content>
793794
{busy ? (
794795
<Trailing>

0 commit comments

Comments
 (0)