Fixing #848 - standard components was not using the same API calls consistently which was breaking some things like charts. For now just make it consistent by updating it to make calls the same way as client lib does but the SDK will eventually replace all this and solve these problems.
This commit is contained in:
parent
37c68467c2
commit
f57acfdf16
|
@ -32,11 +32,11 @@
|
|||
icon="ri-layout-3-line"
|
||||
text="Master Screen"
|
||||
withArrow
|
||||
selected={$store.currentComponentInfo._id === _layout.component.props._id}
|
||||
opened={$store.currentPreviewItem.name === _layout.title}
|
||||
selected={$store.currentComponentInfo?._id === _layout.component.props._id}
|
||||
opened={$store.currentPreviewItem?.name === _layout.title}
|
||||
on:click={setCurrentScreenToLayout} />
|
||||
|
||||
{#if $store.currentPreviewItem.name === _layout.title && _layout.component.props._children}
|
||||
{#if $store.currentPreviewItem?.name === _layout.title && _layout.component.props._children}
|
||||
<ComponentsHierarchyChildren
|
||||
thisComponent={_layout.component.props}
|
||||
components={_layout.component.props._children}
|
||||
|
|
|
@ -11,9 +11,12 @@ const {
|
|||
async function checkForColumnUpdates(db, oldTable, updatedTable) {
|
||||
let updatedRows
|
||||
const rename = updatedTable._rename
|
||||
const deletedColumns = Object.keys(oldTable.schema).filter(
|
||||
let deletedColumns = []
|
||||
if (oldTable && oldTable.schema && updatedTable.schema) {
|
||||
deletedColumns = Object.keys(oldTable.schema).filter(
|
||||
colName => updatedTable.schema[colName] == null
|
||||
)
|
||||
}
|
||||
// check for renaming of columns or deleted columns
|
||||
if (rename || deletedColumns.length !== 0) {
|
||||
const rows = await db.allDocs(
|
||||
|
|
|
@ -1,3 +1,52 @@
|
|||
/**
|
||||
* TODO: this entire file should be removed, this has simply been updated to fix a bug until SDK comes along fixing
|
||||
* all these sort of inconsistency issues.
|
||||
*/
|
||||
const COOKIE_SEPARATOR = ";"
|
||||
const APP_PREFIX = "app_"
|
||||
const KEY_VALUE_SPLIT = "="
|
||||
|
||||
function confirmAppId(possibleAppId) {
|
||||
return possibleAppId && possibleAppId.startsWith(APP_PREFIX)
|
||||
? possibleAppId
|
||||
: undefined
|
||||
}
|
||||
|
||||
function tryGetFromCookie() {
|
||||
const cookie = window.document.cookie
|
||||
.split(COOKIE_SEPARATOR)
|
||||
.find(cookie => cookie.trim().startsWith("budibase:currentapp"))
|
||||
let appId
|
||||
if (cookie && cookie.split(KEY_VALUE_SPLIT).length === 2) {
|
||||
appId = cookie.split("=")[1]
|
||||
}
|
||||
return confirmAppId(appId)
|
||||
}
|
||||
|
||||
function tryGetFromPath() {
|
||||
const appId = location.pathname.split("/")[1]
|
||||
return confirmAppId(appId)
|
||||
}
|
||||
|
||||
function tryGetFromSubdomain() {
|
||||
const parts = window.location.host.split(".")
|
||||
const appId = parts[1] ? parts[0] : undefined
|
||||
return confirmAppId(appId)
|
||||
}
|
||||
|
||||
function getAppId() {
|
||||
const functions = [tryGetFromSubdomain, tryGetFromPath, tryGetFromCookie]
|
||||
// try getting the app Id in order
|
||||
let appId
|
||||
for (let func of functions) {
|
||||
appId = func()
|
||||
if (appId) {
|
||||
break
|
||||
}
|
||||
}
|
||||
return appId
|
||||
}
|
||||
|
||||
const apiCall = method => async (
|
||||
url,
|
||||
body,
|
||||
|
@ -5,17 +54,15 @@ const apiCall = method => async (
|
|||
"Content-Type": "application/json",
|
||||
}
|
||||
) => {
|
||||
const appId = location.pathname.split("/")[1]
|
||||
const appId = getAppId()
|
||||
if (appId) {
|
||||
headers["x-budibase-app-id"] = appId
|
||||
}
|
||||
const response = await fetch(url, {
|
||||
return await fetch(url, {
|
||||
method: method,
|
||||
body: body && JSON.stringify(body),
|
||||
headers,
|
||||
})
|
||||
|
||||
return response
|
||||
}
|
||||
|
||||
export const post = apiCall("POST")
|
||||
|
|
Loading…
Reference in New Issue