mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-31 17:57:43 +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() onCancelled = new EventEmitter<SendView>();
|
||||
|
||||
copyLink = false;
|
||||
disableSend = false;
|
||||
editMode: boolean = false;
|
||||
send: SendView;
|
||||
link: string;
|
||||
title: string;
|
||||
deletionDate: string;
|
||||
expirationDate: string;
|
||||
@ -54,6 +54,8 @@ export class AddEditComponent implements OnInit {
|
||||
canAccessPremium = true;
|
||||
premiumRequiredAlertShown = false;
|
||||
|
||||
private webVaultUrl: string;
|
||||
|
||||
constructor(protected i18nService: I18nService, protected platformUtilsService: PlatformUtilsService,
|
||||
protected environmentService: EnvironmentService, protected datePipe: DatePipe,
|
||||
protected sendService: SendService, protected userService: UserService,
|
||||
@ -74,6 +76,18 @@ export class AddEditComponent implements OnInit {
|
||||
this.expirationDateOptions = [
|
||||
{ name: i18nService.t('never'), value: null },
|
||||
].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() {
|
||||
@ -123,14 +137,6 @@ export class AddEditComponent implements OnInit {
|
||||
// Parse dates
|
||||
this.deletionDate = this.dateToString(this.send.deletionDate);
|
||||
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> {
|
||||
@ -182,10 +188,18 @@ export class AddEditComponent implements OnInit {
|
||||
try {
|
||||
this.formPromise = this.sendService.saveWithServer(encSend);
|
||||
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.i18nService.t(this.editMode ? 'editedSend' : 'createdSend'));
|
||||
this.onSavedSend.emit(this.send);
|
||||
if (this.copyLink) {
|
||||
this.copyLinkToClipboard(this.link);
|
||||
}
|
||||
return true;
|
||||
} catch { }
|
||||
|
||||
@ -196,6 +210,12 @@ export class AddEditComponent implements OnInit {
|
||||
this.expirationDate = null;
|
||||
}
|
||||
|
||||
copyLinkToClipboard(link: string) {
|
||||
if (link != null) {
|
||||
this.platformUtilsService.copyToClipboard(link);
|
||||
}
|
||||
}
|
||||
|
||||
async delete(): Promise<void> {
|
||||
if (this.deletePromise != null) {
|
||||
return;
|
||||
|
@ -152,6 +152,7 @@ export class SendService implements SendServiceAbstraction {
|
||||
response = await this.apiService.postSendFile(fd);
|
||||
}
|
||||
sendData[0].id = response.id;
|
||||
sendData[0].accessId = response.accessId;
|
||||
} else {
|
||||
response = await this.apiService.putSend(sendData[0].id, request);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user