Skip to content

Commit

Permalink
fix(ui): task runner can be filled through low code editor
Browse files Browse the repository at this point in the history
  • Loading branch information
brian-mulier-p committed Aug 29, 2024
1 parent 3c35c8a commit 7061eef
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.google.common.base.CaseFormat;
import io.kestra.core.models.tasks.retrys.AbstractRetry;
import io.kestra.core.models.tasks.runners.TaskRunner;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
Expand Down Expand Up @@ -144,6 +145,10 @@ private Boolean isTypeToKeep(String key){
if (AbstractRetry.class.isAssignableFrom(Class.forName(key))) {
return true;
}

if (TaskRunner.class.isAssignableFrom(Class.forName(key))) {
return true;
}
} catch (ClassNotFoundException ignored) {
log.debug(ignored.getMessage(), ignored);
}
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/flows/TaskEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
type: this.selectedTaskType
};
if (this.section !== SECTIONS.TRIGGERS) {
if (this.section !== SECTIONS.TRIGGERS && this.section !== SECTIONS.TASK_RUNNERS) {
value["id"] = this.taskObject && this.taskObject.id ? this.taskObject.id : "";
}
Expand Down
4 changes: 4 additions & 0 deletions ui/src/components/flows/tasks/Task.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ export default {
return "condition"
}

if (property.$ref.includes("tasks.runners.TaskRunner")) {
return "task-runner"
}

return "complex";
}

Expand Down
10 changes: 8 additions & 2 deletions ui/src/components/flows/tasks/TaskTask.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<task-editor
ref="editor"
:model-value="taskYaml"
:section="SECTIONS.TASKS"
:section="section"
@update:model-value="onInput"
/>
</el-form>
Expand All @@ -34,19 +34,25 @@
<script setup>
import TextSearch from "vue-material-design-icons/TextSearch.vue";
import ContentSave from "vue-material-design-icons/ContentSave.vue";
import {SECTIONS} from "../../../utils/constants.js";
</script>

<script>
import Task from "./Task"
import YamlUtils from "../../../utils/yamlUtils";
import TaskEditor from "../TaskEditor.vue"
import Drawer from "../../Drawer.vue"
import {SECTIONS as SECTION} from "../../../utils/constants.js";
export default {
mixins: [Task],
components: {TaskEditor, Drawer},
emits: ["update:modelValue"],
props: {
section: {
type: String,
default: SECTION.TASKS
},
},
data() {
return {
isOpen: false,
Expand Down
9 changes: 9 additions & 0 deletions ui/src/components/flows/tasks/TaskTaskRunner.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<template>
<task-task @update:model-value="$emit('update:modelValue', $event)" v-bind="$attrs" :section="SECTION.TASK_RUNNERS" />
</template>
<script setup>
import {SECTIONS as SECTION} from "../../../utils/constants.js";
import TaskTask from "./TaskTask.vue";
defineEmits(["update:modelValue"]);
</script>
7 changes: 6 additions & 1 deletion ui/src/components/plugins/PluginSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,17 @@
taskModels() {
const taskModels = [];
for (const plugin of this.plugins || []) {
taskModels.push.apply(taskModels, plugin[this.section.toLowerCase()]);
taskModels.push.apply(taskModels, plugin[this.upperSnakeToCamelCase(this.section)]);
}
return taskModels;
},
},
methods: {
upperSnakeToCamelCase(str) {
return str.toLowerCase().replaceAll(/_([a-z])/g, function (g) {
return g[1].toUpperCase();
});
},
onInput(value) {
this.$emit("update:modelValue", value);
},
Expand Down
1 change: 1 addition & 0 deletions ui/src/utils/constants.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export const SECTIONS = {
TASKS: "TASKS",
TRIGGERS: "TRIGGERS",
TASK_RUNNERS: "TASK_RUNNERS",
}

export const stateGlobalChartTypes = {
Expand Down
2 changes: 2 additions & 0 deletions ui/src/utils/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import TaskSubflowInputs from "../components/flows/tasks/TaskSubflowInputs.vue";
import LeftMenuLink from "../components/LeftMenuLink.vue";
import RouterMd from "../components/utils/RouterMd.vue";
import Utils from "./utils";
import TaskTaskRunner from "../components/flows/tasks/TaskTaskRunner.vue";

export default (app, routes, stores, translations) => {
// charts
Expand Down Expand Up @@ -151,6 +152,7 @@ export default (app, routes, stores, translations) => {
app.component("TaskSubflowNamespace", TaskSubflowNamespace)
app.component("TaskSubflowId", TaskSubflowId)
app.component("TaskSubflowInputs", TaskSubflowInputs)
app.component("TaskTaskRunner", TaskTaskRunner)
app.component("LeftMenuLink", LeftMenuLink)
app.component("RouterMd", RouterMd)

Expand Down

0 comments on commit 7061eef

Please sign in to comment.