Commit 64dd6e60 authored by Mike Cardwell's avatar Mike Cardwell

Test labels are now links to their descriptions

parent d0222748
import React, { Component } from 'react';
import Link from '../Link';
import ServerDate from '../../ServerDate';
import moment from 'moment';
......@@ -18,6 +19,7 @@ const style = {
borderRadius: '0.5em',
minHeight: '3.1em',
fontWeight: 'bold',
textDecoration: 'none',
}),
unHit: css({
backgroundColor: '#ccc',
......@@ -78,16 +80,18 @@ export default class TestResultsLabel extends Component {
render() {
const { name, desc, results } = this.props;
const { id, name, desc, results } = this.props;
const styles = [ style.root ];
styles.push(style[results.length ? 'hit' : 'unHit']);
if (this.state.flash) styles.push(style.flash);
const href = `/testDescription?test=${id}`;
return (
<li
<Link
href = { href }
className = { styles.join(' ') }
title = { desc }
>
{ name }
{
......@@ -97,7 +101,7 @@ export default class TestResultsLabel extends Component {
</span>
) : null
}
</li>
</Link>
);
}
......
......@@ -8,9 +8,6 @@ const style = {
root: css({
display: 'flex',
flexWrap: 'wrap',
listStyleType: 'none',
margin: 0,
padding: 0,
maxWidth: '60em',
}),
};
......@@ -20,13 +17,13 @@ export default class TestResults extends Component {
render() {
return (
<ul className={ style.root }>
<div className={ style.root }>
{
this.tests().map(test => (
<Label key={ test.id } { ...test }/>
))
}
</ul>
</div>
);
}
......
......@@ -99,7 +99,9 @@ export default class TestPage extends Component {
onClick = { this.send }
disabled = { submitting }
>
Send Test Email
{
submitting ? 'Sending...' : 'Send Test Email'
}
</button>
)
}
......
import React, { Component } from 'react';
import Wrapper from '../lib/components/Wrapper';
import api from '../lib/api';
let testList = null;
export default class TestDescriptionPage extends Component {
static async getInitialProps({ query }) {
if (!testList) {
try {
testList = await api.get('testList');
} catch (err) {
// @todo: 404?
}
}
return {
...testList[query.test],
};
}
render() {
const { name, desc } = this.props;
return (
<Wrapper title = { `Test: ${name}` }>
<p style={{ whiteSpace: 'pre' }}>
{ desc }
</p>
</Wrapper>
);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment