Move type to type/ui
This commit is contained in:
parent
7b130c7bcd
commit
8fc0930563
|
@ -1,4 +1,4 @@
|
||||||
import { SortOrder } from "@budibase/types"
|
import { SortOrder, UIDatasource } from "@budibase/types"
|
||||||
import { get } from "svelte/store"
|
import { get } from "svelte/store"
|
||||||
import { Store as StoreContext } from ".."
|
import { Store as StoreContext } from ".."
|
||||||
|
|
||||||
|
@ -10,11 +10,7 @@ interface NonPlusActions {
|
||||||
updateRow: () => Promise<void>
|
updateRow: () => Promise<void>
|
||||||
deleteRows: () => Promise<void>
|
deleteRows: () => Promise<void>
|
||||||
getRow: () => Promise<void>
|
getRow: () => Promise<void>
|
||||||
isDatasourceValid: (datasource: {
|
isDatasourceValid: (datasource: UIDatasource) => boolean
|
||||||
type: string
|
|
||||||
id: string
|
|
||||||
tableId: string
|
|
||||||
}) => boolean
|
|
||||||
canUseColumn: (name: string) => boolean
|
canUseColumn: (name: string) => boolean
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,11 +37,7 @@ export const createActions = (context: StoreContext): NonPlusActions => {
|
||||||
throw "This datasource does not support fetching individual rows"
|
throw "This datasource does not support fetching individual rows"
|
||||||
}
|
}
|
||||||
|
|
||||||
const isDatasourceValid = (datasource: {
|
const isDatasourceValid = (datasource: UIDatasource) => {
|
||||||
type: string
|
|
||||||
id: string
|
|
||||||
tableId: string
|
|
||||||
}) => {
|
|
||||||
// There are many different types and shapes of datasource, so we only
|
// There are many different types and shapes of datasource, so we only
|
||||||
// check that we aren't null
|
// check that we aren't null
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -4,6 +4,7 @@ import {
|
||||||
SaveRowResponse,
|
SaveRowResponse,
|
||||||
SaveTableRequest,
|
SaveTableRequest,
|
||||||
SortOrder,
|
SortOrder,
|
||||||
|
UIDatasource,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { get } from "svelte/store"
|
import { get } from "svelte/store"
|
||||||
import { Store as StoreContext } from ".."
|
import { Store as StoreContext } from ".."
|
||||||
|
@ -18,7 +19,7 @@ interface TableActions {
|
||||||
updateRow: (row: SaveRowRequest) => Promise<SaveRowResponse>
|
updateRow: (row: SaveRowRequest) => Promise<SaveRowResponse>
|
||||||
deleteRows: (rows: (string | Row)[]) => Promise<void>
|
deleteRows: (rows: (string | Row)[]) => Promise<void>
|
||||||
getRow: (id: string) => Promise<Row>
|
getRow: (id: string) => Promise<Row>
|
||||||
isDatasourceValid: (datasource: { type: string; tableId: any }) => boolean
|
isDatasourceValid: (datasource: UIDatasource) => boolean
|
||||||
canUseColumn: (name: string) => boolean
|
canUseColumn: (name: string) => boolean
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +46,7 @@ export const createActions = (context: StoreContext): TableActions => {
|
||||||
await API.deleteRows(get(datasource).tableId, rows)
|
await API.deleteRows(get(datasource).tableId, rows)
|
||||||
}
|
}
|
||||||
|
|
||||||
const isDatasourceValid = (datasource: { type: string; tableId: any }) => {
|
const isDatasourceValid = (datasource: UIDatasource) => {
|
||||||
return datasource?.type === "table" && !!datasource?.tableId
|
return datasource?.type === "table" && !!datasource?.tableId
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ import {
|
||||||
Row,
|
Row,
|
||||||
SaveRowRequest,
|
SaveRowRequest,
|
||||||
SortOrder,
|
SortOrder,
|
||||||
|
UIDatasource,
|
||||||
UpdateViewRequest,
|
UpdateViewRequest,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { Store as StoreContext } from ".."
|
import { Store as StoreContext } from ".."
|
||||||
|
@ -17,11 +18,7 @@ interface ViewActions {
|
||||||
updateRow: (row: SaveRowRequest) => Promise<Row>
|
updateRow: (row: SaveRowRequest) => Promise<Row>
|
||||||
deleteRows: (rows: (string | Row)[]) => Promise<void>
|
deleteRows: (rows: (string | Row)[]) => Promise<void>
|
||||||
getRow: (id: string) => Promise<Row>
|
getRow: (id: string) => Promise<Row>
|
||||||
isDatasourceValid: (datasource: {
|
isDatasourceValid: (datasource: UIDatasource) => boolean
|
||||||
type: string
|
|
||||||
id: string
|
|
||||||
tableId: string
|
|
||||||
}) => boolean
|
|
||||||
canUseColumn: (name: string) => boolean
|
canUseColumn: (name: string) => boolean
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,11 +63,7 @@ export const createActions = (context: StoreContext): ViewActions => {
|
||||||
return res?.rows?.[0]
|
return res?.rows?.[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
const isDatasourceValid = (datasource: {
|
const isDatasourceValid = (datasource: UIDatasource) => {
|
||||||
type: string
|
|
||||||
id: string
|
|
||||||
tableId: string
|
|
||||||
}) => {
|
|
||||||
return (
|
return (
|
||||||
datasource?.type === "viewV2" && !!datasource?.id && !!datasource?.tableId
|
datasource?.type === "viewV2" && !!datasource?.id && !!datasource?.tableId
|
||||||
)
|
)
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
export interface UIDatasource {
|
||||||
|
type: string
|
||||||
|
id: string
|
||||||
|
tableId: string
|
||||||
|
}
|
|
@ -1 +1,2 @@
|
||||||
export * from "./columns"
|
export * from "./columns"
|
||||||
|
export * from "./datasource"
|
||||||
|
|
Loading…
Reference in New Issue