-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP]Support GitLab #44
base: master
Are you sure you want to change the base?
Conversation
No code can be merged until the license issue is resolved. |
app/controllers/tasks.js
Outdated
@@ -4,4 +4,5 @@ import {inject} from '@ember/service'; | |||
export default Controller.extend({ | |||
organizations: inject(), | |||
queryParams: ['org'], | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Irrelevant diff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Irrelevant diff
app/templates/tasks.hbs
Outdated
{{#link-to (query-params org=slug)}} | ||
{{org.name}} | ||
{{/link-to}} | ||
</li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep the indent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, i will change. That's silly mistake
app/utils/task-utils.js
Outdated
@@ -0,0 +1,9 @@ | |||
export const getTrackerIdentifiers = (org, trackerType) => { | |||
if(org && org.trackers){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space before (
and after )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
app/services/user-settings.js
Outdated
const settings = getObject(SETTINGS_KEY) || {}; | ||
|
||
// Only set property defined in PROPERTIES | ||
for(let property of PROPERTIES) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've got some for loops with a space between the for
and the opening parenthesis, and some without. Should be fixed with the .coafile, but I believe we usually go with a space.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bekicot You should've added style rules to .eslintrc like I said
app/routes/tasks/gitlab.js
Outdated
store: inject(), | ||
model() { | ||
const store = this.get('store'); | ||
return this.get('gitlab').tasks({projects: ['coala/mobans']}).then(data => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does this have a coala specific project reference in here?
app/templates/tasks.hbs
Outdated
@@ -13,7 +13,7 @@ | |||
Organizations | |||
</p> | |||
<ul class="menu-list"> | |||
{{#each-in organizations.list as |slug org| }} | |||
{{#each-in organizations.list as |slug org|}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be fix in the first PR, if it is important
see #33 (comment)
app/services/gitlab.js
Outdated
_issueUrl: '', | ||
init() { | ||
this._super(...arguments); | ||
this.set('headers', {'Private-Token': 'sVfZzagWtemrV-suxYK-'}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this shouldnt be here ... ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
omg 😲
app/services/gitlab.js
Outdated
let tasks = projects.map((projectId) => { | ||
const embedRepoInfo = (tasks) => { | ||
return new Promise((resolve, reject) => { | ||
this.fetchRepositoryInfo(projectId).then((repoInfo) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A promise can be chained, no need to explicitly make Promise
app/services/gitlab.js
Outdated
const embedRepoInfo = (tasks) => { | ||
return new Promise((resolve, reject) => { | ||
this.fetchRepositoryInfo(projectId).then((repoInfo) => { | ||
tasks.map((task) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you return tasks.map
the result will be in the resolved Promise.
app/services/gitlab.js
Outdated
task.type = 'gitlab-task'; | ||
return task; | ||
}) | ||
resolve(tasks) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this doesn't return the mapped tasks because map
creates new array not modify it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it does, but .forEach
is more appropriate than .map
app/serializers/gitlab-task.js
Outdated
task.repository.nameWithOwner = payload.repository.path_with_namespace | ||
task.repository.url = payload.repository.web_url | ||
|
||
task.isPullRequest = payload._type == 'PullRequest'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
===
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's still quite a few styling things that would be easily caught and fixed with eslint
app/components/task-item.js
Outdated
formatHref: function (href, type) { | ||
if (type === 'mention') { | ||
href = 'https://github.com/' + | ||
href.substring(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be over the limit, why split into multiple lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No reason, you are right.
app/components/task-item.js
Outdated
validate: { | ||
url: function (value) { | ||
return /^(http|ftp)s?:\/\//.test(value); | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be a pretty arrow function:
url: (value) => /^(http|ftp)s?:\/\//.test(value),
app/components/task-item.js
Outdated
return /^(http|ftp)s?:\/\//.test(value); | ||
}, | ||
}, | ||
formatHref: function (href, type) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can also be an arrow function. Doesn't have much benefit besides consistency, but that's pretty important.
app/controllers/tasks.js
Outdated
export default Controller.extend({ | ||
organizations: inject(), | ||
queryParams: ['org'], | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary newline?
app/graphql/github.js
Outdated
|
||
export const queryBuilder = function queryBuilder({orgs}) { | ||
let queries = ['sort:updated-desc', 'state:open']; | ||
if(isIterable(orgs)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space after if
(at least that's how you've been doing it everywhere else). Not sure what the progress is yet on an eslint?
app/routes/application.js
Outdated
controller.set('organizations', organizationList); | ||
controller.set('searchParams', model.q) | ||
// show modal when user has no github token | ||
if(!this.userSettings.get('githubTokenModalSeen')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space after if
app/services/tasks.js
Outdated
@@ -0,0 +1,3 @@ | |||
import Service from '@ember/service'; | |||
export default Service.extend({ | |||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't match formatting of similar files
app/utils/storage.js
Outdated
@@ -0,0 +1,12 @@ | |||
export const setObject = function(key, value) { | |||
localStorage.setItem(key, JSON.stringify(value)); | |||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arrow function
app/utils/storage.js
Outdated
localStorage.setItem(key, JSON.stringify(value)); | ||
}; | ||
|
||
export const getObject = function(key) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arrow function
app/routes/tasks/github.js
Outdated
|
||
let tasks = github.tasks({orgs: identifiers}); | ||
tasks.then((data) => { | ||
data.forEach(function(task) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should definitely be an arrow function
3704f11
to
1b502d7
Compare
app/controllers/tasks.js
Outdated
@@ -4,4 +4,5 @@ import {inject} from '@ember/service'; | |||
export default Controller.extend({ | |||
organizations: inject(), | |||
queryParams: ['org'], | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Irrelevant diff
app/services/gitlab.js
Outdated
@@ -0,0 +1,50 @@ | |||
// https://gitlab.com/api/v4/projects/coala%2Fmobans/issues?order_by=created_at&state=opened |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's this comment?
app/services/gitlab.js
Outdated
_issueUrl: '', | ||
init(...arg) { | ||
this._super(...arg); | ||
this.set('headers', { 'Private-Token': 'sVfZzagWtemrV-suxYK-' }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was mentioned a month ago at #44 (comment)
app/services/gitlab.js
Outdated
_issueUrl: '', | ||
init(...arg) { | ||
this._super(...arg); | ||
this.set('headers', { 'Private-Token': 'sVfZzagWtemrV-suxYK-' }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was mentioned a month ago at #44 (comment)
@@ -11,7 +11,7 @@ export default { | |||
}, | |||
{ | |||
type: 'gitlab', | |||
identifier: 'coala', | |||
identifier: 'coala/mobans', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is obviously wrong, as it is not an org identifier. It is a project identifier.
This is not too different from the problem I raised in the PR a month ago.
#44 (comment)
fetchGitlabProjects
still doesnt get the projects for the org.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identifier in gitlab currently only support per repository, however, in github, only support per organization.
In gitlab, supporting per org, will make multiple request.
It fit nicely with wikidata where, it already support github organization, but not gitlab. It can be identified via issue tracker used, which is currently support full link.
101c4b0
to
ea3fc0a
Compare
Move GitHub Tasks to github namespace `/tasks/github` Add a new gitlab route `/tasks/gitlab` Add a new gitlab serializer Closes coala#38
No description provided.