Skip to content

Commit b09fdec

Browse files
committed
Use GraphQL for GitHub
Use GraphQL for GitHub API Add support to coala & 52North Add GitHub token modal Rename implementation of Issues to Tasks Use Bulma for task list Regression: Remove Repository and User Model Remove Search Bar Closes #34
1 parent 0ddb626 commit b09fdec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1477
-1917
lines changed

app/adapters/application.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

app/adapters/issue.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

app/adapters/repository.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

app/components/search-card.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

app/components/settings-modal.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import Component from '@ember/component';
2+
import { oneWay } from '@ember/object/computed';
3+
import { inject } from '@ember/service';
4+
5+
export default Component.extend({
6+
// Services
7+
userSettings: inject(),
8+
9+
// Properties
10+
token_github_com: oneWay('userSettings.tokens.github_com'),
11+
12+
init(...args) {
13+
this._super(...args);
14+
},
15+
actions: {
16+
hideModal() {
17+
this.set('isActive', false);
18+
this.userSettings.setSetting('githubTokenModalSeen', true);
19+
},
20+
saveSettings() {
21+
this.userSettings.setToken('github_com', this.get('token_github_com'));
22+
this.set('isActive', false);
23+
},
24+
},
25+
classNames: ['modal'],
26+
classNameBindings: ['isActive'],
27+
isActive: false,
28+
});

app/components/task-item.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import Component from '@ember/component';
2+
import { calculateForegroundColor } from '../utils/label-utils';
3+
4+
export default Component.extend({
5+
init(...args) {
6+
this._super(...args);
7+
},
8+
didReceiveAttrs() {
9+
this.get('task').labels.map((label) => {
10+
const decoratedLabel = label;
11+
decoratedLabel.fontColor = calculateForegroundColor(label.color);
12+
return decoratedLabel;
13+
});
14+
},
15+
didInsertElement() {
16+
this.$().linkify({
17+
validate: {
18+
url(value) {
19+
return /^(http|ftp)s?:\/\//.test(value);
20+
},
21+
},
22+
formatHref(href, type) {
23+
if (type === 'mention') {
24+
return `https://github.com/${
25+
href.substring(1)}`;
26+
}
27+
return href;
28+
},
29+
});
30+
},
31+
});

app/controllers/application.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
import Controller from '@ember/controller';
22

33
export default Controller.extend({
4-
toggleSidenav: true,
54
actions: {
6-
searchIssues(query) {
7-
this.transitionToRoute('issues', { queryParams: { q: query } });
5+
showSettingsModal() {
6+
this.set('showModal', true);
87
},
9-
toggleSidenav() {
10-
return this.set('toggleSidenav', !this.get('toggleSidenav'));
11-
},
12-
searchByOrg(org) {
13-
this.send('searchIssues', org.query.q);
14-
}
15-
}
8+
},
169
});

app/controllers/issues.js

Lines changed: 0 additions & 26 deletions
This file was deleted.

app/controllers/tasks.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import Controller from '@ember/controller';
2+
import { inject } from '@ember/service';
3+
4+
export default Controller.extend({
5+
organizations: inject(),
6+
queryParams: ['org'],
7+
});

app/data/organizations.js

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
export default {
2+
coala: {
3+
name: 'coala association e.V.',
4+
trackers: [
5+
{
6+
type: 'github',
7+
identifier: 'coala',
8+
defaultLabels: [
9+
'difficulty/newcomer',
10+
],
11+
},
12+
{
13+
type: 'gitlab',
14+
identifier: 'coala',
15+
},
16+
],
17+
},
18+
'52-north-initiative-for-geospatial-open-source-software-gmbh': {
19+
name: '52° North Initiative for Geospatial Open Source Software GmbH',
20+
trackers: [
21+
{
22+
type: 'github',
23+
identifier: '52North',
24+
},
25+
],
26+
},
27+
discourse: {
28+
name: 'Discourse',
29+
trackers: [
30+
{
31+
type: 'github',
32+
identifier: 'discourse',
33+
},
34+
],
35+
},
36+
wikimedia: {
37+
name: 'Wikimedia',
38+
trackers: [
39+
{
40+
type: 'github',
41+
identifier: 'wikimedia',
42+
},
43+
],
44+
},
45+
opensuse: {
46+
name: 'Opensuse',
47+
trackers: [
48+
{
49+
type: 'github',
50+
identifier: 'opensuse',
51+
},
52+
],
53+
},
54+
elm: {
55+
name: 'Elm',
56+
trackers: [
57+
{
58+
type: 'github',
59+
identifier: 'elm-lang',
60+
},
61+
],
62+
},
63+
cadasta: {
64+
name: 'Cadasta',
65+
trackers: [
66+
{
67+
type: 'github',
68+
identifier: 'cadasta',
69+
},
70+
],
71+
},
72+
enketo: {
73+
name: 'Enketo',
74+
trackers: [
75+
{
76+
type: 'github',
77+
identifier: 'enketo',
78+
},
79+
],
80+
},
81+
kobotoolbox: {
82+
name: 'Kobotoolbox',
83+
trackers: [
84+
{
85+
type: 'github',
86+
identifier: 'kobotoolbox',
87+
},
88+
],
89+
},
90+
movingblocks: {
91+
name: 'Movingblocks',
92+
trackers: [
93+
{
94+
type: 'github',
95+
identifier: 'movingblocks',
96+
},
97+
],
98+
},
99+
nexB: {
100+
name: 'Nexb',
101+
trackers: [
102+
{
103+
type: 'github',
104+
identifier: 'nexB',
105+
},
106+
],
107+
},
108+
};

app/graphql/github.js

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import { warn } from '@ember/debug';
2+
import { isIterable } from '../utils/commons';
3+
4+
export const tasksQuery = `query($searchQuery: String!){
5+
search(query: $searchQuery, type: ISSUE, first: 100 ) {
6+
nodes {
7+
_type: __typename
8+
... on Issue {
9+
id
10+
author {
11+
...authorFragment
12+
}
13+
bodyText
14+
comments {
15+
totalCount
16+
}
17+
labels {
18+
...labelsFragment
19+
}
20+
repository {
21+
...repositoryFragment
22+
}
23+
title
24+
updatedAt
25+
url
26+
}
27+
... on PullRequest {
28+
id
29+
author {
30+
...authorFragment
31+
}
32+
bodyText
33+
comments {
34+
totalCount
35+
}
36+
labels {
37+
...labelsFragment
38+
}
39+
repository {
40+
...repositoryFragment
41+
}
42+
title
43+
updatedAt
44+
url
45+
}
46+
}
47+
}
48+
}
49+
fragment repositoryFragment on Repository {
50+
nameWithOwner
51+
owner {
52+
avatarUrl
53+
}
54+
url
55+
}
56+
fragment labelsFragment on LabelConnection {
57+
totalCount
58+
nodes {
59+
color
60+
description
61+
id
62+
name
63+
}
64+
}
65+
fragment authorFragment on Actor {
66+
url
67+
login
68+
avatarUrl
69+
}`;
70+
71+
// return an array of github search queries, e.g [paramKey:paramValue[0], ...,
72+
// paramKey:paramValue[-1]]
73+
function buildParams(paramKey, paramValue) {
74+
if (isIterable(paramValue)) {
75+
return paramValue.reduce((seed, v) => [...seed, `${paramKey}:${v}`], []);
76+
} else if (paramValue) {
77+
return [`${paramKey}:${paramValue}`];
78+
}
79+
return [];
80+
}
81+
82+
export function queryBuilder({ orgs, labels }) {
83+
let queries = ['sort:updated-desc', 'state:open', 'no:assignee', 'is:issue'];
84+
if (!orgs) {
85+
warn('Org is not defined.');
86+
} else {
87+
queries = queries.concat(buildParams('user', orgs));
88+
}
89+
if (labels) {
90+
queries = queries.concat(buildParams('label', labels));
91+
}
92+
return queries.join(' ');
93+
}

app/helpers/time-ago.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { helper } from '@ember/component/helper';
2+
import moment from 'moment';
3+
4+
export function timeAgo(params) {
5+
return moment(params[0]).fromNow();
6+
}
7+
8+
export default helper(timeAgo);

0 commit comments

Comments
 (0)