From 0e9feb12ec8664b5b1fa12b05a465f93365f991d Mon Sep 17 00:00:00 2001 From: Jeremy Date: Thu, 2 Jan 2020 18:46:43 +0100 Subject: [PATCH] SONAR-12874 redirect issues to hotspots --- .../src/main/js/app/utils/startReactApp.tsx | 353 ++++++++---------- 1 file changed, 158 insertions(+), 195 deletions(-) diff --git a/server/sonar-web/src/main/js/app/utils/startReactApp.tsx b/server/sonar-web/src/main/js/app/utils/startReactApp.tsx index 305bc7d75e0..d8fb504f091 100644 --- a/server/sonar-web/src/main/js/app/utils/startReactApp.tsx +++ b/server/sonar-web/src/main/js/app/utils/startReactApp.tsx @@ -19,6 +19,7 @@ */ /* eslint-disable react/jsx-sort-props */ import { Location } from 'history'; +import { pick } from 'lodash'; import * as React from 'react'; import { render } from 'react-dom'; import { HelmetProvider } from 'react-helmet-async'; @@ -67,7 +68,6 @@ import onboardingRoutes from '../../apps/tutorials/routes'; import usersRoutes from '../../apps/users/routes'; import webAPIRoutes from '../../apps/web-api/routes'; import webhooksRoutes from '../../apps/webhooks/routes'; -import { isSonarCloud } from '../../helpers/system'; import App from '../components/App'; import GlobalContainer from '../components/GlobalContainer'; import MigrationContainer from '../components/MigrationContainer'; @@ -87,6 +87,158 @@ const RouteWithChildRoutes = Route as React.ComponentClass< RouteProps & { childRoutes: RouteConfig } >; +function renderRedirects() { + return ( + <> + { + replace({ pathname: '/issues', query: { myIssues: 'true', resolved: 'false' } }); + }} + /> + + { + replace(`/coding_rules${window.location.hash}`); + }} + /> + + { + replace({ pathname: '/dashboard', query: { id: nextState.params.key } }); + }} + /> + + { + replace(`/issues${window.location.hash}`); + }} + /> + + + + + + + + + + + + + + + + + + + + + + + + + + + ); +} + +function renderComponentRoutes() { + return ( + import('../components/ComponentContainer'))}> + + + + + + import('../components/extensions/ProjectPageExtension'))} + /> + { + if (query.types) { + if (query.types === 'SECURITY_HOTSPOT') { + replace({ + pathname: '/security_hotspots', + query: { ...pick(query, ['id', 'branch', 'pullRequest']), assignedToMe: false } + }); + } else { + query.types = query.types + .split(',') + .filter((type: string) => type !== 'SECURITY_HOTSPOT') + .join(','); + } + } + }} + /> + + import('../../apps/securityHotspots/SecurityHotspotsApp') + )} + /> + + + import('../components/ProjectAdminContainer'))}> + + import('../components/extensions/ProjectAdminPageExtension'))} + /> + + + + + + + import('../../apps/projectDeletion/App'))} + /> + import('../../apps/projectLinks/App'))} + /> + import('../../apps/projectKey/Key'))} /> + + + ); +} + +function renderAdminRoutes() { + return ( + import('../components/AdminContainer'))} path="admin"> + import('../components/extensions/GlobalAdminPageExtension'))} + /> + + + + + + + + + + + + + ); +} + export default function startReactApp( lang: string, currentUser?: T.CurrentUser, @@ -103,61 +255,7 @@ export default function startReactApp( - { - replace({ pathname: '/issues', query: { myIssues: 'true', resolved: 'false' } }); - }} - /> - - { - replace('/coding_rules' + window.location.hash); - }} - /> - - { - replace({ pathname: '/dashboard', query: { id: nextState.params.key } }); - }} - /> - - { - replace('/issues' + window.location.hash); - }} - /> - - - - - - - - - - - - - - - - - - - - - - - - - + {renderRedirects()} - {!isSonarCloud() && ( - - )} + @@ -196,14 +292,6 @@ export default function startReactApp( /> - {isSonarCloud() && ( - - import('../../apps/create/organization/CreateOrganization') - )} - /> - )} @@ -211,137 +299,12 @@ export default function startReactApp( path="portfolios" component={lazyLoad(() => import('../components/extensions/PortfoliosPage'))} /> - {!isSonarCloud() && ( - - )} + - import('../components/ComponentContainer'))}> - - - - - - - import('../components/extensions/ProjectPageExtension') - )} - /> - - - import('../../apps/securityHotspots/SecurityHotspotsApp') - )} - /> - - - import('../components/ProjectAdminContainer'))}> - {!isSonarCloud() && ( - - )} - - import('../components/extensions/ProjectAdminPageExtension') - )} - /> - - - - - - - import('../../apps/projectDeletion/App'))} - /> - import('../../apps/projectLinks/App'))} - /> - import('../../apps/projectKey/Key'))} - /> - - + {renderComponentRoutes()} - import('../components/AdminContainer'))} - path="admin"> - - import('../components/extensions/GlobalAdminPageExtension') - )} - /> - - - {!isSonarCloud() && ( - <> - - - - - - )} - - - - - - + {renderAdminRoutes()}