[JENKINS-35890] Developer can click the commit ID on the Changes tab of the Run result screen to view the full commit details (#423)

* [JENKINS-35890] Link in changeset to the configured url

* [JENKINS-35890] Only create link when we have a url, otherwise we render only id

* [JENKINS-35890] remove test string

* [JENKINS-35890] Fix tests
This commit is contained in:
Thorsten Scherler 2016-08-23 16:49:12 +02:00 committed by GitHub
parent 9ac41d292a
commit 67cc62155e
2 changed files with 18 additions and 11 deletions

View File

@ -3,14 +3,21 @@ import { CommitHash, EmptyStateView, ReadableDate, Table } from '@jenkins-cd/des
const { object } = PropTypes;
export default class RunDetailsChanges extends Component {
renderEmptyState() {
return (
<EmptyStateView tightSpacing>
<p>There are no changes for this pipeline run.</p>
</EmptyStateView>
);
const CommitLink = (commit) => {
if (commit.url) {
return (<a href={commit.url}>
<CommitHash commitId={commit.commitId} />
</a>);
}
return <CommitHash commitId={commit.commitId} />;
};
const EmptyState = () => (<EmptyStateView tightSpacing>
<p>There are no changes for this pipeline run.</p>
</EmptyStateView>)
;
export default class RunDetailsChanges extends Component {
render() {
const { result } = this.props;
@ -22,7 +29,7 @@ export default class RunDetailsChanges extends Component {
const { changeSet } = result;
if (!changeSet || !changeSet.length) {
return this.renderEmptyState();
return <EmptyState />;
}
const headers = [
@ -36,7 +43,7 @@ export default class RunDetailsChanges extends Component {
<Table headers={headers} className="changeset-table fixed">
{ changeSet.map(commit => (
<tr key={commit.commitId}>
<td><CommitHash commitId={commit.commitId} /></td>
<td><CommitLink {...commit} /></td>
<td>{commit.author.fullName}</td>
<td className="multipleLines">{commit.msg}</td>
<td><ReadableDate date={commit.timestamp} liveUpdate /></td>

View File

@ -36,7 +36,7 @@ describe('RunDetailsChanges', () => {
});
it('renders EmptyStateView', () => {
assert.equal(output.type.name, 'EmptyStateView');
assert.equal(output.type.name, 'EmptyState');
});
});
@ -57,7 +57,7 @@ describe('RunDetailsChanges', () => {
assert.equal(tree.everySubTree('tr').length, 2);
const cols = tree.subTree('tr').everySubTree('td');
assert.equal(cols[0].text(), '<CommitHash />');
assert.equal(cols[0].text(), '<CommitLink />');
assert.equal(cols[1].text(), 'tscherler');
assert.equal(cols[2].text(), 'Update Jenkinsfile');
assert.equal(cols[3].text(), '<ReadableDate />');