Merge branch 'master' into fix/automations-ux
This commit is contained in:
commit
0574fc74ef
|
@ -5,6 +5,7 @@
|
||||||
import { TableNames } from "constants"
|
import { TableNames } from "constants"
|
||||||
import { Grid } from "@budibase/frontend-core"
|
import { Grid } from "@budibase/frontend-core"
|
||||||
import { API } from "api"
|
import { API } from "api"
|
||||||
|
import GridCreateAutomationButton from "./buttons/grid/GridCreateAutomationButton.svelte"
|
||||||
import GridAddColumnModal from "components/backend/DataTable/modals/grid/GridCreateColumnModal.svelte"
|
import GridAddColumnModal from "components/backend/DataTable/modals/grid/GridCreateColumnModal.svelte"
|
||||||
import GridCreateEditRowModal from "components/backend/DataTable/modals/grid/GridCreateEditRowModal.svelte"
|
import GridCreateEditRowModal from "components/backend/DataTable/modals/grid/GridCreateEditRowModal.svelte"
|
||||||
import GridEditUserModal from "components/backend/DataTable/modals/grid/GridEditUserModal.svelte"
|
import GridEditUserModal from "components/backend/DataTable/modals/grid/GridEditUserModal.svelte"
|
||||||
|
@ -81,6 +82,9 @@
|
||||||
<GridCreateViewButton />
|
<GridCreateViewButton />
|
||||||
{/if}
|
{/if}
|
||||||
<GridManageAccessButton />
|
<GridManageAccessButton />
|
||||||
|
{#if !isUsersTable}
|
||||||
|
<GridCreateAutomationButton />
|
||||||
|
{/if}
|
||||||
{#if relationshipsEnabled}
|
{#if relationshipsEnabled}
|
||||||
<GridRelationshipButton />
|
<GridRelationshipButton />
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
@ -0,0 +1,101 @@
|
||||||
|
<script>
|
||||||
|
import {
|
||||||
|
ActionButton,
|
||||||
|
Popover,
|
||||||
|
Menu,
|
||||||
|
MenuItem,
|
||||||
|
notifications,
|
||||||
|
} from "@budibase/bbui"
|
||||||
|
import { getContext } from "svelte"
|
||||||
|
import { automationStore, tables, builderStore } from "stores/builder"
|
||||||
|
import { TriggerStepID } from "constants/backend/automations"
|
||||||
|
import { goto } from "@roxi/routify"
|
||||||
|
|
||||||
|
const { datasource } = getContext("grid")
|
||||||
|
|
||||||
|
$: triggers = $automationStore.blockDefinitions.TRIGGER
|
||||||
|
|
||||||
|
$: table = $tables.list.find(table => table._id === $datasource.tableId)
|
||||||
|
|
||||||
|
async function createAutomation(type) {
|
||||||
|
const triggerType = triggers[type]
|
||||||
|
if (!triggerType) {
|
||||||
|
console.error("Invalid trigger type", type)
|
||||||
|
notifications.error("Invalid automation trigger type")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!table) {
|
||||||
|
notifications.error("Invalid table, cannot create automation")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const automationName = `${table.name} : Row ${
|
||||||
|
type === TriggerStepID.ROW_SAVED ? "created" : "updated"
|
||||||
|
}`
|
||||||
|
const triggerBlock = automationStore.actions.constructBlock(
|
||||||
|
"TRIGGER",
|
||||||
|
triggerType.stepId,
|
||||||
|
triggerType
|
||||||
|
)
|
||||||
|
|
||||||
|
triggerBlock.inputs = { tableId: $datasource.tableId }
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await automationStore.actions.create(
|
||||||
|
automationName,
|
||||||
|
triggerBlock
|
||||||
|
)
|
||||||
|
builderStore.setPreviousTopNavPath(
|
||||||
|
"/builder/app/:application/data",
|
||||||
|
window.location.pathname
|
||||||
|
)
|
||||||
|
$goto(`/builder/app/${response.appId}/automation/${response.id}`)
|
||||||
|
notifications.success(`Automation created`)
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Error creating automation", e)
|
||||||
|
notifications.error("Error creating automation")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let anchor
|
||||||
|
let open
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div bind:this={anchor}>
|
||||||
|
<ActionButton
|
||||||
|
icon="MagicWand"
|
||||||
|
quiet
|
||||||
|
size="M"
|
||||||
|
on:click={() => (open = !open)}
|
||||||
|
selected={open}
|
||||||
|
>
|
||||||
|
Generate
|
||||||
|
</ActionButton>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Popover bind:open {anchor} align="left">
|
||||||
|
<Menu>
|
||||||
|
<MenuItem
|
||||||
|
icon="ShareAndroid"
|
||||||
|
on:click={() => {
|
||||||
|
open = false
|
||||||
|
createAutomation(TriggerStepID.ROW_SAVED)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Automation: when row is created
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem
|
||||||
|
icon="ShareAndroid"
|
||||||
|
on:click={() => {
|
||||||
|
open = false
|
||||||
|
createAutomation(TriggerStepID.ROW_UPDATED)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Automation: when row is updated
|
||||||
|
</MenuItem>
|
||||||
|
</Menu>
|
||||||
|
</Popover>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
</style>
|
File diff suppressed because one or more lines are too long
|
@ -26,7 +26,7 @@
|
||||||
"manifest": "ts-node ./scripts/gen-collection-info.ts"
|
"manifest": "ts-node ./scripts/gen-collection-info.ts"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@budibase/handlebars-helpers": "^0.13.1",
|
"@budibase/handlebars-helpers": "^0.13.2",
|
||||||
"dayjs": "^1.10.8",
|
"dayjs": "^1.10.8",
|
||||||
"handlebars": "^4.7.8",
|
"handlebars": "^4.7.8",
|
||||||
"lodash.clonedeep": "^4.5.0"
|
"lodash.clonedeep": "^4.5.0"
|
||||||
|
|
|
@ -907,6 +907,15 @@
|
||||||
"example": "{{uppercase 'aBcDef'}} -> ABCDEF",
|
"example": "{{uppercase 'aBcDef'}} -> ABCDEF",
|
||||||
"description": "<p>Uppercase all of the characters in the given string. If used as a block helper it will uppercase the entire block. This helper does not support inverse blocks.</p>\n",
|
"description": "<p>Uppercase all of the characters in the given string. If used as a block helper it will uppercase the entire block. This helper does not support inverse blocks.</p>\n",
|
||||||
"requiresBlock": false
|
"requiresBlock": false
|
||||||
|
},
|
||||||
|
"lorem": {
|
||||||
|
"args": [
|
||||||
|
"num"
|
||||||
|
],
|
||||||
|
"numArgs": 1,
|
||||||
|
"example": "{{lorem 11}} -> Lorem ipsum",
|
||||||
|
"description": "<p>Takes a number and returns that many charaters of Lorem Ipsum</p>\n",
|
||||||
|
"requiresBlock": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"comparison": {
|
"comparison": {
|
||||||
|
|
10
yarn.lock
10
yarn.lock
|
@ -2076,10 +2076,10 @@
|
||||||
tar-fs "2.1.1"
|
tar-fs "2.1.1"
|
||||||
uuid "^8.3.2"
|
uuid "^8.3.2"
|
||||||
|
|
||||||
"@budibase/handlebars-helpers@^0.13.1":
|
"@budibase/handlebars-helpers@^0.13.2":
|
||||||
version "0.13.1"
|
version "0.13.2"
|
||||||
resolved "https://registry.yarnpkg.com/@budibase/handlebars-helpers/-/handlebars-helpers-0.13.1.tgz#d02e73c0df8305cd675e70dc37f8427eb0842080"
|
resolved "https://registry.yarnpkg.com/@budibase/handlebars-helpers/-/handlebars-helpers-0.13.2.tgz#73ab51c464e91fd955b429017648e0257060db77"
|
||||||
integrity sha512-v4RbXhr3igvK3i2pj5cNltu/4NMxdPIzcUt/o0RoInhesNH1VSLRdweSFr6/Y34fsCR5jHZ6vltdcz2RgrTKgw==
|
integrity sha512-/IGqyDcjN9AhKSagCsqQRavpraQRjGeSZeMb62yJiK0b/9r47BjzcOeuQbfRhwK1NlL2cSExNcrkWSxisbPvJQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
get-object "^0.2.0"
|
get-object "^0.2.0"
|
||||||
get-value "^3.0.1"
|
get-value "^3.0.1"
|
||||||
|
@ -2146,7 +2146,7 @@
|
||||||
"@budibase/string-templates@2.23.12":
|
"@budibase/string-templates@2.23.12":
|
||||||
version "0.0.0"
|
version "0.0.0"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@budibase/handlebars-helpers" "^0.13.1"
|
"@budibase/handlebars-helpers" "^0.13.2"
|
||||||
dayjs "^1.10.8"
|
dayjs "^1.10.8"
|
||||||
handlebars "^4.7.8"
|
handlebars "^4.7.8"
|
||||||
lodash.clonedeep "^4.5.0"
|
lodash.clonedeep "^4.5.0"
|
||||||
|
|
Loading…
Reference in New Issue