Clean up frontend store

This commit is contained in:
Andrew Kingston 2022-01-24 18:53:41 +00:00
parent 891bdefcb7
commit 81558588dc
2 changed files with 12 additions and 33 deletions

View File

@ -28,7 +28,6 @@ import {
} from "../componentUtils" } from "../componentUtils"
import { Helpers } from "@budibase/bbui" import { Helpers } from "@budibase/bbui"
import { removeBindings } from "../dataBinding" import { removeBindings } from "../dataBinding"
import { notifications } from "@budibase/bbui"
const INITIAL_FRONTEND_STATE = { const INITIAL_FRONTEND_STATE = {
apps: [], apps: [],
@ -160,21 +159,6 @@ export const getFrontendStore = () => {
return state return state
}) })
}, },
create: async screen => {
const savedScreen = await API.saveScreen(screen)
store.update(state => {
state.screens.push(savedScreen)
state.selectedScreenId = savedScreen._id
state.selectedComponentId = savedScreen.props._id
state.currentFrontEndType = FrontendTypes.SCREEN
selectedAccessRole.set(savedScreen.routing.roleId)
return state
})
// Refresh routes
await store.actions.routing.fetch()
return savedScreen
},
save: async screen => { save: async screen => {
const creatingNewScreen = screen._id === undefined const creatingNewScreen = screen._id === undefined
const savedScreen = await API.saveScreen(screen) const savedScreen = await API.saveScreen(screen)
@ -431,8 +415,7 @@ export const getFrontendStore = () => {
parentComponent._children.push(componentInstance) parentComponent._children.push(componentInstance)
// Save components and update UI // Save components and update UI
const savedAsset = await store.actions.preview.saveSelected() await store.actions.preview.saveSelected()
if (savedAsset) {
store.update(state => { store.update(state => {
state.currentView = "component" state.currentView = "component"
state.selectedComponentId = componentInstance._id state.selectedComponentId = componentInstance._id
@ -445,10 +428,6 @@ export const getFrontendStore = () => {
}) })
return componentInstance return componentInstance
} else {
notifications.error("Failed to create component")
return null
}
}, },
delete: async component => { delete: async component => {
if (!component) { if (!component) {

View File

@ -75,7 +75,7 @@
draftScreen.routing.route = route draftScreen.routing.route = route
await store.actions.screens.create(draftScreen) await store.actions.screens.save(draftScreen)
if (draftScreen.props._instanceName.endsWith("List")) { if (draftScreen.props._instanceName.endsWith("List")) {
try { try {
await store.actions.components.links.save( await store.actions.components.links.save(