Skip to content

Commit aacad02

Browse files
shepmastercarols10cents
authored andcommitted
Show detailed build information on a separate page
1 parent 7232096 commit aacad02

File tree

6 files changed

+174
-0
lines changed

6 files changed

+174
-0
lines changed

app/controllers/crate/build-info.js

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import Ember from 'ember';
2+
3+
const { computed } = Ember;
4+
5+
function flattenBuildInfo(buildOrdering, builds) {
6+
if (!buildOrdering || !builds) {
7+
return [];
8+
}
9+
10+
return buildOrdering.map(version => {
11+
const thisVersion = builds[version];
12+
13+
return {
14+
version,
15+
'x86_64-apple-darwin': thisVersion['x86_64-apple-darwin'],
16+
'x86_64-pc-windows-gnu': thisVersion['x86_64-pc-windows-gnu'],
17+
'x86_64-pc-windows-msvc': thisVersion['x86_64-pc-windows-msvc'],
18+
'x86_64-unknown-linux-gnu': thisVersion['x86_64-unknown-linux-gnu'],
19+
};
20+
});
21+
}
22+
23+
export default Ember.Controller.extend({
24+
id: computed.alias('model.crate.id'),
25+
name: computed.alias('model.crate.name'),
26+
version: computed.alias('model.num'),
27+
build_info: computed.alias('model.build_info'),
28+
stable_build: computed('build_info.ordering.stable', 'build_info.stable', function() {
29+
const ordering = this.get('build_info.ordering.stable');
30+
const stable = this.get('build_info.stable');
31+
32+
return flattenBuildInfo(ordering, stable);
33+
}),
34+
beta_build: computed('build_info.ordering.beta', 'build_info.beta', function() {
35+
const ordering = this.get('build_info.ordering.beta');
36+
const beta = this.get('build_info.beta');
37+
38+
return flattenBuildInfo(ordering, beta);
39+
}),
40+
nightly_build: computed('build_info.ordering.nightly', 'build_info.nightly', function() {
41+
const ordering = this.get('build_info.ordering.nightly');
42+
const nightly = this.get('build_info.nightly');
43+
44+
return flattenBuildInfo(ordering, nightly);
45+
}),
46+
has_stable_builds: computed.gt('stable_build.length', 0),
47+
has_beta_builds: computed.gt('beta_build.length', 0),
48+
has_nightly_builds: computed.gt('nightly_build.length', 0),
49+
});

app/helpers/build-info-pass-fail.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import Ember from 'ember';
2+
3+
export function buildInfoPassFail(status) {
4+
if (status === true) {
5+
return '✅ Pass';
6+
} else if (status === false) {
7+
return '❌ Fail';
8+
} else {
9+
return '';
10+
}
11+
}
12+
13+
export default Ember.Helper.helper(params => buildInfoPassFail(params[0]));

app/router.js

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Router.map(function() {
1818
this.route('download');
1919
this.route('versions');
2020
this.route('version', { path: '/:version_num' });
21+
this.route('build_info', { path: '/:version_num/build_info' });
2122

2223
this.route('reverse_dependencies');
2324

app/routes/crate/build_info.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import Ember from 'ember';
2+
3+
export default Ember.Route.extend({
4+
model(params) {
5+
const requestedVersion = params.version_num;
6+
const crate = this.modelFor('crate');
7+
8+
// Find version model
9+
return crate.get('versions')
10+
.then(versions => {
11+
const version = versions.find(version => version.get('num') === requestedVersion);
12+
if (!version) {
13+
this.controllerFor('application').set('nextFlashError',
14+
`Version '${requestedVersion}' of crate '${crate.get('name')}' does not exist`);
15+
}
16+
return version;
17+
});
18+
},
19+
20+
serialize(model) {
21+
let version_num = model ? model.get('num') : '';
22+
return { version_num };
23+
},
24+
});

app/templates/crate/build-info.hbs

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
{{title name}}
2+
3+
<div class='all-versions-back'>
4+
{{#link-to 'crate' id}}&#11013; Back to {{ name }}{{/link-to}}
5+
</div>
6+
7+
<div id='crates-heading'>
8+
<div class="wide">
9+
<div class='info'>
10+
<img class='logo crate' src="/assets/crate.png"/>
11+
<h1>Build info for {{ name }}</h1>
12+
<h2>{{ version }}</h2>
13+
</div>
14+
</div>
15+
</div>
16+
17+
<div id='crate-build-info'>
18+
{{#if has_stable_builds}}
19+
<h3>Stable channel</h3>
20+
<table>
21+
<tr>
22+
<th>Rust Version</th>
23+
<th>Linux 64 bit</th>
24+
<th>macOS 64 bit</th>
25+
<th>Windows (GNU) 64 bit</th>
26+
<th>Windows (MSVC) 64 bit</th>
27+
</tr>
28+
{{#each stable_build as |build|}}
29+
<tr>
30+
<td>{{ build.version }}</td>
31+
<td>{{ build-info-pass-fail build.x86_64-unknown-linux-gnu }}</td>
32+
<td>{{ build-info-pass-fail build.x86_64-apple-darwin }}</td>
33+
<td>{{ build-info-pass-fail build.x86_64-pc-windows-gnu }}</td>
34+
<td>{{ build-info-pass-fail build.x86_64-pc-windows-msvc }}</td>
35+
</tr>
36+
{{/each}}
37+
</table>
38+
{{/if}}
39+
40+
{{#if has_beta_builds}}
41+
<h3>Beta channel</h3>
42+
<table>
43+
<tr>
44+
<th>Rust Version</th>
45+
<th>Linux 64 bit</th>
46+
<th>macOS 64 bit</th>
47+
<th>Windows (GNU) 64 bit</th>
48+
<th>Windows (MSVC) 64 bit</th>
49+
</tr>
50+
{{#each beta_build as |build|}}
51+
<tr>
52+
<td>{{ format-day build.version }}</td>
53+
<td>{{ build-info-pass-fail build.x86_64-unknown-linux-gnu }}</td>
54+
<td>{{ build-info-pass-fail build.x86_64-apple-darwin }}</td>
55+
<td>{{ build-info-pass-fail build.x86_64-pc-windows-gnu }}</td>
56+
<td>{{ build-info-pass-fail build.x86_64-pc-windows-msvc }}</td>
57+
</tr>
58+
{{/each}}
59+
</table>
60+
{{/if}}
61+
62+
{{#if has_nightly_builds}}
63+
<h3>Nightly channel</h3>
64+
<table>
65+
<tr>
66+
<th>Rust Version</th>
67+
<th>Linux 64 bit</th>
68+
<th>macOS 64 bit</th>
69+
<th>Windows (GNU) 64 bit</th>
70+
<th>Windows (MSVC) 64 bit</th>
71+
</tr>
72+
{{#each nightly_build as |build|}}
73+
<tr>
74+
<td>{{ format-day build.version }}</td>
75+
<td>{{ build-info-pass-fail build.x86_64-unknown-linux-gnu }}</td>
76+
<td>{{ build-info-pass-fail build.x86_64-apple-darwin }}</td>
77+
<td>{{ build-info-pass-fail build.x86_64-pc-windows-gnu }}</td>
78+
<td>{{ build-info-pass-fail build.x86_64-pc-windows-msvc }}</td>
79+
</tr>
80+
{{/each}}
81+
</table>
82+
{{/if}}
83+
</div>

app/templates/crate/version.hbs

+4
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@
147147
on {{ target-icons currentVersion.build_info.latest_positive_results.nightly.targets }}
148148
</div>
149149
{{/if}}
150+
151+
{{#link-to 'crate.build_info' currentVersion.num}}
152+
More build info
153+
{{/link-to}}
150154
</div>
151155
{{/if}}
152156

0 commit comments

Comments
 (0)