Update devtools with new features
This commit is contained in:
parent
b8809d33b9
commit
c944d1fdf5
|
@ -208,6 +208,7 @@
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
align-items: stretch;
|
align-items: stretch;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.error {
|
.error {
|
||||||
|
|
|
@ -12,7 +12,11 @@
|
||||||
import { writable, get } from "svelte/store"
|
import { writable, get } from "svelte/store"
|
||||||
import * as AppComponents from "components/app"
|
import * as AppComponents from "components/app"
|
||||||
import Router from "./Router.svelte"
|
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 { builderStore, devToolsStore, componentStore } from "stores"
|
||||||
import { Helpers } from "@budibase/bbui"
|
import { Helpers } from "@budibase/bbui"
|
||||||
import Manifest from "manifest.json"
|
import Manifest from "manifest.json"
|
||||||
|
@ -207,22 +211,6 @@
|
||||||
return type ? Manifest[type] : null
|
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) => {
|
const getInstanceSettings = (instance, settingsDefinition) => {
|
||||||
// Get raw settings
|
// Get raw settings
|
||||||
let settings = {}
|
let settings = {}
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
background: var(--spectrum-alias-background-color-secondary);
|
background: var(--spectrum-alias-background-color-secondary);
|
||||||
flex: 0 0 320px;
|
flex: 0 0 320px;
|
||||||
border-left: 1px solid var(--spectrum-global-color-gray-300);
|
border-left: 1px solid var(--spectrum-global-color-gray-300);
|
||||||
|
overflow: auto;
|
||||||
}
|
}
|
||||||
.devtools.mobile {
|
.devtools.mobile {
|
||||||
display: none;
|
display: none;
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
<script>
|
||||||
|
import DevToolsStat from "./DevToolsStat.svelte"
|
||||||
|
|
||||||
|
export let name
|
||||||
|
export let value
|
||||||
|
export let settingsMap
|
||||||
|
|
||||||
|
$: prettyName = settingsMap?.[name]?.label
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if prettyName}
|
||||||
|
<DevToolsStat label={prettyName} value={JSON.stringify(value)} />
|
||||||
|
{/if}
|
|
@ -5,12 +5,22 @@
|
||||||
Heading,
|
Heading,
|
||||||
Button,
|
Button,
|
||||||
TextArea,
|
TextArea,
|
||||||
Divider,
|
Tabs,
|
||||||
|
Tab,
|
||||||
|
Toggle,
|
||||||
} from "@budibase/bbui"
|
} from "@budibase/bbui"
|
||||||
import { builderStore, devToolsStore, componentStore } from "stores"
|
import { builderStore, devToolsStore, componentStore } from "stores"
|
||||||
import DevToolsStat from "./DevToolsStat.svelte"
|
import DevToolsStat from "./DevToolsStat.svelte"
|
||||||
|
import { getSettingsDefinition } from "utils/componentProps.js"
|
||||||
|
|
||||||
|
let showEnrichedSettings = true
|
||||||
|
|
||||||
$: selectedInstance = $componentStore.selectedComponentInstance
|
$: selectedInstance = $componentStore.selectedComponentInstance
|
||||||
|
$: settingsDefinition = getSettingsDefinition(
|
||||||
|
$componentStore.selectedComponentDefinition
|
||||||
|
)
|
||||||
|
$: rawSettings = selectedInstance?.getRawSettings()
|
||||||
|
$: settings = selectedInstance?.getSettings()
|
||||||
|
|
||||||
$: {
|
$: {
|
||||||
if (!selectedInstance) {
|
if (!selectedInstance) {
|
||||||
|
@ -48,40 +58,83 @@
|
||||||
/>
|
/>
|
||||||
<DevToolsStat label="ID" value={$componentStore.selectedComponent?._id} />
|
<DevToolsStat label="ID" value={$componentStore.selectedComponent?._id} />
|
||||||
</Layout>
|
</Layout>
|
||||||
<div>
|
<div class="buttons">
|
||||||
<Button
|
<Button
|
||||||
cta
|
cta
|
||||||
on:click={() => devToolsStore.actions.setAllowSelection(true)}
|
on:click={() => devToolsStore.actions.setAllowSelection(true)}
|
||||||
>
|
>
|
||||||
Change component
|
Change component
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button
|
||||||
|
quiet
|
||||||
|
secondary
|
||||||
|
on:click={() => builderStore.actions.selectComponent(null)}
|
||||||
|
>
|
||||||
|
Reset
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="data">
|
<div class="data">
|
||||||
<Layout noPadding gap="XS">
|
<Layout noPadding gap="XS">
|
||||||
<TextArea
|
<Tabs selected="Settings">
|
||||||
readonly
|
<Tab title="Settings">
|
||||||
label="Data context"
|
<div class="tab-content">
|
||||||
value={JSON.stringify(selectedInstance?.getDataContext(), null, 2)}
|
<Layout noPadding gap="S">
|
||||||
/>
|
<Toggle
|
||||||
<TextArea
|
text="Show enriched settings"
|
||||||
readonly
|
bind:value={showEnrichedSettings}
|
||||||
label="Raw settings"
|
/>
|
||||||
value={JSON.stringify(selectedInstance?.getRawSettings(), null, 2)}
|
<Layout noPadding gap="XS">
|
||||||
/>
|
{#each settingsDefinition as setting}
|
||||||
<TextArea
|
<DevToolsStat
|
||||||
readonly
|
label={setting.label}
|
||||||
label="Enriched settings"
|
value={JSON.stringify(
|
||||||
value={JSON.stringify(selectedInstance?.getSettings(), null, 2)}
|
(showEnrichedSettings ? settings : rawSettings)?.[
|
||||||
/>
|
setting.key
|
||||||
|
]
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
{/each}
|
||||||
|
</Layout>
|
||||||
|
</Layout>
|
||||||
|
</div>
|
||||||
|
</Tab>
|
||||||
|
<Tab title="Context">
|
||||||
|
<div class="tab-content">
|
||||||
|
<TextArea
|
||||||
|
readonly
|
||||||
|
label="Data context"
|
||||||
|
value={JSON.stringify(
|
||||||
|
selectedInstance?.getDataContext(),
|
||||||
|
null,
|
||||||
|
2
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</Tab>
|
||||||
|
</Tabs>
|
||||||
</Layout>
|
</Layout>
|
||||||
</div>
|
</div>
|
||||||
</Layout>
|
</Layout>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
.buttons {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: flex-start;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--spacing-xs);
|
||||||
|
}
|
||||||
|
.data {
|
||||||
|
margin: 0 calc(-1 * var(--spacing-xl));
|
||||||
|
}
|
||||||
.data :global(.spectrum-Textfield-input) {
|
.data :global(.spectrum-Textfield-input) {
|
||||||
min-height: 200px !important;
|
min-height: 200px !important;
|
||||||
white-space: pre;
|
white-space: pre;
|
||||||
font-size: var(--font-size-s);
|
font-size: var(--font-size-s);
|
||||||
}
|
}
|
||||||
|
.tab-content {
|
||||||
|
padding: 0 var(--spacing-xl);
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="dev-preview-header" class:mobile={$context.device.mobile}>
|
<div class="dev-preview-header" class:mobile={$context.device.mobile}>
|
||||||
<Heading size="XS">Application Preview</Heading>
|
<Heading size="XS">Budibase App Preview</Heading>
|
||||||
<Select
|
<Select
|
||||||
quiet
|
quiet
|
||||||
options={previewOptions}
|
options={previewOptions}
|
||||||
|
@ -53,6 +53,7 @@
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.dev-preview-header {
|
.dev-preview-header {
|
||||||
|
flex: 0 0 50px;
|
||||||
height: 50px;
|
height: 50px;
|
||||||
display: grid;
|
display: grid;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
|
@ -5,7 +5,9 @@
|
||||||
|
|
||||||
<div class="stat">
|
<div class="stat">
|
||||||
<div class="stat-label">{label}</div>
|
<div class="stat-label">{label}</div>
|
||||||
<div class="stat-value">{value}</div>
|
<div class="stat-value" title={value} on:click={() => console.log(value)}>
|
||||||
|
{value == null ? " " : value}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
@ -14,10 +16,24 @@
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
gap: var(--spacing-xl);
|
||||||
}
|
}
|
||||||
.stat-label {
|
.stat-label {
|
||||||
font-size: var(--font-size-xs);
|
font-size: var(--font-size-xs);
|
||||||
color: var(--spectrum-global-color-gray-600);
|
color: var(--spectrum-global-color-gray-600);
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
max-width: 140px;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
.stat-value {
|
||||||
|
flex: 1 1 auto;
|
||||||
|
width: 0;
|
||||||
|
text-align: right;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { writable, get } from "svelte/store"
|
import { writable, get } from "svelte/store"
|
||||||
import { API } from "api"
|
import { API } from "api"
|
||||||
|
import { devToolsStore } from "./devTools.js"
|
||||||
|
|
||||||
const dispatchEvent = (type, data = {}) => {
|
const dispatchEvent = (type, data = {}) => {
|
||||||
window.parent.postMessage({ type, data })
|
window.parent.postMessage({ type, data })
|
||||||
|
@ -31,6 +32,7 @@ const createBuilderStore = () => {
|
||||||
editMode: false,
|
editMode: false,
|
||||||
selectedComponentId: id,
|
selectedComponentId: id,
|
||||||
}))
|
}))
|
||||||
|
devToolsStore.actions.setAllowSelection(false)
|
||||||
dispatchEvent("select-component", { id })
|
dispatchEvent("select-component", { id })
|
||||||
},
|
},
|
||||||
updateProp: (prop, value) => {
|
updateProp: (prop, value) => {
|
||||||
|
|
|
@ -107,3 +107,21 @@ export const propsUseBinding = (props, bindingKey) => {
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the definition of this component's settings from the manifest
|
||||||
|
*/
|
||||||
|
export 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
|
||||||
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ module.exports = async (ctx, next) => {
|
||||||
if (isBuilder && isDevApp && roleHeader) {
|
if (isBuilder && isDevApp && roleHeader) {
|
||||||
// Ensure the role is valid ensuring a definition exists
|
// Ensure the role is valid ensuring a definition exists
|
||||||
try {
|
try {
|
||||||
await getRole(appId, roleHeader)
|
await getRole(roleHeader)
|
||||||
roleId = roleHeader
|
roleId = roleHeader
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Swallow error and do nothing
|
// Swallow error and do nothing
|
||||||
|
|
Loading…
Reference in New Issue