Merge branch 'master' into isolated-vm
This commit is contained in:
commit
a65892d29b
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"version": "2.15.1",
|
||||
"version": "2.15.5",
|
||||
"npmClient": "yarn",
|
||||
"packages": [
|
||||
"packages/*",
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 11469c40d73ea58f2aec80c12c1946289b67c6f2
|
||||
Subproject commit 05c90ce55144e260da6688335c16783eab79bf96
|
|
@ -184,8 +184,9 @@
|
|||
}
|
||||
|
||||
if (
|
||||
(idx === 0 && automation.trigger?.event === "row:update") ||
|
||||
automation.trigger?.event === "row:save"
|
||||
idx === 0 &&
|
||||
(automation.trigger?.event === "row:update" ||
|
||||
automation.trigger?.event === "row:save")
|
||||
) {
|
||||
if (name !== "id" && name !== "revision") return `trigger.row.${name}`
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
Icon,
|
||||
} from "@budibase/bbui"
|
||||
import { capitalise } from "helpers"
|
||||
import { getFormattedPlanName } from "helpers/planTitle"
|
||||
import { get } from "svelte/store"
|
||||
|
||||
export let resourceId
|
||||
|
@ -99,7 +100,9 @@
|
|||
{#if requiresPlanToModify}
|
||||
<span class="lock-tag">
|
||||
<Tags>
|
||||
<Tag icon="LockClosed">{capitalise(requiresPlanToModify)}</Tag>
|
||||
<Tag icon="LockClosed"
|
||||
>{getFormattedPlanName(requiresPlanToModify)}</Tag
|
||||
>
|
||||
</Tags>
|
||||
</span>
|
||||
{/if}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
import { PlanType } from "@budibase/types"
|
||||
|
||||
export function getFormattedPlanName(userPlanType) {
|
||||
let planName = "Free"
|
||||
if (userPlanType === PlanType.PREMIUM_PLUS) {
|
||||
planName = "Premium"
|
||||
} else if (userPlanType === PlanType.ENTERPRISE_BASIC) {
|
||||
planName = "Enterprise"
|
||||
}
|
||||
return `${planName} Plan`
|
||||
}
|
|
@ -15,9 +15,9 @@
|
|||
<Content showMobileNav>
|
||||
<SideNav slot="side-nav">
|
||||
<SideNavItem
|
||||
text="Automation History"
|
||||
url={$url("./automation-history")}
|
||||
active={$isActive("./automation-history")}
|
||||
text="Automations"
|
||||
url={$url("./automations")}
|
||||
active={$isActive("./automations")}
|
||||
/>
|
||||
<SideNavItem
|
||||
text="Backups"
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
Body,
|
||||
Heading,
|
||||
Divider,
|
||||
Toggle,
|
||||
notifications,
|
||||
} from "@budibase/bbui"
|
||||
import DateTimeRenderer from "components/common/renderers/DateTimeRenderer.svelte"
|
||||
import StatusRenderer from "./_components/StatusRenderer.svelte"
|
||||
|
@ -16,7 +18,7 @@
|
|||
import { createPaginationStore } from "helpers/pagination"
|
||||
import { getContext, onDestroy, onMount } from "svelte"
|
||||
import dayjs from "dayjs"
|
||||
import { auth, licensing, admin } from "stores/portal"
|
||||
import { auth, licensing, admin, apps } from "stores/portal"
|
||||
import { Constants } from "@budibase/frontend-core"
|
||||
import Portal from "svelte-portal"
|
||||
|
||||
|
@ -35,9 +37,13 @@
|
|||
let timeRange = null
|
||||
let loaded = false
|
||||
|
||||
$: app = $apps.find(app => app.devId === $store.appId?.includes(app.appId))
|
||||
$: licensePlan = $auth.user?.license?.plan
|
||||
$: page = $pageInfo.page
|
||||
$: fetchLogs(automationId, status, page, timeRange)
|
||||
$: isCloud = $admin.cloud
|
||||
|
||||
$: chainAutomations = app?.automations?.chainAutomations ?? !isCloud
|
||||
|
||||
const timeOptions = [
|
||||
{ value: "90-d", label: "Past 90 days" },
|
||||
|
@ -124,6 +130,18 @@
|
|||
sidePanel.open()
|
||||
}
|
||||
|
||||
async function save({ detail }) {
|
||||
try {
|
||||
await apps.update($store.appId, {
|
||||
automations: {
|
||||
chainAutomations: detail,
|
||||
},
|
||||
})
|
||||
} catch (error) {
|
||||
notifications.error("Error updating automation chaining setting")
|
||||
}
|
||||
}
|
||||
|
||||
onMount(async () => {
|
||||
await automationStore.actions.fetch()
|
||||
const params = new URLSearchParams(window.location.search)
|
||||
|
@ -150,11 +168,30 @@
|
|||
|
||||
<Layout noPadding>
|
||||
<Layout gap="XS" noPadding>
|
||||
<Heading>Automation History</Heading>
|
||||
<Body>View the automations your app has executed</Body>
|
||||
<Heading>Automations</Heading>
|
||||
<Body size="S">See your automation history and edit advanced settings</Body>
|
||||
</Layout>
|
||||
<Divider />
|
||||
|
||||
<Layout gap="XS" noPadding>
|
||||
<Heading size="XS">Chain automations</Heading>
|
||||
<Body size="S">Allow automations to trigger from other automations</Body>
|
||||
<div class="setting-spacing">
|
||||
<Toggle
|
||||
text={"Enable chaining"}
|
||||
on:change={e => {
|
||||
save(e)
|
||||
}}
|
||||
value={chainAutomations}
|
||||
/>
|
||||
</div>
|
||||
</Layout>
|
||||
|
||||
<Divider />
|
||||
<Layout gap="XS" noPadding>
|
||||
<Heading size="XS">History</Heading>
|
||||
<Body size="S">Free plan stores up to 1 day of automation history</Body>
|
||||
</Layout>
|
||||
<div class="controls">
|
||||
<div class="search">
|
||||
<div class="select">
|
||||
|
@ -237,6 +274,9 @@
|
|||
{/if}
|
||||
|
||||
<style>
|
||||
.setting-spacing {
|
||||
padding-top: var(--spacing-s);
|
||||
}
|
||||
.controls {
|
||||
display: flex;
|
||||
flex-direction: row;
|
|
@ -1,5 +1,5 @@
|
|||
<script>
|
||||
import { redirect } from "@roxi/routify"
|
||||
|
||||
$redirect("../settings/automation-history")
|
||||
$redirect("../settings/automations")
|
||||
</script>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
import { DashCard, Usage } from "components/usage"
|
||||
import { PlanModel } from "constants"
|
||||
import { sdk } from "@budibase/shared-core"
|
||||
import { PlanType } from "@budibase/types"
|
||||
import { getFormattedPlanName } from "helpers/planTitle"
|
||||
|
||||
let staticUsage = []
|
||||
let monthlyUsage = []
|
||||
|
@ -100,23 +100,6 @@
|
|||
cancelAt = license?.billing?.subscription?.cancelAt
|
||||
}
|
||||
|
||||
const capitalise = string => {
|
||||
if (string) {
|
||||
return string.charAt(0).toUpperCase() + string.slice(1)
|
||||
}
|
||||
}
|
||||
|
||||
const planTitle = () => {
|
||||
const planType = license?.plan.type
|
||||
let planName = license?.plan.type
|
||||
if (planType === PlanType.PREMIUM_PLUS) {
|
||||
planName = "Premium"
|
||||
} else if (planType === PlanType.ENTERPRISE_BASIC) {
|
||||
planName = "Enterprise"
|
||||
}
|
||||
return `${capitalise(planName)} Plan`
|
||||
}
|
||||
|
||||
const getDaysRemaining = timestamp => {
|
||||
if (!timestamp) {
|
||||
return
|
||||
|
@ -227,7 +210,7 @@
|
|||
|
||||
<DashCard
|
||||
description="YOUR CURRENT PLAN"
|
||||
title={planTitle()}
|
||||
title={getFormattedPlanName(license?.plan.type)}
|
||||
{primaryActionText}
|
||||
primaryAction={showButton ? goToAccountPortal : undefined}
|
||||
{textRows}
|
||||
|
|
|
@ -6098,23 +6098,6 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "style",
|
||||
"type": "select",
|
||||
"label": "Size",
|
||||
"key": "size",
|
||||
"options": [
|
||||
{
|
||||
"label": "Medium",
|
||||
"value": "spectrum--medium"
|
||||
},
|
||||
{
|
||||
"label": "Large",
|
||||
"value": "spectrum--large"
|
||||
}
|
||||
],
|
||||
"defaultValue": "spectrum--medium"
|
||||
},
|
||||
{
|
||||
"tag": "style",
|
||||
"type": "select",
|
||||
|
@ -6131,6 +6114,23 @@
|
|||
}
|
||||
],
|
||||
"defaultValue": "bottom"
|
||||
},
|
||||
{
|
||||
"tag": "style",
|
||||
"type": "select",
|
||||
"label": "Size",
|
||||
"key": "size",
|
||||
"options": [
|
||||
{
|
||||
"label": "Medium",
|
||||
"value": "spectrum--medium"
|
||||
},
|
||||
{
|
||||
"label": "Large",
|
||||
"value": "spectrum--large"
|
||||
}
|
||||
],
|
||||
"defaultValue": "spectrum--medium"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
type,
|
||||
quiet,
|
||||
disabled,
|
||||
size,
|
||||
size: size || "M",
|
||||
}}
|
||||
/>
|
||||
{/each}
|
||||
|
|
|
@ -108,8 +108,16 @@
|
|||
}
|
||||
}
|
||||
|
||||
$: forceFetchRows(filter)
|
||||
$: debouncedFetchRows(searchTerm, primaryDisplay, defaultValue)
|
||||
|
||||
const forceFetchRows = async () => {
|
||||
// if the filter has changed, then we need to reset the options, clear the selection, and re-fetch
|
||||
optionsObj = {}
|
||||
fieldApi.setValue([])
|
||||
selectedValue = []
|
||||
debouncedFetchRows(searchTerm, primaryDisplay, defaultValue)
|
||||
}
|
||||
const fetchRows = async (searchTerm, primaryDisplay, defaultVal) => {
|
||||
const allRowsFetched =
|
||||
$fetch.loaded &&
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 31f11bcd3323d2105a83ebfdee8facc2900bb879
|
||||
Subproject commit ce7722ed4474718596b465dcfd49bef36cab2e42
|
|
@ -9,8 +9,11 @@ import {
|
|||
CreateDatasourceResponse,
|
||||
Datasource,
|
||||
DatasourcePlus,
|
||||
Document,
|
||||
FetchDatasourceInfoRequest,
|
||||
FetchDatasourceInfoResponse,
|
||||
FieldType,
|
||||
RelationshipFieldMetadata,
|
||||
SourceName,
|
||||
UpdateDatasourceResponse,
|
||||
UserCtx,
|
||||
|
@ -218,9 +221,26 @@ async function destroyInternalTablesBySourceId(datasourceId: string) {
|
|||
[]
|
||||
)
|
||||
|
||||
function updateRevisions(deletedLinks: RelationshipFieldMetadata[]) {
|
||||
for (const link of deletedLinks) {
|
||||
datasourceTableDocs.forEach((doc: Document) => {
|
||||
if (doc._id === link.tableId) {
|
||||
doc._rev = link.tableRev
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Destroy the tables.
|
||||
for (const table of datasourceTableDocs) {
|
||||
await sdk.tables.internal.destroy(table)
|
||||
const deleted = await sdk.tables.internal.destroy(table)
|
||||
// Update the revisions of any tables that remain to be deleted
|
||||
const deletedLinks: RelationshipFieldMetadata[] = Object.values(
|
||||
deleted.table.schema
|
||||
)
|
||||
.filter(field => field.type === FieldType.LINK)
|
||||
.map(field => field as RelationshipFieldMetadata)
|
||||
updateRevisions(deletedLinks)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ export const employeeImport = [
|
|||
type: "row",
|
||||
"Employee Level": ["Senior"],
|
||||
"Start Date": "2015-02-12T12:00:00.000",
|
||||
"Badge Photo": [],
|
||||
},
|
||||
{
|
||||
"First Name": "Mandy",
|
||||
|
@ -28,6 +29,7 @@ export const employeeImport = [
|
|||
type: "row",
|
||||
"Employee Level": ["Senior"],
|
||||
"Start Date": "2017-09-10T12:00:00.000",
|
||||
"Badge Photo": [],
|
||||
},
|
||||
{
|
||||
"First Name": "Holly",
|
||||
|
@ -43,6 +45,7 @@ export const employeeImport = [
|
|||
type: "row",
|
||||
"Employee Level": ["Senior"],
|
||||
"Start Date": "2022-02-12T12:00:00.000",
|
||||
"Badge Photo": [],
|
||||
},
|
||||
{
|
||||
"First Name": "Francis",
|
||||
|
@ -58,6 +61,7 @@ export const employeeImport = [
|
|||
type: "row",
|
||||
"Employee Level": ["Apprentice"],
|
||||
"Start Date": "2021-03-10T12:00:00.000",
|
||||
"Badge Photo": [],
|
||||
},
|
||||
{
|
||||
"First Name": "Richard",
|
||||
|
@ -73,6 +77,7 @@ export const employeeImport = [
|
|||
type: "row",
|
||||
"Employee Level": ["Apprentice"],
|
||||
"Start Date": "2020-07-09T12:00:00.000",
|
||||
"Badge Photo": [],
|
||||
},
|
||||
{
|
||||
"First Name": "Donald",
|
||||
|
@ -88,6 +93,7 @@ export const employeeImport = [
|
|||
type: "row",
|
||||
"Employee Level": ["Junior"],
|
||||
"Start Date": "2018-04-13T12:00:00.000",
|
||||
"Badge Photo": [],
|
||||
},
|
||||
{
|
||||
"First Name": "Maria",
|
||||
|
@ -103,6 +109,7 @@ export const employeeImport = [
|
|||
type: "row",
|
||||
"Employee Level": ["Manager"],
|
||||
"Start Date": "2016-05-22T12:00:00.000",
|
||||
"Badge Photo": [],
|
||||
},
|
||||
{
|
||||
"First Name": "Suzy",
|
||||
|
@ -118,6 +125,7 @@ export const employeeImport = [
|
|||
type: "row",
|
||||
"Employee Level": ["Senior", "Manager"],
|
||||
"Start Date": "2019-05-01T12:00:00.000",
|
||||
"Badge Photo": [],
|
||||
},
|
||||
{
|
||||
"First Name": "Patrick",
|
||||
|
@ -133,6 +141,7 @@ export const employeeImport = [
|
|||
type: "row",
|
||||
"Employee Level": ["Apprentice"],
|
||||
"Start Date": "2014-08-30T12:00:00.000",
|
||||
"Badge Photo": [],
|
||||
},
|
||||
{
|
||||
"First Name": "Brayden",
|
||||
|
@ -148,5 +157,6 @@ export const employeeImport = [
|
|||
type: "row",
|
||||
"Employee Level": ["Contractor"],
|
||||
"Start Date": "2022-11-09T12:00:00.000",
|
||||
"Badge Photo": [],
|
||||
},
|
||||
]
|
||||
|
|
|
@ -440,7 +440,7 @@ class LinkController {
|
|||
if (field.type === FieldTypes.LINK && field.fieldName) {
|
||||
const linkedTable = await this._db.get<Table>(field.tableId)
|
||||
delete linkedTable.schema[field.fieldName]
|
||||
await this._db.put(linkedTable)
|
||||
field.tableRev = (await this._db.put(linkedTable)).rev
|
||||
}
|
||||
} catch (err: any) {
|
||||
logging.logWarn(err?.message, err)
|
||||
|
|
|
@ -1,18 +1,11 @@
|
|||
import { rowEmission, tableEmission } from "./utils"
|
||||
import mainEmitter from "./index"
|
||||
import env from "../environment"
|
||||
import { Table, Row } from "@budibase/types"
|
||||
import { Table, Row, DocumentType, App } from "@budibase/types"
|
||||
import { context } from "@budibase/backend-core"
|
||||
|
||||
// max number of automations that can chain on top of each other
|
||||
// TODO: in future make this configurable at the automation level
|
||||
const MAX_AUTOMATION_CHAIN = env.SELF_HOSTED ? 5 : 0
|
||||
const MAX_AUTOMATIONS_ALLOWED = 5
|
||||
|
||||
/**
|
||||
* Special emitter which takes the count of automation runs which have occurred and blocks an
|
||||
* automation from running if it has reached the maximum number of chained automations runs.
|
||||
* This essentially "fakes" the normal emitter to add some functionality in-between to stop automations
|
||||
* from getting stuck endlessly chaining.
|
||||
*/
|
||||
class AutomationEmitter {
|
||||
chainCount: number
|
||||
metadata: { automationChainCount: number }
|
||||
|
@ -24,7 +17,23 @@ class AutomationEmitter {
|
|||
}
|
||||
}
|
||||
|
||||
emitRow(eventName: string, appId: string, row: Row, table?: Table) {
|
||||
async getMaxAutomationChain() {
|
||||
const db = context.getAppDB()
|
||||
const appMetadata = await db.get<App>(DocumentType.APP_METADATA)
|
||||
let chainAutomations = appMetadata?.automations?.chainAutomations
|
||||
|
||||
if (chainAutomations === true) {
|
||||
return MAX_AUTOMATIONS_ALLOWED
|
||||
} else if (chainAutomations === undefined && env.SELF_HOSTED) {
|
||||
return MAX_AUTOMATIONS_ALLOWED
|
||||
} else {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
async emitRow(eventName: string, appId: string, row: Row, table?: Table) {
|
||||
let MAX_AUTOMATION_CHAIN = await this.getMaxAutomationChain()
|
||||
|
||||
// don't emit even if we've reached max automation chain
|
||||
if (this.chainCount >= MAX_AUTOMATION_CHAIN) {
|
||||
return
|
||||
|
@ -39,9 +48,11 @@ class AutomationEmitter {
|
|||
})
|
||||
}
|
||||
|
||||
emitTable(eventName: string, appId: string, table?: Table) {
|
||||
async emitTable(eventName: string, appId: string, table?: Table) {
|
||||
let MAX_AUTOMATION_CHAIN = await this.getMaxAutomationChain()
|
||||
|
||||
// don't emit even if we've reached max automation chain
|
||||
if (this.chainCount > MAX_AUTOMATION_CHAIN) {
|
||||
if (this.chainCount >= MAX_AUTOMATION_CHAIN) {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ export async function getInheritablePermissions(
|
|||
export async function allowsExplicitPermissions(resourceId: string) {
|
||||
if (isViewID(resourceId)) {
|
||||
const allowed = await features.isViewPermissionEnabled()
|
||||
const minPlan = !allowed ? PlanType.BUSINESS : undefined
|
||||
const minPlan = !allowed ? PlanType.PREMIUM_PLUS : undefined
|
||||
|
||||
return {
|
||||
allowed,
|
||||
|
|
|
@ -94,7 +94,7 @@ export async function setTestFlag(id: string) {
|
|||
}
|
||||
|
||||
export async function checkTestFlag(id: string) {
|
||||
const flag = await flagClient.get(id)
|
||||
const flag = await flagClient?.get(id)
|
||||
return !!(flag && flag.testing)
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,9 @@ async function checkResponse(
|
|||
let error
|
||||
try {
|
||||
error = await response.json()
|
||||
if (!error.message) {
|
||||
error = JSON.stringify(error)
|
||||
}
|
||||
} catch (err) {
|
||||
error = await response.text()
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ export interface App extends Document {
|
|||
automationErrors?: AppMetadataErrors
|
||||
icon?: AppIcon
|
||||
features?: AppFeatures
|
||||
automations?: AutomationSettings
|
||||
}
|
||||
|
||||
export interface AppInstance {
|
||||
|
@ -68,3 +69,7 @@ export interface AppFeatures {
|
|||
componentValidation?: boolean
|
||||
disableUserMetadata?: boolean
|
||||
}
|
||||
|
||||
export interface AutomationSettings {
|
||||
chainAutomations?: boolean
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ interface BaseRelationshipFieldMetadata
|
|||
main?: boolean
|
||||
fieldName: string
|
||||
tableId: string
|
||||
tableRev?: string
|
||||
subtype?: AutoFieldSubTypes.CREATED_BY | AutoFieldSubTypes.UPDATED_BY
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue