From c8e9fcfb2c0ec943a9d3a4fb2000f9950cf23cc0 Mon Sep 17 00:00:00 2001 From: panicboat Date: Mon, 25 Nov 2024 05:49:01 +0000 Subject: [PATCH] feat: Allow markdown title and description in KeyValueEditor Signed-off-by: panicboat --- .../components/editors/key-value-editor.scss | 8 ++++++++ .../components/editors/key-value-editor.tsx | 17 +++++++++++++++-- .../editors/labels-and-annotations-editor.tsx | 3 ++- .../editors/workflow-parameters-editor.tsx | 1 + 4 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 ui/src/shared/components/editors/key-value-editor.scss diff --git a/ui/src/shared/components/editors/key-value-editor.scss b/ui/src/shared/components/editors/key-value-editor.scss new file mode 100644 index 000000000000..4f6b77f1b094 --- /dev/null +++ b/ui/src/shared/components/editors/key-value-editor.scss @@ -0,0 +1,8 @@ +@import 'node_modules/argo-ui/src/styles/config'; + +.markdown-rows-name { + line-height: 1.5em; + display: inline-block; + vertical-align: middle; + white-space: pre-line; +} diff --git a/ui/src/shared/components/editors/key-value-editor.tsx b/ui/src/shared/components/editors/key-value-editor.tsx index 0a443aaae695..0df5faf03357 100644 --- a/ui/src/shared/components/editors/key-value-editor.tsx +++ b/ui/src/shared/components/editors/key-value-editor.tsx @@ -1,13 +1,24 @@ import * as React from 'react'; import {useState} from 'react'; +import {ANNOTATION_DESCRIPTION, ANNOTATION_TITLE} from '../../annotations'; +import {SuspenseReactMarkdownGfm} from '../suspense-react-markdown-gfm'; import {TextInput} from '../text-input'; +require('./key-value-editor.scss'); + interface KeyValues { [key: string]: string; } -export function KeyValueEditor({onChange, keyValues = {}, hide}: {keyValues: KeyValues; onChange: (value: KeyValues) => void; hide?: (key: string) => boolean}) { +interface KeyValueEditorProps { + keyValues: KeyValues; + onChange: (value: KeyValues) => void; + hide?: (key: string) => boolean; + source?: string; +} + +export function KeyValueEditor({onChange, keyValues = {}, hide, source}: KeyValueEditorProps) { const [name, setName] = useState(''); const [value, setValue] = useState(''); @@ -32,7 +43,9 @@ export function KeyValueEditor({onChange, keyValues = {}, hide}: {keyValues: Key .map(([k, v]) => (
{k}
-
{v}
+
+ {source == 'annotations' && [ANNOTATION_DESCRIPTION, ANNOTATION_TITLE].indexOf(k) !== -1 ? : v} +