diff --git a/packages/builder/src/pages/builder/portal/overview/[application]/index.svelte b/packages/builder/src/pages/builder/portal/overview/[application]/index.svelte index 58e22ae330..f659b5e5d0 100644 --- a/packages/builder/src/pages/builder/portal/overview/[application]/index.svelte +++ b/packages/builder/src/pages/builder/portal/overview/[application]/index.svelte @@ -34,15 +34,19 @@ export let application - let promise = getPackage() let loaded = false let deletionModal let unpublishModal let appName = "" + let deployments = [] // App $: filteredApps = $apps.filter(app => app.devId === application) $: selectedApp = filteredApps?.length ? filteredApps[0] : null + $: loaded && !selectedApp && backToAppList() + $: isPublished = + selectedApp?.status === AppStatus.DEPLOYED && latestDeployments?.length > 0 + $: appUrl = `${window.origin}/app${selectedApp?.url}` // Locking $: lockedBy = selectedApp?.lockedBy @@ -54,18 +58,11 @@ }` // App deployments - $: deployments = [] $: latestDeployments = deployments - .filter( - deployment => - deployment.status === "SUCCESS" && application === deployment.appId - ) + .filter(x => x.status === "SUCCESS" && application === x.appId) .sort((a, b) => a.updatedAt > b.updatedAt) - $: isPublished = - selectedApp?.status === AppStatus.DEPLOYED && latestDeployments?.length > 0 - - $: appUrl = `${window.origin}/app${selectedApp?.url}` + // Tabs $: tabs = ["Overview", "Automation History", "Backups", "Settings", "Access"] $: selectedTab = "Overview" @@ -83,17 +80,6 @@ } } - async function getPackage() { - try { - const pkg = await API.fetchAppPackage(application) - await store.actions.initialise(pkg) - loaded = true - return pkg - } catch (error) { - notifications.error(`Error initialising app: ${error?.message}`) - } - } - const reviewPendingDeployments = (deployments, newDeployments) => { if (deployments.length > 0) { const pending = checkIncomingDeploymentStatus(deployments, newDeployments) @@ -185,185 +171,190 @@ appName = null } - onDestroy(() => { - store.actions.reset() - }) - onMount(async () => { const params = new URLSearchParams(window.location.search) if (params.get("tab")) { selectedTab = params.get("tab") } + + // Check app exists try { + const pkg = await API.fetchAppPackage(application) + await store.actions.initialise(pkg) + } catch (error) { + // Swallow + backToAppList() + } + + // Initialise application + try { + await API.syncApp(application) + deployments = await fetchDeployments() if (!apps.length) { await apps.load() } - await API.syncApp(application) - deployments = await fetchDeployments() } catch (error) { notifications.error("Error initialising app overview") } + loaded = true + }) + + onDestroy(() => { + store.actions.reset() }) -{#if selectedApp} - - - {#await promise} -
- -
- {:then _} - - - - Back - - -
-
- -
- {selectedApp?.name} -
{appUrl}
+ + + {#if !loaded || !selectedApp} +
+ +
+ {:else} + + + + Back + + +
+
+ -
- - - - - - - - - - exportApp(selectedApp, { published: false })} - icon="DownloadFromCloud" - > - Export latest - - {#if isPublished} - exportApp(selectedApp, { published: true })} - icon="DownloadFromCloudOutline" - > - Export published - - copyAppId(selectedApp)} icon="Copy"> - Copy app ID - - {/if} - {#if !isPublished} - deleteApp(selectedApp)} - icon="Delete" - > - Delete - - {/if} - +
+ {selectedApp?.name} +
{appUrl}
- -
- { - selectedTab = e.detail - }} - > - - unpublishApp(e.detail)} - /> - - - - - {#if isPublished} - - - - {/if} - {#if false} - -
Backups contents
-
- {/if} - - - -
+
+ + + + + + + + + + exportApp(selectedApp, { published: false })} + icon="DownloadFromCloud" + > + Export latest + + {#if isPublished} + exportApp(selectedApp, { published: true })} + icon="DownloadFromCloudOutline" + > + Export published + + copyAppId(selectedApp)} icon="Copy"> + Copy app ID + + {/if} + {#if !isPublished} + deleteApp(selectedApp)} icon="Delete"> + Delete + + {/if} + +
- (appName = null)} - disabled={appName !== selectedApp?.name} + +
+ { + selectedTab = e.detail + }} > - Are you sure you want to delete the app {selectedApp?.name}? + + unpublishApp(e.detail)} + /> + + + + + {#if isPublished} + + + + {/if} + {#if false} + +
Backups contents
+
+ {/if} + + + +
+
+ (appName = null)} + disabled={appName !== selectedApp?.name} + > + Are you sure you want to delete the app {selectedApp?.name}? -

Please enter the app name below to confirm.

- -
- - Are you sure you want to unpublish the app {selectedApp?.name}? - - {:catch error} -

Something went wrong: {error.message}

- {/await} - - -{/if} +

Please enter the app name below to confirm.

+ +
+ + Are you sure you want to unpublish the app {selectedApp?.name}? + + {/if} + +