From 39ba98d4d47cc78351c9bd2848e8aac420c9d6e0 Mon Sep 17 00:00:00 2001 From: Paul Grever Date: Wed, 3 Aug 2016 10:42:20 -0600 Subject: [PATCH 1/2] updated slack to 14 compatible --- client/index.js | 2 ++ client/templates/dashboard/dashboard.js | 1 + client/templates/settings/settings.html | 6 ++-- client/templates/settings/settings.js | 16 ++++++++-- common/collections.js | 9 ------ lib/collections/index.js | 1 + lib/collections/schemas/index.js | 1 + lib/collections/schemas/slack.js | 12 ++++++++ package.js | 41 ------------------------- server/registry.js => register.js | 0 server/api/index.js | 1 + server/{ => api}/slack.js | 22 ++++++++----- server/index.js | 0 13 files changed, 48 insertions(+), 64 deletions(-) create mode 100644 client/index.js delete mode 100644 common/collections.js create mode 100644 lib/collections/index.js create mode 100644 lib/collections/schemas/index.js create mode 100644 lib/collections/schemas/slack.js delete mode 100644 package.js rename server/registry.js => register.js (100%) create mode 100644 server/api/index.js rename server/{ => api}/slack.js (55%) create mode 100644 server/index.js diff --git a/client/index.js b/client/index.js new file mode 100644 index 0000000..0ac5277 --- /dev/null +++ b/client/index.js @@ -0,0 +1,2 @@ +import './templates/settings/settings'; +import './templates/dashboard/dashboard'; diff --git a/client/templates/dashboard/dashboard.js b/client/templates/dashboard/dashboard.js index e69de29..327c597 100644 --- a/client/templates/dashboard/dashboard.js +++ b/client/templates/dashboard/dashboard.js @@ -0,0 +1 @@ +import './dashboard.html'; diff --git a/client/templates/settings/settings.html b/client/templates/settings/settings.html index 4ef909c..5883463 100644 --- a/client/templates/settings/settings.html +++ b/client/templates/settings/settings.html @@ -1,8 +1,8 @@ \ No newline at end of file + diff --git a/client/templates/settings/settings.js b/client/templates/settings/settings.js index 445eca8..2f27362 100644 --- a/client/templates/settings/settings.js +++ b/client/templates/settings/settings.js @@ -1,8 +1,18 @@ +import { Template } from 'meteor/templating'; +import { Reaction } from '/client/api'; +import { Packages } from '/lib/collections'; +import { SlackPackageConfig } from '../../../lib/collections'; + +import './settings.html'; + Template.slackSettings.helpers({ + SlackPackageConfig: function () { + return SlackPackageConfig; + }, packageData: function () { - return ReactionCore.Collections.Packages.findOne({ + return Packages.findOne({ name: 'slack', - shopId: ReactionCore.getShopId() + shopId: Reaction.getShopId() }); } }); @@ -20,4 +30,4 @@ AutoForm.hooks({ return Alerts.add('Slack settings update failed. ' + error, 'danger'); } } -}); \ No newline at end of file +}); diff --git a/common/collections.js b/common/collections.js deleted file mode 100644 index 00aa06f..0000000 --- a/common/collections.js +++ /dev/null @@ -1,9 +0,0 @@ -ReactionCore.Schemas.SlackPackageConfig = new SimpleSchema([ - ReactionCore.Schemas.PackageConfig, { - 'settings.api.token': { - type: String, - label: 'Slack App Token', - optional: true - } - } -]); \ No newline at end of file diff --git a/lib/collections/index.js b/lib/collections/index.js new file mode 100644 index 0000000..1525cf7 --- /dev/null +++ b/lib/collections/index.js @@ -0,0 +1 @@ +export * from './schemas/'; diff --git a/lib/collections/schemas/index.js b/lib/collections/schemas/index.js new file mode 100644 index 0000000..b7c3666 --- /dev/null +++ b/lib/collections/schemas/index.js @@ -0,0 +1 @@ +export * from './slack'; diff --git a/lib/collections/schemas/slack.js b/lib/collections/schemas/slack.js new file mode 100644 index 0000000..d77e88b --- /dev/null +++ b/lib/collections/schemas/slack.js @@ -0,0 +1,12 @@ +import { SimpleSchema } from "meteor/aldeed:simple-schema"; +import { PackageConfig } from "/lib/collections/schemas/registry"; + +export const SlackPackageConfig = new SimpleSchema([ + PackageConfig, { + 'settings.api.token': { + type: String, + label: 'Slack App Token', + optional: true + } + } +]); diff --git a/package.js b/package.js deleted file mode 100644 index 03d0553..0000000 --- a/package.js +++ /dev/null @@ -1,41 +0,0 @@ -Package.describe({ - summary: 'Slack Chat for Reaction', - name: 'getoutfitted:slack', - version: '0.1.0', - git: 'https://github.com/getoutfitted/slack' -}); - -// Npm.depends({ -// "slack": "7.2.0" -// }); - -Package.onUse(function (api) { - api.versionsFrom('METEOR@1.3'); - api.use('meteor-platform'); - api.use('http'); - api.use('base64'); - api.use('underscore'); - api.use('standard-minifiers'); - api.use('reactioncommerce:core@0.12.0'); - api.use('reactioncommerce:reaction-router'); - api.use('reactioncommerce:reaction-collections'); - api.use('momentjs:moment@2.10.6'); - - api.addFiles([ - 'server/registry.js', - 'server/slack.js' - ], 'server'); - - api.addFiles([ - 'common/collections.js' - ], ['client', 'server']); - - api.addFiles([ - 'client/templates/settings/settings.html', - 'client/templates/settings/settings.js', - 'client/templates/dashboard/dashboard.html', - 'client/templates/dashboard/dashboard.js' - ], 'client'); - - api.export('Slack', 'server') -}); diff --git a/server/registry.js b/register.js similarity index 100% rename from server/registry.js rename to register.js diff --git a/server/api/index.js b/server/api/index.js new file mode 100644 index 0000000..b7c3666 --- /dev/null +++ b/server/api/index.js @@ -0,0 +1 @@ +export * from './slack'; diff --git a/server/slack.js b/server/api/slack.js similarity index 55% rename from server/slack.js rename to server/api/slack.js index 6d1ac0d..b73fee7 100644 --- a/server/slack.js +++ b/server/api/slack.js @@ -1,12 +1,18 @@ -Slack = {}; +import { check } from 'meteor/check' +import { Reaction, Logger } from '/server/api'; +import { Packages } from '/lib/collections'; +import { _ } from 'meteor/underscore'; +import { HTTP } from 'meteor/http'; + +export const Slack = {}; Slack.PostMessage = function (options, attachments) { check(options, Object); check(attachments, Match.Optional([Object])) if (options.channel && options.text) { - const slackPackage = ReactionCore.Collections.Packages.findOne({ + const slackPackage = Packages.findOne({ name: 'slack', - shopId: ReactionCore.getShopId() + shopId: Reaction.getShopId() }); if (slackPackage && slackPackage.enabled) { if (slackPackage.settings && slackPackage.settings.api && slackPackage.settings.api.token) { @@ -22,17 +28,17 @@ Slack.PostMessage = function (options, attachments) { { params: options, }); - ReactionCore.Log.info(`Slack message posted to ${options.channel}`); + Logger.info(`Slack message posted to ${options.channel}`); } catch (err) { - Log.error('Error in making call to Slack API' + err); + Logger.error('Error in making call to Slack API' + err); } } else { - ReactionCore.Log.error('Slack is missing it\'s API Token'); + Logger.error('Slack is missing it\'s API Token'); } } else { - ReactionCore.Log.error('Slack package is not enabled.'); + Logger.error('Slack package is not enabled.'); } } else { - ReactionCore.Log.error('Channel or Text is missing, and preventing Slack Package.'); + Logger.error('Channel or Text is missing, and preventing Slack Package.'); } } diff --git a/server/index.js b/server/index.js new file mode 100644 index 0000000..e69de29 From 84bad5eeebc867f9dc47bc103a57cb0d9ce86535 Mon Sep 17 00:00:00 2001 From: Paul Grever Date: Fri, 19 Aug 2016 14:17:36 -0600 Subject: [PATCH 2/2] updated slack for layout changes --- register.js | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/register.js b/register.js index e067f43..cb93c65 100644 --- a/register.js +++ b/register.js @@ -1,4 +1,6 @@ -ReactionCore.registerPackage({ +import { Reaction } from '/server/api'; + +Reaction.registerPackage({ label: 'Slack', name: 'slack', icon: 'fa fa-slack', @@ -12,7 +14,7 @@ ReactionCore.registerPackage({ container: 'getoutfitted', icon: 'fa fa-slack', template: 'slackDashboard', - workflow: 'coreWorkflow', + workflow: 'slackWorkflow', priority: 3 }, { route: '/dashboard/slack/settings', @@ -20,5 +22,32 @@ ReactionCore.registerPackage({ label: 'Slack Settings', name: 'slackSettings', template: 'slackSettings' + }], + layout: [{ + workflow: "slackWorkflow", + layout: "coreLayout", + theme: "default", + enabled: true, + structure: { + template: "slackDashboard", + layoutHeader: "goLayoutHeader", + layoutFooter: "goLayoutFooter", + notFound: "goNotFound", + dashboardControls: "dashboardControls", + adminControlsFooter: "adminControlsFooter" + } + }, { + workflow: "slackWorkflow", + layout: "getoutfittedLayout", + theme: "default", + enabled: true, + structure: { + template: "slackDashboard", + layoutHeader: "goLayoutHeader", + layoutFooter: "goLayoutFooter", + notFound: "goNotFound", + dashboardControls: "dashboardControls", + adminControlsFooter: "adminControlsFooter" + } }] -}); \ No newline at end of file +});