Skip to content

Commit

Permalink
feat(ui): extend link, add workflow in object
Browse files Browse the repository at this point in the history
Signed-off-by: Tianchu Zhao <evantczhao@gmail.com>
  • Loading branch information
tczhao committed Apr 14, 2021
1 parent c0966f5 commit 095bd40
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 15 deletions.
2 changes: 1 addition & 1 deletion api/jsonschema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
Expand Down
2 changes: 1 addition & 1 deletion api/openapi-spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/workflow/v1alpha1/generated.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/apis/workflow/v1alpha1/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
2 changes: 1 addition & 1 deletion pkg/apis/workflow/v1alpha1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,17 @@ export class ArchivedWorkflowDetails extends BasePage<RouteComponentProps<any>,
}

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);
}
}
4 changes: 2 additions & 2 deletions ui/src/app/shared/components/links.tsx
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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<Link[]>();
const [error, setError] = useState<Error>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div className='white-box'>
Expand All @@ -163,7 +158,23 @@ const WorkflowNodeSummary = (props: Props) => {
logs
</Button>
)}{' '}
{props.node.type === 'Pod' && <Links button={true} object={object} scope='pod' />}
{props.node.type === 'Pod' && (
<Links
button={true}
object={{
metadata: {
namespace: props.workflow.metadata.namespace,
name: props.node.id
},
workflow: props.workflow,
status: {
startedAt: props.node.startedAt,
finishedAt: props.node.finishedAt
}
}}
scope='pod'
/>
)}
</div>
</div>
);
Expand Down

0 comments on commit 095bd40

Please sign in to comment.