Skip to content

Commit

Permalink
Merge pull request RocketChat#7195 from RocketChat/fix-missing-i18n
Browse files Browse the repository at this point in the history
[FIX] Fix emoji picker translations

Add leader role and "Chat With" section at top of chat
  • Loading branch information
rodrigok authored and Daniel Schreiber committed Jul 18, 2017
2 parents 5b04c2b + 856676d commit 6b8b50a
Show file tree
Hide file tree
Showing 14 changed files with 270 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/rocketchat-2fa/client/accountSecurity.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h1>{{_ "Two-factor_authentication"}}</h1>
<div class="section-content border-component-color">
<div class="alert pending-background pending-color pending-border">
<strong>
WARNING: Once you enable this, you will not be able to login on the native mobile apps (Rocket.Chat+) using your password until they implement the 2FA.
{{_ "Two-factor_authentication_native_mobile_app_warning"}}
</strong>
</div>
{{#if isEnabled}}
Expand Down
26 changes: 26 additions & 0 deletions packages/rocketchat-api/server/v1/groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ RocketChat.API.v1.addRoute('groups.addOwner', { authRequired: true }, {
}
});

RocketChat.API.v1.addRoute('groups.addLeader', { authRequired: true }, {
post() {
const findResult = findPrivateGroupByIdOrName({ params: this.requestParams(), userId: this.userId });
const user = this.getUserFromParams();
Meteor.runAsUser(this.userId, () => {
Meteor.call('addRoomLeader', findResult.rid, user._id);
});

return RocketChat.API.v1.success();
}
});

//Archives a private group only if it wasn't
RocketChat.API.v1.addRoute('groups.archive', { authRequired: true }, {
post() {
Expand Down Expand Up @@ -373,6 +385,20 @@ RocketChat.API.v1.addRoute('groups.removeOwner', { authRequired: true }, {
}
});

RocketChat.API.v1.addRoute('groups.removeLeader', { authRequired: true }, {
post() {
const findResult = findPrivateGroupByIdOrName({ params: this.requestParams(), userId: this.userId });

const user = this.getUserFromParams();

Meteor.runAsUser(this.userId, () => {
Meteor.call('removeRoomLeader', findResult.rid, user._id);
});

return RocketChat.API.v1.success();
}
});

RocketChat.API.v1.addRoute('groups.rename', { authRequired: true }, {
post() {
if (!this.bodyParams.name || !this.bodyParams.name.trim()) {
Expand Down
2 changes: 2 additions & 0 deletions packages/rocketchat-authorization/server/startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Meteor.startup(function() {
{ _id: 'set-moderator', roles : ['admin', 'owner'] },
{ _id: 'set-owner', roles : ['admin', 'owner'] },
{ _id: 'send-many-messages', roles : ['admin', 'bot'] },
{ _id: 'set-leader', roles : ['admin', 'owner'] },
{ _id: 'unarchive-room', roles : ['admin'] },
{ _id: 'view-c-room', roles : ['admin', 'user', 'bot', 'anonymous'] },
{ _id: 'user-generate-access-token', roles : ['admin'] },
Expand Down Expand Up @@ -74,6 +75,7 @@ Meteor.startup(function() {
const defaultRoles = [
{ name: 'admin', scope: 'Users', description: 'Admin' },
{ name: 'moderator', scope: 'Subscriptions', description: 'Moderator' },
{ name: 'leader', scope: 'Subscriptions', description: 'Leader' },
{ name: 'owner', scope: 'Subscriptions', description: 'Owner' },
{ name: 'user', scope: 'Users', description: '' },
{ name: 'bot', scope: 'Users', description: '' },
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-emoji-custom/client/lib/emojiCustom.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* globals getEmojiUrlFromName:true, updateEmojiCustom:true, deleteEmojiCustom:true, isSetNotNull */
RocketChat.emoji.packages.emojiCustom = {
emojiCategories: { rocket: TAPi18n.__('Custom') },
emojiCategories: { rocket: 'Custom' },
toneList: {},
list: [],

Expand Down
16 changes: 8 additions & 8 deletions packages/rocketchat-emoji-emojione/emojiPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
* Mapping category hashes into human readable and translated names
*/
emojiCategories = {
people: TAPi18n.__('Smileys_and_People'),
nature: TAPi18n.__('Animals_and_Nature'),
food: TAPi18n.__('Food_and_Drink'),
activity: TAPi18n.__('Activity'),
travel: TAPi18n.__('Travel_and_Places'),
objects: TAPi18n.__('Objects'),
symbols: TAPi18n.__('Symbols'),
flags: TAPi18n.__('Flags')
people: 'Smileys_and_People',
nature: 'Animals_and_Nature',
food: 'Food_and_Drink',
activity: 'Activity',
travel: 'Travel_and_Places',
objects: 'Objects',
symbols: 'Symbols',
flags: 'Flags'
};

toneList = {
Expand Down
3 changes: 2 additions & 1 deletion packages/rocketchat-emoji/emojiPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ function categoryName(category) {
for (const emojiPackage in RocketChat.emoji.packages) {
if (RocketChat.emoji.packages.hasOwnProperty(emojiPackage)) {
if (RocketChat.emoji.packages[emojiPackage].emojiCategories.hasOwnProperty(category)) {
return RocketChat.emoji.packages[emojiPackage].emojiCategories[category];
const categoryTag = RocketChat.emoji.packages[emojiPackage].emojiCategories[category];
return TAPi18n.__(categoryTag);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-emoji/rocketchat.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
RocketChat.emoji = {
packages: {
base: {
emojiCategories: { recent: TAPi18n.__('Frequently_Used') },
emojiCategories: { recent: 'Frequently_Used' },
emojisByCategory: {
recent: []
},
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -1678,6 +1678,7 @@
"Two-factor_authentication_disabled": "Two-factor authentication disabled",
"Two-factor_authentication_enabled": "Two-factor authentication enabled",
"Two-factor_authentication_is_currently_disabled": "Two-factor authentication is currently disabled",
"Two-factor_authentication_native_mobile_app_warning" : "WARNING: Once you enable this, you will not be able to login on the native mobile apps (Rocket.Chat+) using your password until they implement the 2FA.",
"Thursday": "Thursday",
"Time_in_seconds": "Time in seconds",
"Title": "Title",
Expand Down
10 changes: 10 additions & 0 deletions packages/rocketchat-lib/server/models/Messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,16 @@ RocketChat.models.Messages = new class extends RocketChat.models._Base {
return this.createWithTypeRoomIdMessageAndUser('owner-removed', roomId, message, user, extraData);
}

createNewLeaderWithRoomIdAndUser(roomId, user, extraData) {
const message = user.username;
return this.createWithTypeRoomIdMessageAndUser('new-leader', roomId, message, user, extraData);
}

createLeaderRemovedWithRoomIdAndUser(roomId, user, extraData) {
const message = user.username;
return this.createWithTypeRoomIdMessageAndUser('leader-removed', roomId, message, user, extraData);
}

createSubscriptionRoleAddedWithRoomIdAndUser(roomId, user, extraData) {
const message = user.username;
return this.createWithTypeRoomIdMessageAndUser('subscription-role-added', roomId, message, user, extraData);
Expand Down
59 changes: 59 additions & 0 deletions packages/rocketchat-theme/client/imports/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -4915,3 +4915,62 @@ a + br.only-after-a {
max-height: 50px !important;
}
}

.room-leader a.chat-now {
position: absolute;
right: 25px;
width: 80px;
top: 15px;
height: 30px;
border: 1px solid #eaeaea;
text-align: center;
border-radius: 4px;
font-family: arial;
font-size: 14px;
text-decoration: none;
color: #555555;
cursor: pointer;
padding-top: 4px;
}

.room-leader a.chat-now:hover{
color: #555555;
}

.room-leader {
color: #555555;
border-bottom: solid 1px #eaeaea;
height: 54px;
background: #fff;
}

.room-leader .right {
position: absolute;
top: 10px;
}

.leader-status .status-text{
text-transform: capitalize;
padding-left: 15px;
font-size: 14px;
}
.leader-status .color-ball {
width: 10px;
height: 10px;
position: absolute;
border-radius: 5px;
margin-top: 5px;
}

.leader-status .color-ball.online {
background: green;
}

.leader-status .color-ball.offline {
background: grey;
}

.leader-info .leader-name {
font-size: 18px;
}

22 changes: 21 additions & 1 deletion packages/rocketchat-ui/client/views/app/room.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ <h2>
<span class="room-topic">{{{RocketChatMarkdown roomTopic}}}</span>
</h2>
</header>

{{/unless}}
<div class="messages-container-wrapper">
<div class="messages-container-main">
Expand Down Expand Up @@ -100,6 +100,26 @@ <h2>
{{/unless}}
<div class="wrapper {{#if hasMoreNext}}has-more-next{{/if}} {{hideUsername}} {{hideAvatar}}">
<ul aria-live="polite">
{{#if roomLeader != "" }}
<li class="message room-leader">
<button class="thumb user-card-message">
<div class="avatar"><div class="avatar-image" style="background-image:url(/avatar/{{roomLeader.username}}?_dc=undefined);"></div></div></button>
<div class="right">
<div class="leader-info">
<div class="leader-name">
{{roomLeader.name}}
</div>
<div class="leader-status userStatus">
<span class="color-ball {{roomLeader.status}}"></span>
<span class="status-text">
{{roomLeader.status}}
</span>
</div>
</div>
</div>
<a class="chat-now" href="/direct/{{roomLeader.username}}">Chat Now</a>
</li>
{{/if}}
{{#if canPreview}}
{{#if hasMore}}
<li class="load-more">
Expand Down
4 changes: 4 additions & 0 deletions packages/rocketchat-ui/client/views/app/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ Template.room.helpers({
return userCanDrop(this._id);
},

roomLeader() {
return RocketChat.models.Subscriptions.findUsersInRoles('leader', this._id).fetch()[0];
},

canPreview() {
const room = Session.get(`roomData${ this._id }`);
if (room && room.t !== 'c') {
Expand Down
67 changes: 67 additions & 0 deletions server/methods/addRoomLeader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
Meteor.methods({
addRoomLeader(rid, userId) {
check(rid, String);
check(userId, String);

if (!Meteor.userId()) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
method: 'addRoomLeader'
});
}

if (!RocketChat.authz.hasPermission(Meteor.userId(), 'set-leader', rid)) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', {
method: 'addRoomLeader'
});
}

const user = RocketChat.models.Users.findOneById(userId);

if (!user || !user.username) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
method: 'addRoomLeader'
});
}

const subscription = RocketChat.models.Subscriptions.findOneByRoomIdAndUserId(rid, user._id);

if (!subscription) {
throw new Meteor.Error('error-user-not-in-room', 'User is not in this room', {
method: 'addRoomLeader'
});
}

if (Array.isArray(subscription.roles) === true && subscription.roles.includes('leader') === true) {
throw new Meteor.Error('error-user-already-leader', 'User is already a leader', {
method: 'addRoomLeader'
});
}

RocketChat.models.Subscriptions.addRoleById(subscription._id, 'leader');

const fromUser = RocketChat.models.Users.findOneById(Meteor.userId());

RocketChat.models.Messages.createSubscriptionRoleAddedWithRoomIdAndUser(rid, user, {
u: {
_id: fromUser._id,
username: fromUser.username
},
role: 'leader'
});

if (RocketChat.settings.get('UI_DisplayRoles')) {
RocketChat.Notifications.notifyLogged('roles-change', {
type: 'added',
_id: 'leader',
u: {
_id: user._id,
username: user.username,
name: user.name
},
scope: rid
});
}

return true;
}
});
67 changes: 67 additions & 0 deletions server/methods/removeRoomLeader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
Meteor.methods({
removeRoomLeader(rid, userId) {
check(rid, String);
check(userId, String);

if (!Meteor.userId()) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
method: 'removeRoomLeader'
});
}

if (!RocketChat.authz.hasPermission(Meteor.userId(), 'set-leader', rid)) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', {
method: 'removeRoomLeader'
});
}

const user = RocketChat.models.Users.findOneById(userId);

if (!user || !user.username) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
method: 'removeRoomLeader'
});
}

const subscription = RocketChat.models.Subscriptions.findOneByRoomIdAndUserId(rid, user._id);

if (!subscription) {
throw new Meteor.Error('error-user-not-in-room', 'User is not in this room', {
method: 'removeRoomLeader'
});
}

if (Array.isArray(subscription.roles) === true && subscription.roles.includes('leader') === false) {
throw new Meteor.Error('error-user-already-leader', 'User is not a leader', {
method: 'removeRoomLeader'
});
}

RocketChat.models.Subscriptions.removeRoleById(subscription._id, 'leader');

const fromUser = RocketChat.models.Users.findOneById(Meteor.userId());

RocketChat.models.Messages.createSubscriptionRoleRemovedWithRoomIdAndUser(rid, user, {
u: {
_id: fromUser._id,
username: fromUser.username
},
role: 'leader'
});

if (RocketChat.settings.get('UI_DisplayRoles')) {
RocketChat.Notifications.notifyLogged('roles-change', {
type: 'removed',
_id: 'leader',
u: {
_id: user._id,
username: user.username,
name: user.name
},
scope: rid
});
}

return true;
}
});

0 comments on commit 6b8b50a

Please sign in to comment.