Type role endpoints
This commit is contained in:
parent
e938fddeed
commit
2a7c0ca276
|
@ -84,10 +84,7 @@ export function createQueriesStore() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const deleteQuery = async query => {
|
const deleteQuery = async query => {
|
||||||
await API.deleteQuery({
|
await API.deleteQuery(query._id, query._rev)
|
||||||
queryId: query?._id,
|
|
||||||
queryRev: query?._rev,
|
|
||||||
})
|
|
||||||
store.update(state => {
|
store.update(state => {
|
||||||
state.list = state.list.filter(existing => existing._id !== query._id)
|
state.list = state.list.filter(existing => existing._id !== query._id)
|
||||||
return state
|
return state
|
||||||
|
|
|
@ -43,10 +43,7 @@ export function createRolesStore() {
|
||||||
setRoles(roles)
|
setRoles(roles)
|
||||||
},
|
},
|
||||||
delete: async role => {
|
delete: async role => {
|
||||||
await API.deleteRole({
|
await API.deleteRole(role._id, role._rev)
|
||||||
roleId: role?._id,
|
|
||||||
roleRev: role?._rev,
|
|
||||||
})
|
|
||||||
await actions.fetch()
|
await actions.fetch()
|
||||||
},
|
},
|
||||||
save: async role => {
|
save: async role => {
|
||||||
|
|
|
@ -1,12 +1,29 @@
|
||||||
export const buildRoleEndpoints = API => ({
|
import {
|
||||||
|
AccessibleRolesResponse,
|
||||||
|
DestroyRoleResponse,
|
||||||
|
FetchRolesResponse,
|
||||||
|
SaveRoleRequest,
|
||||||
|
SaveRoleResponse,
|
||||||
|
} from "@budibase/types"
|
||||||
|
import { BaseAPIClient } from "./types"
|
||||||
|
|
||||||
|
export interface RoleEndpoints {
|
||||||
|
deleteRole: (id: string, rev: string) => Promise<DestroyRoleResponse>
|
||||||
|
saveRole: (role: SaveRoleRequest) => Promise<SaveRoleResponse>
|
||||||
|
getRoles: () => Promise<FetchRolesResponse>
|
||||||
|
getRolesForApp: (appId: string) => Promise<any>
|
||||||
|
getAccessibleRoles: () => Promise<AccessibleRolesResponse>
|
||||||
|
}
|
||||||
|
|
||||||
|
export const buildRoleEndpoints = (API: BaseAPIClient): RoleEndpoints => ({
|
||||||
/**
|
/**
|
||||||
* Deletes a role.
|
* Deletes a role.
|
||||||
* @param roleId the ID of the role to delete
|
* @param id the ID of the role to delete
|
||||||
* @param roleRev the rev of the role to delete
|
* @param rev the rev of the role to delete
|
||||||
*/
|
*/
|
||||||
deleteRole: async ({ roleId, roleRev }) => {
|
deleteRole: async (id, rev) => {
|
||||||
return await API.delete({
|
return await API.delete({
|
||||||
url: `/api/roles/${roleId}/${roleRev}`,
|
url: `/api/roles/${id}/${rev}`,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
|
@ -21,6 +21,7 @@ import { PermissionEndpoints } from "./permissions"
|
||||||
import { PluginEndpoins } from "./plugins"
|
import { PluginEndpoins } from "./plugins"
|
||||||
import { QueryEndpoints } from "./queries"
|
import { QueryEndpoints } from "./queries"
|
||||||
import { RelationshipEndpoints } from "./relationships"
|
import { RelationshipEndpoints } from "./relationships"
|
||||||
|
import { RoleEndpoints } from "./roles"
|
||||||
|
|
||||||
export enum HTTPMethod {
|
export enum HTTPMethod {
|
||||||
POST = "POST",
|
POST = "POST",
|
||||||
|
@ -113,4 +114,5 @@ export type APIClient = BaseAPIClient &
|
||||||
PermissionEndpoints &
|
PermissionEndpoints &
|
||||||
PluginEndpoins &
|
PluginEndpoins &
|
||||||
QueryEndpoints &
|
QueryEndpoints &
|
||||||
RelationshipEndpoints & { [key: string]: any }
|
RelationshipEndpoints &
|
||||||
|
RoleEndpoints & { [key: string]: any }
|
||||||
|
|
Loading…
Reference in New Issue