From d244b830ac1321cab4d34b1c2f455c2cd919251f Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 19 Jan 2020 21:11:07 +0100 Subject: [PATCH 1/3] Updated date on license file --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 174f9b71..f58abfbc 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2018-2019 shlinkio +Copyright (c) 2018-2020 shlinkio Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 2236ed467e65057da536c67dae4e411f3cfa25aa Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 19 Jan 2020 21:25:45 +0100 Subject: [PATCH 2/3] Ensured date range filtering is only displayed if Shlink v1.21 ow higer is run --- src/short-urls/SearchBar.js | 26 +++++++++++++--------- src/short-urls/services/provideServices.js | 2 +- test/short-urls/SearchBar.test.js | 15 +++++++++---- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/short-urls/SearchBar.js b/src/short-urls/SearchBar.js index 71368571..3c75178a 100644 --- a/src/short-urls/SearchBar.js +++ b/src/short-urls/SearchBar.js @@ -7,19 +7,23 @@ import moment from 'moment'; import SearchField from '../utils/SearchField'; import Tag from '../tags/helpers/Tag'; import DateRangeRow from '../utils/DateRangeRow'; -import { formatDate } from '../utils/utils'; +import { compareVersions, formatDate } from '../utils/utils'; +import { serverType } from '../servers/prop-types'; import { shortUrlsListParamsType } from './reducers/shortUrlsListParams'; import './SearchBar.scss'; const propTypes = { listShortUrls: PropTypes.func, shortUrlsListParams: shortUrlsListParamsType, + selectedServer: serverType, }; const dateOrUndefined = (date) => date ? moment(date) : undefined; const SearchBar = (colorGenerator) => { - const SearchBar = ({ listShortUrls, shortUrlsListParams }) => { + const SearchBar = ({ listShortUrls, shortUrlsListParams, selectedServer }) => { + const currentServerVersion = selectedServer ? selectedServer.version : ''; + const enableDateFiltering = !isEmpty(currentServerVersion) && compareVersions(currentServerVersion, '>=', '1.21.0'); const selectedTags = shortUrlsListParams.tags || []; const setDate = (dateName) => pipe( formatDate(), @@ -34,14 +38,16 @@ const SearchBar = (colorGenerator) => { } /> -
- -
+ {enableDateFiltering && ( +
+ +
+ )} {!isEmpty(selectedTags) && (

diff --git a/src/short-urls/services/provideServices.js b/src/short-urls/services/provideServices.js index a46974c9..610d3e08 100644 --- a/src/short-urls/services/provideServices.js +++ b/src/short-urls/services/provideServices.js @@ -25,7 +25,7 @@ const provideServices = (bottle, connect) => { )); bottle.serviceFactory('SearchBar', SearchBar, 'ColorGenerator'); - bottle.decorator('SearchBar', connect([ 'shortUrlsListParams' ], [ 'listShortUrls' ])); + bottle.decorator('SearchBar', connect([ 'shortUrlsListParams', 'selectedServer' ], [ 'listShortUrls' ])); bottle.serviceFactory('ShortUrlsList', ShortUrlsList, 'ShortUrlsRow'); bottle.decorator('ShortUrlsList', connect( diff --git a/test/short-urls/SearchBar.test.js b/test/short-urls/SearchBar.test.js index 411e5665..172b8189 100644 --- a/test/short-urls/SearchBar.test.js +++ b/test/short-urls/SearchBar.test.js @@ -22,10 +22,15 @@ describe('', () => { expect(wrapper.find(SearchField)).toHaveLength(1); }); - it('renders a DateRangeRow', () => { - wrapper = shallow(); + each([ + [ '2.0.0', 1 ], + [ '1.21.2', 1 ], + [ '1.21.0', 1 ], + [ '1.20.0', 0 ], + ]).it('renders a DateRangeRow when proper version is run', (version, expectedLength) => { + wrapper = shallow(); - expect(wrapper.find(DateRangeRow)).toHaveLength(1); + expect(wrapper.find(DateRangeRow)).toHaveLength(expectedLength); }); it('renders no tags when the list of tags is empty', () => { @@ -63,7 +68,9 @@ describe('', () => { }); each([ 'startDateChange', 'endDateChange' ]).it('updates short URLs list when date range changes', (event) => { - wrapper = shallow(); + wrapper = shallow( + + ); const dateRange = wrapper.find(DateRangeRow); expect(listShortUrlsMock).not.toHaveBeenCalled(); From 5762342d6cc5ec8c13bc7cc0e09a9bf91da62073 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 19 Jan 2020 21:30:01 +0100 Subject: [PATCH 3/3] Ensured edit meta menu item is only displayed when shlink v1.18 or greater is run --- src/short-urls/helpers/ShortUrlsRowMenu.js | 13 +++++++++---- test/short-urls/helpers/ShortUrlsRowMenu.test.js | 5 +++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/short-urls/helpers/ShortUrlsRowMenu.js b/src/short-urls/helpers/ShortUrlsRowMenu.js index e8921d04..29d67d43 100644 --- a/src/short-urls/helpers/ShortUrlsRowMenu.js +++ b/src/short-urls/helpers/ShortUrlsRowMenu.js @@ -46,6 +46,7 @@ const ShortUrlsRowMenu = ( const { onCopyToClipboard, shortUrl, selectedServer } = this.props; const completeShortUrl = shortUrl && shortUrl.shortUrl ? shortUrl.shortUrl : ''; const currentServerVersion = selectedServer ? selectedServer.version : ''; + const showEditMetaBtn = !isEmpty(currentServerVersion) && compareVersions(currentServerVersion, '>=', '1.18.0'); const showPreviewBtn = !isEmpty(currentServerVersion) && compareVersions(currentServerVersion, '<', '2.0.0'); const toggleModal = (prop) => () => this.setState((prevState) => ({ [prop]: !prevState[prop] })); const toggleQrCode = toggleModal('isQrModalOpen'); @@ -69,10 +70,14 @@ const ShortUrlsRowMenu = ( - - Edit metadata - - + {showEditMetaBtn && ( + + + Edit metadata + + + + )} Delete short URL diff --git a/test/short-urls/helpers/ShortUrlsRowMenu.test.js b/test/short-urls/helpers/ShortUrlsRowMenu.test.js index 1deb8430..362d61e5 100644 --- a/test/short-urls/helpers/ShortUrlsRowMenu.test.js +++ b/test/short-urls/helpers/ShortUrlsRowMenu.test.js @@ -47,6 +47,11 @@ describe('', () => { }); each([ + [ '1.17.0', 6, 2 ], + [ '1.17.2', 6, 2 ], + [ '1.18.0', 7, 2 ], + [ '1.18.1', 7, 2 ], + [ '1.19.0', 7, 2 ], [ '1.20.3', 7, 2 ], [ '1.21.0', 7, 2 ], [ '1.21.1', 7, 2 ],