summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/htdocs/luci-static/resources/luci.js
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2020-04-15 22:14:44 +0200
committerJo-Philipp Wich <jo@mein.io>2020-04-16 13:30:35 +0200
commitb739fc17eabe9905889017127ac1de8f4e194819 (patch)
tree1deaf3bd7a193069f9e089f4906b90d5ae24af40 /modules/luci-base/htdocs/luci-static/resources/luci.js
parent94a0c571810da25043ca3599561bd9b369c0c65e (diff)
luci-base: luci.js: add hasViewPermission() helper
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base/htdocs/luci-static/resources/luci.js')
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/luci.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/luci.js b/modules/luci-base/htdocs/luci-static/resources/luci.js
index 6d31332a81..519bf8fd67 100644
--- a/modules/luci-base/htdocs/luci-static/resources/luci.js
+++ b/modules/luci-base/htdocs/luci-static/resources/luci.js
@@ -3121,6 +3121,22 @@
},
/**
+ * Check whether a view has sufficient permissions.
+ *
+ * @return {boolean|null}
+ * Returns `null` if the current session has no permission at all to
+ * load resources required by the view. Returns `false` if readonly
+ * permissions are granted or `true` if at least one required ACL
+ * group is granted with write permissions.
+ */
+ hasViewPermission: function() {
+ if (!this.isObject(env.nodespec) || !env.nodespec.satisfied)
+ return null;
+
+ return !env.nodespec.readonly;
+ },
+
+ /**
* Deprecated wrapper around {@link LuCI.poll.remove Poll.remove()}.
*
* @deprecated