2022-04-24 14:05:33 +03:00
|
|
|
import { faChartPie as pieChartIcon, faEdit as editIcon } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
2023-02-18 13:11:01 +03:00
|
|
|
import type { FC } from 'react';
|
|
|
|
import { Link } from 'react-router-dom';
|
|
|
|
import { DropdownItem } from 'reactstrap';
|
2023-07-24 21:14:59 +03:00
|
|
|
import { useToggle } from '../../../src/utils/helpers/hooks';
|
|
|
|
import { RowDropdownBtn } from '../../../src/utils/RowDropdownBtn';
|
2023-07-16 23:54:49 +03:00
|
|
|
import { useFeature } from '../../utils/features';
|
2023-07-24 19:03:59 +03:00
|
|
|
import { useRoutesPrefix } from '../../utils/routesPrefix';
|
2022-04-30 10:05:12 +03:00
|
|
|
import { DEFAULT_DOMAIN } from '../../visits/reducers/domainVisits';
|
2023-02-18 13:11:01 +03:00
|
|
|
import type { Domain } from '../data';
|
|
|
|
import type { EditDomainRedirects } from '../reducers/domainRedirects';
|
|
|
|
import { EditDomainRedirectsModal } from './EditDomainRedirectsModal';
|
2022-04-24 14:05:33 +03:00
|
|
|
|
|
|
|
interface DomainDropdownProps {
|
|
|
|
domain: Domain;
|
2022-11-04 19:10:02 +03:00
|
|
|
editDomainRedirects: (redirects: EditDomainRedirects) => Promise<void>;
|
2022-04-24 14:05:33 +03:00
|
|
|
}
|
|
|
|
|
2023-07-24 19:03:59 +03:00
|
|
|
export const DomainDropdown: FC<DomainDropdownProps> = ({ domain, editDomainRedirects }) => {
|
2022-04-24 14:05:33 +03:00
|
|
|
const [isModalOpen, toggleModal] = useToggle();
|
2023-07-16 23:54:49 +03:00
|
|
|
const withVisits = useFeature('domainVisits');
|
2023-07-24 19:03:59 +03:00
|
|
|
const routesPrefix = useRoutesPrefix();
|
2022-04-24 14:05:33 +03:00
|
|
|
|
|
|
|
return (
|
2023-05-27 11:36:52 +03:00
|
|
|
<RowDropdownBtn>
|
2022-04-24 14:05:33 +03:00
|
|
|
{withVisits && (
|
2022-04-24 19:36:25 +03:00
|
|
|
<DropdownItem
|
|
|
|
tag={Link}
|
2023-07-24 19:03:59 +03:00
|
|
|
to={`${routesPrefix}/domain/${domain.domain}${domain.isDefault ? `_${DEFAULT_DOMAIN}` : ''}/visits`}
|
2022-04-24 19:36:25 +03:00
|
|
|
>
|
2022-04-24 14:05:33 +03:00
|
|
|
<FontAwesomeIcon icon={pieChartIcon} fixedWidth /> Visit stats
|
|
|
|
</DropdownItem>
|
|
|
|
)}
|
2023-07-26 21:04:50 +03:00
|
|
|
<DropdownItem onClick={toggleModal}>
|
2022-04-24 19:36:25 +03:00
|
|
|
<FontAwesomeIcon fixedWidth icon={editIcon} /> Edit redirects
|
|
|
|
</DropdownItem>
|
2022-04-24 14:05:33 +03:00
|
|
|
|
|
|
|
<EditDomainRedirectsModal
|
|
|
|
domain={domain}
|
|
|
|
isOpen={isModalOpen}
|
|
|
|
toggle={toggleModal}
|
|
|
|
editDomainRedirects={editDomainRedirects}
|
|
|
|
/>
|
2023-05-27 11:36:52 +03:00
|
|
|
</RowDropdownBtn>
|
2022-04-24 14:05:33 +03:00
|
|
|
);
|
|
|
|
};
|