diff --git a/CHANGELOG.md b/CHANGELOG.md
index c29c2cf7..bf6ebc8a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
* [#213](https://github.com/shlinkio/shlink-web-client/issues/213) The versions of both shlink-web-client and currently consumed Shlink server are now displayed in the footer.
* [#221](https://github.com/shlinkio/shlink-web-client/issues/221) Improved how servers are handled, displaying meaningful errors when a not-found or a not-reachable server is tried to be loaded.
* [#226](https://github.com/shlinkio/shlink-web-client/issues/226) Created servers can now be edited.
+* [#234](https://github.com/shlinkio/shlink-web-client/issues/234) Allowed short code length to be edited on any new short RUL when suing Shlink 2.1 or higher.
#### Changed
diff --git a/package-lock.json b/package-lock.json
index 489cb65e..45ce16c2 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -13894,9 +13894,9 @@
}
},
"react": {
- "version": "16.10.2",
- "resolved": "https://registry.npmjs.org/react/-/react-16.10.2.tgz",
- "integrity": "sha512-MFVIq0DpIhrHFyqLU0S3+4dIcBhhOvBE8bJ/5kHPVOVaGdo0KuiQzpcjCPsf585WvhypqtrMILyoE2th6dT+Lw==",
+ "version": "16.13.1",
+ "resolved": "https://registry.npmjs.org/react/-/react-16.13.1.tgz",
+ "integrity": "sha512-YMZQQq32xHLX0bz5Mnibv1/LHb3Sqzngu7xstSM+vrkE5Kzr9xE0yMByK5kMoTK30YVJE61WfbxIFFvfeDKT1w==",
"requires": {
"loose-envify": "^1.1.0",
"object-assign": "^4.1.1",
@@ -14106,14 +14106,14 @@
}
},
"react-dom": {
- "version": "16.10.2",
- "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-16.10.2.tgz",
- "integrity": "sha512-kWGDcH3ItJK4+6Pl9DZB16BXYAZyrYQItU4OMy0jAkv5aNqc+mAKb4TpFtAteI6TJZu+9ZlNhaeNQSVQDHJzkw==",
+ "version": "16.13.1",
+ "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-16.13.1.tgz",
+ "integrity": "sha512-81PIMmVLnCNLO/fFOQxdQkvEq/+Hfpv24XNJfpyZhTRfO0QcmQIF/PgCa1zCOj2w1hrn12MFLyaJ/G0+Mxtfag==",
"requires": {
"loose-envify": "^1.1.0",
"object-assign": "^4.1.1",
"prop-types": "^15.6.2",
- "scheduler": "^0.16.2"
+ "scheduler": "^0.19.1"
}
},
"react-error-overlay": {
@@ -15279,9 +15279,9 @@
"dev": true
},
"scheduler": {
- "version": "0.16.2",
- "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.16.2.tgz",
- "integrity": "sha512-BqYVWqwz6s1wZMhjFvLfVR5WXP7ZY32M/wYPo04CcuPM7XZEbV2TBNW7Z0UkguPTl0dWMA59VbNXxK6q+pHItg==",
+ "version": "0.19.1",
+ "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.19.1.tgz",
+ "integrity": "sha512-n/zwRWRYSUj0/3g/otKDRPMh6qv2SYMWNq85IEa8iZyAv8od9zDYpGSnpBEjNgcMNq6Scbu5KfIPxNF72R/2EA==",
"requires": {
"loose-envify": "^1.1.0",
"object-assign": "^4.1.1"
diff --git a/package.json b/package.json
index ce2b7b2f..9041a0eb 100644
--- a/package.json
+++ b/package.json
@@ -43,13 +43,13 @@
"prop-types": "^15.7.2",
"qs": "^6.9.0",
"ramda": "^0.26.1",
- "react": "^16.10.2",
+ "react": "^16.13.1",
"react-autosuggest": "^9.4.3",
"react-chartjs-2": "^2.8.0",
"react-color": "^2.17.3",
"react-copy-to-clipboard": "^5.0.1",
"react-datepicker": "~1.5.0",
- "react-dom": "^16.10.2",
+ "react-dom": "^16.13.1",
"react-external-link": "^1.0.0",
"react-leaflet": "^2.4.0",
"react-moment": "^0.9.5",
diff --git a/src/servers/helpers/ForServerVersion.js b/src/servers/helpers/ForServerVersion.js
index 0c51b22a..0b3c6fba 100644
--- a/src/servers/helpers/ForServerVersion.js
+++ b/src/servers/helpers/ForServerVersion.js
@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { serverType } from '../prop-types';
-import { compareVersions } from '../../utils/helpers/version';
+import { versionMatch } from '../../utils/helpers/version';
const propTypes = {
minVersion: PropTypes.string,
@@ -16,10 +16,9 @@ const ForServerVersion = ({ minVersion, maxVersion, selectedServer, children })
}
const { version } = selectedServer;
- const matchesMinVersion = !minVersion || compareVersions(version, '>=', minVersion);
- const matchesMaxVersion = !maxVersion || compareVersions(version, '<=', maxVersion);
+ const matchesVersion = versionMatch(version, { maxVersion, minVersion });
- if (!matchesMinVersion || !matchesMaxVersion) {
+ if (!matchesVersion) {
return null;
}
diff --git a/src/short-urls/CreateShortUrl.js b/src/short-urls/CreateShortUrl.js
index e1719fe3..32544d9e 100644
--- a/src/short-urls/CreateShortUrl.js
+++ b/src/short-urls/CreateShortUrl.js
@@ -1,55 +1,52 @@
import { faAngleDoubleDown as downIcon, faAngleDoubleUp as upIcon } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
-import { assoc, dissoc, isEmpty, isNil, pipe, replace, trim } from 'ramda';
-import React from 'react';
+import { isEmpty, isNil, pipe, replace, trim } from 'ramda';
+import React, { useState } from 'react';
import { Collapse, FormGroup, Input } from 'reactstrap';
import * as PropTypes from 'prop-types';
import DateInput from '../utils/DateInput';
import Checkbox from '../utils/Checkbox';
import { serverType } from '../servers/prop-types';
-import { compareVersions } from '../utils/helpers/version';
+import { versionMatch } from '../utils/helpers/version';
+import { hasValue } from '../utils/utils';
+import { useToggle } from '../utils/helpers/hooks';
import { createShortUrlResultType } from './reducers/shortUrlCreation';
import UseExistingIfFoundInfoIcon from './UseExistingIfFoundInfoIcon';
const normalizeTag = pipe(trim, replace(/ /g, '-'));
const formatDate = (date) => isNil(date) ? date : date.format();
-const CreateShortUrl = (
- TagsSelector,
- CreateShortUrlResult,
- ForServerVersion
-) => class CreateShortUrl extends React.Component {
- static propTypes = {
- createShortUrl: PropTypes.func,
- shortUrlCreationResult: createShortUrlResultType,
- resetCreateShortUrl: PropTypes.func,
- selectedServer: serverType,
- };
+const propTypes = {
+ createShortUrl: PropTypes.func,
+ shortUrlCreationResult: createShortUrlResultType,
+ resetCreateShortUrl: PropTypes.func,
+ selectedServer: serverType,
+};
- state = {
- longUrl: '',
- tags: [],
- customSlug: undefined,
- domain: undefined,
- validSince: undefined,
- validUntil: undefined,
- maxVisits: undefined,
- findIfExists: false,
- moreOptionsVisible: false,
- };
+const CreateShortUrl = (TagsSelector, CreateShortUrlResult, ForServerVersion) => {
+ const CreateShortUrlComp = ({ createShortUrl, shortUrlCreationResult, resetCreateShortUrl, selectedServer }) => {
+ const [ shortUrlCreation, setShortUrlCreation ] = useState({
+ longUrl: '',
+ tags: [],
+ customSlug: undefined,
+ shortCodeLength: undefined,
+ domain: undefined,
+ validSince: undefined,
+ validUntil: undefined,
+ maxVisits: undefined,
+ findIfExists: false,
+ });
+ const [ moreOptionsVisible, toggleMoreOptionsVisible ] = useToggle(false);
- render() {
- const { createShortUrl, shortUrlCreationResult, resetCreateShortUrl } = this.props;
-
- const changeTags = (tags) => this.setState({ tags: tags.map(normalizeTag) });
+ const changeTags = (tags) => setShortUrlCreation({ ...shortUrlCreation, tags: tags.map(normalizeTag) });
const renderOptionalInput = (id, placeholder, type = 'text', props = {}) => (