Insert mention when replying to 3rd level reply

refs VICE-2991
flag=react_discussions_post

Test Plan:
 - reply to a 3rd level
 - should see a mention for the author of the 3rd level message
     inside the RCE

Change-Id: I2cc86daeb87493e344e62c293764954b8ac2cfbc
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/303227
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Reviewed-by: Jason Gillett <jason.gillett@instructure.com>
Product-Review: Jason Gillett <jason.gillett@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
This commit is contained in:
Drake Harper 2022-10-13 09:35:55 -06:00
parent 4217d67b21
commit 0e018fa87c
2 changed files with 12 additions and 5 deletions

View File

@ -415,13 +415,9 @@ describe "threaded discussions" do
type_in_tiny("textarea", "replying to 3rd level reply")
f("button[data-testid='DiscussionEdit-submit'").click
wait_for_ajaximations
# get "/courses/#{@course.id}/discussion_topics/#{topic.id}"
# f("button[data-testid='expand-button']").click
# wait_for_ajaximations
# expect(f("body")).to contain_jqcss("div:contains('flatten 3rd level replies')")
# expect(f("body")).to contain_jqcss("div:contains('replying to 3rd level reply')")
flattened_reply = DiscussionEntry.last
expect(flattened_reply.parent_id).to eq third_entry.parent_id
expect(flattened_reply.message).to eq "<p><span class=\"mceNonEditable mention\" data-mention=\"1\" data-reactroot=\"\">@student</span>replying to 3rd level reply</p>"
end
context "replies reporting" do

View File

@ -43,6 +43,7 @@ import {SearchContext} from '../../utils/constants'
import {DiscussionEntryContainer} from '../DiscussionEntryContainer/DiscussionEntryContainer'
import PropTypes from 'prop-types'
import React, {useContext, useEffect, useState, useCallback} from 'react'
import * as ReactDOMServer from 'react-dom/server'
import {ReplyInfo} from '../../components/ReplyInfo/ReplyInfo'
import {Responsive} from '@instructure/ui-responsive'
@ -479,6 +480,16 @@ export const DiscussionThreadContainer = props => {
onReplySubmit(message, anonymousAuthorState)
}}
onCancel={() => setEditorExpanded(false)}
value={
props.discussionEntry.rootEntryId &&
props.discussionEntry.rootEntryId !== props.discussionEntry.parentId
? ReactDOMServer.renderToString(
<span className="mceNonEditable mention" data-mention="1">
@{getDisplayName(props.discussionEntry)}
</span>
)
: ''
}
/>
</View>
)}