summaryrefslogtreecommitdiffhomepage
path: root/applications
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2020-04-16 15:30:44 +0200
committerJo-Philipp Wich <jo@mein.io>2020-04-16 15:30:44 +0200
commitdc57e4bc6c83d6c869c318256057e3636bfc5d66 (patch)
treef1303cc7b66b38bfc02a1f5f578672e671e77c16 /applications
parent0306b14d20ec8cfa3b851ddbdcef8c3fb1a3f832 (diff)
luci-app-opkg: disable action buttons on insufficient ACLs
Also flush menu cache after opkg actions. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'applications')
-rw-r--r--applications/luci-app-opkg/htdocs/luci-static/resources/view/opkg.js29
1 files changed, 19 insertions, 10 deletions
diff --git a/applications/luci-app-opkg/htdocs/luci-static/resources/view/opkg.js b/applications/luci-app-opkg/htdocs/luci-static/resources/view/opkg.js
index 952f83676..a5abfc168 100644
--- a/applications/luci-app-opkg/htdocs/luci-static/resources/view/opkg.js
+++ b/applications/luci-app-opkg/htdocs/luci-static/resources/view/opkg.js
@@ -85,6 +85,8 @@ var css = ' \
} \
';
+var isReadonlyView = !L.hasViewPermission() || null;
+
var callMountPoints = rpc.declare({
object: 'luci',
method: 'getMountPoints',
@@ -685,7 +687,7 @@ function handleInstall(ev)
errs || inst || '',
E('div', { 'class': 'right' }, [
E('label', { 'class': 'cbi-checkbox', 'style': 'float:left' }, [
- E('input', { 'id': 'overwrite-cb', 'type': 'checkbox', 'name': 'overwrite' }), ' ',
+ E('input', { 'id': 'overwrite-cb', 'type': 'checkbox', 'name': 'overwrite', 'disabled': isReadonlyView }), ' ',
E('label', { 'for': 'overwrite-cb' }), ' ',
_('Overwrite files from other package(s)')
]),
@@ -698,7 +700,8 @@ function handleInstall(ev)
'data-command': 'install',
'data-package': name,
'class': 'btn cbi-button-action',
- 'click': handleOpkg
+ 'click': handleOpkg,
+ 'disabled': isReadonlyView
}, _('Install'))
])
]);
@@ -804,7 +807,8 @@ function handleConfig(ev)
ui.addNotification(null, E('p', {}, [ _('Unable to save %s: %s').format(file, err) ]));
});
})).then(ui.hideModal);
- }
+ },
+ 'disabled': isReadonlyView
}, _('Save')),
]));
@@ -840,8 +844,9 @@ function handleRemove(ev)
]),
desc || '',
E('div', { 'style': 'display:flex; justify-content:space-between; flex-wrap:wrap' }, [
- E('label', {}, [
- E('input', { type: 'checkbox', checked: 'checked', name: 'autoremove' }),
+ E('label', { 'class': 'cbi-checkbox', 'style': 'float:left' }, [
+ E('input', { 'id': 'autoremove-cb', 'type': 'checkbox', 'checked': 'checked', 'name': 'autoremove', 'disabled': isReadonlyView }), ' ',
+ E('label', { 'for': 'autoremove-cb' }), ' ',
_('Automatically remove unused dependencies')
]),
E('div', { 'style': 'flex-grow:1', 'class': 'right' }, [
@@ -854,7 +859,8 @@ function handleRemove(ev)
'data-command': 'remove',
'data-package': name,
'class': 'btn cbi-button-negative',
- 'click': handleOpkg
+ 'click': handleOpkg,
+ 'disabled': isReadonlyView
}, _('Remove'))
])
])
@@ -903,6 +909,9 @@ function handleOpkg(ev)
E('div', {
'class': 'btn',
'click': L.bind(function(res) {
+ if (ui.menu && ui.menu.flushCache)
+ ui.menu.flushCache();
+
ui.hideModal();
updateLists();
@@ -1026,16 +1035,16 @@ return view.extend({
E('div', {}, [
E('label', {}, _('Download and install package') + ':'),
E('span', { 'class': 'control-group' }, [
- E('input', { 'type': 'text', 'name': 'install', 'placeholder': _('Package name or URL…'), 'keydown': function(ev) { if (ev.keyCode === 13) handleManualInstall(ev) } }),
- E('button', { 'class': 'btn cbi-button cbi-button-action', 'click': handleManualInstall }, [ _('OK') ])
+ E('input', { 'type': 'text', 'name': 'install', 'placeholder': _('Package name or URL…'), 'keydown': function(ev) { if (ev.keyCode === 13) handleManualInstall(ev) }, 'disabled': isReadonlyView }),
+ E('button', { 'class': 'btn cbi-button cbi-button-action', 'click': handleManualInstall, 'disabled': isReadonlyView }, [ _('OK') ])
])
]),
E('div', {}, [
E('label', {}, _('Actions') + ':'), ' ',
E('span', { 'class': 'control-group' }, [
- E('button', { 'class': 'btn cbi-button-positive', 'data-command': 'update', 'click': handleOpkg }, [ _('Update lists…') ]), ' ',
- E('button', { 'class': 'btn cbi-button-action', 'click': handleUpload }, [ _('Upload Package…') ]), ' ',
+ E('button', { 'class': 'btn cbi-button-positive', 'data-command': 'update', 'click': handleOpkg, 'disabled': isReadonlyView }, [ _('Update lists…') ]), ' ',
+ E('button', { 'class': 'btn cbi-button-action', 'click': handleUpload, 'disabled': isReadonlyView }, [ _('Upload Package…') ]), ' ',
E('button', { 'class': 'btn cbi-button-neutral', 'click': handleConfig }, [ _('Configure opkg…') ])
])
])