Skip to content

Commit f8fa61f

Browse files
Implement maintenance badge for front end
1 parent 9c8947c commit f8fa61f

File tree

4 files changed

+53
-1
lines changed

4 files changed

+53
-1
lines changed

app/components/badge-maintenance.js

Lines changed: 33 additions & 0 deletions
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+
});
Lines changed: 7 additions & 0 deletions
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

Lines changed: 12 additions & 1 deletion
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

Lines changed: 1 addition & 0 deletions
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)