fixes for templates, ensured iframetemplate fires ready event
This commit is contained in:
parent
8b7f3a461f
commit
50b547e0a9
|
@ -1,9 +1,16 @@
|
|||
<script>
|
||||
import { Icon, Modal, notifications, ModalContent } from "@budibase/bbui"
|
||||
import {
|
||||
Icon,
|
||||
Input,
|
||||
Modal,
|
||||
notifications,
|
||||
ModalContent,
|
||||
} from "@budibase/bbui"
|
||||
import { store } from "builderStore"
|
||||
import api from "builderStore/api"
|
||||
|
||||
let revertModal
|
||||
let appName
|
||||
|
||||
$: appId = $store.appId
|
||||
|
||||
|
@ -33,10 +40,17 @@
|
|||
|
||||
<Icon name="Revert" hoverable on:click={revertModal.show} />
|
||||
<Modal bind:this={revertModal}>
|
||||
<ModalContent title="Revert Changes" confirmText="Revert" onConfirm={revert}>
|
||||
<ModalContent
|
||||
title="Revert Changes"
|
||||
confirmText="Revert"
|
||||
onConfirm={revert}
|
||||
disabled={appName !== $store.name}
|
||||
>
|
||||
<span
|
||||
>The changes you have made will be deleted and the application reverted
|
||||
back to its production state.</span
|
||||
>
|
||||
<span>Please enter your app name to continue.</span>
|
||||
<Input bind:value={appName} />
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
|
|
|
@ -69,6 +69,7 @@
|
|||
theme: $store.theme,
|
||||
customTheme: $store.customTheme,
|
||||
previewDevice: $store.previewDevice,
|
||||
messagePassing: $store.clientFeatures.messagePassing
|
||||
}
|
||||
|
||||
// Saving pages and screens to the DB causes them to have _revs.
|
||||
|
|
|
@ -65,6 +65,7 @@ export default `
|
|||
theme,
|
||||
customTheme,
|
||||
previewDevice,
|
||||
messagePassing
|
||||
} = parsed
|
||||
|
||||
// Set some flags so the app knows we're in the builder
|
||||
|
@ -89,7 +90,11 @@ export default `
|
|||
throw "The client library couldn't be loaded"
|
||||
}
|
||||
} catch (error) {
|
||||
window.parent.postMessage({ type: "error", error })
|
||||
if (messagePassing) {
|
||||
window.parent.postMessage({ type: "error", error })
|
||||
} else {
|
||||
window.dispatchEvent(new CustomEvent("error", { detail: error }))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,7 +102,9 @@ export default `
|
|||
window.addEventListener("keydown", evt => {
|
||||
window.parent.postMessage({ type: "keydown", key: event.key })
|
||||
})
|
||||
|
||||
window.parent.postMessage({ type: "ready" })
|
||||
window.dispatchEvent(new Event("ready"))
|
||||
</script>
|
||||
</head>
|
||||
<body/>
|
||||
|
|
|
@ -157,6 +157,11 @@
|
|||
}
|
||||
return title
|
||||
}
|
||||
|
||||
async function onCancel() {
|
||||
template = null
|
||||
await auth.setInitInfo({})
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if showTemplateSelection}
|
||||
|
@ -186,7 +191,7 @@
|
|||
title={getModalTitle()}
|
||||
confirmText={template?.fromFile ? "Import app" : "Create app"}
|
||||
onConfirm={createNewApp}
|
||||
onCancel={inline ? () => (template = null) : null}
|
||||
onCancel={inline ? onCancel : null}
|
||||
cancelText={inline ? "Back" : undefined}
|
||||
showCloseIcon={!inline}
|
||||
disabled={!valid}
|
||||
|
|
|
@ -80,6 +80,10 @@ export function createAuthStore() {
|
|||
}
|
||||
}
|
||||
|
||||
async function setInitInfo(info) {
|
||||
await api.post(`/api/global/auth/init`, info)
|
||||
}
|
||||
|
||||
return {
|
||||
subscribe: store.subscribe,
|
||||
setOrganisation: setOrganisation,
|
||||
|
@ -87,9 +91,7 @@ export function createAuthStore() {
|
|||
const response = await api.get(`/api/global/auth/init`)
|
||||
return await response.json()
|
||||
},
|
||||
setInitInfo: async info => {
|
||||
await api.post(`/api/global/auth/init`, info)
|
||||
},
|
||||
setInitInfo,
|
||||
checkQueryString: async () => {
|
||||
const urlParams = new URLSearchParams(window.location.search)
|
||||
if (urlParams.has("tenantId")) {
|
||||
|
@ -129,6 +131,7 @@ export function createAuthStore() {
|
|||
throw "Unable to create logout"
|
||||
}
|
||||
await response.json()
|
||||
await setInitInfo({})
|
||||
setUser(null)
|
||||
},
|
||||
updateSelf: async fields => {
|
||||
|
|
|
@ -323,7 +323,7 @@ exports.delete = async ctx => {
|
|||
ctx.body = result
|
||||
}
|
||||
|
||||
exports.sync = async ctx => {
|
||||
exports.sync = async (ctx, next) => {
|
||||
const appId = ctx.params.appId
|
||||
if (!isDevAppID(appId)) {
|
||||
ctx.throw(400, "This action cannot be performed for production apps")
|
||||
|
@ -336,10 +336,11 @@ exports.sync = async ctx => {
|
|||
if (info.error) throw info.error
|
||||
} catch (err) {
|
||||
// the database doesn't exist. Don't replicate
|
||||
ctx.status = 200
|
||||
ctx.body = {
|
||||
message: "App sync not required, app not deployed.",
|
||||
}
|
||||
return
|
||||
return next()
|
||||
}
|
||||
|
||||
const replication = new Replication({
|
||||
|
|
Loading…
Reference in New Issue