diff options
author | Jo-Philipp Wich <jo@mein.io> | 2020-04-16 15:38:09 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2020-04-16 15:38:09 +0200 |
commit | 74e8fb0c8edccdc34263748809c9500766af622c (patch) | |
tree | 714770229a514bd31ded2e6f20c831e7777928a5 /modules/luci-mod-system/htdocs | |
parent | d7a17641d3411b71565135d5749037b7c18ffb69 (diff) |
luci-mod-system: sshkeys.js: make readonly on insufficient ACLs
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-mod-system/htdocs')
-rw-r--r-- | modules/luci-mod-system/htdocs/luci-static/resources/view/system/sshkeys.js | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/sshkeys.js b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/sshkeys.js index 487621daa3..4740b8c9dd 100644 --- a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/sshkeys.js +++ b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/sshkeys.js @@ -1,9 +1,12 @@ 'use strict'; +'require baseclass'; 'require view'; 'require fs'; 'require ui'; -var SSHPubkeyDecoder = L.Class.singleton({ +var isReadonlyView = !L.hasViewPermission() || null; + +var SSHPubkeyDecoder = baseclass.singleton({ lengthDecode: function(s, off) { var l = (s.charCodeAt(off++) << 24) | @@ -224,17 +227,23 @@ return view.extend({ }, render: function(keys) { - var list = E('div', { 'class': 'cbi-dynlist', 'dragover': dragKey, 'drop': dropKey }, [ + var list = E('div', { + 'class': 'cbi-dynlist', + 'dragover': isReadonlyView ? null : dragKey, + 'drop': isReadonlyView ? null : dropKey + }, [ E('div', { 'class': 'add-item' }, [ E('input', { 'class': 'cbi-input-text', 'type': 'text', 'placeholder': _('Paste or drag SSH key fileā¦') , - 'keydown': function(ev) { if (ev.keyCode === 13) addKey(ev) } + 'keydown': function(ev) { if (ev.keyCode === 13) addKey(ev) }, + 'disabled': isReadonlyView }), E('button', { 'class': 'cbi-button', - 'click': ui.createHandlerFn(this, addKey) + 'click': ui.createHandlerFn(this, addKey), + 'disabled': isReadonlyView }, _('Add key')) ]) ]); @@ -244,7 +253,7 @@ return view.extend({ if (pubkey) list.insertBefore(E('div', { class: 'item', - click: ui.createHandlerFn(this, removeKey), + click: isReadonlyView ? null : ui.createHandlerFn(this, removeKey), 'data-key': key }, [ E('strong', pubkey.comment || _('Unnamed key')), E('br'), |