Type layout endpoints
This commit is contained in:
parent
d36122b7bd
commit
b2b2648798
|
@ -59,10 +59,7 @@ export class LayoutStore extends BudiStore {
|
|||
if (!layout?._id) {
|
||||
return
|
||||
}
|
||||
await API.deleteLayout({
|
||||
layoutId: layout._id,
|
||||
layoutRev: layout._rev,
|
||||
})
|
||||
await API.deleteLayout(layout._id, layout._rev)
|
||||
this.update(state => {
|
||||
state.layouts = state.layouts.filter(x => x._id !== layout._id)
|
||||
return state
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
export const buildLayoutEndpoints = API => ({
|
||||
/**
|
||||
* Saves a layout.
|
||||
* @param layout the layout to save
|
||||
*/
|
||||
saveLayout: async layout => {
|
||||
return await API.post({
|
||||
url: "/api/layouts",
|
||||
body: layout,
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Deletes a layout.
|
||||
* @param layoutId the ID of the layout to delete
|
||||
* @param layoutRev the rev of the layout to delete
|
||||
*/
|
||||
deleteLayout: async ({ layoutId, layoutRev }) => {
|
||||
return await API.delete({
|
||||
url: `/api/layouts/${layoutId}/${layoutRev}`,
|
||||
})
|
||||
},
|
||||
})
|
|
@ -0,0 +1,31 @@
|
|||
import { Layout, SaveLayoutRequest, SaveLayoutResponse } from "@budibase/types"
|
||||
import { BaseAPIClient } from "./types"
|
||||
|
||||
export interface LayoutEndpoints {
|
||||
saveLayout: (layout: Layout) => Promise<SaveLayoutResponse>
|
||||
deleteLayout: (id: string, rev: string) => Promise<{ message: string }>
|
||||
}
|
||||
|
||||
export const buildLayoutEndpoints = (API: BaseAPIClient): LayoutEndpoints => ({
|
||||
/**
|
||||
* Saves a layout.
|
||||
* @param layout the layout to save
|
||||
*/
|
||||
saveLayout: async layout => {
|
||||
return await API.post<SaveLayoutRequest, SaveLayoutResponse>({
|
||||
url: "/api/layouts",
|
||||
body: layout,
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Deletes a layout.
|
||||
* @param layoutId the ID of the layout to delete
|
||||
* @param layoutRev the rev of the layout to delete
|
||||
*/
|
||||
deleteLayout: async (id: string, rev: string) => {
|
||||
return await API.delete({
|
||||
url: `/api/layouts/${id}/${rev}`,
|
||||
})
|
||||
},
|
||||
})
|
|
@ -12,6 +12,7 @@ import { EnvironmentVariableEndpoints } from "./environmentVariables"
|
|||
import { EventEndpoints } from "./events"
|
||||
import { FlagEndpoints } from "./flags"
|
||||
import { GroupEndpoints } from "./groups"
|
||||
import { LayoutEndpoints } from "./layouts"
|
||||
|
||||
export enum HTTPMethod {
|
||||
POST = "POST",
|
||||
|
@ -85,4 +86,5 @@ export type APIClient = BaseAPIClient &
|
|||
EnvironmentVariableEndpoints &
|
||||
EventEndpoints &
|
||||
FlagEndpoints &
|
||||
GroupEndpoints
|
||||
GroupEndpoints &
|
||||
LayoutEndpoints
|
||||
|
|
Loading…
Reference in New Issue