Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert rocketchat-message-snippet to main module structure #12768

Merged
merged 2 commits into from
Dec 4, 2018
Merged
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 packages/rocketchat-message-snippet/client/actionButton.js
Original file line number Diff line number Diff line change
@@ -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({
Expand Down
10 changes: 10 additions & 0 deletions packages/rocketchat-message-snippet/client/index.js
Original file line number Diff line number Diff line change
@@ -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';
Original file line number Diff line number Diff line change
@@ -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');
1 change: 1 addition & 0 deletions packages/rocketchat-message-snippet/client/messageType.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { RocketChat } from 'meteor/rocketchat:lib';
import s from 'underscore.string';

Meteor.startup(function() {
Expand Down
Original file line number Diff line number Diff line change
@@ -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({
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-message-snippet/client/router.js
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
2 changes: 2 additions & 0 deletions packages/rocketchat-message-snippet/client/snippetMessage.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
34 changes: 3 additions & 31 deletions packages/rocketchat-message-snippet/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
6 changes: 6 additions & 0 deletions packages/rocketchat-message-snippet/server/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import './startup/settings';
import './models/Rooms';
import './methods/snippetMessage';
import './requests';
import './publications/snippetedMessagesByRoom';
import './publications/snippetedMessage';
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { RocketChat } from 'meteor/rocketchat:lib';

Meteor.methods({
snippetMessage(message, filename) {
Expand Down
2 changes: 2 additions & 0 deletions packages/rocketchat-message-snippet/server/models/Rooms.js
Original file line number Diff line number Diff line change
@@ -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 };

Expand Down
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion packages/rocketchat-message-snippet/server/requests.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { RocketChat } from 'meteor/rocketchat:lib';

Meteor.startup(function() {
RocketChat.settings.add('Message_AllowSnippeting', false, {
Expand Down
4 changes: 2 additions & 2 deletions packages/rocketchat-ui/client/lib/collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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(() => {
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-ui/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});