Merge pull request #341 from acelaya-forks/feature/validate-flag

Feature/validate flag
This commit is contained in:
Alejandro Celaya 2020-12-06 13:21:08 +01:00 committed by GitHub
commit 920effb4c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 30 additions and 13 deletions

View file

@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
## [Unreleased]
### Added
* [#309](https://github.com/shlinkio/shlink-web-client/issues/309) Added new domain selector component in create URL form which allows selecting from previously used domains or set a new one.
* [#315](https://github.com/shlinkio/shlink-web-client/issues/315) Now you can tell if you want to validate the long URL when using Shlink >=2.4.
### Changed
* *Nothing*

View file

@ -8,9 +8,9 @@ import {
Input,
InputGroup,
InputGroupAddon,
InputProps,
UncontrolledTooltip,
} from 'reactstrap';
import { InputProps } from 'reactstrap/lib/Input';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faUndo } from '@fortawesome/free-solid-svg-icons';
import { isEmpty, pipe } from 'ramda';

View file

@ -38,6 +38,7 @@ const initialState: ShortUrlData = {
validUntil: undefined,
maxVisits: undefined,
findIfExists: false,
validateUrl: true,
};
type NonDateFields = 'longUrl' | 'customSlug' | 'shortCodeLength' | 'domain' | 'maxVisits';
@ -154,7 +155,19 @@ const CreateShortUrl = (
</div>
<ForServerVersion minVersion="1.16.0">
<div className="mb-4 text-right">
<div className="mb-4 row">
<div className="col-sm-6 text-center text-sm-left mb-2 mb-sm-0">
<ForServerVersion minVersion="2.4.0">
<Checkbox
inline
checked={shortUrlCreation.validateUrl}
onChange={(validateUrl) => setShortUrlCreation({ ...shortUrlCreation, validateUrl })}
>
Validate URL
</Checkbox>
</ForServerVersion>
</div>
<div className="col-sm-6 text-center text-sm-right">
<Checkbox
inline
className="mr-2"
@ -165,6 +178,7 @@ const CreateShortUrl = (
</Checkbox>
<UseExistingIfFoundInfoIcon />
</div>
</div>
</ForServerVersion>
</Collapse>

View file

@ -11,6 +11,7 @@ export interface ShortUrlData {
validUntil?: m.Moment | string;
maxVisits?: number;
findIfExists?: boolean;
validateUrl?: boolean;
}
export interface ShortUrl {

View file

@ -1,4 +1,4 @@
import { ChangeEvent, FC } from 'react';
import { ChangeEvent, FC, useRef } from 'react';
import classNames from 'classnames';
import { v4 as uuid } from 'uuid';
import { identity } from 'ramda';
@ -17,7 +17,7 @@ interface BooleanControlWithTypeProps extends BooleanControlProps {
const BooleanControl: FC<BooleanControlWithTypeProps> = (
{ checked = false, onChange = identity, className, children, type, inline = false },
) => {
const id = uuid();
const { current: id } = useRef(uuid());
const onChecked = (e: ChangeEvent<HTMLInputElement>) => onChange(e.target.checked, e);
const typeClasses = {
'custom-switch': type === 'switch',

View file

@ -52,6 +52,7 @@ describe('<CreateShortUrl />', () => {
maxVisits: '20',
findIfExists: false,
shortCodeLength: 15,
validateUrl: true,
});
});
});