Type screen endpoints
This commit is contained in:
parent
2d46939fb1
commit
9b16849fe6
|
@ -344,12 +344,7 @@ export class ScreenStore extends BudiStore {
|
|||
let deleteUrls = []
|
||||
screensToDelete.forEach(screen => {
|
||||
// Delete the screen
|
||||
promises.push(
|
||||
API.deleteScreen({
|
||||
screenId: screen._id,
|
||||
screenRev: screen._rev,
|
||||
})
|
||||
)
|
||||
promises.push(API.deleteScreen(screen._id, screen._rev))
|
||||
// Remove links to this screen
|
||||
deleteUrls.push(screen.routing.route)
|
||||
})
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
export const buildScreenEndpoints = API => ({
|
||||
/**
|
||||
* Saves a screen definition
|
||||
* @param screen the screen to save
|
||||
*/
|
||||
saveScreen: async screen => {
|
||||
return await API.post({
|
||||
url: "/api/screens",
|
||||
body: screen,
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Deletes a screen.
|
||||
* @param screenId the ID of the screen to delete
|
||||
* @param screenRev the rev of the screen to delete
|
||||
*/
|
||||
deleteScreen: async ({ screenId, screenRev }) => {
|
||||
return await API.delete({
|
||||
url: `/api/screens/${screenId}/${screenRev}`,
|
||||
})
|
||||
},
|
||||
})
|
|
@ -0,0 +1,31 @@
|
|||
import { Screen } from "@budibase/types"
|
||||
import { BaseAPIClient } from "./types"
|
||||
|
||||
export interface ScreenEndpoints {
|
||||
saveScreen: (screen: Screen) => Promise<Screen>
|
||||
deleteScreen: (id: string, rev: string) => Promise<{ message: string }>
|
||||
}
|
||||
|
||||
export const buildScreenEndpoints = (API: BaseAPIClient): ScreenEndpoints => ({
|
||||
/**
|
||||
* Saves a screen definition
|
||||
* @param screen the screen to save
|
||||
*/
|
||||
saveScreen: async screen => {
|
||||
return await API.post({
|
||||
url: "/api/screens",
|
||||
body: screen,
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Deletes a screen.
|
||||
* @param id the ID of the screen to delete
|
||||
* @param rev the rev of the screen to delete
|
||||
*/
|
||||
deleteScreen: async (id, rev) => {
|
||||
return await API.delete({
|
||||
url: `/api/screens/${id}/${rev}`,
|
||||
})
|
||||
},
|
||||
})
|
|
@ -25,6 +25,7 @@ import { RoleEndpoints } from "./roles"
|
|||
import { RouteEndpoints } from "./routes"
|
||||
import { RowActionEndpoints } from "./rowActions"
|
||||
import { RowEndpoints } from "./rows"
|
||||
import { ScreenEndpoints } from "./screens"
|
||||
|
||||
export enum HTTPMethod {
|
||||
POST = "POST",
|
||||
|
@ -120,4 +121,5 @@ export type APIClient = BaseAPIClient &
|
|||
RelationshipEndpoints &
|
||||
RoleEndpoints &
|
||||
RouteEndpoints &
|
||||
RowEndpoints & { rowActions: RowActionEndpoints; [key: string]: any }
|
||||
RowEndpoints &
|
||||
ScreenEndpoints & { rowActions: RowActionEndpoints; [key: string]: any }
|
||||
|
|
Loading…
Reference in New Issue