ui: ACL view: fix path filtering
and add some comments about actual behavior of those config properties.. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
e1da9ca4bb
commit
09f1f28800
|
@ -22,7 +22,12 @@ Ext.define('PBS.config.ACLView', {
|
||||||
|
|
||||||
title: gettext('Permissions'),
|
title: gettext('Permissions'),
|
||||||
|
|
||||||
|
// Show only those permissions, which can affect this and children paths.
|
||||||
|
// That means that also higher up, "shorter" paths are included, as those
|
||||||
|
// can have a say in the rights on the asked path.
|
||||||
aclPath: undefined,
|
aclPath: undefined,
|
||||||
|
|
||||||
|
// tell API to only return ACLs matching exactly the aclPath config.
|
||||||
aclExact: undefined,
|
aclExact: undefined,
|
||||||
|
|
||||||
controller: {
|
controller: {
|
||||||
|
@ -83,19 +88,26 @@ Ext.define('PBS.config.ACLView', {
|
||||||
let proxy = view.getStore().rstore.getProxy();
|
let proxy = view.getStore().rstore.getProxy();
|
||||||
|
|
||||||
let params = {};
|
let params = {};
|
||||||
if (view.aclPath !== undefined) {
|
if (typeof view.aclPath === "string") {
|
||||||
|
|
||||||
let pathFilter = Ext.create('Ext.util.Filter', {
|
let pathFilter = Ext.create('Ext.util.Filter', {
|
||||||
filterPath: view.aclPath,
|
filterPath: view.aclPath,
|
||||||
|
filterAtoms: view.aclPath.split('/'),
|
||||||
filterFn: function(item) {
|
filterFn: function(item) {
|
||||||
let me = this;
|
let me = this;
|
||||||
let curr = item.data.path;
|
let path = item.data.path;
|
||||||
|
if (path === "/" || path === me.filterPath) {
|
||||||
if (curr.lastIndexOf("/") < me.filterPath.lastIndexOf("/")) {
|
return true;
|
||||||
return me.filterPath.startsWith(curr);
|
} else if (path.length > me.filterPath.length) {
|
||||||
} else {
|
return path.startsWith(me.filterPath + '/');
|
||||||
return me.filterPath === curr;
|
|
||||||
}
|
}
|
||||||
|
let pathAtoms = path.split('/');
|
||||||
|
let commonLength = Math.min(pathAtoms.length, me.filterAtoms.length);
|
||||||
|
for (let i = 1; i < commonLength; i++) {
|
||||||
|
if (me.filterAtoms[i] !== pathAtoms[i]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
view.getStore().addFilter(pathFilter);
|
view.getStore().addFilter(pathFilter);
|
||||||
|
|
Loading…
Reference in New Issue