Clean up frontend store
This commit is contained in:
parent
891bdefcb7
commit
81558588dc
|
@ -28,7 +28,6 @@ import {
|
|||
} from "../componentUtils"
|
||||
import { Helpers } from "@budibase/bbui"
|
||||
import { removeBindings } from "../dataBinding"
|
||||
import { notifications } from "@budibase/bbui"
|
||||
|
||||
const INITIAL_FRONTEND_STATE = {
|
||||
apps: [],
|
||||
|
@ -160,21 +159,6 @@ export const getFrontendStore = () => {
|
|||
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 => {
|
||||
const creatingNewScreen = screen._id === undefined
|
||||
const savedScreen = await API.saveScreen(screen)
|
||||
|
@ -431,24 +415,19 @@ export const getFrontendStore = () => {
|
|||
parentComponent._children.push(componentInstance)
|
||||
|
||||
// Save components and update UI
|
||||
const savedAsset = await store.actions.preview.saveSelected()
|
||||
if (savedAsset) {
|
||||
store.update(state => {
|
||||
state.currentView = "component"
|
||||
state.selectedComponentId = componentInstance._id
|
||||
return state
|
||||
})
|
||||
await store.actions.preview.saveSelected()
|
||||
store.update(state => {
|
||||
state.currentView = "component"
|
||||
state.selectedComponentId = componentInstance._id
|
||||
return state
|
||||
})
|
||||
|
||||
// Log event
|
||||
analytics.captureEvent(Events.COMPONENT.CREATED, {
|
||||
name: componentInstance._component,
|
||||
})
|
||||
// Log event
|
||||
analytics.captureEvent(Events.COMPONENT.CREATED, {
|
||||
name: componentInstance._component,
|
||||
})
|
||||
|
||||
return componentInstance
|
||||
} else {
|
||||
notifications.error("Failed to create component")
|
||||
return null
|
||||
}
|
||||
return componentInstance
|
||||
},
|
||||
delete: async component => {
|
||||
if (!component) {
|
||||
|
|
|
@ -75,7 +75,7 @@
|
|||
|
||||
draftScreen.routing.route = route
|
||||
|
||||
await store.actions.screens.create(draftScreen)
|
||||
await store.actions.screens.save(draftScreen)
|
||||
if (draftScreen.props._instanceName.endsWith("List")) {
|
||||
try {
|
||||
await store.actions.components.links.save(
|
||||
|
|
Loading…
Reference in New Issue