mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 01:20:24 +03:00
Removed conditional orphan visits section
This commit is contained in:
parent
a949ec9e8e
commit
763ef207f1
5 changed files with 20 additions and 28 deletions
|
@ -5,12 +5,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|||
import classNames from 'classnames';
|
||||
import { withSelectedServer } from '../servers/helpers/withSelectedServer';
|
||||
import { useSwipeable, useToggle } from '../utils/helpers/hooks';
|
||||
import {
|
||||
supportsDomainRedirects,
|
||||
supportsDomainVisits,
|
||||
supportsNonOrphanVisits,
|
||||
supportsOrphanVisits,
|
||||
} from '../utils/helpers/features';
|
||||
import { supportsDomainRedirects, supportsDomainVisits, supportsNonOrphanVisits } from '../utils/helpers/features';
|
||||
import { isReachableServer } from '../servers/data';
|
||||
import NotFound from './NotFound';
|
||||
import { AsideMenuProps } from './AsideMenu';
|
||||
|
@ -51,7 +46,6 @@ const MenuLayout = (
|
|||
return <ServerError />;
|
||||
}
|
||||
|
||||
const addOrphanVisitsRoute = supportsOrphanVisits(selectedServer);
|
||||
const addNonOrphanVisitsRoute = supportsNonOrphanVisits(selectedServer);
|
||||
const addManageDomainsRoute = supportsDomainRedirects(selectedServer);
|
||||
const addDomainVisitsRoute = supportsDomainVisits(selectedServer);
|
||||
|
@ -76,7 +70,7 @@ const MenuLayout = (
|
|||
<Route path="/short-code/:shortCode/edit" element={<EditShortUrl />} />
|
||||
<Route path="/tag/:tag/visits/*" element={<TagVisits />} />
|
||||
{addDomainVisitsRoute && <Route path="/domain/:domain/visits/*" element={<DomainVisits />} />}
|
||||
{addOrphanVisitsRoute && <Route path="/orphan-visits/*" element={<OrphanVisits />} />}
|
||||
<Route path="/orphan-visits/*" element={<OrphanVisits />} />
|
||||
{addNonOrphanVisitsRoute && <Route path="/non-orphan-visits/*" element={<NonOrphanVisits />} />}
|
||||
<Route path="/manage-tags" element={<TagsList />} />
|
||||
{addManageDomainsRoute && <Route path="/manage-domains" element={<ManageDomains />} />}
|
||||
|
|
|
@ -10,7 +10,7 @@ import { CreateShortUrlProps } from '../short-urls/CreateShortUrl';
|
|||
import { VisitsOverview } from '../visits/reducers/visitsOverview';
|
||||
import { Topics } from '../mercure/helpers/Topics';
|
||||
import { ShlinkShortUrlsListParams } from '../api/types';
|
||||
import { supportsNonOrphanVisits, supportsOrphanVisits } from '../utils/helpers/features';
|
||||
import { supportsNonOrphanVisits } from '../utils/helpers/features';
|
||||
import { getServerId, SelectedServer } from './data';
|
||||
import { HighlightCard } from './helpers/HighlightCard';
|
||||
import { ForServerVersionProps } from './helpers/ForServerVersion';
|
||||
|
@ -42,7 +42,6 @@ export const Overview = (
|
|||
const { loading: loadingTags } = tagsList;
|
||||
const { loading: loadingVisits, visitsCount, orphanVisitsCount } = visitsOverview;
|
||||
const serverId = getServerId(selectedServer);
|
||||
const linkToOrphanVisits = supportsOrphanVisits(selectedServer);
|
||||
const linkToNonOrphanVisits = supportsNonOrphanVisits(selectedServer);
|
||||
const navigate = useNavigate();
|
||||
|
||||
|
@ -61,7 +60,7 @@ export const Overview = (
|
|||
</HighlightCard>
|
||||
</div>
|
||||
<div className="col-lg-6 col-xl-3 mb-3">
|
||||
<HighlightCard title="Orphan visits" link={linkToOrphanVisits && `/server/${serverId}/orphan-visits`}>
|
||||
<HighlightCard title="Orphan visits" link={`/server/${serverId}/orphan-visits`}>
|
||||
<ForServerVersion minVersion="2.6.0">
|
||||
{loadingVisits ? 'Loading...' : prettify(orphanVisitsCount ?? 0)}
|
||||
</ForServerVersion>
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
import { isReachableServer, SelectedServer } from '../../servers/data';
|
||||
import { versionMatch, Versions } from './version';
|
||||
import { SemVerPattern, versionMatch } from './version';
|
||||
|
||||
const serverMatchesVersions = (versions: Versions) => (selectedServer: SelectedServer): boolean =>
|
||||
isReachableServer(selectedServer) && versionMatch(selectedServer.version, versions);
|
||||
const serverMatchesMinVersion = (minVersion: SemVerPattern) => (selectedServer: SelectedServer): boolean =>
|
||||
isReachableServer(selectedServer) && versionMatch(selectedServer.version, { minVersion });
|
||||
|
||||
export const supportsShortUrlTitle = serverMatchesVersions({ minVersion: '2.6.0' });
|
||||
export const supportsOrphanVisits = supportsShortUrlTitle;
|
||||
export const supportsBotVisits = serverMatchesVersions({ minVersion: '2.7.0' });
|
||||
export const supportsShortUrlTitle = serverMatchesMinVersion('2.6.0');
|
||||
export const supportsBotVisits = serverMatchesMinVersion('2.7.0');
|
||||
export const supportsCrawlableVisits = supportsBotVisits;
|
||||
export const supportsQrErrorCorrection = serverMatchesVersions({ minVersion: '2.8.0' });
|
||||
export const supportsQrErrorCorrection = serverMatchesMinVersion('2.8.0');
|
||||
export const supportsDomainRedirects = supportsQrErrorCorrection;
|
||||
export const supportsForwardQuery = serverMatchesVersions({ minVersion: '2.9.0' });
|
||||
export const supportsDefaultDomainRedirectsEdition = serverMatchesVersions({ minVersion: '2.10.0' });
|
||||
export const supportsNonOrphanVisits = serverMatchesVersions({ minVersion: '3.0.0' });
|
||||
export const supportsForwardQuery = serverMatchesMinVersion('2.9.0');
|
||||
export const supportsDefaultDomainRedirectsEdition = serverMatchesMinVersion('2.10.0');
|
||||
export const supportsNonOrphanVisits = serverMatchesMinVersion('3.0.0');
|
||||
export const supportsAllTagsFiltering = supportsNonOrphanVisits;
|
||||
export const supportsDomainVisits = serverMatchesVersions({ minVersion: '3.1.0' });
|
||||
export const supportsDomainVisits = serverMatchesMinVersion('3.1.0');
|
||||
|
|
|
@ -53,7 +53,6 @@ describe('<MenuLayout />', () => {
|
|||
});
|
||||
|
||||
it.each([
|
||||
['2.5.0' as SemVer, 9],
|
||||
['2.6.0' as SemVer, 10],
|
||||
['2.7.0' as SemVer, 10],
|
||||
['2.8.0' as SemVer, 11],
|
||||
|
|
|
@ -77,10 +77,11 @@ describe('<Overview />', () => {
|
|||
const wrapper = createWrapper();
|
||||
const links = wrapper.find(Link);
|
||||
|
||||
expect(links).toHaveLength(4);
|
||||
expect(links.at(0).prop('to')).toEqual(`/server/${serverId}/list-short-urls/1`);
|
||||
expect(links.at(1).prop('to')).toEqual(`/server/${serverId}/manage-tags`);
|
||||
expect(links.at(2).prop('to')).toEqual(`/server/${serverId}/create-short-url`);
|
||||
expect(links.at(3).prop('to')).toEqual(`/server/${serverId}/list-short-urls/1`);
|
||||
expect(links).toHaveLength(5);
|
||||
expect(links.at(0).prop('to')).toEqual(`/server/${serverId}/orphan-visits`);
|
||||
expect(links.at(1).prop('to')).toEqual(`/server/${serverId}/list-short-urls/1`);
|
||||
expect(links.at(2).prop('to')).toEqual(`/server/${serverId}/manage-tags`);
|
||||
expect(links.at(3).prop('to')).toEqual(`/server/${serverId}/create-short-url`);
|
||||
expect(links.at(4).prop('to')).toEqual(`/server/${serverId}/list-short-urls/1`);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue