mirror of
https://github.com/apache/superset.git
synced 2024-09-12 00:29:39 -04:00
fix:fix get permission function (#14099)
This commit is contained in:
parent
6392d41ac9
commit
f453287a07
@ -18,25 +18,22 @@
|
||||
*/
|
||||
import memoizeOne from 'memoize-one';
|
||||
|
||||
export default function getPermissions(
|
||||
perm: string,
|
||||
view: string,
|
||||
roles: object,
|
||||
) {
|
||||
return memoizeOne(() => {
|
||||
const roleList = Object.entries(roles);
|
||||
if (roleList.length === 0) return false;
|
||||
let bool;
|
||||
const findPermissions = (perm: string, view: string, roles: object) => {
|
||||
const roleList = Object.entries(roles);
|
||||
if (roleList.length === 0) return false;
|
||||
let bool;
|
||||
|
||||
roleList.forEach(([role, permissions]) => {
|
||||
bool = Boolean(
|
||||
permissions.find(
|
||||
(permission: Array<string>) =>
|
||||
permission[0] === perm && permission[1] === view,
|
||||
),
|
||||
);
|
||||
});
|
||||
console.log('bool', bool);
|
||||
return bool;
|
||||
roleList.forEach(([role, permissions]) => {
|
||||
bool = Boolean(
|
||||
permissions.find(
|
||||
(permission: Array<string>) =>
|
||||
permission[0] === perm && permission[1] === view,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
return bool;
|
||||
};
|
||||
|
||||
const getPermissions = memoizeOne(findPermissions);
|
||||
|
||||
export default getPermissions;
|
||||
|
Loading…
Reference in New Issue
Block a user