PLT-3777 Channel URL name changes when display name is updated (#3795)
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
fdd7962d42
Коммит
52aa1120c5
@@ -2,7 +2,6 @@
|
|||||||
// See License.txt for license information.
|
// See License.txt for license information.
|
||||||
|
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import TeamStore from 'stores/team_store.jsx';
|
|
||||||
import * as Utils from 'utils/utils.jsx';
|
import * as Utils from 'utils/utils.jsx';
|
||||||
import Client from 'client/web_client.jsx';
|
import Client from 'client/web_client.jsx';
|
||||||
import * as AsyncClient from 'utils/async_client.jsx';
|
import * as AsyncClient from 'utils/async_client.jsx';
|
||||||
@@ -11,7 +10,6 @@ import Constants from 'utils/constants.jsx';
|
|||||||
import {intlShape, injectIntl, defineMessages, FormattedMessage} from 'react-intl';
|
import {intlShape, injectIntl, defineMessages, FormattedMessage} from 'react-intl';
|
||||||
|
|
||||||
import {Modal} from 'react-bootstrap';
|
import {Modal} from 'react-bootstrap';
|
||||||
import {browserHistory} from 'react-router';
|
|
||||||
|
|
||||||
const holders = defineMessages({
|
const holders = defineMessages({
|
||||||
required: {
|
required: {
|
||||||
@@ -57,7 +55,6 @@ export default class RenameChannelModal extends React.Component {
|
|||||||
|
|
||||||
this.onNameChange = this.onNameChange.bind(this);
|
this.onNameChange = this.onNameChange.bind(this);
|
||||||
this.onDisplayNameChange = this.onDisplayNameChange.bind(this);
|
this.onDisplayNameChange = this.onDisplayNameChange.bind(this);
|
||||||
this.displayNameKeyUp = this.displayNameKeyUp.bind(this);
|
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
displayName: props.channel.display_name,
|
displayName: props.channel.display_name,
|
||||||
@@ -167,9 +164,7 @@ export default class RenameChannelModal extends React.Component {
|
|||||||
Client.updateChannel(
|
Client.updateChannel(
|
||||||
channel,
|
channel,
|
||||||
() => {
|
() => {
|
||||||
const team = TeamStore.getCurrent().name;
|
|
||||||
AsyncClient.getChannel(channel.id);
|
AsyncClient.getChannel(channel.id);
|
||||||
browserHistory.replace(`/${team}/channels/${channel.name}`);
|
|
||||||
this.handleHide();
|
this.handleHide();
|
||||||
},
|
},
|
||||||
(err) => {
|
(err) => {
|
||||||
@@ -198,15 +193,6 @@ export default class RenameChannelModal extends React.Component {
|
|||||||
this.setState({displayName: ReactDOM.findDOMNode(this.refs.displayName).value});
|
this.setState({displayName: ReactDOM.findDOMNode(this.refs.displayName).value});
|
||||||
}
|
}
|
||||||
|
|
||||||
displayNameKeyUp() {
|
|
||||||
if (this.state.channelName !== Constants.DEFAULT_CHANNEL) {
|
|
||||||
const displayName = ReactDOM.findDOMNode(this.refs.displayName).value.trim();
|
|
||||||
const channelName = Utils.cleanUpUrlable(displayName);
|
|
||||||
ReactDOM.findDOMNode(this.refs.channelName).value = channelName;
|
|
||||||
this.setState({channelName});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let displayNameError = null;
|
let displayNameError = null;
|
||||||
let displayNameClass = 'form-group';
|
let displayNameClass = 'form-group';
|
||||||
@@ -260,7 +246,6 @@ export default class RenameChannelModal extends React.Component {
|
|||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
onKeyUp={this.displayNameKeyUp}
|
|
||||||
onChange={this.onDisplayNameChange}
|
onChange={this.onDisplayNameChange}
|
||||||
type='text'
|
type='text'
|
||||||
ref='displayName'
|
ref='displayName'
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user