Merge pull request #2668 from Budibase/fix/tenant-app-id-parsing

Update app ID parsing to handle tenant ID's
This commit is contained in:
Andrew Kingston 2021-09-20 10:11:38 +01:00 committed by GitHub
commit dec175a1a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 3 deletions

View File

@ -3,6 +3,11 @@ import { get } from "builderStore/api"
import { AppStatus } from "../../constants"
import api from "../../builderStore/api"
const extractAppId = id => {
const split = id?.split("_") || []
return split.length ? split[split.length - 1] : null
}
export function createAppStore() {
const store = writable([])
@ -18,7 +23,7 @@ export function createAppStore() {
// First append all dev app version
devApps.forEach(app => {
const id = app.appId.substring(8)
const id = extractAppId(app.appId)
appMap[id] = {
...app,
devId: app.appId,
@ -28,7 +33,13 @@ export function createAppStore() {
// Then merge with all prod app versions
deployedApps.forEach(app => {
const id = app.appId.substring(4)
const id = extractAppId(app.appId)
// Skip any deployed apps which don't have a dev counterpart
if (!appMap[id]) {
return
}
appMap[id] = {
...appMap[id],
...app,
@ -40,7 +51,7 @@ export function createAppStore() {
// Transform into an array and clean up
const apps = Object.values(appMap)
apps.forEach(app => {
app.appId = app.devId.substring(8)
app.appId = extractAppId(app.devId)
delete app._id
delete app._rev
})