1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-23 11:56:00 +01: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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 2 deletions

2
jslib

@ -1 +1 @@
Subproject commit 5b751d38a00ef529e801a63547fb214c31962761
Subproject commit 4eb50d757d03343ee842ea68a6b2c8282ef3f382

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);