1
0
mirror of https://github.com/mattermost/focalboard.git synced 2025-02-01 19:14:35 +02:00

Gh 3974 guest autocomplete (#4010)

This commit is contained in:
Scott Bishel 2022-10-13 14:53:38 -06:00 committed by GitHub
parent 57fcdd93b3
commit 610dea35e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View File

@ -11,7 +11,7 @@ import {IUser} from '../../user'
import {Utils} from '../../utils'
import mutator from '../../mutator'
import {useAppSelector} from '../../store/hooks'
import {getBoardUsers, getBoardUsersList} from '../../store/users'
import {getBoardUsers, getBoardUsersList, getMe} from '../../store/users'
import {BoardMember, BoardTypeOpen, MemberRole} from '../../blocks/board'
import {PropertyProps} from '../types'
@ -70,8 +70,10 @@ const MultiPerson = (props: PropertyProps): JSX.Element => {
const boardUsers = useAppSelector<IUser[]>(getBoardUsersList)
const boardUsersKey = Object.keys(boardUsersById) ? Utils.hashCode(JSON.stringify(Object.keys(boardUsersById))) : 0
const me = useAppSelector<IUser|null>(getMe)
const allowManageBoardRoles = useHasPermissions(board.teamId, board.id, [Permission.ManageBoardRoles])
const allowAddUsers = allowManageBoardRoles || board.type === BoardTypeOpen
const allowAddUsers = !me?.is_guest && (allowManageBoardRoles || board.type === BoardTypeOpen)
const onChange = useCallback((newValue) => mutator.changePropertyValue(board.id, card, propertyTemplate.id, newValue), [board.id, card, propertyTemplate.id])

View File

@ -8,7 +8,7 @@ import {CSSObject} from '@emotion/serialize'
import {Utils} from '../../utils'
import {IUser} from '../../user'
import {getBoardUsersList, getBoardUsers} from '../../store/users'
import {getBoardUsersList, getBoardUsers, getMe} from '../../store/users'
import {BoardMember, BoardTypeOpen, MemberRole} from '../../blocks/board'
import {useAppSelector} from '../../store/hooks'
import mutator from '../../mutator'
@ -68,7 +68,7 @@ const Person = (props: PropertyProps): JSX.Element => {
const boardUsersKey = Object.keys(boardUsersById) ? Utils.hashCode(JSON.stringify(Object.keys(boardUsersById))) : 0
const onChange = useCallback((newValue) => mutator.changePropertyValue(board.id, card, propertyTemplate.id, newValue), [board.id, card, propertyTemplate.id])
const me: IUser = boardUsersById[propertyValue as string]
const me = useAppSelector<IUser|null>(getMe)
const clientConfig = useAppSelector<ClientConfig>(getClientConfig)
const intl = useIntl()
@ -112,7 +112,7 @@ const Person = (props: PropertyProps): JSX.Element => {
}, [board, card, propertyTemplate])
const allowManageBoardRoles = useHasPermissions(board.teamId, board.id, [Permission.ManageBoardRoles])
const allowAddUsers = allowManageBoardRoles || board.type === BoardTypeOpen
const allowAddUsers = !me?.is_guest && (allowManageBoardRoles || board.type === BoardTypeOpen)
const loadOptions = useCallback(async (value: string) => {
if (!allowAddUsers) {
@ -138,7 +138,7 @@ const Person = (props: PropertyProps): JSX.Element => {
if (readOnly) {
return (
<div className={`Person ${props.property.valueClassName(true)}`}>
{me ? formatOptionLabel(me) : propertyValue}
{boardUsersById[propertyValue as string] ? formatOptionLabel(boardUsersById[propertyValue as string]) : propertyValue}
</div>
)
}