mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-27 12:36:14 +01:00
Add minimize when copying to clipboard option (#390)
* Add minimize when copying to clipboard option * Change minimizeOnCopyToClipboardKey constant reference and fix whitespace * Extend feature to context menus and view component * Cleanup and refactor methods * Refactor copy method and add minimizeOnCopyToClipboardKey constant to electronConstants.ts * Use window.main subclass and fix formatting * Revert "Use window.main subclass and fix formatting" This reverts commit 0159613751a54bc886fac0b34bd09d3a26498924. * Reimplement part of 0159613751a54bc886fac0b34bd09d3a26498924 * Add null check to VaultComponent::copyValue * Remove unused import
This commit is contained in:
parent
0faa987f41
commit
a84af15c93
@ -59,6 +59,16 @@
|
|||||||
</select>
|
</select>
|
||||||
<small class="help-block">{{'clearClipboardDesc' | i18n}}</small>
|
<small class="help-block">{{'clearClipboardDesc' | i18n}}</small>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="checkbox">
|
||||||
|
<label for="minimizeOnCopyToClipboard">
|
||||||
|
<input id="minimizeOnCopyToClipboard" type="checkbox" name="MinimizeOnCopyToClipboard"
|
||||||
|
[(ngModel)]="minimizeOnCopyToClipboard" (change)="saveMinOnCopyToClipboard()">
|
||||||
|
{{'minimizeOnCopyToClipboard' | i18n}}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<small class="help-block">{{'minimizeOnCopyToClipboardDesc' | i18n}}</small>
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
<label for="disableFavicons">
|
<label for="disableFavicons">
|
||||||
|
@ -38,6 +38,7 @@ export class SettingsComponent implements OnInit {
|
|||||||
enableTray: boolean = false;
|
enableTray: boolean = false;
|
||||||
showMinToTray: boolean = false;
|
showMinToTray: boolean = false;
|
||||||
startToTray: boolean = false;
|
startToTray: boolean = false;
|
||||||
|
minimizeOnCopyToClipboard: boolean = false;
|
||||||
locale: string;
|
locale: string;
|
||||||
vaultTimeouts: any[];
|
vaultTimeouts: any[];
|
||||||
localeOptions: any[];
|
localeOptions: any[];
|
||||||
@ -122,6 +123,8 @@ export class SettingsComponent implements OnInit {
|
|||||||
this.locale = await this.storageService.get<string>(ConstantsService.localeKey);
|
this.locale = await this.storageService.get<string>(ConstantsService.localeKey);
|
||||||
this.theme = await this.storageService.get<string>(ConstantsService.themeKey);
|
this.theme = await this.storageService.get<string>(ConstantsService.themeKey);
|
||||||
this.clearClipboard = await this.storageService.get<number>(ConstantsService.clearClipboardKey);
|
this.clearClipboard = await this.storageService.get<number>(ConstantsService.clearClipboardKey);
|
||||||
|
this.minimizeOnCopyToClipboard = await this.storageService.get<boolean>(
|
||||||
|
ElectronConstants.minimizeOnCopyToClipboardKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
async saveVaultTimeoutOptions() {
|
async saveVaultTimeoutOptions() {
|
||||||
@ -227,6 +230,11 @@ export class SettingsComponent implements OnInit {
|
|||||||
window.setTimeout(() => window.location.reload(), 200);
|
window.setTimeout(() => window.location.reload(), 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async saveMinOnCopyToClipboard() {
|
||||||
|
await this.storageService.save(ElectronConstants.minimizeOnCopyToClipboardKey, this.minimizeOnCopyToClipboard);
|
||||||
|
this.callAnalytics('MinOnCopyToClipboard', this.minimizeOnCopyToClipboard);
|
||||||
|
}
|
||||||
|
|
||||||
async saveClearClipboard() {
|
async saveClearClipboard() {
|
||||||
await this.storageService.save(ConstantsService.clearClipboardKey, this.clearClipboard);
|
await this.storageService.save(ConstantsService.clearClipboardKey, this.clearClipboard);
|
||||||
this.analytics.eventTrack.next({
|
this.analytics.eventTrack.next({
|
||||||
|
@ -660,6 +660,9 @@ export class VaultComponent implements OnInit, OnDestroy {
|
|||||||
this.platformUtilsService.copyToClipboard(value);
|
this.platformUtilsService.copyToClipboard(value);
|
||||||
this.toasterService.popAsync('info', null,
|
this.toasterService.popAsync('info', null,
|
||||||
this.i18nService.t('valueCopied', this.i18nService.t(labelI18nKey)));
|
this.i18nService.t('valueCopied', this.i18nService.t(labelI18nKey)));
|
||||||
|
if (this.viewComponent != null && this.action === 'view') {
|
||||||
|
this.viewComponent.minimizeIfNeeded();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,9 @@ import { CipherService } from 'jslib/abstractions/cipher.service';
|
|||||||
import { CryptoService } from 'jslib/abstractions/crypto.service';
|
import { CryptoService } from 'jslib/abstractions/crypto.service';
|
||||||
import { EventService } from 'jslib/abstractions/event.service';
|
import { EventService } from 'jslib/abstractions/event.service';
|
||||||
import { I18nService } from 'jslib/abstractions/i18n.service';
|
import { I18nService } from 'jslib/abstractions/i18n.service';
|
||||||
|
import { MessagingService } from 'jslib/abstractions/messaging.service';
|
||||||
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
|
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
|
||||||
|
import { StorageService } from 'jslib/abstractions/storage.service';
|
||||||
import { TokenService } from 'jslib/abstractions/token.service';
|
import { TokenService } from 'jslib/abstractions/token.service';
|
||||||
import { TotpService } from 'jslib/abstractions/totp.service';
|
import { TotpService } from 'jslib/abstractions/totp.service';
|
||||||
import { UserService } from 'jslib/abstractions/user.service';
|
import { UserService } from 'jslib/abstractions/user.service';
|
||||||
@ -23,6 +25,8 @@ import { ViewComponent as BaseViewComponent } from 'jslib/angular/components/vie
|
|||||||
|
|
||||||
import { CipherView } from 'jslib/models/view/cipherView';
|
import { CipherView } from 'jslib/models/view/cipherView';
|
||||||
|
|
||||||
|
import { ElectronConstants } from 'jslib/electron/electronConstants';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-vault-view',
|
selector: 'app-vault-view',
|
||||||
templateUrl: 'view.component.html',
|
templateUrl: 'view.component.html',
|
||||||
@ -35,7 +39,8 @@ export class ViewComponent extends BaseViewComponent implements OnChanges {
|
|||||||
cryptoService: CryptoService, platformUtilsService: PlatformUtilsService,
|
cryptoService: CryptoService, platformUtilsService: PlatformUtilsService,
|
||||||
auditService: AuditService, broadcasterService: BroadcasterService,
|
auditService: AuditService, broadcasterService: BroadcasterService,
|
||||||
ngZone: NgZone, changeDetectorRef: ChangeDetectorRef,
|
ngZone: NgZone, changeDetectorRef: ChangeDetectorRef,
|
||||||
userService: UserService, eventService: EventService) {
|
userService: UserService, eventService: EventService,
|
||||||
|
private messagingService: MessagingService, private storageService: StorageService) {
|
||||||
super(cipherService, totpService, tokenService, i18nService, cryptoService, platformUtilsService,
|
super(cipherService, totpService, tokenService, i18nService, cryptoService, platformUtilsService,
|
||||||
auditService, window, broadcasterService, ngZone, changeDetectorRef, userService, eventService);
|
auditService, window, broadcasterService, ngZone, changeDetectorRef, userService, eventService);
|
||||||
}
|
}
|
||||||
@ -48,4 +53,17 @@ export class ViewComponent extends BaseViewComponent implements OnChanges {
|
|||||||
this.platformUtilsService.eventTrack('View Password History');
|
this.platformUtilsService.eventTrack('View Password History');
|
||||||
this.onViewCipherPasswordHistory.emit(this.cipher);
|
this.onViewCipherPasswordHistory.emit(this.cipher);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
copy(value: string, typeI18nKey: string, aType: string) {
|
||||||
|
super.copy(value, typeI18nKey, aType);
|
||||||
|
this.minimizeIfNeeded();
|
||||||
|
}
|
||||||
|
|
||||||
|
async minimizeIfNeeded(): Promise<void> {
|
||||||
|
const shouldMinimize = await this.storageService.get<boolean>(
|
||||||
|
ElectronConstants.minimizeOnCopyToClipboardKey);
|
||||||
|
if (shouldMinimize) {
|
||||||
|
this.messagingService.send('minimize');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,6 +112,12 @@
|
|||||||
"message": "Copy Value",
|
"message": "Copy Value",
|
||||||
"description": "Copy value to clipboard"
|
"description": "Copy value to clipboard"
|
||||||
},
|
},
|
||||||
|
"minimizeOnCopyToClipboard": {
|
||||||
|
"message": "Minimize when copying to clipboard"
|
||||||
|
},
|
||||||
|
"minimizeOnCopyToClipboardDesc": {
|
||||||
|
"message": "Bitwarden will minimize when credentials are copied to clipboard."
|
||||||
|
},
|
||||||
"toggleVisibility": {
|
"toggleVisibility": {
|
||||||
"message": "Toggle Visibility"
|
"message": "Toggle Visibility"
|
||||||
},
|
},
|
||||||
|
@ -23,6 +23,11 @@ export class MessagingMain {
|
|||||||
this.main.menuMain.updateApplicationMenuState(message.isAuthenticated, message.isLocked);
|
this.main.menuMain.updateApplicationMenuState(message.isAuthenticated, message.isLocked);
|
||||||
this.updateTrayMenu(message.isAuthenticated, message.isLocked);
|
this.updateTrayMenu(message.isAuthenticated, message.isLocked);
|
||||||
break;
|
break;
|
||||||
|
case 'minimize':
|
||||||
|
if (this.main.windowMain.win != null) {
|
||||||
|
this.main.windowMain.win.minimize();
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 'showTray':
|
case 'showTray':
|
||||||
this.main.trayMain.showTray();
|
this.main.trayMain.showTray();
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user