Include stage templates

This commit is contained in:
Mel O'Hagan 2022-10-12 15:31:53 +01:00
parent bf7b0ab7dd
commit 9ee4788147
3 changed files with 42 additions and 2 deletions

View File

@ -4,6 +4,7 @@
import { import {
Label, Label,
Input, Input,
Select,
Divider, Divider,
Layout, Layout,
Icon, Icon,
@ -42,6 +43,19 @@
} }
} }
function setEditorTemplate(fromKey, toKey, index) {
if (
schema.steps.filter(step => step.key === fromKey)[0]?.template ===
query.fields.steps[index].value.value
) {
query.fields.steps[index].value.value = schema.steps.filter(
step => step.key === toKey
)[0]?.template
flowEditors[index].update(query.fields.steps[index].value.value)
}
query.fields.steps[index].key = toKey
}
$: shouldDisplayJsonBox = $: shouldDisplayJsonBox =
schema.type === QueryTypes.JSON && query.fields.extra?.actionType !== "flow" schema.type === QueryTypes.JSON && query.fields.extra?.actionType !== "flow"
</script> </script>
@ -114,10 +128,11 @@
<Layout noPadding gap="S"> <Layout noPadding gap="S">
<div class="fields"> <div class="fields">
<div class="block-field"> <div class="block-field">
<Input <Select
value={step.key} value={step.key}
options={schema.steps.map(s => s.key)}
on:change={({ detail }) => { on:change={({ detail }) => {
query.fields.steps[index].key = detail setEditorTemplate(step.key, detail, index)
}} }}
/> />
<Editor <Editor

View File

@ -58,6 +58,25 @@ const SCHEMA: Integration = {
}, },
aggregate: { aggregate: {
type: QueryType.JSON, type: QueryType.JSON,
steps: [
{
key: "$addFields",
template: "{\n\t\n}",
},
{
key: "$bucket",
template: `{
"groupBy": "",
"boundaries": [],
"default": "",
"output": {}
}`,
},
{
key: "$match",
template: "{\n\t\n}",
},
]
}, },
}, },
extra: { extra: {

View File

@ -70,6 +70,11 @@ export enum FilterType {
ONE_OF = "oneOf", ONE_OF = "oneOf",
} }
export interface StepDefinition {
key: string
template: string
}
export interface QueryDefinition { export interface QueryDefinition {
type: QueryType type: QueryType
displayName?: string displayName?: string
@ -77,6 +82,7 @@ export interface QueryDefinition {
customisable?: boolean customisable?: boolean
fields?: object fields?: object
urlDisplay?: boolean urlDisplay?: boolean
steps?: Array<StepDefinition>
} }
export interface ExtraQueryConfig { export interface ExtraQueryConfig {