From 969faba1f0b7a122f314fc726e644425cbbff2da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milo=C5=A1=20Paunovi=C4=87?= Date: Fri, 17 Jan 2025 13:17:37 +0100 Subject: [PATCH] feat(ui): improvements of no code editor (#6804) * chore(ui): enhance toggle button for switching between `YAML` and `No Code` editors * chore(ui): remove the export flow button from main section * chore(ui): remove the unused context menu options * chore(ui): add margin after the last entry for variables and inputs * chore(ui): only show save button on task creation if one is selected * chore(ui): replace plugin default component from input to editor type * chore(ui): replace retry and outputs component from input to editor type * chore(ui): move all general properties to the top level --- ui/src/components/code/segments/Editor.vue | 178 ++++++++---------- ui/src/components/code/segments/Task.vue | 16 +- ui/src/components/code/utils/types.ts | 38 ++-- ui/src/components/flows/MetadataInputs.vue | 2 +- ui/src/components/flows/MetadataVariables.vue | 3 +- ui/src/components/inputs/Editor.vue | 8 +- ui/src/components/inputs/EditorButtons.vue | 39 +--- ui/src/components/inputs/EditorView.vue | 41 ++-- ui/src/translations/de.json | 3 - ui/src/translations/en.json | 3 - ui/src/translations/es.json | 3 - ui/src/translations/fr.json | 3 - ui/src/translations/hi.json | 3 - ui/src/translations/it.json | 3 - ui/src/translations/ja.json | 3 - ui/src/translations/ko.json | 3 - ui/src/translations/pl.json | 3 - ui/src/translations/pt.json | 3 - ui/src/translations/ru.json | 3 - ui/src/translations/zh_CN.json | 3 - 20 files changed, 138 insertions(+), 223 deletions(-) diff --git a/ui/src/components/code/segments/Editor.vue b/ui/src/components/code/segments/Editor.vue index 5869bce2f47..2170a8e733e 100644 --- a/ui/src/components/code/segments/Editor.vue +++ b/ui/src/components/code/segments/Editor.vue @@ -2,7 +2,7 @@
import {ref, shallowRef} from "vue"; - import {Field, Fields, Sections} from "../utils/types"; + import {Field, Fields, CollapseItem} from "../utils/types"; import Collapse from "../components/collapse/Collapse.vue"; import InputText from "../components/inputs/InputText.vue"; import InputSwitch from "../components/inputs/InputSwitch.vue"; import InputLabel from "../components/inputs/InputLabel.vue"; + import Editor from "../../inputs/Editor.vue"; import MetadataInputs from "../../flows/MetadataInputs.vue"; import MetadataVariables from "../../flows/MetadataVariables.vue"; @@ -81,72 +65,80 @@ }; const fields = ref({ - main: { - id: { - component: shallowRef(InputText), - value: props.metadata.id, - label: t("no_code.fields.main.flow_id"), - required: true, - disabled: !props.creation, - }, - namespace: { - component: shallowRef(InputText), - value: props.metadata.namespace, - label: t("no_code.fields.main.namespace"), - required: true, - disabled: !props.creation, - }, - description: { - component: shallowRef(InputText), - value: props.metadata.description, - label: t("no_code.fields.main.description"), - }, + id: { + component: shallowRef(InputText), + value: props.metadata.id, + label: t("no_code.fields.main.flow_id"), + required: true, + disabled: !props.creation, + }, + namespace: { + component: shallowRef(InputText), + value: props.metadata.namespace, + label: t("no_code.fields.main.namespace"), + required: true, + disabled: !props.creation, + }, + description: { + component: shallowRef(InputText), + value: props.metadata.description, + label: t("no_code.fields.main.description"), + }, + retry: { + component: shallowRef(Editor), + value: props.metadata.retry, + label: t("no_code.fields.general.retry"), + navbar: false, + input: true, + lang: "yaml", + style: {height: "100px"}, + }, + labels: { + component: shallowRef(InputLabel), + value: props.metadata.labels, + label: t("no_code.fields.general.labels"), }, - general: { - retry: { - component: shallowRef(InputText), - value: props.metadata.retry, - label: t("no_code.fields.general.retry"), - }, - labels: { - component: shallowRef(InputLabel), - value: props.metadata.labels, - label: t("no_code.fields.general.labels"), - }, - inputs: { - component: shallowRef(MetadataInputs), - value: props.metadata.inputs, - label: t("no_code.fields.general.inputs"), - inputs: props.metadata.inputs, - }, - outputs: { - component: shallowRef(InputText), - value: props.metadata.outputs, - label: t("no_code.fields.general.outputs"), - }, - variables: { - component: shallowRef(MetadataVariables), - value: props.metadata.variables, - label: t("no_code.fields.general.variables"), - variables: props.metadata.variables, - }, - // concurrency: { - // component: shallowRef(InputSwitch), // TODO: To improve slot content - // value: props.metadata.concurrency, - // label: t("no_code.fields.general.concurrency"), - // schema: props.schemas?.definitions?.[CONCURRENCY] ?? {}, - // root: "concurrency", - // }, - pluginDefaults: { - component: shallowRef(InputText), - value: props.metadata.pluginDefaults, - label: t("no_code.fields.general.plugin_defaults"), - }, - disabled: { - component: shallowRef(InputSwitch), - value: props.metadata.disabled, - label: t("no_code.fields.general.disabled"), - }, + inputs: { + component: shallowRef(MetadataInputs), + value: props.metadata.inputs, + label: t("no_code.fields.general.inputs"), + inputs: props.metadata.inputs, + }, + outputs: { + component: shallowRef(Editor), + value: props.metadata.outputs, + label: t("no_code.fields.general.outputs"), + navbar: false, + input: true, + lang: "yaml", + style: {height: "100px"}, + }, + variables: { + component: shallowRef(MetadataVariables), + value: props.metadata.variables, + label: t("no_code.fields.general.variables"), + variables: props.metadata.variables, + }, + // concurrency: { + // component: shallowRef(InputSwitch), // TODO: To improve slot content + // value: props.metadata.concurrency, + // label: t("no_code.fields.general.concurrency"), + // schema: props.schemas?.definitions?.[CONCURRENCY] ?? {}, + // root: "concurrency", + // }, + pluginDefaults: { + component: shallowRef(Editor), + value: props.metadata.pluginDefaults, + label: t("no_code.fields.general.plugin_defaults"), + navbar: false, + input: true, + lang: "yaml", + style: {height: "100px"}, + }, + disabled: { + component: shallowRef(InputSwitch), + value: props.metadata.disabled, + label: t("no_code.fields.general.disabled"), }, }); @@ -155,15 +147,9 @@ const title = t(`no_code.sections.${label}`); return {title, elements}; }; - const sections = ref({ - main: [{title: t("no_code.sections.general")}], - segments: [ - getSectionTitle("tasks", YamlUtils.parse(props.flow).tasks ?? []), - getSectionTitle("triggers", YamlUtils.parse(props.flow).triggers ?? []), - getSectionTitle( - "error_handlers", - YamlUtils.parse(props.flow).errors ?? [], - ), - ], - }); + const sections = ref([ + getSectionTitle("tasks", YamlUtils.parse(props.flow).tasks ?? []), + getSectionTitle("triggers", YamlUtils.parse(props.flow).triggers ?? []), + getSectionTitle("error_handlers", YamlUtils.parse(props.flow).errors ?? []), + ]); diff --git a/ui/src/components/code/segments/Task.vue b/ui/src/components/code/segments/Task.vue index 5ae34b2657b..54a29f4bc5c 100644 --- a/ui/src/components/code/segments/Task.vue +++ b/ui/src/components/code/segments/Task.vue @@ -1,15 +1,17 @@ + +