Merge branch 'feature/security-update' of github.com:Budibase/budibase into feature/security-update

This commit is contained in:
mike12345567 2020-12-09 12:30:49 +00:00
commit 6f9340c4d2
1 changed files with 3 additions and 34 deletions

View File

@ -83,8 +83,7 @@ export const getFrontendStore = () => {
}, },
}, },
screens: { screens: {
select: async screenId => { select: screenId => {
let promise
store.update(state => { store.update(state => {
const screens = get(allScreens) const screens = get(allScreens)
let selectedScreen = screens.find(screen => screen._id === screenId) let selectedScreen = screens.find(screen => screen._id === screenId)
@ -94,11 +93,9 @@ export const getFrontendStore = () => {
state.currentFrontEndType = FrontendTypes.SCREEN state.currentFrontEndType = FrontendTypes.SCREEN
state.currentAssetId = selectedScreen._id state.currentAssetId = selectedScreen._id
state.currentView = "detail" state.currentView = "detail"
promise = store.actions.screens.regenerateCss(selectedScreen)
state.selectedComponentId = selectedScreen.props._id state.selectedComponentId = selectedScreen.props._id
return state return state
}) })
await promise
}, },
create: async screen => { create: async screen => {
screen = await store.actions.screens.save(screen) screen = await store.actions.screens.save(screen)
@ -136,16 +133,6 @@ export const getFrontendStore = () => {
}) })
return screen return screen
}, },
regenerateCss: async asset => {
const response = await api.post("/api/css/generate", asset)
asset._css = (await response.json())?.css
},
regenerateCssForCurrentScreen: async () => {
const asset = get(currentAsset)
if (asset) {
await store.actions.screens.regenerateCss(asset)
}
},
delete: async screens => { delete: async screens => {
const screensToDelete = Array.isArray(screens) ? screens : [screens] const screensToDelete = Array.isArray(screens) ? screens : [screens]
@ -179,29 +166,18 @@ export const getFrontendStore = () => {
}, },
}, },
layouts: { layouts: {
select: async layoutId => { select: layoutId => {
store.update(state => { store.update(state => {
const layout = store.actions.layouts.find(layoutId) const layout = store.actions.layouts.find(layoutId)
state.currentFrontEndType = FrontendTypes.LAYOUT state.currentFrontEndType = FrontendTypes.LAYOUT
state.currentView = "detail" state.currentView = "detail"
state.currentAssetId = layout._id state.currentAssetId = layout._id
state.selectedComponentId = layout.props._id state.selectedComponentId = layout.props._id
return state return state
}) })
let cssPromises = []
cssPromises.push(store.actions.screens.regenerateCssForCurrentScreen())
for (let screen of get(allScreens)) {
cssPromises.push(store.actions.screens.regenerateCss(screen))
}
await Promise.all(cssPromises)
}, },
save: async layout => { save: async layout => {
const layoutToSave = cloneDeep(layout) const layoutToSave = cloneDeep(layout)
delete layoutToSave._css
const response = await api.post(`/api/layouts`, layoutToSave) const response = await api.post(`/api/layouts`, layoutToSave)
@ -371,7 +347,6 @@ export const getFrontendStore = () => {
const index = mode === "above" ? targetIndex : targetIndex + 1 const index = mode === "above" ? targetIndex : targetIndex + 1
parent._children.splice(index, 0, cloneDeep(componentToPaste)) parent._children.splice(index, 0, cloneDeep(componentToPaste))
promises.push(store.actions.screens.regenerateCssForCurrentScreen())
promises.push(store.actions.preview.saveSelected()) promises.push(store.actions.preview.saveSelected())
store.actions.components.select(componentToPaste) store.actions.components.select(componentToPaste)
@ -389,8 +364,6 @@ export const getFrontendStore = () => {
} }
selected._styles[type][name] = value selected._styles[type][name] = value
promises.push(store.actions.screens.regenerateCssForCurrentScreen())
// save without messing with the store // save without messing with the store
promises.push(store.actions.preview.saveSelected()) promises.push(store.actions.preview.saveSelected())
return state return state
@ -475,13 +448,9 @@ export const getFrontendStore = () => {
}).props }).props
} }
// Save layout and regenerate all CSS because otherwise weird things happen // Save layout
nav._children = [...nav._children, newLink] nav._children = [...nav._children, newLink]
state.currentAssetId = layout._id state.currentAssetId = layout._id
promises.push(store.actions.screens.regenerateCss(layout))
for (let screen of get(allScreens)) {
promises.push(store.actions.screens.regenerateCss(screen))
}
promises.push(store.actions.layouts.save(layout)) promises.push(store.actions.layouts.save(layout))
} }
return state return state