Skip to content

Commit

Permalink
Use graphql for GitHub
Browse files Browse the repository at this point in the history
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 2017's GSoC Organization

Closes coala#34
  • Loading branch information
bekicot committed Jun 1, 2018
1 parent e706d74 commit 55589c3
Show file tree
Hide file tree
Showing 53 changed files with 981 additions and 1,719 deletions.
12 changes: 0 additions & 12 deletions app/adapters/application.js

This file was deleted.

25 changes: 0 additions & 25 deletions app/adapters/issue.js

This file was deleted.

14 changes: 0 additions & 14 deletions app/adapters/repository.js

This file was deleted.

28 changes: 28 additions & 0 deletions app/components/settings-modal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import Component from '@ember/component';
import {oneWay} from '@ember/object/computed';
import {inject} from '@ember/service';


export default Component.extend({
// Services
userSettings: inject(),

// Properties
token_github_com: oneWay('userSettings.tokens.github_com'),

init() {
this._super(...arguments);
},
actions: {
hideModal() {
this.set('isActive', false);
this.userSettings.setSetting('githubTokenModalSeen', true);
},
saveSettings() {
this.userSettings.setToken('github_com', this.get('token_github_com'));
},
},
classNames: ['modal'],
classNameBindings: ['isActive'],
isActive: false
});
23 changes: 23 additions & 0 deletions app/components/task-item.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import Component from '@ember/component';

export default Component.extend({
init() {
this._super(...arguments);
},
didInsertElement() {
this.$().linkify({
validate: {
url: function (value) {
return /^(http|ftp)s?:\/\//.test(value);
}
},
formatHref: function (href, type) {
if (type === 'mention') {
href = 'https://github.com/' +
href.substring(1);
}
return href;
}
});
}
});
11 changes: 2 additions & 9 deletions app/controllers/application.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import Controller from '@ember/controller';

export default Controller.extend({
toggleSidenav: true,
actions: {
searchIssues(query) {
this.transitionToRoute('issues', { queryParams: { q: query } });
},
toggleSidenav() {
return this.set('toggleSidenav', !this.get('toggleSidenav'));
},
searchByOrg(org) {
this.send('searchIssues', org.query.q);
showSettingsModal() {
this.set('showModal', true);
}
}
});
26 changes: 0 additions & 26 deletions app/controllers/issues.js

This file was deleted.

7 changes: 7 additions & 0 deletions app/controllers/tasks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Controller from '@ember/controller';
import {inject} from '@ember/service';

export default Controller.extend({
organizations: inject(),
queryParams: ['org']
});
24 changes: 24 additions & 0 deletions app/data/organizations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export default {
coala: {
name: 'coala association e.V.',
trackers: [
{
type: 'github',
identifier: 'coala'
},
{
type: 'gitlab',
identifier: 'coala'
}
]
},
"52-north-initiative-for-geospatial-open-source-software-gmbh": {
name: '52° North Initiative for Geospatial Open Source Software GmbH',
trackers: [
{
type: 'github',
identifier: '52North'
}
]
}
}
62 changes: 62 additions & 0 deletions app/graphql/github.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import {isIterable} from '../utils/commons';

export const tasksQuery = `query($searchQuery: String!){
rateLimit {
remaining
}
search(query: $searchQuery, type: ISSUE, first: 100 ) {
nodes {
type: __typename
... on Issue {
title
author {
url
login
avatarUrl
}
bodyText
url
updatedAt
repository {
nameWithOwner
owner {
avatarUrl
}
url
}
comments {
totalCount
}
}
... on PullRequest {
title
author {
url
login
avatarUrl
}
bodyText
url
updatedAt
repository {
nameWithOwner
owner {
avatarUrl
}
url
}
comments {
totalCount
}
}
}
}
}`

export const queryBuilder = function queryBuilder({orgs}) {
let queries = ["sort:updated-desc", "state:open"];
if(isIterable(orgs)) {
queries = orgs.reduce((a,b) => [...a, "user:" + b], queries)
}
return queries.join(" ")
}
8 changes: 8 additions & 0 deletions app/helpers/time-ago.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { helper } from '@ember/component/helper';
import moment from 'moment';

export function timeAgo(params) {
return moment(params[0]).fromNow();
}

export default helper(timeAgo);
19 changes: 19 additions & 0 deletions app/helpers/truncate-text.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { helper } from '@ember/component/helper';

function truncateText(params, hash) {
const [ value ] = params;
const { limit } = hash;
let text = '';

if (value != null && value.length > 0) {
text = value.substr(0, limit);

if (value.length > limit) {
text += '...';
}
}

return text;
}

export default helper(truncateText);
33 changes: 0 additions & 33 deletions app/organizations.js

This file was deleted.

1 change: 1 addition & 0 deletions app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Router.map(function() {
this.route('issues', function() {
this.route('issue', {path: "/post/:issue_id"});
});
this.route('tasks');
});

export default Router;
27 changes: 12 additions & 15 deletions app/routes/application.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
import {inject} from '@ember/service';
import Route from '@ember/routing/route';
import organizationList from '../organizations';

export default Route.extend({
queryParams: {
q: {
refreshModel: true
}
},
actions: {
searchIssues(query) {
this.transitionTo('issues', { queryParams: { q: query} });
}
},
model(params) {
return params;
// services
userSettings: inject(),
github: inject(),
organizations: inject(),

model() {
return this.get('organizations').get('list');
},

setupController(controller, model) {
controller.set('organizations', organizationList);
controller.set('searchParams', model.q)
// show modal when user has no github token
if(!this.userSettings.get('githubTokenModalSeen'))
controller.set('showModal', !this.userSettings.tokens.get('github_com'));
this._super(controller, model);
}

Expand Down
17 changes: 0 additions & 17 deletions app/routes/issues.js

This file was deleted.

Loading

0 comments on commit 55589c3

Please sign in to comment.