Merge pull request #11401 from Budibase/plugin-improvements
Plugin improvements to allow block plugins
This commit is contained in:
commit
8bbfc751d3
|
@ -26,9 +26,9 @@
|
||||||
$: parentId = $component?.id
|
$: parentId = $component?.id
|
||||||
$: inBuilder = $builderStore.inBuilder
|
$: inBuilder = $builderStore.inBuilder
|
||||||
$: instance = {
|
$: instance = {
|
||||||
_component: `@budibase/standard-components/${type}`,
|
_component: getComponent(type),
|
||||||
_id: id,
|
_id: id,
|
||||||
_instanceName: name || type[0].toUpperCase() + type.slice(1),
|
_instanceName: getInstanceName(name, type),
|
||||||
_styles: {
|
_styles: {
|
||||||
...styles,
|
...styles,
|
||||||
normal: styles?.normal || {},
|
normal: styles?.normal || {},
|
||||||
|
@ -45,6 +45,30 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getComponent = type => {
|
||||||
|
if (!type) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
if (type.startsWith("plugin/")) {
|
||||||
|
return type
|
||||||
|
} else {
|
||||||
|
return `@budibase/standard-components/${type}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const getInstanceName = (name, type) => {
|
||||||
|
if (name) {
|
||||||
|
return name
|
||||||
|
}
|
||||||
|
if (!type) {
|
||||||
|
return "New component"
|
||||||
|
}
|
||||||
|
if (type.startsWith("plugin/")) {
|
||||||
|
type = type.split("plugin/")[1]
|
||||||
|
}
|
||||||
|
return type[0].toUpperCase() + type.slice(1)
|
||||||
|
}
|
||||||
|
|
||||||
onDestroy(() => {
|
onDestroy(() => {
|
||||||
if (inBuilder) {
|
if (inBuilder) {
|
||||||
block.unregisterComponent(id, parentId)
|
block.unregisterComponent(id, parentId)
|
||||||
|
|
|
@ -18,6 +18,8 @@ import { styleable } from "utils/styleable"
|
||||||
import { linkable } from "utils/linkable"
|
import { linkable } from "utils/linkable"
|
||||||
import { getAction } from "utils/getAction"
|
import { getAction } from "utils/getAction"
|
||||||
import Provider from "components/context/Provider.svelte"
|
import Provider from "components/context/Provider.svelte"
|
||||||
|
import Block from "components/Block.svelte"
|
||||||
|
import BlockComponent from "components/BlockComponent.svelte"
|
||||||
import { ActionTypes } from "./constants"
|
import { ActionTypes } from "./constants"
|
||||||
import { fetchDatasourceSchema } from "./utils/schema.js"
|
import { fetchDatasourceSchema } from "./utils/schema.js"
|
||||||
import { getAPIKey } from "./utils/api.js"
|
import { getAPIKey } from "./utils/api.js"
|
||||||
|
@ -44,4 +46,6 @@ export default {
|
||||||
Provider,
|
Provider,
|
||||||
ActionTypes,
|
ActionTypes,
|
||||||
getAPIKey,
|
getAPIKey,
|
||||||
|
Block,
|
||||||
|
BlockComponent,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue