Type remaining screens
This commit is contained in:
parent
13027c6a6d
commit
058b3def3a
|
@ -41,6 +41,7 @@ interface ComponentDefinition {
|
||||||
settings?: ComponentSetting[]
|
settings?: ComponentSetting[]
|
||||||
features?: Record<string, boolean>
|
features?: Record<string, boolean>
|
||||||
typeSupportPresets?: Record<string, any>
|
typeSupportPresets?: Record<string, any>
|
||||||
|
illegalChildren?: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ComponentSetting {
|
interface ComponentSetting {
|
||||||
|
|
|
@ -27,6 +27,9 @@ export const INITIAL_SCREENS_STATE: ScreenState = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ScreenStore extends BudiStore<ScreenState> {
|
export class ScreenStore extends BudiStore<ScreenState> {
|
||||||
|
save: (doc: Screen) => Promise<Screen>
|
||||||
|
delete: (doc: Screen) => Promise<void>
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super(INITIAL_SCREENS_STATE)
|
super(INITIAL_SCREENS_STATE)
|
||||||
|
|
||||||
|
@ -120,7 +123,7 @@ export class ScreenStore extends BudiStore<ScreenState> {
|
||||||
component: Component,
|
component: Component,
|
||||||
illegalChildren: string[] = [],
|
illegalChildren: string[] = [],
|
||||||
legalDirectChildren: string[] = []
|
legalDirectChildren: string[] = []
|
||||||
) => {
|
): string | undefined => {
|
||||||
const type = component._component
|
const type = component._component
|
||||||
|
|
||||||
if (illegalChildren.includes(type)) {
|
if (illegalChildren.includes(type)) {
|
||||||
|
@ -145,13 +148,6 @@ export class ScreenStore extends BudiStore<ScreenState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
const definition = componentStore.getDefinition(component._component)
|
const definition = componentStore.getDefinition(component._component)
|
||||||
// Reset whitelist for direct children
|
|
||||||
legalDirectChildren = []
|
|
||||||
if (definition?.legalDirectChildren?.length) {
|
|
||||||
legalDirectChildren = definition.legalDirectChildren.map(x => {
|
|
||||||
return `@budibase/standard-components/${x}`
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Append blacklisted components and remove duplicates
|
// Append blacklisted components and remove duplicates
|
||||||
if (definition?.illegalChildren?.length) {
|
if (definition?.illegalChildren?.length) {
|
||||||
|
@ -264,7 +260,10 @@ export class ScreenStore extends BudiStore<ScreenState> {
|
||||||
* supports deeply mutating the current doc rather than just appending data.
|
* supports deeply mutating the current doc rather than just appending data.
|
||||||
*/
|
*/
|
||||||
sequentialScreenPatch = Utils.sequential(
|
sequentialScreenPatch = Utils.sequential(
|
||||||
async (patchFn: (screen: Screen) => any, screenId: string) => {
|
async (
|
||||||
|
patchFn: (screen: Screen) => any,
|
||||||
|
screenId: string
|
||||||
|
): Promise<Screen | undefined> => {
|
||||||
const state = get(this.store)
|
const state = get(this.store)
|
||||||
const screen = state.screens.find(screen => screen._id === screenId)
|
const screen = state.screens.find(screen => screen._id === screenId)
|
||||||
if (!screen) {
|
if (!screen) {
|
||||||
|
@ -286,7 +285,10 @@ export class ScreenStore extends BudiStore<ScreenState> {
|
||||||
* @param {string | null} screenId
|
* @param {string | null} screenId
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
async patch(patchFn, screenId: string) {
|
async patch(
|
||||||
|
patchFn: (screen: Screen) => void,
|
||||||
|
screenId: string | undefined | null
|
||||||
|
) {
|
||||||
// Default to the currently selected screen
|
// Default to the currently selected screen
|
||||||
if (!screenId) {
|
if (!screenId) {
|
||||||
const state = get(this.store)
|
const state = get(this.store)
|
||||||
|
@ -346,8 +348,8 @@ export class ScreenStore extends BudiStore<ScreenState> {
|
||||||
* @param {object | array} screens
|
* @param {object | array} screens
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
async deleteScreen(screens: Screen[]) {
|
async deleteScreen(screen: Screen) {
|
||||||
const screensToDelete = Array.isArray(screens) ? screens : [screens]
|
const screensToDelete = [screen]
|
||||||
// Build array of promises to speed up bulk deletions
|
// Build array of promises to speed up bulk deletions
|
||||||
let promises: Promise<any>[] = []
|
let promises: Promise<any>[] = []
|
||||||
let deleteUrls: string[] = []
|
let deleteUrls: string[] = []
|
||||||
|
@ -387,7 +389,7 @@ export class ScreenStore extends BudiStore<ScreenState> {
|
||||||
|
|
||||||
return state
|
return state
|
||||||
})
|
})
|
||||||
return null
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -127,15 +127,15 @@ export const domDebounce = (callback: Function) => {
|
||||||
* @param {any} props
|
* @param {any} props
|
||||||
* */
|
* */
|
||||||
export const buildFormBlockButtonConfig = (props?: {
|
export const buildFormBlockButtonConfig = (props?: {
|
||||||
_id: string
|
_id?: string
|
||||||
actionType: string
|
actionType?: string
|
||||||
dataSource: { resourceId: string }
|
dataSource?: { resourceId: string }
|
||||||
notificationOverride: boolean
|
notificationOverride?: boolean
|
||||||
actionUrl: string
|
actionUrl?: string
|
||||||
showDeleteButton: boolean
|
showDeleteButton?: boolean
|
||||||
deleteButtonLabel: string
|
deleteButtonLabel?: string
|
||||||
showSaveButton: boolean
|
showSaveButton?: boolean
|
||||||
saveButtonLabel: string
|
saveButtonLabel?: string
|
||||||
}) => {
|
}) => {
|
||||||
const {
|
const {
|
||||||
_id,
|
_id,
|
||||||
|
|
Loading…
Reference in New Issue