1
0
mirror of https://github.com/bitwarden/web synced 2025-12-10 13:23:15 +00:00

Fix "copy link to clipboard" for large file Sends (#949)

* Throw error if execCommand('copy') is disabled

* Use dialog for file Send creation success

* Show popup modal after long Send file uploads

* fix linting

* bump jslib
This commit is contained in:
Thomas Rittson
2021-04-28 07:40:36 +10:00
committed by GitHub
parent dd56c9bc87
commit b3a4f833a1
3 changed files with 16 additions and 2 deletions

2
jslib

Submodule jslib updated: 5b751d38a0...4eb50d757d

View File

@@ -12,6 +12,8 @@ import { UserService } from 'jslib/abstractions/user.service';
import { AddEditComponent as BaseAddEditComponent } from 'jslib/angular/components/send/add-edit.component';
import { SendType } from 'jslib/enums/sendType';
@Component({
selector: 'app-send-add-edit',
templateUrl: 'add-edit.component.html',
@@ -25,6 +27,15 @@ export class AddEditComponent extends BaseAddEditComponent {
messagingService, policyService);
}
async showSuccessMessage(inactive: boolean) {
if (inactive && this.copyLink && this.send.type === SendType.File) {
await this.platformUtilsService.showDialog(this.i18nService.t('createdSend'), null,
this.i18nService.t('ok'), null, 'success', null);
} else {
await super.showSuccessMessage(inactive);
}
}
copyLinkToClipboard(link: string) {
// Copy function on web depends on the modal being open or not. Since this event occurs during a transition
// of the modal closing we need to add a small delay to make sure state of the DOM is consistent.

View File

@@ -245,7 +245,10 @@ export class WebPlatformUtilsService implements PlatformUtilsService {
textarea.select();
try {
// Security exception may be thrown by some browsers.
doc.execCommand('copy');
const copyEnabled = doc.execCommand('copy');
if (!copyEnabled) {
throw new Error('Command unsupported or disabled');
}
} catch (e) {
// tslint:disable-next-line
console.warn('Copy to clipboard failed.', e);