From 095bd4057a795e7d85bbad8c0d54005f31e12dc3 Mon Sep 17 00:00:00 2001 From: Tianchu Zhao Date: Wed, 14 Apr 2021 12:37:21 +1000 Subject: [PATCH] feat(ui): extend link, add workflow in object Signed-off-by: Tianchu Zhao --- api/jsonschema/schema.json | 2 +- api/openapi-spec/swagger.json | 2 +- pkg/apis/workflow/v1alpha1/generated.proto | 2 +- pkg/apis/workflow/v1alpha1/info.go | 2 +- .../workflow/v1alpha1/openapi_generated.go | 2 +- .../archived-workflow-details.tsx | 13 ++++++++++- ui/src/app/shared/components/links.tsx | 4 ++-- .../workflow-details/workflow-details.tsx | 13 ++++++++++- .../workflow-logs-viewer.tsx | 1 + .../workflow-node-info/workflow-node-info.tsx | 23 ++++++++++++++----- 10 files changed, 49 insertions(+), 15 deletions(-) diff --git a/api/jsonschema/schema.json b/api/jsonschema/schema.json index b100a2df1b4e..e8a0bda4f2a4 100644 --- a/api/jsonschema/schema.json +++ b/api/jsonschema/schema.json @@ -3818,7 +3818,7 @@ "type": "string" }, "url": { - "description": "The URL. Can contain \"${metadata.namespace}\", \"${metadata.name}\", \"${status.startedAt}\", \"${status.finishedAt}\" or any other element in workflow yaml, e.g. \"${metadata.annotations.userDefinedKey}\"", + "description": "The URL. Can contain \"${metadata.namespace}\", \"${metadata.name}\", \"${status.startedAt}\", \"${status.finishedAt}\" or any other element in workflow yaml, e.g. \"${io.argoproj.workflow.v1alpha1.metadata.annotations.userDefinedKey}\"", "type": "string" } }, diff --git a/api/openapi-spec/swagger.json b/api/openapi-spec/swagger.json index f7744ddbfc4e..7c0b1dc7d92d 100644 --- a/api/openapi-spec/swagger.json +++ b/api/openapi-spec/swagger.json @@ -7238,7 +7238,7 @@ "type": "string" }, "url": { - "description": "The URL. Can contain \"${metadata.namespace}\", \"${metadata.name}\", \"${status.startedAt}\", \"${status.finishedAt}\" or any other element in workflow yaml, e.g. \"${metadata.annotations.userDefinedKey}\"", + "description": "The URL. Can contain \"${metadata.namespace}\", \"${metadata.name}\", \"${status.startedAt}\", \"${status.finishedAt}\" or any other element in workflow yaml, e.g. \"${io.argoproj.workflow.v1alpha1.metadata.annotations.userDefinedKey}\"", "type": "string" } }, diff --git a/pkg/apis/workflow/v1alpha1/generated.proto b/pkg/apis/workflow/v1alpha1/generated.proto index 66b7779acf33..5cbdec408239 100644 --- a/pkg/apis/workflow/v1alpha1/generated.proto +++ b/pkg/apis/workflow/v1alpha1/generated.proto @@ -555,7 +555,7 @@ message Link { // "workflow", "pod", "pod-logs", "event-source-logs", "sensor-logs" or "chat" optional string scope = 2; - // The URL. Can contain "${metadata.namespace}", "${metadata.name}", "${status.startedAt}", "${status.finishedAt}" or any other element in workflow yaml, e.g. "${metadata.annotations.userDefinedKey}" + // The URL. Can contain "${metadata.namespace}", "${metadata.name}", "${status.startedAt}", "${status.finishedAt}" or any other element in workflow yaml, e.g. "${workflow.metadata.annotations.userDefinedKey}" optional string url = 3; } diff --git a/pkg/apis/workflow/v1alpha1/info.go b/pkg/apis/workflow/v1alpha1/info.go index 9f9563e1ee60..1a17e5af04ce 100644 --- a/pkg/apis/workflow/v1alpha1/info.go +++ b/pkg/apis/workflow/v1alpha1/info.go @@ -8,6 +8,6 @@ type Link struct { Name string `json:"name" protobuf:"bytes,1,opt,name=name"` // "workflow", "pod", "pod-logs", "event-source-logs", "sensor-logs" or "chat" Scope string `json:"scope" protobuf:"bytes,2,opt,name=scope"` - // The URL. Can contain "${metadata.namespace}", "${metadata.name}", "${status.startedAt}", "${status.finishedAt}" or any other element in workflow yaml, e.g. "${metadata.annotations.userDefinedKey}" + // The URL. Can contain "${metadata.namespace}", "${metadata.name}", "${status.startedAt}", "${status.finishedAt}" or any other element in workflow yaml, e.g. "${workflow.metadata.annotations.userDefinedKey}" URL string `json:"url" protobuf:"bytes,3,opt,name=url"` } diff --git a/pkg/apis/workflow/v1alpha1/openapi_generated.go b/pkg/apis/workflow/v1alpha1/openapi_generated.go index e721d8fd631a..f7bd3cd556b9 100644 --- a/pkg/apis/workflow/v1alpha1/openapi_generated.go +++ b/pkg/apis/workflow/v1alpha1/openapi_generated.go @@ -2323,7 +2323,7 @@ func schema_pkg_apis_workflow_v1alpha1_Link(ref common.ReferenceCallback) common }, "url": { SchemaProps: spec.SchemaProps{ - Description: "The URL. Can contain \"${metadata.namespace}\", \"${metadata.name}\", \"${status.startedAt}\", \"${status.finishedAt}\" or any other element in workflow yaml, e.g. \"${metadata.annotations.userDefinedKey}\"", + Description: "The URL. Can contain \"${metadata.namespace}\", \"${metadata.name}\", \"${status.startedAt}\", \"${status.finishedAt}\" or any other element in workflow yaml, e.g. \"${workflow.metadata.annotations.userDefinedKey}\"", Default: "", Type: []string{"string"}, Format: "", diff --git a/ui/src/app/archived-workflows/components/archived-workflow-details/archived-workflow-details.tsx b/ui/src/app/archived-workflows/components/archived-workflow-details/archived-workflow-details.tsx index 166f0e396a36..98833955e87a 100644 --- a/ui/src/app/archived-workflows/components/archived-workflow-details/archived-workflow-details.tsx +++ b/ui/src/app/archived-workflows/components/archived-workflow-details/archived-workflow-details.tsx @@ -262,6 +262,17 @@ export class ArchivedWorkflowDetails extends BasePage, } private openLink(link: Link) { - document.location.href = ProcessURL(link.url, this.state.workflow); + const object = { + metadata: { + namespace: this.state.workflow.metadata.namespace, + name: this.state.workflow.metadata.name + }, + workflow: this.state.workflow, + status: { + startedAt: this.state.workflow.status.startedAt, + finishedAt: this.state.workflow.status.finishedAt + } + }; + document.location.href = ProcessURL(link.url, object); } } diff --git a/ui/src/app/shared/components/links.tsx b/ui/src/app/shared/components/links.tsx index 260793735f8c..e8c0336c19a6 100644 --- a/ui/src/app/shared/components/links.tsx +++ b/ui/src/app/shared/components/links.tsx @@ -1,7 +1,7 @@ import {ObjectMeta} from 'argo-ui/src/models/kubernetes'; import {useEffect, useState} from 'react'; import React = require('react'); -import {Link} from '../../../models'; +import {Link, Workflow} from '../../../models'; import {services} from '../services'; import {Button} from './button'; @@ -17,7 +17,7 @@ export const ProcessURL = (url: string, jsonObject: any) => { }); }; -export const Links = ({scope, object, button}: {scope: string; object: {metadata: ObjectMeta; status?: any}; button?: boolean}) => { +export const Links = ({scope, object, button}: {scope: string; object: {metadata: ObjectMeta; workflow?: Workflow; status?: any}; button?: boolean}) => { const [links, setLinks] = useState(); const [error, setError] = useState(); diff --git a/ui/src/app/workflows/components/workflow-details/workflow-details.tsx b/ui/src/app/workflows/components/workflow-details/workflow-details.tsx index 5cad8260497b..4dc81f63cdbc 100644 --- a/ui/src/app/workflows/components/workflow-details/workflow-details.tsx +++ b/ui/src/app/workflows/components/workflow-details/workflow-details.tsx @@ -202,7 +202,18 @@ export const WorkflowDetails = ({history, location, match}: RouteComponentProps< }, [namespace, name]); const openLink = (link: Link) => { - const url = ProcessURL(link.url, workflow); + const object = { + metadata: { + namespace: workflow.metadata.namespace, + name: workflow.metadata.name + }, + workflow, + status: { + startedAt: workflow.status.startedAt, + finishedAt: workflow.status.finishedAt + } + }; + const url = ProcessURL(link.url, object); if ((window.event as MouseEvent).ctrlKey) { window.open(url, '_blank'); diff --git a/ui/src/app/workflows/components/workflow-logs-viewer/workflow-logs-viewer.tsx b/ui/src/app/workflows/components/workflow-logs-viewer/workflow-logs-viewer.tsx index e9faaf30756b..2c1bdb7c68fa 100644 --- a/ui/src/app/workflows/components/workflow-logs-viewer/workflow-logs-viewer.tsx +++ b/ui/src/app/workflows/components/workflow-logs-viewer/workflow-logs-viewer.tsx @@ -122,6 +122,7 @@ export const WorkflowLogsViewer = ({workflow, nodeId, container, archived}: Work namespace: workflow.metadata.namespace, name: podName }, + workflow, status: { startedAt: workflow.status.startedAt, finishedAt: workflow.status.finishedAt diff --git a/ui/src/app/workflows/components/workflow-node-info/workflow-node-info.tsx b/ui/src/app/workflows/components/workflow-node-info/workflow-node-info.tsx index c7d5c7bb5a84..44e35d6fba78 100644 --- a/ui/src/app/workflows/components/workflow-node-info/workflow-node-info.tsx +++ b/ui/src/app/workflows/components/workflow-node-info/workflow-node-info.tsx @@ -132,11 +132,6 @@ const WorkflowNodeSummary = (props: Props) => { }); } - const object = props.workflow; - object.metadata.name = props.node.id; - object.status.startedAt = props.node.startedAt; - object.status.finishedAt = props.node.finishedAt; - const showLogs = (x = 'main') => props.onShowContainerLogs(props.node.id, x); return (
@@ -163,7 +158,23 @@ const WorkflowNodeSummary = (props: Props) => { logs )}{' '} - {props.node.type === 'Pod' && } + {props.node.type === 'Pod' && ( + + )}
);