From 12896bd23eeba79884245c1c29fdc568cf21a7fa Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Mon, 14 Mar 2016 08:50:46 -0400 Subject: Converting to Webpack. Stage 1. --- webapp/components/get_link_modal.jsx | 139 +++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 webapp/components/get_link_modal.jsx (limited to 'webapp/components/get_link_modal.jsx') diff --git a/webapp/components/get_link_modal.jsx b/webapp/components/get_link_modal.jsx new file mode 100644 index 000000000..c04ebb957 --- /dev/null +++ b/webapp/components/get_link_modal.jsx @@ -0,0 +1,139 @@ +// 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.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 = ( + + ); + } + + const linkText = ( +