From c944d1fdf5ca908d8f80845b12e6faec9e492fdf Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 24 Feb 2022 15:36:21 +0000 Subject: [PATCH] Update devtools with new features --- .../client/src/components/ClientApp.svelte | 1 + .../client/src/components/Component.svelte | 22 ++--- .../src/components/devtools/DevTools.svelte | 1 + .../devtools/DevToolsComponentSetting.svelte | 13 +++ .../devtools/DevToolsComponentTab.svelte | 87 +++++++++++++++---- .../components/devtools/DevToolsHeader.svelte | 3 +- .../components/devtools/DevToolsStat.svelte | 18 +++- packages/client/src/stores/builder.js | 2 + packages/client/src/utils/componentProps.js | 18 ++++ packages/server/src/middleware/currentapp.js | 2 +- 10 files changed, 130 insertions(+), 37 deletions(-) create mode 100644 packages/client/src/components/devtools/DevToolsComponentSetting.svelte diff --git a/packages/client/src/components/ClientApp.svelte b/packages/client/src/components/ClientApp.svelte index 29258a1a31..d55b00ef9c 100644 --- a/packages/client/src/components/ClientApp.svelte +++ b/packages/client/src/components/ClientApp.svelte @@ -208,6 +208,7 @@ flex-direction: row; justify-content: flex-start; align-items: stretch; + overflow: hidden; } .error { diff --git a/packages/client/src/components/Component.svelte b/packages/client/src/components/Component.svelte index 7feb92fb86..f9e3027ecf 100644 --- a/packages/client/src/components/Component.svelte +++ b/packages/client/src/components/Component.svelte @@ -12,7 +12,11 @@ import { writable, get } from "svelte/store" import * as AppComponents from "components/app" import Router from "./Router.svelte" - import { enrichProps, propsAreSame } from "utils/componentProps" + import { + enrichProps, + propsAreSame, + getSettingsDefinition, + } from "utils/componentProps" import { builderStore, devToolsStore, componentStore } from "stores" import { Helpers } from "@budibase/bbui" import Manifest from "manifest.json" @@ -207,22 +211,6 @@ return type ? Manifest[type] : null } - // Gets the definition of this component's settings from the manifest - const getSettingsDefinition = definition => { - if (!definition) { - return [] - } - let settings = [] - definition.settings?.forEach(setting => { - if (setting.section) { - settings = settings.concat(setting.settings || []) - } else { - settings.push(setting) - } - }) - return settings - } - const getInstanceSettings = (instance, settingsDefinition) => { // Get raw settings let settings = {} diff --git a/packages/client/src/components/devtools/DevTools.svelte b/packages/client/src/components/devtools/DevTools.svelte index e8d9c1cb44..731695e29c 100644 --- a/packages/client/src/components/devtools/DevTools.svelte +++ b/packages/client/src/components/devtools/DevTools.svelte @@ -38,6 +38,7 @@ background: var(--spectrum-alias-background-color-secondary); flex: 0 0 320px; border-left: 1px solid var(--spectrum-global-color-gray-300); + overflow: auto; } .devtools.mobile { display: none; diff --git a/packages/client/src/components/devtools/DevToolsComponentSetting.svelte b/packages/client/src/components/devtools/DevToolsComponentSetting.svelte new file mode 100644 index 0000000000..9bbbf2615c --- /dev/null +++ b/packages/client/src/components/devtools/DevToolsComponentSetting.svelte @@ -0,0 +1,13 @@ + + +{#if prettyName} + +{/if} diff --git a/packages/client/src/components/devtools/DevToolsComponentTab.svelte b/packages/client/src/components/devtools/DevToolsComponentTab.svelte index f90af754aa..cf99159f1d 100644 --- a/packages/client/src/components/devtools/DevToolsComponentTab.svelte +++ b/packages/client/src/components/devtools/DevToolsComponentTab.svelte @@ -5,12 +5,22 @@ Heading, Button, TextArea, - Divider, + Tabs, + Tab, + Toggle, } from "@budibase/bbui" import { builderStore, devToolsStore, componentStore } from "stores" import DevToolsStat from "./DevToolsStat.svelte" + import { getSettingsDefinition } from "utils/componentProps.js" + + let showEnrichedSettings = true $: selectedInstance = $componentStore.selectedComponentInstance + $: settingsDefinition = getSettingsDefinition( + $componentStore.selectedComponentDefinition + ) + $: rawSettings = selectedInstance?.getRawSettings() + $: settings = selectedInstance?.getSettings() $: { if (!selectedInstance) { @@ -48,40 +58,83 @@ /> -
+
+
+
-