diff options
-rw-r--r-- | client/components/boards/boardHeader.jade | 20 | ||||
-rw-r--r-- | client/components/boards/boardHeader.js | 27 | ||||
-rw-r--r-- | client/components/boards/boardHeader.styl | 3 | ||||
-rw-r--r-- | i18n/en.i18n.json | 2 | ||||
-rw-r--r-- | models/integrations.js | 3 |
5 files changed, 39 insertions, 16 deletions
diff --git a/client/components/boards/boardHeader.jade b/client/components/boards/boardHeader.jade index 3d98322d..9539fc79 100644 --- a/client/components/boards/boardHeader.jade +++ b/client/components/boards/boardHeader.jade @@ -227,11 +227,21 @@ template(name="archiveBoardPopup") button.js-confirm.negate.full(type="submit") {{_ 'archive'}} template(name="outgoingWebhooksPopup") - form + each integrations + form.integration-form + if title + h4 {{title}} + else + h4 {{_ 'no-name'}} + label + | URL + input.js-outgoing-webhooks-url(type="text" name="url" value=url) + input(type="hidden" value=_id name="id") + input.primary.wide(type="submit" value="{{_ 'save'}}") + form.integration-form + h4 + | {{_ 'new-integration'}} label | URL - if integration.enabled - input.js-outgoing-webhooks-url(type="text" value=integration.url autofocus) - else - input.js-outgoing-webhooks-url(type="text" autofocus) + input.js-outgoing-webhooks-url(type="text" name="url" autofocus) input.primary.wide(type="submit" value="{{_ 'save'}}") diff --git a/client/components/boards/boardHeader.js b/client/components/boards/boardHeader.js index 2ee21905..b7807ca9 100644 --- a/client/components/boards/boardHeader.js +++ b/client/components/boards/boardHeader.js @@ -241,39 +241,44 @@ BlazeComponent.extendComponent({ }).register('boardChangeWatchPopup'); BlazeComponent.extendComponent({ - integration() { + integrations() { const boardId = Session.get('currentBoard'); - return Integrations.findOne({ boardId: `${boardId}` }); + return Integrations.find({ boardId: `${boardId}` }).fetch(); + }, + + integration(id) { + const boardId = Session.get('currentBoard'); + return Integrations.findOne({ _id: id, boardId: `${boardId}` }); }, events() { return [{ 'submit'(evt) { evt.preventDefault(); - const url = this.find('.js-outgoing-webhooks-url').value.trim(); + const url = evt.target.url.value; const boardId = Session.get('currentBoard'); - const integration = this.integration(); - if (integration) { + let id = null; + let integration = null; + if (evt.target.id) { + id = evt.target.id.value; + integration = this.integration(id); if (url) { Integrations.update(integration._id, { $set: { - enabled: true, url: `${url}`, }, }); } else { - Integrations.update(integration._id, { - $set: { - enabled: false, - }, - }); + Integrations.remove(integration._id); } } else if (url) { Integrations.insert({ + userId: Meteor.userId(), enabled: true, type: 'outgoing-webhooks', url: `${url}`, boardId: `${boardId}`, + activities: ['all'], }); } Popup.close(); diff --git a/client/components/boards/boardHeader.styl b/client/components/boards/boardHeader.styl new file mode 100644 index 00000000..0abdb5bd --- /dev/null +++ b/client/components/boards/boardHeader.styl @@ -0,0 +1,3 @@ +.integration-form + padding: 5px + border-bottom: 1px solid #ccc diff --git a/i18n/en.i18n.json b/i18n/en.i18n.json index b2ea9354..ebf4722b 100644 --- a/i18n/en.i18n.json +++ b/i18n/en.i18n.json @@ -368,6 +368,8 @@ "error-notAuthorized": "You are not authorized to view this page.", "outgoing-webhooks": "Outgoing Webhooks", "outgoingWebhooksPopup-title": "Outgoing Webhooks", + "new-integration": "New integration", + "no-name": "(Unknown)", "Wekan_version": "Wekan version", "Node_version": "Node version", "OS_Arch": "OS Arch", diff --git a/models/integrations.js b/models/integrations.js index e9447f69..826873ce 100644 --- a/models/integrations.js +++ b/models/integrations.js @@ -50,6 +50,9 @@ Integrations.allow({ update(userId, doc) { return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId)); }, + remove(userId, doc) { + return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId)); + }, fetch: ['boardId'], }); |