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

[PM-3810] Unify Passkeys view #6335

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 0 additions & 6 deletions apps/browser/src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2425,15 +2425,9 @@
"application": {
"message": "Application"
},
"passkeyEditInformation": {
"message": "You cannot edit passkey application because it would invalidate the passkey."
},
"duplicatePasskey": {
"message": "A passkey with this ID already exists in this organization."
},
"passkeyTwoStepLogin": {
"message": "Available for two-step login"
},
"passkeyNotCopied": {
"message": "Passkey will not be copied"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,41 +100,3 @@
<i class="bwi bwi-lg bwi-clone" aria-hidden="true"></i>
</button>
</ng-container>
<ng-container *ngIf="cipher.type === cipherType.Fido2Key">
<button
type="button"
class="row-btn"
appStopClick
appStopProp
appA11yTitle="{{ 'launch' | i18n }}"
(click)="launchCipher()"
*ngIf="!showView"
[ngClass]="{ disabled: !cipher.fido2Key.canLaunch }"
[attr.disabled]="!cipher.fido2Key.canLaunch ? '' : null"
>
<i class="bwi bwi-lg bwi-share-square" aria-hidden="true"></i>
</button>
<button
type="button"
class="row-btn"
appStopClick
appStopProp
appA11yTitle="{{ 'copyUsername' | i18n }}"
(click)="copy(cipher, cipher.fido2Key.userDisplayName, 'username', 'Username')"
[ngClass]="{ disabled: !cipher.fido2Key.userDisplayName }"
[attr.disabled]="!cipher.fido2Key.userDisplayName ? '' : null"
>
<i class="bwi bwi-lg bwi-user" aria-hidden="true"></i>
</button>
<button
type="button"
class="row-btn"
appStopClick
appStopProp
appA11yTitle="{{ 'loginPasskey' | i18n }}"
[ngClass]="{ disabled: true }"
disabled
>
<i class="bwi bwi-lg bwi-passkey" aria-hidden="true"></i>
</button>
</ng-container>
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ <h1 class="center">
<h2 class="box-header">
{{ "itemInformation" | i18n }}
</h2>
<div class="box-footer" *ngIf="cipher.type === cipherType.Fido2Key">
{{ "passkeyEditInformation" | i18n }}
</div>
<div class="box-content">
<div class="box-content-row" *ngIf="!editMode" appBoxRow>
<label for="type">{{ "type" | i18n }}</label>
Expand Down Expand Up @@ -138,7 +135,8 @@ <h2 class="box-header">
<div class="box-content">
<div class="box-content-row text-muted">
<span class="row-label">{{ "typePasskey" | i18n }}</span>
{{ "passkeyTwoStepLogin" | i18n }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: should this string be removed from the translation file?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it should

{{ "dateCreated" | i18n }}
{{ cipher.login.fido2Keys[0].creationDate | date : "short" }}
</div>
</div>
</div>
Expand Down Expand Up @@ -475,39 +473,6 @@ <h2 class="box-header">
/>
</div>
</div>
<!-- Fido2Key -->
<div *ngIf="cipher.type === cipherType.Fido2Key">
<div class="box-content-row" appBoxRow>
<label for="fido2KeyUserDisplayName">{{ "username" | i18n }}</label>
<input
id="fido2KeyUserDisplayName"
type="text"
name="Fido2Key.UserDisplayName"
[(ngModel)]="cipher.fido2Key.userDisplayName"
appInputVerbatim
[readonly]="!cipher.edit && editMode"
/>
</div>
<div class="box-content-row text-muted" appBoxRow>
<span class="row-label">{{ "typePasskey" | i18n }}</span>
{{ "dateCreated" | i18n }} {{ cipher.creationDate | date : "short" }}
</div>

<div class="box" *ngIf="cipher.fido2Key.canLaunch">
<div class="box-content">
<div class="box-content-row" appBoxRow>
<label for="fido2KeyApplication">{{ "application" | i18n }}</label>
<input
class="text-muted"
id="fido2KeyApplication"
type="text"
[value]="cipher.fido2Key.rpId"
readonly
/>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="box" *ngIf="cipher.type === cipherType.Login">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ <h2 class="box-header">
<div class="icon"><i class="bwi bwi-fw bwi-lg bwi-globe"></i></div>
<span class="text">{{ "typeLogin" | i18n }}</span>
</div>
<span class="row-sub-label">{{
getTypeCountsSum(typeCounts, cipherType.Login, cipherType.Fido2Key)
}}</span>
<span class="row-sub-label">
{{ typeCounts.get(cipherType.Login) || 0 }}
</span>
<span><i class="bwi bwi-angle-right bwi-lg row-sub-icon"></i></span>
</button>
<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,7 @@ export class VaultFilterComponent implements OnInit, OnDestroy {
}

async launchCipher(cipher: CipherView) {
let launchUri: string;
if (cipher.type === CipherType.Login && cipher.login.canLaunch) {
launchUri = cipher.login.launchUri;
} else if (cipher.type === CipherType.Fido2Key && cipher.fido2Key.canLaunch) {
launchUri = cipher.fido2Key.launchUri;
}

if (!launchUri) {
if (cipher.type !== CipherType.Login || !cipher.login.canLaunch) {
return;
}

Expand All @@ -271,7 +264,7 @@ export class VaultFilterComponent implements OnInit, OnDestroy {
}
this.preventSelected = true;
await this.cipherService.updateLastLaunchedDate(cipher.id);
BrowserApi.createNewTab(launchUri);
BrowserApi.createNewTab(cipher.login.launchUri);
if (this.popupUtils.inPopup(window)) {
BrowserApi.closePopup(window);
}
Expand Down Expand Up @@ -362,10 +355,6 @@ export class VaultFilterComponent implements OnInit, OnDestroy {
this.collectionCounts = collectionCounts;
}

getTypeCountsSum(typeCounts: Map<CipherType, number>, ...types: CipherType[]): number {
return types.reduce((sum, type) => sum + (typeCounts.get(type) || 0), 0);
}

showSearching() {
return (
this.hasSearched || (!this.searchPending && this.searchService.isSearchable(this.searchText))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Location } from "@angular/common";

Check notice on line 1 in apps/browser/src/vault/popup/components/vault/vault-items.component.ts

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (EC-598-beeep-properly-store-passkeys-in-bitwarden)

✅ Getting better: Overall Code Complexity

The mean cyclomatic complexity decreases from 5.83 to 5.33, threshold = 4. This file has many conditional statements (e.g. if, for, while) across its implementation, leading to lower code health. Avoid adding more conditionals.
import { ChangeDetectorRef, Component, NgZone, OnDestroy, OnInit } from "@angular/core";
import { ActivatedRoute, Router } from "@angular/router";
import { first } from "rxjs/operators";
Expand Down Expand Up @@ -98,8 +98,7 @@
this.searchPlaceholder = this.i18nService.t("searchType");
this.type = parseInt(params.type, null);
switch (this.type) {
case CipherType.Login:

Check notice on line 101 in apps/browser/src/vault/popup/components/vault/vault-items.component.ts

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (EC-598-beeep-properly-store-passkeys-in-bitwarden)

✅ Getting better: Complex Method

VaultItemsComponent.ngOnInit decreases in cyclomatic complexity from 28 to 27, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.
case CipherType.Fido2Key:
this.groupingTitle = this.i18nService.t("logins");
break;
case CipherType.Card:
Expand Down Expand Up @@ -210,15 +209,7 @@
}

async launchCipher(cipher: CipherView) {
let launchUri: string;

if (cipher.type === CipherType.Login && cipher.login.canLaunch) {
launchUri = cipher.login.launchUri;
} else if (cipher.type === CipherType.Fido2Key && cipher.fido2Key.canLaunch) {
launchUri = cipher.fido2Key.launchUri;
}

if (!launchUri) {
if (cipher.type !== CipherType.Login || !cipher.login.canLaunch) {
return;
}

Expand All @@ -227,7 +218,7 @@
}
this.preventSelected = true;
await this.cipherService.updateLastLaunchedDate(cipher.id);
BrowserApi.createNewTab(launchUri);
BrowserApi.createNewTab(cipher.login.launchUri);
if (this.popupUtils.inPopup(window)) {
BrowserApi.closePopup(window);
}
Expand Down Expand Up @@ -273,12 +264,7 @@
cipherPassesFilter = cipher.isDeleted;
}
if (this.type != null && cipherPassesFilter) {
//Fido2Key's should also be included in the Login type
if (this.type === CipherType.Login) {
cipherPassesFilter = cipher.type === this.type || cipher.type === CipherType.Fido2Key;
} else {
cipherPassesFilter = cipher.type === this.type;
}
cipherPassesFilter = cipher.type === this.type;

Check notice on line 267 in apps/browser/src/vault/popup/components/vault/vault-items.component.ts

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (EC-598-beeep-properly-store-passkeys-in-bitwarden)

✅ Getting better: Complex Method

VaultItemsComponent.buildFilter decreases in cyclomatic complexity from 18 to 16, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.
}
if (this.folderId != null && this.folderId != "none" && cipherPassesFilter) {
cipherPassesFilter = cipher.folderId === this.folderId;
Expand Down
59 changes: 4 additions & 55 deletions apps/browser/src/vault/popup/components/vault/view.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ <h2 class="box-header">
<div class="box-content">
<div class="box-content-row text-muted">
<span class="row-label">{{ "typePasskey" | i18n }}</span>
{{ "passkeyTwoStepLogin" | i18n }}
{{ "dateCreated" | i18n }}
{{ cipher.login.fido2Keys[0].creationDate | date : "short" }}
</div>
</div>
</div>
Expand Down Expand Up @@ -424,57 +425,6 @@ <h2 class="box-header">
<div *ngIf="cipher.identity.country">{{ cipher.identity.country }}</div>
</div>
</div>
<!-- Fido2Key -->
<div *ngIf="cipher.type == cipherType.Fido2Key">
<div class="box-content-row">
<span class="row-label">{{ "username" | i18n }}</span>
{{ cipher.fido2Key.userDisplayName }}
</div>
<div class="box-content-row">
<span class="row-label">{{ "typePasskey" | i18n }}</span>
{{ "dateCreated" | i18n }} {{ cipher.creationDate | date : "short" }}
</div>

<div class="box" *ngIf="cipher.fido2Key.canLaunch">
<div class="box-content">
<div class="box-content-row box-content-row-flex">
<div class="row-main">
<label
class="row-label draggable"
draggable="true"
(dragstart)="setTextDataOnDrag($event, cipher.fido2Key.launchUri)"
>{{ "application" | i18n }}</label
>
<span title="{{ cipher.fido2Key.launchUri }}">
<input type="text" [value]="cipher.fido2Key.rpId" readonly aria-readonly="true" />
</span>
</div>
<div class="action-buttons">
<button
type="button"
class="row-btn"
appStopClick
(click)="launch(cipher.fido2Key)"
attr.aria-label="{{ 'launch' | i18n }} {{ cipher.fido2Key.launchUri }}"
[appA11yTitle]="'launch' | i18n"
>
<i class="bwi bwi-lg bwi-share-square" aria-hidden="true"></i>
</button>
<button
type="button"
class="row-btn"
appStopClick
attr.aria-label="{{ 'copyUri' | i18n }} {{ cipher.fido2Key.launchUri }}"
[appA11yTitle]="'copyUri' | i18n"
(click)="copy(cipher.fido2Key.launchUri, 'uri', 'URI')"
>
<i class="bwi bwi-lg bwi-clone" aria-hidden="true"></i>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="box" *ngIf="cipher.login && cipher.login.hasUris">
Expand Down Expand Up @@ -619,8 +569,7 @@ <h2 class="box-header">
*ngIf="
cipher.type !== cipherType.SecureNote &&
!cipher.isDeleted &&
(!this.inPopout || this.loadAction) &&
cipher.type != cipherType.Fido2Key
(!this.inPopout || this.loadAction)
"
>
<div class="row-main text-primary">
Expand Down Expand Up @@ -649,7 +598,7 @@ <h2 class="box-header">
class="box-content-row"
appStopClick
(click)="clone()"
*ngIf="!cipher.organizationId && !cipher.isDeleted && cipher.type != cipherType.Fido2Key"
*ngIf="!cipher.organizationId && !cipher.isDeleted"
>
<div class="row-main text-primary">
<div class="icon text-primary" aria-hidden="true">
Expand Down
6 changes: 0 additions & 6 deletions apps/desktop/src/locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2422,15 +2422,9 @@
"application": {
"message": "Application"
},
"passkeyEditInformation": {
"message": "You cannot edit passkey application because it would invalidate the passkey."
},
"duplicatePasskey": {
"message": "A passkey with this ID already exists in this organization."
},
"passkeyTwoStepLogin": {
"message": "Available for two-step login"
},
"passkeyNotCopied": {
"message": "Passkey will not be copied"
},
Expand Down
39 changes: 2 additions & 37 deletions apps/desktop/src/vault/app/vault/add-edit.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ <h2 class="box-header">
appBoxRow
>
<span class="row-label">{{ "typePasskey" | i18n }}</span>
{{ "passkeyTwoStepLogin" | i18n }}
{{ "dateCreated" | i18n }}
{{ cipher.login.fido2Keys[0].creationDate | date : "short" }}
</div>

<div class="box-content-row" appBoxRow>
Expand Down Expand Up @@ -458,24 +459,6 @@ <h2 class="box-header">
/>
</div>
</div>
<!-- Fido2Key -->
<div *ngIf="cipher.type === cipherType.Fido2Key">
<div class="box-content-row" appBoxRow>
<label for="fido2KeyUserDisplayName">{{ "username" | i18n }}</label>
<input
id="fido2KeyUserDisplayName"
type="text"
name="Fido2Key.UserDisplayName"
[(ngModel)]="cipher.fido2Key.userDisplayName"
appInputVerbatim
[readonly]="!cipher.edit && editMode"
/>
</div>
<div class="box-content-row text-muted" appBoxRow>
<span class="row-label">{{ "typePasskey" | i18n }}</span>
{{ "dateCreated" | i18n }} {{ cipher.creationDate | date : "short" }}
</div>
</div>
</div>
</div>
<div class="box" *ngIf="cipher.type === cipherType.Login">
Expand Down Expand Up @@ -556,24 +539,6 @@ <h2 class="box-header">
</button>
</div>
</div>
<!-- Fido2Key Application -->
<div class="box" *ngIf="cipher.type === cipherType.Fido2Key && cipher.fido2Key.canLaunch">
<div class="box-content">
<div class="box-content-row" appBoxRow>
<label for="fido2KeyApplication">{{ "application" | i18n }}</label>
<input
class="text-muted"
id="fido2KeyApplication"
type="text"
[value]="cipher.fido2Key.rpId"
readonly
/>
</div>
</div>
<div class="box-footer">
{{ "passkeyEditInformation" | i18n }}
</div>
</div>
<div class="box">
<div class="box-content">
<div class="box-content-row" appBoxRow>
Expand Down
Loading
Loading