Converted GetLinkModal to React-Bootstrap and added GetTeamInviteLinkModal
Этот коммит содержится в:
@@ -1,32 +1,28 @@
|
|||||||
// 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 UserStore from '../stores/user_store.jsx';
|
const Modal = ReactBootstrap.Modal;
|
||||||
|
|
||||||
export default class GetLinkModal extends React.Component {
|
export default class GetLinkModal extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
this.handleClick = this.handleClick.bind(this);
|
|
||||||
this.onShow = this.onShow.bind(this);
|
|
||||||
this.onHide = this.onHide.bind(this);
|
this.onHide = this.onHide.bind(this);
|
||||||
|
|
||||||
this.state = {copiedLink: false};
|
this.copyLink = this.copyLink.bind(this);
|
||||||
}
|
|
||||||
onShow(e) {
|
this.state = {
|
||||||
var button = e.relatedTarget;
|
copiedLink: false
|
||||||
this.setState({title: $(button).attr('data-title'), value: $(button).attr('data-value')});
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
onHide() {
|
onHide() {
|
||||||
this.setState({copiedLink: false});
|
this.setState({copiedLink: false});
|
||||||
|
|
||||||
|
this.props.onHide();
|
||||||
}
|
}
|
||||||
componentDidMount() {
|
|
||||||
if (this.refs.modal) {
|
copyLink() {
|
||||||
$(ReactDOM.findDOMNode(this.refs.modal)).on('show.bs.modal', this.onShow);
|
|
||||||
$(ReactDOM.findDOMNode(this.refs.modal)).on('hide.bs.modal', this.onHide);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
handleClick() {
|
|
||||||
var copyTextarea = $(ReactDOM.findDOMNode(this.refs.textarea));
|
var copyTextarea = $(ReactDOM.findDOMNode(this.refs.textarea));
|
||||||
copyTextarea.select();
|
copyTextarea.select();
|
||||||
|
|
||||||
@@ -41,8 +37,18 @@ export default class GetLinkModal extends React.Component {
|
|||||||
this.setState({copiedLink: false});
|
this.setState({copiedLink: false});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
var currentUser = UserStore.getCurrentUser();
|
let helpText = null;
|
||||||
|
if (this.props.helpText) {
|
||||||
|
helpText = (
|
||||||
|
<p>
|
||||||
|
{this.props.helpText}
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
</p>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
let copyLink = null;
|
let copyLink = null;
|
||||||
if (document.queryCommandSupported('copy')) {
|
if (document.queryCommandSupported('copy')) {
|
||||||
@@ -51,75 +57,59 @@ export default class GetLinkModal extends React.Component {
|
|||||||
data-copy-btn='true'
|
data-copy-btn='true'
|
||||||
type='button'
|
type='button'
|
||||||
className='btn btn-primary pull-left'
|
className='btn btn-primary pull-left'
|
||||||
onClick={this.handleClick}
|
onClick={this.copyLink}
|
||||||
data-clipboard-text={this.state.value}
|
|
||||||
>
|
>
|
||||||
Copy Link
|
{'Copy Link'}
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
var copyLinkConfirm = null;
|
var copyLinkConfirm = null;
|
||||||
if (this.state.copiedLink) {
|
if (this.state.copiedLink) {
|
||||||
copyLinkConfirm = <p className='alert alert-success copy-link-confirm'><i className='fa fa-check'></i> Link copied to clipboard.</p>;
|
copyLinkConfirm = <p className='alert alert-success copy-link-confirm'><i className='fa fa-check'></i>{' Link copied to clipboard.'}</p>;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentUser != null) {
|
return (
|
||||||
return (
|
<Modal
|
||||||
<div
|
show={this.props.show}
|
||||||
className='modal fade'
|
onHide={this.onHide}
|
||||||
ref='modal'
|
>
|
||||||
id='get_link'
|
<Modal.Header closeButton={true}>
|
||||||
tabIndex='-1'
|
{this.props.title}
|
||||||
role='dialog'
|
</Modal.Header>
|
||||||
aria-hidden='true'
|
<Modal.Body>
|
||||||
>
|
{helpText}
|
||||||
<div className='modal-dialog'>
|
<textarea
|
||||||
<div className='modal-content'>
|
className='form-control no-resize min-height'
|
||||||
<div className='modal-header'>
|
readOnly='true'
|
||||||
<button
|
ref='textarea'
|
||||||
type='button'
|
value={this.props.link}
|
||||||
className='close'
|
/>
|
||||||
data-dismiss='modal'
|
</Modal.Body>
|
||||||
aria-label='Close'
|
<Modal.Footer>
|
||||||
>
|
<button
|
||||||
<span aria-hidden='true'>×</span>
|
type='button'
|
||||||
</button>
|
className='btn btn-default'
|
||||||
<h4
|
onClick={this.onHide}
|
||||||
className='modal-title'
|
>
|
||||||
id='myModalLabel'
|
{'Close'}
|
||||||
>
|
</button>
|
||||||
{this.state.title} Link
|
{copyLink}
|
||||||
</h4>
|
{copyLinkConfirm}
|
||||||
</div>
|
</Modal.Footer>
|
||||||
<div className='modal-body'>
|
</Modal>
|
||||||
<p>
|
);
|
||||||
Send teammates the link below for them to sign-up to this team site.
|
|
||||||
<br /><br />
|
|
||||||
</p>
|
|
||||||
<textarea
|
|
||||||
className='form-control no-resize min-height'
|
|
||||||
readOnly='true'
|
|
||||||
ref='textarea'
|
|
||||||
value={this.state.value}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className='modal-footer'>
|
|
||||||
<button
|
|
||||||
type='button'
|
|
||||||
className='btn btn-default'
|
|
||||||
data-dismiss='modal'
|
|
||||||
>
|
|
||||||
Close
|
|
||||||
</button>
|
|
||||||
{copyLink}
|
|
||||||
{copyLinkConfirm}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return <div/>;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GetLinkModal.propTypes = {
|
||||||
|
show: React.PropTypes.bool.isRequired,
|
||||||
|
onHide: React.PropTypes.func.isRequired,
|
||||||
|
title: React.PropTypes.string.isRequired,
|
||||||
|
helpText: React.PropTypes.string,
|
||||||
|
link: React.PropTypes.string.isRequired
|
||||||
|
};
|
||||||
|
|
||||||
|
GetLinkModal.defaultProps = {
|
||||||
|
helpText: null
|
||||||
|
};
|
||||||
|
|||||||
53
web/react/components/get_team_invite_link_modal.jsx
Обычный файл
53
web/react/components/get_team_invite_link_modal.jsx
Обычный файл
@@ -0,0 +1,53 @@
|
|||||||
|
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
|
||||||
|
// See License.txt for license information.
|
||||||
|
|
||||||
|
import AppDispatcher from '../dispatcher/app_dispatcher.jsx';
|
||||||
|
import Constants from '../utils/constants.jsx';
|
||||||
|
import GetLinkModal from './get_link_modal.jsx';
|
||||||
|
import ModalStore from '../stores/modal_store.jsx';
|
||||||
|
import TeamStore from '../stores/team_store.jsx';
|
||||||
|
|
||||||
|
export default class GetTeamInviteLinkModal extends React.Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
|
||||||
|
this.handleToggle = this.handleToggle.bind(this);
|
||||||
|
|
||||||
|
this.state = {
|
||||||
|
show: false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
ModalStore.addModalListener(Constants.ActionTypes.TOGGLE_GET_TEAM_INVITE_LINK_MODAL, this.handleToggle);
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
ModalStore.removeModalListener(Constants.ActionTypes.TOGGLE_GET_TEAM_INVITE_LINK_MODAL, this.handleToggle);
|
||||||
|
}
|
||||||
|
|
||||||
|
handleToggle(value) {
|
||||||
|
this.setState({
|
||||||
|
show: value
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<GetLinkModal
|
||||||
|
show={this.state.show}
|
||||||
|
onHide={() => this.setState({show: false})}
|
||||||
|
title='Team Invite Link'
|
||||||
|
helpText='Send teammates the link below for them to sign-up to this team site.'
|
||||||
|
link={TeamStore.getCurrentInviteLink()}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static show() {
|
||||||
|
AppDispatcher.handleViewAction({
|
||||||
|
type: Constants.ActionTypes.TOGGLE_GET_TEAM_INVITE_LINK_MODAL,
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@ import ModalStore from '../stores/modal_store.jsx';
|
|||||||
import UserStore from '../stores/user_store.jsx';
|
import UserStore from '../stores/user_store.jsx';
|
||||||
import TeamStore from '../stores/team_store.jsx';
|
import TeamStore from '../stores/team_store.jsx';
|
||||||
import ConfirmModal from './confirm_modal.jsx';
|
import ConfirmModal from './confirm_modal.jsx';
|
||||||
|
import GetTeamInviteLinkModal from './get_team_invite_link_modal.jsx';
|
||||||
|
|
||||||
const Modal = ReactBootstrap.Modal;
|
const Modal = ReactBootstrap.Modal;
|
||||||
|
|
||||||
@@ -23,6 +24,7 @@ export default class InviteMemberModal extends React.Component {
|
|||||||
this.addInviteFields = this.addInviteFields.bind(this);
|
this.addInviteFields = this.addInviteFields.bind(this);
|
||||||
this.clearFields = this.clearFields.bind(this);
|
this.clearFields = this.clearFields.bind(this);
|
||||||
this.removeInviteFields = this.removeInviteFields.bind(this);
|
this.removeInviteFields = this.removeInviteFields.bind(this);
|
||||||
|
this.showGetTeamInviteLinkModal = this.showGetTeamInviteLinkModal.bind(this);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
show: false,
|
show: false,
|
||||||
@@ -188,6 +190,12 @@ export default class InviteMemberModal extends React.Component {
|
|||||||
this.setState({inviteIds: inviteIds, idCount: count});
|
this.setState({inviteIds: inviteIds, idCount: count});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
showGetTeamInviteLinkModal() {
|
||||||
|
this.handleHide(false);
|
||||||
|
|
||||||
|
GetTeamInviteLinkModal.show();
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
var currentUser = UserStore.getCurrentUser();
|
var currentUser = UserStore.getCurrentUser();
|
||||||
|
|
||||||
@@ -333,22 +341,18 @@ export default class InviteMemberModal extends React.Component {
|
|||||||
} else {
|
} else {
|
||||||
var teamInviteLink = null;
|
var teamInviteLink = null;
|
||||||
if (currentUser && TeamStore.getCurrent().type === 'O') {
|
if (currentUser && TeamStore.getCurrent().type === 'O') {
|
||||||
var linkUrl = utils.getWindowLocationOrigin() + '/signup_user_complete/?id=' + TeamStore.getCurrent().invite_id;
|
var link = (
|
||||||
var link =
|
<a
|
||||||
(
|
href='#'
|
||||||
<a
|
onClick={this.showGetTeamInviteLinkModal}
|
||||||
href='#'
|
>
|
||||||
data-toggle='modal'
|
{'Team Invite Link'}
|
||||||
data-target='#get_link'
|
</a>
|
||||||
data-title='Team Invite'
|
|
||||||
data-value={linkUrl}
|
|
||||||
onClick={() => this.handleHide(this, false)}
|
|
||||||
>Team Invite Link</a>
|
|
||||||
);
|
);
|
||||||
|
|
||||||
teamInviteLink = (
|
teamInviteLink = (
|
||||||
<p>
|
<p>
|
||||||
You can also invite people using the {link}.
|
{'You can also invite people using the '}{link}{'.'}
|
||||||
</p>
|
</p>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import UserStore from '../stores/user_store.jsx';
|
|||||||
import TeamStore from '../stores/team_store.jsx';
|
import TeamStore from '../stores/team_store.jsx';
|
||||||
|
|
||||||
import AboutBuildModal from './about_build_modal.jsx';
|
import AboutBuildModal from './about_build_modal.jsx';
|
||||||
|
import GetTeamInviteLinkModal from './get_team_invite_link_modal.jsx';
|
||||||
import InviteMemberModal from './invite_member_modal.jsx';
|
import InviteMemberModal from './invite_member_modal.jsx';
|
||||||
import UserSettingsModal from './user_settings/user_settings_modal.jsx';
|
import UserSettingsModal from './user_settings/user_settings_modal.jsx';
|
||||||
|
|
||||||
@@ -105,10 +106,7 @@ export default class NavbarDropdown extends React.Component {
|
|||||||
<li>
|
<li>
|
||||||
<a
|
<a
|
||||||
href='#'
|
href='#'
|
||||||
data-toggle='modal'
|
onClick={GetTeamInviteLinkModal.show}
|
||||||
data-target='#get_link'
|
|
||||||
data-title='Team Invite'
|
|
||||||
data-value={Utils.getWindowLocationOrigin() + '/signup_user_complete/?id=' + TeamStore.getCurrent().invite_id}
|
|
||||||
>
|
>
|
||||||
{'Get Team Invite Link'}
|
{'Get Team Invite Link'}
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
// 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 GetTeamInviteLinkModal from './get_team_invite_link_modal.jsx';
|
||||||
import InviteMemberModal from './invite_member_modal.jsx';
|
import InviteMemberModal from './invite_member_modal.jsx';
|
||||||
import UserSettingsModal from './user_settings/user_settings_modal.jsx';
|
import UserSettingsModal from './user_settings/user_settings_modal.jsx';
|
||||||
import UserStore from '../stores/user_store.jsx';
|
import UserStore from '../stores/user_store.jsx';
|
||||||
import TeamStore from '../stores/team_store.jsx';
|
|
||||||
import * as client from '../utils/client.jsx';
|
import * as client from '../utils/client.jsx';
|
||||||
import * as utils from '../utils/utils.jsx';
|
import * as utils from '../utils/utils.jsx';
|
||||||
|
|
||||||
@@ -56,12 +56,12 @@ export default class SidebarRightMenu extends React.Component {
|
|||||||
if (this.props.teamType === 'O') {
|
if (this.props.teamType === 'O') {
|
||||||
teamLink = (
|
teamLink = (
|
||||||
<li>
|
<li>
|
||||||
<a href='#'
|
<a
|
||||||
data-toggle='modal'
|
href='#'
|
||||||
data-target='#get_link'
|
onClick={GetTeamInviteLinkModal.show}
|
||||||
data-title='Team Invite'
|
>
|
||||||
data-value={utils.getWindowLocationOrigin() + '/signup_user_complete/?id=' + TeamStore.getCurrent().invite_id}
|
<i className='glyphicon glyphicon-link'></i>{'Get Team Invite Link'}
|
||||||
><i className='fa fa-link'></i>Get Team Invite Link</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import ErrorBar from '../components/error_bar.jsx';
|
|||||||
import ErrorStore from '../stores/error_store.jsx';
|
import ErrorStore from '../stores/error_store.jsx';
|
||||||
|
|
||||||
import MentionList from '../components/mention_list.jsx';
|
import MentionList from '../components/mention_list.jsx';
|
||||||
import GetLinkModal from '../components/get_link_modal.jsx';
|
import GetTeamInviteLinkModal from '../components/get_team_invite_link_modal.jsx';
|
||||||
import RenameChannelModal from '../components/rename_channel_modal.jsx';
|
import RenameChannelModal from '../components/rename_channel_modal.jsx';
|
||||||
import EditPostModal from '../components/edit_post_modal.jsx';
|
import EditPostModal from '../components/edit_post_modal.jsx';
|
||||||
import DeletePostModal from '../components/delete_post_modal.jsx';
|
import DeletePostModal from '../components/delete_post_modal.jsx';
|
||||||
@@ -67,8 +67,8 @@ function setupChannelPage(props, team, channel) {
|
|||||||
// Modals
|
// Modals
|
||||||
//
|
//
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<GetLinkModal />,
|
<GetTeamInviteLinkModal />,
|
||||||
document.getElementById('get_link_modal')
|
document.getElementById('get_team_invite_link_modal')
|
||||||
);
|
);
|
||||||
|
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ class ModalStoreClass extends EventEmitter {
|
|||||||
case ActionTypes.TOGGLE_IMPORT_THEME_MODAL:
|
case ActionTypes.TOGGLE_IMPORT_THEME_MODAL:
|
||||||
case ActionTypes.TOGGLE_INVITE_MEMBER_MODAL:
|
case ActionTypes.TOGGLE_INVITE_MEMBER_MODAL:
|
||||||
case ActionTypes.TOGGLE_DELETE_POST_MODAL:
|
case ActionTypes.TOGGLE_DELETE_POST_MODAL:
|
||||||
|
case ActionTypes.TOGGLE_GET_TEAM_INVITE_LINK_MODAL:
|
||||||
this.emit(type, value, args);
|
this.emit(type, value, args);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ class TeamStoreClass extends EventEmitter {
|
|||||||
this.getCurrentId = this.getCurrentId.bind(this);
|
this.getCurrentId = this.getCurrentId.bind(this);
|
||||||
this.getCurrent = this.getCurrent.bind(this);
|
this.getCurrent = this.getCurrent.bind(this);
|
||||||
this.getCurrentTeamUrl = this.getCurrentTeamUrl.bind(this);
|
this.getCurrentTeamUrl = this.getCurrentTeamUrl.bind(this);
|
||||||
|
this.getCurrentInviteLink = this.getCurrentInviteLink.bind(this);
|
||||||
this.saveTeam = this.saveTeam.bind(this);
|
this.saveTeam = this.saveTeam.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,6 +93,16 @@ class TeamStoreClass extends EventEmitter {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getCurrentInviteLink() {
|
||||||
|
const current = this.getCurrent();
|
||||||
|
|
||||||
|
if (current) {
|
||||||
|
return getWindowLocationOrigin() + '/signup_user_complete/?id=' + current.invite_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
saveTeam(team) {
|
saveTeam(team) {
|
||||||
var teams = this.getAll();
|
var teams = this.getAll();
|
||||||
teams[team.id] = team;
|
teams[team.id] = team;
|
||||||
|
|||||||
@@ -101,10 +101,7 @@ export function createDefaultIntroMessage(channel) {
|
|||||||
<a
|
<a
|
||||||
className='intro-links'
|
className='intro-links'
|
||||||
href='#'
|
href='#'
|
||||||
data-toggle='modal'
|
onClick={GetTeamInviteLinkModal.show}
|
||||||
data-target='#get_link'
|
|
||||||
data-title='Team Invite'
|
|
||||||
data-value={Utils.getWindowLocationOrigin() + '/signup_user_complete/?id=' + team.id}
|
|
||||||
>
|
>
|
||||||
<i className='fa fa-user-plus'></i>{'Invite others to this team'}
|
<i className='fa fa-user-plus'></i>{'Invite others to this team'}
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -48,7 +48,8 @@ export default {
|
|||||||
|
|
||||||
TOGGLE_IMPORT_THEME_MODAL: null,
|
TOGGLE_IMPORT_THEME_MODAL: null,
|
||||||
TOGGLE_INVITE_MEMBER_MODAL: null,
|
TOGGLE_INVITE_MEMBER_MODAL: null,
|
||||||
TOGGLE_DELETE_POST_MODAL: null
|
TOGGLE_DELETE_POST_MODAL: null,
|
||||||
|
TOGGLE_GET_TEAM_INVITE_LINK_MODAL: null
|
||||||
}),
|
}),
|
||||||
|
|
||||||
PayloadSources: keyMirror({
|
PayloadSources: keyMirror({
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user