mirror of
https://github.com/documize/community.git
synced 2025-08-05 05:25:27 +02:00
[WIP] Admin level Jira creds and vendored jira libs
This commit is contained in:
parent
0c5ec43c80
commit
7878a244d3
83 changed files with 10569 additions and 28 deletions
51
gui/app/components/customize/integration-settings.js
Normal file
51
gui/app/components/customize/integration-settings.js
Normal file
|
@ -0,0 +1,51 @@
|
|||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||
//
|
||||
// This software (Documize Community Edition) is licensed under
|
||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
//
|
||||
// You can operate outside the AGPL restrictions by purchasing
|
||||
// Documize Enterprise Edition and obtaining a commercial license
|
||||
// by contacting <sales@documize.com>.
|
||||
//
|
||||
// https://documize.com
|
||||
|
||||
import { inject as service } from '@ember/service';
|
||||
import Notifier from '../../mixins/notifier';
|
||||
import Component from '@ember/component';
|
||||
|
||||
export default Component.extend(Notifier, {
|
||||
orgSvc: service('organization'),
|
||||
appMeta: service(),
|
||||
|
||||
didReceiveAttrs() {
|
||||
this._super(...arguments);
|
||||
let jira = this.get('jira');
|
||||
|
||||
if (is.not.object(jira)) {
|
||||
jira = {
|
||||
url: '',
|
||||
username: '',
|
||||
password: ''
|
||||
};
|
||||
}
|
||||
|
||||
this.set('jiraCreds', jira);
|
||||
},
|
||||
|
||||
actions: {
|
||||
onSave() {
|
||||
let orgId = this.get("appMeta.orgId");
|
||||
let url = this.get('jiraCreds.url');
|
||||
|
||||
if (is.endWith(url, '/')) {
|
||||
this.set('jiraCreds.url', url.substring(0, url.length-1));
|
||||
}
|
||||
|
||||
this.showWait();
|
||||
|
||||
this.get('orgSvc').saveOrgSetting(orgId, 'jira', this.get('jiraCreds')).then(() =>{
|
||||
this.showDone();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
216
gui/app/components/section/jira/type-editor.js
Normal file
216
gui/app/components/section/jira/type-editor.js
Normal file
|
@ -0,0 +1,216 @@
|
|||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||
//
|
||||
// This software (Documize Community Edition) is licensed under
|
||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
//
|
||||
// You can operate outside the AGPL restrictions by purchasing
|
||||
// Documize Enterprise Edition and obtaining a commercial license
|
||||
// by contacting <sales@documize.com>.
|
||||
//
|
||||
// https://documize.com
|
||||
|
||||
import $ from 'jquery';
|
||||
import { set } from '@ember/object';
|
||||
import { schedule } from '@ember/runloop';
|
||||
import { inject as service } from '@ember/service';
|
||||
import Component from '@ember/component';
|
||||
import SectionMixin from '../../../mixins/section';
|
||||
import TooltipMixin from '../../../mixins/tooltip';
|
||||
|
||||
export default Component.extend(SectionMixin, TooltipMixin, {
|
||||
sectionService: service('section'),
|
||||
isDirty: false,
|
||||
waiting: false,
|
||||
authenticated: false,
|
||||
|
||||
init() {
|
||||
this._super(...arguments);
|
||||
this.user = {};
|
||||
this.filters = [];
|
||||
this.config = {};
|
||||
},
|
||||
|
||||
didReceiveAttrs() {
|
||||
this._super(...arguments);
|
||||
|
||||
// Parse section config (usually the query that returns list of issues).
|
||||
let config = {};
|
||||
|
||||
try {
|
||||
config = JSON.parse(this.get('meta.config'));
|
||||
} catch (e) {} // eslint-disable-line no-empty
|
||||
|
||||
if (is.empty(config)) {
|
||||
config = {
|
||||
jql: '',
|
||||
itemCount: 0,
|
||||
};
|
||||
}
|
||||
|
||||
this.set('config', config);
|
||||
|
||||
// let self = this;
|
||||
// self.set('waiting', true);
|
||||
// this.get('sectionService').fetch(this.get('page'), "secrets", this.get('config'))
|
||||
// .then(function (response) {
|
||||
// self.set('waiting', false);
|
||||
// self.set('config.APIKey', response.apikey);
|
||||
// self.set('config.url', response.url);
|
||||
// self.set('config.username', response.username);
|
||||
|
||||
// if (response.apikey.length > 0 && response.url.length > 0 && response.username.length > 0) {
|
||||
// self.send('auth');
|
||||
// }
|
||||
// }, function (reason) { // eslint-disable-line no-unused-vars
|
||||
// self.set('waiting', false);
|
||||
// if (self.get('config.userId') > 0) {
|
||||
// self.send('auth');
|
||||
// }
|
||||
// });
|
||||
},
|
||||
|
||||
getWorkspaces() {
|
||||
let page = this.get('page');
|
||||
let self = this;
|
||||
this.set('waiting', true);
|
||||
|
||||
this.get('sectionService').fetch(page, "workspace", this.get('config'))
|
||||
.then(function (response) {
|
||||
// console.log(response);
|
||||
let workspaceId = self.get('config.workspaceId');
|
||||
|
||||
if (response.length > 0 && workspaceId === 0) {
|
||||
workspaceId = response[0].Id;
|
||||
}
|
||||
|
||||
self.set("config.workspaceId", workspaceId);
|
||||
self.set('workspaces', response);
|
||||
self.selectWorkspace(workspaceId);
|
||||
|
||||
schedule('afterRender', () => {
|
||||
window.scrollTo(0, document.body.scrollHeight);
|
||||
self.renderTooltips();
|
||||
});
|
||||
self.set('waiting', false);
|
||||
}, function (reason) { // eslint-disable-line no-unused-vars
|
||||
self.set('workspaces', []);
|
||||
self.set('waiting', false);
|
||||
});
|
||||
},
|
||||
|
||||
getItems() {
|
||||
let page = this.get('page');
|
||||
let self = this;
|
||||
|
||||
this.set('waiting', true);
|
||||
|
||||
this.get('sectionService').fetch(page, "items", this.get('config'))
|
||||
.then(function (response) {
|
||||
if (self.get('isDestroyed') || self.get('isDestroying')) {
|
||||
return;
|
||||
}
|
||||
self.set('items', response);
|
||||
self.set('config.itemCount', response.length);
|
||||
self.set('waiting', false);
|
||||
}, function (reason) { // eslint-disable-line no-unused-vars
|
||||
if (self.get('isDestroyed') || self.get('isDestroying')) {
|
||||
return;
|
||||
}
|
||||
self.set('items', []);
|
||||
self.set('waiting', false);
|
||||
});
|
||||
},
|
||||
|
||||
selectWorkspace(id) {
|
||||
let self = this;
|
||||
let w = this.get('workspaces');
|
||||
|
||||
w.forEach(function (w) {
|
||||
set(w, 'selected', w.Id === id);
|
||||
|
||||
if (w.Id === id) {
|
||||
self.set("config.filter", w.Filter);
|
||||
self.set("config.workspaceId", id);
|
||||
self.set("config.workspaceName", w.Title);
|
||||
// console.log(self.get('config'));
|
||||
}
|
||||
});
|
||||
|
||||
this.set('workspaces', w);
|
||||
this.getItems();
|
||||
},
|
||||
|
||||
actions: {
|
||||
isDirty() {
|
||||
return this.get('isDirty');
|
||||
},
|
||||
|
||||
auth() {
|
||||
// missing data?
|
||||
if (is.empty(this.get('config.url'))) {
|
||||
$("#gemini-url").addClass("is-invalid").focus();
|
||||
return;
|
||||
}
|
||||
if (is.empty(this.get('config.username'))) {
|
||||
$("#gemini-username").addClass("is-invalid").focus();
|
||||
return;
|
||||
}
|
||||
if (is.empty(this.get('config.APIKey'))) {
|
||||
$("#gemini-apikey").addClass("is-invalid").focus();
|
||||
return;
|
||||
}
|
||||
|
||||
// knock out spaces
|
||||
this.set('config.url', this.get('config.url').trim());
|
||||
this.set('config.username', this.get('config.username').trim());
|
||||
this.set('config.APIKey', this.get('config.APIKey').trim());
|
||||
|
||||
// remove trailing slash in URL
|
||||
let url = this.get('config.url');
|
||||
if (url.indexOf("/", url.length - 1) !== -1) {
|
||||
this.set('config.url', url.substring(0, url.length - 1));
|
||||
}
|
||||
|
||||
let page = this.get('page');
|
||||
let self = this;
|
||||
|
||||
this.set('waiting', true);
|
||||
|
||||
this.get('sectionService').fetch(page, "auth", this.get('config'))
|
||||
.then(function (response) {
|
||||
self.set('authenticated', true);
|
||||
self.set('user', response);
|
||||
self.set('config.userId', response.BaseEntity.id);
|
||||
self.set('waiting', false);
|
||||
self.getWorkspaces();
|
||||
}, function (reason) { // eslint-disable-line no-unused-vars
|
||||
self.set('authenticated', false);
|
||||
self.set('user', null);
|
||||
self.set('config.userId', 0);
|
||||
self.set('waiting', false);
|
||||
});
|
||||
},
|
||||
|
||||
onWorkspaceChange(id) {
|
||||
this.set('isDirty', true);
|
||||
this.selectWorkspace(id);
|
||||
},
|
||||
|
||||
onCancel() {
|
||||
let cb = this.get('onCancel');
|
||||
cb();
|
||||
},
|
||||
|
||||
onAction(title) {
|
||||
let page = this.get('page');
|
||||
let meta = this.get('meta');
|
||||
page.set('title', title);
|
||||
meta.set('rawBody', JSON.stringify(this.get("items")));
|
||||
meta.set('config', JSON.stringify(this.get('config')));
|
||||
meta.set('externalSource', true);
|
||||
|
||||
let cb = this.get('onAction');
|
||||
cb(page, meta);
|
||||
}
|
||||
}
|
||||
});
|
14
gui/app/components/section/jira/type-renderer.js
Normal file
14
gui/app/components/section/jira/type-renderer.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||
//
|
||||
// This software (Documize Community Edition) is licensed under
|
||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
//
|
||||
// You can operate outside the AGPL restrictions by purchasing
|
||||
// Documize Enterprise Edition and obtaining a commercial license
|
||||
// by contacting <sales@documize.com>.
|
||||
//
|
||||
// https://documize.com
|
||||
|
||||
import Component from '@ember/component';
|
||||
|
||||
export default Component.extend({});
|
24
gui/app/pods/customize/integrations/controller.js
Normal file
24
gui/app/pods/customize/integrations/controller.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||
//
|
||||
// This software (Documize Community Edition) is licensed under
|
||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
//
|
||||
// You can operate outside the AGPL restrictions by purchasing
|
||||
// Documize Enterprise Edition and obtaining a commercial license
|
||||
// by contacting <sales@documize.com>.
|
||||
//
|
||||
// https://documize.com
|
||||
|
||||
import { inject as service } from '@ember/service';
|
||||
import Controller from '@ember/controller';
|
||||
|
||||
export default Controller.extend({
|
||||
orgService: service('organization'),
|
||||
|
||||
actions: {
|
||||
save() {
|
||||
return this.get('orgService').save(this.model.general).then(() => {
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
39
gui/app/pods/customize/integrations/route.js
Normal file
39
gui/app/pods/customize/integrations/route.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||
//
|
||||
// This software (Documize Community Edition) is licensed under
|
||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
//
|
||||
// You can operate outside the AGPL restrictions by purchasing
|
||||
// Documize Enterprise Edition and obtaining a commercial license
|
||||
// by contacting <sales@documize.com>.
|
||||
//
|
||||
// https://documize.com
|
||||
|
||||
import { inject as service } from '@ember/service';
|
||||
import RSVP from 'rsvp';
|
||||
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';
|
||||
import Route from '@ember/routing/route';
|
||||
|
||||
export default Route.extend(AuthenticatedRouteMixin, {
|
||||
orgService: service('organization'),
|
||||
appMeta: service(),
|
||||
session: service(),
|
||||
|
||||
beforeModel() {
|
||||
if (!this.get("session.isAdmin")) {
|
||||
this.transitionTo('auth.login');
|
||||
}
|
||||
},
|
||||
|
||||
model() {
|
||||
let orgId = this.get("appMeta.orgId");
|
||||
|
||||
return RSVP.hash({
|
||||
jira: this.get('orgService').getOrgSetting(orgId, "jira")
|
||||
});
|
||||
},
|
||||
|
||||
activate() {
|
||||
this.get('browser').setTitle('Integrations');
|
||||
}
|
||||
});
|
1
gui/app/pods/customize/integrations/template.hbs
Normal file
1
gui/app/pods/customize/integrations/template.hbs
Normal file
|
@ -0,0 +1 @@
|
|||
{{customize/integration-settings jira=jira}}
|
|
@ -15,6 +15,7 @@
|
|||
{{#link-to 'customize.folders' activeClass='selected' class="tab tab-vertical" tagName="li" }}Spaces{{/link-to}}
|
||||
{{#link-to 'customize.groups' activeClass='selected' class="tab tab-vertical" tagName="li" }}Groups{{/link-to}}
|
||||
{{#link-to 'customize.users' activeClass='selected' class="tab tab-vertical" tagName="li" }}Users{{/link-to}}
|
||||
{{#link-to 'customize.integrations' activeClass='selected' class="tab tab-vertical" tagName="li" }}Integrations{{/link-to}}
|
||||
{{#if session.isGlobalAdmin}}
|
||||
{{#link-to 'customize.smtp' activeClass='selected' class="tab tab-vertical" tagName="li" }}SMTP{{/link-to}}
|
||||
{{#link-to 'customize.auth' activeClass='selected' class="tab tab-vertical" tagName="li" }}Authentication{{/link-to}}
|
||||
|
|
|
@ -95,6 +95,9 @@ export default Router.map(function () {
|
|||
this.route('search', {
|
||||
path: 'search'
|
||||
});
|
||||
this.route('integrations', {
|
||||
path: 'integrations'
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ export default Service.extend({
|
|||
|
||||
// Returns attributes for specified org id.
|
||||
getOrg(id) {
|
||||
return this.get('ajax').request(`organizations/${id}`, {
|
||||
return this.get('ajax').request(`organization/${id}`, {
|
||||
method: 'GET'
|
||||
}).then((response) => {
|
||||
let data = this.get('store').normalize('organization', response);
|
||||
|
@ -38,9 +38,22 @@ export default Service.extend({
|
|||
conversionEndpoint: org.get('conversionEndpoint')
|
||||
});
|
||||
|
||||
return this.get('ajax').request(`organizations/${id}`, {
|
||||
return this.get('ajax').request(`organization/${id}`, {
|
||||
method: 'PUT',
|
||||
data: JSON.stringify(org)
|
||||
});
|
||||
},
|
||||
|
||||
getOrgSetting(orgId, key) {
|
||||
return this.get('ajax').request(`organization/${orgId}/setting?key=${key}`, {
|
||||
method: 'GET'
|
||||
});
|
||||
},
|
||||
|
||||
saveOrgSetting(orgId, key, config) {
|
||||
return this.get('ajax').request(`organization/${orgId}/setting?key=${key}`, {
|
||||
method: 'POST',
|
||||
data: JSON.stringify(config)
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
@import "trello.scss";
|
||||
@import "code.scss";
|
||||
@import "flowchart.scss";
|
||||
@import "gemini.scss";
|
||||
@import "github.scss";
|
||||
@import "jira.scss";
|
||||
@import "markdown.scss";
|
||||
@import "table.scss";
|
||||
@import "code.scss";
|
||||
@import "plantuml.scss";
|
||||
@import "papertrail.scss";
|
||||
@import "table.scss";
|
||||
@import "trello.scss";
|
||||
@import "wysiwyg.scss";
|
||||
@import "flowchart.scss";
|
||||
|
|
5
gui/app/styles/section/jira.scss
Normal file
5
gui/app/styles/section/jira.scss
Normal file
|
@ -0,0 +1,5 @@
|
|||
.section-jira {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="view-customize">
|
||||
<h1 class="admin-heading">Integrations Settings</h1>
|
||||
<h2 class="sub-heading">Enable and configure third party integrations</h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="view-customize">
|
||||
<form class="mt-5">
|
||||
<h2>Jira Connector</h2>
|
||||
<p>Displays issues within documentation</p>
|
||||
<div class="form-group row">
|
||||
<label for="siteTitle" class="col-sm-4 col-form-label">URL</label>
|
||||
<div class="col-sm-7">
|
||||
{{focus-input id="jira-url" type="text" value=jiraCreds.url class="form-control"}}
|
||||
<small class="form-text text-muted">Fully qualified domain name for your Jira instance e.g. http://jira.example.org</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="siteTitle" class="col-sm-4 col-form-label">Username</label>
|
||||
<div class="col-sm-7">
|
||||
{{input id="jira-username" type="text" value=jiraCreds.username class="form-control"}}
|
||||
<small class="form-text text-muted">Your Jira login username/email</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="siteTitle" class="col-sm-4 col-form-label">Password</label>
|
||||
<div class="col-sm-7">
|
||||
{{input id="jira-secret" type="password" value=jiraCreds.secret class="form-control"}}
|
||||
<small class="form-text text-muted">Provide API Token if using Atlassian Cloud or Password when self-hosting Jira</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn btn-success font-weight-bold text-uppercase mt-4" {{action 'onSave'}}>Save</div>
|
||||
</form>
|
||||
</div>
|
25
gui/app/templates/components/section/jira/type-editor.hbs
Normal file
25
gui/app/templates/components/section/jira/type-editor.hbs
Normal file
|
@ -0,0 +1,25 @@
|
|||
{{#section/base-editor document=document folder=folder page=page busy=waiting tip="Jira issue tracking" isDirty=(action 'isDirty') onCancel=(action 'onCancel') onAction=(action 'onAction')}}
|
||||
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
{{#unless authenticated}}
|
||||
<p>Your Documize administrator needs to provide Jira connection details before usage.</p>
|
||||
{{/unless}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{#if authenticated}}
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="form-group">
|
||||
<label for="gemini-url">Jira Query Language</label>
|
||||
{{focus-input id="jira-jql" type="text" value=config.query class="form-control"}}
|
||||
<small class="form-text text-muted">Find issues using JQL</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{/section/base-editor}}
|
|
@ -0,0 +1 @@
|
|||
{{{page.body}}}
|
Loading…
Add table
Add a link
Reference in a new issue