{
@@ -205,6 +208,74 @@ export class VaultComponent implements OnInit, OnDestroy {
this.go();
}
+ viewCipherMenu(cipher: CipherView) {
+ const menu = new remote.Menu();
+ menu.append(new remote.MenuItem({
+ label: this.i18nService.t('view'),
+ click: () => {
+ this.ngZone.run(async () => {
+ this.viewCipher(cipher);
+ this.changeDetectorRef.detectChanges();
+ });
+ },
+ }));
+ menu.append(new remote.MenuItem({
+ label: this.i18nService.t('edit'),
+ click: () => {
+ this.ngZone.run(async () => {
+ this.editCipher(cipher);
+ this.changeDetectorRef.detectChanges();
+ });
+ },
+ }));
+
+ switch (cipher.type) {
+ case CipherType.Login:
+ if (cipher.login.canLaunch || cipher.login.username != null || cipher.login.password != null) {
+ menu.append(new remote.MenuItem({ type: 'separator' }));
+ }
+ if (cipher.login.canLaunch) {
+ menu.append(new remote.MenuItem({
+ label: this.i18nService.t('launch'),
+ click: () => this.platformUtilsService.launchUri(cipher.login.uri),
+ }));
+ }
+ if (cipher.login.username != null) {
+ menu.append(new remote.MenuItem({
+ label: this.i18nService.t('copyUsername'),
+ click: () => this.platformUtilsService.copyToClipboard(cipher.login.username),
+ }));
+ }
+ if (cipher.login.password != null) {
+ menu.append(new remote.MenuItem({
+ label: this.i18nService.t('copyPassword'),
+ click: () => this.platformUtilsService.copyToClipboard(cipher.login.password),
+ }));
+ }
+ break;
+ case CipherType.Card:
+ if (cipher.card.number != null || cipher.card.code != null) {
+ menu.append(new remote.MenuItem({ type: 'separator' }));
+ }
+ if (cipher.card.number != null) {
+ menu.append(new remote.MenuItem({
+ label: this.i18nService.t('copyNumber'),
+ click: () => this.platformUtilsService.copyToClipboard(cipher.card.number),
+ }));
+ }
+ if (cipher.card.code != null) {
+ menu.append(new remote.MenuItem({
+ label: this.i18nService.t('copySecurityCode'),
+ click: () => this.platformUtilsService.copyToClipboard(cipher.card.code),
+ }));
+ }
+ break;
+ default:
+ break;
+ }
+ menu.popup(remote.getCurrentWindow());
+ }
+
editCipher(cipher: CipherView) {
if (this.action === 'edit' && this.cipherId === cipher.id) {
return;
@@ -226,6 +297,27 @@ export class VaultComponent implements OnInit, OnDestroy {
this.go();
}
+ addCipherOptions() {
+ const menu = new remote.Menu();
+ menu.append(new remote.MenuItem({
+ label: this.i18nService.t('typeLogin'),
+ click: () => this.addCipherWithChangeDetection(CipherType.Login),
+ }));
+ menu.append(new remote.MenuItem({
+ label: this.i18nService.t('typeCard'),
+ click: () => this.addCipherWithChangeDetection(CipherType.Card),
+ }));
+ menu.append(new remote.MenuItem({
+ label: this.i18nService.t('typeIdentity'),
+ click: () => this.addCipherWithChangeDetection(CipherType.Identity),
+ }));
+ menu.append(new remote.MenuItem({
+ label: this.i18nService.t('typeSecureNote'),
+ click: () => this.addCipherWithChangeDetection(CipherType.SecureNote),
+ }));
+ menu.popup(remote.getCurrentWindow());
+ }
+
async savedCipher(cipher: CipherView) {
this.cipherId = cipher.id;
this.action = 'view';
@@ -394,4 +486,11 @@ export class VaultComponent implements OnInit, OnDestroy {
const url = this.router.createUrlTree(['vault'], { queryParams: queryParams }).toString();
this.location.go(url);
}
+
+ private addCipherWithChangeDetection(type: CipherType = null) {
+ this.ngZone.run(async () => {
+ this.addCipher(type);
+ this.changeDetectorRef.detectChanges();
+ });
+ }
}
diff --git a/src/app/vault/view.component.html b/src/app/vault/view.component.html
index 8fff134b2fa..d58923953dc 100644
--- a/src/app/vault/view.component.html
+++ b/src/app/vault/view.component.html
@@ -34,7 +34,7 @@
{{cipher.login.username}}