Include stage templates

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

View File

@ -4,6 +4,7 @@
import {
Label,
Input,
Select,
Divider,
Layout,
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 =
schema.type === QueryTypes.JSON && query.fields.extra?.actionType !== "flow"
</script>
@ -114,10 +128,11 @@
<Layout noPadding gap="S">
<div class="fields">
<div class="block-field">
<Input
<Select
value={step.key}
options={schema.steps.map(s => s.key)}
on:change={({ detail }) => {
query.fields.steps[index].key = detail
setEditorTemplate(step.key, detail, index)
}}
/>
<Editor

View File

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

View File

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