From d46acdbd702e6d6131a4e535ed085deffbc2223b Mon Sep 17 00:00:00 2001 From: MartinH0 Date: Tue, 7 Jul 2020 22:10:35 +0200 Subject: [PATCH 01/14] Added Links to Version Info Actually it would be better if the link is just added if version info is provided. Now the Link is given always. --- src/common/ShlinkVersions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/ShlinkVersions.js b/src/common/ShlinkVersions.js index 44afc1c4..f6126495 100644 --- a/src/common/ShlinkVersions.js +++ b/src/common/ShlinkVersions.js @@ -19,7 +19,7 @@ const ShlinkVersions = ({ selectedServer, className, clientVersion = SHLINK_WEB_ return ( - Client: {normalizedClientVersion} - Server: {serverVersion} + Client: {normalizedClientVersion} - Server: {serverVersion} ); }; From 1c335506d8a5181817e6ace2d4c87247c60179a5 Mon Sep 17 00:00:00 2001 From: MartinH0 Date: Thu, 9 Jul 2020 12:58:10 +0200 Subject: [PATCH 02/14] Update ShlinkVersions.js --- src/common/ShlinkVersions.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/common/ShlinkVersions.js b/src/common/ShlinkVersions.js index f6126495..27a8eeb7 100644 --- a/src/common/ShlinkVersions.js +++ b/src/common/ShlinkVersions.js @@ -4,6 +4,7 @@ import classNames from 'classnames'; import { pipe } from 'ramda'; import { serverType } from '../servers/prop-types'; import { versionToPrintable, versionToSemVer } from '../utils/helpers/version'; +import { ExternalLink } from 'react-external-link'; const SHLINK_WEB_CLIENT_VERSION = '%_VERSION_%'; @@ -19,7 +20,7 @@ const ShlinkVersions = ({ selectedServer, className, clientVersion = SHLINK_WEB_ return ( - Client: {normalizedClientVersion} - Server: {serverVersion} + Client: {normalizedClientVersion} - Server: {serverVersion} ); }; From 897e35f0b8ca1a9a1f23436bf8d013df2c1b544a Mon Sep 17 00:00:00 2001 From: MartinH0 Date: Thu, 9 Jul 2020 14:43:53 +0200 Subject: [PATCH 03/14] Update ShlinkVersions.js --- src/common/ShlinkVersions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/ShlinkVersions.js b/src/common/ShlinkVersions.js index 27a8eeb7..b583b159 100644 --- a/src/common/ShlinkVersions.js +++ b/src/common/ShlinkVersions.js @@ -20,7 +20,7 @@ const ShlinkVersions = ({ selectedServer, className, clientVersion = SHLINK_WEB_ return ( - Client: {normalizedClientVersion} - Server: {serverVersion} + Client: {normalizedClientVersion} - Server: {serverVersion} ); }; From 2a0def262dca5149c1538118f3e3673a5e28ab02 Mon Sep 17 00:00:00 2001 From: MartinH0 Date: Thu, 9 Jul 2020 14:53:15 +0200 Subject: [PATCH 04/14] Update ShlinkVersions.js --- src/common/ShlinkVersions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/ShlinkVersions.js b/src/common/ShlinkVersions.js index b583b159..8e2cd007 100644 --- a/src/common/ShlinkVersions.js +++ b/src/common/ShlinkVersions.js @@ -20,7 +20,7 @@ const ShlinkVersions = ({ selectedServer, className, clientVersion = SHLINK_WEB_ return ( - Client: {normalizedClientVersion} - Server: {serverVersion} + Client: {normalizedClientVersion} - Server: {serverVersion} ); }; From b96f4b7a9025fba6c151028f8cba32058a00fbaa Mon Sep 17 00:00:00 2001 From: MartinH0 Date: Thu, 9 Jul 2020 15:04:14 +0200 Subject: [PATCH 05/14] Update ShlinkVersions.js Changed back ExternalLink against docs to normal closing Tag. --- src/common/ShlinkVersions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/ShlinkVersions.js b/src/common/ShlinkVersions.js index 8e2cd007..b583b159 100644 --- a/src/common/ShlinkVersions.js +++ b/src/common/ShlinkVersions.js @@ -20,7 +20,7 @@ const ShlinkVersions = ({ selectedServer, className, clientVersion = SHLINK_WEB_ return ( - Client: {normalizedClientVersion} - Server: {serverVersion} + Client: {normalizedClientVersion} - Server: {serverVersion} ); }; From 76b3d573c0eaa45080fd2b979243dcc14d4d5501 Mon Sep 17 00:00:00 2001 From: MartinH0 Date: Thu, 9 Jul 2020 15:15:01 +0200 Subject: [PATCH 06/14] Update ShlinkVersions.js --- src/common/ShlinkVersions.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/common/ShlinkVersions.js b/src/common/ShlinkVersions.js index b583b159..0dc28c9b 100644 --- a/src/common/ShlinkVersions.js +++ b/src/common/ShlinkVersions.js @@ -17,10 +17,12 @@ const propTypes = { const ShlinkVersions = ({ selectedServer, className, clientVersion = SHLINK_WEB_CLIENT_VERSION }) => { const { printableVersion: serverVersion } = selectedServer; const normalizedClientVersion = pipe(versionToSemVer(), versionToPrintable)(clientVersion); + const linkClientVersion = () => (
normalizedClientVersion
); + const linkServerVersion = () => (
serverVersion
); return ( - Client: {normalizedClientVersion} - Server: {serverVersion} + Client: {linkClientVersion} - Server: {linkServerVersion} ); }; From c4730ec92d6ee4527f4c3716bb568a8d414a3588 Mon Sep 17 00:00:00 2001 From: MartinH0 Date: Thu, 9 Jul 2020 15:18:48 +0200 Subject: [PATCH 07/14] Update ShlinkVersions.js --- src/common/ShlinkVersions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/ShlinkVersions.js b/src/common/ShlinkVersions.js index 0dc28c9b..e7712a4e 100644 --- a/src/common/ShlinkVersions.js +++ b/src/common/ShlinkVersions.js @@ -17,8 +17,8 @@ const propTypes = { const ShlinkVersions = ({ selectedServer, className, clientVersion = SHLINK_WEB_CLIENT_VERSION }) => { const { printableVersion: serverVersion } = selectedServer; const normalizedClientVersion = pipe(versionToSemVer(), versionToPrintable)(clientVersion); - const linkClientVersion = () => (
normalizedClientVersion
); - const linkServerVersion = () => (
serverVersion
); + const linkClientVersion = () => (
normalizedClientVersion
); + const linkServerVersion = () => (
serverVersion
); return ( From ea84ce9c41598d181c3d8f2ba5b4dcd48f89cffb Mon Sep 17 00:00:00 2001 From: MartinH0 Date: Thu, 9 Jul 2020 15:25:53 +0200 Subject: [PATCH 08/14] Update ShlinkVersions.js --- src/common/ShlinkVersions.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/ShlinkVersions.js b/src/common/ShlinkVersions.js index e7712a4e..52878fc4 100644 --- a/src/common/ShlinkVersions.js +++ b/src/common/ShlinkVersions.js @@ -17,12 +17,12 @@ const propTypes = { const ShlinkVersions = ({ selectedServer, className, clientVersion = SHLINK_WEB_CLIENT_VERSION }) => { const { printableVersion: serverVersion } = selectedServer; const normalizedClientVersion = pipe(versionToSemVer(), versionToPrintable)(clientVersion); - const linkClientVersion = () => (
normalizedClientVersion
); - const linkServerVersion = () => (
serverVersion
); + const linkClientVersion = () => (
normalizedClientVersion
); + const linkServerVersion = () => (
serverVersion
); return ( - Client: {linkClientVersion} - Server: {linkServerVersion} + Client: {linkClientVersion} - Server: {linkServerVersion} ); }; From 8c7616c3a70232e533a06a92ca32b94ac555ffad Mon Sep 17 00:00:00 2001 From: MartinH0 Date: Thu, 9 Jul 2020 15:33:58 +0200 Subject: [PATCH 09/14] Update ShlinkVersions.js --- src/common/ShlinkVersions.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/common/ShlinkVersions.js b/src/common/ShlinkVersions.js index 52878fc4..16520d2a 100644 --- a/src/common/ShlinkVersions.js +++ b/src/common/ShlinkVersions.js @@ -15,14 +15,12 @@ const propTypes = { }; const ShlinkVersions = ({ selectedServer, className, clientVersion = SHLINK_WEB_CLIENT_VERSION }) => { - const { printableVersion: serverVersion } = selectedServer; - const normalizedClientVersion = pipe(versionToSemVer(), versionToPrintable)(clientVersion); - const linkClientVersion = () => (
normalizedClientVersion
); - const linkServerVersion = () => (
serverVersion
); + const { printableVersion: serverVersion } = selectedServer; + const normalizedClientVersion = pipe(versionToSemVer(), versionToPrintable)(clientVersion); return ( - Client: {linkClientVersion} - Server: {linkServerVersion} + Client: {normalizedClientVersion} - Server: {serverVersion} ); }; From 90245016a0dda27c091caad1c761794127cc783c Mon Sep 17 00:00:00 2001 From: MartinH0 Date: Thu, 9 Jul 2020 15:47:09 +0200 Subject: [PATCH 10/14] Update ShlinkVersions.js Hope this works now, but tests obviously fails bc it does not expect a Link --- src/common/ShlinkVersions.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/ShlinkVersions.js b/src/common/ShlinkVersions.js index 16520d2a..b583b159 100644 --- a/src/common/ShlinkVersions.js +++ b/src/common/ShlinkVersions.js @@ -15,12 +15,12 @@ const propTypes = { }; const ShlinkVersions = ({ selectedServer, className, clientVersion = SHLINK_WEB_CLIENT_VERSION }) => { - const { printableVersion: serverVersion } = selectedServer; - const normalizedClientVersion = pipe(versionToSemVer(), versionToPrintable)(clientVersion); + const { printableVersion: serverVersion } = selectedServer; + const normalizedClientVersion = pipe(versionToSemVer(), versionToPrintable)(clientVersion); return ( - Client: {normalizedClientVersion} - Server: {serverVersion} + Client: {normalizedClientVersion} - Server: {serverVersion} ); }; From feeb2122598c15eeafde074f27776cb5dc95c94f Mon Sep 17 00:00:00 2001 From: MartinH0 Date: Thu, 9 Jul 2020 15:54:45 +0200 Subject: [PATCH 11/14] Update ShlinkVersions.js --- src/common/ShlinkVersions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/ShlinkVersions.js b/src/common/ShlinkVersions.js index b583b159..90cc0ba5 100644 --- a/src/common/ShlinkVersions.js +++ b/src/common/ShlinkVersions.js @@ -20,7 +20,7 @@ const ShlinkVersions = ({ selectedServer, className, clientVersion = SHLINK_WEB_ return ( - Client: {normalizedClientVersion} - Server: {serverVersion} + Client: {{normalizedClientVersion}} - Server: {{serverVersion}} ); }; From 474239c151c5fcf84819f22f9de799ff614ba994 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Thu, 9 Jul 2020 17:17:19 +0200 Subject: [PATCH 12/14] Moved version link to common component, and fixed coding styles --- src/common/ShlinkVersions.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/common/ShlinkVersions.js b/src/common/ShlinkVersions.js index 90cc0ba5..ae083806 100644 --- a/src/common/ShlinkVersions.js +++ b/src/common/ShlinkVersions.js @@ -2,11 +2,12 @@ import React from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import { pipe } from 'ramda'; +import { ExternalLink } from 'react-external-link'; import { serverType } from '../servers/prop-types'; import { versionToPrintable, versionToSemVer } from '../utils/helpers/version'; -import { ExternalLink } from 'react-external-link'; const SHLINK_WEB_CLIENT_VERSION = '%_VERSION_%'; +const normalizeVersion = pipe(versionToSemVer(), versionToPrintable); const propTypes = { selectedServer: serverType, @@ -14,13 +15,27 @@ const propTypes = { clientVersion: PropTypes.string, }; +const versionLinkPropTypes = { + project: PropTypes.oneOf([ 'shlink', 'shlink-web-client' ]).isRequired, + version: PropTypes.string.isRequired, +}; + +const VersionLink = ({ project, version }) => ( + + {version} + +); + +VersionLink.propTypes = versionLinkPropTypes; + const ShlinkVersions = ({ selectedServer, className, clientVersion = SHLINK_WEB_CLIENT_VERSION }) => { const { printableVersion: serverVersion } = selectedServer; - const normalizedClientVersion = pipe(versionToSemVer(), versionToPrintable)(clientVersion); + const normalizedClientVersion = normalizeVersion(clientVersion); return ( - Client: {{normalizedClientVersion}} - Server: {{serverVersion}} + Client: - + Server: ); }; From b1df1652bf7d74144f994db4e7ea6813f8098d1d Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Thu, 9 Jul 2020 17:34:23 +0200 Subject: [PATCH 13/14] Fixed ShlinkVersions test --- test/common/ShlinkVersions.test.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/test/common/ShlinkVersions.test.js b/test/common/ShlinkVersions.test.js index 685158b0..cb9fbc7f 100644 --- a/test/common/ShlinkVersions.test.js +++ b/test/common/ShlinkVersions.test.js @@ -13,14 +13,20 @@ describe('', () => { afterEach(() => wrapper && wrapper.unmount()); it.each([ - [ '1.2.3', 'foo', 'Client: v1.2.3 - Server: foo' ], - [ 'foo', '1.2.3', 'Client: latest - Server: 1.2.3' ], - [ 'latest', 'latest', 'Client: latest - Server: latest' ], - [ '5.5.0', '0.2.8', 'Client: v5.5.0 - Server: 0.2.8' ], - [ 'not-semver', 'something', 'Client: latest - Server: something' ], - ])('displays expected versions', (clientVersion, printableVersion, expected) => { + [ '1.2.3', 'foo', 'v1.2.3', 'foo' ], + [ 'foo', '1.2.3', 'latest', '1.2.3' ], + [ 'latest', 'latest', 'latest', 'latest' ], + [ '5.5.0', '0.2.8', 'v5.5.0', '0.2.8' ], + [ 'not-semver', 'something', 'latest', 'something' ], + ])('displays expected versions', (clientVersion, printableVersion, expectedClientVersion, expectedServerVersion) => { const wrapper = createWrapper({ clientVersion, selectedServer: { printableVersion } }); + const links = wrapper.find('VersionLink'); + const clientLink = links.at(0); + const serverLink = links.at(1); - expect(wrapper.text()).toEqual(expected); + expect(clientLink.prop("project")).toEqual('shlink-web-client'); + expect(clientLink.prop("version")).toEqual(expectedClientVersion); + expect(serverLink.prop("project")).toEqual('shlink'); + expect(serverLink.prop("version")).toEqual(expectedServerVersion); }); }); From e6efda5563dd9a17e70dce87de3ee9fafeefad4a Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Thu, 9 Jul 2020 17:36:26 +0200 Subject: [PATCH 14/14] Fixed wrong use of quotes --- test/common/ShlinkVersions.test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/common/ShlinkVersions.test.js b/test/common/ShlinkVersions.test.js index cb9fbc7f..020f50dd 100644 --- a/test/common/ShlinkVersions.test.js +++ b/test/common/ShlinkVersions.test.js @@ -24,9 +24,9 @@ describe('', () => { const clientLink = links.at(0); const serverLink = links.at(1); - expect(clientLink.prop("project")).toEqual('shlink-web-client'); - expect(clientLink.prop("version")).toEqual(expectedClientVersion); - expect(serverLink.prop("project")).toEqual('shlink'); - expect(serverLink.prop("version")).toEqual(expectedServerVersion); + expect(clientLink.prop('project')).toEqual('shlink-web-client'); + expect(clientLink.prop('version')).toEqual(expectedClientVersion); + expect(serverLink.prop('project')).toEqual('shlink'); + expect(serverLink.prop('version')).toEqual(expectedServerVersion); }); });