mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 01:20:24 +03:00
Extracted ShortUrlsRowMenu to its own module
This commit is contained in:
parent
842b1a7590
commit
b734b4515b
4 changed files with 77 additions and 74 deletions
|
@ -1,20 +1,12 @@
|
|||
import caretDownIcon from '@fortawesome/fontawesome-free-solid/faCaretDown';
|
||||
import caretUpIcon from '@fortawesome/fontawesome-free-solid/faCaretUp';
|
||||
import FontAwesomeIcon from '@fortawesome/react-fontawesome';
|
||||
import { isEmpty } from 'ramda';
|
||||
import React from 'react';
|
||||
import { CopyToClipboard } from 'react-copy-to-clipboard';
|
||||
import Moment from 'react-moment';
|
||||
import { connect } from 'react-redux';
|
||||
import { ButtonDropdown, DropdownItem, DropdownMenu, DropdownToggle } from 'reactstrap';
|
||||
import { isEmpty } from 'ramda';
|
||||
import caretUpIcon from '@fortawesome/fontawesome-free-solid/faCaretUp';
|
||||
import caretDownIcon from '@fortawesome/fontawesome-free-solid/faCaretDown';
|
||||
import pieChartIcon from '@fortawesome/fontawesome-free-solid/faChartPie';
|
||||
import pictureIcon from '@fortawesome/fontawesome-free-regular/faImage';
|
||||
import qrIcon from '@fortawesome/fontawesome-free-solid/faQrcode';
|
||||
import copyIcon from '@fortawesome/fontawesome-free-regular/faCopy';
|
||||
import menuIcon from '@fortawesome/fontawesome-free-solid/faEllipsisV';
|
||||
import FontAwesomeIcon from '@fortawesome/react-fontawesome';
|
||||
import Tag from '../utils/Tag';
|
||||
import PreviewModal from './helpers/PreviewModal';
|
||||
import QrCodeModal from './helpers/QrCodeModal';
|
||||
import { RowMenu } from './helpers/ShortUrlsRowMenu';
|
||||
import { listShortUrls } from './reducers/shortUrlsList';
|
||||
import './ShortUrlsList.scss';
|
||||
|
||||
|
@ -175,60 +167,6 @@ class Row extends React.Component {
|
|||
}
|
||||
}
|
||||
|
||||
class RowMenu extends React.Component {
|
||||
state = { isOpen: false, isQrModalOpen: false, isPreviewOpen: false };
|
||||
toggle = () => this.setState({ isOpen: ! this.state.isOpen });
|
||||
|
||||
render () {
|
||||
const { display, shortUrl, onCopyToClipboard } = this.props;
|
||||
const baseClass = 'short-urls-list__dropdown-toggle';
|
||||
const toggleClass = ! display ? `${baseClass} short-urls-list__dropdown-toggle--hidden` : baseClass;
|
||||
const toggleQrCode = () => this.setState({ isQrModalOpen: !this.state.isQrModalOpen });
|
||||
const togglePreview = () => this.setState({ isPreviewOpen: !this.state.isPreviewOpen });
|
||||
|
||||
return (
|
||||
<ButtonDropdown toggle={this.toggle} isOpen={this.state.isOpen} direction="left">
|
||||
<DropdownToggle color="white" size="sm" caret className={toggleClass}>
|
||||
<FontAwesomeIcon icon={menuIcon} />
|
||||
</DropdownToggle>
|
||||
<DropdownMenu>
|
||||
<DropdownItem>
|
||||
<FontAwesomeIcon icon={pieChartIcon} /> Visit Stats
|
||||
</DropdownItem>
|
||||
|
||||
<DropdownItem divider />
|
||||
|
||||
<DropdownItem onClick={togglePreview}>
|
||||
<FontAwesomeIcon icon={pictureIcon} /> Preview
|
||||
</DropdownItem>
|
||||
<PreviewModal
|
||||
url={shortUrl}
|
||||
isOpen={this.state.isPreviewOpen}
|
||||
toggle={togglePreview}
|
||||
/>
|
||||
|
||||
<DropdownItem onClick={toggleQrCode}>
|
||||
<FontAwesomeIcon icon={qrIcon} /> QR code
|
||||
</DropdownItem>
|
||||
<QrCodeModal
|
||||
url={shortUrl}
|
||||
isOpen={this.state.isQrModalOpen}
|
||||
toggle={toggleQrCode}
|
||||
/>
|
||||
|
||||
<DropdownItem divider />
|
||||
|
||||
<CopyToClipboard text={shortUrl} onCopy={onCopyToClipboard}>
|
||||
<DropdownItem>
|
||||
<FontAwesomeIcon icon={copyIcon} /> Copy to clipboard
|
||||
</DropdownItem>
|
||||
</CopyToClipboard>
|
||||
</DropdownMenu>
|
||||
</ButtonDropdown>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(state => ({
|
||||
selectedServer: state.selectedServer,
|
||||
shortUrlsListParams: state.shortUrlsListParams,
|
||||
|
|
|
@ -12,13 +12,6 @@
|
|||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.short-urls-list__dropdown-toggle:before {
|
||||
display: none !important;
|
||||
}
|
||||
.short-urls-list__dropdown-toggle--hidden {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.short-urls-list__cell--relative {
|
||||
position: relative;
|
||||
}
|
||||
|
|
66
src/short-urls/helpers/ShortUrlsRowMenu.js
Normal file
66
src/short-urls/helpers/ShortUrlsRowMenu.js
Normal file
|
@ -0,0 +1,66 @@
|
|||
import copyIcon from '@fortawesome/fontawesome-free-regular/faCopy';
|
||||
import pictureIcon from '@fortawesome/fontawesome-free-regular/faImage';
|
||||
import pieChartIcon from '@fortawesome/fontawesome-free-solid/faChartPie';
|
||||
import menuIcon from '@fortawesome/fontawesome-free-solid/faEllipsisV';
|
||||
import qrIcon from '@fortawesome/fontawesome-free-solid/faQrcode';
|
||||
import FontAwesomeIcon from '@fortawesome/react-fontawesome';
|
||||
import React from 'react';
|
||||
import { CopyToClipboard } from 'react-copy-to-clipboard';
|
||||
import { ButtonDropdown, DropdownItem, DropdownMenu, DropdownToggle } from 'reactstrap';
|
||||
import PreviewModal from './PreviewModal';
|
||||
import QrCodeModal from './QrCodeModal';
|
||||
import './ShortUrlsRowMenu.scss';
|
||||
|
||||
export class RowMenu extends React.Component {
|
||||
state = { isOpen: false, isQrModalOpen: false, isPreviewOpen: false };
|
||||
toggle = () => this.setState({ isOpen: !this.state.isOpen });
|
||||
|
||||
render() {
|
||||
const {display, shortUrl, onCopyToClipboard} = this.props;
|
||||
const baseClass = 'short-urls-row-menu__dropdown-toggle';
|
||||
const toggleClass = !display ? `${baseClass} short-urls-row-menu__dropdown-toggle--hidden` : baseClass;
|
||||
const toggleQrCode = () => this.setState({isQrModalOpen: !this.state.isQrModalOpen});
|
||||
const togglePreview = () => this.setState({isPreviewOpen: !this.state.isPreviewOpen});
|
||||
|
||||
return (
|
||||
<ButtonDropdown toggle={this.toggle} isOpen={this.state.isOpen} direction="left">
|
||||
<DropdownToggle color="white" size="sm" caret className={toggleClass}>
|
||||
<FontAwesomeIcon icon={menuIcon}/>
|
||||
</DropdownToggle>
|
||||
<DropdownMenu>
|
||||
<DropdownItem>
|
||||
<FontAwesomeIcon icon={pieChartIcon}/> Visit Stats
|
||||
</DropdownItem>
|
||||
|
||||
<DropdownItem divider/>
|
||||
|
||||
<DropdownItem onClick={togglePreview}>
|
||||
<FontAwesomeIcon icon={pictureIcon}/> Preview
|
||||
</DropdownItem>
|
||||
<PreviewModal
|
||||
url={shortUrl}
|
||||
isOpen={this.state.isPreviewOpen}
|
||||
toggle={togglePreview}
|
||||
/>
|
||||
|
||||
<DropdownItem onClick={toggleQrCode}>
|
||||
<FontAwesomeIcon icon={qrIcon}/> QR code
|
||||
</DropdownItem>
|
||||
<QrCodeModal
|
||||
url={shortUrl}
|
||||
isOpen={this.state.isQrModalOpen}
|
||||
toggle={toggleQrCode}
|
||||
/>
|
||||
|
||||
<DropdownItem divider/>
|
||||
|
||||
<CopyToClipboard text={shortUrl} onCopy={onCopyToClipboard}>
|
||||
<DropdownItem>
|
||||
<FontAwesomeIcon icon={copyIcon}/> Copy to clipboard
|
||||
</DropdownItem>
|
||||
</CopyToClipboard>
|
||||
</DropdownMenu>
|
||||
</ButtonDropdown>
|
||||
);
|
||||
}
|
||||
}
|
6
src/short-urls/helpers/ShortUrlsRowMenu.scss
Normal file
6
src/short-urls/helpers/ShortUrlsRowMenu.scss
Normal file
|
@ -0,0 +1,6 @@
|
|||
.short-urls-row-menu__dropdown-toggle:before {
|
||||
display: none !important;
|
||||
}
|
||||
.short-urls-row-menu__dropdown-toggle--hidden {
|
||||
visibility: hidden;
|
||||
}
|
Loading…
Reference in a new issue