From 78ba798be2ff6bd187f8ca505a2cc9a214456667 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 18 May 2021 14:39:26 +0100 Subject: [PATCH] Improve routing based on auth and roles, and use redirects rather than pushing new routes --- .../src/components/start/AppCard.svelte | 6 +- .../src/components/start/AppRow.svelte | 15 +- .../builder/src/pages/builder/_layout.svelte | 6 +- .../src/pages/builder/apps/_layout.svelte | 7 + .../src/pages/builder/apps/index.svelte | 193 ++++++------------ .../src/pages/builder/auth/index.svelte | 4 +- .../builder/src/pages/builder/index.svelte | 14 +- .../src/pages/builder/portal/_layout.svelte | 102 +++++---- .../src/pages/builder/portal/index.svelte | 4 +- packages/builder/src/pages/index.svelte | 4 +- 10 files changed, 155 insertions(+), 200 deletions(-) create mode 100644 packages/builder/src/pages/builder/apps/_layout.svelte diff --git a/packages/builder/src/components/start/AppCard.svelte b/packages/builder/src/components/start/AppCard.svelte index 3e7d87bb0f..1d444b2afb 100644 --- a/packages/builder/src/components/start/AppCard.svelte +++ b/packages/builder/src/components/start/AppCard.svelte @@ -25,11 +25,11 @@
- openApp(app)}> +
openApp(app)}> {app.name} - +
exportApp(app)} icon="Download"> @@ -76,7 +76,7 @@ align-items: center; } - .title :global(a) { + .name { text-decoration: none; flex: 1 1 auto; width: 0; diff --git a/packages/builder/src/components/start/AppRow.svelte b/packages/builder/src/components/start/AppRow.svelte index 1fe65f290a..7213a0bd3e 100644 --- a/packages/builder/src/components/start/AppRow.svelte +++ b/packages/builder/src/components/start/AppRow.svelte @@ -1,13 +1,6 @@ diff --git a/packages/builder/src/pages/builder/apps/_layout.svelte b/packages/builder/src/pages/builder/apps/_layout.svelte new file mode 100644 index 0000000000..ece538e0e9 --- /dev/null +++ b/packages/builder/src/pages/builder/apps/_layout.svelte @@ -0,0 +1,7 @@ + + +{#if $auth.user} + +{/if} diff --git a/packages/builder/src/pages/builder/apps/index.svelte b/packages/builder/src/pages/builder/apps/index.svelte index e9444d426a..c81bc894f9 100644 --- a/packages/builder/src/pages/builder/apps/index.svelte +++ b/packages/builder/src/pages/builder/apps/index.svelte @@ -9,154 +9,86 @@ Avatar, Page, Icon, - notifications, Body, } from "@budibase/bbui" - import api, { del } from "builderStore/api" - import analytics from "analytics" import { onMount } from "svelte" import { apps, organisation } from "stores/portal" import { auth } from "stores/backend" - import download from "downloadjs" import { goto } from "@roxi/routify" import { AppStatus } from "constants" import { gradient } from "actions" - let layout = "grid" - let template - let appToDelete - let creationModal - let deletionModal - let creatingApp = false let loaded = false - const checkKeys = async () => { - const response = await api.get(`/api/keys/`) - const keys = await response.json() - if (keys.userId) { - analytics.identify(keys.userId) - } - } - - const initiateAppCreation = () => { - creationModal.show() - creatingApp = true - } - - const initiateAppImport = () => { - template = { fromFile: true } - creationModal.show() - creatingApp = true - } - - const stopAppCreation = () => { - template = null - creatingApp = false - } - - const openApp = app => { - $goto(`../../app/${app._id}`) - } - - const exportApp = app => { - try { - download( - `/api/backups/export?appId=${app._id}&appname=${encodeURIComponent( - app.name - )}` - ) - notifications.success("App export complete") - } catch (err) { - console.error(err) - notifications.error("App export failed") - } - } - - const deleteApp = app => { - appToDelete = app - deletionModal.show() - } - - const confirmDeleteApp = async () => { - if (!appToDelete) { - return - } - await del(`/api/applications/${appToDelete?._id}`) - await apps.load() - appToDelete = null - } - onMount(async () => { - checkKeys() await apps.load(AppStatus.DEV) loaded = true }) - - $: console.log($auth.user) -
- -
- - -
- - Hey {$auth.user.email} - - Welcome to the {$organisation.company} portal. Below you'll find the - list of apps that you have access to, as well as company news and the - employee handbook. - - - -
- - -
- - Update user information - - - Update password - - $goto("../portal")}> - Open developer mode - - Log out -
-
- -
- Apps - +
+
+ +
+ GROUP + {#if $auth.user?.builder?.global} + + {/if} +
+ {#each $apps as app, idx (app.appId)} + + +
+
+ +
+{/if}