updated get permissions to take in the keys and types to get the correct permissions using the context chain
This commit is contained in:
parent
2c28588861
commit
d3a5c24741
2 changed files with 16 additions and 17 deletions
|
|
@ -8,7 +8,7 @@ import { createContext, PropsWithChildren, useContext } from "react";
|
|||
import { objectQueryParams, pondURL } from "./pond";
|
||||
|
||||
export interface IPermissionAPIContext {
|
||||
getPermissions: (user: string, scope: Scope) => Promise<AxiosResponse<any>>;
|
||||
getPermissions: (user: string, keys: string[], types: string[]) => Promise<AxiosResponse<pond.EvaluatePermissionsResponse>>;
|
||||
removePermissions: (user: string, scope: Scope) => Promise<AxiosResponse<any>>;
|
||||
updatePermissions: (scope: Scope, users: User[] | Team[]) => Promise<AxiosResponse<any>>;
|
||||
updateRelativePermissions: (
|
||||
|
|
@ -44,9 +44,12 @@ export default function PermissionProvider(props: PropsWithChildren<Props>) {
|
|||
const { get, del, put, post } = useHTTP();
|
||||
const [{ as }] = useGlobalState();
|
||||
|
||||
const getPermissions = (user: string, scope: Scope) => {
|
||||
const getPermissions = (user: string, keys: string[], types: string[]) => {
|
||||
return new Promise<AxiosResponse>((resolve, reject) => {
|
||||
get(pondURL("/users/" + user + "/permissions" + objectQueryParams(scope))).then(resp => {
|
||||
get<pond.EvaluatePermissionsResponse>(pondURL(
|
||||
"/users/" + user + "/permissions?types=" + types.toString() + "&keys=" + keys.toString() +
|
||||
(as && "&as=" + as)
|
||||
)).then(resp => {
|
||||
return resolve(resp)
|
||||
}).catch(err => {
|
||||
return reject(err)
|
||||
|
|
@ -54,6 +57,8 @@ export default function PermissionProvider(props: PropsWithChildren<Props>) {
|
|||
})
|
||||
};
|
||||
|
||||
|
||||
|
||||
const removePermissions = (user: string, scope: Scope) => {
|
||||
return new Promise<AxiosResponse>((resolve, reject) => {
|
||||
del(pondURL("/users/" + user + "/permissions" + objectQueryParams(scope))).then(resp => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue