diff --git a/packages/builder/src/stores/builder/components.ts b/packages/builder/src/stores/builder/components.ts index e60d4e80a4..8fa7f5113d 100644 --- a/packages/builder/src/stores/builder/components.ts +++ b/packages/builder/src/stores/builder/components.ts @@ -41,6 +41,7 @@ interface ComponentDefinition { settings?: ComponentSetting[] features?: Record typeSupportPresets?: Record + illegalChildren?: string[] } interface ComponentSetting { diff --git a/packages/builder/src/stores/builder/screens.ts b/packages/builder/src/stores/builder/screens.ts index fff54b364d..d87d12f23c 100644 --- a/packages/builder/src/stores/builder/screens.ts +++ b/packages/builder/src/stores/builder/screens.ts @@ -27,6 +27,9 @@ export const INITIAL_SCREENS_STATE: ScreenState = { } export class ScreenStore extends BudiStore { + save: (doc: Screen) => Promise + delete: (doc: Screen) => Promise + constructor() { super(INITIAL_SCREENS_STATE) @@ -120,7 +123,7 @@ export class ScreenStore extends BudiStore { component: Component, illegalChildren: string[] = [], legalDirectChildren: string[] = [] - ) => { + ): string | undefined => { const type = component._component if (illegalChildren.includes(type)) { @@ -145,13 +148,6 @@ export class ScreenStore extends BudiStore { } 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 if (definition?.illegalChildren?.length) { @@ -264,7 +260,10 @@ export class ScreenStore extends BudiStore { * supports deeply mutating the current doc rather than just appending data. */ sequentialScreenPatch = Utils.sequential( - async (patchFn: (screen: Screen) => any, screenId: string) => { + async ( + patchFn: (screen: Screen) => any, + screenId: string + ): Promise => { const state = get(this.store) const screen = state.screens.find(screen => screen._id === screenId) if (!screen) { @@ -286,7 +285,10 @@ export class ScreenStore extends BudiStore { * @param {string | null} screenId * @returns */ - async patch(patchFn, screenId: string) { + async patch( + patchFn: (screen: Screen) => void, + screenId: string | undefined | null + ) { // Default to the currently selected screen if (!screenId) { const state = get(this.store) @@ -346,8 +348,8 @@ export class ScreenStore extends BudiStore { * @param {object | array} screens * @returns */ - async deleteScreen(screens: Screen[]) { - const screensToDelete = Array.isArray(screens) ? screens : [screens] + async deleteScreen(screen: Screen) { + const screensToDelete = [screen] // Build array of promises to speed up bulk deletions let promises: Promise[] = [] let deleteUrls: string[] = [] @@ -387,7 +389,7 @@ export class ScreenStore extends BudiStore { return state }) - return null + return } /** diff --git a/packages/frontend-core/src/utils/utils.ts b/packages/frontend-core/src/utils/utils.ts index 0eaca6548e..124f0f03b9 100644 --- a/packages/frontend-core/src/utils/utils.ts +++ b/packages/frontend-core/src/utils/utils.ts @@ -127,15 +127,15 @@ export const domDebounce = (callback: Function) => { * @param {any} props * */ export const buildFormBlockButtonConfig = (props?: { - _id: string - actionType: string - dataSource: { resourceId: string } - notificationOverride: boolean - actionUrl: string - showDeleteButton: boolean - deleteButtonLabel: string - showSaveButton: boolean - saveButtonLabel: string + _id?: string + actionType?: string + dataSource?: { resourceId: string } + notificationOverride?: boolean + actionUrl?: string + showDeleteButton?: boolean + deleteButtonLabel?: string + showSaveButton?: boolean + saveButtonLabel?: string }) => { const { _id,