PLT-1310 moving permalink to dropdown

Этот коммит содержится в:
=Corey Hulen
2015-12-01 21:04:37 -08:00
родитель c8f642a499
Коммит 3e51a9ea2a
2 изменённых файлов: 37 добавлений и 14 удалений

Просмотреть файл

@@ -9,14 +9,15 @@ import * as EventHelpers from '../dispatcher/event_helpers.jsx';
import Constants from '../utils/constants.jsx'; import Constants from '../utils/constants.jsx';
const OverlayTrigger = ReactBootstrap.OverlayTrigger; const Overlay = ReactBootstrap.Overlay;
const Popover = ReactBootstrap.Popover; const Popover = ReactBootstrap.Popover;
export default class PostInfo extends React.Component { export default class PostInfo extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
copiedLink: false copiedLink: false,
show: false
}; };
this.handlePermalinkCopy = this.handlePermalinkCopy.bind(this); this.handlePermalinkCopy = this.handlePermalinkCopy.bind(this);
@@ -99,6 +100,20 @@ export default class PostInfo extends React.Component {
); );
} }
dropdownContents.push(
<li
key='copyLink'
role='presentation'
>
<a
href='#'
onClick={(e) => this.setState({target: e.target, show: !this.state.show})}
>
{'Permalink'}
</a>
</li>
);
if (dropdownContents.length === 0) { if (dropdownContents.length === 0) {
return ''; return '';
} }
@@ -121,6 +136,7 @@ export default class PostInfo extends React.Component {
</div> </div>
); );
} }
handlePermalinkCopy() { handlePermalinkCopy() {
const textBox = $(ReactDOM.findDOMNode(this.refs.permalinkbox)); const textBox = $(ReactDOM.findDOMNode(this.refs.permalinkbox));
textBox.select(); textBox.select();
@@ -128,7 +144,7 @@ export default class PostInfo extends React.Component {
try { try {
const successful = document.execCommand('copy'); const successful = document.execCommand('copy');
if (successful) { if (successful) {
this.setState({copiedLink: true}); this.setState({copiedLink: true, show: false});
} else { } else {
this.setState({copiedLink: false}); this.setState({copiedLink: false});
} }
@@ -167,7 +183,7 @@ export default class PostInfo extends React.Component {
var dropdown = this.createDropdown(); var dropdown = this.createDropdown();
const permalink = TeamStore.getCurrentTeamUrl() + '/pl/' + post.id; const permalink = TeamStore.getCurrentTeamUrl() + '/pl/' + post.id;
const copyButtonText = this.state.copiedLink ? (<div>{'Copy '}<i className='fa fa-check'/></div>) : 'Copy'; const copyButtonText = this.state.copiedLink ? (<div>{'Copy X '}<i className='fa fa-check'/></div>) : 'Copy X';
const permalinkOverlay = ( const permalinkOverlay = (
<Popover <Popover
id='permalink-overlay' id='permalink-overlay'
@@ -197,6 +213,8 @@ export default class PostInfo extends React.Component {
</Popover> </Popover>
); );
const containerPadding = 20;
return ( return (
<ul className='post__header post__header--info'> <ul className='post__header post__header--info'>
<li className='col'> <li className='col'>
@@ -206,18 +224,23 @@ export default class PostInfo extends React.Component {
</li> </li>
<li className='col col__reply'> <li className='col col__reply'>
{comments} {comments}
<OverlayTrigger <div
trigger='click' className='dropdown'
placement='left' ref='dotMenu'
rootClose={true}
overlay={permalinkOverlay}
> >
<i className={'permalink-icon fa fa-link ' + showCommentClass}/>
</OverlayTrigger>
<div className='dropdown'>
{dropdown} {dropdown}
</div> </div>
<Overlay
show={this.state.show}
target={() => ReactDOM.findDOMNode(this.refs.dotMenu)}
onHide={() => this.setState({show: false})}
placement='left'
container={this}
containerPadding={containerPadding}
rootClose={true}
>
{permalinkOverlay}
</Overlay>
</li> </li>
</ul> </ul>
); );

Просмотреть файл

@@ -564,7 +564,6 @@ body.ios {
display: inline-block; display: inline-block;
visibility: hidden; visibility: hidden;
top: -1px; top: -1px;
float: right;
.dropdown-menu { .dropdown-menu {
right: 0; right: 0;
@@ -794,4 +793,5 @@ body.ios {
.permalink-popover { .permalink-popover {
min-width: 320px; min-width: 320px;
margin-left: 50px !important;
} }