mirror of
https://github.com/bitwarden/desktop.git
synced 2024-11-24 11:55:50 +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 commit0159613751
. * Reimplement part of0159613751
* Add null check to VaultComponent::copyValue * Remove unused import
This commit is contained in:
parent
0faa987f41
commit
a84af15c93
@ -59,6 +59,16 @@
|
||||
</select>
|
||||
<small class="help-block">{{'clearClipboardDesc' | i18n}}</small>
|
||||
</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="checkbox">
|
||||
<label for="disableFavicons">
|
||||
|
@ -38,6 +38,7 @@ export class SettingsComponent implements OnInit {
|
||||
enableTray: boolean = false;
|
||||
showMinToTray: boolean = false;
|
||||
startToTray: boolean = false;
|
||||
minimizeOnCopyToClipboard: boolean = false;
|
||||
locale: string;
|
||||
vaultTimeouts: any[];
|
||||
localeOptions: any[];
|
||||
@ -122,6 +123,8 @@ export class SettingsComponent implements OnInit {
|
||||
this.locale = await this.storageService.get<string>(ConstantsService.localeKey);
|
||||
this.theme = await this.storageService.get<string>(ConstantsService.themeKey);
|
||||
this.clearClipboard = await this.storageService.get<number>(ConstantsService.clearClipboardKey);
|
||||
this.minimizeOnCopyToClipboard = await this.storageService.get<boolean>(
|
||||
ElectronConstants.minimizeOnCopyToClipboardKey);
|
||||
}
|
||||
|
||||
async saveVaultTimeoutOptions() {
|
||||
@ -227,6 +230,11 @@ export class SettingsComponent implements OnInit {
|
||||
window.setTimeout(() => window.location.reload(), 200);
|
||||
}
|
||||
|
||||
async saveMinOnCopyToClipboard() {
|
||||
await this.storageService.save(ElectronConstants.minimizeOnCopyToClipboardKey, this.minimizeOnCopyToClipboard);
|
||||
this.callAnalytics('MinOnCopyToClipboard', this.minimizeOnCopyToClipboard);
|
||||
}
|
||||
|
||||
async saveClearClipboard() {
|
||||
await this.storageService.save(ConstantsService.clearClipboardKey, this.clearClipboard);
|
||||
this.analytics.eventTrack.next({
|
||||
|
@ -660,6 +660,9 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||
this.platformUtilsService.copyToClipboard(value);
|
||||
this.toasterService.popAsync('info', null,
|
||||
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 { EventService } from 'jslib/abstractions/event.service';
|
||||
import { I18nService } from 'jslib/abstractions/i18n.service';
|
||||
import { MessagingService } from 'jslib/abstractions/messaging.service';
|
||||
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
|
||||
import { StorageService } from 'jslib/abstractions/storage.service';
|
||||
import { TokenService } from 'jslib/abstractions/token.service';
|
||||
import { TotpService } from 'jslib/abstractions/totp.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 { ElectronConstants } from 'jslib/electron/electronConstants';
|
||||
|
||||
@Component({
|
||||
selector: 'app-vault-view',
|
||||
templateUrl: 'view.component.html',
|
||||
@ -35,7 +39,8 @@ export class ViewComponent extends BaseViewComponent implements OnChanges {
|
||||
cryptoService: CryptoService, platformUtilsService: PlatformUtilsService,
|
||||
auditService: AuditService, broadcasterService: BroadcasterService,
|
||||
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,
|
||||
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.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",
|
||||
"description": "Copy value to clipboard"
|
||||
},
|
||||
"minimizeOnCopyToClipboard": {
|
||||
"message": "Minimize when copying to clipboard"
|
||||
},
|
||||
"minimizeOnCopyToClipboardDesc": {
|
||||
"message": "Bitwarden will minimize when credentials are copied to clipboard."
|
||||
},
|
||||
"toggleVisibility": {
|
||||
"message": "Toggle Visibility"
|
||||
},
|
||||
|
@ -23,6 +23,11 @@ export class MessagingMain {
|
||||
this.main.menuMain.updateApplicationMenuState(message.isAuthenticated, message.isLocked);
|
||||
this.updateTrayMenu(message.isAuthenticated, message.isLocked);
|
||||
break;
|
||||
case 'minimize':
|
||||
if (this.main.windowMain.win != null) {
|
||||
this.main.windowMain.win.minimize();
|
||||
}
|
||||
break;
|
||||
case 'showTray':
|
||||
this.main.trayMain.showTray();
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user