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 ApiTokenList from '../api-token/ApiTokenList/ApiTokenList'; | ||||||
| import AdminMenu from '../menu/AdminMenu'; | import AdminMenu from '../menu/AdminMenu'; | ||||||
| import ConditionallyRender from '../../common/ConditionallyRender'; | import ConditionallyRender from '../../common/ConditionallyRender'; | ||||||
| import AccessContext from '../../../contexts/AccessContext'; | import AccessContext from '../../../contexts/AccessContext'; | ||||||
| import { useContext } from 'react'; | import { useContext } from 'react'; | ||||||
| 
 | 
 | ||||||
| const ApiPage = ({ history }) => { | const ApiPage = () => { | ||||||
|     const { isAdmin } = useContext(AccessContext); |     const { isAdmin } = useContext(AccessContext); | ||||||
| 
 | 
 | ||||||
|     return ( |     return ( | ||||||
|         <div> |         <div> | ||||||
|             <ConditionallyRender |             <ConditionallyRender | ||||||
|                 condition={isAdmin} |                 condition={isAdmin} | ||||||
|                 show={<AdminMenu history={history} />} |                 show={<AdminMenu />} | ||||||
|             /> |             /> | ||||||
|             <ApiTokenList /> |             <ApiTokenList /> | ||||||
|         </div> |         </div> | ||||||
|     ); |     ); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| ApiPage.propTypes = { |  | ||||||
|     match: PropTypes.object.isRequired, |  | ||||||
|     history: PropTypes.object.isRequired, |  | ||||||
| }; |  | ||||||
| 
 |  | ||||||
| export default ApiPage; | export default ApiPage; | ||||||
|  | |||||||
| @ -18,7 +18,7 @@ const ProjectRoles = () => { | |||||||
| 
 | 
 | ||||||
|     return ( |     return ( | ||||||
|         <div> |         <div> | ||||||
|             <AdminMenu history={history} /> |             <AdminMenu /> | ||||||
|             <PageContent |             <PageContent | ||||||
|                 bodyClass={styles.rolesListBody} |                 bodyClass={styles.rolesListBody} | ||||||
|                 headerContent={ |                 headerContent={ | ||||||
|  | |||||||
| @ -18,7 +18,7 @@ const UsersAdmin = () => { | |||||||
| 
 | 
 | ||||||
|     return ( |     return ( | ||||||
|         <div> |         <div> | ||||||
|             <AdminMenu history={history} /> |             <AdminMenu /> | ||||||
|             <PageContent |             <PageContent | ||||||
|                 bodyClass={styles.userListBody} |                 bodyClass={styles.userListBody} | ||||||
|                 headerContent={ |                 headerContent={ | ||||||
|  | |||||||
| @ -18,7 +18,6 @@ test('renders correctly if no application', () => { | |||||||
|                                 fetchApplication={() => Promise.resolve({})} |                                 fetchApplication={() => Promise.resolve({})} | ||||||
|                                 storeApplicationMetaData={jest.fn()} |                                 storeApplicationMetaData={jest.fn()} | ||||||
|                                 deleteApplication={jest.fn()} |                                 deleteApplication={jest.fn()} | ||||||
|                                 history={{}} |  | ||||||
|                                 locationSettings={{ locale: 'en-GB' }} |                                 locationSettings={{ locale: 'en-GB' }} | ||||||
|                             /> |                             /> | ||||||
|                         </MemoryRouter> |                         </MemoryRouter> | ||||||
| @ -42,7 +41,6 @@ test('renders correctly without permission', () => { | |||||||
|                                 fetchApplication={() => Promise.resolve({})} |                                 fetchApplication={() => Promise.resolve({})} | ||||||
|                                 storeApplicationMetaData={jest.fn()} |                                 storeApplicationMetaData={jest.fn()} | ||||||
|                                 deleteApplication={jest.fn()} |                                 deleteApplication={jest.fn()} | ||||||
|                                 history={{}} |  | ||||||
|                                 application={{ |                                 application={{ | ||||||
|                                     appName: 'test-app', |                                     appName: 'test-app', | ||||||
|                                     instances: [ |                                     instances: [ | ||||||
| @ -104,7 +102,6 @@ test('renders correctly with permissions', () => { | |||||||
|                             <ApplicationEdit |                             <ApplicationEdit | ||||||
|                                 fetchApplication={() => Promise.resolve({})} |                                 fetchApplication={() => Promise.resolve({})} | ||||||
|                                 storeApplicationMetaData={jest.fn()} |                                 storeApplicationMetaData={jest.fn()} | ||||||
|                                 history={{}} |  | ||||||
|                                 deleteApplication={jest.fn()} |                                 deleteApplication={jest.fn()} | ||||||
|                                 application={{ |                                 application={{ | ||||||
|                                     appName: 'test-app', |                                     appName: 'test-app', | ||||||
|  | |||||||
| @ -18,7 +18,6 @@ test('renders correctly if no application', () => { | |||||||
|                                 fetchApplication={() => Promise.resolve({})} |                                 fetchApplication={() => Promise.resolve({})} | ||||||
|                                 storeApplicationMetaData={jest.fn()} |                                 storeApplicationMetaData={jest.fn()} | ||||||
|                                 deleteApplication={jest.fn()} |                                 deleteApplication={jest.fn()} | ||||||
|                                 history={{}} |  | ||||||
|                                 locationSettings={{ locale: 'en-GB' }} |                                 locationSettings={{ locale: 'en-GB' }} | ||||||
|                             /> |                             /> | ||||||
|                         </MemoryRouter> |                         </MemoryRouter> | ||||||
| @ -42,7 +41,6 @@ test('renders correctly without permission', () => { | |||||||
|                                 fetchApplication={() => Promise.resolve({})} |                                 fetchApplication={() => Promise.resolve({})} | ||||||
|                                 storeApplicationMetaData={jest.fn()} |                                 storeApplicationMetaData={jest.fn()} | ||||||
|                                 deleteApplication={jest.fn()} |                                 deleteApplication={jest.fn()} | ||||||
|                                 history={{}} |  | ||||||
|                                 application={{ |                                 application={{ | ||||||
|                                     appName: 'test-app', |                                     appName: 'test-app', | ||||||
|                                     instances: [ |                                     instances: [ | ||||||
| @ -104,7 +102,6 @@ test('renders correctly with permissions', () => { | |||||||
|                             <ApplicationEdit |                             <ApplicationEdit | ||||||
|                                 fetchApplication={() => Promise.resolve({})} |                                 fetchApplication={() => Promise.resolve({})} | ||||||
|                                 storeApplicationMetaData={jest.fn()} |                                 storeApplicationMetaData={jest.fn()} | ||||||
|                                 history={{}} |  | ||||||
|                                 deleteApplication={jest.fn()} |                                 deleteApplication={jest.fn()} | ||||||
|                                 application={{ |                                 application={{ | ||||||
|                                     appName: 'test-app', |                                     appName: 'test-app', | ||||||
|  | |||||||
| @ -1,11 +1,11 @@ | |||||||
| import { Alert } from '@material-ui/lab'; | import { Alert } from '@material-ui/lab'; | ||||||
| import React, { useContext } from 'react'; | import React, { useContext } from 'react'; | ||||||
| import { ADMIN } from '../../component/providers/AccessProvider/permissions'; | import { ADMIN } from '../../providers/AccessProvider/permissions'; | ||||||
| import ConditionallyRender from '../../component/common/ConditionallyRender'; | import ConditionallyRender from '../../common/ConditionallyRender'; | ||||||
| import { EventHistory } from '../../component/history/EventHistory/EventHistory'; | import AccessContext from '../../../contexts/AccessContext'; | ||||||
| import AccessContext from '../../contexts/AccessContext'; | import { EventHistory } from '../EventHistory/EventHistory'; | ||||||
| 
 | 
 | ||||||
| const HistoryPage = () => { | export const EventHistoryPage = () => { | ||||||
|     const { hasAccess } = useContext(AccessContext); |     const { hasAccess } = useContext(AccessContext); | ||||||
| 
 | 
 | ||||||
|     return ( |     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 { FeatureToggleListContainer } from '../feature/FeatureToggleList/FeatureToggleListContainer'; | ||||||
| import { StrategyForm } from '../strategies/StrategyForm/StrategyForm'; | 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 { StrategiesList } from '../strategies/StrategiesList/StrategiesList'; | ||||||
| import HistoryPage from '../../page/history'; |  | ||||||
| import HistoryTogglePage from '../../page/history/toggle'; |  | ||||||
| import { ArchiveListContainer } from '../archive/ArchiveListContainer'; | import { ArchiveListContainer } from '../archive/ArchiveListContainer'; | ||||||
| import { TagTypeList } from '../tags/TagTypeList/TagTypeList'; | import { TagTypeList } from '../tags/TagTypeList/TagTypeList'; | ||||||
| import { AddonList } from '../addons/AddonList/AddonList'; | import { AddonList } from '../addons/AddonList/AddonList'; | ||||||
| @ -45,6 +43,8 @@ import RedirectFeatureView from '../feature/RedirectFeatureView/RedirectFeatureV | |||||||
| import { CreateAddon } from '../addons/CreateAddon/CreateAddon'; | import { CreateAddon } from '../addons/CreateAddon/CreateAddon'; | ||||||
| import { EditAddon } from '../addons/EditAddon/EditAddon'; | import { EditAddon } from '../addons/EditAddon/EditAddon'; | ||||||
| import { CopyFeatureToggle } from '../feature/CopyFeature/CopyFeature'; | import { CopyFeatureToggle } from '../feature/CopyFeature/CopyFeature'; | ||||||
|  | import { EventHistoryPage } from '../history/EventHistoryPage/EventHistoryPage'; | ||||||
|  | import { FeatureEventHistoryPage } from '../history/FeatureEventHistoryPage/FeatureEventHistoryPage'; | ||||||
| 
 | 
 | ||||||
| export const routes = [ | export const routes = [ | ||||||
|     // Project
 |     // Project
 | ||||||
| @ -354,7 +354,7 @@ export const routes = [ | |||||||
|         path: '/history/:toggleName', |         path: '/history/:toggleName', | ||||||
|         title: ':toggleName', |         title: ':toggleName', | ||||||
|         parent: '/history', |         parent: '/history', | ||||||
|         component: HistoryTogglePage, |         component: FeatureEventHistoryPage, | ||||||
|         type: 'protected', |         type: 'protected', | ||||||
|         layout: 'main', |         layout: 'main', | ||||||
|         menu: {}, |         menu: {}, | ||||||
| @ -362,7 +362,7 @@ export const routes = [ | |||||||
|     { |     { | ||||||
|         path: '/history', |         path: '/history', | ||||||
|         title: 'Event History', |         title: 'Event History', | ||||||
|         component: HistoryPage, |         component: EventHistoryPage, | ||||||
|         type: 'protected', |         type: 'protected', | ||||||
|         layout: 'main', |         layout: 'main', | ||||||
|         menu: { adminSettings: true }, |         menu: { adminSettings: true }, | ||||||
|  | |||||||
| @ -23,7 +23,6 @@ test('renders correctly with one strategy', () => { | |||||||
|                             removeStrategy={jest.fn()} |                             removeStrategy={jest.fn()} | ||||||
|                             deprecateStrategy={jest.fn()} |                             deprecateStrategy={jest.fn()} | ||||||
|                             reactivateStrategy={jest.fn()} |                             reactivateStrategy={jest.fn()} | ||||||
|                             history={{}} |  | ||||||
|                         /> |                         /> | ||||||
|                     </AccessProvider> |                     </AccessProvider> | ||||||
|                 </UIProvider> |                 </UIProvider> | ||||||
| @ -50,7 +49,6 @@ test('renders correctly with one strategy without permissions', () => { | |||||||
|                             removeStrategy={jest.fn()} |                             removeStrategy={jest.fn()} | ||||||
|                             deprecateStrategy={jest.fn()} |                             deprecateStrategy={jest.fn()} | ||||||
|                             reactivateStrategy={jest.fn()} |                             reactivateStrategy={jest.fn()} | ||||||
|                             history={{}} |  | ||||||
|                         /> |                         /> | ||||||
|                     </AccessProvider> |                     </AccessProvider> | ||||||
|                 </UIProvider> |                 </UIProvider> | ||||||
|  | |||||||
| @ -45,7 +45,6 @@ test('renders correctly with one strategy', () => { | |||||||
|                         fetchStrategies={jest.fn()} |                         fetchStrategies={jest.fn()} | ||||||
|                         fetchApplications={jest.fn()} |                         fetchApplications={jest.fn()} | ||||||
|                         fetchFeatureToggles={jest.fn()} |                         fetchFeatureToggles={jest.fn()} | ||||||
|                         history={{}} |  | ||||||
|                     /> |                     /> | ||||||
|                 </ThemeProvider> |                 </ThemeProvider> | ||||||
|             </AccessProvider> |             </AccessProvider> | ||||||
|  | |||||||
| @ -22,7 +22,6 @@ test('renders an empty list correctly', () => { | |||||||
|                             tagTypes={[]} |                             tagTypes={[]} | ||||||
|                             fetchTagTypes={jest.fn()} |                             fetchTagTypes={jest.fn()} | ||||||
|                             removeTagType={jest.fn()} |                             removeTagType={jest.fn()} | ||||||
|                             history={{}} |  | ||||||
|                         /> |                         /> | ||||||
|                     </AccessProvider> |                     </AccessProvider> | ||||||
|                 </UIProvider> |                 </UIProvider> | ||||||
| @ -53,7 +52,6 @@ test('renders a list with elements correctly', () => { | |||||||
|                             ]} |                             ]} | ||||||
|                             fetchTagTypes={jest.fn()} |                             fetchTagTypes={jest.fn()} | ||||||
|                             removeTagType={jest.fn()} |                             removeTagType={jest.fn()} | ||||||
|                             history={{}} |  | ||||||
|                         /> |                         /> | ||||||
|                     </AccessProvider> |                     </AccessProvider> | ||||||
|                 </UIProvider> |                 </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