Browse Source

Render disconnect message via template and add padding.

JC Brand 8 years ago
parent
commit
6af4480c14
7 changed files with 32 additions and 20 deletions
  1. 3 0
      css/converse.css
  2. 1 0
      docs/CHANGES.md
  3. 3 1
      sass/_chatrooms.scss
  4. 11 11
      spec/chatroom.js
  5. 1 0
      src/config.js
  6. 12 8
      src/converse-muc.js
  7. 1 0
      src/templates/chatroom_disconnect.html

+ 3 - 0
css/converse.css

@@ -2308,6 +2308,9 @@
       #converse-embedded-chat .chatroom .box-flyout .chatroom-body .chat-msg-room,
       #converse-embedded-chat .chatroom .box-flyout .chatroom-body .chat-msg-room,
       #conversejs .chatroom .box-flyout .chatroom-body .chat-msg-room {
       #conversejs .chatroom .box-flyout .chatroom-body .chat-msg-room {
         color: #1A9707; }
         color: #1A9707; }
+      #converse-embedded-chat .chatroom .box-flyout .chatroom-body .disconnect-msg,
+      #conversejs .chatroom .box-flyout .chatroom-body .disconnect-msg {
+        padding: 2em 2em 0 2em; }
       #converse-embedded-chat .chatroom .box-flyout .chatroom-body .chat-area,
       #converse-embedded-chat .chatroom .box-flyout .chatroom-body .chat-area,
       #conversejs .chatroom .box-flyout .chatroom-body .chat-area {
       #conversejs .chatroom .box-flyout .chatroom-body .chat-area {
         word-wrap: break-word;
         word-wrap: break-word;

+ 1 - 0
docs/CHANGES.md

@@ -18,6 +18,7 @@
 - #842 Persistent muc room creation not working [jcbrand]
 - #842 Persistent muc room creation not working [jcbrand]
 - #848 OTR doesn't start when `cache_otr_key` is set to `true`. [jcbrand]
 - #848 OTR doesn't start when `cache_otr_key` is set to `true`. [jcbrand]
 - #849 `TypeError: _converse.i18n.locale_data is undefined` when reconnecting. [jcbrand]
 - #849 `TypeError: _converse.i18n.locale_data is undefined` when reconnecting. [jcbrand]
+- #850 Roster not loading when group names are numbers. [jcbrand]
 
 
 ## 3.0.1 (2017-04-04)
 ## 3.0.1 (2017-04-04)
 
 

+ 3 - 1
sass/_chatrooms.scss

@@ -71,7 +71,9 @@
                 .chat-msg-room {
                 .chat-msg-room {
                     color: $message-them-color;
                     color: $message-them-color;
                 }
                 }
-
+                .disconnect-msg {
+                    padding: 2em 2em 0 2em;
+                }
                 .chat-area {
                 .chat-area {
                     word-wrap: break-word; 
                     word-wrap: break-word; 
                     height: 100%;
                     height: 100%;

+ 11 - 11
spec/chatroom.js

@@ -1441,11 +1441,11 @@
                 expect(view.$('.chat-area').is(':visible')).toBeFalsy();
                 expect(view.$('.chat-area').is(':visible')).toBeFalsy();
                 expect(view.$('.occupants').is(':visible')).toBeFalsy();
                 expect(view.$('.occupants').is(':visible')).toBeFalsy();
                 var $chat_body = view.$('.chatroom-body');
                 var $chat_body = view.$('.chatroom-body');
-                expect($chat_body.html().trim().indexOf(
-                    '<p>You have been kicked from this room</p>'+
-                    '<p>This action was done by Fluellen.</p>'+
-                    '<p>The reason given is: "Avaunt, you cullion!".</p>'
-                )).not.toBe(-1);
+                expect($chat_body.find('.disconnect-msg').text()).toBe(
+                    'You have been kicked from this room'+
+                    'This action was done by Fluellen.'+
+                    'The reason given is: "Avaunt, you cullion!".'
+                );
             }));
             }));
 
 
             it("can be saved to, and retrieved from, browserStorage", mock.initConverse(function (_converse) {
             it("can be saved to, and retrieved from, browserStorage", mock.initConverse(function (_converse) {
@@ -1703,7 +1703,7 @@
                 var view = _converse.chatboxviews.get('problematic@muc.localhost');
                 var view = _converse.chatboxviews.get('problematic@muc.localhost');
                 spyOn(view, 'showErrorMessage').and.callThrough();
                 spyOn(view, 'showErrorMessage').and.callThrough();
                 view.onChatRoomPresence(presence);
                 view.onChatRoomPresence(presence);
-                expect(view.$el.find('.chatroom-body p:last').text()).toBe('You are not on the member list of this room');
+                expect(view.$el.find('.chatroom-body p:last').text()).toBe('You are not on the member list of this room.');
             }));
             }));
 
 
             it("will show an error message if the user has been banned", mock.initConverse(function (_converse) {
             it("will show an error message if the user has been banned", mock.initConverse(function (_converse) {
@@ -1719,7 +1719,7 @@
                 var view = _converse.chatboxviews.get('problematic@muc.localhost');
                 var view = _converse.chatboxviews.get('problematic@muc.localhost');
                 spyOn(view, 'showErrorMessage').and.callThrough();
                 spyOn(view, 'showErrorMessage').and.callThrough();
                 view.onChatRoomPresence(presence);
                 view.onChatRoomPresence(presence);
-                expect(view.$el.find('.chatroom-body p:last').text()).toBe('You have been banned from this room');
+                expect(view.$el.find('.chatroom-body p:last').text()).toBe('You have been banned from this room.');
             }));
             }));
 
 
             it("will render a nickname form if a nickname conflict happens and muc_nickname_from_jid=false", mock.initConverse(function (_converse) {
             it("will render a nickname form if a nickname conflict happens and muc_nickname_from_jid=false", mock.initConverse(function (_converse) {
@@ -1804,7 +1804,7 @@
                 var view = _converse.chatboxviews.get('problematic@muc.localhost');
                 var view = _converse.chatboxviews.get('problematic@muc.localhost');
                 spyOn(view, 'showErrorMessage').and.callThrough();
                 spyOn(view, 'showErrorMessage').and.callThrough();
                 view.onChatRoomPresence(presence);
                 view.onChatRoomPresence(presence);
-                expect(view.$el.find('.chatroom-body p:last').text()).toBe('You are not allowed to create new rooms');
+                expect(view.$el.find('.chatroom-body p:last').text()).toBe('You are not allowed to create new rooms.');
             }));
             }));
 
 
             it("will show an error message if the user's nickname doesn't conform to room policy", mock.initConverse(function (_converse) {
             it("will show an error message if the user's nickname doesn't conform to room policy", mock.initConverse(function (_converse) {
@@ -1820,7 +1820,7 @@
                 var view = _converse.chatboxviews.get('problematic@muc.localhost');
                 var view = _converse.chatboxviews.get('problematic@muc.localhost');
                 spyOn(view, 'showErrorMessage').and.callThrough();
                 spyOn(view, 'showErrorMessage').and.callThrough();
                 view.onChatRoomPresence(presence);
                 view.onChatRoomPresence(presence);
-                expect(view.$el.find('.chatroom-body p:last').text()).toBe("Your nickname doesn't conform to this room's policies");
+                expect(view.$el.find('.chatroom-body p:last').text()).toBe("Your nickname doesn't conform to this room's policies.");
             }));
             }));
 
 
             it("will show an error message if the room doesn't yet exist", mock.initConverse(function (_converse) {
             it("will show an error message if the room doesn't yet exist", mock.initConverse(function (_converse) {
@@ -1836,7 +1836,7 @@
                 var view = _converse.chatboxviews.get('problematic@muc.localhost');
                 var view = _converse.chatboxviews.get('problematic@muc.localhost');
                 spyOn(view, 'showErrorMessage').and.callThrough();
                 spyOn(view, 'showErrorMessage').and.callThrough();
                 view.onChatRoomPresence(presence);
                 view.onChatRoomPresence(presence);
-                expect(view.$el.find('.chatroom-body p:last').text()).toBe("This room does not (yet) exist");
+                expect(view.$el.find('.chatroom-body p:last').text()).toBe("This room does not (yet) exist.");
             }));
             }));
 
 
             it("will show an error message if the room has reached its maximum number of occupants", mock.initConverse(function (_converse) {
             it("will show an error message if the room has reached its maximum number of occupants", mock.initConverse(function (_converse) {
@@ -1852,7 +1852,7 @@
                 var view = _converse.chatboxviews.get('problematic@muc.localhost');
                 var view = _converse.chatboxviews.get('problematic@muc.localhost');
                 spyOn(view, 'showErrorMessage').and.callThrough();
                 spyOn(view, 'showErrorMessage').and.callThrough();
                 view.onChatRoomPresence(presence);
                 view.onChatRoomPresence(presence);
-                expect(view.$el.find('.chatroom-body p:last').text()).toBe("This room has reached its maximum number of occupants");
+                expect(view.$el.find('.chatroom-body p:last').text()).toBe("This room has reached its maximum number of occupants.");
             }));
             }));
         });
         });
 
 

+ 1 - 0
src/config.js

@@ -108,6 +108,7 @@ require.config({
         "chatroom":                 "src/templates/chatroom",
         "chatroom":                 "src/templates/chatroom",
         "chatroom_bookmark_form":   "src/templates/chatroom_bookmark_form",
         "chatroom_bookmark_form":   "src/templates/chatroom_bookmark_form",
         "chatroom_bookmark_toggle": "src/templates/chatroom_bookmark_toggle",
         "chatroom_bookmark_toggle": "src/templates/chatroom_bookmark_toggle",
+        "chatroom_disconnect":      "src/templates/chatroom_disconnect",
         "chatroom_features":        "src/templates/chatroom_features",
         "chatroom_features":        "src/templates/chatroom_features",
         "chatroom_form":            "src/templates/chatroom_form",
         "chatroom_form":            "src/templates/chatroom_form",
         "chatroom_head":            "src/templates/chatroom_head",
         "chatroom_head":            "src/templates/chatroom_head",

+ 12 - 8
src/converse-muc.js

@@ -14,6 +14,7 @@
             "converse-core",
             "converse-core",
             "tpl!chatarea",
             "tpl!chatarea",
             "tpl!chatroom",
             "tpl!chatroom",
+            "tpl!chatroom_disconnect",
             "tpl!chatroom_features",
             "tpl!chatroom_features",
             "tpl!chatroom_form",
             "tpl!chatroom_form",
             "tpl!chatroom_head",
             "tpl!chatroom_head",
@@ -35,6 +36,7 @@
             converse,
             converse,
             tpl_chatarea,
             tpl_chatarea,
             tpl_chatroom,
             tpl_chatroom,
+            tpl_chatroom_disconnect,
             tpl_chatroom_features,
             tpl_chatroom_features,
             tpl_chatroom_form,
             tpl_chatroom_form,
             tpl_chatroom_head,
             tpl_chatroom_head,
@@ -1594,7 +1596,9 @@
                     this.$('.chat-area').addClass('hidden');
                     this.$('.chat-area').addClass('hidden');
                     this.$('.occupants').addClass('hidden');
                     this.$('.occupants').addClass('hidden');
                     this.$('span.centered.spinner').remove();
                     this.$('span.centered.spinner').remove();
-                    this.$('.chatroom-body').append($('<p>'+msg+'</p>'));
+                    this.$('.chatroom-body').append(tpl_chatroom_disconnect({
+                        'disconnect_message': msg
+                    }));
                 },
                 },
 
 
                 getMessageFromStatus: function (stat, stanza, is_self) {
                 getMessageFromStatus: function (stat, stanza, is_self) {
@@ -1773,25 +1777,25 @@
                         if (!_.isNull(error.querySelector('not-authorized'))) {
                         if (!_.isNull(error.querySelector('not-authorized'))) {
                             this.renderPasswordForm();
                             this.renderPasswordForm();
                         } else if (!_.isNull(error.querySelector('registration-required'))) {
                         } else if (!_.isNull(error.querySelector('registration-required'))) {
-                            this.showDisconnectMessage(__('You are not on the member list of this room'));
+                            this.showDisconnectMessage(__('You are not on the member list of this room.'));
                         } else if (!_.isNull(error.querySelector('forbidden'))) {
                         } else if (!_.isNull(error.querySelector('forbidden'))) {
-                            this.showDisconnectMessage(__('You have been banned from this room'));
+                            this.showDisconnectMessage(__('You have been banned from this room.'));
                         }
                         }
                     } else if (error.getAttribute('type') === 'modify') {
                     } else if (error.getAttribute('type') === 'modify') {
                         if (!_.isNull(error.querySelector('jid-malformed'))) {
                         if (!_.isNull(error.querySelector('jid-malformed'))) {
-                            this.showDisconnectMessage(__('No nickname was specified'));
+                            this.showDisconnectMessage(__('No nickname was specified.'));
                         }
                         }
                     } else if (error.getAttribute('type') === 'cancel') {
                     } else if (error.getAttribute('type') === 'cancel') {
                         if (!_.isNull(error.querySelector('not-allowed'))) {
                         if (!_.isNull(error.querySelector('not-allowed'))) {
-                            this.showDisconnectMessage(__('You are not allowed to create new rooms'));
+                            this.showDisconnectMessage(__('You are not allowed to create new rooms.'));
                         } else if (!_.isNull(error.querySelector('not-acceptable'))) {
                         } else if (!_.isNull(error.querySelector('not-acceptable'))) {
-                            this.showDisconnectMessage(__("Your nickname doesn't conform to this room's policies"));
+                            this.showDisconnectMessage(__("Your nickname doesn't conform to this room's policies."));
                         } else if (!_.isNull(error.querySelector('conflict'))) {
                         } else if (!_.isNull(error.querySelector('conflict'))) {
                             this.onNicknameClash(presence);
                             this.onNicknameClash(presence);
                         } else if (!_.isNull(error.querySelector('item-not-found'))) {
                         } else if (!_.isNull(error.querySelector('item-not-found'))) {
-                            this.showDisconnectMessage(__("This room does not (yet) exist"));
+                            this.showDisconnectMessage(__("This room does not (yet) exist."));
                         } else if (!_.isNull(error.querySelector('service-unavailable'))) {
                         } else if (!_.isNull(error.querySelector('service-unavailable'))) {
-                            this.showDisconnectMessage(__("This room has reached its maximum number of occupants"));
+                            this.showDisconnectMessage(__("This room has reached its maximum number of occupants."));
                         }
                         }
                     }
                     }
                 },
                 },

+ 1 - 0
src/templates/chatroom_disconnect.html

@@ -0,0 +1 @@
+<p class="disconnect-msg">{{{disconnect_message}}}</p>