Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

bekicot
Copy link
Contributor

@bekicot bekicot commented Jun 7, 2018

No description provided.

@bekicot bekicot changed the title Support GitLab [WIP]Support GitLab Jun 7, 2018
@jayvdb
Copy link
Member

jayvdb commented Jun 7, 2018

No code can be merged until the license issue is resolved.

@jayvdb jayvdb added blocked and removed blocked labels Jun 7, 2018
@@ -4,4 +4,5 @@ import {inject} from '@ember/service';
export default Controller.extend({
organizations: inject(),
queryParams: ['org'],

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Irrelevant diff

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Irrelevant diff

{{#link-to (query-params org=slug)}}
{{org.name}}
{{/link-to}}
</li>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep the indent?

Copy link
Contributor Author

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

@bekicot bekicot changed the title [WIP]Support GitLab Support GitLab Jun 9, 2018
@bekicot
Copy link
Contributor Author

bekicot commented Jun 9, 2018

@jayvdb
The fixes has been created. I've made requested PR #42 #47
This PR, ready to merge

@@ -0,0 +1,9 @@
export const getTrackerIdentifiers = (org, trackerType) => {
if(org && org.trackers){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space before ( and after )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

const settings = getObject(SETTINGS_KEY) || {};

// Only set property defined in PROPERTIES
for(let property of PROPERTIES) {
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright

Copy link
Member

@blazeu blazeu Jun 9, 2018

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

store: inject(),
model() {
const store = this.get('store');
return this.get('gitlab').tasks({projects: ['coala/mobans']}).then(data => {
Copy link
Member

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?

@@ -13,7 +13,7 @@
Organizations
</p>
<ul class="menu-list">
{{#each-in organizations.list as |slug org| }}
{{#each-in organizations.list as |slug org|}}
Copy link
Member

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)

_issueUrl: '',
init() {
this._super(...arguments);
this.set('headers', {'Private-Token': 'sVfZzagWtemrV-suxYK-'});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this shouldnt be here ... ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

omg 😲

@bekicot bekicot changed the title Support GitLab [WIP]Support GitLab Jun 11, 2018
let tasks = projects.map((projectId) => {
const embedRepoInfo = (tasks) => {
return new Promise((resolve, reject) => {
this.fetchRepositoryInfo(projectId).then((repoInfo) => {
Copy link
Member

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

const embedRepoInfo = (tasks) => {
return new Promise((resolve, reject) => {
this.fetchRepositoryInfo(projectId).then((repoInfo) => {
tasks.map((task) => {
Copy link
Member

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.

task.type = 'gitlab-task';
return task;
})
resolve(tasks)
Copy link
Member

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.

Copy link
Member

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

task.repository.nameWithOwner = payload.repository.path_with_namespace
task.repository.url = payload.repository.web_url

task.isPullRequest = payload._type == 'PullRequest';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

===

Copy link
Member

@andrewda andrewda left a 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

formatHref: function (href, type) {
if (type === 'mention') {
href = 'https://github.com/' +
href.substring(1);
Copy link
Member

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?

Copy link
Contributor Author

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.

validate: {
url: function (value) {
return /^(http|ftp)s?:\/\//.test(value);
},
Copy link
Member

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),

return /^(http|ftp)s?:\/\//.test(value);
},
},
formatHref: function (href, type) {
Copy link
Member

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.

export default Controller.extend({
organizations: inject(),
queryParams: ['org'],

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary newline?


export const queryBuilder = function queryBuilder({orgs}) {
let queries = ['sort:updated-desc', 'state:open'];
if(isIterable(orgs)) {
Copy link
Member

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?

controller.set('organizations', organizationList);
controller.set('searchParams', model.q)
// show modal when user has no github token
if(!this.userSettings.get('githubTokenModalSeen'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space after if

@@ -0,0 +1,3 @@
import Service from '@ember/service';
export default Service.extend({
});
Copy link
Member

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

@@ -0,0 +1,12 @@
export const setObject = function(key, value) {
localStorage.setItem(key, JSON.stringify(value));
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arrow function

localStorage.setItem(key, JSON.stringify(value));
};

export const getObject = function(key) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arrow function


let tasks = github.tasks({orgs: identifiers});
tasks.then((data) => {
data.forEach(function(task) {
Copy link
Member

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

@bekicot bekicot force-pushed the support_gitlab branch 2 times, most recently from 3704f11 to 1b502d7 Compare July 11, 2018 10:55
@@ -4,4 +4,5 @@ import {inject} from '@ember/service';
export default Controller.extend({
organizations: inject(),
queryParams: ['org'],

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Irrelevant diff

@@ -0,0 +1,50 @@
// https://gitlab.com/api/v4/projects/coala%2Fmobans/issues?order_by=created_at&state=opened
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this comment?

_issueUrl: '',
init(...arg) {
this._super(...arg);
this.set('headers', { 'Private-Token': 'sVfZzagWtemrV-suxYK-' });
Copy link
Member

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?

Copy link
Member

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)

_issueUrl: '',
init(...arg) {
this._super(...arg);
this.set('headers', { 'Private-Token': 'sVfZzagWtemrV-suxYK-' });
Copy link
Member

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',
Copy link
Member

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.

Copy link
Contributor Author

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.

@bekicot bekicot force-pushed the support_gitlab branch 2 times, most recently from 101c4b0 to ea3fc0a Compare July 12, 2018 22:06
Move GitHub Tasks to github namespace `/tasks/github`
Add a new gitlab route `/tasks/gitlab`
Add a new gitlab serializer

Closes coala#38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

4 participants