Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MM-59373: Respecting name display preference in boards #22

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions webapp/src/components/cardDetail/comment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import React, {FC} from 'react'
import {useIntl} from 'react-intl'

import {getChannelsNameMapInTeam} from 'mattermost-redux/selectors/entities/channels'

import {Provider} from 'react-redux'

import {Block} from '../../blocks/block'
import mutator from '../../mutator'
import {Utils} from '../../utils'
Expand All @@ -17,6 +21,9 @@ import Tooltip from '../../widgets/tooltip'
import GuestBadge from '../../widgets/guestBadge'

import './comment.scss'
import {formatText, messageHtmlToComponent} from '../../webapp_globals'
import {getCurrentTeam} from '../../store/teams'


type Props = {
comment: Block
Expand All @@ -28,10 +35,20 @@ type Props = {
const Comment: FC<Props> = (props: Props) => {
const {comment, userId, userImageUrl} = props
const intl = useIntl()
const html = Utils.htmlFromMarkdown(comment.title)
const user = useAppSelector(getUser(userId))
const date = new Date(comment.createAt)

const selectedTeam = useAppSelector(getCurrentTeam)
const channelNamesMap = getChannelsNameMapInTeam((window as any).store.getState(), selectedTeam!.id)

const formattedText = messageHtmlToComponent(formatText(comment.title, {
singleline: false,
atMentions: true,
mentionHighlight: false,
team: selectedTeam,
channelNamesMap,
}))

return (
<div
key={comment.id}
Expand Down Expand Up @@ -65,10 +82,9 @@ const Comment: FC<Props> = (props: Props) => {
</MenuWrapper>
)}
</div>
<div
className='comment-text'
dangerouslySetInnerHTML={{__html: html}}
/>
<Provider store={(window as any).store}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you share why do we need to create a store provider here? It does't look right.

{formattedText}
</Provider>
</div>
)
}
Expand Down
10 changes: 10 additions & 0 deletions webapp/src/webapp_globals.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

export const {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatText,
messageHtmlToComponent,

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
} = global.PostUtils ?? {}
Loading