From 8633c197abbc19bc68fe09c9294b72c8066f9e2f Mon Sep 17 00:00:00 2001 From: csawatzky Date: Fri, 27 Mar 2026 14:35:02 -0600 Subject: [PATCH] now passing the kind for share object by key in order to be able to share things to ther objects and not just users/teams --- src/providers/pond/permissionAPI.tsx | 4 +++- src/teams/ShareWithTeam.tsx | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/providers/pond/permissionAPI.tsx b/src/providers/pond/permissionAPI.tsx index ea8e0b9..3005599 100644 --- a/src/providers/pond/permissionAPI.tsx +++ b/src/providers/pond/permissionAPI.tsx @@ -25,6 +25,7 @@ export interface IPermissionAPIContext { shareObjectByKey: ( scope: Scope, key: string, + kind: string, permissions: pond.Permission[], keys?: string[], type?: string[] @@ -138,7 +139,7 @@ export default function PermissionProvider(props: PropsWithChildren) { }) }; - const shareObjectByKey = (scope: Scope, key: string, permissions: pond.Permission[], keys?: string[], types?: string[]) => { + const shareObjectByKey = (scope: Scope, key: string, kind: string, permissions: pond.Permission[], keys?: string[], types?: string[]) => { let url = pondURL("/" + scope.kind + "s/" + scope.key + "/shareByKey") + (keys ? "?keys=" + keys.join(",") : "") + (types ? "&types=" + types.join(",") : "") if (as) url = pondURL(`/${scope.kind}s/${scope.key}/shareByKey?as=${as}`) + (keys ? "&keys=" + keys.join(",") : "") + @@ -146,6 +147,7 @@ export default function PermissionProvider(props: PropsWithChildren) { return new Promise((resolve, reject) => { post(url, { key: key, + kind: kind, permissions: permissions.map(permission => permissionToString(permission)) }).then(resp => { return resolve(resp) diff --git a/src/teams/ShareWithTeam.tsx b/src/teams/ShareWithTeam.tsx index 89c9a03..ffda3f0 100644 --- a/src/teams/ShareWithTeam.tsx +++ b/src/teams/ShareWithTeam.tsx @@ -111,7 +111,8 @@ export default function ShareObject(props: Props) { const [teamKey, setTeamKey] = useState(""); const share = () => { - permissionAPI.shareObjectByKey(scope, teamKey, sharedPermissions, keys, types).then(resp => { + + permissionAPI.shareObjectByKey(scope, teamKey, "team", sharedPermissions, keys, types).then(resp => { let shareBins = true; if (resp && resp.data && resp.data.existing) { success(label + " was shared with team"); @@ -125,7 +126,7 @@ export default function ShareObject(props: Props) { resp.data.bins.forEach(bin => { if (bin.settings) { let newScope = binScope(bin.settings?.key); - permissionAPI.shareObjectByKey(newScope, teamKey, sharedPermissions, keys, types).catch(_err => { + permissionAPI.shareObjectByKey(newScope, teamKey, "team", sharedPermissions, keys, types).catch(_err => { successBins = false; }); } @@ -145,7 +146,7 @@ export default function ShareObject(props: Props) { resp.data.gates.forEach(gate => { if (gate) { let newScope = { key: gate.key, kind: "gate" } as Scope; - permissionAPI.shareObjectByKey(newScope, teamKey, sharedPermissions, keys, types).catch(_err => { + permissionAPI.shareObjectByKey(newScope, teamKey, "team", sharedPermissions, keys, types).catch(_err => { successGates = false; }); }