[MM-57988] Fix move thread logic to not block channel admins (#27061)

* mm-57988: Allowing for channel admins to move thread

* Fix the MoveThread team admin unit test that was introduced

* Renaming the hasPermittedRole function to hasPermittedWranglerRole

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
Matheus
2024-06-18 10:41:49 -07:00
коммит произвёл GitHub
родитель 0da473b9f8
Коммит cbd5d95bbb
3 изменённых файлов: 97 добавлений и 21 удалений

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

@@ -11,7 +11,7 @@ import {getCurrentUser} from 'mattermost-redux/selectors/entities/common';
import {getConfig} from 'mattermost-redux/selectors/entities/general';
import {getPost} from 'mattermost-redux/selectors/entities/posts';
import {moveThreadsEnabled} from 'mattermost-redux/selectors/entities/preferences';
import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users';
import {getCurrentUserId, getCurrentUserRoles} from 'mattermost-redux/selectors/entities/users';
import {arePreviewsCollapsed} from 'selectors/preferences';
import {getGlobalItem} from 'selectors/storage';
@@ -64,10 +64,11 @@ export function makeCanWrangler() {
'makeCanWrangler',
getConfig,
getCurrentUser,
getCurrentUserRoles,
moveThreadsEnabled,
(_state: GlobalState, channelType: Channel['type']) => channelType,
(_state: GlobalState, _channelType: Channel['type'], replyCount: number) => replyCount,
(config: Partial<ClientConfig>, user: UserProfile, enabled: boolean, channelType: Channel['type'], replyCount: number) => {
(config: Partial<ClientConfig>, user: UserProfile, userRoles: string, enabled: boolean, channelType: Channel['type'], replyCount: number) => {
if (!enabled) {
return false;
}
@@ -90,8 +91,8 @@ export function makeCanWrangler() {
allowedEmailDomains = WranglerAllowedEmailDomain?.split(',') || [];
}
if (permittedUsers.length > 0 && !user.roles.includes('system_admin')) {
const roles = user.roles.split(' ');
if (permittedUsers.length > 0 && !userRoles.includes('system_admin')) {
const roles = userRoles.split(' ');
const hasRole = roles.some((role) => permittedUsers.includes(role));
if (!hasRole) {
return false;