mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 03:10:46 -06:00
FIX: Clicking on expanded user actions uses user expansion. Also added
integration test.
This commit is contained in:
parent
bcfd2778d7
commit
504d61de94
@ -32,7 +32,7 @@ export default Em.Component.extend({
|
||||
if (c.get('usersExpanded')) {
|
||||
var postUrl;
|
||||
c.get('users').forEach(function(u) {
|
||||
iconsHtml += "<a href=\"" + Discourse.getURL("/users/") + (u.get('username_lower')) + "\">";
|
||||
iconsHtml += "<a href=\"" + Discourse.getURL("/users/") + u.get('username_lower') + "\" data-user-expand=\"" + u.get('username_lower') + "\">";
|
||||
if (u.post_url) {
|
||||
postUrl = postUrl || u.post_url;
|
||||
}
|
||||
|
@ -18,6 +18,8 @@ export default {
|
||||
$currentTarget.data('ember-action') ||
|
||||
$currentTarget.data('auto-route') ||
|
||||
$currentTarget.data('share-url') ||
|
||||
$currentTarget.data('user-expand') ||
|
||||
$currentTarget.hasClass('mention') ||
|
||||
$currentTarget.hasClass('ember-view') ||
|
||||
$currentTarget.hasClass('lightbox') ||
|
||||
href.indexOf("mailto:") === 0 ||
|
||||
|
@ -234,7 +234,6 @@ Discourse.PostView = Discourse.GroupedView.extend(Ember.Evented, {
|
||||
|
||||
_destroyedPostView: function() {
|
||||
Discourse.ScreenTrack.current().stopTracking(this.get('elementId'));
|
||||
this._unbindExpandMentions();
|
||||
}.on('willDestroyElement'),
|
||||
|
||||
_postViewInserted: function() {
|
||||
@ -262,23 +261,8 @@ Discourse.PostView = Discourse.GroupedView.extend(Ember.Evented, {
|
||||
Em.run.scheduleOnce('afterRender', this, '_insertQuoteControls');
|
||||
|
||||
this._applySearchHighlight();
|
||||
this._bindExpandMentions();
|
||||
}.on('didInsertElement'),
|
||||
|
||||
_bindExpandMentions: function() {
|
||||
var self = this;
|
||||
this.$('.cooked').on('click.discourse-mention', 'a.mention', function(e) {
|
||||
var $target = $(e.target);
|
||||
self.appEvents.trigger('poster:expand', $target);
|
||||
self.get('controller').send('expandPostUsername', $target.text());
|
||||
return false;
|
||||
});
|
||||
},
|
||||
|
||||
_unbindExpandMentions: function() {
|
||||
this.$('.cooked').off('click.discourse-mention');
|
||||
},
|
||||
|
||||
_applySearchHighlight: function() {
|
||||
var highlight = this.get('controller.searchHighlight');
|
||||
var cooked = this.$('.cooked');
|
||||
|
@ -2,18 +2,13 @@ import { renderAvatar } from 'discourse/helpers/user-avatar';
|
||||
|
||||
export default Ember.View.extend({
|
||||
tagName: 'a',
|
||||
attributeBindings: ['href'],
|
||||
attributeBindings: ['href', 'data-user-expand'],
|
||||
classNameBindings: ['content.extras'],
|
||||
|
||||
user: Em.computed.alias('content.user'),
|
||||
href: Em.computed.alias('user.path'),
|
||||
|
||||
click: function(e) {
|
||||
var user = this.get('user');
|
||||
this.appEvents.trigger('poster:expand', $(e.target));
|
||||
this.get('controller').send('expandUser', user);
|
||||
return false;
|
||||
},
|
||||
'data-user-expand': Em.computed.alias('user.username'),
|
||||
|
||||
render: function(buffer) {
|
||||
var av = renderAvatar(this.get('content'), {usernamePath: 'user.username', imageSize: 'small'});
|
||||
|
@ -1,6 +1,8 @@
|
||||
import CleansUp from 'discourse/mixins/cleans-up';
|
||||
|
||||
var clickOutsideEventName = "mousedown.outside-user-expansion";
|
||||
var clickOutsideEventName = "mousedown.outside-user-expansion",
|
||||
clickDataExpand = "click.discourse-user-expand",
|
||||
clickMention = "click.discourse-user-mention";
|
||||
|
||||
export default Discourse.View.extend(CleansUp, {
|
||||
elementId: 'user-expansion',
|
||||
@ -21,6 +23,21 @@ export default Discourse.View.extend(CleansUp, {
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
$('#main-outlet').on(clickDataExpand, '[data-user-expand]', function(e) {
|
||||
var $target = $(e.currentTarget);
|
||||
self._posterExpand($target);
|
||||
self.get('controller').show($target.data('user-expand'));
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#main-outlet').on(clickMention, 'a.mention', function(e) {
|
||||
var $target = $(e.target);
|
||||
self._posterExpand($target);
|
||||
var username = $target.text().replace(/^@/, '');
|
||||
self.get('controller').show(username);
|
||||
return false;
|
||||
});
|
||||
}.on('didInsertElement'),
|
||||
|
||||
_posterExpand: function(target) {
|
||||
@ -50,6 +67,9 @@ export default Discourse.View.extend(CleansUp, {
|
||||
|
||||
_removeEvents: function() {
|
||||
$('html').off(clickOutsideEventName);
|
||||
$('#main').off(clickDataExpand);
|
||||
$('#main').off(clickMention);
|
||||
|
||||
this.appEvents.off('poster:expand', this, '_posterExpand');
|
||||
}.on('willDestroyElement')
|
||||
|
||||
|
13
test/javascripts/integration/user-expansion-test.js.es6
Normal file
13
test/javascripts/integration/user-expansion-test.js.es6
Normal file
@ -0,0 +1,13 @@
|
||||
integration("User Expansion");
|
||||
|
||||
test("expansion", function() {
|
||||
visit('/');
|
||||
|
||||
ok(find('#user-expansion:visible').length === 0, 'user expansion is invisible by default');
|
||||
click('a[data-user-expand=eviltrout]:first');
|
||||
|
||||
andThen(function() {
|
||||
ok(find('#user-expansion:visible').length === 1, 'expansion should appear');
|
||||
});
|
||||
|
||||
});
|
Loading…
Reference in New Issue
Block a user