Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow markdown title and description in KeyValueEditor #13935

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions ui/src/shared/components/editors/key-value-editor.scss
Original file line number Diff line number Diff line change
@@ -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;
}
17 changes: 15 additions & 2 deletions ui/src/shared/components/editors/key-value-editor.tsx
Original file line number Diff line number Diff line change
@@ -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('');

Expand All @@ -32,7 +43,9 @@ export function KeyValueEditor({onChange, keyValues = {}, hide}: {keyValues: Key
.map(([k, v]) => (
<div className='row white-box__details-row' key={k}>
<div className='columns small-4'>{k}</div>
<div className='columns small-6'>{v}</div>
<div className='columns small-6 markdown-rows-name'>
{source == 'annotations' && [ANNOTATION_DESCRIPTION, ANNOTATION_TITLE].indexOf(k) !== -1 ? <SuspenseReactMarkdownGfm markdown={v} /> : v}
</div>
<div className='columns small-2'>
<button onClick={() => deleteItem(k)}>
<i className='fa fa-times-circle' />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ export function LabelsAndAnnotationsEditor({value, onChange}: {value: kubernetes
<>
<div className='white-box'>
<h5>Labels</h5>
<KeyValueEditor keyValues={value && value.labels} onChange={labels => onChange({...value, labels})} />
<KeyValueEditor keyValues={value && value.labels} onChange={labels => onChange({...value, labels})} source={'labels'} />
</div>
<div className='white-box'>
<h5>Annotations</h5>
<KeyValueEditor
keyValues={value && value.annotations}
onChange={annotations => onChange({...value, annotations})}
hide={key => key === 'kubectl.kubernetes.io/last-applied-configuration'}
source={'annotations'}
/>
</div>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export function WorkflowParametersEditor<T extends WorkflowSpec>(props: {value:
);
props.onChange(props.value);
}}
source={'parameters'}
/>
</div>
</>
Expand Down
Loading