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

This commit is contained in:
csawatzky 2026-03-27 14:35:02 -06:00
parent 777089e8c4
commit 8633c197ab
2 changed files with 7 additions and 4 deletions

View file

@ -25,6 +25,7 @@ export interface IPermissionAPIContext {
shareObjectByKey: ( shareObjectByKey: (
scope: Scope, scope: Scope,
key: string, key: string,
kind: string,
permissions: pond.Permission[], permissions: pond.Permission[],
keys?: string[], keys?: string[],
type?: string[] type?: string[]
@ -138,7 +139,7 @@ export default function PermissionProvider(props: PropsWithChildren<Props>) {
}) })
}; };
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(",") : "") + let url = pondURL("/" + scope.kind + "s/" + scope.key + "/shareByKey") + (keys ? "?keys=" + keys.join(",") : "") +
(types ? "&types=" + types.join(",") : "") (types ? "&types=" + types.join(",") : "")
if (as) url = pondURL(`/${scope.kind}s/${scope.key}/shareByKey?as=${as}`) + (keys ? "&keys=" + keys.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<Props>) {
return new Promise<AxiosResponse>((resolve, reject) => { return new Promise<AxiosResponse>((resolve, reject) => {
post(url, { post(url, {
key: key, key: key,
kind: kind,
permissions: permissions.map(permission => permissionToString(permission)) permissions: permissions.map(permission => permissionToString(permission))
}).then(resp => { }).then(resp => {
return resolve(resp) return resolve(resp)

View file

@ -111,7 +111,8 @@ export default function ShareObject(props: Props) {
const [teamKey, setTeamKey] = useState<string>(""); const [teamKey, setTeamKey] = useState<string>("");
const share = () => { const share = () => {
permissionAPI.shareObjectByKey(scope, teamKey, sharedPermissions, keys, types).then(resp => {
permissionAPI.shareObjectByKey(scope, teamKey, "team", sharedPermissions, keys, types).then(resp => {
let shareBins = true; let shareBins = true;
if (resp && resp.data && resp.data.existing) { if (resp && resp.data && resp.data.existing) {
success(label + " was shared with team"); success(label + " was shared with team");
@ -125,7 +126,7 @@ export default function ShareObject(props: Props) {
resp.data.bins.forEach(bin => { resp.data.bins.forEach(bin => {
if (bin.settings) { if (bin.settings) {
let newScope = binScope(bin.settings?.key); 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; successBins = false;
}); });
} }
@ -145,7 +146,7 @@ export default function ShareObject(props: Props) {
resp.data.gates.forEach(gate => { resp.data.gates.forEach(gate => {
if (gate) { if (gate) {
let newScope = { key: gate.key, kind: "gate" } as Scope; 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; successGates = false;
}); });
} }