From c02b0e05919623df5bbf2167f0b9f1951f6949a1 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 29 Jul 2018 18:39:00 +0200 Subject: [PATCH] Created ShortUrlVisits page --- src/common/MenuLayout.js | 6 ++++++ src/short-urls/ShortUrlVisits.js | 11 +++++++++++ src/short-urls/helpers/ShortUrlsRow.js | 6 ++++-- src/short-urls/helpers/ShortUrlsRowMenu.js | 6 ++++-- 4 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 src/short-urls/ShortUrlVisits.js diff --git a/src/common/MenuLayout.js b/src/common/MenuLayout.js index 4cbaaa7c..64caa4cd 100644 --- a/src/common/MenuLayout.js +++ b/src/common/MenuLayout.js @@ -4,6 +4,7 @@ import { connect } from 'react-redux'; import { selectServer } from '../servers/reducers/selectedServer'; import CreateShortUrl from '../short-urls/CreateShortUrl'; import ShortUrls from '../short-urls/ShortUrls'; +import ShortUrlsVisits from '../short-urls/ShortUrlVisits'; import AsideMenu from './AsideMenu'; import { pick } from 'ramda'; @@ -29,6 +30,11 @@ export class MenuLayout extends React.Component { path="/server/:serverId/create-short-url" component={CreateShortUrl} /> + diff --git a/src/short-urls/ShortUrlVisits.js b/src/short-urls/ShortUrlVisits.js new file mode 100644 index 00000000..39eac8c7 --- /dev/null +++ b/src/short-urls/ShortUrlVisits.js @@ -0,0 +1,11 @@ +import React from 'react'; +import { connect } from 'react-redux'; + +export class ShortUrlsVisits extends React.Component { + render() { + const { match: { params } } = this.props; + return
Visits for {params.shortCode}
; + } +} + +export default connect()(ShortUrlsVisits); diff --git a/src/short-urls/helpers/ShortUrlsRow.js b/src/short-urls/helpers/ShortUrlsRow.js index 29b36e55..5c5fafa1 100644 --- a/src/short-urls/helpers/ShortUrlsRow.js +++ b/src/short-urls/helpers/ShortUrlsRow.js @@ -5,10 +5,10 @@ import { ShortUrlsRowMenu } from './ShortUrlsRowMenu'; import './ShortUrlsRow.scss' export class ShortUrlsRow extends React.Component { - state = {displayMenu: false, copiedToClipboard: false}; + state = { displayMenu: false, copiedToClipboard: false }; render() { - const {shortUrl, selectedServer} = this.props; + const { shortUrl, selectedServer } = this.props; const completeShortUrl = !selectedServer ? shortUrl.shortCode : `${selectedServer.url}/${shortUrl.shortCode}`; return ( @@ -37,6 +37,8 @@ export class ShortUrlsRow extends React.Component { { this.setState({ copiedToClipboard: true }); setTimeout(() => this.setState({ copiedToClipboard: false }), 2000); diff --git a/src/short-urls/helpers/ShortUrlsRowMenu.js b/src/short-urls/helpers/ShortUrlsRowMenu.js index d3c04148..4700c625 100644 --- a/src/short-urls/helpers/ShortUrlsRowMenu.js +++ b/src/short-urls/helpers/ShortUrlsRowMenu.js @@ -6,6 +6,7 @@ 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 { Link } from 'react-router-dom'; import { ButtonDropdown, DropdownItem, DropdownMenu, DropdownToggle } from 'reactstrap'; import PreviewModal from './PreviewModal'; import QrCodeModal from './QrCodeModal'; @@ -16,7 +17,8 @@ export class ShortUrlsRowMenu extends React.Component { toggle = () => this.setState({ isOpen: !this.state.isOpen }); render() { - const {display, shortUrl, onCopyToClipboard} = this.props; + const { display, shortUrl, onCopyToClipboard, selectedServer, shortCode } = this.props; + const serverId = selectedServer ? selectedServer.id : ''; 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}); @@ -28,7 +30,7 @@ export class ShortUrlsRowMenu extends React.Component {    - +  Visit Stats