Skip to content

Commit 95fdea6

Browse files
committed
graphql: Use graphql for GitHub
Use graphql for GitHub API Add support to coala & 52North Add GitHub token modal Closes #34
1 parent e706d74 commit 95fdea6

Some content is hidden

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

57 files changed

+981
-1832
lines changed

Diff for: app/adapters/application.js

-12
This file was deleted.

Diff for: app/adapters/issue.js

-25
This file was deleted.

Diff for: app/adapters/repository.js

-14
This file was deleted.

Diff for: app/components/settings-modal.js

+28
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+
6+
export default Component.extend({
7+
// Services
8+
userSettings: inject(),
9+
10+
// Properties
11+
token_github_com: oneWay('userSettings.tokens.github_com'),
12+
13+
init() {
14+
this._super(...arguments);
15+
},
16+
actions: {
17+
hideModal() {
18+
this.set('isActive', false);
19+
this.userSettings.setSetting('githubTokenModalSeen', true);
20+
},
21+
saveSettings() {
22+
this.userSettings.setToken('github_com', this.get('token_github_com'));
23+
},
24+
},
25+
classNames: ['modal'],
26+
classNameBindings: ['isActive'],
27+
isActive: false
28+
});

Diff for: app/components/task-item.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import Component from '@ember/component';
2+
3+
export default Component.extend({
4+
init() {
5+
this._super(...arguments);
6+
},
7+
didInsertElement() {
8+
this.$().linkify({
9+
validate: {
10+
url: function (value) {
11+
return /^(http|ftp)s?:\/\//.test(value);
12+
}
13+
},
14+
formatHref: function (href, type) {
15+
if (type === 'mention') {
16+
href = 'https://github.com/' +
17+
href.substring(1);
18+
}
19+
return href;
20+
}
21+
});
22+
}
23+
});

Diff for: app/controllers/application.js

+2-9
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 } });
8-
},
9-
toggleSidenav() {
10-
return this.set('toggleSidenav', !this.get('toggleSidenav'));
11-
},
12-
searchByOrg(org) {
13-
this.send('searchIssues', org.query.q);
5+
showSettingsModal() {
6+
this.set('showModal', true);
147
}
158
}
169
});

Diff for: app/controllers/issues.js

-26
This file was deleted.

Diff for: app/controllers/tasks.js

+7
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+
});

Diff for: app/data/organizations.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
export default {
2+
coala: {
3+
name: 'coala association e.V.',
4+
trackers: [
5+
{
6+
type: 'github',
7+
identifier: 'coala'
8+
},
9+
{
10+
type: 'gitlab',
11+
identifier: 'coala'
12+
}
13+
]
14+
},
15+
"52-north-initiative-for-geospatial-open-source-software-gmbh": {
16+
name: '52° North Initiative for Geospatial Open Source Software GmbH',
17+
trackers: [
18+
{
19+
type: 'github',
20+
identifier: '52North'
21+
}
22+
]
23+
}
24+
}

Diff for: app/graphql/github.js

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import {isIterable} from '../utils/commons';
2+
3+
export const tasksQuery = `query($searchQuery: String!){
4+
rateLimit {
5+
remaining
6+
}
7+
search(query: $searchQuery, type: ISSUE, first: 100 ) {
8+
nodes {
9+
type: __typename
10+
... on Issue {
11+
title
12+
author {
13+
url
14+
login
15+
avatarUrl
16+
}
17+
bodyText
18+
url
19+
updatedAt
20+
repository {
21+
nameWithOwner
22+
owner {
23+
avatarUrl
24+
}
25+
url
26+
}
27+
comments {
28+
totalCount
29+
}
30+
}
31+
... on PullRequest {
32+
title
33+
author {
34+
url
35+
login
36+
avatarUrl
37+
}
38+
bodyText
39+
url
40+
updatedAt
41+
repository {
42+
nameWithOwner
43+
owner {
44+
avatarUrl
45+
}
46+
url
47+
}
48+
comments {
49+
totalCount
50+
}
51+
}
52+
}
53+
}
54+
}`
55+
56+
export const queryBuilder = function queryBuilder({orgs}) {
57+
let queries = ["sort:updated-desc", "state:open"];
58+
if(isIterable(orgs)) {
59+
queries = orgs.reduce((a,b) => [...a, "user:" + b], queries)
60+
}
61+
return queries.join(" ")
62+
}

Diff for: app/helpers/time-ago.js

+8
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);

Diff for: app/helpers/truncate-text.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { helper } from '@ember/component/helper';
2+
3+
function truncateText(params, hash) {
4+
const [ value ] = params;
5+
const { limit } = hash;
6+
let text = '';
7+
8+
if (value != null && value.length > 0) {
9+
text = value.substr(0, limit);
10+
11+
if (value.length > limit) {
12+
text += '...';
13+
}
14+
}
15+
16+
return text;
17+
}
18+
19+
export default helper(truncateText);

Diff for: app/models/.gitkeep

Whitespace-only changes.

Diff for: app/models/issue.js

-34
This file was deleted.

Diff for: app/models/repository.js

-74
This file was deleted.

Diff for: app/models/user.js

-5
This file was deleted.

0 commit comments

Comments
 (0)