Tweak styling of new component, add deprecation warning to old component.

This commit is contained in:
Sam Rose 2025-01-15 12:24:33 +00:00
parent 96869c2b4d
commit 6dafe79e67
No known key found for this signature in database
9 changed files with 68 additions and 70 deletions

View File

@ -6,6 +6,7 @@
export let icon = "" export let icon = ""
export let avatar = "" export let avatar = ""
export let invalid = false export let invalid = false
export let emphasized = false
export let disabled = false export let disabled = false
export let closable = false export let closable = false
</script> </script>
@ -13,6 +14,7 @@
<div <div
class:is-invalid={invalid} class:is-invalid={invalid}
class:is-disabled={disabled} class:is-disabled={disabled}
class:is-emphasized={emphasized}
class="spectrum-Tags-item" class="spectrum-Tags-item"
role="listitem" role="listitem"
> >
@ -40,4 +42,9 @@
margin-bottom: 0; margin-bottom: 0;
margin-top: 0; margin-top: 0;
} }
.is-emphasized {
border-color: var(--spectrum-global-color-blue-700);
color: var(--spectrum-global-color-blue-700);
}
</style> </style>

View File

@ -23,9 +23,8 @@
let collectBlockAllowedSteps = [TriggerStepID.APP, TriggerStepID.WEBHOOK] let collectBlockAllowedSteps = [TriggerStepID.APP, TriggerStepID.WEBHOOK]
let selectedAction let selectedAction
let actions = Object.entries($automationStore.blockDefinitions.ACTION).filter( let actions = Object.entries($automationStore.blockDefinitions.ACTION).filter(
entry => { ([key, action]) => {
const [key] = entry return key !== AutomationActionStepId.BRANCH && action.deprecated !== true
return key !== AutomationActionStepId.BRANCH
} }
) )
let lockedFeatures = [ let lockedFeatures = [
@ -187,11 +186,9 @@
{:else if isDisabled} {:else if isDisabled}
<Icon name="Help" tooltip={disabled()[idx].message} /> <Icon name="Help" tooltip={disabled()[idx].message} />
{:else if action.new} {:else if action.new}
<div class="tag-color"> <Tags>
<Tags> <Tag emphasized>New</Tag>
<Tag>New</Tag> </Tags>
</Tags>
</div>
{/if} {/if}
</div> </div>
</div> </div>
@ -233,6 +230,10 @@
grid-gap: var(--spectrum-alias-grid-baseline); grid-gap: var(--spectrum-alias-grid-baseline);
} }
.item :global(.spectrum-Tags-itemLabel) {
cursor: pointer;
}
.item { .item {
cursor: pointer; cursor: pointer;
grid-gap: var(--spectrum-alias-grid-margin-xsmall); grid-gap: var(--spectrum-alias-grid-margin-xsmall);
@ -243,6 +244,8 @@
border-radius: 5px; border-radius: 5px;
box-sizing: border-box; box-sizing: border-box;
border-width: 2px; border-width: 2px;
min-height: 3.5rem;
display: flex;
} }
.item:not(.disabled):hover, .item:not(.disabled):hover,
.selected { .selected {

View File

@ -1,6 +1,13 @@
<script> <script>
import { automationStore, selectedAutomation } from "@/stores/builder" import { automationStore, selectedAutomation } from "@/stores/builder"
import { Icon, Body, AbsTooltip, StatusLight } from "@budibase/bbui" import {
Icon,
Body,
AbsTooltip,
StatusLight,
Tags,
Tag,
} from "@budibase/bbui"
import { externalActions } from "./ExternalActions" import { externalActions } from "./ExternalActions"
import { createEventDispatcher } from "svelte" import { createEventDispatcher } from "svelte"
import { Features } from "@/constants/backend/automations" import { Features } from "@/constants/backend/automations"
@ -24,6 +31,7 @@
$: blockRefs = $selectedAutomation?.blockRefs || {} $: blockRefs = $selectedAutomation?.blockRefs || {}
$: stepNames = automation?.definition.stepNames || {} $: stepNames = automation?.definition.stepNames || {}
$: allSteps = automation?.definition.steps || [] $: allSteps = automation?.definition.steps || []
$: blockDefinition = $automationStore.blockDefinitions.ACTION[block.stepId]
$: automationName = itemName || stepNames?.[block.id] || block?.name || "" $: automationName = itemName || stepNames?.[block.id] || block?.name || ""
$: automationNameError = getAutomationNameError(automationName) $: automationNameError = getAutomationNameError(automationName)
$: status = updateStatus(testResult) $: status = updateStatus(testResult)
@ -135,7 +143,16 @@
{#if isHeaderTrigger} {#if isHeaderTrigger}
<Body size="XS"><b>Trigger</b></Body> <Body size="XS"><b>Trigger</b></Body>
{:else} {:else}
<Body size="XS"><b>{isBranch ? "Branch" : "Step"}</b></Body> <Body size="XS">
<div style="display: flex; gap: 0.5rem; align-items: center;">
<b>{isBranch ? "Branch" : "Step"}</b>
{#if blockDefinition.deprecated}
<Tags>
<Tag invalid>Deprecated</Tag>
</Tags>
{/if}
</div>
</Body>
{/if} {/if}
{#if enableNaming} {#if enableNaming}

View File

@ -30,6 +30,8 @@ import {
AutomationTriggerSchema, AutomationTriggerSchema,
BranchPath, BranchPath,
BlockDefinitions, BlockDefinitions,
GetAutomationTriggerDefinitionsResponse,
GetAutomationActionDefinitionsResponse,
} from "@budibase/types" } from "@budibase/types"
import { ActionStepID } from "@/constants/backend/automations" import { ActionStepID } from "@/constants/backend/automations"
import { FIELDS } from "@/constants/backend" import { FIELDS } from "@/constants/backend"
@ -65,16 +67,19 @@ const initialAutomationState: AutomationState = {
} }
const getFinalDefinitions = ( const getFinalDefinitions = (
triggers: Record<string, any>, triggers: GetAutomationTriggerDefinitionsResponse,
actions: Record<string, any> actions: GetAutomationActionDefinitionsResponse
): BlockDefinitions => { ): BlockDefinitions => {
const creatable: Record<string, any> = {} const creatable: Partial<GetAutomationTriggerDefinitionsResponse> = {}
Object.entries(triggers).forEach(entry => { for (const [key, trigger] of Object.entries(triggers)) {
if (entry[0] === AutomationTriggerStepId.ROW_ACTION) { if (key === AutomationTriggerStepId.ROW_ACTION) {
return continue
} }
creatable[entry[0]] = entry[1] if (trigger.deprecated === true) {
}) continue
}
creatable[key as keyof GetAutomationTriggerDefinitionsResponse] = trigger
}
return { return {
TRIGGER: triggers, TRIGGER: triggers,
CREATABLE_TRIGGER: creatable, CREATABLE_TRIGGER: creatable,

View File

@ -1,7 +1,7 @@
import * as triggers from "../../automations/triggers" import * as triggers from "../../automations/triggers"
import { sdk as coreSdk } from "@budibase/shared-core" import { sdk as coreSdk } from "@budibase/shared-core"
import { DocumentType } from "../../db/utils" import { DocumentType } from "../../db/utils"
import { updateTestHistory, removeDeprecated } from "../../automations/utils" import { updateTestHistory } from "../../automations/utils"
import { setTestFlag, clearTestFlag } from "../../utilities/redis" import { setTestFlag, clearTestFlag } from "../../utilities/redis"
import { context, cache, events, db as dbCore } from "@budibase/backend-core" import { context, cache, events, db as dbCore } from "@budibase/backend-core"
import { automations, features } from "@budibase/pro" import { automations, features } from "@budibase/pro"
@ -34,14 +34,6 @@ import sdk from "../../sdk"
import { builderSocket } from "../../websockets" import { builderSocket } from "../../websockets"
import env from "../../environment" import env from "../../environment"
async function getActionDefinitions() {
return removeDeprecated(await actionDefs())
}
function getTriggerDefinitions() {
return removeDeprecated(triggers.TRIGGER_DEFINITIONS)
}
/************************* /*************************
* * * *
* BUILDER FUNCTIONS * * BUILDER FUNCTIONS *
@ -141,21 +133,21 @@ export async function clearLogError(
export async function getActionList( export async function getActionList(
ctx: UserCtx<void, GetAutomationActionDefinitionsResponse> ctx: UserCtx<void, GetAutomationActionDefinitionsResponse>
) { ) {
ctx.body = await getActionDefinitions() ctx.body = await actionDefs()
} }
export async function getTriggerList( export async function getTriggerList(
ctx: UserCtx<void, GetAutomationTriggerDefinitionsResponse> ctx: UserCtx<void, GetAutomationTriggerDefinitionsResponse>
) { ) {
ctx.body = getTriggerDefinitions() ctx.body = triggers.TRIGGER_DEFINITIONS
} }
export async function getDefinitionList( export async function getDefinitionList(
ctx: UserCtx<void, GetAutomationStepDefinitionsResponse> ctx: UserCtx<void, GetAutomationStepDefinitionsResponse>
) { ) {
ctx.body = { ctx.body = {
trigger: getTriggerDefinitions(), trigger: triggers.TRIGGER_DEFINITIONS,
action: await getActionDefinitions(), action: await actionDefs(),
} }
} }

View File

@ -20,7 +20,6 @@ import {
} from "@budibase/types" } from "@budibase/types"
import { mocks } from "@budibase/backend-core/tests" import { mocks } from "@budibase/backend-core/tests"
import { FilterConditions } from "../../../automations/steps/filter" import { FilterConditions } from "../../../automations/steps/filter"
import { removeDeprecated } from "../../../automations/utils"
import { createAutomationBuilder } from "../../../automations/tests/utilities/AutomationTestBuilder" import { createAutomationBuilder } from "../../../automations/tests/utilities/AutomationTestBuilder"
const MAX_RETRIES = 4 const MAX_RETRIES = 4
@ -76,15 +75,11 @@ describe("/automations", () => {
.expect("Content-Type", /json/) .expect("Content-Type", /json/)
.expect(200) .expect(200)
let definitionsLength = Object.keys(
removeDeprecated(BUILTIN_ACTION_DEFINITIONS)
).length
expect(Object.keys(res.body.action).length).toBeGreaterThanOrEqual( expect(Object.keys(res.body.action).length).toBeGreaterThanOrEqual(
definitionsLength Object.keys(BUILTIN_ACTION_DEFINITIONS).length
) )
expect(Object.keys(res.body.trigger).length).toEqual( expect(Object.keys(res.body.trigger).length).toEqual(
Object.keys(removeDeprecated(TRIGGER_DEFINITIONS)).length Object.keys(TRIGGER_DEFINITIONS).length
) )
}) })
}) })

View File

@ -12,9 +12,9 @@ import {
import { processStringSync } from "@budibase/string-templates" import { processStringSync } from "@budibase/string-templates"
export const definition: AutomationStepDefinition = { export const definition: AutomationStepDefinition = {
name: "JS Scripting", name: "JavaScript",
tagline: "Execute JavaScript Code", tagline: "Execute JavaScript Code",
icon: "Code", icon: "Brackets",
description: "Run a piece of JavaScript code in your automation", description: "Run a piece of JavaScript code in your automation",
type: AutomationStepType.ACTION, type: AutomationStepType.ACTION,
internal: true, internal: true,

View File

@ -4,17 +4,8 @@ import { automationQueue } from "./bullboard"
import { updateEntityMetadata } from "../utilities" import { updateEntityMetadata } from "../utilities"
import { context, db as dbCore, utils } from "@budibase/backend-core" import { context, db as dbCore, utils } from "@budibase/backend-core"
import { getAutomationMetadataParams } from "../db/utils" import { getAutomationMetadataParams } from "../db/utils"
import { cloneDeep } from "lodash/fp"
import { quotas } from "@budibase/pro" import { quotas } from "@budibase/pro"
import { import { Automation, AutomationJob, MetadataType } from "@budibase/types"
Automation,
AutomationActionStepId,
AutomationJob,
AutomationStepDefinition,
AutomationTriggerDefinition,
AutomationTriggerStepId,
MetadataType,
} from "@budibase/types"
import { automationsEnabled } from "../features" import { automationsEnabled } from "../features"
import { helpers, REBOOT_CRON } from "@budibase/shared-core" import { helpers, REBOOT_CRON } from "@budibase/shared-core"
import tracer from "dd-trace" import tracer from "dd-trace"
@ -122,23 +113,6 @@ export async function updateTestHistory(
) )
} }
export function removeDeprecated<
T extends
| Record<keyof typeof AutomationTriggerStepId, AutomationTriggerDefinition>
| Record<keyof typeof AutomationActionStepId, AutomationStepDefinition>
>(definitions: T): T {
const base: Record<
string,
AutomationTriggerDefinition | AutomationStepDefinition
> = cloneDeep(definitions)
for (let key of Object.keys(base)) {
if (base[key].deprecated) {
delete base[key]
}
}
return base as T
}
// end the repetition and the job itself // end the repetition and the job itself
export async function disableAllCrons(appId: any) { export async function disableAllCrons(appId: any) {
const promises = [] const promises = []

View File

@ -1,3 +1,8 @@
import {
GetAutomationActionDefinitionsResponse,
GetAutomationTriggerDefinitionsResponse,
} from "../../api"
export interface BranchPath { export interface BranchPath {
stepIdx: number stepIdx: number
branchIdx: number branchIdx: number
@ -6,7 +11,7 @@ export interface BranchPath {
} }
export interface BlockDefinitions { export interface BlockDefinitions {
TRIGGER: Record<string, any> TRIGGER: Partial<GetAutomationTriggerDefinitionsResponse>
CREATABLE_TRIGGER: Record<string, any> CREATABLE_TRIGGER: Partial<GetAutomationTriggerDefinitionsResponse>
ACTION: Record<string, any> ACTION: Partial<GetAutomationActionDefinitionsResponse>
} }