mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-01-10 18:27:25 +03:00
Deleted ForServerVersion component, which is no longer used
This commit is contained in:
parent
677f1da8df
commit
337bfc47c1
6 changed files with 3 additions and 71 deletions
|
@ -46,7 +46,7 @@ export interface ShlinkVisits {
|
||||||
|
|
||||||
export interface ShlinkVisitsOverview {
|
export interface ShlinkVisitsOverview {
|
||||||
visitsCount: number;
|
visitsCount: number;
|
||||||
orphanVisitsCount?: number; // Optional only for versions older than 2.6.0
|
orphanVisitsCount: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ShlinkVisitsParams {
|
export interface ShlinkVisitsParams {
|
||||||
|
|
|
@ -59,7 +59,7 @@ export const Overview = (
|
||||||
</div>
|
</div>
|
||||||
<div className="col-lg-6 col-xl-3 mb-3">
|
<div className="col-lg-6 col-xl-3 mb-3">
|
||||||
<HighlightCard title="Orphan visits" link={`/server/${serverId}/orphan-visits`}>
|
<HighlightCard title="Orphan visits" link={`/server/${serverId}/orphan-visits`}>
|
||||||
{loadingVisits ? 'Loading...' : prettify(orphanVisitsCount ?? 0)}
|
{loadingVisits ? 'Loading...' : prettify(orphanVisitsCount)}
|
||||||
</HighlightCard>
|
</HighlightCard>
|
||||||
</div>
|
</div>
|
||||||
<div className="col-lg-6 col-xl-3 mb-3">
|
<div className="col-lg-6 col-xl-3 mb-3">
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
import { FC, PropsWithChildren } from 'react';
|
|
||||||
import { versionMatch, Versions } from '../../utils/helpers/version';
|
|
||||||
import { isReachableServer, SelectedServer } from '../data';
|
|
||||||
|
|
||||||
export type ForServerVersionProps = PropsWithChildren<Versions>;
|
|
||||||
|
|
||||||
interface ForServerVersionConnectProps extends ForServerVersionProps {
|
|
||||||
selectedServer: SelectedServer;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const ForServerVersion: FC<ForServerVersionConnectProps> = (
|
|
||||||
{ minVersion, maxVersion, selectedServer, children },
|
|
||||||
) => {
|
|
||||||
if (!isReachableServer(selectedServer)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const { version } = selectedServer;
|
|
||||||
const matchesVersion = versionMatch(version, { maxVersion, minVersion });
|
|
||||||
|
|
||||||
if (!matchesVersion) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return <>{children}</>;
|
|
||||||
};
|
|
|
@ -8,7 +8,6 @@ import ImportServersBtn from '../helpers/ImportServersBtn';
|
||||||
import { resetSelectedServer, selectServer } from '../reducers/selectedServer';
|
import { resetSelectedServer, selectServer } from '../reducers/selectedServer';
|
||||||
import { createServer, createServers, deleteServer, editServer, setAutoConnect } from '../reducers/servers';
|
import { createServer, createServers, deleteServer, editServer, setAutoConnect } from '../reducers/servers';
|
||||||
import { fetchServers } from '../reducers/remoteServers';
|
import { fetchServers } from '../reducers/remoteServers';
|
||||||
import { ForServerVersion } from '../helpers/ForServerVersion';
|
|
||||||
import { ServerError } from '../helpers/ServerError';
|
import { ServerError } from '../helpers/ServerError';
|
||||||
import { ConnectDecorator } from '../../container/types';
|
import { ConnectDecorator } from '../../container/types';
|
||||||
import { withoutSelectedServer } from '../helpers/withoutSelectedServer';
|
import { withoutSelectedServer } from '../helpers/withoutSelectedServer';
|
||||||
|
@ -55,9 +54,6 @@ const provideServices = (bottle: Bottle, connect: ConnectDecorator) => {
|
||||||
bottle.serviceFactory('ImportServersBtn', ImportServersBtn, 'ServersImporter');
|
bottle.serviceFactory('ImportServersBtn', ImportServersBtn, 'ServersImporter');
|
||||||
bottle.decorator('ImportServersBtn', connect(['servers'], ['createServers']));
|
bottle.decorator('ImportServersBtn', connect(['servers'], ['createServers']));
|
||||||
|
|
||||||
bottle.serviceFactory('ForServerVersion', () => ForServerVersion);
|
|
||||||
bottle.decorator('ForServerVersion', connect(['selectedServer']));
|
|
||||||
|
|
||||||
bottle.serviceFactory('ServerError', ServerError, 'DeleteServerButton');
|
bottle.serviceFactory('ServerError', ServerError, 'DeleteServerButton');
|
||||||
bottle.decorator('ServerError', connect(['servers', 'selectedServer']));
|
bottle.decorator('ServerError', connect(['servers', 'selectedServer']));
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ export const GET_OVERVIEW = 'shlink/visitsOverview/GET_OVERVIEW';
|
||||||
|
|
||||||
export interface VisitsOverview {
|
export interface VisitsOverview {
|
||||||
visitsCount: number;
|
visitsCount: number;
|
||||||
orphanVisitsCount?: number;
|
orphanVisitsCount: number;
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
error: boolean;
|
error: boolean;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
import { render, screen } from '@testing-library/react';
|
|
||||||
import { Mock } from 'ts-mockery';
|
|
||||||
import { ForServerVersion } from '../../../src/servers/helpers/ForServerVersion';
|
|
||||||
import { ReachableServer, SelectedServer } from '../../../src/servers/data';
|
|
||||||
import { SemVer, SemVerPattern } from '../../../src/utils/helpers/version';
|
|
||||||
|
|
||||||
describe('<ForServerVersion />', () => {
|
|
||||||
const setUp = (selectedServer: SelectedServer, minVersion?: SemVerPattern, maxVersion?: SemVerPattern) => render(
|
|
||||||
<ForServerVersion minVersion={minVersion} maxVersion={maxVersion} selectedServer={selectedServer}>
|
|
||||||
<span>Hello</span>
|
|
||||||
</ForServerVersion>,
|
|
||||||
);
|
|
||||||
|
|
||||||
it('does not render children when current server is empty', () => {
|
|
||||||
setUp(null, '1.*.*');
|
|
||||||
expect(screen.queryByText('Hello')).not.toBeInTheDocument();
|
|
||||||
});
|
|
||||||
|
|
||||||
it.each([
|
|
||||||
['2.0.0' as SemVerPattern, undefined, '1.8.3' as SemVer],
|
|
||||||
[undefined, '1.8.0' as SemVerPattern, '1.8.3' as SemVer],
|
|
||||||
['1.7.0' as SemVerPattern, '1.8.0' as SemVerPattern, '1.8.3' as SemVer],
|
|
||||||
])('does not render children when current version does not match requirements', (min, max, version) => {
|
|
||||||
setUp(Mock.of<ReachableServer>({ version, printableVersion: version }), min, max);
|
|
||||||
expect(screen.queryByText('Hello')).not.toBeInTheDocument();
|
|
||||||
});
|
|
||||||
|
|
||||||
it.each([
|
|
||||||
['2.0.0' as SemVerPattern, undefined, '2.8.3' as SemVer],
|
|
||||||
['2.0.0' as SemVerPattern, undefined, '2.0.0' as SemVer],
|
|
||||||
[undefined, '1.8.0' as SemVerPattern, '1.8.0' as SemVer],
|
|
||||||
[undefined, '1.8.0' as SemVerPattern, '1.7.1' as SemVer],
|
|
||||||
['1.7.0' as SemVerPattern, '1.8.0' as SemVerPattern, '1.7.3' as SemVer],
|
|
||||||
])('renders children when current version matches requirements', (min, max, version) => {
|
|
||||||
setUp(Mock.of<ReachableServer>({ version, printableVersion: version }), min, max);
|
|
||||||
expect(screen.queryByText('Hello')).toBeInTheDocument();
|
|
||||||
});
|
|
||||||
});
|
|
Loading…
Reference in a new issue