Code Insights: Adjust insight routes (#46228)

Adjust insight routes
This commit is contained in:
Vova Kulikov 2023-01-09 11:31:20 -03:00 committed by GitHub
parent 419eb52fff
commit 4ddf243b16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 20 deletions

View File

@ -49,23 +49,11 @@ export const CodeInsightsAppRouter = withAuthenticatedUser<CodeInsightsAppRouter
<Route path="*" component={GaConfirmationModal} />
<Switch>
<Route path={`${match.url}/create`}>
<CreationRoutes telemetryService={telemetryService} />
</Route>
<Route path={match.url} exact={true} component={CodeInsightsSmartRoutingRedirect} />
<Route
path={`${match.url}/insight/:id`}
render={props => (
<CodeInsightIndependentPage
insightId={props.match.params.id}
telemetryService={telemetryService}
/>
)}
/>
<Route
path={`${match.url}/edit/:insightId`}
render={props => <EditInsightLazyPage insightID={props.match.params.insightId} />}
path={`${match.url}/create`}
render={() => <CreationRoutes telemetryService={telemetryService} />}
/>
<Route
@ -89,14 +77,40 @@ export const CodeInsightsAppRouter = withAuthenticatedUser<CodeInsightsAppRouter
)}
/>
<Route path={match.url} exact={true} component={CodeInsightsRedirect} />
<Route
// Deprecated URL, delete this in the 4.10
path={`${match.url}/edit/:insightId`}
render={props => <Redirect to={`${match.url}/${props.match.params.insightId}/edit`} />}
/>
<Route
path={`${match.url}/:insightId/edit`}
render={props => <EditInsightLazyPage insightID={props.match.params.insightId} />}
/>
<Route
// Deprecated URL, delete this in the 4.10
path={`${match.url}/insight/:id`}
render={props => <Redirect to={`${match.url}/${props.match.params.id}`} />}
/>
<Route
path={`${match.url}/:id`}
render={props => (
<CodeInsightIndependentPage
insightId={props.match.params.id}
telemetryService={telemetryService}
/>
)}
/>
<Route render={() => <HeroPage icon={MapSearchIcon} title="404: Not Found" />} key="hardcoded-key" />
</Switch>
</CodeInsightsBackendContext.Provider>
)
})
const CodeInsightsRedirect: FC = () => {
const CodeInsightsSmartRoutingRedirect: FC = () => {
const match = useRouteMatch()
const state = useDashboardExistence()

View File

@ -161,7 +161,7 @@ export const BackendInsightView = forwardRef<HTMLElement, BackendInsightProps>((
<InsightCardHeader
title={
<Link
to={`${window.location.origin}/insights/insight/${insight.id}`}
to={`${window.location.origin}/insights/${insight.id}`}
target="_blank"
rel="noopener noreferrer"
>

View File

@ -89,7 +89,7 @@ export const InsightContextMenu: React.FunctionComponent<React.PropsWithChildren
as={Link}
data-testid="InsightContextMenuEditLink"
className={styles.item}
to={encodeDashboardIdQueryParam(`/insights/edit/${insight.id}`, currentDashboard?.id)}
to={encodeDashboardIdQueryParam(`/insights/${insight.id}/edit`, currentDashboard?.id)}
>
Edit
</MenuLink>

View File

@ -62,7 +62,7 @@ export const LangStatsInsightCard = forwardRef<HTMLElement, BuiltInInsightProps>
<InsightCardHeader
title={
<Link
to={`${window.location.origin}/insights/insight/${insight.id}`}
to={`${window.location.origin}/insights/${insight.id}`}
target="_blank"
rel="noopener noreferrer"
>