PLT-6484 Add /leave command to leave a channel (#6402)
* PLT-6484 Add /leave command to leave a channel * Text changes requeted on review. * PLT-6484 Display the right error message when trying to /leave town-square * PLT-6484 Be able to execute /leave command in direct and group message channels with the same effect as clicking x * PLT-6484 Refactor to create new leave_private_channel_modal.jsx * PLT-6484 Remove previous leave private channel logic to use new leave_private_channel_modal.jsx * Remove dot in command description. Change localized error when leaving Town square. * disable /leave command in reply threads on the right-hand sidebar, since it is not obvious which channel you should leave
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
19804c4e40
Коммит
b54d134299
@@ -72,6 +72,39 @@ export function executeCommand(message, args, success, error) {
|
||||
msg = '/shortcuts';
|
||||
}
|
||||
break;
|
||||
case '/leave': {
|
||||
// /leave command not supported in reply threads.
|
||||
if (args.channel_id && (args.root_id || args.parent_id)) {
|
||||
GlobalActions.sendEphemeralPost('/leave is not supported in reply threads. Use it in the center channel instead.', args.channel_id, args.parent_id);
|
||||
return;
|
||||
}
|
||||
const channel = ChannelStore.getCurrent();
|
||||
if (channel.type === Constants.PRIVATE_CHANNEL) {
|
||||
GlobalActions.showLeavePrivateChannelModal(channel);
|
||||
return;
|
||||
} else if (
|
||||
channel.type === Constants.DM_CHANNEL ||
|
||||
channel.type === Constants.GM_CHANNEL
|
||||
) {
|
||||
let name;
|
||||
let category;
|
||||
if (channel.type === Constants.DM_CHANNEL) {
|
||||
name = Utils.getUserIdFromChannelName(channel);
|
||||
category = Constants.Preferences.CATEGORY_DIRECT_CHANNEL_SHOW;
|
||||
} else {
|
||||
name = channel.id;
|
||||
category = Constants.Preferences.CATEGORY_GROUP_CHANNEL_SHOW;
|
||||
}
|
||||
const currentUserId = UserStore.getCurrentId();
|
||||
savePreferences(currentUserId, [{category, name, user_id: currentUserId, value: 'false'}])(dispatch, getState);
|
||||
if (ChannelUtils.isFavoriteChannel(channel)) {
|
||||
unmarkFavorite(channel.id);
|
||||
}
|
||||
browserHistory.push(`${TeamStore.getCurrentTeamRelativeUrl()}/channels/town-square`);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case '/settings':
|
||||
GlobalActions.showAccountSettingsModal();
|
||||
return;
|
||||
|
||||
@@ -281,6 +281,13 @@ export function showLeaveTeamModal() {
|
||||
});
|
||||
}
|
||||
|
||||
export function showLeavePrivateChannelModal(channel) {
|
||||
AppDispatcher.handleViewAction({
|
||||
type: ActionTypes.TOGGLE_LEAVE_PRIVATE_CHANNEL_MODAL,
|
||||
value: channel
|
||||
});
|
||||
}
|
||||
|
||||
export function emitSuggestionPretextChanged(suggestionId, pretext) {
|
||||
AppDispatcher.handleViewAction({
|
||||
type: ActionTypes.SUGGESTION_PRETEXT_CHANGED,
|
||||
@@ -351,7 +358,7 @@ export function emitPreferencesDeletedEvent(preferences) {
|
||||
});
|
||||
}
|
||||
|
||||
export function sendEphemeralPost(message, channelId) {
|
||||
export function sendEphemeralPost(message, channelId, parentId) {
|
||||
const timestamp = Utils.getTimestamp();
|
||||
const post = {
|
||||
id: Utils.generateId(),
|
||||
@@ -361,6 +368,8 @@ export function sendEphemeralPost(message, channelId) {
|
||||
type: Constants.PostTypes.EPHEMERAL,
|
||||
create_at: timestamp,
|
||||
update_at: timestamp,
|
||||
root_id: parentId,
|
||||
parent_id: parentId,
|
||||
props: {}
|
||||
};
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user