From 7c26f30b0ce7e58f3bece46d47eedce39d103f33 Mon Sep 17 00:00:00 2001 From: Marcos Spessatto Defendi Date: Thu, 6 Dec 2018 13:10:26 -0200 Subject: [PATCH] Convert rocketchat-ui-flextab to main module structure (#12859) * Exposing isRtl and UserRoles * Convert rocketchat-ui-flextab to main module structure --- .../rocketchat-ui-flextab/client/flexTabBar.js | 3 ++- packages/rocketchat-ui-flextab/client/index.js | 13 +++++++++++++ .../client/tabs/inviteUsers.js | 2 ++ .../client/tabs/membersList.js | 4 +++- .../client/tabs/userActions.js | 5 +++-- .../client/tabs/userEdit.js | 2 ++ .../client/tabs/userInfo.js | 5 ++--- packages/rocketchat-ui-flextab/package.js | 17 ++--------------- .../rocketchat-ui/client/lib/collections.js | 2 +- packages/rocketchat-ui/client/lib/tapi18n.js | 2 +- packages/rocketchat-ui/package.js | 2 ++ 11 files changed, 33 insertions(+), 24 deletions(-) create mode 100644 packages/rocketchat-ui-flextab/client/index.js diff --git a/packages/rocketchat-ui-flextab/client/flexTabBar.js b/packages/rocketchat-ui-flextab/client/flexTabBar.js index c52453b7b5458..5badd59a81d93 100644 --- a/packages/rocketchat-ui-flextab/client/flexTabBar.js +++ b/packages/rocketchat-ui-flextab/client/flexTabBar.js @@ -1,9 +1,10 @@ -/* globals popover */ import { Meteor } from 'meteor/meteor'; 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'; +import { t, popover } from 'meteor/rocketchat:ui'; import _ from 'underscore'; const commonHelpers = { diff --git a/packages/rocketchat-ui-flextab/client/index.js b/packages/rocketchat-ui-flextab/client/index.js new file mode 100644 index 0000000000000..70e83cef3b3bf --- /dev/null +++ b/packages/rocketchat-ui-flextab/client/index.js @@ -0,0 +1,13 @@ +import './flexTabBar.html'; +import './tabs/inviteUsers.html'; +import './tabs/membersList.html'; +import './tabs/uploadedFilesList.html'; +import './tabs/userEdit.html'; +import './tabs/userInfo.html'; +import './flexTabBar'; +import './tabs/inviteUsers'; +import './tabs/membersList'; +import './tabs/uploadedFilesList'; +import './tabs/userEdit'; +import './tabs/userInfo'; +import './tabs/keyboardShortcuts.html'; diff --git a/packages/rocketchat-ui-flextab/client/tabs/inviteUsers.js b/packages/rocketchat-ui-flextab/client/tabs/inviteUsers.js index 26e60310006e5..00e35f7787e57 100644 --- a/packages/rocketchat-ui-flextab/client/tabs/inviteUsers.js +++ b/packages/rocketchat-ui-flextab/client/tabs/inviteUsers.js @@ -4,6 +4,8 @@ import { Blaze } from 'meteor/blaze'; import { Session } from 'meteor/session'; import { Template } from 'meteor/templating'; import { AutoComplete } from 'meteor/mizzao:autocomplete'; +import { RocketChat } from 'meteor/rocketchat:lib'; +import { t } from 'meteor/rocketchat:ui'; import toastr from 'toastr'; const acEvents = { diff --git a/packages/rocketchat-ui-flextab/client/tabs/membersList.js b/packages/rocketchat-ui-flextab/client/tabs/membersList.js index 7566899fc7793..7948c582742d9 100644 --- a/packages/rocketchat-ui-flextab/client/tabs/membersList.js +++ b/packages/rocketchat-ui-flextab/client/tabs/membersList.js @@ -1,9 +1,11 @@ -/* globals WebRTC popover isRtl */ import { Meteor } from 'meteor/meteor'; import { ReactiveVar } from 'meteor/reactive-var'; import { Tracker } from 'meteor/tracker'; import { Session } from 'meteor/session'; import { Template } from 'meteor/templating'; +import { RocketChat, handleError } from 'meteor/rocketchat:lib'; +import { t, ChatRoom, RoomManager, popover, isRtl } from 'meteor/rocketchat:ui'; +import { WebRTC } from 'meteor/rocketchat:webrtc'; import _ from 'underscore'; import { getActions } from './userActions'; diff --git a/packages/rocketchat-ui-flextab/client/tabs/userActions.js b/packages/rocketchat-ui-flextab/client/tabs/userActions.js index bc0cdd5312c2c..7f8bc884b3386 100644 --- a/packages/rocketchat-ui-flextab/client/tabs/userActions.js +++ b/packages/rocketchat-ui-flextab/client/tabs/userActions.js @@ -1,12 +1,13 @@ -/* globals RoomRoles, WebRTC*/ import { Meteor } from 'meteor/meteor'; import { FlowRouter } from 'meteor/kadira:flow-router'; import { Session } from 'meteor/session'; import { TAPi18n } from 'meteor/tap:i18n'; +import { RocketChat, handleError } from 'meteor/rocketchat:lib'; +import { WebRTC } from 'meteor/rocketchat:webrtc'; +import { t, modal, ChatRoom, ChatSubscription, RoomRoles } from 'meteor/rocketchat:ui'; import _ from 'underscore'; import toastr from 'toastr'; - export const getActions = function({ user, directActions, hideAdminControls }) { const hasPermission = RocketChat.authz.hasAllPermission; diff --git a/packages/rocketchat-ui-flextab/client/tabs/userEdit.js b/packages/rocketchat-ui-flextab/client/tabs/userEdit.js index 19c159a1b8d52..6da320f07a6f2 100644 --- a/packages/rocketchat-ui-flextab/client/tabs/userEdit.js +++ b/packages/rocketchat-ui-flextab/client/tabs/userEdit.js @@ -3,6 +3,8 @@ import { ReactiveVar } from 'meteor/reactive-var'; import { Random } from 'meteor/random'; import { Template } from 'meteor/templating'; import { TAPi18n } from 'meteor/tap:i18n'; +import { RocketChat, handleError } from 'meteor/rocketchat:lib'; +import { t } from 'meteor/rocketchat:ui'; import toastr from 'toastr'; import s from 'underscore.string'; diff --git a/packages/rocketchat-ui-flextab/client/tabs/userInfo.js b/packages/rocketchat-ui-flextab/client/tabs/userInfo.js index 8a422b6ca0b73..9a1782f60097c 100644 --- a/packages/rocketchat-ui-flextab/client/tabs/userInfo.js +++ b/packages/rocketchat-ui-flextab/client/tabs/userInfo.js @@ -1,4 +1,3 @@ -/* globals RoomRoles UserRoles popover */ import { Meteor } from 'meteor/meteor'; import { ReactiveVar } from 'meteor/reactive-var'; import { Session } from 'meteor/session'; @@ -7,8 +6,8 @@ import { TAPi18n } from 'meteor/tap:i18n'; import _ from 'underscore'; import s from 'underscore.string'; import moment from 'moment'; -import { DateFormat } from 'meteor/rocketchat:lib'; - +import { DateFormat, RocketChat } from 'meteor/rocketchat:lib'; +import { RoomRoles, popover, UserRoles } from 'meteor/rocketchat:ui'; import { getActions } from './userActions'; const more = function() { diff --git a/packages/rocketchat-ui-flextab/package.js b/packages/rocketchat-ui-flextab/package.js index 7a421084ec5fb..4789bea39691d 100644 --- a/packages/rocketchat-ui-flextab/package.js +++ b/packages/rocketchat-ui-flextab/package.js @@ -17,20 +17,7 @@ Package.onUse(function(api) { 'templating', 'rocketchat:lib', 'mizzao:autocomplete', + 'rocketchat:webrtc', ]); - - api.addFiles('client/flexTabBar.html', 'client'); - api.addFiles('client/tabs/inviteUsers.html', 'client'); - api.addFiles('client/tabs/membersList.html', 'client'); - api.addFiles('client/tabs/uploadedFilesList.html', 'client'); - api.addFiles('client/tabs/userEdit.html', 'client'); - api.addFiles('client/tabs/userInfo.html', 'client'); - - api.addFiles('client/flexTabBar.js', 'client'); - api.addFiles('client/tabs/inviteUsers.js', 'client'); - api.addFiles('client/tabs/membersList.js', 'client'); - api.addFiles('client/tabs/uploadedFilesList.js', 'client'); - api.addFiles('client/tabs/userEdit.js', 'client'); - api.addFiles('client/tabs/userInfo.js', 'client'); - api.addFiles('client/tabs/keyboardShortcuts.html', 'client'); + api.mainModule('client/index.js', 'client'); }); diff --git a/packages/rocketchat-ui/client/lib/collections.js b/packages/rocketchat-ui/client/lib/collections.js index 6e9cf03cb3904..51f9638a2d51c 100644 --- a/packages/rocketchat-ui/client/lib/collections.js +++ b/packages/rocketchat-ui/client/lib/collections.js @@ -9,7 +9,7 @@ ChatRoom = this.CachedChatRoom.collection; this.CachedChatSubscription = new RocketChat.CachedCollection({ name: 'subscriptions' }); ChatSubscription = this.CachedChatSubscription.collection; //eslint-disable-line -this.UserRoles = new Mongo.Collection(null); +UserRoles = new Mongo.Collection(null); //eslint-disable-line RoomRoles = new Mongo.Collection(null); //eslint-disable-line this.UserAndRoom = new Mongo.Collection(null); this.CachedChannelList = new Mongo.Collection(null); diff --git a/packages/rocketchat-ui/client/lib/tapi18n.js b/packages/rocketchat-ui/client/lib/tapi18n.js index 4ea4f5aaa5bf8..148d3a4cb0d93 100644 --- a/packages/rocketchat-ui/client/lib/tapi18n.js +++ b/packages/rocketchat-ui/client/lib/tapi18n.js @@ -23,7 +23,7 @@ this.tr = function(key, options, ...replaces) { } }; -this.isRtl = (lang) => { +isRtl = (lang) => { //eslint-disable-line const language = lang || localStorage.getItem('userLanguage') || 'en-US'; return ['ar', 'dv', 'fa', 'he', 'ku', 'ps', 'sd', 'ug', 'ur', 'yi'].includes(language.split('-').shift().toLowerCase()); }; diff --git a/packages/rocketchat-ui/package.js b/packages/rocketchat-ui/package.js index 47c78bbe751bd..0ccd954a30b16 100644 --- a/packages/rocketchat-ui/package.js +++ b/packages/rocketchat-ui/package.js @@ -161,4 +161,6 @@ Package.onUse(function(api) { api.export('ChatMessage', 'client'); api.export('RoomHistoryManager', 'client'); api.export('KonchatNotification', 'client'); + api.export('UserRoles', 'client'); + api.export('isRtl', 'client'); });