API to fetch users who have read/write permission on a document collection (#5047)

This commit is contained in:
Apoorv Mishra
2023-03-29 06:24:32 +05:30
committed by GitHub
parent fcc89be622
commit 1b1cd1c8d4
6 changed files with 349 additions and 5 deletions

View File

@@ -159,6 +159,25 @@ export default class UsersStore extends BaseStore<User> {
return res.data;
};
@action
fetchDocumentUsers = async (params: {
id: string;
query?: string;
}): Promise<User[]> => {
try {
const res = await client.post("/documents.users", params);
invariant(res?.data, "User list not available");
let response: User[] = [];
runInAction("DocumentsStore#fetchUsers", () => {
response = res.data.map(this.add);
this.addPolicies(res.policies);
});
return response;
} catch (err) {
return Promise.resolve([]);
}
};
@action
async delete(user: User, options: Record<string, any> = {}) {
super.delete(user, options);