diff --git a/packages/rocketchat-message-snippet/client/actionButton.js b/packages/rocketchat-message-snippet/client/actionButton.js index f3b0023ab160..e99541bc6dcf 100644 --- a/packages/rocketchat-message-snippet/client/actionButton.js +++ b/packages/rocketchat-message-snippet/client/actionButton.js @@ -1,4 +1,6 @@ import { Meteor } from 'meteor/meteor'; +import { RocketChat, handleError } from 'meteor/rocketchat:lib'; +import { modal, t } from 'meteor/rocketchat:ui'; Meteor.startup(function() { RocketChat.MessageAction.addButton({ diff --git a/packages/rocketchat-message-snippet/client/index.js b/packages/rocketchat-message-snippet/client/index.js new file mode 100644 index 000000000000..fdf7c7938384 --- /dev/null +++ b/packages/rocketchat-message-snippet/client/index.js @@ -0,0 +1,10 @@ +import './page/stylesheets/snippetPage.css'; +import './actionButton'; +import './messageType'; +import './snippetMessage'; +import './router'; +import './page/snippetPage.html'; +import './page/snippetPage'; +import './tabBar/tabBar'; +import './tabBar/views/snippetedMessages.html'; +import './tabBar/views/snippetedMessages'; diff --git a/packages/rocketchat-message-snippet/client/lib/collections.js b/packages/rocketchat-message-snippet/client/lib/collections.js index c0091ff67218..ff80211fc3a3 100644 --- a/packages/rocketchat-message-snippet/client/lib/collections.js +++ b/packages/rocketchat-message-snippet/client/lib/collections.js @@ -1,3 +1,3 @@ import { Mongo } from 'meteor/mongo'; -this.SnippetedMessages = new Mongo.Collection('rocketchat_snippeted_message'); +export const SnippetedMessages = new Mongo.Collection('rocketchat_snippeted_message'); diff --git a/packages/rocketchat-message-snippet/client/messageType.js b/packages/rocketchat-message-snippet/client/messageType.js index ce827b99eb76..00b826badb7a 100644 --- a/packages/rocketchat-message-snippet/client/messageType.js +++ b/packages/rocketchat-message-snippet/client/messageType.js @@ -1,4 +1,5 @@ import { Meteor } from 'meteor/meteor'; +import { RocketChat } from 'meteor/rocketchat:lib'; import s from 'underscore.string'; Meteor.startup(function() { diff --git a/packages/rocketchat-message-snippet/client/page/snippetPage.js b/packages/rocketchat-message-snippet/client/page/snippetPage.js index 8e7089fb7ac8..a985b453be8f 100644 --- a/packages/rocketchat-message-snippet/client/page/snippetPage.js +++ b/packages/rocketchat-message-snippet/client/page/snippetPage.js @@ -1,8 +1,9 @@ -/* global SnippetedMessages */ import { Meteor } from 'meteor/meteor'; import { DateFormat } from 'meteor/rocketchat:lib'; import { FlowRouter } from 'meteor/kadira:flow-router'; import { Template } from 'meteor/templating'; +import { RocketChat } from 'meteor/rocketchat:lib'; +import { SnippetedMessages } from '../lib/collections'; import moment from 'moment'; Template.snippetPage.helpers({ diff --git a/packages/rocketchat-message-snippet/client/router.js b/packages/rocketchat-message-snippet/client/router.js index b9b230227d34..4df5e3778b79 100644 --- a/packages/rocketchat-message-snippet/client/router.js +++ b/packages/rocketchat-message-snippet/client/router.js @@ -1,5 +1,6 @@ import { FlowRouter } from 'meteor/kadira:flow-router'; import { BlazeLayout } from 'meteor/kadira:blaze-layout'; +import { RocketChat } from 'meteor/rocketchat:lib'; FlowRouter.route('/snippet/:snippetId/:snippetName', { name: 'snippetView', diff --git a/packages/rocketchat-message-snippet/client/snippetMessage.js b/packages/rocketchat-message-snippet/client/snippetMessage.js index 28da80d4eed8..a45af6d0a487 100644 --- a/packages/rocketchat-message-snippet/client/snippetMessage.js +++ b/packages/rocketchat-message-snippet/client/snippetMessage.js @@ -1,4 +1,6 @@ import { Meteor } from 'meteor/meteor'; +import { RocketChat } from 'meteor/rocketchat:lib'; +import { ChatMessage } from 'meteor/rocketchat:ui'; Meteor.methods({ snippetMessage(message) { diff --git a/packages/rocketchat-message-snippet/client/tabBar/tabBar.js b/packages/rocketchat-message-snippet/client/tabBar/tabBar.js index 850f8ba5fc75..74b53c1707a3 100644 --- a/packages/rocketchat-message-snippet/client/tabBar/tabBar.js +++ b/packages/rocketchat-message-snippet/client/tabBar/tabBar.js @@ -1,5 +1,6 @@ import { Meteor } from 'meteor/meteor'; import { Tracker } from 'meteor/tracker'; +import { RocketChat } from 'meteor/rocketchat:lib'; Meteor.startup(function() { Tracker.autorun(function() { diff --git a/packages/rocketchat-message-snippet/client/tabBar/views/snippetedMessages.js b/packages/rocketchat-message-snippet/client/tabBar/views/snippetedMessages.js index bce0a5a976f7..c764e0894542 100644 --- a/packages/rocketchat-message-snippet/client/tabBar/views/snippetedMessages.js +++ b/packages/rocketchat-message-snippet/client/tabBar/views/snippetedMessages.js @@ -1,8 +1,8 @@ import _ from 'underscore'; import { ReactiveVar } from 'meteor/reactive-var'; import { Template } from 'meteor/templating'; +import { SnippetedMessages } from '../../lib/collections'; -/* global SnippetedMessages */ Template.snippetedMessages.helpers({ hasMessages() { return SnippetedMessages.find({ snippeted:true, rid: this.rid }, { sort: { ts: -1 } }).count() > 0; diff --git a/packages/rocketchat-message-snippet/package.js b/packages/rocketchat-message-snippet/package.js index 09d17d77e599..22e2b6e1f882 100644 --- a/packages/rocketchat-message-snippet/package.js +++ b/packages/rocketchat-message-snippet/package.js @@ -17,38 +17,10 @@ Package.onUse(function(api) { 'random', 'tracker', 'webapp', - ]); - - api.use([ 'templating', 'kadira:flow-router', 'kadira:blaze-layout', - ], 'client'); - - - // Server - api.addFiles([ - 'server/startup/settings.js', - 'server/models/Rooms.js', - 'server/methods/snippetMessage.js', - 'server/requests.js', - 'server/publications/snippetedMessagesByRoom.js', - 'server/publications/snippetedMessage.js', - ], 'server'); - - // Client - api.addFiles([ - 'client/lib/collections.js', - 'client/actionButton.js', - 'client/messageType.js', - 'client/snippetMessage.js', - 'client/router.js', - 'client/page/snippetPage.html', - 'client/page/snippetPage.js', - 'client/tabBar/tabBar.js', - 'client/tabBar/views/snippetedMessages.html', - 'client/tabBar/views/snippetedMessages.js', - 'client/page/stylesheets/snippetPage.css', - ], 'client'); - + ]); + api.mainModule('client/index.js', 'client'); + api.mainModule('server/index.js', 'server'); }); diff --git a/packages/rocketchat-message-snippet/server/index.js b/packages/rocketchat-message-snippet/server/index.js new file mode 100644 index 000000000000..2445b9485f4e --- /dev/null +++ b/packages/rocketchat-message-snippet/server/index.js @@ -0,0 +1,6 @@ +import './startup/settings'; +import './models/Rooms'; +import './methods/snippetMessage'; +import './requests'; +import './publications/snippetedMessagesByRoom'; +import './publications/snippetedMessage'; diff --git a/packages/rocketchat-message-snippet/server/methods/snippetMessage.js b/packages/rocketchat-message-snippet/server/methods/snippetMessage.js index 61692e204185..f9ef3b77f052 100644 --- a/packages/rocketchat-message-snippet/server/methods/snippetMessage.js +++ b/packages/rocketchat-message-snippet/server/methods/snippetMessage.js @@ -1,4 +1,5 @@ import { Meteor } from 'meteor/meteor'; +import { RocketChat } from 'meteor/rocketchat:lib'; Meteor.methods({ snippetMessage(message, filename) { diff --git a/packages/rocketchat-message-snippet/server/models/Rooms.js b/packages/rocketchat-message-snippet/server/models/Rooms.js index 907c911531df..165c7a155c67 100644 --- a/packages/rocketchat-message-snippet/server/models/Rooms.js +++ b/packages/rocketchat-message-snippet/server/models/Rooms.js @@ -1,3 +1,5 @@ +import { RocketChat } from 'meteor/rocketchat:lib'; + RocketChat.models.Rooms.setLastMessageSnippeted = function(roomId, message, snippetName, snippetedBy, snippeted, snippetedAt) { const query = { _id: roomId }; diff --git a/packages/rocketchat-message-snippet/server/publications/snippetedMessage.js b/packages/rocketchat-message-snippet/server/publications/snippetedMessage.js index bd5c6866a34f..4f30beaa3d62 100644 --- a/packages/rocketchat-message-snippet/server/publications/snippetedMessage.js +++ b/packages/rocketchat-message-snippet/server/publications/snippetedMessage.js @@ -1,4 +1,5 @@ import { Meteor } from 'meteor/meteor'; +import { RocketChat } from 'meteor/rocketchat:lib'; Meteor.publish('snippetedMessage', function(_id) { if (typeof this.userId === 'undefined' || this.userId === null) { diff --git a/packages/rocketchat-message-snippet/server/publications/snippetedMessagesByRoom.js b/packages/rocketchat-message-snippet/server/publications/snippetedMessagesByRoom.js index 3aca49b586da..b7b6c5a769d3 100644 --- a/packages/rocketchat-message-snippet/server/publications/snippetedMessagesByRoom.js +++ b/packages/rocketchat-message-snippet/server/publications/snippetedMessagesByRoom.js @@ -1,4 +1,5 @@ import { Meteor } from 'meteor/meteor'; +import { RocketChat } from 'meteor/rocketchat:lib'; Meteor.publish('snippetedMessages', function(rid, limit = 50) { if (typeof this.userId === 'undefined' || this.userId === null) { diff --git a/packages/rocketchat-message-snippet/server/requests.js b/packages/rocketchat-message-snippet/server/requests.js index 65d1a1089fe5..6a526a5a3435 100644 --- a/packages/rocketchat-message-snippet/server/requests.js +++ b/packages/rocketchat-message-snippet/server/requests.js @@ -1,5 +1,6 @@ -/* global Cookies */ import { WebApp } from 'meteor/webapp'; +import { Cookies } from 'meteor/ostrio:cookies'; +import { RocketChat } from 'meteor/rocketchat:lib'; WebApp.connectHandlers.use('/snippet/download', function(req, res) { let rawCookies; diff --git a/packages/rocketchat-message-snippet/server/startup/settings.js b/packages/rocketchat-message-snippet/server/startup/settings.js index cbe192ff9543..7f5e7c2816f6 100644 --- a/packages/rocketchat-message-snippet/server/startup/settings.js +++ b/packages/rocketchat-message-snippet/server/startup/settings.js @@ -1,4 +1,5 @@ import { Meteor } from 'meteor/meteor'; +import { RocketChat } from 'meteor/rocketchat:lib'; Meteor.startup(function() { RocketChat.settings.add('Message_AllowSnippeting', false, { diff --git a/packages/rocketchat-ui/client/lib/collections.js b/packages/rocketchat-ui/client/lib/collections.js index f7c476a4e964..6e9cf03cb390 100644 --- a/packages/rocketchat-ui/client/lib/collections.js +++ b/packages/rocketchat-ui/client/lib/collections.js @@ -3,7 +3,7 @@ import { Mongo } from 'meteor/mongo'; import { Tracker } from 'meteor/tracker'; import _ from 'underscore'; -this.ChatMessage = new Mongo.Collection(null); +ChatMessage = new Mongo.Collection(null); //eslint-disable-line this.CachedChatRoom = new RocketChat.CachedCollection({ name: 'rooms' }); ChatRoom = this.CachedChatRoom.collection; @@ -18,7 +18,7 @@ this.CachedUserList = new Mongo.Collection(null); RocketChat.models.Users = _.extend({}, RocketChat.models.Users, Meteor.users); RocketChat.models.Subscriptions = _.extend({}, RocketChat.models.Subscriptions, ChatSubscription); //eslint-disable-line RocketChat.models.Rooms = _.extend({}, RocketChat.models.Rooms, ChatRoom); -RocketChat.models.Messages = _.extend({}, RocketChat.models.Messages, this.ChatMessage); +RocketChat.models.Messages = _.extend({}, RocketChat.models.Messages, ChatMessage); Meteor.startup(() => { Tracker.autorun(() => { diff --git a/packages/rocketchat-ui/package.js b/packages/rocketchat-ui/package.js index b33a06eb147d..8715ea6478ce 100644 --- a/packages/rocketchat-ui/package.js +++ b/packages/rocketchat-ui/package.js @@ -157,5 +157,6 @@ Package.onUse(function(api) { api.export('RoomManager', 'client'); api.export('getAvatarUrlFromUsername'); api.export('popout', 'client'); + api.export('ChatMessage', 'client'); api.export('RoomHistoryManager', 'client'); });