Skip to content

Commit

Permalink
feat(markdown): Allow markdown in workflow title and description
Browse files Browse the repository at this point in the history
Fixes: argoproj#10126

- [x] new react component for handling workflow row name
- [x] new css file to manage row name column
- [x] new example file for title and description with markdown
- [x] include `remark-gfm` for GitHub Friendly Markdown (aka urls automatically translate to links)
- [x] Add User Guid -> UI Features -> Title and Description docs page
- [x] make first column of workflow row not be wrapped in row link so markdown links can be clicked
  - [x] add overlay so users can still click to open workflow
- [x] change remark-gfm to 3.0.0 based on remarkjs/react-markdown#771 (comment)

Signed-off-by: jmeridth <jmeridth@gmail.com>
Co-authored-by: Steven Johnson <52087249+stevenbjohnson@users.noreply.github.com>
  • Loading branch information
jmeridth and stevenbjohnson committed Dec 29, 2023
1 parent 954884d commit 416139f
Show file tree
Hide file tree
Showing 10 changed files with 2,627 additions and 1,775 deletions.
Binary file added docs/assets/workflow-title-and-description.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions docs/fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@ Workflow is the definition of a workflow resource

- [`timeouts-workflow.yaml`](https://github.com/argoproj/argo-workflows/blob/main/examples/timeouts-workflow.yaml)

- [`title-and-descriptin-with-markdown.yaml`](https://github.com/argoproj/argo-workflows/blob/main/examples/title-and-descriptin-with-markdown.yaml)

- [`volumes-emptydir.yaml`](https://github.com/argoproj/argo-workflows/blob/main/examples/volumes-emptydir.yaml)

- [`volumes-existing.yaml`](https://github.com/argoproj/argo-workflows/blob/main/examples/volumes-existing.yaml)
Expand Down Expand Up @@ -755,6 +757,8 @@ WorkflowSpec is the specification of a Workflow.

- [`timeouts-workflow.yaml`](https://github.com/argoproj/argo-workflows/blob/main/examples/timeouts-workflow.yaml)

- [`title-and-descriptin-with-markdown.yaml`](https://github.com/argoproj/argo-workflows/blob/main/examples/title-and-descriptin-with-markdown.yaml)

- [`volumes-emptydir.yaml`](https://github.com/argoproj/argo-workflows/blob/main/examples/volumes-emptydir.yaml)

- [`volumes-existing.yaml`](https://github.com/argoproj/argo-workflows/blob/main/examples/volumes-existing.yaml)
Expand Down Expand Up @@ -1191,6 +1195,8 @@ CronWorkflowSpec is the specification of a CronWorkflow

- [`timeouts-workflow.yaml`](https://github.com/argoproj/argo-workflows/blob/main/examples/timeouts-workflow.yaml)

- [`title-and-descriptin-with-markdown.yaml`](https://github.com/argoproj/argo-workflows/blob/main/examples/title-and-descriptin-with-markdown.yaml)

- [`volumes-emptydir.yaml`](https://github.com/argoproj/argo-workflows/blob/main/examples/volumes-emptydir.yaml)

- [`volumes-existing.yaml`](https://github.com/argoproj/argo-workflows/blob/main/examples/volumes-existing.yaml)
Expand Down Expand Up @@ -3707,6 +3713,8 @@ MetricLabel is a single label for a prometheus metric
- [`pod-metadata.yaml`](https://github.com/argoproj/argo-workflows/blob/main/examples/pod-metadata.yaml)

- [`steps-inline-workflow.yaml`](https://github.com/argoproj/argo-workflows/blob/main/examples/steps-inline-workflow.yaml)

- [`title-and-descriptin-with-markdown.yaml`](https://github.com/argoproj/argo-workflows/blob/main/examples/title-and-descriptin-with-markdown.yaml)
</details>

### Fields
Expand Down Expand Up @@ -4895,6 +4903,8 @@ ObjectMeta is metadata that all persisted resources must have, which includes al

- [`timeouts-workflow.yaml`](https://github.com/argoproj/argo-workflows/blob/main/examples/timeouts-workflow.yaml)

- [`title-and-descriptin-with-markdown.yaml`](https://github.com/argoproj/argo-workflows/blob/main/examples/title-and-descriptin-with-markdown.yaml)

- [`volumes-emptydir.yaml`](https://github.com/argoproj/argo-workflows/blob/main/examples/volumes-emptydir.yaml)

- [`volumes-existing.yaml`](https://github.com/argoproj/argo-workflows/blob/main/examples/volumes-existing.yaml)
Expand Down Expand Up @@ -5503,6 +5513,8 @@ A single application container that you want to run within a pod.

- [`timeouts-workflow.yaml`](https://github.com/argoproj/argo-workflows/blob/main/examples/timeouts-workflow.yaml)

- [`title-and-descriptin-with-markdown.yaml`](https://github.com/argoproj/argo-workflows/blob/main/examples/title-and-descriptin-with-markdown.yaml)

- [`volumes-emptydir.yaml`](https://github.com/argoproj/argo-workflows/blob/main/examples/volumes-emptydir.yaml)

- [`volumes-existing.yaml`](https://github.com/argoproj/argo-workflows/blob/main/examples/volumes-existing.yaml)
Expand Down Expand Up @@ -6238,6 +6250,8 @@ PersistentVolumeClaimSpec describes the common attributes of storage devices and

- [`timeouts-workflow.yaml`](https://github.com/argoproj/argo-workflows/blob/main/examples/timeouts-workflow.yaml)

- [`title-and-descriptin-with-markdown.yaml`](https://github.com/argoproj/argo-workflows/blob/main/examples/title-and-descriptin-with-markdown.yaml)

- [`volumes-emptydir.yaml`](https://github.com/argoproj/argo-workflows/blob/main/examples/volumes-emptydir.yaml)

- [`volumes-existing.yaml`](https://github.com/argoproj/argo-workflows/blob/main/examples/volumes-existing.yaml)
Expand Down
25 changes: 25 additions & 0 deletions docs/title-and-description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Title and Description

If you add specific title and description annotations to your workflow they will show up on the workflow lists. It will also work with markdown.

```yaml
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
name: my-wf
annotations:
workflows.argoproj.io/title: '**Build and test**'
workflows.argoproj.io/description: '`SuperDuperProject` PR #6529: Implement frobbing (aff39ee)'
```
Examples by row:
- markdown title, markdown description using [`remark-gfm`](https://github.com/remarkjs/remark-gfm) to auto turn URLs into links
- no title or description, defaults to `workflow.metadata.name`
- markdown title, no description
- no title, markdown description (title defaults to `workflow.metadata.name`)
- markdown title, markdown description (description includes URL that auto turns into anchor
- markdown title, markdown description, includes markdown URL
- markdown title, markdown description, includes markdown URL (pr link goes to `github.com`)

![Workflow Title And Description](assets/workflow-title-and-description.png)
19 changes: 19 additions & 0 deletions examples/title-and-descriptin-with-markdown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: title-and-description-with-markdown-
labels:
workflows.argoproj.io/archive-strategy: "false"
annotations:
workflows.argoproj.io/title: "**Test Title**"
workflows.argoproj.io/description: |
`This is a simple hello world example.`
You can also run it in Python: https://couler-proj.github.io/couler/examples/#hello-world
spec:
entrypoint: whalesay
templates:
- name: whalesay
container:
image: docker/whalesay:latest
command: [cowsay]
args: ["hello world"]
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ nav:
- artifact-visualization.md
- widgets.md
- intermediate-inputs.md
- title-and-description.md
- Debugging Tools:
- workflow-events.md
- debug-pause.md
Expand Down
2 changes: 2 additions & 0 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@
"react-chartjs-2": "^2.11.2",
"react-datepicker": "^4.25.0",
"react-dom": "^16.14.0",
"react-markdown": "^8.0.7",
"react-monaco-editor": "^0.50.1",
"react-router-dom": "^4.2.2",
"remark-gfm": "^3.0.0",
"superagent": "^8.1.2",
"swagger-ui-react": "^4.19.1"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import * as kubernetes from 'argo-ui/src/models/kubernetes';
import * as React from 'react';
import ReactMarkdown from 'react-markdown';
import remarkGfm from 'remark-gfm';
import {ANNOTATION_DESCRIPTION, ANNOTATION_TITLE} from '../../../shared/annotations';

require('./workflows-row.scss');

export const WorkflowsRowName = ({metadata}: {metadata: kubernetes.ObjectMeta}) => {
const title = (metadata.annotations && metadata.annotations[ANNOTATION_TITLE]) || metadata.name;
const description = (metadata.annotations && metadata.annotations[ANNOTATION_DESCRIPTION] && `\n${metadata.annotations[ANNOTATION_DESCRIPTION]}`) || '';
const markdown = `${title}${description}`;
return (
<div className='wf-rows-name'>
<ReactMarkdown components={{p: React.Fragment}} remarkPlugins={[remarkGfm]}>
{markdown}
</ReactMarkdown>
</div>
);
};
22 changes: 22 additions & 0 deletions ui/src/app/workflows/components/workflows-row/workflows-row.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@import 'node_modules/argo-ui/src/styles/config';

.wf-rows-name {
line-height: 1.5em;
display: inline-block;
position: relative;
pointer-events: none;
vertical-align: middle;
white-space: pre-line;
}
.overlay {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
.wf-rows-name a {
pointer-events: all;
position: relative;
z-index: 1;
}
13 changes: 7 additions & 6 deletions ui/src/app/workflows/components/workflows-row/workflows-row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import {useState} from 'react';
import {Link} from 'react-router-dom';
import * as models from '../../../../models';
import {isArchivedWorkflow, Workflow} from '../../../../models';
import {ANNOTATION_DESCRIPTION, ANNOTATION_TITLE} from '../../../shared/annotations';
import {uiUrl} from '../../../shared/base';
import {DurationPanel} from '../../../shared/components/duration-panel';
import {PhaseIcon} from '../../../shared/components/phase-icon';
import {Timestamp} from '../../../shared/components/timestamp';
import {wfDuration} from '../../../shared/duration';
import {WorkflowDrawer} from '../workflow-drawer/workflow-drawer';
import {WorkflowsRowName} from './workflows-row-name';

interface WorkflowsRowProps {
workflow: Workflow;
Expand All @@ -23,6 +23,7 @@ interface WorkflowsRowProps {
export function WorkflowsRow(props: WorkflowsRowProps) {
const [hideDrawer, setHideDrawer] = useState(true);
const wf = props.workflow;
const workflowLink = uiUrl(`workflows/${wf.metadata.namespace}/${wf.metadata.name}?uid=${wf.metadata.uid}`);

return (
<div className='workflows-list__row-container'>
Expand All @@ -41,16 +42,16 @@ export function WorkflowsRow(props: WorkflowsRowProps) {
/>
<PhaseIcon value={wf.status.phase} />
</div>
<div className='columns small-2'>
<a className='overlay' href={workflowLink}></a>
<WorkflowsRowName metadata={wf.metadata} />
</div>
<Link
to={{
pathname: uiUrl(`workflows/${wf.metadata.namespace}/${wf.metadata.name}`),
search: `?uid=${wf.metadata.uid}`
}}
className='small-11 row'>
<div className='columns small-2'>
{(wf.metadata.annotations && wf.metadata.annotations[ANNOTATION_TITLE]) || wf.metadata.name}
{wf.metadata.annotations && wf.metadata.annotations[ANNOTATION_DESCRIPTION] ? <p>{wf.metadata.annotations[ANNOTATION_DESCRIPTION]}</p> : null}
</div>
className='small-8 row'>
<div className='columns small-1'>{wf.metadata.namespace}</div>
<div className='columns small-1'>
<Timestamp date={wf.status.startedAt} />
Expand Down
Loading

0 comments on commit 416139f

Please sign in to comment.