Skip to content

feat: abstract routing configuration and URI parameter access (#48)#392

Open
igoroctaviano wants to merge 1 commit into
masterfrom
feat/48-abstract-routing
Open

feat: abstract routing configuration and URI parameter access (#48)#392
igoroctaviano wants to merge 1 commit into
masterfrom
feat/48-abstract-routing

Conversation

@igoroctaviano

Copy link
Copy Markdown
Collaborator

Summary

Resolves #48. The URI template /studies/:studyInstanceUID/series/:seriesInstanceUID (and its GCP DICOM store variant) was assumed/hardcoded in several places and re-parsed by hand, making routing changes error-prone.

This introduces src/utils/routes.ts as a single source of truth for:

  • Route templates (RoutePaths) consumed by react-router <Route path> definitions, with parameter names centralized in RouteParams.
  • Path builders: buildStudyPath, buildSeriesPath, buildLogoutPath.
  • Parsers / predicates: parseSeriesInstanceUID, hasSeriesInPath, isProjectsPath, getProjectStorePath, withSeriesInProjectPath, isViewerPath, isGcpDicomStorePath.

Refactored to use the abstraction

  • App.tsx<Route> paths (ROOT, STUDY, GCP_STUDY, LOGOUT) and GCP client base-URL derivation.
  • components/CaseViewer.tsx — series-selection URL building, series parsing, and nested SERIES route (removed ad-hoc interpolation + regex).
  • components/Worklist.tsx — study navigation.
  • components/Header.tsx — DICOM Tag Browser visibility, series parsing, and GCP server-URL validation (removed the local DICOM_TAG_BROWSER_PATHS constant).
  • auth/OidcManager.tsxpost_logout_redirect_uri.

No behavior change — paths produced/parsed are identical to before; the logic is just centralized.

Test plan

  • pnpm run typecheck passes
  • pnpm run lint (biome) passes
  • pnpm test — all 53 tests pass, including new src/utils/__tests__/routes.test.ts (22 assertions covering builders, parsers, and predicates)
  • Manual: open a study from the worklist, switch series, open DICOM Tag Browser, and verify GCP projects/.../dicomStores/... deep links still route correctly

Introduce src/utils/routes.ts as a single source of truth for route
templates, path builders, and URI parameter parsing. Previously the
/studies/:studyInstanceUID/series/:seriesInstanceUID template (and its
GCP DICOM store variant) was hardcoded and re-parsed by hand across
App, CaseViewer, Worklist, Header, and OidcManager, making routing
changes error-prone.

Components now consume RoutePaths for <Route> definitions and the
buildStudyPath/buildSeriesPath/buildLogoutPath builders plus
parse/predicate helpers instead of ad-hoc string interpolation,
split(), includes(), and regex replacement.

Add unit tests for the new routing helpers.

Closes #48
@sonarqubecloud

Copy link
Copy Markdown

@deepsource-io

deepsource-io Bot commented Jun 22, 2026

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in 3faa989...2b65892 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
JavaScript Jun 22, 2026 10:40p.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Abstract routing configuration and access to URI parameters

1 participant