forked from coala/git-task-list
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move GitHub Tasks to github namespace `/tasks/github` Add a new gitlab route `/tasks/gitlab` Add a new gitlab serializer Closes coala#38
- Loading branch information
Showing
12 changed files
with
136 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import Controller from '@ember/controller'; | ||
|
||
export default Controller.extend({ | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import TaskModel from './task'; | ||
|
||
export default TaskModel.extend({}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import Route from '@ember/routing/route'; | ||
import {inject} from '@ember/service'; | ||
|
||
export default Route.extend({ | ||
gitlab: inject(), | ||
store: inject(), | ||
model() { | ||
const store = this.get('store'); | ||
return this.get('gitlab').tasks({projects: ['coala/mobans']}).then(data => { | ||
for (let task of data) { | ||
store.pushPayload('gitlab-task', task); | ||
} | ||
return store.peekAll('gitlab-task'); | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import DS from 'ember-data'; | ||
|
||
export default DS.JSONSerializer.extend({ | ||
pushPayload(store, payload) { | ||
const task = {}; | ||
task.id = payload.id | ||
task.bodyText = payload.description | ||
task.commentCount = payload.user_notes_count | ||
task.updatedAt = payload.updated_at | ||
task.url = payload.web_url | ||
task.title = payload.title | ||
|
||
task.author = {} | ||
task.author.url = payload.author.web_url | ||
task.author.login = payload.author.username | ||
task.author.avatarUrl = payload.author.avatar_url | ||
|
||
task.repository = {} | ||
task.repository.nameWithOwner = payload.repository.path_with_namespace | ||
task.repository.url = payload.repository.web_url | ||
|
||
task.isPullRequest = payload._type == 'PullRequest'; | ||
|
||
store.push(this.normalize(store.modelFor('gitlab-task'), task)); | ||
return task; | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// https://gitlab.com/api/v4/projects/coala%2Fmobans/issues?order_by=created_at&state=opened | ||
import AjaxService from 'ember-ajax/services/ajax'; | ||
import RSVP from 'rsvp'; | ||
|
||
const ENDPOINT = 'https://gitlab.com/api/v4'; | ||
const PROJECT_ENDPOINT = ENDPOINT + '/projects/{projectId}' | ||
const ISSUE_ENDPOINT = PROJECT_ENDPOINT + '/issues?order_by=created_at&state=opened&per_page=100'; | ||
|
||
function buildIssuesUrl(projectId) { | ||
return ISSUE_ENDPOINT.replace('{projectId}', encodeURIComponent(projectId)); | ||
} | ||
|
||
function buildProjectUrl(projectId) { | ||
return PROJECT_ENDPOINT.replace('{projectId}', encodeURIComponent(projectId)); | ||
} | ||
|
||
export default AjaxService.extend({ | ||
host: 'https://gitlab.com/', | ||
_issueUrl: '', | ||
init() { | ||
this._super(...arguments); | ||
this.set('headers', {'Private-Token': 'sVfZzagWtemrV-suxYK-'}); | ||
}, | ||
|
||
tasks({projects}) { | ||
let tasks = projects.map((projectId) => { | ||
const embedRepoInfo = (tasks) => { | ||
return new Promise((resolve, reject) => { | ||
this.fetchRepositoryInfo(projectId).then((repoInfo) => { | ||
tasks.map((task) => { | ||
task.repository = repoInfo; | ||
task.type = 'gitlab-task'; | ||
return task; | ||
}) | ||
resolve(tasks) | ||
}).catch((error) => reject(error)); | ||
}); | ||
} | ||
|
||
return this.fetchIssues(projectId).then(embedRepoInfo) | ||
}); | ||
|
||
return RSVP.all(tasks).then((tasks) => { | ||
return tasks.reduce((combinedTasks, tasks) => { | ||
return combinedTasks.concat(tasks); | ||
}, []) | ||
}) | ||
}, | ||
|
||
fetchRepositoryInfo(projectId) { | ||
return this.request(buildProjectUrl(projectId)); | ||
}, | ||
|
||
fetchIssues(projectId) { | ||
return this.request(buildIssuesUrl(projectId)); | ||
}, | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<nav class="panel"> | ||
<p class="panel-tabs is-size-4"> | ||
{{#link-to 'tasks.github'}} | ||
GitHub | ||
{{/link-to}} | ||
<a>|</a> | ||
<a class="is-active" disabled>GitLab</a> | ||
</p> | ||
</nav> | ||
{{#each model as |task|}} | ||
{{task-item task=task}} | ||
<hr> | ||
{{/each}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2384,6 +2384,12 @@ electron-to-chromium@^1.3.47: | |
version "1.3.48" | ||
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.48.tgz#d3b0d8593814044e092ece2108fc3ac9aea4b900" | ||
|
||
ember-ajax@^3.1.0: | ||
version "3.1.0" | ||
resolved "https://registry.yarnpkg.com/ember-ajax/-/ember-ajax-3.1.0.tgz#3db36e67357ef447639517656aeac4bb13e73a9c" | ||
dependencies: | ||
ember-cli-babel "^6.6.0" | ||
|
||
[email protected]: | ||
version "0.3.5" | ||
resolved "https://registry.yarnpkg.com/ember-ast-helpers/-/ember-ast-helpers-0.3.5.tgz#db72afd9bc3de03759720ff7b03d4e3b2c7f2351" | ||
|