Type screen endpoints

This commit is contained in:
Andrew Kingston 2024-12-03 11:53:07 +00:00
parent 2d46939fb1
commit 9b16849fe6
No known key found for this signature in database
4 changed files with 35 additions and 30 deletions

View File

@ -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)
})

View File

@ -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}`,
})
},
})

View File

@ -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}`,
})
},
})

View File

@ -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 }