mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 17:40:23 +03:00
Added domain input to create short url form
This commit is contained in:
parent
08b710930d
commit
67a23bfe33
3 changed files with 22 additions and 8 deletions
|
@ -1,6 +1,6 @@
|
||||||
import { faAngleDoubleDown as downIcon, faAngleDoubleUp as upIcon } from '@fortawesome/free-solid-svg-icons';
|
import { faAngleDoubleDown as downIcon, faAngleDoubleUp as upIcon } from '@fortawesome/free-solid-svg-icons';
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
import { assoc, dissoc, isNil, pipe, replace, trim } from 'ramda';
|
import { assoc, dissoc, isEmpty, isNil, pipe, replace, trim } from 'ramda';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Collapse } from 'reactstrap';
|
import { Collapse } from 'reactstrap';
|
||||||
import * as PropTypes from 'prop-types';
|
import * as PropTypes from 'prop-types';
|
||||||
|
@ -23,6 +23,7 @@ const CreateShortUrl = (TagsSelector, CreateShortUrlResult) => class CreateShort
|
||||||
longUrl: '',
|
longUrl: '',
|
||||||
tags: [],
|
tags: [],
|
||||||
customSlug: undefined,
|
customSlug: undefined,
|
||||||
|
domain: undefined,
|
||||||
validSince: undefined,
|
validSince: undefined,
|
||||||
validUntil: undefined,
|
validUntil: undefined,
|
||||||
maxVisits: undefined,
|
maxVisits: undefined,
|
||||||
|
@ -89,15 +90,25 @@ const CreateShortUrl = (TagsSelector, CreateShortUrlResult) => class CreateShort
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<div className="col-sm-6">
|
<div className="col-sm-6">
|
||||||
{renderOptionalInput('customSlug', 'Custom slug')}
|
{renderOptionalInput('customSlug', 'Custom slug')}
|
||||||
{renderOptionalInput('maxVisits', 'Maximum number of visits allowed', 'number', { min: 1 })}
|
|
||||||
</div>
|
</div>
|
||||||
<div className="col-sm-6">
|
<div className="col-sm-6">
|
||||||
|
{renderOptionalInput('domain', 'Domain', 'text')}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-sm-4">
|
||||||
|
{renderOptionalInput('maxVisits', 'Maximum number of visits allowed', 'number', { min: 1 })}
|
||||||
|
</div>
|
||||||
|
<div className="col-sm-4">
|
||||||
{renderDateInput('validSince', 'Enabled since...', { maxDate: this.state.validUntil })}
|
{renderDateInput('validSince', 'Enabled since...', { maxDate: this.state.validUntil })}
|
||||||
|
</div>
|
||||||
|
<div className="col-sm-4">
|
||||||
{renderDateInput('validUntil', 'Enabled until...', { minDate: this.state.validSince })}
|
{renderDateInput('validUntil', 'Enabled until...', { minDate: this.state.validSince })}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="mb-3 text-right">
|
<div className="mb-4 text-right">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
className="mr-2"
|
className="mr-2"
|
||||||
checked={this.state.findIfExists}
|
checked={this.state.findIfExists}
|
||||||
|
@ -119,7 +130,10 @@ const CreateShortUrl = (TagsSelector, CreateShortUrlResult) => class CreateShort
|
||||||
|
|
||||||
{this.state.moreOptionsVisible ? 'Less' : 'More'} options
|
{this.state.moreOptionsVisible ? 'Less' : 'More'} options
|
||||||
</button>
|
</button>
|
||||||
<button className="btn btn-outline-primary float-right" disabled={shortUrlCreationResult.loading}>
|
<button
|
||||||
|
className="btn btn-outline-primary float-right"
|
||||||
|
disabled={shortUrlCreationResult.loading || isEmpty(this.state.longUrl)}
|
||||||
|
>
|
||||||
{shortUrlCreationResult.loading ? 'Creating...' : 'Create'}
|
{shortUrlCreationResult.loading ? 'Creating...' : 'Create'}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -20,7 +20,7 @@ const renderInfoModal = (isOpen, toggle) => (
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
When only the long URL is provided: The most recent match will be returned, or a new short URL will be created
|
When only the long URL is provided: The most recent match will be returned, or a new short URL will be created
|
||||||
if none is found
|
if none is found.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
When long URL and custom slug are provided: Same as in previous case, but it will try to match the short URL
|
When long URL and custom slug are provided: Same as in previous case, but it will try to match the short URL
|
||||||
|
@ -33,9 +33,6 @@ const renderInfoModal = (isOpen, toggle) => (
|
||||||
all provided data. If any of them does not match, a new short URL will be created
|
all provided data. If any of them does not match, a new short URL will be created
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<blockquote className="use-existing-if-found-info-icon__modal-quote">
|
|
||||||
<b>Important:</b> This feature will be ignored while using a Shlink version older than v1.16.0.
|
|
||||||
</blockquote>
|
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
|
|
|
@ -32,6 +32,7 @@ describe('<CreateShortUrl />', () => {
|
||||||
const urlInput = wrapper.find('.form-control-lg');
|
const urlInput = wrapper.find('.form-control-lg');
|
||||||
const tagsInput = wrapper.find(TagsSelector);
|
const tagsInput = wrapper.find(TagsSelector);
|
||||||
const customSlugInput = wrapper.find('#customSlug');
|
const customSlugInput = wrapper.find('#customSlug');
|
||||||
|
const domain = wrapper.find('#domain');
|
||||||
const maxVisitsInput = wrapper.find('#maxVisits');
|
const maxVisitsInput = wrapper.find('#maxVisits');
|
||||||
const dateInputs = wrapper.find(DateInput);
|
const dateInputs = wrapper.find(DateInput);
|
||||||
const validSinceInput = dateInputs.at(0);
|
const validSinceInput = dateInputs.at(0);
|
||||||
|
@ -40,6 +41,7 @@ describe('<CreateShortUrl />', () => {
|
||||||
urlInput.simulate('change', { target: { value: 'https://long-domain.com/foo/bar' } });
|
urlInput.simulate('change', { target: { value: 'https://long-domain.com/foo/bar' } });
|
||||||
tagsInput.simulate('change', [ 'tag_foo', 'tag_bar' ]);
|
tagsInput.simulate('change', [ 'tag_foo', 'tag_bar' ]);
|
||||||
customSlugInput.simulate('change', { target: { value: 'my-slug' } });
|
customSlugInput.simulate('change', { target: { value: 'my-slug' } });
|
||||||
|
domain.simulate('change', { target: { value: 'example.com' } });
|
||||||
maxVisitsInput.simulate('change', { target: { value: '20' } });
|
maxVisitsInput.simulate('change', { target: { value: '20' } });
|
||||||
validSinceInput.simulate('change', validSince);
|
validSinceInput.simulate('change', validSince);
|
||||||
validUntilInput.simulate('change', validUntil);
|
validUntilInput.simulate('change', validUntil);
|
||||||
|
@ -53,6 +55,7 @@ describe('<CreateShortUrl />', () => {
|
||||||
longUrl: 'https://long-domain.com/foo/bar',
|
longUrl: 'https://long-domain.com/foo/bar',
|
||||||
tags: [ 'tag_foo', 'tag_bar' ],
|
tags: [ 'tag_foo', 'tag_bar' ],
|
||||||
customSlug: 'my-slug',
|
customSlug: 'my-slug',
|
||||||
|
domain: 'example.com',
|
||||||
validSince: validSince.format(),
|
validSince: validSince.format(),
|
||||||
validUntil: validUntil.format(),
|
validUntil: validUntil.format(),
|
||||||
maxVisits: '20',
|
maxVisits: '20',
|
||||||
|
|
Loading…
Reference in a new issue