ui: move NotesView panel and NotesEdit window to widget kit

this removes the NotesView panel and NotesEdit and replaces them with
with the version from the widget kit. requires a bump of the widget
toolkit.

Signed-off-by: Stefan Sterz <s.sterz@proxmox.com>
This commit is contained in:
Stefan Sterz 2022-04-12 12:34:22 +02:00 committed by Thomas Lamprecht
parent 6c06783930
commit 742de03d5a
6 changed files with 3 additions and 172 deletions

View File

@ -84,7 +84,6 @@ JSSRC= \
panel/BackupJobPrune.js \ panel/BackupJobPrune.js \
panel/HealthWidget.js \ panel/HealthWidget.js \
panel/IPSet.js \ panel/IPSet.js \
panel/NotesView.js \
panel/RunningChart.js \ panel/RunningChart.js \
panel/StatusPanel.js \ panel/StatusPanel.js \
panel/GuestStatusView.js \ panel/GuestStatusView.js \
@ -102,7 +101,6 @@ JSSRC= \
window/FirewallLograteEdit.js \ window/FirewallLograteEdit.js \
window/LoginWindow.js \ window/LoginWindow.js \
window/Migrate.js \ window/Migrate.js \
window/NotesEdit.js \
window/Prune.js \ window/Prune.js \
window/Restore.js \ window/Restore.js \
window/SafeDestroyGuest.js \ window/SafeDestroyGuest.js \

View File

@ -28,7 +28,7 @@ Ext.define('PVE.dc.Config', {
itemId: 'summary', itemId: 'summary',
}, },
{ {
xtype: 'pveNotesView', xtype: 'pmxNotesView',
title: gettext('Notes'), title: gettext('Notes'),
iconCls: 'fa fa-sticky-note-o', iconCls: 'fa fa-sticky-note-o',
itemId: 'notes', itemId: 'notes',

View File

@ -129,7 +129,7 @@ Ext.define('PVE.node.Config', {
itemId: 'summary', itemId: 'summary',
}, },
{ {
xtype: 'pveNotesView', xtype: 'pmxNotesView',
title: gettext('Notes'), title: gettext('Notes'),
iconCls: 'fa fa-sticky-note-o', iconCls: 'fa fa-sticky-note-o',
itemId: 'notes', itemId: 'notes',

View File

@ -40,7 +40,7 @@ Ext.define('PVE.qemu.Summary', {
rstore: rstore, rstore: rstore,
}, },
{ {
xtype: 'pveNotesView', xtype: 'pmxNotesView',
flex: 1, flex: 1,
padding: template ? '5' : '0 0 0 5', padding: template ? '5' : '0 0 0 5',
itemId: 'notesview', itemId: 'notesview',

View File

@ -1,129 +0,0 @@
Ext.define('PVE.panel.NotesView', {
extend: 'Ext.panel.Panel',
xtype: 'pveNotesView',
title: gettext("Notes"),
bodyPadding: 10,
scrollable: true,
animCollapse: false,
maxLength: 64 * 1024,
tbar: {
itemId: 'tbar',
hidden: true,
items: [
{
text: gettext('Edit'),
handler: function() {
let view = this.up('panel');
view.run_editor();
},
},
],
},
run_editor: function() {
let me = this;
Ext.create('PVE.window.NotesEdit', {
pveSelNode: me.pveSelNode,
url: me.url,
listeners: {
destroy: () => me.load(),
},
autoShow: true,
}).setMaxLength(me.maxLength);
},
load: function() {
var me = this;
Proxmox.Utils.API2Request({
url: me.url,
waitMsgTarget: me,
failure: function(response, opts) {
me.update(gettext('Error') + " " + response.htmlStatus);
me.setCollapsed(false);
},
success: function(response, opts) {
var data = response.result.data.description || '';
let mdHTML = Proxmox.Markdown.parse(data);
me.update(mdHTML);
if (me.collapsible && me.collapseMode === 'auto') {
me.setCollapsed(data === '');
}
},
});
},
listeners: {
render: function(c) {
var me = this;
me.getEl().on('dblclick', me.run_editor, me);
},
afterlayout: function() {
let me = this;
if (me.collapsible && !me.getCollapsed() && me.collapseMode === 'always') {
me.setCollapsed(true);
me.collapseMode = ''; // only once, on initial load!
}
},
},
tools: [{
type: 'gear',
handler: function() {
let view = this.up('panel');
view.run_editor();
},
}],
initComponent: function() {
const me = this;
const type = me.pveSelNode.data.type;
if (me.pveSelNode.data.id === 'root') {
me.url = '/api2/extjs/cluster/options';
} else {
const nodename = me.pveSelNode.data.node;
if (!nodename) {
throw "no node name specified";
}
if (!Ext.Array.contains(['node', 'qemu', 'lxc'], type)) {
throw 'invalid type specified';
}
const vmid = me.pveSelNode.data.vmid;
if (!vmid && type !== 'node') {
throw "no VM ID specified";
}
me.url = `/api2/extjs/nodes/${nodename}/`;
// add the type specific path if qemu/lxc and set the backend's maxLen
if (type === 'qemu' || type === 'lxc') {
me.url += `${type}/${vmid}/`;
me.maxLength = 8 * 1024;
}
me.url += 'config';
}
me.callParent();
if (type === 'node' || type === '') { // '' is for datacenter
me.down('#tbar').setVisible(true);
} else if (me.pveSelNode.data.template !== 1) {
me.setCollapsible(true);
me.collapseDirection = 'right';
let sp = Ext.state.Manager.getProvider();
me.collapseMode = sp.get('guest-notes-collapse', 'never');
if (me.collapseMode === 'auto') {
me.setCollapsed(true);
}
}
me.load();
},
});

View File

@ -1,38 +0,0 @@
Ext.define('PVE.window.NotesEdit', {
extend: 'Proxmox.window.Edit',
title: gettext('Notes'),
onlineHelp: 'markdown_basics',
width: 800,
height: '600px',
resizable: true,
layout: 'fit',
autoLoad: true,
defaultButton: undefined,
setMaxLength: function(maxLength) {
let me = this;
let area = me.down('textarea[name="description"]');
area.maxLength = maxLength;
area.validate();
return me;
},
items: {
xtype: 'textarea',
name: 'description',
height: '100%',
value: '',
hideLabel: true,
emptyText: gettext('You can use Markdown for rich text formatting.'),
fieldStyle: {
'white-space': 'pre-wrap',
'font-family': 'monospace',
},
},
});