* [PATCH pve-manager] ui: custom cpu models view: disable edits if missing permissions
@ 2026-05-20 5:25 Arthur Bied-Charreton
0 siblings, 0 replies; only message in thread
From: Arthur Bied-Charreton @ 2026-05-20 5:25 UTC (permalink / raw)
To: pve-devel
Until now, the custom CPU models view would let a user lacking
Mapping.Modify permissions go through the whole custom model
creation/edit flow and only fail on submit.
Disable the buttons if the user lacks the required permissions.
Reported-by: Michael Köppl <m.koeppl@proxmox.com>
Signed-off-by: Arthur Bied-Charreton <a.bied-charreton@proxmox.com>
---
www/manager6/dc/CPUTypeView.js | 62 ++++++++++++++++++----------------
1 file changed, 32 insertions(+), 30 deletions(-)
diff --git a/www/manager6/dc/CPUTypeView.js b/www/manager6/dc/CPUTypeView.js
index d60c1330..11882b3c 100644
--- a/www/manager6/dc/CPUTypeView.js
+++ b/www/manager6/dc/CPUTypeView.js
@@ -103,36 +103,6 @@ Ext.define('PVE.dc.CPUTypeView', {
},
],
- tbar: [
- {
- text: gettext('Add'),
- handler: 'onAdd',
- },
- '-',
- {
- xtype: 'proxmoxStdRemoveButton',
- baseurl: '/api2/extjs/cluster/qemu/custom-cpu-models/',
- getRecordName: (rec) => rec.data.cputype,
- getUrl: function (rec) {
- let me = this;
- return me.baseurl + rec.data.cputype;
- },
- confirmMsg: function (rec) {
- return Ext.String.format(
- gettext("Are you sure you want to remove the custom CPU model '{0}'?"),
- rec.data.cputype.replace(/^custom-/, ''),
- );
- },
- callback: 'reload',
- },
- {
- xtype: 'proxmoxButton',
- text: gettext('Edit'),
- disabled: true,
- handler: 'onEdit',
- },
- ],
-
selModel: {
xtype: 'rowmodel',
},
@@ -146,6 +116,38 @@ Ext.define('PVE.dc.CPUTypeView', {
initComponent: function () {
let me = this;
+ let caps = Ext.state.Manager.get('GuiCap');
+ let canEdit = !!caps.mapping['Mapping.Modify'];
+
+ me.tbar = [
+ { text: gettext('Add'), handler: 'onAdd', disabled: !canEdit },
+ '-',
+ {
+ xtype: 'proxmoxStdRemoveButton',
+ baseurl: '/api2/extjs/cluster/qemu/custom-cpu-models/',
+ enableFn: (rec) => canEdit,
+ getRecordName: (rec) => rec.data.cputype,
+ getUrl: function (rec) {
+ let me = this;
+ return me.baseurl + rec.data.cputype;
+ },
+ confirmMsg: function (rec) {
+ return Ext.String.format(
+ gettext("Are you sure you want to remove the custom CPU model '{0}'?"),
+ rec.data.cputype.replace(/^custom-/, ''),
+ );
+ },
+ callback: 'reload',
+ },
+ {
+ xtype: 'proxmoxButton',
+ text: gettext('Edit'),
+ disabled: true,
+ enableFn: (_) => canEdit,
+ handler: 'onEdit',
+ },
+ ];
+
me.callParent();
Proxmox.Utils.monStoreErrors(me, me.store);
},
--
2.47.3
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-05-20 5:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-20 5:25 [PATCH pve-manager] ui: custom cpu models view: disable edits if missing permissions Arthur Bied-Charreton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.