Skip to content

Commit fec6115

Browse files
Merge #952
952: Maintenence badge front end r=carols10cents Start front end work for #704 by creating a maintenance badge component. I'm not quite sure what the alias() function does in ember.js, think it takes out the attributes from the badges for a crate? I'm going to work on all the frontend changes here, since the tests failed when I attempted to add the fixture without the badge component. NOTE: If #996 is approved, I'll have to change this PR to work with it.
2 parents 3e11a69 + f8fa61f commit fec6115

File tree

4 files changed

+53
-1
lines changed

4 files changed

+53
-1
lines changed

app/components/badge-maintenance.js

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import Component from '@ember/component';
2+
import { computed } from '@ember/object';
3+
import { alias } from '@ember/object/computed';
4+
5+
export default Component.extend({
6+
tagName: 'span',
7+
classNames: ['badge'],
8+
escapedStatus: computed('badge', function() {
9+
return this.get('badge.attributes.status').replace(/-/g, '--');
10+
}),
11+
none: computed('badge', function() {
12+
return this.get('badge.attributes.status') === 'none'
13+
|| !this.get('badge.attributes.status');
14+
}),
15+
status: alias('badge.attributes.status'),
16+
color: computed('badge', function() {
17+
switch (this.get('badge.attributes.status')) {
18+
case 'actively-developed':
19+
return 'brightgreen';
20+
case 'passively-maintained':
21+
return 'yellowgreen';
22+
case 'as-is':
23+
return 'yellow';
24+
case 'experimental':
25+
return 'blue';
26+
case 'looking-for-maintainer':
27+
return 'orange';
28+
case 'deprecated':
29+
return 'red';
30+
}
31+
}),
32+
text: 'Maintenance intention for this crate'
33+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{{#unless none}}
2+
<img
3+
src="https://img.shields.io/badge/maintenance-{{escapedStatus}}-{{color}}.svg"
4+
alt="{{text}}"
5+
title="{{text}}"
6+
/>
7+
{{/unless}}

mirage/fixtures/crates.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
/* eslint-disable quotes */
22
export default [{
3-
"badges": [],
3+
"badges": [{
4+
"badge_type": "maintenance",
5+
"attributes": {
6+
"value": "actively-developed"
7+
}
8+
}],
49
"categories": [],
510
"created_at": "2014-12-08T02:08:06Z",
611
"description": "A high-level, Rust idiomatic wrapper around nanomsg.",
@@ -191,6 +196,12 @@ export default [{
191196
"updated_at": "2015-11-11T00:10:43Z",
192197
"versions": null
193198
}, {
199+
"badges": [{
200+
"badge_type": "maintenance",
201+
"attributes": {
202+
"status": "actively-developed"
203+
}
204+
}],
194205
"created_at": "2014-11-23T09:01:21Z",
195206
"description": "A Kinetic protocol library written in Rust",
196207
"documentation": "https://icorderi.github.io/kinetic-rust/doc/kinetic/",

tests/acceptance/search-test.js

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ test('searching for "rust"', async function(assert) {
2525

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

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

0 commit comments

Comments
 (0)