// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import UserStore from '../stores/user_store.jsx'; export default class GetLinkModal extends React.Component { constructor(props) { super(props); this.handleClick = this.handleClick.bind(this); this.onShow = this.onShow.bind(this); this.onHide = this.onHide.bind(this); this.state = {copiedLink: false}; } onShow(e) { var button = e.relatedTarget; this.setState({title: $(button).attr('data-title'), value: $(button).attr('data-value')}); } onHide() { this.setState({copiedLink: false}); } componentDidMount() { if (this.refs.modal) { $(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)); copyTextarea.select(); try { var successful = document.execCommand('copy'); if (successful) { this.setState({copiedLink: true}); } else { this.setState({copiedLink: false}); } } catch (err) { this.setState({copiedLink: false}); } } render() { var currentUser = UserStore.getCurrentUser(); let copyLink = null; if (document.queryCommandSupported('copy')) { copyLink = ( ); } var copyLinkConfirm = null; if (this.state.copiedLink) { copyLinkConfirm =
Link copied to clipboard.
; } if (currentUser != null) { return ( ); } return ; } }