final adjustments to the field task list and the field drawer and field page using the tasks with the permissions in the correct way

This commit is contained in:
csawatzky 2026-03-31 13:37:49 -06:00
parent 8633c197ab
commit 186604dccf
11 changed files with 97 additions and 177 deletions

View file

@ -7,10 +7,16 @@ import { useGlobalState } from "providers";
import { createContext, PropsWithChildren, useContext } from "react";
import { objectQueryParams, pondURL } from "./pond";
export interface PermissionChanges {
key: string; //the key of the object having its permissions changed (parent)
permissions: string[] //the new permissions the parent will have to the child
}
export interface IPermissionAPIContext {
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>>;
updateObjectPermissions: (key: string, type: string, parentType: string, changes: PermissionChanges[], keys: string[], types: string[]) => Promise<AxiosResponse<any>>;
updateRelativePermissions: (
parentScope: Scope,
childScope: Scope,
@ -96,6 +102,28 @@ export default function PermissionProvider(props: PropsWithChildren<Props>) {
})
};
const updateObjectPermissions = (key: string, type: string, parentType: string, changes: PermissionChanges[], keys: string[], types: string[]) => {
let body = {
childKey: key,
childType: type,
parentType: parentType,
permissionChanges: changes
};
if (as) {
keys.unshift(as)
types.unshift("team")
}
return new Promise<AxiosResponse>((resolve, reject) => {
put(pondURL("/" + type + "s/" + key + "/objectPermissions?keys=" + keys + "&types=" + types ), body).then(resp => {
return resolve(resp)
}).catch(err => {
return reject(err)
})
})
}
const shareObject = (
scope: Scope,
email: string,
@ -207,6 +235,7 @@ export default function PermissionProvider(props: PropsWithChildren<Props>) {
getPermissions,
removePermissions,
updatePermissions,
updateObjectPermissions,
updateRelativePermissions,
shareObject,
shareObjectByKey,