// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. const Modal = ReactBootstrap.Modal; export default class GetLinkModal extends React.Component { constructor(props) { super(props); this.onHide = this.onHide.bind(this); this.copyLink = this.copyLink.bind(this); this.state = { copiedLink: false }; } onHide() { this.setState({copiedLink: false}); this.props.onHide(); } copyLink() { 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() { let helpText = null; if (this.props.helpText) { helpText = (

{this.props.helpText}

); } let copyLink = null; if (document.queryCommandSupported('copy')) { copyLink = ( ); } var copyLinkConfirm = null; if (this.state.copiedLink) { copyLinkConfirm =

{' Link copied to clipboard.'}

; } return (

{this.props.title}

{helpText}