Skip to content

Commit

Permalink
Show detailed build information on a separate page
Browse files Browse the repository at this point in the history
  • Loading branch information
shepmaster committed Jul 27, 2017
1 parent 0b69365 commit 937b9c7
Show file tree
Hide file tree
Showing 6 changed files with 174 additions and 0 deletions.
49 changes: 49 additions & 0 deletions app/controllers/crate/build-info.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import Ember from 'ember';

const { computed } = Ember;

function flattenBuildInfo(buildOrdering, builds) {
if (!buildOrdering || !builds) {
return [];
}

return buildOrdering.map(version => {
const thisVersion = builds[version];

return {
version,
'x86_64-apple-darwin': thisVersion['x86_64-apple-darwin'],
'x86_64-pc-windows-gnu': thisVersion['x86_64-pc-windows-gnu'],
'x86_64-pc-windows-msvc': thisVersion['x86_64-pc-windows-msvc'],
'x86_64-unknown-linux-gnu': thisVersion['x86_64-unknown-linux-gnu'],
};
});
}

export default Ember.Controller.extend({
id: computed.alias('model.crate.id'),
name: computed.alias('model.crate.name'),
version: computed.alias('model.num'),
build_info: computed.alias('model.build_info'),
stable_build: computed('build_info.ordering.stable', 'build_info.stable', function() {
const ordering = this.get('build_info.ordering.stable');
const stable = this.get('build_info.stable');

return flattenBuildInfo(ordering, stable);
}),
beta_build: computed('build_info.ordering.beta', 'build_info.beta', function() {
const ordering = this.get('build_info.ordering.beta');
const beta = this.get('build_info.beta');

return flattenBuildInfo(ordering, beta);
}),
nightly_build: computed('build_info.ordering.nightly', 'build_info.nightly', function() {
const ordering = this.get('build_info.ordering.nightly');
const nightly = this.get('build_info.nightly');

return flattenBuildInfo(ordering, nightly);
}),
has_stable_builds: computed.gt('stable_build.length', 0),
has_beta_builds: computed.gt('beta_build.length', 0),
has_nightly_builds: computed.gt('nightly_build.length', 0),
});
13 changes: 13 additions & 0 deletions app/helpers/build-info-pass-fail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Ember from 'ember';

export function buildInfoPassFail(status) {
if (status === true) {
return '✅ Pass';
} else if (status === false) {
return '❌ Fail';
} else {
return '';
}
}

export default Ember.Helper.helper(params => buildInfoPassFail(params[0]));
1 change: 1 addition & 0 deletions app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Router.map(function() {
this.route('download');
this.route('versions');
this.route('version', { path: '/:version_num' });
this.route('build_info', { path: '/:version_num/build_info' });

this.route('reverse_dependencies');

Expand Down
24 changes: 24 additions & 0 deletions app/routes/crate/build_info.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import Ember from 'ember';

export default Ember.Route.extend({
model(params) {
const requestedVersion = params.version_num;
const crate = this.modelFor('crate');

// Find version model
return crate.get('versions')
.then(versions => {
const version = versions.find(version => version.get('num') === requestedVersion);
if (!version) {
this.controllerFor('application').set('nextFlashError',
`Version '${requestedVersion}' of crate '${crate.get('name')}' does not exist`);
}
return version;
});
},

serialize(model) {
let version_num = model ? model.get('num') : '';
return { version_num };
},
});
83 changes: 83 additions & 0 deletions app/templates/crate/build-info.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{{title name}}

<div class='all-versions-back'>
{{#link-to 'crate' id}}&#11013; Back to {{ name }}{{/link-to}}
</div>

<div id='crates-heading'>
<div class="wide">
<div class='info'>
<img class='logo crate' src="/assets/crate.png"/>
<h1>Build info for {{ name }}</h1>
<h2>{{ version }}</h2>
</div>
</div>
</div>

<div id='crate-build-info'>
{{#if has_stable_builds}}
<h3>Stable channel</h3>
<table>
<tr>
<th>Rust Version</th>
<th>Linux 64 bit</th>
<th>macOS 64 bit</th>
<th>Windows (GNU) 64 bit</th>
<th>Windows (MSVC) 64 bit</th>
</tr>
{{#each stable_build as |build|}}
<tr>
<td>{{ build.version }}</td>
<td>{{ build-info-pass-fail build.x86_64-unknown-linux-gnu }}</td>
<td>{{ build-info-pass-fail build.x86_64-apple-darwin }}</td>
<td>{{ build-info-pass-fail build.x86_64-pc-windows-gnu }}</td>
<td>{{ build-info-pass-fail build.x86_64-pc-windows-msvc }}</td>
</tr>
{{/each}}
</table>
{{/if}}

{{#if has_beta_builds}}
<h3>Beta channel</h3>
<table>
<tr>
<th>Rust Version</th>
<th>Linux 64 bit</th>
<th>macOS 64 bit</th>
<th>Windows (GNU) 64 bit</th>
<th>Windows (MSVC) 64 bit</th>
</tr>
{{#each beta_build as |build|}}
<tr>
<td>{{ format-day build.version }}</td>
<td>{{ build-info-pass-fail build.x86_64-unknown-linux-gnu }}</td>
<td>{{ build-info-pass-fail build.x86_64-apple-darwin }}</td>
<td>{{ build-info-pass-fail build.x86_64-pc-windows-gnu }}</td>
<td>{{ build-info-pass-fail build.x86_64-pc-windows-msvc }}</td>
</tr>
{{/each}}
</table>
{{/if}}

{{#if has_nightly_builds}}
<h3>Nightly channel</h3>
<table>
<tr>
<th>Rust Version</th>
<th>Linux 64 bit</th>
<th>macOS 64 bit</th>
<th>Windows (GNU) 64 bit</th>
<th>Windows (MSVC) 64 bit</th>
</tr>
{{#each nightly_build as |build|}}
<tr>
<td>{{ format-day build.version }}</td>
<td>{{ build-info-pass-fail build.x86_64-unknown-linux-gnu }}</td>
<td>{{ build-info-pass-fail build.x86_64-apple-darwin }}</td>
<td>{{ build-info-pass-fail build.x86_64-pc-windows-gnu }}</td>
<td>{{ build-info-pass-fail build.x86_64-pc-windows-msvc }}</td>
</tr>
{{/each}}
</table>
{{/if}}
</div>
4 changes: 4 additions & 0 deletions app/templates/crate/version.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@
on {{ target-icons currentVersion.build_info.latest_positive_results.nightly.targets }}
</div>
{{/if}}

{{#link-to 'crate.build_info' currentVersion.num}}
More build info
{{/link-to}}
</div>
{{/if}}

Expand Down

0 comments on commit 937b9c7

Please sign in to comment.