mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	refactor: remove unused page components (#707)
* refactor: remove unused history props * refactor: remove unused page components * refactor: move history page components Co-authored-by: Fredrik Strand Oseberg <fredrik.no@gmail.com>
This commit is contained in:
		
							parent
							
								
									ffde1512a0
								
							
						
					
					
						commit
						eda802bcf9
					
				@ -1,27 +1,21 @@
 | 
			
		||||
import PropTypes from 'prop-types';
 | 
			
		||||
import ApiTokenList from '../api-token/ApiTokenList/ApiTokenList';
 | 
			
		||||
import AdminMenu from '../menu/AdminMenu';
 | 
			
		||||
import ConditionallyRender from '../../common/ConditionallyRender';
 | 
			
		||||
import AccessContext from '../../../contexts/AccessContext';
 | 
			
		||||
import { useContext } from 'react';
 | 
			
		||||
 | 
			
		||||
const ApiPage = ({ history }) => {
 | 
			
		||||
const ApiPage = () => {
 | 
			
		||||
    const { isAdmin } = useContext(AccessContext);
 | 
			
		||||
 | 
			
		||||
    return (
 | 
			
		||||
        <div>
 | 
			
		||||
            <ConditionallyRender
 | 
			
		||||
                condition={isAdmin}
 | 
			
		||||
                show={<AdminMenu history={history} />}
 | 
			
		||||
                show={<AdminMenu />}
 | 
			
		||||
            />
 | 
			
		||||
            <ApiTokenList />
 | 
			
		||||
        </div>
 | 
			
		||||
    );
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
ApiPage.propTypes = {
 | 
			
		||||
    match: PropTypes.object.isRequired,
 | 
			
		||||
    history: PropTypes.object.isRequired,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export default ApiPage;
 | 
			
		||||
 | 
			
		||||
@ -18,7 +18,7 @@ const ProjectRoles = () => {
 | 
			
		||||
 | 
			
		||||
    return (
 | 
			
		||||
        <div>
 | 
			
		||||
            <AdminMenu history={history} />
 | 
			
		||||
            <AdminMenu />
 | 
			
		||||
            <PageContent
 | 
			
		||||
                bodyClass={styles.rolesListBody}
 | 
			
		||||
                headerContent={
 | 
			
		||||
 | 
			
		||||
@ -18,7 +18,7 @@ const UsersAdmin = () => {
 | 
			
		||||
 | 
			
		||||
    return (
 | 
			
		||||
        <div>
 | 
			
		||||
            <AdminMenu history={history} />
 | 
			
		||||
            <AdminMenu />
 | 
			
		||||
            <PageContent
 | 
			
		||||
                bodyClass={styles.userListBody}
 | 
			
		||||
                headerContent={
 | 
			
		||||
 | 
			
		||||
@ -18,7 +18,6 @@ test('renders correctly if no application', () => {
 | 
			
		||||
                                fetchApplication={() => Promise.resolve({})}
 | 
			
		||||
                                storeApplicationMetaData={jest.fn()}
 | 
			
		||||
                                deleteApplication={jest.fn()}
 | 
			
		||||
                                history={{}}
 | 
			
		||||
                                locationSettings={{ locale: 'en-GB' }}
 | 
			
		||||
                            />
 | 
			
		||||
                        </MemoryRouter>
 | 
			
		||||
@ -42,7 +41,6 @@ test('renders correctly without permission', () => {
 | 
			
		||||
                                fetchApplication={() => Promise.resolve({})}
 | 
			
		||||
                                storeApplicationMetaData={jest.fn()}
 | 
			
		||||
                                deleteApplication={jest.fn()}
 | 
			
		||||
                                history={{}}
 | 
			
		||||
                                application={{
 | 
			
		||||
                                    appName: 'test-app',
 | 
			
		||||
                                    instances: [
 | 
			
		||||
@ -104,7 +102,6 @@ test('renders correctly with permissions', () => {
 | 
			
		||||
                            <ApplicationEdit
 | 
			
		||||
                                fetchApplication={() => Promise.resolve({})}
 | 
			
		||||
                                storeApplicationMetaData={jest.fn()}
 | 
			
		||||
                                history={{}}
 | 
			
		||||
                                deleteApplication={jest.fn()}
 | 
			
		||||
                                application={{
 | 
			
		||||
                                    appName: 'test-app',
 | 
			
		||||
 | 
			
		||||
@ -18,7 +18,6 @@ test('renders correctly if no application', () => {
 | 
			
		||||
                                fetchApplication={() => Promise.resolve({})}
 | 
			
		||||
                                storeApplicationMetaData={jest.fn()}
 | 
			
		||||
                                deleteApplication={jest.fn()}
 | 
			
		||||
                                history={{}}
 | 
			
		||||
                                locationSettings={{ locale: 'en-GB' }}
 | 
			
		||||
                            />
 | 
			
		||||
                        </MemoryRouter>
 | 
			
		||||
@ -42,7 +41,6 @@ test('renders correctly without permission', () => {
 | 
			
		||||
                                fetchApplication={() => Promise.resolve({})}
 | 
			
		||||
                                storeApplicationMetaData={jest.fn()}
 | 
			
		||||
                                deleteApplication={jest.fn()}
 | 
			
		||||
                                history={{}}
 | 
			
		||||
                                application={{
 | 
			
		||||
                                    appName: 'test-app',
 | 
			
		||||
                                    instances: [
 | 
			
		||||
@ -104,7 +102,6 @@ test('renders correctly with permissions', () => {
 | 
			
		||||
                            <ApplicationEdit
 | 
			
		||||
                                fetchApplication={() => Promise.resolve({})}
 | 
			
		||||
                                storeApplicationMetaData={jest.fn()}
 | 
			
		||||
                                history={{}}
 | 
			
		||||
                                deleteApplication={jest.fn()}
 | 
			
		||||
                                application={{
 | 
			
		||||
                                    appName: 'test-app',
 | 
			
		||||
 | 
			
		||||
@ -1,11 +1,11 @@
 | 
			
		||||
import { Alert } from '@material-ui/lab';
 | 
			
		||||
import React, { useContext } from 'react';
 | 
			
		||||
import { ADMIN } from '../../component/providers/AccessProvider/permissions';
 | 
			
		||||
import ConditionallyRender from '../../component/common/ConditionallyRender';
 | 
			
		||||
import { EventHistory } from '../../component/history/EventHistory/EventHistory';
 | 
			
		||||
import AccessContext from '../../contexts/AccessContext';
 | 
			
		||||
import { ADMIN } from '../../providers/AccessProvider/permissions';
 | 
			
		||||
import ConditionallyRender from '../../common/ConditionallyRender';
 | 
			
		||||
import AccessContext from '../../../contexts/AccessContext';
 | 
			
		||||
import { EventHistory } from '../EventHistory/EventHistory';
 | 
			
		||||
 | 
			
		||||
const HistoryPage = () => {
 | 
			
		||||
export const EventHistoryPage = () => {
 | 
			
		||||
    const { hasAccess } = useContext(AccessContext);
 | 
			
		||||
 | 
			
		||||
    return (
 | 
			
		||||
@ -20,5 +20,3 @@ const HistoryPage = () => {
 | 
			
		||||
        />
 | 
			
		||||
    );
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export default HistoryPage;
 | 
			
		||||
@ -0,0 +1,9 @@
 | 
			
		||||
import React from 'react';
 | 
			
		||||
import { useParams } from 'react-router-dom';
 | 
			
		||||
import { FeatureEventHistory } from '../FeatureEventHistory/FeatureEventHistory';
 | 
			
		||||
 | 
			
		||||
export const FeatureEventHistoryPage = () => {
 | 
			
		||||
    const { toggleName } = useParams<{ toggleName: string }>();
 | 
			
		||||
 | 
			
		||||
    return <FeatureEventHistory toggleName={toggleName} />;
 | 
			
		||||
};
 | 
			
		||||
@ -1,9 +1,7 @@
 | 
			
		||||
import { FeatureToggleListContainer } from '../feature/FeatureToggleList/FeatureToggleListContainer';
 | 
			
		||||
import { StrategyForm } from '../strategies/StrategyForm/StrategyForm';
 | 
			
		||||
import { StrategyView } from '../../component/strategies/StrategyView/StrategyView';
 | 
			
		||||
import { StrategyView } from '../strategies/StrategyView/StrategyView';
 | 
			
		||||
import { StrategiesList } from '../strategies/StrategiesList/StrategiesList';
 | 
			
		||||
import HistoryPage from '../../page/history';
 | 
			
		||||
import HistoryTogglePage from '../../page/history/toggle';
 | 
			
		||||
import { ArchiveListContainer } from '../archive/ArchiveListContainer';
 | 
			
		||||
import { TagTypeList } from '../tags/TagTypeList/TagTypeList';
 | 
			
		||||
import { AddonList } from '../addons/AddonList/AddonList';
 | 
			
		||||
@ -45,6 +43,8 @@ import RedirectFeatureView from '../feature/RedirectFeatureView/RedirectFeatureV
 | 
			
		||||
import { CreateAddon } from '../addons/CreateAddon/CreateAddon';
 | 
			
		||||
import { EditAddon } from '../addons/EditAddon/EditAddon';
 | 
			
		||||
import { CopyFeatureToggle } from '../feature/CopyFeature/CopyFeature';
 | 
			
		||||
import { EventHistoryPage } from '../history/EventHistoryPage/EventHistoryPage';
 | 
			
		||||
import { FeatureEventHistoryPage } from '../history/FeatureEventHistoryPage/FeatureEventHistoryPage';
 | 
			
		||||
 | 
			
		||||
export const routes = [
 | 
			
		||||
    // Project
 | 
			
		||||
@ -354,7 +354,7 @@ export const routes = [
 | 
			
		||||
        path: '/history/:toggleName',
 | 
			
		||||
        title: ':toggleName',
 | 
			
		||||
        parent: '/history',
 | 
			
		||||
        component: HistoryTogglePage,
 | 
			
		||||
        component: FeatureEventHistoryPage,
 | 
			
		||||
        type: 'protected',
 | 
			
		||||
        layout: 'main',
 | 
			
		||||
        menu: {},
 | 
			
		||||
@ -362,7 +362,7 @@ export const routes = [
 | 
			
		||||
    {
 | 
			
		||||
        path: '/history',
 | 
			
		||||
        title: 'Event History',
 | 
			
		||||
        component: HistoryPage,
 | 
			
		||||
        component: EventHistoryPage,
 | 
			
		||||
        type: 'protected',
 | 
			
		||||
        layout: 'main',
 | 
			
		||||
        menu: { adminSettings: true },
 | 
			
		||||
 | 
			
		||||
@ -23,7 +23,6 @@ test('renders correctly with one strategy', () => {
 | 
			
		||||
                            removeStrategy={jest.fn()}
 | 
			
		||||
                            deprecateStrategy={jest.fn()}
 | 
			
		||||
                            reactivateStrategy={jest.fn()}
 | 
			
		||||
                            history={{}}
 | 
			
		||||
                        />
 | 
			
		||||
                    </AccessProvider>
 | 
			
		||||
                </UIProvider>
 | 
			
		||||
@ -50,7 +49,6 @@ test('renders correctly with one strategy without permissions', () => {
 | 
			
		||||
                            removeStrategy={jest.fn()}
 | 
			
		||||
                            deprecateStrategy={jest.fn()}
 | 
			
		||||
                            reactivateStrategy={jest.fn()}
 | 
			
		||||
                            history={{}}
 | 
			
		||||
                        />
 | 
			
		||||
                    </AccessProvider>
 | 
			
		||||
                </UIProvider>
 | 
			
		||||
 | 
			
		||||
@ -45,7 +45,6 @@ test('renders correctly with one strategy', () => {
 | 
			
		||||
                        fetchStrategies={jest.fn()}
 | 
			
		||||
                        fetchApplications={jest.fn()}
 | 
			
		||||
                        fetchFeatureToggles={jest.fn()}
 | 
			
		||||
                        history={{}}
 | 
			
		||||
                    />
 | 
			
		||||
                </ThemeProvider>
 | 
			
		||||
            </AccessProvider>
 | 
			
		||||
 | 
			
		||||
@ -22,7 +22,6 @@ test('renders an empty list correctly', () => {
 | 
			
		||||
                            tagTypes={[]}
 | 
			
		||||
                            fetchTagTypes={jest.fn()}
 | 
			
		||||
                            removeTagType={jest.fn()}
 | 
			
		||||
                            history={{}}
 | 
			
		||||
                        />
 | 
			
		||||
                    </AccessProvider>
 | 
			
		||||
                </UIProvider>
 | 
			
		||||
@ -53,7 +52,6 @@ test('renders a list with elements correctly', () => {
 | 
			
		||||
                            ]}
 | 
			
		||||
                            fetchTagTypes={jest.fn()}
 | 
			
		||||
                            removeTagType={jest.fn()}
 | 
			
		||||
                            history={{}}
 | 
			
		||||
                        />
 | 
			
		||||
                    </AccessProvider>
 | 
			
		||||
                </UIProvider>
 | 
			
		||||
 | 
			
		||||
@ -1,6 +0,0 @@
 | 
			
		||||
import React from 'react';
 | 
			
		||||
import ClientInstance from '../../component/client-instance/client-instance-container';
 | 
			
		||||
 | 
			
		||||
const render = () => <ClientInstance />;
 | 
			
		||||
 | 
			
		||||
export default render;
 | 
			
		||||
@ -1,13 +0,0 @@
 | 
			
		||||
import React from 'react';
 | 
			
		||||
import CreateFeature from '../../component/feature/create/CreateFeature';
 | 
			
		||||
import PropTypes from 'prop-types';
 | 
			
		||||
 | 
			
		||||
const render = ({ history }) => (
 | 
			
		||||
    <CreateFeature title="Create feature toggle" history={history} />
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
render.propTypes = {
 | 
			
		||||
    history: PropTypes.object.isRequired,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export default render;
 | 
			
		||||
@ -1,13 +0,0 @@
 | 
			
		||||
import React from 'react';
 | 
			
		||||
import PropTypes from 'prop-types';
 | 
			
		||||
import { FeatureEventHistory } from '../../component/history/FeatureEventHistory/FeatureEventHistory';
 | 
			
		||||
 | 
			
		||||
const render = ({ match: { params } }) => (
 | 
			
		||||
    <FeatureEventHistory toggleName={params.toggleName} />
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
render.propTypes = {
 | 
			
		||||
    match: PropTypes.object.isRequired,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export default render;
 | 
			
		||||
@ -1,6 +0,0 @@
 | 
			
		||||
import React from 'react';
 | 
			
		||||
import Metrics from '../../component/metrics/metrics-container';
 | 
			
		||||
 | 
			
		||||
const render = () => <Metrics />;
 | 
			
		||||
 | 
			
		||||
export default render;
 | 
			
		||||
@ -1,11 +0,0 @@
 | 
			
		||||
import React from 'react';
 | 
			
		||||
import CreateProject from '../../component/project/create-project-container';
 | 
			
		||||
import PropTypes from 'prop-types';
 | 
			
		||||
 | 
			
		||||
const render = ({ history }) => <CreateProject title="Create Project" history={history} />;
 | 
			
		||||
 | 
			
		||||
render.propTypes = {
 | 
			
		||||
    history: PropTypes.object.isRequired,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export default render;
 | 
			
		||||
@ -1,14 +0,0 @@
 | 
			
		||||
import React from 'react';
 | 
			
		||||
import EditProject from '../../component/project/edit-project-container';
 | 
			
		||||
import PropTypes from 'prop-types';
 | 
			
		||||
 | 
			
		||||
const render = ({ match: { params }, history }) => (
 | 
			
		||||
    <EditProject projectId={params.id} title="Edit project" history={history} />
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
render.propTypes = {
 | 
			
		||||
    match: PropTypes.object.isRequired,
 | 
			
		||||
    history: PropTypes.object.isRequired,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export default render;
 | 
			
		||||
@ -1,6 +0,0 @@
 | 
			
		||||
import React from 'react';
 | 
			
		||||
import ProjectEnvironment from '../../component/project/ProjectEnvironment/ProjectEnvironment';
 | 
			
		||||
 | 
			
		||||
const ProjectEnvironmentConfigPage = () => <ProjectEnvironment />;
 | 
			
		||||
 | 
			
		||||
export default ProjectEnvironmentConfigPage;
 | 
			
		||||
@ -1,11 +0,0 @@
 | 
			
		||||
import React from 'react';
 | 
			
		||||
import ProjectList from '../../component/project/ProjectList/ProjectList';
 | 
			
		||||
import PropTypes from 'prop-types';
 | 
			
		||||
 | 
			
		||||
const render = ({ history }) => <ProjectList history={history} />;
 | 
			
		||||
 | 
			
		||||
render.propTypes = {
 | 
			
		||||
    history: PropTypes.object.isRequired,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export default render;
 | 
			
		||||
@ -1,14 +0,0 @@
 | 
			
		||||
import React from 'react';
 | 
			
		||||
import ViewProject from '../../component/project/ProjectView';
 | 
			
		||||
import PropTypes from 'prop-types';
 | 
			
		||||
 | 
			
		||||
const render = ({ match: { params }, history }) => (
 | 
			
		||||
    <ViewProject projectId={params.id} title="View project" history={history} />
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
render.propTypes = {
 | 
			
		||||
    match: PropTypes.object.isRequired,
 | 
			
		||||
    history: PropTypes.object.isRequired,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export default render;
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user