Misc fixes (#9383)

* Shrink cloud upgrade button to proper size

* Add brackets to fix operator precedence when ejecting blocks to prevent undefined custom CSS

* Prevent relationship fields in forms from being used as datasources

* Remove extraneous navigation when adding a component which caused next navigation to fail

* Improve form logic concerning when to fully remount itself to fix issues with stale schema being passed in
This commit is contained in:
Andrew Kingston 2023-01-19 09:47:10 +00:00 committed by GitHub
parent 62cdb3962d
commit a3e555c85e
6 changed files with 22 additions and 9 deletions

View File

@ -378,6 +378,7 @@ const getProviderContextBindings = (asset, dataProviders) => {
providerId, providerId,
// Table ID is used by JSON fields to know what table the field is in // Table ID is used by JSON fields to know what table the field is in
tableId: table?._id, tableId: table?._id,
component: component._component,
category: component._instanceName, category: component._instanceName,
icon: def.icon, icon: def.icon,
display: { display: {

View File

@ -70,7 +70,10 @@
type: "provider", type: "provider",
})) }))
$: links = bindings $: links = bindings
// Get only link bindings
.filter(x => x.fieldSchema?.type === "link") .filter(x => x.fieldSchema?.type === "link")
// Filter out bindings provided by forms
.filter(x => !x.component?.endsWith("/form"))
.map(binding => { .map(binding => {
const { providerId, readableBinding, fieldSchema } = binding || {} const { providerId, readableBinding, fieldSchema } = binding || {}
const { name, tableId } = fieldSchema || {} const { name, tableId } = fieldSchema || {}

View File

@ -176,7 +176,6 @@
const addComponent = async component => { const addComponent = async component => {
try { try {
await store.actions.components.create(component) await store.actions.components.create(component)
$goto("../")
} catch (error) { } catch (error) {
notifications.error(error || "Error creating component") notifications.error(error || "Error creating component")
} }

View File

@ -7,6 +7,7 @@
{#if $admin.cloud && $auth?.user?.accountPortalAccess} {#if $admin.cloud && $auth?.user?.accountPortalAccess}
<Button <Button
cta cta
size="S"
on:click on:click
on:click={() => { on:click={() => {
$goto($admin.accountPortalUrl + "/portal/upgrade") $goto($admin.accountPortalUrl + "/portal/upgrade")

View File

@ -38,7 +38,7 @@
...$component.styles?.normal, ...$component.styles?.normal,
}, },
custom: custom:
definition._styles?.custom || "" + $component.styles?.custom || "", (definition._styles?.custom || "") + ($component.styles?.custom || ""),
} }
// Create component tree // Create component tree

View File

@ -24,6 +24,11 @@
let table let table
$: fetchSchema(dataSource) $: fetchSchema(dataSource)
$: schemaKey = generateSchemaKey(schema)
$: initialValues = getInitialValues(actionType, dataSource, $context)
$: resetKey = Helpers.hashString(
schemaKey + JSON.stringify(initialValues) + disabled
)
// Returns the closes data context which isn't a built in context // Returns the closes data context which isn't a built in context
const getInitialValues = (type, dataSource, context) => { const getInitialValues = (type, dataSource, context) => {
@ -57,13 +62,17 @@
schema = res || {} schema = res || {}
} }
$: initialValues = getInitialValues(actionType, dataSource, $context) // Generates a predictable string that uniquely identifies a schema. We can't
$: resetKey = Helpers.hashString( // simply stringify the whole schema as there are array fields which have
!!schema + // random order.
JSON.stringify(initialValues) + const generateSchemaKey = schema => {
JSON.stringify(dataSource) + if (!schema) {
disabled return null
) }
const fields = Object.keys(schema)
fields.sort()
return fields.map(field => `${field}:${schema[field].type}`).join("-")
}
</script> </script>
{#key resetKey} {#key resetKey}