mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 17:40:23 +03:00
Removed rest of version checks for versions older than 2.4
This commit is contained in:
parent
f7cc90bb77
commit
8b5b035568
5 changed files with 10 additions and 39 deletions
|
@ -55,14 +55,7 @@ export const Overview = (
|
||||||
<div className="col-md-6 col-xl-3">
|
<div className="col-md-6 col-xl-3">
|
||||||
<Card className="overview__card mb-3" body>
|
<Card className="overview__card mb-3" body>
|
||||||
<CardTitle tag="h5" className="overview__card-title">Visits</CardTitle>
|
<CardTitle tag="h5" className="overview__card-title">Visits</CardTitle>
|
||||||
<CardText tag="h2">
|
<CardText tag="h2">{loadingVisits ? 'Loading...' : prettify(visitsCount)}</CardText>
|
||||||
<ForServerVersion minVersion="2.2.0">
|
|
||||||
{loadingVisits ? 'Loading...' : prettify(visitsCount)}
|
|
||||||
</ForServerVersion>
|
|
||||||
<ForServerVersion maxVersion="2.1.*">
|
|
||||||
<small className="text-muted"><i>Shlink 2.2 is needed</i></small>
|
|
||||||
</ForServerVersion>
|
|
||||||
</CardText>
|
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
<div className="col-md-6 col-xl-3">
|
<div className="col-md-6 col-xl-3">
|
||||||
|
|
|
@ -5,7 +5,6 @@ import { FC, useEffect, useRef } from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { prettify } from '../utils/helpers/numbers';
|
import { prettify } from '../utils/helpers/numbers';
|
||||||
import { useToggle } from '../utils/helpers/hooks';
|
import { useToggle } from '../utils/helpers/hooks';
|
||||||
import { Versions } from '../utils/helpers/version';
|
|
||||||
import ColorGenerator from '../utils/services/ColorGenerator';
|
import ColorGenerator from '../utils/services/ColorGenerator';
|
||||||
import { isServerWithId, SelectedServer } from '../servers/data';
|
import { isServerWithId, SelectedServer } from '../servers/data';
|
||||||
import TagBullet from './helpers/TagBullet';
|
import TagBullet from './helpers/TagBullet';
|
||||||
|
@ -25,16 +24,13 @@ const isTruncated = (el: HTMLElement | undefined): boolean => !!el && el.scrollW
|
||||||
const TagCard = (
|
const TagCard = (
|
||||||
DeleteTagConfirmModal: FC<TagModalProps>,
|
DeleteTagConfirmModal: FC<TagModalProps>,
|
||||||
EditTagModal: FC<TagModalProps>,
|
EditTagModal: FC<TagModalProps>,
|
||||||
ForServerVersion: FC<Versions>,
|
|
||||||
colorGenerator: ColorGenerator,
|
colorGenerator: ColorGenerator,
|
||||||
) => ({ tag, tagStats, selectedServer, displayed, toggle }: TagCardProps) => {
|
) => ({ tag, tagStats, selectedServer, displayed, toggle }: TagCardProps) => {
|
||||||
const [ isDeleteModalOpen, toggleDelete ] = useToggle();
|
const [ isDeleteModalOpen, toggleDelete ] = useToggle();
|
||||||
const [ isEditModalOpen, toggleEdit ] = useToggle();
|
const [ isEditModalOpen, toggleEdit ] = useToggle();
|
||||||
const [ hasTitle,, displayTitle ] = useToggle();
|
const [ hasTitle,, displayTitle ] = useToggle();
|
||||||
const titleRef = useRef<HTMLElement>();
|
const titleRef = useRef<HTMLElement>();
|
||||||
|
|
||||||
const serverId = isServerWithId(selectedServer) ? selectedServer.id : '';
|
const serverId = isServerWithId(selectedServer) ? selectedServer.id : '';
|
||||||
const shortUrlsLink = `/server/${serverId}/list-short-urls/1?tag=${encodeURIComponent(tag)}`;
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isTruncated(titleRef.current)) {
|
if (isTruncated(titleRef.current)) {
|
||||||
|
@ -59,12 +55,7 @@ const TagCard = (
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<TagBullet tag={tag} colorGenerator={colorGenerator} />
|
<TagBullet tag={tag} colorGenerator={colorGenerator} />
|
||||||
<ForServerVersion minVersion="2.2.0">
|
<span className="tag-card__tag-name" onClick={toggle}>{tag}</span>
|
||||||
<span className="tag-card__tag-name" onClick={toggle}>{tag}</span>
|
|
||||||
</ForServerVersion>
|
|
||||||
<ForServerVersion maxVersion="2.1.*">
|
|
||||||
<Link to={shortUrlsLink}>{tag}</Link>
|
|
||||||
</ForServerVersion>
|
|
||||||
</h5>
|
</h5>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
|
|
||||||
|
@ -72,7 +63,7 @@ const TagCard = (
|
||||||
<Collapse isOpen={displayed}>
|
<Collapse isOpen={displayed}>
|
||||||
<CardBody className="tag-card__body">
|
<CardBody className="tag-card__body">
|
||||||
<Link
|
<Link
|
||||||
to={shortUrlsLink}
|
to={`/server/${serverId}/list-short-urls/1?tag=${encodeURIComponent(tag)}`}
|
||||||
className="btn btn-outline-secondary btn-block d-flex justify-content-between align-items-center mb-1"
|
className="btn btn-outline-secondary btn-block d-flex justify-content-between align-items-center mb-1"
|
||||||
>
|
>
|
||||||
<span className="text-ellipsis"><FontAwesomeIcon icon={faLink} className="mr-2" />Short URLs</span>
|
<span className="text-ellipsis"><FontAwesomeIcon icon={faLink} className="mr-2" />Short URLs</span>
|
||||||
|
|
|
@ -18,14 +18,7 @@ const provideServices = (bottle: Bottle, connect: ConnectDecorator) => {
|
||||||
bottle.serviceFactory('TagsSelector', TagsSelector, 'ColorGenerator');
|
bottle.serviceFactory('TagsSelector', TagsSelector, 'ColorGenerator');
|
||||||
bottle.decorator('TagsSelector', connect([ 'tagsList', 'settings' ], [ 'listTags' ]));
|
bottle.decorator('TagsSelector', connect([ 'tagsList', 'settings' ], [ 'listTags' ]));
|
||||||
|
|
||||||
bottle.serviceFactory(
|
bottle.serviceFactory('TagCard', TagCard, 'DeleteTagConfirmModal', 'EditTagModal', 'ColorGenerator');
|
||||||
'TagCard',
|
|
||||||
TagCard,
|
|
||||||
'DeleteTagConfirmModal',
|
|
||||||
'EditTagModal',
|
|
||||||
'ForServerVersion',
|
|
||||||
'ColorGenerator',
|
|
||||||
);
|
|
||||||
|
|
||||||
bottle.serviceFactory('DeleteTagConfirmModal', () => DeleteTagConfirmModal);
|
bottle.serviceFactory('DeleteTagConfirmModal', () => DeleteTagConfirmModal);
|
||||||
bottle.decorator('DeleteTagConfirmModal', connect([ 'tagDelete' ], [ 'deleteTag', 'tagDeleted' ]));
|
bottle.decorator('DeleteTagConfirmModal', connect([ 'tagDelete' ], [ 'deleteTag', 'tagDeleted' ]));
|
||||||
|
|
|
@ -64,13 +64,6 @@ describe('<Overview />', () => {
|
||||||
expect(cards.at(3).html()).toContain(prettify(3));
|
expect(cards.at(3).html()).toContain(prettify(3));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('displays warning in first card for old shlink versions', () => {
|
|
||||||
const wrapper = createWrapper();
|
|
||||||
const firstCard = wrapper.find(CardText).first();
|
|
||||||
|
|
||||||
expect(firstCard.html()).toContain('Shlink 2.2 is needed');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('nests complex components', () => {
|
it('nests complex components', () => {
|
||||||
const wrapper = createWrapper();
|
const wrapper = createWrapper();
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ describe('<TagCard />', () => {
|
||||||
};
|
};
|
||||||
const DeleteTagConfirmModal = jest.fn();
|
const DeleteTagConfirmModal = jest.fn();
|
||||||
const EditTagModal = jest.fn();
|
const EditTagModal = jest.fn();
|
||||||
const TagCard = createTagCard(DeleteTagConfirmModal, EditTagModal, () => null, Mock.all<ColorGenerator>());
|
const TagCard = createTagCard(DeleteTagConfirmModal, EditTagModal, Mock.all<ColorGenerator>());
|
||||||
const createWrapper = (tag = 'ssr') => {
|
const createWrapper = (tag = 'ssr') => {
|
||||||
wrapper = shallow(
|
wrapper = shallow(
|
||||||
<TagCard
|
<TagCard
|
||||||
|
@ -65,9 +65,10 @@ describe('<TagCard />', () => {
|
||||||
it('shows expected tag stats', () => {
|
it('shows expected tag stats', () => {
|
||||||
const links = wrapper.find(Link);
|
const links = wrapper.find(Link);
|
||||||
|
|
||||||
expect(links.at(1).prop('to')).toEqual('/server/1/list-short-urls/1?tag=ssr');
|
expect(links).toHaveLength(2);
|
||||||
expect(links.at(1).text()).toContain('48');
|
expect(links.at(0).prop('to')).toEqual('/server/1/list-short-urls/1?tag=ssr');
|
||||||
expect(links.at(2).prop('to')).toEqual('/server/1/tag/ssr/visits');
|
expect(links.at(0).text()).toContain('48');
|
||||||
expect(links.at(2).text()).toContain('23,257');
|
expect(links.at(1).prop('to')).toEqual('/server/1/tag/ssr/visits');
|
||||||
|
expect(links.at(1).text()).toContain('23,257');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue