Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions client/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import './templates/settings/settings';
import './templates/dashboard/dashboard';
1 change: 1 addition & 0 deletions client/templates/dashboard/dashboard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './dashboard.html';
6 changes: 3 additions & 3 deletions client/templates/settings/settings.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<template name='slackSettings'>
<div class="panel-body">
{{#autoForm
collection="ReactionCore.Collections.Packages"
schema="ReactionCore.Schemas.SlackPackageConfig"
collection=Collections.Packages
schema=SlackPackageConfig
doc=packageData
type="update"
id="slack-update-form"
Expand All @@ -13,4 +13,4 @@ <h2>Slack Configuration</h2>
<button type="submit" class="btn btn-primary pull-right">Save Changes</button>
{{/autoForm}}
</div>
</template>
</template>
16 changes: 13 additions & 3 deletions client/templates/settings/settings.js
Original file line number Diff line number Diff line change
@@ -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()
});
}
});
Expand All @@ -20,4 +30,4 @@ AutoForm.hooks({
return Alerts.add('Slack settings update failed. ' + error, 'danger');
}
}
});
});
9 changes: 0 additions & 9 deletions common/collections.js

This file was deleted.

1 change: 1 addition & 0 deletions lib/collections/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './schemas/';
1 change: 1 addition & 0 deletions lib/collections/schemas/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './slack';
12 changes: 12 additions & 0 deletions lib/collections/schemas/slack.js
Original file line number Diff line number Diff line change
@@ -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
}
}
]);
41 changes: 0 additions & 41 deletions package.js

This file was deleted.

53 changes: 53 additions & 0 deletions register.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { Reaction } from '/server/api';

Reaction.registerPackage({
label: 'Slack',
name: 'slack',
icon: 'fa fa-slack',
autoEnable: true,
registry: [{
route: '/dashboard/slack',
provides: 'dashboard',
name: 'slack',
label: 'Slack',
description: 'Slack Post a Message to Channel',
container: 'getoutfitted',
icon: 'fa fa-slack',
template: 'slackDashboard',
workflow: 'slackWorkflow',
priority: 3
}, {
route: '/dashboard/slack/settings',
provides: 'settings',
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"
}
}]
});
1 change: 1 addition & 0 deletions server/api/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './slack';
22 changes: 14 additions & 8 deletions server/slack.js → server/api/slack.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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.');
}
}
Empty file added server/index.js
Empty file.
24 changes: 0 additions & 24 deletions server/registry.js

This file was deleted.