Skip to content
Snippets Groups Projects
Commit 93d4ada0 authored by Thomas Spiesser's avatar Thomas Spiesser Committed by Rodrigo Nascimento
Browse files

add editable channel descriptions (#3705)

parent a12f6463
No related branches found
No related tags found
No related merge requests found
......@@ -18,3 +18,11 @@ Meteor.startup ->
user_by: message.u?.username
room_topic: message.msg
}
RocketChat.MessageTypes.registerType
id: 'room_changed_description'
system: true
message: 'room_changed_description'
data: (message) ->
user_by: message.u?.username
room_description: message.msg
......@@ -23,6 +23,8 @@ Template.channelSettings.helpers
return ChatRoom.findOne(@rid, { fields: { topic: 1 }})?.topic
roomTopicUnescaped: ->
return s.unescapeHTML ChatRoom.findOne(@rid, { fields: { topic: 1 }})?.topic
roomDescription: ->
return ChatRoom.findOne(@rid, { fields: { description: 1 }})?.description
archivationState: ->
return ChatRoom.findOne(@rid, { fields: { archived: 1 }})?.archived
archivationStateDescription: ->
......@@ -109,6 +111,11 @@ Template.channelSettings.onCreated ->
Meteor.call 'saveRoomSettings', room._id, 'roomType', @$('input[name=roomType]:checked').val(), (err, result) ->
return handleError err if err
toastr.success TAPi18n.__ 'Room_type_changed_successfully'
when 'roomDescription'
if @validateRoomTopic()
Meteor.call 'saveRoomSettings', room._id, 'roomDescription', @$('input[name=roomDescription]').val(), (err, result) ->
return handleError err if err
toastr.success TAPi18n.__ 'Room_description_changed_successfully'
when 'archivationState'
if @$('input[name=archivationState]:checked').val() is 'true'
if room.archived isnt true
......
......@@ -28,6 +28,18 @@
{{/if}}
</div>
</li>
{{#if notDirect}}
<li>
<label>{{_ "Description"}}</label>
<div>
{{#if editing 'roomDescription'}}
<input type="text" name="roomDescription" value="{{roomDescription}}" class="editing" /> <button type="button" class="button secondary cancel">{{_ "Cancel"}}</button><button type="button" class="button primary save">{{_ "Save"}}</button>
{{else}}
<span>{{roomDescription}}{{#if canEdit}} <i class="icon-pencil" data-edit="roomDescription"></i>{{/if}}</span>
{{/if}}
</div>
</li>
{{/if}}
{{#if notDirect}}
<li>
<label>{{_ "Type"}}</label>
......
......@@ -31,7 +31,9 @@ Package.onUse(function(api) {
'server/functions/saveRoomType.coffee',
'server/functions/saveRoomTopic.coffee',
'server/functions/saveRoomName.coffee',
'server/functions/saveRoomDescription.coffee',
'server/methods/saveRoomSettings.coffee',
'server/models/Messages.coffee'
'server/models/Messages.coffee',
'server/models/Rooms.coffee'
], 'server');
});
RocketChat.saveRoomDescription = (rid, roomDescription) ->
unless Match.test rid, String
throw new Meteor.Error 'invalid-rid'
return RocketChat.models.Rooms.setDescriptionById rid, roomDescription
......@@ -3,7 +3,7 @@ Meteor.methods
unless Match.test rid, String
throw new Meteor.Error 'error-invalid-room', 'Invalid room', { method: 'saveRoomSettings' }
if setting not in ['roomName', 'roomTopic', 'roomType', 'default']
if setting not in ['roomName', 'roomTopic', 'roomDescription', 'roomType', 'default']
throw new Meteor.Error 'error-invalid-settings', 'Invalid settings provided', { method: 'saveRoomSettings' }
unless RocketChat.authz.hasPermission(Meteor.userId(), 'edit-room', rid)
......@@ -21,6 +21,10 @@ Meteor.methods
when 'roomTopic'
if value isnt room.topic
RocketChat.saveRoomTopic(rid, value, Meteor.user())
when 'roomDescription'
if value isnt room.description
RocketChat.saveRoomDescription rid, value
RocketChat.models.Messages.createRoomSettingsChangedWithTypeRoomIdMessageAndUser 'room_changed_description', rid, value, Meteor.user()
when 'roomType'
if value isnt room.t
RocketChat.saveRoomType(rid, value, Meteor.user())
......
RocketChat.models.Rooms.setDescriptionById = (_id, description) ->
query =
_id: _id
update =
$set:
description: description
return @update query, update
......@@ -896,8 +896,10 @@
"Room_archivation_state_false" : "Active",
"Room_archivation_state_true" : "Archived",
"Room_archived" : "Room archived",
"room_changed_description" : "Room description changed to: <em>__room_description__</em> by <em>__user_by__</em>",
"room_changed_privacy" : "Room type changed to: <em>__room_type__</em> by <em>__user_by__</em>",
"room_changed_topic" : "Room topic changed to: <em>__room_topic__</em> by <em>__user_by__</em>",
"Room_description_changed_successfully" : "Room description changed successfully",
"Room_has_been_deleted" : "Room has been deleted",
"Room_Info" : "Room Info",
"Room_name_changed" : "Room name changed to: <em>__room_name__</em> by <em>__user_by__</em>",
......
......@@ -11,6 +11,7 @@ Meteor.startup ->
muted: 1
archived: 1
jitsiTimeout: 1
description: 1
if RocketChat.authz.hasPermission(this.userId, 'view-c-room')
return RocketChat.models.Rooms.findByTypeAndName 'c', identifier, options
......@@ -32,6 +33,7 @@ Meteor.startup ->
muted: 1
archived: 1
jitsiTimeout: 1
description: 1
user = RocketChat.models.Users.findOneById this.userId, fields: username: 1
return RocketChat.models.Rooms.findByTypeAndNameContainingUsername 'p', identifier, user.username, options
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment