Skip to content

Commit

Permalink
Convert rocketchat-autotranslate to main module structure (#12530)
Browse files Browse the repository at this point in the history
* Exposing ChatSubscription from rocketchat-ui

* Convert rocketchat-autotranslate to main module structure
  • Loading branch information
MarcosSpessatto authored and rodrigok committed Nov 6, 2018
1 parent cb5eb20 commit b4debdc
Show file tree
Hide file tree
Showing 17 changed files with 34 additions and 25 deletions.
6 changes: 6 additions & 0 deletions packages/rocketchat-autotranslate/client/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import './stylesheets/autotranslate.css';
import './lib/actionButton';
import './lib/autotranslate';
import './lib/tabBar';
import './views/autoTranslateFlexTab.html';
import './views/autoTranslateFlexTab';
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,5 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
import { RocketChat } from 'meteor/rocketchat:lib';
import _ from 'underscore';

RocketChat.AutoTranslate = {
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-autotranslate/client/lib/tabBar.js
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,9 @@
/* globals ChatSubscription */
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import { Random } from 'meteor/random';
import { Template } from 'meteor/templating';
import { RocketChat } from 'meteor/rocketchat:lib';
import { ChatSubscription, t } from 'meteor/rocketchat:ui';
import _ from 'underscore';
import toastr from 'toastr';

Expand Down
25 changes: 3 additions & 22 deletions packages/rocketchat-autotranslate/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,8 @@ Package.onUse(function(api) {
'ecmascript',
'ddp-rate-limiter',
'rocketchat:lib',
'templating',
]);

api.use('templating', 'client');

api.addFiles([
'client/stylesheets/autotranslate.css',
'client/lib/autotranslate.js',
'client/lib/actionButton.js',
'client/lib/tabBar.js',
'client/views/autoTranslateFlexTab.html',
'client/views/autoTranslateFlexTab.js',
], 'client');

api.addFiles([
'server/settings.js',
'server/autotranslate.js',
'server/permissions.js',
'server/models/Messages.js',
'server/models/Subscriptions.js',
'server/methods/saveSettings.js',
'server/methods/translateMessage.js',
'server/methods/getSupportedLanguages.js',
], 'server');
api.mainModule('client/index.js', 'client');
api.mainModule('server/index.js', 'server');
});
1 change: 1 addition & 0 deletions packages/rocketchat-autotranslate/server/autotranslate.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { HTTP } from 'meteor/http';
import { RocketChat } from 'meteor/rocketchat:lib';
import _ from 'underscore';
import s from 'underscore.string';

Expand Down
8 changes: 8 additions & 0 deletions packages/rocketchat-autotranslate/server/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import './models/Messages';
import './models/Subscriptions';
import './settings';
import './permissions';
import './autotranslate';
import './methods/getSupportedLanguages';
import './methods/saveSettings';
import './methods/translateMessage';
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { DDPRateLimiter } from 'meteor/ddp-rate-limiter';
import { RocketChat } from 'meteor/rocketchat:lib';

Meteor.methods({
'autoTranslate.getSupportedLanguages'(targetLanguage) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import { RocketChat } from 'meteor/rocketchat:lib';

Meteor.methods({
'autoTranslate.saveSettings'(rid, field, value, options) {
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.methods({
'autoTranslate.translateMessage'(message, targetLanguage) {
Expand Down
2 changes: 2 additions & 0 deletions packages/rocketchat-autotranslate/server/models/Messages.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { RocketChat } from 'meteor/rocketchat:lib';

RocketChat.models.Messages.addTranslations = function(messageId, translations) {
const updateObj = {};
Object.keys(translations).forEach((key) => {
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';

RocketChat.models.Subscriptions.updateAutoTranslateById = function(_id, autoTranslate) {
const query = {
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-autotranslate/server/permissions.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';

Meteor.startup(() => {
if (RocketChat.models && RocketChat.models.Permissions) {
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-autotranslate/server/settings.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';

Meteor.startup(function() {
RocketChat.settings.add('AutoTranslate_Enabled', false, { type: 'boolean', group: 'Message', section: 'AutoTranslate', public: true });
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 @@ -8,15 +8,15 @@ this.CachedChatRoom = new RocketChat.CachedCollection({ name: 'rooms' });
ChatRoom = this.CachedChatRoom.collection;

this.CachedChatSubscription = new RocketChat.CachedCollection({ name: 'subscriptions' });
this.ChatSubscription = this.CachedChatSubscription.collection;
ChatSubscription = this.CachedChatSubscription.collection; //eslint-disable-line
this.UserRoles = new Mongo.Collection(null);
RoomRoles = new Mongo.Collection(null); //eslint-disable-line
this.UserAndRoom = new Mongo.Collection(null);
this.CachedChannelList = new Mongo.Collection(null);
this.CachedUserList = new Mongo.Collection(null);

RocketChat.models.Users = _.extend({}, RocketChat.models.Users, Meteor.users);
RocketChat.models.Subscriptions = _.extend({}, RocketChat.models.Subscriptions, this.ChatSubscription);
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);

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 @@ -150,5 +150,6 @@ Package.onUse(function(api) {
api.export('modal', 'client');
api.export('fireGlobalEvent', 'client');
api.export('ChatRoom', 'client');
api.export('ChatSubscription', 'client');
api.export('RoomRoles', 'client');
});

0 comments on commit b4debdc

Please sign in to comment.