Skip to content

Commit 2e1bce0

Browse files
committed
feat: add template schema to workflow settings
1 parent 2913e17 commit 2e1bce0

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

components/workflows/WorkflowForm.tsx

+19-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { gql } from '@apollo/client'
22
import { Alert, Button, Form, Input, Switch } from 'antd'
3+
import TextArea from 'antd/lib/input/TextArea'
34
import { useEffect, useState } from 'react'
45
import { Workflow } from '../../graphql'
56
import { WorkflowSelector } from './WorkflowSelector'
@@ -13,8 +14,7 @@ interface Props {
1314
error: string | null
1415
}
1516

16-
export const WorkflowForm = (props: Props) => {
17-
const { workflow, showSubmit, onSubmit, onChange, loading, error } = props
17+
export const WorkflowForm = ({ workflow, showSubmit, onSubmit, onChange, loading, error }: Props) => {
1818
const [name, setName] = useState(workflow?.name ?? '')
1919
const [runWorkflowOnFailureEnabled, setRunWorkflowOnFailureEnabled] = useState(!!workflow.runOnFailure)
2020
const [runOnFailure, setRunOnFailure] = useState<string | null>(workflow.runOnFailure ?? null)
@@ -78,6 +78,21 @@ export const WorkflowForm = (props: Props) => {
7878
<span style={{ marginLeft: 8 }}>Run a workflow on failure</span>
7979
</div>
8080

81+
{workflow.isTemplate && (
82+
<div className="mb-8">
83+
<Form.Item
84+
name="templateSchema"
85+
label="Template Schema (Advanced)"
86+
initialValue={JSON.stringify(workflow.templateSchema, null, 2)}
87+
rules={[{ required: true }]}
88+
help="Define the JSON Schema for the use template modal. Only for advanced users."
89+
style={{ marginBottom: 46 }}
90+
>
91+
<TextArea rows={4} />
92+
</Form.Item>
93+
</div>
94+
)}
95+
8196
{runWorkflowOnFailureEnabled && (
8297
<div style={{ marginBottom: 32 }}>
8398
<WorkflowSelector
@@ -106,6 +121,8 @@ WorkflowForm.fragments = {
106121
id
107122
name
108123
runOnFailure
124+
templateSchema
125+
isTemplate
109126
}
110127
`,
111128

pages/workflows/[id]/settings.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ function WorkflowSettingsPage({ workflowId }: Props) {
7575
})
7676
delete update.maxConsecutiveFailures
7777
}
78+
if (update.templateSchema) {
79+
update.templateSchema = JSON.parse(update.templateSchema)
80+
}
7881
const res = await updateWorkflow({
7982
variables: {
8083
input: {
@@ -83,6 +86,7 @@ function WorkflowSettingsPage({ workflowId }: Props) {
8386
},
8487
},
8588
})
89+
await refetch()
8690
await router.push(`/workflows/${workflowId}`)
8791
} catch (e: any) {
8892
setUpdateError(e?.message)

0 commit comments

Comments
 (0)