mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 17:40:23 +03:00
Merge pull request #341 from acelaya-forks/feature/validate-flag
Feature/validate flag
This commit is contained in:
commit
920effb4c6
6 changed files with 30 additions and 13 deletions
|
@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
### Added
|
### 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.
|
* [#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
|
### Changed
|
||||||
* *Nothing*
|
* *Nothing*
|
||||||
|
|
|
@ -8,9 +8,9 @@ import {
|
||||||
Input,
|
Input,
|
||||||
InputGroup,
|
InputGroup,
|
||||||
InputGroupAddon,
|
InputGroupAddon,
|
||||||
InputProps,
|
|
||||||
UncontrolledTooltip,
|
UncontrolledTooltip,
|
||||||
} from 'reactstrap';
|
} from 'reactstrap';
|
||||||
|
import { InputProps } from 'reactstrap/lib/Input';
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
import { faUndo } from '@fortawesome/free-solid-svg-icons';
|
import { faUndo } from '@fortawesome/free-solid-svg-icons';
|
||||||
import { isEmpty, pipe } from 'ramda';
|
import { isEmpty, pipe } from 'ramda';
|
||||||
|
|
|
@ -38,6 +38,7 @@ const initialState: ShortUrlData = {
|
||||||
validUntil: undefined,
|
validUntil: undefined,
|
||||||
maxVisits: undefined,
|
maxVisits: undefined,
|
||||||
findIfExists: false,
|
findIfExists: false,
|
||||||
|
validateUrl: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
type NonDateFields = 'longUrl' | 'customSlug' | 'shortCodeLength' | 'domain' | 'maxVisits';
|
type NonDateFields = 'longUrl' | 'customSlug' | 'shortCodeLength' | 'domain' | 'maxVisits';
|
||||||
|
@ -154,16 +155,29 @@ const CreateShortUrl = (
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ForServerVersion minVersion="1.16.0">
|
<ForServerVersion minVersion="1.16.0">
|
||||||
<div className="mb-4 text-right">
|
<div className="mb-4 row">
|
||||||
<Checkbox
|
<div className="col-sm-6 text-center text-sm-left mb-2 mb-sm-0">
|
||||||
inline
|
<ForServerVersion minVersion="2.4.0">
|
||||||
className="mr-2"
|
<Checkbox
|
||||||
checked={shortUrlCreation.findIfExists}
|
inline
|
||||||
onChange={(findIfExists) => setShortUrlCreation({ ...shortUrlCreation, findIfExists })}
|
checked={shortUrlCreation.validateUrl}
|
||||||
>
|
onChange={(validateUrl) => setShortUrlCreation({ ...shortUrlCreation, validateUrl })}
|
||||||
Use existing URL if found
|
>
|
||||||
</Checkbox>
|
Validate URL
|
||||||
<UseExistingIfFoundInfoIcon />
|
</Checkbox>
|
||||||
|
</ForServerVersion>
|
||||||
|
</div>
|
||||||
|
<div className="col-sm-6 text-center text-sm-right">
|
||||||
|
<Checkbox
|
||||||
|
inline
|
||||||
|
className="mr-2"
|
||||||
|
checked={shortUrlCreation.findIfExists}
|
||||||
|
onChange={(findIfExists) => setShortUrlCreation({ ...shortUrlCreation, findIfExists })}
|
||||||
|
>
|
||||||
|
Use existing URL if found
|
||||||
|
</Checkbox>
|
||||||
|
<UseExistingIfFoundInfoIcon />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ForServerVersion>
|
</ForServerVersion>
|
||||||
</Collapse>
|
</Collapse>
|
||||||
|
|
|
@ -11,6 +11,7 @@ export interface ShortUrlData {
|
||||||
validUntil?: m.Moment | string;
|
validUntil?: m.Moment | string;
|
||||||
maxVisits?: number;
|
maxVisits?: number;
|
||||||
findIfExists?: boolean;
|
findIfExists?: boolean;
|
||||||
|
validateUrl?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ShortUrl {
|
export interface ShortUrl {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { ChangeEvent, FC } from 'react';
|
import { ChangeEvent, FC, useRef } from 'react';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { v4 as uuid } from 'uuid';
|
import { v4 as uuid } from 'uuid';
|
||||||
import { identity } from 'ramda';
|
import { identity } from 'ramda';
|
||||||
|
@ -17,7 +17,7 @@ interface BooleanControlWithTypeProps extends BooleanControlProps {
|
||||||
const BooleanControl: FC<BooleanControlWithTypeProps> = (
|
const BooleanControl: FC<BooleanControlWithTypeProps> = (
|
||||||
{ checked = false, onChange = identity, className, children, type, inline = false },
|
{ 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 onChecked = (e: ChangeEvent<HTMLInputElement>) => onChange(e.target.checked, e);
|
||||||
const typeClasses = {
|
const typeClasses = {
|
||||||
'custom-switch': type === 'switch',
|
'custom-switch': type === 'switch',
|
||||||
|
|
|
@ -52,6 +52,7 @@ describe('<CreateShortUrl />', () => {
|
||||||
maxVisits: '20',
|
maxVisits: '20',
|
||||||
findIfExists: false,
|
findIfExists: false,
|
||||||
shortCodeLength: 15,
|
shortCodeLength: 15,
|
||||||
|
validateUrl: true,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue