Skip to content

Commit 77478f3

Browse files
authored
fix: no-code for plugin ai.ChatAutocompletion (#14945)
1 parent 782a6d6 commit 77478f3

File tree

8 files changed

+71
-47
lines changed

8 files changed

+71
-47
lines changed

ui/src/components/no-code/components/TaskEditor.vue

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
@update:model-value="onTaskInput"
2727
:schema
2828
:properties
29+
filterType
2930
/>
3031
</div>
3132
</template>
@@ -122,8 +123,6 @@
122123
$ref: "",
123124
}));
124125
125-
126-
127126
const properties = computed(() => {
128127
if(!resolvedProperties.value){
129128
return undefined;
@@ -207,7 +206,19 @@
207206
}
208207
}
209208
210-
const typeAsConst = resolvedItem?.properties?.type?.const
209+
const typeField = resolvedItem?.properties?.type
210+
if(!typeField){
211+
return acc;
212+
}
213+
214+
if(typeField.enum){
215+
for(const typeAsEnum of typeField.enum){
216+
acc[typeAsEnum] = acc[typeAsEnum] || [];
217+
acc[typeAsEnum].push(removeRefPrefix(item.$ref));
218+
}
219+
}
220+
221+
const typeAsConst = typeField?.const
211222
212223
if (typeAsConst) {
213224
acc[typeAsConst] = acc[typeAsConst] || [];

ui/src/components/no-code/components/tasks/TaskList.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<template #icon>
1111
<Creation
1212
:parentPathComplete
13-
:refPath="elements?.length ? elements.length - 1 : undefined"
13+
:refPath="elements?.length ? elements.length - 1 : -1"
1414
:blockSchemaPath
1515
/>
1616
</template>

ui/src/components/no-code/components/tasks/TaskObject.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
required?: boolean;
8787
schema?: Schema;
8888
root?: string;
89+
filterType?: boolean;
8990
}>();
9091
9192
const emit = defineEmits<{
@@ -145,12 +146,9 @@
145146
146147
const filteredProperties = computed<Entry[]>(() => {
147148
const propertiesProc = (props.properties ?? props.schema?.properties);
148-
const isOutputsContext = props.root?.startsWith("outputs[") || false;
149149
return propertiesProc
150150
? (Object.entries(propertiesProc) as Entry[]).filter(([key, value]) => {
151-
// Allow "type" field for outputs context, filter it out for other contexts
152-
const shouldFilterType = key === "type" && !isOutputsContext;
153-
return value && !shouldFilterType && !Array.isArray(value);
151+
return value && !(props.filterType && key === "type") && !Array.isArray(value);
154152
})
155153
: [];
156154
});

ui/src/components/no-code/components/tasks/TaskTask.vue

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
<Element
44
:section="root"
55
:parentPathComplete="parentPathComplete"
6-
:blockSchemaPath="[blockSchemaPath, 'properties', root.split('.').pop()].join('/')"
7-
:element="{
8-
id: model?.id ?? 'Set a task',
6+
:blockSchemaPath
7+
:element="Object.keys(model).length > 0 ? {
8+
id: (localSchema?.properties?.id ? model?.id : undefined),
99
type: model?.type,
10-
}"
10+
} : {id: fieldTitle}"
1111
typeFieldSchema="type"
1212
@remove-element="removeElement()"
1313
/>
@@ -20,9 +20,12 @@
2020
PARENT_PATH_INJECTION_KEY,
2121
REF_PATH_INJECTION_KEY,
2222
CREATING_TASK_INJECTION_KEY,
23-
BLOCK_SCHEMA_PATH_INJECTION_KEY
23+
BLOCK_SCHEMA_PATH_INJECTION_KEY,
24+
FULL_SCHEMA_INJECTION_KEY
2425
} from "../../injectionKeys";
2526
import Element from "./taskList/Element.vue";
27+
import {getValueAtJsonPath} from "../../../../utils/utils";
28+
2629
2730
const model = defineModel({
2831
type: Object,
@@ -36,10 +39,36 @@
3639
},
3740
});
3841
42+
defineOptions({
43+
inheritAttrs: false
44+
})
45+
3946
const parentPath = inject(PARENT_PATH_INJECTION_KEY, "");
4047
const refPath = inject(REF_PATH_INJECTION_KEY, undefined);
4148
const creatingTask = inject(CREATING_TASK_INJECTION_KEY, false);
42-
const blockSchemaPath = inject(BLOCK_SCHEMA_PATH_INJECTION_KEY, ref())
49+
const blockSchemaPathInjected = inject(BLOCK_SCHEMA_PATH_INJECTION_KEY, ref())
50+
const fullSchema = inject(FULL_SCHEMA_INJECTION_KEY, ref({}))
51+
52+
const blockSchemaPath = computed(() => {
53+
return [blockSchemaPathInjected.value, "properties", props.root.split(".").pop()].join("/")
54+
})
55+
56+
const localSchema = computed(() => getValueAtJsonPath(fullSchema.value, blockSchemaPath.value))
57+
58+
const fieldTitle = computed(() => {
59+
const schema = localSchema.value;
60+
61+
if(schema?.anyOf && Array.isArray(schema.anyOf)){
62+
// find all the title fields in the anyOf
63+
const titles: string[] = schema.anyOf.map((s: any) => s.allOf?.find((a: any) => a.title)?.title ?? s.title);
64+
65+
// if all the titles are the same, return that title
66+
if(titles.every((t) => t === titles[0])){
67+
return titles[0];
68+
}
69+
}
70+
return "Set a task"
71+
})
4372
4473
const parentPathComplete = computed(() => {
4574
return `${[

ui/src/components/no-code/components/tasks/taskList/Element.vue

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,20 @@
55
</div>
66

77
<div class="flex-grow-1 label">
8-
{{ identifier }}
8+
{{ title ?? identifier }}
99
</div>
1010

1111
<button v-if="playgroundStore.enabled && element.id && isTask" @click.stop="playgroundStore.runUntilTask(element.id)" type="button" class="playground-run-task">
1212
<PlayIcon />
1313
</button>
1414

15-
<el-button
15+
<button
16+
class="delete-element"
17+
type="button"
1618
@click.prevent.stop="emits('removeElement')"
17-
:icon="DeleteOutline"
18-
size="small"
19-
class="border-0"
20-
/>
19+
>
20+
<DeleteOutline />
21+
</button>
2122
<div v-if="elementIndex !== undefined" class="d-flex flex-column">
2223
<ChevronUp @click.prevent.stop="emits('moveElement', 'up')" />
2324
<ChevronDown @click.prevent.stop="emits('moveElement', 'down')" />
@@ -56,6 +57,7 @@
5657
elementIndex?: number;
5758
typeFieldSchema: "on" | "type";
5859
moved?: boolean;
60+
title?: string
5961
}>();
6062
6163
const pluginsStore = usePluginsStore();
@@ -122,12 +124,9 @@
122124
border: none;
123125
}
124126
125-
:deep(.el-button) {
127+
.delete-element { color: $base-white;
128+
border: none;
126129
background-color: transparent;
127-
128-
&:hover {
129-
color: var(--ks-content-alert);
130-
}
131130
}
132131
}
133132
</style>

ui/src/components/plugins/PluginSelect.vue

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -83,27 +83,6 @@
8383
}) || []);
8484
8585
const taskModelsSets = computed(() => {
86-
if (blockType === "pluginDefaults" || isPluginBlock) {
87-
const models = new Map<string, string>();
88-
const pluginKeySection = (["tasks", "conditions", "triggers", "taskRunners"] as const)
89-
.filter(s => blockType === "pluginDefaults" || s === blockType);
90-
91-
for (const plugin of pluginsStore.plugins || []) {
92-
for (const curSection of pluginKeySection) {
93-
const entries = plugin[curSection] as {cls: string, title?: string, deprecated?: boolean}[] | undefined;
94-
if (entries) {
95-
for (const {cls, title} of entries.filter(({deprecated}) => !deprecated)) {
96-
if (cls) {
97-
models.set(cls, title ?? cls);
98-
}
99-
}
100-
}
101-
}
102-
}
103-
104-
return models;
105-
}
106-
10786
return allRefs.value.reduce((acc: Map<string, string>, item: string) => {
10887
const def = rootDefinitions.value?.[item]
10988
@@ -118,6 +97,12 @@
11897
if (consolidatedType?.const) {
11998
acc.set(consolidatedType.const, def.title ?? consolidatedType.const);
12099
}
100+
101+
if (consolidatedType?.enum) {
102+
const val = consolidatedType.enum[0];
103+
104+
acc.set(val, def.title ?? val);
105+
}
121106
return acc
122107
}, new Map<string, string>());
123108
})

ui/src/translations/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1377,7 +1377,8 @@
13771377
"listeners": "Listeners",
13781378
"taskDefaults": "Task Defaults",
13791379
"workerGroup": "Worker Group",
1380-
"checks": "Checks"
1380+
"checks": "Checks",
1381+
"updated": "Updated"
13811382
}
13821383
},
13831384
"select": {

ui/tests/storybook/components/no-code/components/tasks/TaskObject.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const AppTableBlockRender = () => ({
4343
schema={schema}
4444
modelValue={model.value}
4545
onUpdate:modelValue={(value) => model.value = value}
46+
filterType
4647
/>
4748
</div>
4849
<div style={{width: "500px"}}>

0 commit comments

Comments
 (0)