From a6d957d6f59329cc16c838afe3c88c6072fad236 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Wed, 7 Jul 2021 17:14:15 +0200 Subject: [PATCH] luci-mod-status: disable "Set static" lease action on readonly view Fixes: f6b6a12927 ("luci-mod-status: add support for one-click static lease") Signed-off-by: Jo-Philipp Wich --- .../resources/view/status/include/40_dhcp.js | 13 +++++++------ .../root/usr/share/rpcd/acl.d/luci-mod-status.json | 3 +++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/40_dhcp.js b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/40_dhcp.js index 69305a2a9c..b93f26875d 100644 --- a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/40_dhcp.js +++ b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/40_dhcp.js @@ -21,7 +21,7 @@ return baseclass.extend({ return Promise.all([ callLuciDHCPLeases(), network.getHostHints(), - uci.load('dhcp') + L.resolveDefault(uci.load('dhcp')) ]); }, @@ -63,7 +63,8 @@ return baseclass.extend({ var leases = Array.isArray(data[0].dhcp_leases) ? data[0].dhcp_leases : [], leases6 = Array.isArray(data[0].dhcp6_leases) ? data[0].dhcp6_leases : [], machints = data[1].getMACHints(false), - hosts = uci.sections('dhcp', 'host'); + hosts = uci.sections('dhcp', 'host'), + isReadonlyView = !L.hasViewPermission(); for (var i = 0; i < hosts.length; i++) { var host = hosts[i]; @@ -87,7 +88,7 @@ return baseclass.extend({ E('th', { 'class': 'th' }, _('IPv4 address')), E('th', { 'class': 'th' }, _('MAC address')), E('th', { 'class': 'th' }, _('Lease time remaining')), - E('th', { 'class': 'th cbi-section-actions' }, _('Static Lease')) + isReadonlyView ? E([]) : E('th', { 'class': 'th cbi-section-actions' }, _('Static Lease')) ]) ]); @@ -108,7 +109,7 @@ return baseclass.extend({ exp ]; - if (lease.macaddr != null) { + if (!isReadonlyView && lease.macaddr != null) { var mac = lease.macaddr.toUpperCase(); rows.push(E('button', { 'class': 'cbi-button cbi-button-apply', @@ -126,7 +127,7 @@ return baseclass.extend({ E('th', { 'class': 'th' }, _('IPv6 address')), E('th', { 'class': 'th' }, _('DUID')), E('th', { 'class': 'th' }, _('Lease time remaining')), - E('th', { 'class': 'th cbi-section-actions' }, _('Static Lease')) + isReadonlyView ? E([]) : E('th', { 'class': 'th cbi-section-actions' }, _('Static Lease')) ]) ]); @@ -157,7 +158,7 @@ return baseclass.extend({ exp ]; - if (lease.duid != null) { + if (!isReadonlyView && lease.duid != null) { var duid = lease.duid.toUpperCase(); rows.push(E('button', { 'class': 'cbi-button cbi-button-apply', diff --git a/modules/luci-mod-status/root/usr/share/rpcd/acl.d/luci-mod-status.json b/modules/luci-mod-status/root/usr/share/rpcd/acl.d/luci-mod-status.json index e23a0ae6b4..3e7d823014 100644 --- a/modules/luci-mod-status/root/usr/share/rpcd/acl.d/luci-mod-status.json +++ b/modules/luci-mod-status/root/usr/share/rpcd/acl.d/luci-mod-status.json @@ -104,6 +104,9 @@ "file": [ "list", "read" ], "system": [ "board", "info" ] } + }, + "write": { + "uci": [ "dhcp" ] } }, -- 2.30.2