diff --git a/gui/app/components/section/github/type-editor.js b/gui/app/components/section/github/type-editor.js index d7ba2cf9..ef351d9e 100644 --- a/gui/app/components/section/github/type-editor.js +++ b/gui/app/components/section/github/type-editor.js @@ -9,15 +9,14 @@ // // https://documize.com -import { set } from '@ember/object'; - +import EmberObject from '@ember/object'; +import { A } from '@ember/array'; import { inject as service } from '@ember/service'; import Component from '@ember/component'; import NotifierMixin from '../../../mixins/notifier'; -import TooltipMixin from '../../../mixins/tooltip'; import SectionMixin from '../../../mixins/section'; -export default Component.extend(SectionMixin, NotifierMixin, TooltipMixin, { +export default Component.extend(SectionMixin, NotifierMixin, { sectionService: service('section'), isDirty: false, busy: false, @@ -90,21 +89,17 @@ export default Component.extend(SectionMixin, NotifierMixin, TooltipMixin, { self.get('sectionService').fetch(page, "checkAuth", self.get('config')) .then(function () { self.send('authStage2'); - }, function (error) { + }, function (error) { console.log(error); // eslint-disable-line no-console self.send('auth'); // require auth if the db token is invalid }); } - }, function (error) { + }, function (error) { console.log(error); // eslint-disable-line no-console }); } }, - willDestroyElement() { - this.destroyTooltips(); - }, - getOwnerLists() { this.set('busy', true); @@ -138,41 +133,48 @@ export default Component.extend(SectionMixin, NotifierMixin, TooltipMixin, { let page = this.get('page'); this.get('sectionService').fetch(page, "orgrepos", self.get('config')) - .then(function (lists) { - let savedLists = self.get('config.lists'); - if (savedLists === null) { - savedLists = []; - } + .then(function (lists) { - if (lists.length > 0) { - let noIncluded = true; + let lists2 = A([]); - lists.forEach(function (list) { - let included = false; - var saved; - if (is.not.undefined(savedLists)) { - saved = savedLists.findBy("id", list.id); - } - if (is.not.undefined(saved)) { - included = saved.included; - noIncluded = false; - } - list.included = included; + lists.forEach((i) => { + lists2.pushObject(EmberObject.create(i)); }); - if (noIncluded) { - lists[0].included = true; // make the first entry the default + let savedLists = self.get('config.lists'); + if (savedLists === null) { + savedLists = []; } - } - self.set('config.lists', lists); - self.set('busy', false); - }, function (error) { - self.set('busy', false); - self.set('authenticated', false); - self.showNotification("Unable to fetch repositories"); - console.log(error); // eslint-disable-line no-console - }); + if (lists2.length > 0) { + let noIncluded = true; + + lists2.forEach(function (list) { + let included = false; + var saved; + if (is.not.undefined(savedLists)) { + saved = savedLists.findBy("id", list.id); + } + if (is.not.undefined(saved)) { + included = saved.selected; + noIncluded = false; + } + list.selected = included; + }); + + if (noIncluded) { + lists2[0].selected = true; // make the first entry the default + } + } + + self.set('config.lists', lists2); + self.set('busy', false); + }, function (error) { + self.set('busy', false); + self.set('authenticated', false); + self.showNotification("Unable to fetch repositories"); + console.log(error); // eslint-disable-line no-console + }); }, actions: { @@ -180,19 +182,6 @@ export default Component.extend(SectionMixin, NotifierMixin, TooltipMixin, { return this.get('isDirty'); }, - onListCheckbox(id) { // select one repository only - let lists = this.get('config.lists'); - let list = lists.findBy('id', id); - - lists.forEach(function (entry) { - set(entry, 'included', false); - }); - - if (list !== null) { - set(list, 'included', true); - } - }, - authStage2() { let self = this; self.set('config.userId', self.get("session.session.authenticated.user.id")); @@ -205,7 +194,7 @@ export default Component.extend(SectionMixin, NotifierMixin, TooltipMixin, { self.set('busy', false); self.set('owners', owners); self.getOwnerLists(); - }, function (error) { + }, function (error) { self.set('busy', false); self.set('authenticated', false); self.showNotification("Unable to fetch owners"); diff --git a/gui/app/styles/section/github.scss b/gui/app/styles/section/github.scss index fd9da2f0..991245b6 100644 --- a/gui/app/styles/section/github.scss +++ b/gui/app/styles/section/github.scss @@ -23,11 +23,12 @@ .github-list-title { color: #4c4c4c; font-size: 14px; - margin: 5px; + vertical-align: text-top; } .github-list-checkbox { - vertical-align: text-bottom; + vertical-align: text-top; + margin-right: 10px; } .github-issue-label { diff --git a/gui/app/templates/components/section/github/type-editor.hbs b/gui/app/templates/components/section/github/type-editor.hbs index bfea2bb4..8750fb91 100644 --- a/gui/app/templates/components/section/github/type-editor.hbs +++ b/gui/app/templates/components/section/github/type-editor.hbs @@ -1,20 +1,20 @@ {{#section/base-editor document=document folder=folder page=page busy=busy tip="GitHub is how people build software. (https://github.com)" isDirty=(action 'isDirty') onCancel=(action 'onCancel') onAction=(action 'onAction')}} -
+ +
{{#if authenticated}} -
-
- -
Select organization or user whose repository you want to show
- {{ui-select id="owners-dropdown" content=owners action=(action 'onOwnerChange') optionValuePath="id" optionLabelPath="name" selection=config.owner}} +
+
+ + {{ui-select id="owners-dropdown" content=owners action=(action 'onOwnerChange') optionValuePath="id" optionLabelPath="name" selection=config.owner}} + Select organization or user whose repository you want to show
-
+
-
default is 7 days ago
- {{input id="branch-since" value=config.branchSince type="text" }}
+ {{input id="branch-since" value=config.branchSince type="text" class="form-control"}} + default is 7 days ago
-
+
-
Select the views you want to show
{{input id="show-milestone" checked=config.showMilestones type="checkbox"}} @@ -25,17 +25,17 @@ {{input id="show-commits" checked=config.showCommits type="checkbox" }}
+ Select the views you want to show
-
 
- -
+
-
- -
Select the repository to show
-
+
+ + {{ui/ui-list-picker items=config.lists nameField='repo' singleSelect=true}} + + {{!--
{{#each config.lists as |list|}}
{{#if list.included}} @@ -46,19 +46,15 @@ {{list.repo}} {{#if list.private}}(private){{/if}}
{{/each}} -
-
+
--}}
{{else}} -
-
- -
Click to authenticate with Github
-
-
Authenticate
+
+
Authenticate
{{/if}}
+ {{/section/base-editor}}