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 chatpal search package to modular structure #12481

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ad2cd8c
First wave of removal of Meteor global
rodrigok Oct 19, 2018
51095cb
Second wave of removal of Meteor global
rodrigok Oct 19, 2018
3f0c9f7
Third wave of removal of Meteor global
rodrigok Oct 19, 2018
e6dfe65
Fix tests
rodrigok Oct 19, 2018
6c46cd2
Merge remote-tracking branch 'origin/develop' into imports/meteor-1
rodrigok Oct 19, 2018
2ac4a38
Remove global variable SHA256
rodrigok Oct 19, 2018
0ebaa95
Remove global variable WebApp
rodrigok Oct 19, 2018
7db5aa9
Remove global variable EJSON
rodrigok Oct 19, 2018
bff9b31
Remove global variable Email
rodrigok Oct 19, 2018
4aafc1b
Remove global variable HTTP
rodrigok Oct 19, 2018
4551e92
Remove global variable Random
rodrigok Oct 19, 2018
501fec5
Remove global variable ReactiveDict
rodrigok Oct 19, 2018
963b5af
Remove global variable ReactiveVar
rodrigok Oct 19, 2018
103d8c5
Remove global variable Accounts
rodrigok Oct 19, 2018
7c99760
Remove globals variables Match and check
MarcosSpessatto Oct 24, 2018
b4dc88d
Remove global variable Mongo
MarcosSpessatto Oct 24, 2018
c813f5e
Remove global variable moment
MarcosSpessatto Oct 24, 2018
c3b9886
Remove global variable Tracker
MarcosSpessatto Oct 24, 2018
a3e965f
Remove global variable Blaze
MarcosSpessatto Oct 25, 2018
577acf7
Remove global variables FlowRouter and BlazeLayout
MarcosSpessatto Oct 25, 2018
2b82e3c
Add FlowRouter to eslint global in tests file
MarcosSpessatto Oct 25, 2018
be79f54
Remove global variable DDPRateLimiter
MarcosSpessatto Oct 26, 2018
70adda6
Remove global variable Session
MarcosSpessatto Oct 26, 2018
a9c962e
Remove global variable UAParser
MarcosSpessatto Oct 26, 2018
dbb0f28
Remove global variable Promise
MarcosSpessatto Oct 26, 2018
e3b4dc8
Remove global variable Reload
MarcosSpessatto Oct 26, 2018
7346aa3
Remove global variable CryptoJS
MarcosSpessatto Oct 26, 2018
5f9a3d4
Remove global variable Template
MarcosSpessatto Oct 26, 2018
39e7721
Remove global variable TAPi18n
MarcosSpessatto Oct 26, 2018
f1fa949
Remove global variable TAPi18next
MarcosSpessatto Oct 26, 2018
2d8544a
Exposing t function from rocketchat:ui package
MarcosSpessatto Oct 30, 2018
011bd15
Convert chatpal search to main module structure
MarcosSpessatto Oct 30, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
27 changes: 0 additions & 27 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,16 @@
"globals": {
"__meteor_runtime_config__" : false,
"AccountBox" : false,
"Accounts" : false,
"AgentUsers" : false,
"Apps" : false,
"Assets" : false,
"Blaze" : false,
"BlazeLayout" : false,
"browser" : false,
"ChatMessage" : false,
"ChatMessages" : false,
"ChatRoom" : false,
"ChatSubscription" : false,
"check" : false,
"CryptoJS" : false,
"Department" : false,
"DDPRateLimiter" : false,
"EJSON" : false,
"Email" : false,
"FlowRouter" : false,
"FileUpload" : false,
"HTTP" : false,
"getNextAgent" : false,
"handleError" : false,
"getAvatarUrlFromUsername" : false,
Expand All @@ -35,40 +25,23 @@
"LivechatPageVisited" : false,
"LivechatTrigger" : false,
"Logger" : false,
"Match" : false,
"Meteor" : false,
"modal" : false,
"moment" : false,
"Mongo" : false,
"Npm" : false,
"Package" : false,
"parentCall" : false,
"Promise" : false,
"Random" : false,
"ReactiveDict" : false,
"ReactiveVar" : false,
"Reload" : false,
"RocketChat" : true,
"RocketChatFile" : false,
"RoomHistoryManager" : false,
"RoomManager" : false,
"ServiceConfiguration" : false,
"Session" : false,
"Settings" : false,
"SHA256" : false,
"SideNav" : false,
"t" : false,
"TAPi18n" : false,
"TAPi18next" : false,
"Template" : false,
"TimeSync" : false,
"toastr" : false,
"Tracker" : false,
"Trigger" : false,
"Triggers" : false,
"UAParser" : false,
"visitor" : false,
"WebApp" : false,
"VideoRecorder" : false,
"VRecDialog" : false
}
Expand Down
2 changes: 2 additions & 0 deletions client/helpers/escapeCssUrl.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
import { Template } from 'meteor/templating';

Template.registerHelper('escapeCssUrl', (url) => url.replace(/(['"])/g, '\\$1'));
2 changes: 2 additions & 0 deletions client/helpers/log.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Template } from 'meteor/templating';

Template.registerHelper('log', (...args) => {
console.log.apply(console, args);
});
2 changes: 2 additions & 0 deletions client/helpers/not.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
import { Template } from 'meteor/templating';

Template.registerHelper('not', (value) => !value);
1 change: 1 addition & 0 deletions client/lib/handleError.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { TAPi18n } from 'meteor/tap:i18n';
import _ from 'underscore';
import s from 'underscore.string';
import toastr from 'toastr';
Expand Down
2 changes: 2 additions & 0 deletions client/methods/deleteMessage.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
import _ from 'underscore';
import moment from 'moment';

Expand Down
1 change: 1 addition & 0 deletions client/methods/hideRoom.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Meteor } from 'meteor/meteor';
Meteor.methods({
hideRoom(rid) {
if (!Meteor.userId()) {
Expand Down
1 change: 1 addition & 0 deletions client/methods/openRoom.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Meteor } from 'meteor/meteor';
Meteor.methods({
openRoom(rid) {
if (!Meteor.userId()) {
Expand Down
1 change: 1 addition & 0 deletions client/methods/setUserActiveStatus.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Meteor } from 'meteor/meteor';
Meteor.methods({
setUserActiveStatus(userId, active) {
Meteor.users.update(userId, { $set: { active } });
Expand Down
1 change: 1 addition & 0 deletions client/methods/toggleFavorite.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Meteor } from 'meteor/meteor';
Meteor.methods({
toggleFavorite(rid, f) {
if (!Meteor.userId()) {
Expand Down
2 changes: 2 additions & 0 deletions client/methods/updateMessage.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
import _ from 'underscore';
import moment from 'moment';
import toastr from 'toastr';
Expand Down
2 changes: 2 additions & 0 deletions client/notifications/UsersNameChanged.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Meteor } from 'meteor/meteor';

Meteor.startup(function() {
RocketChat.Notifications.onLogged('Users:NameChanged', function({ _id, name, username }) {
RocketChat.models.Messages.update({
Expand Down
4 changes: 4 additions & 0 deletions client/notifications/notification.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
/* globals KonchatNotification, fireGlobalEvent, readMessage, CachedChatSubscription */
import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { Session } from 'meteor/session';

// Show notifications and play a sound for new messages.
// We trust the server to only send notifications for interesting messages, e.g. direct messages or
Expand Down
1 change: 1 addition & 0 deletions client/notifications/updateAvatar.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* globals updateAvatarOfUsername */
import { Meteor } from 'meteor/meteor';

Meteor.startup(function() {
RocketChat.Notifications.onLogged('updateAvatar', function(data) {
Expand Down
1 change: 1 addition & 0 deletions client/notifications/updateUserState.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* globals fireGlobalEvent */
import { Meteor } from 'meteor/meteor';

/* fire user state change globally, to listen on desktop electron client */
Meteor.startup(function() {
Expand Down
3 changes: 3 additions & 0 deletions client/routes/adminRouter.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { FlowRouter } from 'meteor/kadira:flow-router' ;
import { BlazeLayout } from 'meteor/kadira:blaze-layout';

FlowRouter.route('/admin/users', {
name: 'admin-users',
action() {
Expand Down
2 changes: 2 additions & 0 deletions client/routes/roomRoute.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { FlowRouter } from 'meteor/kadira:flow-router';

FlowRouter.goToRoomById = (roomId) => {
const subscription = ChatSubscription.findOne({ rid: roomId });
if (subscription) {
Expand Down
7 changes: 7 additions & 0 deletions client/routes/router.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
/* globals KonchatNotification */
import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';
import { Tracker } from 'meteor/tracker';
import { Blaze } from 'meteor/blaze';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { BlazeLayout } from 'meteor/kadira:blaze-layout';
import { Session } from 'meteor/session';
import s from 'underscore.string';

Blaze.registerHelper('pathFor', function(path, kw) {
Expand Down
5 changes: 5 additions & 0 deletions client/startup/emailVerification.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
import { Session } from 'meteor/session';
import { TAPi18n } from 'meteor/tap:i18n';
import toastr from 'toastr';

Meteor.startup(function() {
Tracker.autorun(function() {
const user = Meteor.user();
Expand Down
5 changes: 4 additions & 1 deletion client/startup/i18n.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/* globals isRtl */

import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import { Tracker } from 'meteor/tracker';
import { TAPi18n } from 'meteor/tap:i18n';
import moment from 'moment';

const currentLanguage = new ReactiveVar();
Expand Down
3 changes: 3 additions & 0 deletions client/startup/loginViaQuery.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { FlowRouter } from 'meteor/kadira:flow-router';

Meteor.startup(() => {
if (FlowRouter.getQueryParam('resumeToken')) {
Meteor.loginWithToken(FlowRouter.getQueryParam('resumeToken'), () => {
Expand Down
3 changes: 3 additions & 0 deletions client/startup/roomObserve.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { Session } from 'meteor/session';

Meteor.startup(function() {
ChatRoom.find().observe({
added(data) {
Expand Down
4 changes: 3 additions & 1 deletion client/startup/startup.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* globals UserPresence, fireGlobalEvent */

import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
import { Session } from 'meteor/session';
import toastr from 'toastr';
import hljs from 'highlight.js';
import 'highlight.js/styles/github.css';
Expand Down
4 changes: 4 additions & 0 deletions client/startup/unread.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
/* globals fireGlobalEvent, readMessage, Favico, favico, menu */
import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { Session } from 'meteor/session';

Meteor.startup(function() {
Tracker.autorun(function() {
Expand Down
2 changes: 2 additions & 0 deletions client/startup/userSetUtcOffset.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
import moment from 'moment';

Meteor.startup(function() {
Expand Down
3 changes: 3 additions & 0 deletions client/startup/usersObserve.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { Session } from 'meteor/session';

Meteor.startup(function() {
Meteor.users.find({}, { fields: { name: 1, username: 1, pictures: 1, status: 1, emails: 1, phone: 1, services: 1, utcOffset: 1 } }).observe({
added(user) {
Expand Down
2 changes: 2 additions & 0 deletions imports/message-read-receipt/client/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Template } from 'meteor/templating';

Template.main.helpers({
readReceiptsEnabled() {
if (RocketChat.settings.get('Message_Read_Receipt_Store_Users')) {
Expand Down
2 changes: 2 additions & 0 deletions imports/message-read-receipt/client/readReceipts.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import { Template } from 'meteor/templating';
import moment from 'moment';

import './readReceipts.css';
Expand Down
1 change: 1 addition & 0 deletions imports/message-read-receipt/server/lib/ReadReceipt.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Meteor } from 'meteor/meteor';
import { Random } from 'meteor/random';
import ModelReadReceipts from '../models/ReadReceipts';

Expand Down
4 changes: 4 additions & 0 deletions imports/personal-access-tokens/client/personalAccessTokens.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { Meteor } from 'meteor/meteor';
import { Mongo } from 'meteor/mongo';
import { ReactiveVar } from 'meteor/reactive-var';
import { Tracker } from 'meteor/tracker';
import { Template } from 'meteor/templating';
import toastr from 'toastr';
import moment from 'moment';

Expand Down
2 changes: 2 additions & 0 deletions lib/francocatena_fix.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { TAPi18n } from 'meteor/tap:i18n';

this.i18n_status_func = function(key, options) {
return TAPi18n.__(key, options);
};
8 changes: 8 additions & 0 deletions packages/chatpal-search/client/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import './style.css';
import './template/admin.html';
import './template/result.html';
import './template/suggestion.html';
import './template/admin';
import './template/result';
import './template/suggestion';
import './route';
4 changes: 4 additions & 0 deletions packages/chatpal-search/client/route.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import { FlowRouter } from 'meteor/kadira:flow-router';
import { BlazeLayout } from 'meteor/kadira:blaze-layout';
import { t } from 'meteor/rocketchat:ui';

FlowRouter.route('/admin/chatpal', {
name: 'chatpal-admin',
action() {
Expand Down
5 changes: 5 additions & 0 deletions packages/chatpal-search/client/template/admin.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import { Template } from 'meteor/templating';
import { TAPi18n } from 'meteor/tap:i18n';
import { RocketChat } from 'meteor/rocketchat:lib';
import toastr from 'toastr';

Template.ChatpalAdmin.onCreated(function() {
Expand Down
5 changes: 5 additions & 0 deletions packages/chatpal-search/client/template/result.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { DateFormat } from 'meteor/rocketchat:lib';
import { ReactiveVar } from 'meteor/reactive-var';
import { Session } from 'meteor/session';
import { Template } from 'meteor/templating';
import { TAPi18n } from 'meteor/tap:i18n';
import { RocketChat } from 'meteor/rocketchat:lib';

Template.ChatpalSearchResultTemplate.onCreated(function() {
this.badRequest = new ReactiveVar(false);
Expand Down
2 changes: 2 additions & 0 deletions packages/chatpal-search/client/template/suggestion.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Template } from 'meteor/templating';

Template.ChatpalSuggestionItemTemplate.onCreated(function() {
if (this.data.type === 'link') {
this.data.action = () => {
Expand Down
29 changes: 5 additions & 24 deletions packages/chatpal-search/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,13 @@ Package.onUse(function(api) {
api.use([
'ecmascript',
'templating',
'rocketchat:lib',
'rocketchat:logger',
'rocketchat:search',
'kadira:flow-router',
'meteorhacks:inject-initial',
]);

api.addFiles('server/asset/chatpal-enter.svg', 'server', { isAsset:true });
api.addFiles('server/asset/chatpal-logo-icon-darkblue.svg', 'server', { isAsset:true });

api.addFiles([
'server/provider/provider.js',
'server/provider/index.js',
'server/utils/logger.js',
'server/utils/utils.js',
'server/asset/config.js',
api.addAssets([
'server/asset/chatpal-enter.svg',
'server/asset/chatpal-logo-icon-darkblue.svg',
], 'server');

api.addFiles([
'client/template/suggestion.html',
'client/template/suggestion.js',
'client/template/result.html',
'client/template/result.js',
'client/template/admin.html',
'client/template/admin.js',
'client/style.css',
'client/route.js',
], 'client');
api.mainModule('client/index.js', 'client');
api.mainModule('server/index.js', 'server');
});
2 changes: 1 addition & 1 deletion packages/chatpal-search/server/asset/config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* globals Inject */
import { Inject } from 'meteor/meteorhacks:inject-initial';

Inject.rawBody('chatpal-enter', Assets.getText('server/asset/chatpal-enter.svg'));
Inject.rawBody('chatpal-logo-icon-darkblue', Assets.getText('server/asset/chatpal-logo-icon-darkblue.svg'));
3 changes: 3 additions & 0 deletions packages/chatpal-search/server/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import './asset/config';
import './provider/provider';
import './utils/utils';
3 changes: 3 additions & 0 deletions packages/chatpal-search/server/provider/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { Meteor } from 'meteor/meteor';
import { HTTP } from 'meteor/http';
import ChatpalLogger from '../utils/logger';
import { Random } from 'meteor/random';
import { RocketChat } from 'meteor/rocketchat:lib';

/**
* Enables HTTP functions on Chatpal Backend
Expand Down
2 changes: 2 additions & 0 deletions packages/chatpal-search/server/provider/provider.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Meteor } from 'meteor/meteor';
import { searchProviderService, SearchProvider } from 'meteor/rocketchat:search';
import Index from './index';
import ChatpalLogger from '../utils/logger';
import { RocketChat } from 'meteor/rocketchat:lib';

/**
* The chatpal search provider enables chatpal search. An appropriate backedn has to be specified by settings.
Expand Down
2 changes: 2 additions & 0 deletions packages/chatpal-search/server/utils/logger.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
import { Logger } from 'meteor/rocketchat:logger';

const ChatpalLogger = new Logger('Chatpal Logger', {});
export default ChatpalLogger;
3 changes: 3 additions & 0 deletions packages/chatpal-search/server/utils/utils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { HTTP } from 'meteor/http';

Meteor.methods({
'chatpalUtilsCreateKey'(email) {
try {
Expand Down
3 changes: 3 additions & 0 deletions packages/meteor-accounts-saml/saml_client.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/* globals cordova */
import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';
import { Random } from 'meteor/random';

if (!Accounts.saml) {
Accounts.saml = {};
Expand Down
Loading