Skip to content

Commit

Permalink
[PM-5430] Separate Active Account from other accounts (#7374)
Browse files Browse the repository at this point in the history
* make spacing consistent between log out and lock all buttons

* update color of avatar when no active account

* separate active account from other available accounts

* remove unnecessary ng-container
  • Loading branch information
rr-bw authored Jan 2, 2024
1 parent ec417cf commit 565846f
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 8 deletions.
3 changes: 3 additions & 0 deletions apps/browser/src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2835,6 +2835,9 @@
"activeAccount": {
"message": "Active account"
},
"availableAccounts": {
"message": "Available accounts"
},
"accountLimitReached": {
"message": "Account limit reached. Log out of an account to add another."
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,20 @@
<div class="tw-p-2">
<div *ngIf="availableAccounts$ | async as availableAccounts">
<ul class="tw-grid tw-list-none tw-gap-2" role="listbox">
<li *ngFor="let availableAccount of availableAccounts" role="option">
<auth-account [account]="availableAccount" (loading)="loading = $event"></auth-account>
</li>
<ng-container
*ngFor="let availableAccount of availableAccounts; first as isFirst"
role="option"
>
<li *ngIf="availableAccount.isActive" class="tw-mb-4">
<auth-account [account]="availableAccount" (loading)="loading = $event"></auth-account>
</li>
<div *ngIf="isFirst" class="tw-uppercase tw-text-muted">
{{ "availableAccounts" | i18n }}
</div>
<li *ngIf="!availableAccount.isActive">
<auth-account [account]="availableAccount" (loading)="loading = $event"></auth-account>
</li>
</ng-container>
</ul>
<!--
If the user has not reached the account limit, the last 'availableAccount' will have an 'id' of
Expand Down Expand Up @@ -58,7 +69,7 @@
</button>
<button
type="button"
class="account-switcher-row tw-mt-2 tw-flex tw-w-full tw-items-center tw-gap-3 tw-rounded-md tw-p-3"
class="account-switcher-row tw-flex tw-w-full tw-items-center tw-gap-3 tw-rounded-md tw-p-3"
(click)="lockAll()"
>
<i class="bwi bwi-lock tw-text-2xl" aria-hidden="true"></i>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class AccountComponent {
}

get status() {
if (this.account.isActive && this.account.status !== AuthenticationStatus.Locked) {
if (this.account.isActive) {
return { text: this.i18nService.t("active"), icon: "bwi-check-circle" };
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<span class="tw-sr-only">{{ "switchAccounts" | i18n }}</span>
<bit-avatar
[text]="'&hellip;'"
[color]="'#175DDC'"
[color]="'#6795E8'"
size="small"
aria-hidden="true"
class="[&>img]:tw-block"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,21 @@ export class AccountSwitcherService {
options.push({
name: "Add account",
id: this.SPECIAL_ADD_ACCOUNT_ID,
isActive: activeAccount?.id == null,
isActive: false,
});
}

return options;
return options.sort((a, b) => {
// Active account is always first
if (a.isActive) {
return -1;
}

// "Add Account" button is always last
if (a.id === this.SPECIAL_ADD_ACCOUNT_ID) {
return 1;
}
});
}),
);

Expand Down

0 comments on commit 565846f

Please sign in to comment.