[PLT-6708] /purpose [text] slash command: Edit the channel purpose (#6569)
* /purpose [text] slash command: Edit the channel purpose * update command on server side to check for direct or group channels * update stings and block the dialog when is DM or GM * update per review * remove duplicate websocker event and apply the same for /header command * update per review * update
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
10b7b96a29
Коммит
816bfbeb91
@@ -227,12 +227,19 @@ export default class CreatePost extends React.Component {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.state.message.endsWith('/header ')) {
|
||||
if (this.state.message.trimRight() === '/header') {
|
||||
GlobalActions.showChannelHeaderUpdateModal(updateChannel);
|
||||
this.setState({message: ''});
|
||||
return;
|
||||
}
|
||||
|
||||
const isDirectOrGroup = ((updateChannel.type === Constants.DM_CHANNEL) || (updateChannel.type === Constants.GM_CHANNEL));
|
||||
if (!isDirectOrGroup && this.state.message.trimRight() === '/purpose') {
|
||||
GlobalActions.showChannelPurposeUpdateModal(updateChannel);
|
||||
this.setState({message: ''});
|
||||
return;
|
||||
}
|
||||
|
||||
this.doSubmit(e);
|
||||
}
|
||||
|
||||
|
||||
@@ -56,6 +56,8 @@ export default class Navbar extends React.Component {
|
||||
|
||||
this.showEditChannelHeaderModal = this.showEditChannelHeaderModal.bind(this);
|
||||
this.hideEditChannelHeaderModal = this.hideEditChannelHeaderModal.bind(this);
|
||||
this.showChannelPurposeModal = this.showChannelPurposeModal.bind(this);
|
||||
this.hideChannelPurposeModal = this.hideChannelPurposeModal.bind(this);
|
||||
this.showRenameChannelModal = this.showRenameChannelModal.bind(this);
|
||||
this.hideRenameChannelModal = this.hideRenameChannelModal.bind(this);
|
||||
this.isStateValid = this.isStateValid.bind(this);
|
||||
@@ -112,6 +114,7 @@ export default class Navbar extends React.Component {
|
||||
PreferenceStore.addChangeListener(this.onChange);
|
||||
ModalStore.addModalListener(ActionTypes.TOGGLE_QUICK_SWITCH_MODAL, this.toggleQuickSwitchModal);
|
||||
ModalStore.addModalListener(ActionTypes.TOGGLE_CHANNEL_HEADER_UPDATE_MODAL, this.showEditChannelHeaderModal);
|
||||
ModalStore.addModalListener(ActionTypes.TOGGLE_CHANNEL_PURPOSE_UPDATE_MODAL, this.showChannelPurposeModal);
|
||||
$('.inner-wrap').click(this.hideSidebars);
|
||||
document.addEventListener('keydown', this.handleQuickSwitchKeyPress);
|
||||
}
|
||||
@@ -124,6 +127,7 @@ export default class Navbar extends React.Component {
|
||||
PreferenceStore.removeChangeListener(this.onChange);
|
||||
ModalStore.removeModalListener(ActionTypes.TOGGLE_QUICK_SWITCH_MODAL, this.toggleQuickSwitchModal);
|
||||
ModalStore.addModalListener(ActionTypes.TOGGLE_CHANNEL_HEADER_UPDATE_MODAL, this.hideEditChannelHeaderModal);
|
||||
ModalStore.addModalListener(ActionTypes.TOGGLE_CHANNEL_PURPOSE_UPDATE_MODAL, this.hideChannelPurposeModal);
|
||||
document.removeEventListener('keydown', this.handleQuickSwitchKeyPress);
|
||||
}
|
||||
|
||||
@@ -202,6 +206,18 @@ export default class Navbar extends React.Component {
|
||||
});
|
||||
}
|
||||
|
||||
showChannelPurposeModal() {
|
||||
this.setState({
|
||||
showEditChannelPurposeModal: true
|
||||
});
|
||||
}
|
||||
|
||||
hideChannelPurposeModal() {
|
||||
this.setState({
|
||||
showEditChannelPurposeModal: false
|
||||
});
|
||||
}
|
||||
|
||||
showRenameChannelModal(e) {
|
||||
e.preventDefault();
|
||||
|
||||
@@ -504,7 +520,7 @@ export default class Navbar extends React.Component {
|
||||
<a
|
||||
role='menuitem'
|
||||
href='#'
|
||||
onClick={() => this.setState({showEditChannelPurposeModal: true})}
|
||||
onClick={this.showChannelPurposeModal}
|
||||
>
|
||||
<FormattedMessage
|
||||
id='channel_header.setPurpose'
|
||||
@@ -891,7 +907,7 @@ export default class Navbar extends React.Component {
|
||||
if (this.state.showEditChannelPurposeModal) {
|
||||
editChannelPurposeModal = (
|
||||
<EditChannelPurposeModal
|
||||
onModalDismissed={() => this.setState({showEditChannelPurposeModal: false})}
|
||||
onModalDismissed={this.hideChannelPurposeModal}
|
||||
channel={channel}
|
||||
/>
|
||||
);
|
||||
|
||||
Ссылка в новой задаче
Block a user