Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintenence badge front end #952

Merged
merged 1 commit into from
Aug 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions app/components/badge-maintenance.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import Component from '@ember/component';
import { computed } from '@ember/object';
import { alias } from '@ember/object/computed';

export default Component.extend({
tagName: 'span',
classNames: ['badge'],
escapedStatus: computed('badge', function() {
return this.get('badge.attributes.status').replace(/-/g, '--');
}),
none: computed('badge', function() {
return this.get('badge.attributes.status') === 'none'
|| !this.get('badge.attributes.status');
}),
status: alias('badge.attributes.status'),
color: computed('badge', function() {
switch (this.get('badge.attributes.status')) {
case 'actively-developed':
return 'brightgreen';
case 'passively-maintained':
return 'yellowgreen';
case 'as-is':
return 'yellow';
case 'experimental':
return 'blue';
case 'looking-for-maintainer':
return 'orange';
case 'deprecated':
return 'red';
}
}),
text: 'Maintenance intention for this crate'
});
7 changes: 7 additions & 0 deletions app/templates/components/badge-maintenance.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{#unless none}}
<img
src="https://img.shields.io/badge/maintenance-{{escapedStatus}}-{{color}}.svg"
alt="{{text}}"
title="{{text}}"
/>
{{/unless}}
13 changes: 12 additions & 1 deletion mirage/fixtures/crates.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
/* eslint-disable quotes */
export default [{
"badges": [],
"badges": [{
"badge_type": "maintenance",
"attributes": {
"value": "actively-developed"
}
}],
"categories": [],
"created_at": "2014-12-08T02:08:06Z",
"description": "A high-level, Rust idiomatic wrapper around nanomsg.",
Expand Down Expand Up @@ -191,6 +196,12 @@ export default [{
"updated_at": "2015-11-11T00:10:43Z",
"versions": null
}, {
"badges": [{
"badge_type": "maintenance",
"attributes": {
"status": "actively-developed"
}
}],
"created_at": "2014-11-23T09:01:21Z",
"description": "A Kinetic protocol library written in Rust",
"documentation": "https://icorderi.github.io/kinetic-rust/doc/kinetic/",
Expand Down
1 change: 1 addition & 0 deletions tests/acceptance/search-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ test('searching for "rust"', async function(assert) {

hasText(assert, '#crates .row:first .desc .summary', 'A Kinetic protocol library written in Rust');
hasText(assert, '#crates .row:first .downloads', 'All-Time: 225');
findWithAssert('#crates .row:first .desc .info img[alt="Maintenance intention for this crate"]');
});

test('pressing S key to focus the search bar', async function(assert) {
Expand Down