Skip to content

Commit 9f41092

Browse files
authored
Merge pull request #1596 from appirio-tech/revert-1594-issue_1469
Revert "Issue #1469 - User mentions in the posts"
2 parents 9ac5d6a + 9fbc68e commit 9f41092

File tree

4 files changed

+15
-87
lines changed

4 files changed

+15
-87
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
"draft-js-image-plugin": "^2.0.0-rc2",
6363
"draft-js-link-plugin": "^1.2.2",
6464
"draft-js-plugins-editor": "^2.0.0-rc2",
65-
"draft-js-mention-plugin": "^2.0.0-rc2",
6665
"draft-js-utils": "^0.1.7",
6766
"fbemitter": "^2.1.1",
6867
"fbjs": "^0.8.12",

src/components/Feed/NewPost.jsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class NewPost extends React.Component {
1111
}
1212

1313
render() {
14-
const {currentUser, allMembers, titlePlaceholder, isCreating, hasError} = this.props
14+
const {currentUser, titlePlaceholder, isCreating, hasError} = this.props
1515
let authorName = currentUser.firstName
1616
if (authorName && currentUser.lastName) {
1717
authorName += ' ' + currentUser.lastName
@@ -33,7 +33,6 @@ class NewPost extends React.Component {
3333
hasError={hasError}
3434
avatarUrl={currentUser.photoURL}
3535
authorName={authorName}
36-
allMembers={allMembers}
3736
/>
3837
)
3938
}
@@ -42,7 +41,6 @@ class NewPost extends React.Component {
4241

4342
NewPost.propTypes = {
4443
currentUser: PropTypes.object.isRequired,
45-
allMembers: PropTypes.object.isRequired,
4644
onPost: PropTypes.func.isRequired,
4745
onNewPostChange: PropTypes.func.isRequired,
4846
hasError: PropTypes.bool,

src/components/RichTextArea/RichTextArea.jsx

Lines changed: 13 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,14 @@ import stateToMarkdown from '../../helpers/stateToMarkdown'
1818
import 'draft-js-link-plugin/lib/plugin.css'
1919
import EditorIcons from './EditorIcons'
2020
import './RichTextArea.scss'
21-
import 'draft-js-mention-plugin/lib/plugin.css'
22-
import createMentionPlugin, { defaultSuggestionsFilter } from 'draft-js-mention-plugin'
23-
import _ from 'lodash'
2421

2522
const linkPlugin = createLinkPlugin()
2623
const blockDndPlugin = createBlockDndPlugin()
27-
const mentionPlugin = createMentionPlugin({mentionPrefix: '@'})
28-
2924
const decorator = composeDecorators(
3025
blockDndPlugin.decorator
3126
)
3227
const allowImages = false
33-
const plugins = [linkPlugin, blockDndPlugin, mentionPlugin]
28+
const plugins = [linkPlugin, blockDndPlugin]
3429
if (allowImages){
3530
const imagePlugin = createImagePlugin({ decorator })
3631
plugins.push(handleDropPlugin)
@@ -56,8 +51,7 @@ const blocks = [
5651
class RichTextArea extends React.Component {
5752
constructor(props) {
5853
super(props)
59-
this.mentions = _.map(_.values(this.props.allMembers), (e) => { return {name: e.firstName + ' ' + e.lastName, handle: e.handle, userId: e.userId} })
60-
this.state = {editorExpanded: false, editorState: EditorState.createEmpty(), titleValue: '', suggestions: this.mentions, mentions: []}
54+
this.state = {editorExpanded: false, editorState: EditorState.createEmpty(), titleValue: ''}
6155
this.onTitleChange = this.onTitleChange.bind(this)
6256
this.onEditorChange = this.onEditorChange.bind(this)
6357
this.handleKeyCommand = this.handleKeyCommand.bind(this)
@@ -207,42 +201,12 @@ class RichTextArea extends React.Component {
207201
return
208202
}
209203
const title = this.state.titleValue
210-
211-
var that = this
212-
const replaceMentionWithUserID = (content) =>
213-
{
214-
const encodeContent = (text) => {
215-
return text.replace(/[*_`]/g, '\\$&')
216-
}
217-
218-
const userIdMap = _.reduce(that.mentions, (obj, item) => {
219-
obj[encodeContent(item.name)] = encodeContent(item.handle)
220-
return obj
221-
}, {})
222-
223-
for (var item in userIdMap)
224-
{
225-
content = content.replace('@' + item, '@' + userIdMap[item])
226-
}
227-
return content
228-
}
229-
230-
const content = replaceMentionWithUserID(this.state.currentMDContent)
231-
204+
const content = this.state.currentMDContent
232205
if ((this.props.disableTitle || title) && content) {
233206
this.props.onPost({title, content})
234207
}
235208
}
236209

237-
onSearchChange = ({ value }) => {
238-
this.setState({
239-
suggestions: defaultSuggestionsFilter(value, this.mentions),
240-
});
241-
};
242-
243-
onAddMention = (mention) => {
244-
}
245-
246210
cancelEdit() {
247211
this.props.cancelEdit()
248212
}
@@ -256,7 +220,6 @@ class RichTextArea extends React.Component {
256220
this.setState({uploading})
257221
}
258222
render() {
259-
const {MentionSuggestions} = mentionPlugin
260223
const {className, avatarUrl, authorName, titlePlaceholder, contentPlaceholder, editMode, isCreating, isGettingComment, disableTitle} = this.props
261224
const {editorExpanded, editorState, titleValue, oldMDContent, currentMDContent, uploading} = this.state
262225
let canSubmit = (disableTitle || titleValue.trim())
@@ -269,28 +232,6 @@ class RichTextArea extends React.Component {
269232
const currentEntity = getCurrentEntity(editorState)
270233
const disableForCodeBlock = blockType === 'code-block'
271234

272-
const Entry = (props) => {
273-
const {
274-
mention,
275-
theme,
276-
searchValue, // eslint-disable-line no-unused-vars
277-
isFocused, // eslint-disable-line no-unused-vars
278-
...parentProps
279-
} = props;
280-
281-
return (
282-
<div {...parentProps}>
283-
<div className={theme.mentionSuggestionsEntryContainer}>
284-
<div className={theme.mentionSuggestionsEntryContainerRight}>
285-
<div className={theme.mentionSuggestionsEntryText}>
286-
{mention.get('handle')}
287-
</div>
288-
</div>
289-
</div>
290-
</div>
291-
);
292-
};
293-
294235
return (
295236
<div className={cn(className, 'rich-editor', {expanded: editorExpanded || editMode})} ref="richEditor">
296237
{(isCreating || isGettingComment) &&
@@ -317,23 +258,15 @@ class RichTextArea extends React.Component {
317258
/>
318259
<div className="draftjs-editor tc-textarea">
319260
{!isGettingComment &&
320-
<div>
321-
<Editor
322-
ref="editor"
323-
placeholder={contentPlaceholder}
324-
editorState={editorState}
325-
onChange={this.onEditorChange}
326-
handleKeyCommand={this.handleKeyCommand}
327-
plugins={plugins}
328-
setUploadState={this.setUploadState}
329-
/>
330-
<MentionSuggestions
331-
onSearchChange={this.onSearchChange}
332-
suggestions={this.state.suggestions}
333-
onAddMention={this.onAddMention}
334-
entryComponent={Entry}
335-
/>
336-
</div>
261+
<Editor
262+
ref="editor"
263+
placeholder={contentPlaceholder}
264+
editorState={editorState}
265+
onChange={this.onEditorChange}
266+
handleKeyCommand={this.handleKeyCommand}
267+
plugins={plugins}
268+
setUploadState={this.setUploadState}
269+
/>
337270
}
338271
<div className="textarea-footer">
339272
<div className="textarea-buttons">
@@ -425,8 +358,7 @@ RichTextArea.propTypes = {
425358
oldTitle: PropTypes.string,
426359
oldContent: PropTypes.string,
427360
title: PropTypes.string,
428-
content: PropTypes.string,
429-
allMembers: PropTypes.object
361+
content: PropTypes.string
430362
}
431363

432364
export default RichTextArea

src/projects/detail/containers/FeedContainer.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ class FeedView extends React.Component {
338338
}
339339

340340
render () {
341-
const {currentUser, project, currentMemberRole, isCreatingFeed, error, allMembers} = this.props
341+
const {currentUser, project, currentMemberRole, isCreatingFeed, error } = this.props
342342
const { feeds } = this.state
343343
const showDraftSpec = project.status === PROJECT_STATUS_DRAFT && currentMemberRole === PROJECT_ROLE_CUSTOMER
344344
const onLeaveMessage = this.onLeave() || ''
@@ -383,7 +383,6 @@ class FeedView extends React.Component {
383383
/>
384384
<NewPost
385385
currentUser={currentUser}
386-
allMembers={allMembers}
387386
onPost={this.onNewPost}
388387
isCreating={isCreatingFeed}
389388
hasError={error}

0 commit comments

Comments
 (0)