PLT-5050 (WebApp): Change channel member roles. (#5076)
Admins can now Promote/Demote channel members in the Channel Manage Membersmodal.
Этот коммит содержится в:
коммит произвёл
enahum
родитель
2554ae4a25
Коммит
e15ae2253a
@@ -125,6 +125,48 @@ export function removeUserFromChannel(channelId, userId, success, error) {
|
||||
);
|
||||
}
|
||||
|
||||
export function makeUserChannelAdmin(channelId, userId, success, error) {
|
||||
Client.updateChannelMemberRoles(
|
||||
channelId,
|
||||
userId,
|
||||
'channel_user channel_admin',
|
||||
() => {
|
||||
AsyncClient.getChannelMember(channelId, userId);
|
||||
getChannelMembersForUserIds(channelId, [userId]);
|
||||
|
||||
if (success) {
|
||||
success();
|
||||
}
|
||||
},
|
||||
(err) => {
|
||||
if (error) {
|
||||
error(err);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export function makeUserChannelMember(channelId, userId, success, error) {
|
||||
Client.updateChannelMemberRoles(
|
||||
channelId,
|
||||
userId,
|
||||
'channel_user',
|
||||
() => {
|
||||
AsyncClient.getChannelMember(channelId, userId);
|
||||
getChannelMembersForUserIds(channelId, [userId]);
|
||||
|
||||
if (success) {
|
||||
success();
|
||||
}
|
||||
},
|
||||
(err) => {
|
||||
if (error) {
|
||||
error(err);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export function openDirectChannelToUser(user, success, error) {
|
||||
const channelName = Utils.getDirectChannelName(UserStore.getCurrentId(), user.id);
|
||||
const channel = ChannelStore.getByName(channelName);
|
||||
@@ -343,3 +385,33 @@ export function updateChannelHeader(channelId, header, success, error) {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export function getChannelMembersForUserIds(channelId, userIds, success, error) {
|
||||
Client.getChannelMembersByIds(
|
||||
channelId,
|
||||
userIds,
|
||||
(data) => {
|
||||
const memberMap = {};
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
memberMap[data[i].user_id] = data[i];
|
||||
}
|
||||
|
||||
AppDispatcher.handleServerAction({
|
||||
type: ActionTypes.RECEIVED_MEMBERS_IN_CHANNEL,
|
||||
channel_id: channelId,
|
||||
channel_members: memberMap
|
||||
});
|
||||
|
||||
if (success) {
|
||||
success(data);
|
||||
}
|
||||
},
|
||||
(err) => {
|
||||
AsyncClient.dispatchError(err, 'getChannelMembersByIds');
|
||||
|
||||
if (error) {
|
||||
error(err);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import TeamStore from 'stores/team_store.jsx';
|
||||
import UserStore from 'stores/user_store.jsx';
|
||||
import ChannelStore from 'stores/channel_store.jsx';
|
||||
|
||||
import {getChannelMembersForUserIds} from 'actions/channel_actions.jsx';
|
||||
import {loadStatusesForProfilesList, loadStatusesForProfilesMap} from 'actions/status_actions.jsx';
|
||||
|
||||
import {getDirectChannelName} from 'utils/utils.jsx';
|
||||
@@ -180,7 +181,7 @@ export function loadChannelMembersForProfilesMap(profiles, channelId = ChannelSt
|
||||
return;
|
||||
}
|
||||
|
||||
loadChannelMembersForProfiles(list, channelId, success, error);
|
||||
getChannelMembersForUserIds(channelId, list, success, error);
|
||||
}
|
||||
|
||||
export function loadTeamMembersAndChannelMembersForProfilesList(profiles, teamId = TeamStore.getCurrentId(), channelId = ChannelStore.getCurrentId(), success, error) {
|
||||
@@ -207,37 +208,7 @@ export function loadChannelMembersForProfilesList(profiles, channelId = ChannelS
|
||||
return;
|
||||
}
|
||||
|
||||
loadChannelMembersForProfiles(list, channelId, success, error);
|
||||
}
|
||||
|
||||
function loadChannelMembersForProfiles(userIds, channelId, success, error) {
|
||||
Client.getChannelMembersByIds(
|
||||
channelId,
|
||||
userIds,
|
||||
(data) => {
|
||||
const memberMap = {};
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
memberMap[data[i].user_id] = data[i];
|
||||
}
|
||||
|
||||
AppDispatcher.handleServerAction({
|
||||
type: ActionTypes.RECEIVED_MEMBERS_IN_CHANNEL,
|
||||
channel_id: channelId,
|
||||
channel_members: memberMap
|
||||
});
|
||||
|
||||
if (success) {
|
||||
success(data);
|
||||
}
|
||||
},
|
||||
(err) => {
|
||||
AsyncClient.dispatchError(err, 'getChannelMembersByIds');
|
||||
|
||||
if (error) {
|
||||
error(err);
|
||||
}
|
||||
}
|
||||
);
|
||||
getChannelMembersForUserIds(channelId, list, success, error);
|
||||
}
|
||||
|
||||
function populateDMChannelsWithProfiles(userIds) {
|
||||
|
||||
Ссылка в новой задаче
Block a user