PLT-6486 Add an @username button to the profile popover, that puts the username in the post when clicked (#6349)

* PLT-6486 Add an `@username` button to the profile popover, that puts the username in the post when clicked

* PLT-6486 Display `@username` mention on the right text area on center or RHS.

* Disable @mentions from profile popover on searches, mentions and pinned posts. Fix js errors.

* Control undefined post in SearchStore that causes an exception.
Этот коммит содержится в:
David Meza
2017-07-31 07:24:13 -05:00
коммит произвёл Joram Wilander
родитель 22fa48f455
Коммит f740698dbe
18 изменённых файлов: 183 добавлений и 21 удалений

Просмотреть файл

@@ -122,7 +122,7 @@ class SearchStoreClass extends EventEmitter {
updatePost(post) {
const results = this.getSearchResults();
if (results == null) {
if (!post || results == null) {
return;
}

Просмотреть файл

@@ -10,6 +10,7 @@ const ActionTypes = Constants.ActionTypes;
const COMPLETE_WORD_EVENT = 'complete_word';
const PRETEXT_CHANGED_EVENT = 'pretext_changed';
const SUGGESTIONS_CHANGED_EVENT = 'suggestions_changed';
const POPOVER_MENTION_KEY_CLICK_EVENT = 'popover_mention_key_click';
class SuggestionStore extends EventEmitter {
constructor() {
@@ -27,6 +28,10 @@ class SuggestionStore extends EventEmitter {
this.removeCompleteWordListener = this.removeCompleteWordListener.bind(this);
this.emitCompleteWord = this.emitCompleteWord.bind(this);
this.addPopoverMentionKeyClickListener = this.addPopoverMentionKeyClickListener.bind(this);
this.removePopoverMentionKeyClickListener = this.removePopoverMentionKeyClickListener.bind(this);
this.emitPopoverMentionKeyClick = this.emitPopoverMentionKeyClick.bind(this);
this.handleEventPayload = this.handleEventPayload.bind(this);
this.dispatchToken = AppDispatcher.register(this.handleEventPayload);
@@ -71,6 +76,16 @@ class SuggestionStore extends EventEmitter {
this.emit(COMPLETE_WORD_EVENT + id, term, matchedPretext);
}
addPopoverMentionKeyClickListener(id, callback) {
this.on(POPOVER_MENTION_KEY_CLICK_EVENT + id, callback);
}
removePopoverMentionKeyClickListener(id, callback) {
this.removeListener(POPOVER_MENTION_KEY_CLICK_EVENT + id, callback);
}
emitPopoverMentionKeyClick(isRHS, mentionKey) {
this.emit(POPOVER_MENTION_KEY_CLICK_EVENT + isRHS, mentionKey);
}
registerSuggestionBox(id) {
this.suggestions.set(id, {
pretext: '',
@@ -304,6 +319,9 @@ class SuggestionStore extends EventEmitter {
this.completeWord(id, other.term, other.matchedPretext);
}
break;
case ActionTypes.POPOVER_MENTION_KEY_CLICK:
this.emitPopoverMentionKeyClick(other.isRHS, other.mentionKey);
break;
}
}
}