Merge pull request #2347 from hmhealey/morechannels

Fixed positioning of elements in MoreChannels modal
Этот коммит содержится в:
Christopher Speller
2016-03-08 08:42:43 -05:00
родитель 3c14155148 c6fce25c7c
Коммит 8dd3711bd8
3 изменённых файлов: 79 добавлений и 57 удалений

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

@@ -1,7 +1,7 @@
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information. // See License.txt for license information.
import * as utils from '../utils/utils.jsx'; import * as Utils from '../utils/utils.jsx';
import * as client from '../utils/client.jsx'; import * as client from '../utils/client.jsx';
import * as AsyncClient from '../utils/async_client.jsx'; import * as AsyncClient from '../utils/async_client.jsx';
import ChannelStore from '../stores/channel_store.jsx'; import ChannelStore from '../stores/channel_store.jsx';
@@ -24,6 +24,7 @@ export default class MoreChannels extends React.Component {
this.onListenerChange = this.onListenerChange.bind(this); this.onListenerChange = this.onListenerChange.bind(this);
this.handleJoin = this.handleJoin.bind(this); this.handleJoin = this.handleJoin.bind(this);
this.handleNewChannel = this.handleNewChannel.bind(this); this.handleNewChannel = this.handleNewChannel.bind(this);
this.createChannelRow = this.createChannelRow.bind(this);
var initState = getStateFromStores(); var initState = getStateFromStores();
initState.channelType = ''; initState.channelType = '';
@@ -48,7 +49,7 @@ export default class MoreChannels extends React.Component {
} }
onListenerChange() { onListenerChange() {
var newState = getStateFromStores(); var newState = getStateFromStores();
if (!utils.areObjectsEqual(newState.channels, this.state.channels)) { if (!Utils.areObjectsEqual(newState.channels, this.state.channels)) {
this.setState(newState); this.setState(newState);
} }
} }
@@ -58,7 +59,7 @@ export default class MoreChannels extends React.Component {
() => { () => {
$(ReactDOM.findDOMNode(this.refs.modal)).modal('hide'); $(ReactDOM.findDOMNode(this.refs.modal)).modal('hide');
AsyncClient.getChannel(channel.id); AsyncClient.getChannel(channel.id);
utils.switchChannel(channel); Utils.switchChannel(channel);
this.setState({joiningChannel: -1}); this.setState({joiningChannel: -1});
}, },
(err) => { (err) => {
@@ -70,26 +71,9 @@ export default class MoreChannels extends React.Component {
$(ReactDOM.findDOMNode(this.refs.modal)).modal('hide'); $(ReactDOM.findDOMNode(this.refs.modal)).modal('hide');
this.setState({showNewChannelModal: true}); this.setState({showNewChannelModal: true});
} }
render() { createChannelRow(channel, index) {
var serverError; let joinButton;
if (this.state.serverError) { if (this.state.joiningChannel === index) {
serverError = <div className='form-group has-error'><label className='control-label'>{this.state.serverError}</label></div>;
}
var self = this;
var moreChannels;
if (this.state.channels != null) {
var channels = this.state.channels;
if (channels.loading) {
moreChannels = <LoadingScreen/>;
} else if (channels.length) {
moreChannels = (
<table className='more-table table'>
<tbody>
{channels.map(function cMap(channel, index) {
var joinButton;
if (self.state.joiningChannel === index) {
joinButton = ( joinButton = (
<img <img
className='join-channel-loading-gif' className='join-channel-loading-gif'
@@ -99,7 +83,7 @@ export default class MoreChannels extends React.Component {
} else { } else {
joinButton = ( joinButton = (
<button <button
onClick={self.handleJoin.bind(self, channel, index)} onClick={this.handleJoin.bind(self, channel, index)}
className='btn btn-primary' className='btn btn-primary'
> >
<FormattedMessage <FormattedMessage
@@ -112,16 +96,40 @@ export default class MoreChannels extends React.Component {
return ( return (
<tr key={channel.id}> <tr key={channel.id}>
<td> <td className='more-row'>
<div className='more-details'>
<p className='more-name'>{channel.display_name}</p> <p className='more-name'>{channel.display_name}</p>
<p className='more-description'>{channel.purpose}</p> <p className='more-description'>{channel.purpose}</p>
</td> </div>
<td className='td--action'> <div className='more-actions'>
{joinButton} {joinButton}
</div>
</td> </td>
</tr> </tr>
); );
})} }
render() {
let maxHeight = 1000;
if (Utils.windowHeight() <= 1200) {
maxHeight = Utils.windowHeight() - 300;
}
var serverError;
if (this.state.serverError) {
serverError = <div className='form-group has-error'><label className='control-label'>{this.state.serverError}</label></div>;
}
var moreChannels;
if (this.state.channels != null) {
var channels = this.state.channels;
if (channels.loading) {
moreChannels = <LoadingScreen/>;
} else if (channels.length) {
moreChannels = (
<table className='more-table table'>
<tbody>
{channels.map(this.createChannelRow)}
</tbody> </tbody>
</table> </table>
); );
@@ -192,7 +200,10 @@ export default class MoreChannels extends React.Component {
onModalDismissed={() => this.setState({showNewChannelModal: false})} onModalDismissed={() => this.setState({showNewChannelModal: false})}
/> />
</div> </div>
<div className='modal-body'> <div
className='modal-body'
style={{maxHeight}}
>
{moreChannels} {moreChannels}
{serverError} {serverError}
</div> </div>

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

@@ -28,7 +28,6 @@ export default function UserListRow({user, actions}) {
<tr> <tr>
<td <td
key={user.id} key={user.id}
className='direct-channel'
style={{display: 'flex'}} style={{display: 'flex'}}
> >
<img <img

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

@@ -23,17 +23,29 @@
border-radius: 50px; border-radius: 50px;
margin-right: 8px; margin-right: 8px;
} }
.more-row {
display: flex;
.more-details {
flex-grow: 1;
flex-shrink: 1;
overflow: hidden;
text-overflow: ellipsis;
}
.more-actions {
flex-grow: 0;
flex-shrink: 0;
}
}
.more-name { .more-name {
font-weight: 600; font-weight: 600;
font-size: 0.95em; font-size: 0.95em;
overflow: hidden; white-space: nowrap;
text-overflow: ellipsis;
} }
.more-description { .more-description {
@include opacity(0.7); @include opacity(0.7);
display: block; display: block;
overflow: hidden; white-space: nowrap;
text-overflow: ellipsis;
} }
tbody { tbody {
> tr { > tr {