2019-03-17 20:35:47 +03:00
|
|
|
import React from 'react';
|
2019-03-17 19:48:05 +03:00
|
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
|
|
import { faInfoCircle as infoIcon } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
import { Modal, ModalBody, ModalHeader } from 'reactstrap';
|
|
|
|
import './UseExistingIfFoundInfoIcon.scss';
|
2019-03-17 20:35:47 +03:00
|
|
|
import { useToggle } from '../utils/utils';
|
2019-03-17 19:48:05 +03:00
|
|
|
|
|
|
|
const renderInfoModal = (isOpen, toggle) => (
|
|
|
|
<Modal isOpen={isOpen} toggle={toggle} centered size="lg">
|
|
|
|
<ModalHeader toggle={toggle}>Info</ModalHeader>
|
|
|
|
<ModalBody>
|
|
|
|
<p>
|
|
|
|
When the
|
|
|
|
<b><i>"Use existing URL if found"</i></b>
|
|
|
|
checkbox is checked, the server will return an existing short URL if it matches provided params.
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
These are the checks performed by Shlink in order to determine if an existing short URL should be returned:
|
|
|
|
</p>
|
|
|
|
<ul>
|
|
|
|
<li>
|
|
|
|
When only the long URL is provided: The most recent match will be returned, or a new short URL will be created
|
2019-10-05 10:02:02 +03:00
|
|
|
if none is found.
|
2019-03-17 19:48:05 +03:00
|
|
|
</li>
|
|
|
|
<li>
|
2019-10-05 11:20:33 +03:00
|
|
|
When long URL and custom slug and/or domain are provided: Same as in previous case, but it will try to match
|
|
|
|
the short URL using both the long URL and the slug, the long URL and the domain, or the three of them.
|
2019-03-17 19:48:05 +03:00
|
|
|
<br />
|
|
|
|
If the slug is being used by another long URL, an error will be returned.
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
When other params are provided: Same as in previous cases, but it will try to match existing short URLs with
|
|
|
|
all provided data. If any of them does not match, a new short URL will be created
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</ModalBody>
|
|
|
|
</Modal>
|
|
|
|
);
|
|
|
|
|
|
|
|
const UseExistingIfFoundInfoIcon = () => {
|
2019-03-17 20:35:47 +03:00
|
|
|
const [ isModalOpen, toggleModal ] = useToggle(false);
|
2019-03-17 19:48:05 +03:00
|
|
|
|
|
|
|
return (
|
|
|
|
<React.Fragment>
|
|
|
|
<span title="What does this mean?">
|
|
|
|
<FontAwesomeIcon icon={infoIcon} style={{ cursor: 'pointer' }} onClick={toggleModal} />
|
|
|
|
</span>
|
|
|
|
{renderInfoModal(isModalOpen, toggleModal)}
|
|
|
|
</React.Fragment>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default UseExistingIfFoundInfoIcon;
|