PLT-4493 Fixed copy button in Get Link Modal on Safari 10 (#4786)
* Fixed copy button in Get Link Modal for Safari 10 * Shortened 'link copied' label on GetLinkModal
Этот коммит содержится в:
коммит произвёл
Corey Hulen
родитель
0bbc599b68
Коммит
0529b253fc
@@ -1,14 +1,11 @@
|
|||||||
// 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 $ from 'jquery';
|
|
||||||
import ReactDOM from 'react-dom';
|
|
||||||
import {FormattedMessage} from 'react-intl';
|
|
||||||
|
|
||||||
import {Modal} from 'react-bootstrap';
|
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
|
import {FormattedMessage} from 'react-intl';
|
||||||
|
import {Modal} from 'react-bootstrap';
|
||||||
|
|
||||||
export default class GetLinkModal extends React.Component {
|
export default class GetLinkModal extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
@@ -16,37 +13,25 @@ export default class GetLinkModal extends React.Component {
|
|||||||
this.onHide = this.onHide.bind(this);
|
this.onHide = this.onHide.bind(this);
|
||||||
|
|
||||||
this.copyLink = this.copyLink.bind(this);
|
this.copyLink = this.copyLink.bind(this);
|
||||||
this.selectLinkOnClick = this.selectLinkOnClick.bind(this);
|
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
copiedLink: false
|
copiedLink: false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
componntWillUnmount() {
|
|
||||||
$(this.refs.textarea).off('click');
|
|
||||||
}
|
|
||||||
|
|
||||||
onHide() {
|
onHide() {
|
||||||
this.setState({copiedLink: false});
|
this.setState({copiedLink: false});
|
||||||
|
|
||||||
this.props.onHide();
|
this.props.onHide();
|
||||||
}
|
}
|
||||||
|
|
||||||
selectLinkOnClick() {
|
|
||||||
$(this.refs.textarea).on('click', function selectLinkOnClick() {
|
|
||||||
$(this).select();
|
|
||||||
this.setSelectionRange(0, this.value.length);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
copyLink() {
|
copyLink() {
|
||||||
var copyTextarea = $(ReactDOM.findDOMNode(this.refs.textarea));
|
const textarea = this.refs.textarea;
|
||||||
copyTextarea.select();
|
textarea.focus();
|
||||||
|
textarea.setSelectionRange(0, this.props.link.length);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var successful = document.execCommand('copy');
|
if (document.execCommand('copy')) {
|
||||||
if (successful) {
|
|
||||||
this.setState({copiedLink: true});
|
this.setState({copiedLink: true});
|
||||||
} else {
|
} else {
|
||||||
this.setState({copiedLink: false});
|
this.setState({copiedLink: false});
|
||||||
@@ -90,6 +75,7 @@ export default class GetLinkModal extends React.Component {
|
|||||||
className='form-control no-resize min-height'
|
className='form-control no-resize min-height'
|
||||||
ref='textarea'
|
ref='textarea'
|
||||||
value={this.props.link}
|
value={this.props.link}
|
||||||
|
onClick={this.copyLink}
|
||||||
readOnly={true}
|
readOnly={true}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@@ -101,7 +87,7 @@ export default class GetLinkModal extends React.Component {
|
|||||||
<i className='fa fa-check'/>
|
<i className='fa fa-check'/>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id='get_link.clipboard'
|
id='get_link.clipboard'
|
||||||
defaultMessage=' Link copied to clipboard.'
|
defaultMessage=' Link copied'
|
||||||
/>
|
/>
|
||||||
</p>
|
</p>
|
||||||
);
|
);
|
||||||
@@ -111,7 +97,6 @@ export default class GetLinkModal extends React.Component {
|
|||||||
<Modal
|
<Modal
|
||||||
show={this.props.show}
|
show={this.props.show}
|
||||||
onHide={this.onHide}
|
onHide={this.onHide}
|
||||||
onEntered={this.selectLinkOnClick}
|
|
||||||
>
|
>
|
||||||
<Modal.Header closeButton={true}>
|
<Modal.Header closeButton={true}>
|
||||||
<h4 className='modal-title'>{this.props.title}</h4>
|
<h4 className='modal-title'>{this.props.title}</h4>
|
||||||
|
|||||||
@@ -1301,7 +1301,7 @@
|
|||||||
"get_app.iosHeader": "Mattermost works best if you switch to our iPhone app",
|
"get_app.iosHeader": "Mattermost works best if you switch to our iPhone app",
|
||||||
"get_app.mattermostInc": "Mattermost, Inc",
|
"get_app.mattermostInc": "Mattermost, Inc",
|
||||||
"get_app.openMattermost": "Open Mattermost",
|
"get_app.openMattermost": "Open Mattermost",
|
||||||
"get_link.clipboard": " Link copied to clipboard.",
|
"get_link.clipboard": " Link copied",
|
||||||
"get_link.close": "Close",
|
"get_link.close": "Close",
|
||||||
"get_link.copy": "Copy Link",
|
"get_link.copy": "Copy Link",
|
||||||
"get_post_link_modal.help": "The link below allows authorized users to see your post.",
|
"get_post_link_modal.help": "The link below allows authorized users to see your post.",
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user