luci-base: luci.js: add hasViewPermission() helper
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
parent
94a0c57181
commit
b739fc17ea
1 changed files with 16 additions and 0 deletions
|
@ -3120,6 +3120,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 wrapper around {@link LuCI.poll.remove Poll.remove()}.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue