-
-
+ {#if loaded && enrichedApps.length}
+
+
+ Apps
+
+ Import app
+ Create new app
+
+
+
+
+
+
+
+ (layout = "grid")}
+ selected={layout === "grid"}
+ quiet
+ icon="ClassicGridView"
+ />
+ (layout = "table")}
+ selected={layout === "table"}
+ quiet
+ icon="ViewRow"
+ />
+
-
- (layout = "grid")}
- selected={layout === "grid"}
- quiet
- icon="ClassicGridView"
- />
- (layout = "table")}
- selected={layout === "table"}
- quiet
- icon="ViewRow"
- />
-
-
- {#if loaded && $apps.length}
- {#each $apps as app, idx (app.appId)}
+ {#each enrichedApps as app (app.appId)}
{/each}
- {/if}
-
- {#if !$apps.length && !creatingApp && loaded}
+
+ {/if}
+ {#if !enrichedApps.length && !creatingApp && loaded}
- Are you sure you want to delete the app {appToDelete?.name} ?
+ Are you sure you want to delete the app {selectedApp?.name} ?
+
+
+ Are you sure you want to unpublish the app {selectedApp?.name} ?
diff --git a/packages/builder/src/stores/portal/apps.js b/packages/builder/src/stores/portal/apps.js
index e0dfe112b5..f0cee6147c 100644
--- a/packages/builder/src/stores/portal/apps.js
+++ b/packages/builder/src/stores/portal/apps.js
@@ -1,15 +1,49 @@
import { writable } from "svelte/store"
import { get } from "builderStore/api"
+import { AppStatus } from "../../constants"
export function createAppStore() {
const store = writable([])
- async function load(status = "") {
+ async function load() {
try {
- const res = await get(`/api/applications?status=${status}`)
+ const res = await get(`/api/applications?status=all`)
const json = await res.json()
if (res.ok && Array.isArray(json)) {
- store.set(json)
+ // Merge apps into one sensible list
+ let appMap = {}
+ let devApps = json.filter(app => app.status === AppStatus.DEV)
+ let deployedApps = json.filter(app => app.status === AppStatus.DEPLOYED)
+
+ // First append all dev app version
+ devApps.forEach(app => {
+ const id = app.appId.substring(8)
+ appMap[id] = {
+ ...app,
+ devId: app.appId,
+ devRev: app._rev,
+ }
+ })
+
+ // Then merge with all prod app versions
+ deployedApps.forEach(app => {
+ const id = app.appId.substring(4)
+ appMap[id] = {
+ ...appMap[id],
+ ...app,
+ prodId: app.appId,
+ prodRev: app._rev,
+ }
+ })
+
+ // Transform into an array and clean up
+ const apps = Object.values(appMap)
+ apps.forEach(app => {
+ app.appId = app.devId.substring(8)
+ delete app._id
+ delete app._rev
+ })
+ store.set(apps)
} else {
store.set([])
}
diff --git a/packages/server/src/db/utils.js b/packages/server/src/db/utils.js
index 81686ea267..29617a7dff 100644
--- a/packages/server/src/db/utils.js
+++ b/packages/server/src/db/utils.js
@@ -18,9 +18,9 @@ const StaticDatabases = {
}
const AppStatus = {
- DEV: "dev",
+ DEV: "development",
ALL: "all",
- DEPLOYED: "PUBLISHED",
+ DEPLOYED: "published",
}
const DocumentTypes = {