mirror of
https://github.com/bitwarden/browser.git
synced 2025-01-18 20:41:31 +01:00
support for copying send link to clipboard on save (#265)
This commit is contained in:
parent
58e6f24d5f
commit
a4ac842cec
@ -33,10 +33,10 @@ export class AddEditComponent implements OnInit {
|
|||||||
@Output() onDeletedSend = new EventEmitter<SendView>();
|
@Output() onDeletedSend = new EventEmitter<SendView>();
|
||||||
@Output() onCancelled = new EventEmitter<SendView>();
|
@Output() onCancelled = new EventEmitter<SendView>();
|
||||||
|
|
||||||
|
copyLink = false;
|
||||||
disableSend = false;
|
disableSend = false;
|
||||||
editMode: boolean = false;
|
editMode: boolean = false;
|
||||||
send: SendView;
|
send: SendView;
|
||||||
link: string;
|
|
||||||
title: string;
|
title: string;
|
||||||
deletionDate: string;
|
deletionDate: string;
|
||||||
expirationDate: string;
|
expirationDate: string;
|
||||||
@ -54,6 +54,8 @@ export class AddEditComponent implements OnInit {
|
|||||||
canAccessPremium = true;
|
canAccessPremium = true;
|
||||||
premiumRequiredAlertShown = false;
|
premiumRequiredAlertShown = false;
|
||||||
|
|
||||||
|
private webVaultUrl: string;
|
||||||
|
|
||||||
constructor(protected i18nService: I18nService, protected platformUtilsService: PlatformUtilsService,
|
constructor(protected i18nService: I18nService, protected platformUtilsService: PlatformUtilsService,
|
||||||
protected environmentService: EnvironmentService, protected datePipe: DatePipe,
|
protected environmentService: EnvironmentService, protected datePipe: DatePipe,
|
||||||
protected sendService: SendService, protected userService: UserService,
|
protected sendService: SendService, protected userService: UserService,
|
||||||
@ -74,6 +76,18 @@ export class AddEditComponent implements OnInit {
|
|||||||
this.expirationDateOptions = [
|
this.expirationDateOptions = [
|
||||||
{ name: i18nService.t('never'), value: null },
|
{ name: i18nService.t('never'), value: null },
|
||||||
].concat([...this.deletionDateOptions]);
|
].concat([...this.deletionDateOptions]);
|
||||||
|
|
||||||
|
this.webVaultUrl = this.environmentService.getWebVaultUrl();
|
||||||
|
if (this.webVaultUrl == null) {
|
||||||
|
this.webVaultUrl = 'https://vault.bitwarden.com';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
get link(): string {
|
||||||
|
if (this.send.id != null && this.send.accessId != null) {
|
||||||
|
return this.webVaultUrl + '/#/send/' + this.send.accessId + '/' + this.send.urlB64Key;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
@ -123,14 +137,6 @@ export class AddEditComponent implements OnInit {
|
|||||||
// Parse dates
|
// Parse dates
|
||||||
this.deletionDate = this.dateToString(this.send.deletionDate);
|
this.deletionDate = this.dateToString(this.send.deletionDate);
|
||||||
this.expirationDate = this.dateToString(this.send.expirationDate);
|
this.expirationDate = this.dateToString(this.send.expirationDate);
|
||||||
|
|
||||||
if (this.editMode) {
|
|
||||||
let webVaultUrl = this.environmentService.getWebVaultUrl();
|
|
||||||
if (webVaultUrl == null) {
|
|
||||||
webVaultUrl = 'https://vault.bitwarden.com';
|
|
||||||
}
|
|
||||||
this.link = webVaultUrl + '/#/send/' + this.send.accessId + '/' + this.send.urlB64Key;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async submit(): Promise<boolean> {
|
async submit(): Promise<boolean> {
|
||||||
@ -182,10 +188,18 @@ export class AddEditComponent implements OnInit {
|
|||||||
try {
|
try {
|
||||||
this.formPromise = this.sendService.saveWithServer(encSend);
|
this.formPromise = this.sendService.saveWithServer(encSend);
|
||||||
await this.formPromise;
|
await this.formPromise;
|
||||||
this.send.id = encSend[0].id;
|
if (this.send.id == null) {
|
||||||
|
this.send.id = encSend[0].id;
|
||||||
|
}
|
||||||
|
if (this.send.accessId == null) {
|
||||||
|
this.send.accessId = encSend[0].accessId;
|
||||||
|
}
|
||||||
this.platformUtilsService.showToast('success', null,
|
this.platformUtilsService.showToast('success', null,
|
||||||
this.i18nService.t(this.editMode ? 'editedSend' : 'createdSend'));
|
this.i18nService.t(this.editMode ? 'editedSend' : 'createdSend'));
|
||||||
this.onSavedSend.emit(this.send);
|
this.onSavedSend.emit(this.send);
|
||||||
|
if (this.copyLink) {
|
||||||
|
this.copyLinkToClipboard(this.link);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch { }
|
} catch { }
|
||||||
|
|
||||||
@ -196,6 +210,12 @@ export class AddEditComponent implements OnInit {
|
|||||||
this.expirationDate = null;
|
this.expirationDate = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
copyLinkToClipboard(link: string) {
|
||||||
|
if (link != null) {
|
||||||
|
this.platformUtilsService.copyToClipboard(link);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async delete(): Promise<void> {
|
async delete(): Promise<void> {
|
||||||
if (this.deletePromise != null) {
|
if (this.deletePromise != null) {
|
||||||
return;
|
return;
|
||||||
|
@ -152,6 +152,7 @@ export class SendService implements SendServiceAbstraction {
|
|||||||
response = await this.apiService.postSendFile(fd);
|
response = await this.apiService.postSendFile(fd);
|
||||||
}
|
}
|
||||||
sendData[0].id = response.id;
|
sendData[0].id = response.id;
|
||||||
|
sendData[0].accessId = response.accessId;
|
||||||
} else {
|
} else {
|
||||||
response = await this.apiService.putSend(sendData[0].id, request);
|
response = await this.apiService.putSend(sendData[0].id, request);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user