Merge branch 'matthias-brun-develop' into develop

pull/1738/merge
Marcelo Schmidt 10 years ago
commit f4464a1392
  1. 9
      i18n/en.i18n.json
  2. 35
      packages/rocketchat-channel-settings/client/views/channelSettings.coffee
  3. 10
      packages/rocketchat-channel-settings/client/views/channelSettings.html
  4. 1
      packages/rocketchat-channel-settings/i18n/en.i18n.json
  5. 11
      packages/rocketchat-lib/server/models/Rooms.coffee
  6. 2
      packages/rocketchat-lib/server/models/Subscriptions.coffee
  7. 3
      packages/rocketchat-ui-sidenav/side-nav/createChannelFlex.coffee
  8. 6
      packages/rocketchat-ui-sidenav/side-nav/createChannelFlex.html
  9. 2
      packages/rocketchat-ui-sidenav/side-nav/listPrivateGroupsFlex.coffee
  10. 3
      packages/rocketchat-ui-sidenav/side-nav/privateGroupsFlex.coffee
  11. 6
      packages/rocketchat-ui-sidenav/side-nav/privateGroupsFlex.html
  12. 9
      packages/rocketchat-ui/views/app/privateHistory.coffee
  13. 23
      packages/rocketchat-ui/views/app/privateHistory.html
  14. 2
      server/methods/channelsList.coffee
  15. 3
      server/methods/createChannel.coffee
  16. 3
      server/methods/createPrivateGroup.coffee
  17. 4
      server/methods/unarchiveRoom.coffee
  18. 1
      server/publications/subscription.coffee
  19. 2
      server/startup/roomPublishes.coffee

@ -76,6 +76,7 @@
"API_Embed" : "Embed", "API_Embed" : "Embed",
"API_EmbedDisabledFor" : "Disable Embed for Users", "API_EmbedDisabledFor" : "Disable Embed for Users",
"API_EmbedDisabledFor_Description" : "Comma-separated list of usernames", "API_EmbedDisabledFor_Description" : "Comma-separated list of usernames",
"Archive" : "Archive",
"are_also_typing" : "are also typing", "are_also_typing" : "are also typing",
"are_typing" : "are typing", "are_typing" : "are typing",
"Are_you_sure" : "Are you sure?", "Are_you_sure" : "Are you sure?",
@ -139,6 +140,8 @@
"Disable_New_Room_Notification" : "Disable New Room Notification", "Disable_New_Room_Notification" : "Disable New Room Notification",
"Do_you_want_to_change_to_s_question" : "Do you want to change to <strong>%s</strong>?", "Do_you_want_to_change_to_s_question" : "Do you want to change to <strong>%s</strong>?",
"Drop_to_upload_file" : "Drop to upload file", "Drop_to_upload_file" : "Drop to upload file",
"Duplicate_archived_channel_name" : "An archived Channel with name '%s' exists",
"Duplicate_archived_private_group_name" : "An archived Private Group with name '%s' exists",
"Duplicate_channel_name" : "A Channel with name '%s' exists", "Duplicate_channel_name" : "A Channel with name '%s' exists",
"Duplicate_private_group_name" : "A Private Group with name '%s' exists", "Duplicate_private_group_name" : "A Private Group with name '%s' exists",
"E-mail" : "E-mail", "E-mail" : "E-mail",
@ -217,8 +220,8 @@
"italics" : "italics", "italics" : "italics",
"join" : "Join", "join" : "Join",
"Join_the_Community" : "Join the Community", "Join_the_Community" : "Join the Community",
"Jump_to_recent_messages" : "Jump to recent messages",
"Jump_to_message" : "Jump to message", "Jump_to_message" : "Jump to message",
"Jump_to_recent_messages" : "Jump to recent messages",
"Language" : "Language", "Language" : "Language",
"Language_Version" : "English Version", "Language_Version" : "English Version",
"Last_login" : "Last login", "Last_login" : "Last login",
@ -383,10 +386,12 @@
"Restart" : "Restart", "Restart" : "Restart",
"Restart_the_server" : "Restart the server", "Restart_the_server" : "Restart the server",
"Room" : "Room", "Room" : "Room",
"Room_archived" : "Room archived",
"Room_has_been_deleted" : "Room has been deleted", "Room_has_been_deleted" : "Room has been deleted",
"Room_name_changed" : "Room name changed to: <em>__room_name__</em> by <em>__user_by__</em>", "Room_name_changed" : "Room name changed to: <em>__room_name__</em> by <em>__user_by__</em>",
"Room_name_changed_successfully" : "Room name changed successfully", "Room_name_changed_successfully" : "Room name changed successfully",
"Room_not_found" : "Room not found", "Room_not_found" : "Room not found",
"Room_unarchived" : "Room unarchived",
"Room_uploaded_file_list" : "Files List", "Room_uploaded_file_list" : "Files List",
"Room_uploaded_file_list_empty" : "No files available.", "Room_uploaded_file_list_empty" : "No files available.",
"room_user_count" : "%s users", "room_user_count" : "%s users",
@ -426,6 +431,7 @@
"Settings_updated" : "Settings updated", "Settings_updated" : "Settings updated",
"Should_be_a_URL_of_an_image" : "Should be a URL of an image.", "Should_be_a_URL_of_an_image" : "Should be a URL of an image.",
"Should_exists_a_user_with_this_username" : "The user must already exist.", "Should_exists_a_user_with_this_username" : "The user must already exist.",
"Showing_archived_results" : "<p>Showing <b>%s</b> archived results</p>",
"Showing_online_users" : "Showing <b>__total_online__</b> of __total__ users", "Showing_online_users" : "Showing <b>__total_online__</b> of __total__ users",
"Showing_results" : "<p>Showing <b>%s</b> results</p>", "Showing_results" : "<p>Showing <b>%s</b> results</p>",
"Silence" : "Silence", "Silence" : "Silence",
@ -477,6 +483,7 @@
"There_is_no_integrations" : "There is no integrations", "There_is_no_integrations" : "There is no integrations",
"This_is_a_push_test_messsage" : "This is a push test messsage", "This_is_a_push_test_messsage" : "This is a push test messsage",
"True" : "True", "True" : "True",
"Unarchive" : "Unarchive",
"Unmute_user" : "Unmute user", "Unmute_user" : "Unmute user",
"Unnamed" : "Unnamed", "Unnamed" : "Unnamed",
"Unread_Rooms" : "Unread Rooms", "Unread_Rooms" : "Unread Rooms",

@ -19,27 +19,10 @@ Template.channelSettings.helpers
return ChatRoom.findOne(@rid)?.name return ChatRoom.findOne(@rid)?.name
roomTopic: -> roomTopic: ->
return ChatRoom.findOne(@rid)?.topic return ChatRoom.findOne(@rid)?.topic
archived: ->
return ChatRoom.findOne(@rid)?.archived
Template.channelSettings.events Template.channelSettings.events
# 'click .save': (e, t) ->
# e.preventDefault()
# settings =
# roomType: t.$('input[name=roomType]:checked').val()
# roomName: t.$('input[name=roomName]').val()
# roomTopic: t.$('input[name=roomTopic]').val()
# if t.validate()
# Meteor.call 'saveRoomSettings', t.data.rid, settings, (err, results) ->
# if err
# if err.error in [ 'duplicate-name', 'name-invalid' ]
# return toastr.error TAPi18n.__(err.reason, err.details.channelName)
# if err.error is 'invalid-room-type'
# return toastr.error TAPi18n.__(err.reason, err.details.roomType)
# return toastr.error TAPi18n.__(err.reason)
# toastr.success TAPi18n.__ 'Settings_updated'
'keydown input[type=text]': (e, t) -> 'keydown input[type=text]': (e, t) ->
if e.keyCode is 13 if e.keyCode is 13
e.preventDefault() e.preventDefault()
@ -58,6 +41,20 @@ Template.channelSettings.events
e.preventDefault() e.preventDefault()
t.saveSetting() t.saveSetting()
'click .archive': (e, t) ->
e.preventDefault()
Meteor.call 'archiveRoom', t.data.rid, true, (err, results) ->
return toastr.error err.reason if err
toastr.success TAPi18n.__ 'Room_archived'
'click .unarchive': (e, t) ->
e.preventDefault()
Meteor.call 'unarchiveRoom', t.data.rid, true, (err, results) ->
return toastr.error err.reason if err
toastr.success TAPi18n.__ 'Room_unarchived'
Template.channelSettings.onCreated -> Template.channelSettings.onCreated ->
@editing = new ReactiveVar @editing = new ReactiveVar

@ -43,6 +43,16 @@
</div> </div>
</li> </li>
{{/if}} {{/if}}
{{#if notDirect}}
<li>
<label>{{_ "Archive_Unarchive"}}</label>
{{#if archived}}
<button class="button unarchive"><span>{{_ "Unarchive"}}</span></button>
{{else}}
<button class="button archive"><span>{{_ "Archive"}}</span></button>
{{/if}}
</li>
{{/if}}
{{#each channelSettings}} {{#each channelSettings}}
{{> Template.dynamic template=template data=data}} {{> Template.dynamic template=template data=data}}
{{/each}} {{/each}}

@ -1,4 +1,5 @@
{ {
"Archive_Unarchive": "Archive / Unarchive",
"Cancel": "Cancel", "Cancel": "Cancel",
"Channel": "Channel", "Channel": "Channel",
"Private_Group": "Private Group", "Private_Group": "Private Group",

@ -147,6 +147,17 @@ RocketChat.models.Rooms = new class extends RocketChat.models._Base
return @find query, options return @find query, options
findByTypeAndArchivationState: (type, archivationstate, options) ->
query =
t: type
if archivationstate
query.archived = true
else
query.archived = { $ne: true }
return @find query, options
findByVisitorToken: (visitorToken, options) -> findByVisitorToken: (visitorToken, options) ->
query = query =
"v.token": visitorToken "v.token": visitorToken

@ -54,7 +54,7 @@ RocketChat.models.Subscriptions = new class extends RocketChat.models._Base
update = update =
$set: $set:
alert: false alert: false
open: false open: true
archived: false archived: false
return @update query, update return @update query, update

@ -90,6 +90,9 @@ Template.createChannelFlex.events
if err.error is 'duplicate-name' if err.error is 'duplicate-name'
instance.error.set({ duplicate: true }) instance.error.set({ duplicate: true })
return return
if err.error is 'archived-duplicate-name'
instance.error.set({ archivedduplicate: true })
return
else else
return toastr.error err.reason return toastr.error err.reason

@ -40,6 +40,12 @@
{{{_ "Duplicate_channel_name" roomName}}} {{{_ "Duplicate_channel_name" roomName}}}
</div> </div>
{{/if}} {{/if}}
{{#if error.archivedduplicate}}
<div class="input-error">
<strong>{{_ "Oops!"}}</strong>
{{{_ "Duplicate_archived_channel_name" roomName}}}
</div>
{{/if}}
<div class="input-submit"> <div class="input-submit">
<button class="button clean primary save-channel">{{_ "Save" }}</button> <button class="button clean primary save-channel">{{_ "Save" }}</button>
<button class="button clean cancel-channel">{{_ "Cancel" }}</button> <button class="button clean cancel-channel">{{_ "Cancel" }}</button>

@ -1,6 +1,6 @@
Template.listPrivateGroupsFlex.helpers Template.listPrivateGroupsFlex.helpers
groups: -> groups: ->
return ChatSubscription.find { t: { $in: ['p']}, f: { $ne: true } }, { sort: 't': 1, 'name': 1 } return ChatSubscription.find { t: { $in: ['p']}, f: { $ne: true }, archived: { $ne: true } }, { sort: 't': 1, 'name': 1 }
Template.listPrivateGroupsFlex.events Template.listPrivateGroupsFlex.events
'click header': -> 'click header': ->

@ -85,6 +85,9 @@ Template.privateGroupsFlex.events
if err.error is 'duplicate-name' if err.error is 'duplicate-name'
instance.error.set({ duplicate: true }) instance.error.set({ duplicate: true })
return return
if err.error is 'archived-duplicate-name'
instance.error.set({ archivedduplicate: true })
return
return toastr.error err.reason return toastr.error err.reason
SideNav.closeFlex() SideNav.closeFlex()
instance.clearForm() instance.clearForm()

@ -40,6 +40,12 @@
{{{_ "Duplicate_private_group_name" groupName}}} {{{_ "Duplicate_private_group_name" groupName}}}
</div> </div>
{{/if}} {{/if}}
{{#if error.archivedduplicate}}
<div class="input-error">
<strong>{{_ "Oops!"}}</strong>
{{{_ "Duplicate_archived_private_group_name" groupName}}}
</div>
{{/if}}
<div class="input-submit"> <div class="input-submit">
<button class="button clean primary save-pvt-group">{{_ "Save" }}</button> <button class="button clean primary save-pvt-group">{{_ "Save" }}</button>
<button class="button clean cancel-pvt-group">{{_ "Cancel" }}</button> <button class="button clean cancel-pvt-group">{{_ "Cancel" }}</button>

@ -1,6 +1,13 @@
Template.privateHistory.helpers Template.privateHistory.helpers
history: -> history: ->
items = ChatSubscription.find { name: { $regex: Session.get('historyFilter'), $options: 'i' }, t: { $in: ['d', 'c', 'p'] } }, {'sort': { 'ts': -1 } } items = ChatSubscription.find { name: { $regex: Session.get('historyFilter'), $options: 'i' }, t: { $in: ['d', 'c', 'p'] }, archived: { $ne: true } }, {'sort': { 'ts': -1 } }
return {
items: items
length: items.count()
}
archivedHistory: ->
items = ChatSubscription.find { name: { $regex: Session.get('historyFilter'), $options: 'i' }, t: { $in: ['d', 'c', 'p'] }, archived: true }, {'sort': { 'ts': -1 } }
return { return {
items: items items: items
length: items.count() length: items.count()

@ -35,6 +35,29 @@
</a> </a>
{{/each}} {{/each}}
</div> </div>
<div class="results">
{{{_ "Showing_archived_results" archivedHistory.length}}}
</div>
<div class="list">
{{#each archivedHistory.items}}
<a href="{{path}}">
<div class="info">
<h3><i class="{{type}}"></i><span class="enter-room">{{name}}</span></h3>
<ul>
{{#with roomOf rid}}
<li>{{_ "n_messages" msgs}}</li>
<li>{{_ "since_creation" creation}}</li>
{{/with}}
</ul>
</div>
<div class="status">
{{#with roomOf rid}}
<strong>{{lastMessage}}</strong>
{{/with}}
</div>
</a>
{{/each}}
</div>
</div> </div>
</section> </section>
</template> </template>

@ -1,3 +1,3 @@
Meteor.methods Meteor.methods
channelsList: -> channelsList: ->
return { channels: RocketChat.models.Rooms.findByType('c', { sort: { msgs:-1 } }).fetch() } return { channels: RocketChat.models.Rooms.findByTypeAndArchivationState('c', false, { sort: { msgs:-1 } }).fetch() }

@ -21,6 +21,9 @@ Meteor.methods
# avoid duplicate names # avoid duplicate names
if RocketChat.models.Rooms.findOneByName name if RocketChat.models.Rooms.findOneByName name
if RocketChat.models.Rooms.findOneByName(name).archived
throw new Meteor.Error 'archived-duplicate-name'
else
throw new Meteor.Error 'duplicate-name' throw new Meteor.Error 'duplicate-name'
# name = s.slugify name # name = s.slugify name

@ -24,6 +24,9 @@ Meteor.methods
# avoid duplicate names # avoid duplicate names
if RocketChat.models.Rooms.findOneByName name if RocketChat.models.Rooms.findOneByName name
if RocketChat.models.Rooms.findOneByName(name).archived
throw new Meteor.Error 'archived-duplicate-name'
else
throw new Meteor.Error 'duplicate-name' throw new Meteor.Error 'duplicate-name'
# create new room # create new room

@ -1,7 +1,7 @@
Meteor.methods Meteor.methods
unArchiveRoom: (rid) -> unarchiveRoom: (rid) ->
if not Meteor.userId() if not Meteor.userId()
throw new Meteor.Error 'invalid-user', '[methods] unArchiveRoom -> Invalid user' throw new Meteor.Error 'invalid-user', '[methods] unarchiveRoom -> Invalid user'
room = RocketChat.models.Rooms.findOneById rid room = RocketChat.models.Rooms.findOneById rid

@ -13,3 +13,4 @@ Meteor.publish 'subscription', ->
open: 1 open: 1
alert: 1 alert: 1
unread: 1 unread: 1
archived: 1

@ -9,6 +9,7 @@ Meteor.startup ->
usernames: 1 usernames: 1
topic: 1 topic: 1
muted: 1 muted: 1
archived: 1
return RocketChat.models.Rooms.findByTypeAndName 'c', identifier, options return RocketChat.models.Rooms.findByTypeAndName 'c', identifier, options
@ -22,6 +23,7 @@ Meteor.startup ->
usernames: 1 usernames: 1
topic: 1 topic: 1
muted: 1 muted: 1
archived: 1
user = RocketChat.models.Users.findOneById this.userId, fields: username: 1 user = RocketChat.models.Users.findOneById this.userId, fields: username: 1
return RocketChat.models.Rooms.findByTypeAndNameContainigUsername 'p', identifier, user.username, options return RocketChat.models.Rooms.findByTypeAndNameContainigUsername 'p', identifier, user.username, options

Loading…
Cancel
Save