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-ui-master to main module structure #13107

Merged
merged 73 commits into from
Jan 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
eb36f8b
Move rocketchat settings to specific package
MarcosSpessatto Dec 21, 2018
4428a97
WIP: Move models from rocketchat-lib to a specific package (server)
MarcosSpessatto Dec 24, 2018
157edc0
Move function from rocketchat:lib to rocketchat:utils to use it in ro…
MarcosSpessatto Dec 24, 2018
7b65a21
Merge branch 'develop' into globals/remove-rocketchat-settings
MarcosSpessatto Dec 24, 2018
4a26cba
Merge branch 'globals/remove-rocketchat-settings' into globals/move-r…
MarcosSpessatto Dec 24, 2018
24cfb4f
Move client models from rocketchat:lib to rocketchat:models
MarcosSpessatto Dec 26, 2018
0683f57
Fix lint
MarcosSpessatto Dec 26, 2018
b26e192
Move rocketchat.info from lib to utils
MarcosSpessatto Dec 27, 2018
8eeac90
Remove directly dependency between lib and migrations
MarcosSpessatto Dec 27, 2018
7080105
Move statistics Model to rocketchat:models
MarcosSpessatto Dec 27, 2018
3d2395c
Create rocketchat:metrics to be able to depacking rocketchat callbacks
MarcosSpessatto Dec 27, 2018
289c478
Move callbacks to specific package
MarcosSpessatto Dec 27, 2018
ccba459
Remove unused dependency
MarcosSpessatto Dec 27, 2018
869c15d
Move rocketchat-notifications to a specific package
MarcosSpessatto Dec 27, 2018
af817df
Move rocketchat-promises to a specific package
MarcosSpessatto Dec 28, 2018
4f1947d
Merge branch 'develop' into globals/remove-rocketchat-settings
MarcosSpessatto Jan 2, 2019
52e95cc
Merge branch 'globals/remove-rocketchat-settings' into globals/move-r…
MarcosSpessatto Jan 2, 2019
a8d506b
remove directly dependency from metrics and models
MarcosSpessatto Jan 3, 2019
42c1ac9
Move CachedCollection from lib to models
MarcosSpessatto Jan 3, 2019
a05c6f5
Move ui models/collections from ui to models
MarcosSpessatto Jan 3, 2019
36ff49e
Move authorization client/ui models to rocketchat:models to be able t…
MarcosSpessatto Jan 3, 2019
dfbcf6b
Merge branch 'globals/move-rocketchat-models' into globals/move-rocke…
MarcosSpessatto Jan 3, 2019
e60d248
Merge branch 'globals/move-rocketchat-metrics' into globals/move-rock…
MarcosSpessatto Jan 3, 2019
2c34342
Merge branch 'globals/move-rocketchat-callbacks' into globals/move-ro…
MarcosSpessatto Jan 3, 2019
e71d2b5
Merge branch 'globals/move-rocketchat-notifications' into globals/mov…
MarcosSpessatto Jan 3, 2019
3ea4cf7
Merge branch 'globals/move-rocketchat-promises' into globals/move-ui-…
MarcosSpessatto Jan 3, 2019
15b52fa
Creation of rocketchat:ui-utils to help decouple rocketchat:lib and r…
MarcosSpessatto Jan 3, 2019
6383ad5
Move some common functions to rocketchat:utils
MarcosSpessatto Jan 3, 2019
86bf84c
Change imports to dynamic imports to avoid directly dependency betwee…
MarcosSpessatto Jan 3, 2019
ec7fd7b
Move authz models to rocketchat:models
MarcosSpessatto Jan 3, 2019
523d704
Remove directly dependency between rocketchat:authz and rocketchat:lib
MarcosSpessatto Jan 3, 2019
c770001
Move some functions from rocketchat:lib to rocketchat:utils
MarcosSpessatto Jan 8, 2019
252ad4c
Add functions to settings package
MarcosSpessatto Jan 8, 2019
0d94009
Convert rocketchat:file-upload to main module structure
MarcosSpessatto Jan 8, 2019
61a71eb
Import FileUpload where it is being used
MarcosSpessatto Jan 8, 2019
5a8d997
Remove FileUpload and fileUploadHandler from globals eslintrc
MarcosSpessatto Jan 8, 2019
f6b7f82
Move some functions to rocketchat:ui-utils
MarcosSpessatto Jan 8, 2019
d64719a
Remove directly dependency between rocketchat:authorization and rocke…
MarcosSpessatto Jan 8, 2019
0932300
Remove dependency between lazy-load and lib
MarcosSpessatto Jan 8, 2019
601008b
Change imports of renderMessageBody from ui-message to ui-utils
MarcosSpessatto Jan 8, 2019
c4dd3aa
Add import of main ready from ui-utils
MarcosSpessatto Jan 8, 2019
f82338e
Convert rocketchat-ui-sidenav to main module structure
MarcosSpessatto Jan 8, 2019
2ffadf0
Add imports of toolbarSearch from ui-sidenav
MarcosSpessatto Jan 8, 2019
545d534
Remove toolbarSearch from eslintrc globals
MarcosSpessatto Jan 8, 2019
c4320ea
Move CachedCollection to a specific package
MarcosSpessatto Jan 9, 2019
0ff6b3e
Change imports of CachedCollection to new package
MarcosSpessatto Jan 9, 2019
803abf6
Move some functions to rocketchat:ui-utils
MarcosSpessatto Jan 9, 2019
76ee0f0
Remove directly dependency between tooltip and lib
MarcosSpessatto Jan 9, 2019
6455fbc
Remove directly dependency between settings and metrics
MarcosSpessatto Jan 9, 2019
772e87c
Move some settings client function from lib to settings
MarcosSpessatto Jan 9, 2019
0f16f53
Convert rocketchat-ui-master to main module structure
MarcosSpessatto Jan 9, 2019
b40ea2d
Merge branch 'develop' into globals/move-rocketchat-callbacks
MarcosSpessatto Jan 10, 2019
ac03e2d
Merge branch 'develop' into globals/move-rocketchat-callbacks
MarcosSpessatto Jan 10, 2019
483650d
Merge branch 'globals/move-rocketchat-callbacks' into globals/move-ro…
MarcosSpessatto Jan 10, 2019
63bb0a4
Merge branch 'globals/move-rocketchat-notifications' into globals/mov…
MarcosSpessatto Jan 10, 2019
f052372
Merge branch 'globals/move-rocketchat-promises' into globals/move-ui-…
MarcosSpessatto Jan 10, 2019
6fb8b0b
Merge branch 'globals/move-ui-collections' into globals/authorization
MarcosSpessatto Jan 10, 2019
839c7a1
Merge branch 'globals/authorization' into globals/main-module-file-up…
MarcosSpessatto Jan 10, 2019
db361ac
Merge branch 'develop' into globals/move-rocketchat-notifications
rodrigok Jan 10, 2019
30df39b
Merge branch 'globals/move-rocketchat-notifications' into globals/mov…
MarcosSpessatto Jan 10, 2019
e50de55
Merge branch 'globals/move-rocketchat-promises' into globals/move-ui-…
MarcosSpessatto Jan 10, 2019
dba0ec5
Merge branch 'globals/move-ui-collections' into globals/authorization
MarcosSpessatto Jan 10, 2019
488a311
Merge branch 'globals/authorization' into globals/main-module-file-up…
MarcosSpessatto Jan 10, 2019
a177d27
Merge branch 'globals/main-module-file-upload' into globals/main-modu…
MarcosSpessatto Jan 10, 2019
f500d47
Merge branch 'globals/main-module-ui-sidenav' into globals/main-modul…
MarcosSpessatto Jan 10, 2019
6c06061
Merge branch 'develop' into globals/authorization
rodrigok Jan 10, 2019
6969209
Merge branch 'globals/authorization' into globals/main-module-file-up…
MarcosSpessatto Jan 11, 2019
b0aff80
Merge branch 'globals/main-module-file-upload' into globals/main-modu…
MarcosSpessatto Jan 11, 2019
0640958
Fix import missed objects inside RocketChat namespace
MarcosSpessatto Jan 11, 2019
fc30b19
Merge branch 'globals/main-module-ui-sidenav' into globals/main-modul…
MarcosSpessatto Jan 11, 2019
a575e54
Fix lint
MarcosSpessatto Jan 11, 2019
f2bc83a
Merge branch 'globals/main-module-ui-sidenav' into globals/main-modul…
MarcosSpessatto Jan 11, 2019
57d4a71
Merge branch 'develop' into globals/main-module-ui-master
MarcosSpessatto Jan 11, 2019
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
1 change: 1 addition & 0 deletions .meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,4 @@ rocketchat:callbacks
rocketchat:notifications
rocketchat:promises
rocketchat:ui-utils
rocketchat:ui-cached-collection
1 change: 1 addition & 0 deletions .meteor/versions
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ rocketchat:tooltip@0.0.1
rocketchat:ui@0.1.0
rocketchat:ui-account@0.1.0
rocketchat:ui-admin@0.1.0
rocketchat:ui-cached-collection@0.0.1
rocketchat:ui-clean-history@0.0.1
rocketchat:ui-flextab@0.1.0
rocketchat:ui-login@0.1.0
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-authorization/client/startup.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { CachedCollectionManager } from 'meteor/rocketchat:models';
import { CachedCollectionManager } from 'meteor/rocketchat:ui-cached-collection';
import { hasAllPermission } from './hasPermission';

Meteor.startup(async() => {
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-authorization/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Package.onUse(function(api) {
'rocketchat:utils',
'rocketchat:models',
'rocketchat:notifications',
'rocketchat:ui-cached-collection',
]);
api.use([
'templating',
Expand Down
108 changes: 1 addition & 107 deletions packages/rocketchat-iframe-login/client/iframe_client.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { Meteor } from 'meteor/meteor';
import { Match } from 'meteor/check';
import { RocketChat } from 'meteor/rocketchat:lib';
import { Accounts } from 'meteor/accounts-base';
import { ReactiveVar } from 'meteor/reactive-var';
import { Tracker } from 'meteor/tracker';
import { HTTP } from 'meteor/http';
import { IframeLogin } from 'meteor/rocketchat:ui-utils';
import { OAuth } from 'meteor/oauth';
import _ from 'underscore';

Expand All @@ -14,109 +11,6 @@ Accounts._unstoreLoginToken = function(...args) {
_unstoreLoginToken.apply(Accounts, args);
};

class IframeLogin {
constructor() {
this.enabled = false;
this.reactiveIframeUrl = new ReactiveVar();
this.reactiveEnabled = new ReactiveVar();
this.iframeUrl = undefined;
this.apiUrl = undefined;
this.apiMethod = undefined;

Tracker.autorun((c) => {
this.enabled = RocketChat.settings.get('Accounts_iframe_enabled');
this.reactiveEnabled.set(this.enabled);

this.iframeUrl = RocketChat.settings.get('Accounts_iframe_url');
this.apiUrl = RocketChat.settings.get('Accounts_Iframe_api_url');
this.apiMethod = RocketChat.settings.get('Accounts_Iframe_api_method');

if (this.enabled === false) {
return c.stop();
}

if (this.enabled === true && this.iframeUrl && this.apiUrl && this.apiMethod) {
c.stop();
if (!Accounts._storedLoginToken()) {
this.tryLogin(() => {});
}
}
});
}

tryLogin(callback) {
if (!this.enabled) {
return;
}

if (!this.iframeUrl || !this.apiUrl || !this.apiMethod) {
return;
}

console.log('tryLogin');
const options = {
beforeSend: (xhr) => {
xhr.withCredentials = true;
},
};

let { iframeUrl } = this;
let separator = '?';
if (iframeUrl.indexOf('?') > -1) {
separator = '&';
}

if (window.cordova) {
iframeUrl += `${ separator }client=cordova`;
} else if (navigator.userAgent.indexOf('Electron') > -1) {
iframeUrl += `${ separator }client=electron`;
}

HTTP.call(this.apiMethod, this.apiUrl, options, (error, result) => {
console.log(error, result);
if (result && result.data && (result.data.token || result.data.loginToken)) {
this.loginWithToken(result.data, (error, result) => {
if (error) {
this.reactiveIframeUrl.set(iframeUrl);
} else {
this.reactiveIframeUrl.set();
}
callback(error, result);
});
} else {
this.reactiveIframeUrl.set(iframeUrl);
callback(error, result);
}
});
}

loginWithToken(tokenData, callback) {
if (!this.enabled) {
return;
}

if (Match.test(tokenData, String)) {
tokenData = {
token: tokenData,
};
}

console.log('loginWithToken');

if (tokenData.loginToken) {
return Meteor.loginWithToken(tokenData.loginToken, callback);
}

Accounts.callLoginMethod({
methodArguments: [{
iframe: true,
token: tokenData.token,
}],
userCallback: callback,
});
}
}

RocketChat.iframeLogin = new IframeLogin();

const requestCredential = (serviceName, options = {}, callback) => {
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-iframe-login/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Package.onUse(function(api) {
'rocketchat:logger',
'kadira:flow-router',
'rocketchat:lib',
'rocketchat:ui-utils',
'accounts-base',
'ecmascript',
'reactive-var',
Expand Down
14 changes: 2 additions & 12 deletions packages/rocketchat-lib/client/lib/Layout.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
import { Tracker } from 'meteor/tracker';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { Layout } from 'meteor/rocketchat:ui-utils';

RocketChat.Layout = new (class RocketChatLayout {
constructor() {
Tracker.autorun(() => {
this.layout = FlowRouter.getQueryParam('layout');
});
}
RocketChat.Layout = Layout;

isEmbedded() {
return this.layout === 'embedded';
}
});
2 changes: 1 addition & 1 deletion packages/rocketchat-lib/client/lib/cachedCollection.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CachedCollection, CachedCollectionManager } from 'meteor/rocketchat:models';
import { CachedCollection, CachedCollectionManager } from 'meteor/rocketchat:ui-cached-collection';

RocketChat.CachedCollectionManager = CachedCollectionManager;
RocketChat.CachedCollection = CachedCollection;
47 changes: 0 additions & 47 deletions packages/rocketchat-lib/client/lib/settings.js
Original file line number Diff line number Diff line change
@@ -1,54 +1,7 @@
import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
import { ReactiveDict } from 'meteor/reactive-dict';
import { t } from 'meteor/rocketchat:utils';

/*
* RocketChat.settings holds all packages settings
* @namespace RocketChat.settings
*/

RocketChat.settings.cachedCollection = new RocketChat.CachedCollection({
name: 'public-settings',
eventType: 'onAll',
userRelated: false,
listenChangesForLoggedUsersOnly: true,
});

RocketChat.settings.collection = RocketChat.settings.cachedCollection.collection;

RocketChat.settings.cachedCollection.init();

RocketChat.settings.dict = new ReactiveDict('settings');

RocketChat.settings.get = function(_id) {
return RocketChat.settings.dict.get(_id);
};

RocketChat.settings.init = function() {
let initialLoad = true;
RocketChat.settings.collection.find().observe({
added(record) {
Meteor.settings[record._id] = record.value;
RocketChat.settings.dict.set(record._id, record.value);
RocketChat.settings.load(record._id, record.value, initialLoad);
},
changed(record) {
Meteor.settings[record._id] = record.value;
RocketChat.settings.dict.set(record._id, record.value);
RocketChat.settings.load(record._id, record.value, initialLoad);
},
removed(record) {
delete Meteor.settings[record._id];
RocketChat.settings.dict.set(record._id, null);
RocketChat.settings.load(record._id, null, initialLoad);
},
});
initialLoad = false;
};

RocketChat.settings.init();

Meteor.startup(function() {
if (Meteor.isCordova === true) {
return;
Expand Down
3 changes: 3 additions & 0 deletions packages/rocketchat-lib/client/lib/tooltip.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { tooltip } from 'meteor/rocketchat:tooltip';

RocketChat.tooltip = tooltip;
2 changes: 2 additions & 0 deletions packages/rocketchat-lib/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Package.onUse(function(api) {
api.use('rocketchat:notifications');
api.use('rocketchat:promises');
api.use('rocketchat:ui-utils');
api.use('rocketchat:tooltip');
api.use('rocketchat:accounts');
api.use('modules');
api.use('rocketchat:i18n');
Expand Down Expand Up @@ -235,6 +236,7 @@ Package.onUse(function(api) {
api.addFiles('client/lib/Layout.js', 'client');
api.addFiles('client/lib/handleError.js', 'client');
api.addFiles('client/lib/authorization.js', 'client');
api.addFiles('client/lib/tooltip.js', 'client');

// CLIENT LIB STARTUP
api.addFiles('client/lib/startup/commands.js', 'client');
Expand Down
1 change: 0 additions & 1 deletion packages/rocketchat-metrics/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Package.describe({
Package.onUse(function(api) {
api.use([
'ecmascript',
'rocketchat:settings',
'rocketchat:migrations',
'rocketchat:version',
]);
Expand Down
21 changes: 12 additions & 9 deletions packages/rocketchat-metrics/server/lib/metrics.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Meteor } from 'meteor/meteor';
import { settings } from 'meteor/rocketchat:settings';
import { Migrations } from 'meteor/rocketchat:migrations';
import client from 'prom-client';
import connect from 'connect';
Expand Down Expand Up @@ -77,12 +76,12 @@ metrics.totalPrivateGroupMessages = new client.Gauge({ name: 'rocketchat_private
metrics.totalDirectMessages = new client.Gauge({ name: 'rocketchat_direct_messages_total', help: 'total of messages in direct rooms' });
metrics.totalLivechatMessages = new client.Gauge({ name: 'rocketchat_livechat_messages_total', help: 'total of messages in livechat rooms' });

client.register.setDefaultLabels({
uniqueId: settings.get('uniqueID'),
siteUrl: settings.get('Site_Url'),
});

const setPrometheusData = async() => {
const { settings } = await import('meteor/rocketchat:settings');
client.register.setDefaultLabels({
uniqueId: settings.get('uniqueID'),
siteUrl: settings.get('Site_Url'),
});
const date = new Date();
if (!Info) {
const Utils = await import('meteor/rocketchat:utils');
Expand Down Expand Up @@ -167,7 +166,8 @@ app.use('/', (req, res) => {
const server = http.createServer(app);

let timer;
const updatePrometheusConfig = () => {
const updatePrometheusConfig = async() => {
const { settings } = await import('meteor/rocketchat:settings');
const port = settings.get('Prometheus_Port');
const enabled = settings.get('Prometheus_Enabled');
if (port == null || enabled == null) {
Expand All @@ -186,5 +186,8 @@ const updatePrometheusConfig = () => {
}
};

settings.get('Prometheus_Enabled', updatePrometheusConfig);
settings.get('Prometheus_Port', updatePrometheusConfig);
Meteor.startup(async() => {
const { settings } = await import('meteor/rocketchat:settings');
settings.get('Prometheus_Enabled', updatePrometheusConfig);
settings.get('Prometheus_Port', updatePrometheusConfig);
});
3 changes: 0 additions & 3 deletions packages/rocketchat-models/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Base } from './models/_Base';
import Avatars from './models/Avatars';
import Uploads from './models/Uploads';
import UserDataFiles from './models/UserDataFiles';
import { CachedCollection, CachedCollectionManager } from './models/CachedCollection';
import { Roles } from './models/Roles';
import { Subscriptions as subscriptions } from './models/Subscriptions';
import { Users as users } from './models/Users';
Expand Down Expand Up @@ -31,8 +30,6 @@ export {
Avatars,
Uploads,
UserDataFiles,
CachedCollection,
CachedCollectionManager,
Roles,
Subscriptions,
Users,
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-models/client/models/CachedChatRoom.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { CachedCollection } from './CachedCollection';
import { CachedCollection } from 'meteor/rocketchat:ui-cached-collection';

export const CachedChatRoom = new CachedCollection({ name: 'rooms' });
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { CachedCollection } from './CachedCollection';
import { CachedCollection } from 'meteor/rocketchat:ui-cached-collection';

export const CachedChatSubscription = new CachedCollection({ name: 'subscriptions' });
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CachedCollection } from './CachedCollection';
import { CachedCollection } from 'meteor/rocketchat:ui-cached-collection';

export const AuthzCachedCollection = new CachedCollection({
name: 'permissions',
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-models/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Package.onUse(function(api) {
'ecmascript',
'rocketchat:settings',
'rocketchat:callbacks',
'rocketchat:ui-cached-collection',
'konecty:multiple-instances-status',
]);
api.mainModule('client/index.js', 'client');
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-settings/client/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { settings } from '../lib/settings';
import { settings } from './lib/settings';

export {
settings,
Expand Down
Loading