// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import $ from 'jquery'; import ReactDOM from 'react-dom'; import {FormattedMessage} from 'react-intl'; import {Modal} from 'react-bootstrap'; import React from 'react'; export default class GetLinkModal extends React.Component { constructor(props) { super(props); this.onHide = this.onHide.bind(this); this.copyLink = this.copyLink.bind(this); this.selectLinkOnClick = this.selectLinkOnClick.bind(this); this.state = { copiedLink: false }; } componntWillUnmount() { $(this.refs.textarea).off('click'); } onHide() { this.setState({copiedLink: false}); this.props.onHide(); } selectLinkOnClick() { $(this.refs.textarea).on('click', function selectLinkOnClick() { $(this).select(); this.setSelectionRange(0, this.value.length); }); } 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}