Add project and issue links in card
This commit is contained in:
parent
b087e50292
commit
477f221b24
|
@ -1,8 +1,13 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
|
const issueURLPattern = /(^https?:\/\/([^\/]))$/i;
|
||||||
|
|
||||||
export class IssueCard extends React.PureComponent {
|
export class IssueCard extends React.PureComponent {
|
||||||
render() {
|
render() {
|
||||||
const { card } = this.props;
|
const { card } = this.props;
|
||||||
|
const issueURLInfo = extractInfoFromIssueURL(card.issue.url);
|
||||||
|
const projectURL = `${issueURLInfo.baseURL}/${issueURLInfo.owner}/${issueURLInfo.projectName}`;
|
||||||
|
const issueURL = `${projectURL}/issues/${card.issue.number}`;
|
||||||
return (
|
return (
|
||||||
<div className="kanboard-card">
|
<div className="kanboard-card">
|
||||||
<div className="box">
|
<div className="box">
|
||||||
|
@ -30,18 +35,28 @@ export class IssueCard extends React.PureComponent {
|
||||||
</div>
|
</div>
|
||||||
<div className="level is-mobile" style={{marginTop:'1rem'}}>
|
<div className="level is-mobile" style={{marginTop:'1rem'}}>
|
||||||
<div className="level-left">
|
<div className="level-left">
|
||||||
<small className="level-item"><a href="#">{card.project}</a></small>
|
<small className="level-item"><a href={projectURL}>{card.project}</a></small>
|
||||||
</div>
|
</div>
|
||||||
<div className="level-right">
|
<div className="level-right">
|
||||||
<a className="level-item" target="_blank" href={card.issue.url.replace('/api/v1/repos', '')}>
|
<a className="level-item" target="_blank" href={issueURL}>
|
||||||
<span className="icon is-small has-text-info">
|
<span className="icon is-small has-text-info">
|
||||||
<i className="fas fa-search" aria-hidden="true"></i>
|
<i className="fas fa-search" aria-hidden="true"></i>
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function extractInfoFromIssueURL(issueURL) {
|
||||||
|
const pattern = /^(https?:\/\/[^\/]+)\/api\/v1\/repos\/([^\/]+)\/([^\/]+)\/.*$/;
|
||||||
|
const matches = pattern.exec(issueURL);
|
||||||
|
return {
|
||||||
|
baseURL: matches[1],
|
||||||
|
owner: matches[2],
|
||||||
|
projectName: matches[3],
|
||||||
|
};
|
||||||
}
|
}
|
Loading…
Reference in New Issue