mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-01-03 23:07:26 +03:00
Removed non-needed components which were just wrapping another component that could directly be used instead
This commit is contained in:
parent
368f7acd2d
commit
ddb08f4d2e
8 changed files with 10 additions and 80 deletions
|
@ -7,7 +7,7 @@ import VisitsStats from './VisitsStats';
|
|||
import { NormalizedVisit, VisitsInfo, VisitsParams } from './types';
|
||||
import { CommonVisitsProps } from './types/CommonVisitsProps';
|
||||
import { toApiParams } from './types/helpers';
|
||||
import { NonOrphanVisitsHeader } from './NonOrphanVisitsHeader';
|
||||
import VisitsHeader from './VisitsHeader';
|
||||
|
||||
export interface NonOrphanVisitsProps extends CommonVisitsProps {
|
||||
getNonOrphanVisits: (params?: ShlinkVisitsParams, doIntervalFallback?: boolean) => void;
|
||||
|
@ -36,7 +36,7 @@ export const NonOrphanVisits = ({ exportVisits }: ReportExporter) => boundToMerc
|
|||
exportCsv={exportCsv}
|
||||
selectedServer={selectedServer}
|
||||
>
|
||||
<NonOrphanVisitsHeader nonOrphanVisits={nonOrphanVisits} goBack={goBack} />
|
||||
<VisitsHeader title="Non-orphan visits" goBack={goBack} visits={nonOrphanVisits.visits} />
|
||||
</VisitsStats>
|
||||
);
|
||||
}, () => [Topics.visits]);
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
import VisitsHeader from './VisitsHeader';
|
||||
import { VisitsInfo } from './types';
|
||||
import './ShortUrlVisitsHeader.scss';
|
||||
|
||||
interface NonOrphanVisitsHeaderProps {
|
||||
nonOrphanVisits: VisitsInfo;
|
||||
goBack: () => void;
|
||||
}
|
||||
|
||||
export const NonOrphanVisitsHeader = ({ nonOrphanVisits, goBack }: NonOrphanVisitsHeaderProps) => {
|
||||
const { visits } = nonOrphanVisits;
|
||||
|
||||
return <VisitsHeader title="Non-orphan visits" goBack={goBack} visits={visits} />;
|
||||
};
|
|
@ -4,10 +4,10 @@ import { Topics } from '../mercure/helpers/Topics';
|
|||
import { useGoBack } from '../utils/helpers/hooks';
|
||||
import { ReportExporter } from '../common/services/ReportExporter';
|
||||
import VisitsStats from './VisitsStats';
|
||||
import { OrphanVisitsHeader } from './OrphanVisitsHeader';
|
||||
import { NormalizedVisit, OrphanVisitType, VisitsInfo, VisitsParams } from './types';
|
||||
import { CommonVisitsProps } from './types/CommonVisitsProps';
|
||||
import { toApiParams } from './types/helpers';
|
||||
import VisitsHeader from './VisitsHeader';
|
||||
|
||||
export interface OrphanVisitsProps extends CommonVisitsProps {
|
||||
getOrphanVisits: (
|
||||
|
@ -41,7 +41,7 @@ export const OrphanVisits = ({ exportVisits }: ReportExporter) => boundToMercure
|
|||
selectedServer={selectedServer}
|
||||
isOrphanVisits
|
||||
>
|
||||
<OrphanVisitsHeader orphanVisits={orphanVisits} goBack={goBack} />
|
||||
<VisitsHeader title="Orphan visits" goBack={goBack} visits={orphanVisits.visits} />
|
||||
</VisitsStats>
|
||||
);
|
||||
}, () => [Topics.orphanVisits]);
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
import VisitsHeader from './VisitsHeader';
|
||||
import { VisitsInfo } from './types';
|
||||
import './ShortUrlVisitsHeader.scss';
|
||||
|
||||
interface OrphanVisitsHeaderProps {
|
||||
orphanVisits: VisitsInfo;
|
||||
goBack: () => void;
|
||||
}
|
||||
|
||||
export const OrphanVisitsHeader = ({ orphanVisits, goBack }: OrphanVisitsHeaderProps) => {
|
||||
const { visits } = orphanVisits;
|
||||
|
||||
return <VisitsHeader title="Orphan visits" goBack={goBack} visits={visits} />;
|
||||
};
|
|
@ -4,10 +4,10 @@ import { NonOrphanVisits as createNonOrphanVisits } from '../../src/visits/NonOr
|
|||
import { MercureBoundProps } from '../../src/mercure/helpers/boundToMercureHub';
|
||||
import { VisitsInfo } from '../../src/visits/types';
|
||||
import VisitsStats from '../../src/visits/VisitsStats';
|
||||
import { NonOrphanVisitsHeader } from '../../src/visits/NonOrphanVisitsHeader';
|
||||
import { Settings } from '../../src/settings/reducers/settings';
|
||||
import { ReportExporter } from '../../src/common/services/ReportExporter';
|
||||
import { SelectedServer } from '../../src/servers/data';
|
||||
import VisitsHeader from '../../src/visits/VisitsHeader';
|
||||
|
||||
jest.mock('react-router-dom', () => ({
|
||||
...jest.requireActual('react-router-dom'),
|
||||
|
@ -33,14 +33,14 @@ describe('<NonOrphanVisits />', () => {
|
|||
/>,
|
||||
).dive();
|
||||
const stats = wrapper.find(VisitsStats);
|
||||
const header = wrapper.find(NonOrphanVisitsHeader);
|
||||
const header = wrapper.find(VisitsHeader);
|
||||
|
||||
expect(stats).toHaveLength(1);
|
||||
expect(header).toHaveLength(1);
|
||||
expect(stats.prop('cancelGetVisits')).toEqual(cancelGetNonOrphanVisits);
|
||||
expect(stats.prop('visitsInfo')).toEqual(nonOrphanVisits);
|
||||
expect(stats.prop('isOrphanVisits')).not.toBeDefined();
|
||||
expect(header.prop('nonOrphanVisits')).toEqual(nonOrphanVisits);
|
||||
expect(header.prop('visits')).toEqual(nonOrphanVisits.visits);
|
||||
expect(header.prop('goBack')).toEqual(expect.any(Function));
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
import { shallow } from 'enzyme';
|
||||
import { Mock } from 'ts-mockery';
|
||||
import { NonOrphanVisitsHeader } from '../../src/visits/NonOrphanVisitsHeader';
|
||||
import VisitsHeader from '../../src/visits/VisitsHeader';
|
||||
import { Visit, VisitsInfo } from '../../src/visits/types';
|
||||
|
||||
describe('<NonOrphanVisitsHeader />', () => {
|
||||
it('wraps a VisitsHeader with provided data', () => {
|
||||
const visits: Visit[] = [];
|
||||
const orphanVisits = Mock.of<VisitsInfo>({ visits });
|
||||
const goBack = jest.fn();
|
||||
|
||||
const wrapper = shallow(<NonOrphanVisitsHeader nonOrphanVisits={orphanVisits} goBack={goBack} />);
|
||||
const visitsHeader = wrapper.find(VisitsHeader);
|
||||
|
||||
expect(visitsHeader).toHaveLength(1);
|
||||
expect(visitsHeader.prop('visits')).toEqual(visits);
|
||||
expect(visitsHeader.prop('goBack')).toEqual(goBack);
|
||||
expect(visitsHeader.prop('title')).toEqual('Non-orphan visits');
|
||||
});
|
||||
});
|
|
@ -4,10 +4,10 @@ import { OrphanVisits as createOrphanVisits } from '../../src/visits/OrphanVisit
|
|||
import { MercureBoundProps } from '../../src/mercure/helpers/boundToMercureHub';
|
||||
import { VisitsInfo } from '../../src/visits/types';
|
||||
import VisitsStats from '../../src/visits/VisitsStats';
|
||||
import { OrphanVisitsHeader } from '../../src/visits/OrphanVisitsHeader';
|
||||
import { Settings } from '../../src/settings/reducers/settings';
|
||||
import { ReportExporter } from '../../src/common/services/ReportExporter';
|
||||
import { SelectedServer } from '../../src/servers/data';
|
||||
import VisitsHeader from '../../src/visits/VisitsHeader';
|
||||
|
||||
jest.mock('react-router-dom', () => ({
|
||||
...jest.requireActual('react-router-dom'),
|
||||
|
@ -33,14 +33,14 @@ describe('<OrphanVisits />', () => {
|
|||
/>,
|
||||
).dive();
|
||||
const stats = wrapper.find(VisitsStats);
|
||||
const header = wrapper.find(OrphanVisitsHeader);
|
||||
const header = wrapper.find(VisitsHeader);
|
||||
|
||||
expect(stats).toHaveLength(1);
|
||||
expect(header).toHaveLength(1);
|
||||
expect(stats.prop('cancelGetVisits')).toEqual(cancelGetOrphanVisits);
|
||||
expect(stats.prop('visitsInfo')).toEqual(orphanVisits);
|
||||
expect(stats.prop('isOrphanVisits')).toEqual(true);
|
||||
expect(header.prop('orphanVisits')).toEqual(orphanVisits);
|
||||
expect(header.prop('visits')).toEqual(orphanVisits.visits);
|
||||
expect(header.prop('goBack')).toEqual(expect.any(Function));
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
import { shallow } from 'enzyme';
|
||||
import { Mock } from 'ts-mockery';
|
||||
import { OrphanVisitsHeader } from '../../src/visits/OrphanVisitsHeader';
|
||||
import VisitsHeader from '../../src/visits/VisitsHeader';
|
||||
import { Visit, VisitsInfo } from '../../src/visits/types';
|
||||
|
||||
describe('<OrphanVisitsHeader />', () => {
|
||||
it('wraps a VisitsHeader with provided data', () => {
|
||||
const visits: Visit[] = [];
|
||||
const orphanVisits = Mock.of<VisitsInfo>({ visits });
|
||||
const goBack = jest.fn();
|
||||
|
||||
const wrapper = shallow(<OrphanVisitsHeader orphanVisits={orphanVisits} goBack={goBack} />);
|
||||
const visitsHeader = wrapper.find(VisitsHeader);
|
||||
|
||||
expect(visitsHeader).toHaveLength(1);
|
||||
expect(visitsHeader.prop('visits')).toEqual(visits);
|
||||
expect(visitsHeader.prop('goBack')).toEqual(goBack);
|
||||
expect(visitsHeader.prop('title')).toEqual('Orphan visits');
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue