mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-04 09:38:50 +01:00
🧑🤝🧑 feat: Add People Picker Permissions Management UI
This commit is contained in:
parent
d82a63642d
commit
a434d28579
15 changed files with 419 additions and 229 deletions
|
|
@ -4,6 +4,7 @@ import {
|
|||
dataService,
|
||||
promptPermissionsSchema,
|
||||
memoryPermissionsSchema,
|
||||
peoplePickerPermissionsSchema,
|
||||
} from 'librechat-data-provider';
|
||||
import type {
|
||||
UseQueryOptions,
|
||||
|
|
@ -132,3 +133,39 @@ export const useUpdateMemoryPermissionsMutation = (
|
|||
},
|
||||
);
|
||||
};
|
||||
|
||||
export const useUpdatePeoplePickerPermissionsMutation = (
|
||||
options?: t.UpdatePeoplePickerPermOptions,
|
||||
): UseMutationResult<
|
||||
t.UpdatePermResponse,
|
||||
t.TError | undefined,
|
||||
t.UpdatePeoplePickerPermVars,
|
||||
unknown
|
||||
> => {
|
||||
const queryClient = useQueryClient();
|
||||
const { onMutate, onSuccess, onError } = options ?? {};
|
||||
return useMutation(
|
||||
(variables) => {
|
||||
peoplePickerPermissionsSchema.partial().parse(variables.updates);
|
||||
return dataService.updatePeoplePickerPermissions(variables);
|
||||
},
|
||||
{
|
||||
onSuccess: (data, variables, context) => {
|
||||
queryClient.invalidateQueries([QueryKeys.roles, variables.roleName]);
|
||||
if (onSuccess) {
|
||||
onSuccess(data, variables, context);
|
||||
}
|
||||
},
|
||||
onError: (...args) => {
|
||||
const error = args[0];
|
||||
if (error != null) {
|
||||
console.error('Failed to update people picker permissions:', error);
|
||||
}
|
||||
if (onError) {
|
||||
onError(...args);
|
||||
}
|
||||
},
|
||||
onMutate,
|
||||
},
|
||||
);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue