Added SpinnerButton component to handle buttons that are also spinners
Этот коммит содержится в:
@@ -7,8 +7,7 @@ import * as AsyncClient from 'utils/async_client.jsx';
|
|||||||
import * as Client from 'utils/client.jsx';
|
import * as Client from 'utils/client.jsx';
|
||||||
|
|
||||||
import {FormattedMessage} from 'react-intl';
|
import {FormattedMessage} from 'react-intl';
|
||||||
|
import SpinnerButton from 'components/spinner_button.jsx';
|
||||||
import loadingGif from 'images/load.gif';
|
|
||||||
|
|
||||||
export default class ChannelInviteButton extends React.Component {
|
export default class ChannelInviteButton extends React.Component {
|
||||||
static get propTypes() {
|
static get propTypes() {
|
||||||
@@ -29,9 +28,7 @@ export default class ChannelInviteButton extends React.Component {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
handleClick(e) {
|
handleClick() {
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
if (this.state.addingUser) {
|
if (this.state.addingUser) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -66,26 +63,17 @@ export default class ChannelInviteButton extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
if (this.state.addingUser) {
|
|
||||||
return (
|
|
||||||
<img
|
|
||||||
className='channel-loading-gif'
|
|
||||||
src={loadingGif}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<a
|
<SpinnerButton
|
||||||
onClick={this.handleClick}
|
onClick={this.handleClick}
|
||||||
className='btn btn-sm btn-primary'
|
spinning={this.state.addingUser}
|
||||||
>
|
>
|
||||||
<i className='glyphicon glyphicon-envelope'/>
|
<i className='glyphicon glyphicon-envelope'/>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id='channel_invite.add'
|
id='channel_invite.add'
|
||||||
defaultMessage=' Add'
|
defaultMessage=' Add'
|
||||||
/>
|
/>
|
||||||
</a>
|
</SpinnerButton>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ import {Modal} from 'react-bootstrap';
|
|||||||
import FilteredUserList from './filtered_user_list.jsx';
|
import FilteredUserList from './filtered_user_list.jsx';
|
||||||
import UserStore from 'stores/user_store.jsx';
|
import UserStore from 'stores/user_store.jsx';
|
||||||
import * as Utils from 'utils/utils.jsx';
|
import * as Utils from 'utils/utils.jsx';
|
||||||
import loadingGif from 'images/load.gif';
|
|
||||||
|
|
||||||
import {FormattedMessage} from 'react-intl';
|
import {FormattedMessage} from 'react-intl';
|
||||||
|
import SpinnerButton from 'components/spinner_button.jsx';
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
@@ -83,26 +83,16 @@ export default class MoreDirectChannels extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
createJoinDirectChannelButton({user}) {
|
createJoinDirectChannelButton({user}) {
|
||||||
if (this.state.loadingDMChannel === user.id) {
|
|
||||||
return (
|
|
||||||
<img
|
|
||||||
className='channel-loading-gif'
|
|
||||||
src={loadingGif}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button
|
<SpinnerButton
|
||||||
type='button'
|
spinning={this.state.loadingDMChannel === user.id}
|
||||||
className='btn btn-primary btn-message'
|
|
||||||
onClick={this.handleShowDirectChannel.bind(this, user)}
|
onClick={this.handleShowDirectChannel.bind(this, user)}
|
||||||
>
|
>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id='more_direct_channels.message'
|
id='more_direct_channels.message'
|
||||||
defaultMessage='Message'
|
defaultMessage='Message'
|
||||||
/>
|
/>
|
||||||
</button>
|
</SpinnerButton>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
48
webapp/components/spinner_button.jsx
Обычный файл
48
webapp/components/spinner_button.jsx
Обычный файл
@@ -0,0 +1,48 @@
|
|||||||
|
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||||
|
// See License.txt for license information.
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import loadingGif from 'images/load.gif';
|
||||||
|
|
||||||
|
export default class SpinnerButton extends React.Component {
|
||||||
|
static get propTypes() {
|
||||||
|
return {
|
||||||
|
children: React.PropTypes.node,
|
||||||
|
spinning: React.PropTypes.bool.isRequired,
|
||||||
|
onClick: React.PropTypes.func
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
|
||||||
|
this.handleClick = this.handleClick.bind(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
handleClick(e) {
|
||||||
|
if (this.props.onClick) {
|
||||||
|
this.props.onClick(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
if (this.props.spinning) {
|
||||||
|
return (
|
||||||
|
<img
|
||||||
|
className='spinner-button__gif'
|
||||||
|
src={loadingGif}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
onClick={this.handleClick}
|
||||||
|
className='btn btn-sm btn-primary'
|
||||||
|
>
|
||||||
|
{this.props.children}
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
8
webapp/sass/components/_spinner-button.scss
Обычный файл
8
webapp/sass/components/_spinner-button.scss
Обычный файл
@@ -0,0 +1,8 @@
|
|||||||
|
@charset 'UTF-8';
|
||||||
|
|
||||||
|
.spinner-button__gif {
|
||||||
|
height: 15px;
|
||||||
|
margin-top: 2px;
|
||||||
|
width: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
Ссылка в новой задаче
Block a user