mirror of
https://git.proxmox.com/git/proxmox-backup
synced 2025-04-30 14:16:29 +00:00
gui: remove document.execCommand calls
The `document.execCommand` call is deprecated since a few years [0] so I went ahead and removed it. We only use it to copy stuff to the clipboard and the recommended way now is to use `navigator.clipboard.writeText` [1]. `writeText` is kind of new, but I think we'll be alright regarding compatibility (Compat table is also available at [1]). Making the handler functions async is okay because extjs executes the handler and does not expect any result from it, nor does it need to do some work afterwards. [0]: https://developer.mozilla.org/en-US/docs/Web/API/document/execCommand [1]: https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/writeText Signed-off-by: Gabriel Goller <g.goller@proxmox.com> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
5b1f51ffa5
commit
e66d75ca2f
@ -76,11 +76,9 @@ Ext.define('PBS.ServerStatus', {
|
|||||||
{
|
{
|
||||||
xtype: 'button',
|
xtype: 'button',
|
||||||
iconCls: 'fa fa-clipboard',
|
iconCls: 'fa fa-clipboard',
|
||||||
handler: function(button) {
|
handler: async function(button) {
|
||||||
window.getSelection().selectAllChildren(
|
let el = document.getElementById('pkgversions');
|
||||||
document.getElementById('pkgversions'),
|
await navigator.clipboard.writeText(el.textContent);
|
||||||
);
|
|
||||||
document.execCommand("copy");
|
|
||||||
},
|
},
|
||||||
text: gettext('Copy'),
|
text: gettext('Copy'),
|
||||||
},
|
},
|
||||||
|
@ -45,10 +45,9 @@ Ext.define('PBS.NodeInfoPanel', {
|
|||||||
{
|
{
|
||||||
xtype: 'button',
|
xtype: 'button',
|
||||||
iconCls: 'fa fa-clipboard',
|
iconCls: 'fa fa-clipboard',
|
||||||
handler: function(b) {
|
handler: async function(b) {
|
||||||
var el = document.getElementById('fingerprintField');
|
var el = document.getElementById('fingerprintField');
|
||||||
el.select();
|
await navigator.clipboard.writeText(el.value);
|
||||||
document.execCommand("copy");
|
|
||||||
},
|
},
|
||||||
text: gettext('Copy'),
|
text: gettext('Copy'),
|
||||||
},
|
},
|
||||||
|
@ -113,15 +113,14 @@ Ext.define('PBS.form.CopyField', {
|
|||||||
iconCls: 'fa fa-clipboard x-btn-icon-el-default-toolbar-small',
|
iconCls: 'fa fa-clipboard x-btn-icon-el-default-toolbar-small',
|
||||||
baseCls: 'x-btn',
|
baseCls: 'x-btn',
|
||||||
cls: 'x-btn-default-toolbar-small proxmox-inline-button',
|
cls: 'x-btn-default-toolbar-small proxmox-inline-button',
|
||||||
handler: function() {
|
handler: async function() {
|
||||||
let me = this;
|
let me = this;
|
||||||
let field = me.up('pbsCopyField');
|
let field = me.up('pbsCopyField');
|
||||||
let el = field.getComponent('inputField')?.inputEl;
|
let el = field.getComponent('inputField')?.inputEl;
|
||||||
if (!el?.dom) {
|
if (!el?.dom) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
el.dom.select();
|
await navigator.clipboard.writeText(el.dom.value);
|
||||||
document.execCommand("copy");
|
|
||||||
},
|
},
|
||||||
text: gettext('Copy'),
|
text: gettext('Copy'),
|
||||||
},
|
},
|
||||||
|
@ -203,9 +203,9 @@ Ext.define('PBS.window.TokenShow', {
|
|||||||
],
|
],
|
||||||
buttons: [
|
buttons: [
|
||||||
{
|
{
|
||||||
handler: function(b) {
|
handler: async function(b) {
|
||||||
document.getElementById('token-secret-value').select();
|
let el = document.getElementById('token-secret-value');
|
||||||
document.execCommand("copy");
|
await navigator.clipboard.writeText(el.value);
|
||||||
},
|
},
|
||||||
text: gettext('Copy Secret Value'),
|
text: gettext('Copy Secret Value'),
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user