mirror of
https://github.com/bitwarden/web
synced 2025-12-11 13:53:17 +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:
2
jslib
2
jslib
Submodule jslib updated: 5b751d38a0...4eb50d757d
@@ -12,6 +12,8 @@ import { UserService } from 'jslib/abstractions/user.service';
|
|||||||
|
|
||||||
import { AddEditComponent as BaseAddEditComponent } from 'jslib/angular/components/send/add-edit.component';
|
import { AddEditComponent as BaseAddEditComponent } from 'jslib/angular/components/send/add-edit.component';
|
||||||
|
|
||||||
|
import { SendType } from 'jslib/enums/sendType';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-send-add-edit',
|
selector: 'app-send-add-edit',
|
||||||
templateUrl: 'add-edit.component.html',
|
templateUrl: 'add-edit.component.html',
|
||||||
@@ -25,6 +27,15 @@ export class AddEditComponent extends BaseAddEditComponent {
|
|||||||
messagingService, policyService);
|
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) {
|
copyLinkToClipboard(link: string) {
|
||||||
// Copy function on web depends on the modal being open or not. Since this event occurs during a transition
|
// 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.
|
// of the modal closing we need to add a small delay to make sure state of the DOM is consistent.
|
||||||
|
|||||||
@@ -245,7 +245,10 @@ export class WebPlatformUtilsService implements PlatformUtilsService {
|
|||||||
textarea.select();
|
textarea.select();
|
||||||
try {
|
try {
|
||||||
// Security exception may be thrown by some browsers.
|
// 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) {
|
} catch (e) {
|
||||||
// tslint:disable-next-line
|
// tslint:disable-next-line
|
||||||
console.warn('Copy to clipboard failed.', e);
|
console.warn('Copy to clipboard failed.', e);
|
||||||
|
|||||||
Reference in New Issue
Block a user