diff --git a/packages/builder/src/components/start/AppCard.svelte b/packages/builder/src/components/start/AppCard.svelte deleted file mode 100644 index 670ef16b60..0000000000 --- a/packages/builder/src/components/start/AppCard.svelte +++ /dev/null @@ -1,126 +0,0 @@ - - -
- -
-
- {#if app.lockedBy} - - {/if} -
editApp(app)}> - - {app.name} - -
- - - {#if app.deployed} - viewApp(app)} icon="GlobeOutline"> - View published app - - {/if} - {#if app.lockedYou} - releaseLock(app)} icon="LockOpen"> - Release lock - - {/if} - exportApp(app)} icon="Download"> - Export - - {#if app.deployed} - unpublishApp(app)} icon="GlobeRemove"> - Unpublish - - {/if} - {#if !app.deployed} - updateApp(app)} icon="Edit">Edit - deleteApp(app)} icon="Delete"> - Delete - - {/if} - -
-
- - {#if app.updatedAt} - {processStringSync("Updated {{ duration time 'millisecond' }} ago", { - time: new Date().getTime() - new Date(app.updatedAt).getTime(), - })} - {:else} - Never updated - {/if} - - - {#if app.deployed}Published{:else}Unpublished{/if} - -
- -
- - diff --git a/packages/builder/src/pages/builder/apps/index.svelte b/packages/builder/src/pages/builder/apps/index.svelte index 1639e3390f..aafc28cd92 100644 --- a/packages/builder/src/pages/builder/apps/index.svelte +++ b/packages/builder/src/pages/builder/apps/index.svelte @@ -12,7 +12,7 @@ Modal, } from "@budibase/bbui" import { onMount } from "svelte" - import { apps, organisation, auth } from "stores/portal" + import { apps, organisation, auth, admin } from "stores/portal" import { goto } from "@roxi/routify" import { AppStatus } from "constants" import { gradient } from "actions" @@ -34,12 +34,16 @@ const publishedAppsOnly = app => app.status === AppStatus.DEPLOYED $: publishedApps = $apps.filter(publishedAppsOnly) - + $: isCloud = $admin.cloud $: userApps = $auth.user?.builder?.global ? publishedApps : publishedApps.filter(app => Object.keys($auth.user?.roles).includes(app.prodId) ) + + function getUrl(app) { + return !isCloud ? `/app/${encodeURIComponent(app.name)}` : `/${app.prodId}` + } {#if $auth.user && loaded} @@ -93,7 +97,7 @@
{#each userApps as app, idx (app.appId)} - +
{app.name} diff --git a/packages/builder/src/pages/builder/portal/apps/index.svelte b/packages/builder/src/pages/builder/portal/apps/index.svelte index 336489be8d..c85ad79d45 100644 --- a/packages/builder/src/pages/builder/portal/apps/index.svelte +++ b/packages/builder/src/pages/builder/portal/apps/index.svelte @@ -47,6 +47,7 @@ $: filteredApps = enrichedApps.filter(app => app?.name?.toLowerCase().includes(searchTerm.toLowerCase()) ) + $: isCloud = $admin.cloud const enrichApps = (apps, user, sortBy) => { const enrichedApps = apps.map(app => ({ @@ -158,8 +159,13 @@ } const viewApp = app => { - const id = app.deployed ? app.prodId : app.devId - window.open(`/${id}`, "_blank") + if (!isCloud && app.deployed) { + // special case to use the short form name if self hosted + window.open(`/app/${encodeURIComponent(app.name)}`) + } else { + const id = app.deployed ? app.prodId : app.devId + window.open(`/${id}`, "_blank") + } } const editApp = app => { diff --git a/packages/worker/src/api/controllers/app.js b/packages/worker/src/api/controllers/app.js index 8f0d4f402f..fa03c09c55 100644 --- a/packages/worker/src/api/controllers/app.js +++ b/packages/worker/src/api/controllers/app.js @@ -1,18 +1,29 @@ -const { getAllApps } = require("@budibase/auth/db") +const { + getAllApps, + getDeployedAppID, + isProdAppID, +} = require("@budibase/auth/db") const CouchDB = require("../../db") const URL_REGEX_SLASH = /\/|\\/g exports.getApps = async ctx => { - const apps = await getAllApps(CouchDB, { dev: true }) + const apps = await getAllApps(CouchDB, { all: true }) const body = {} for (let app of apps) { let url = app.url || encodeURI(`${app.name}`) url = `/${url.replace(URL_REGEX_SLASH, "")}` - body[url] = { - appId: app.appId, - name: app.name, - url, + const appId = app.appId, + isProd = isProdAppID(app.appId) + if (!body[url]) { + body[url] = { + appId: getDeployedAppID(appId), + name: app.name, + url, + deployed: isProd, + } + } else { + body[url].deployed = isProd || body[url].deployed } } ctx.body = body