Skip to content

fix(web): type renderPort as Port[], hoist to module scope, show all ports - #177

Merged
rodriguecyber merged 1 commit into
Open-Source-Kigali:developfrom
SurajPatelPro:fix/render-port-any-and-multiple-ports
Aug 31, 2026
Merged

fix(web): type renderPort as Port[], hoist to module scope, show all ports#177
rodriguecyber merged 1 commit into
Open-Source-Kigali:developfrom
SurajPatelPro:fix/render-port-any-and-multiple-ports

Conversation

@SurajPatelPro

Copy link
Copy Markdown

Summary

ContainerTable.tsx's renderPort:

  • took ports: any[], so a typo like .PublicPrt would have compiled fine and rendered undefined:... at runtime
  • was redefined inside the component body on every render despite closing over nothing
  • only ever read ports[0], silently hiding every other published port

Fixes all three:

  • Moved to module scope, next to NEEDS_ADMIN.
  • Typed with the existing Port type from types/api.ts.
  • Joins every mapping ("8080:80, 8443:443") instead of dropping all but the first.
  • PublicPort empty (exposed but not published) now renders just the private port instead of the previous bare ":80".

Left the port link's ports[0]?.PublicPort href untouched — that's owned by #157 per this issue's own cross-reference, and is a separable, larger decision (host-reachability question) that this PR shouldn't bundle in.

Closes #165

Test plan

  • npm run lint --workspace=@docksight/web — clean (pre-existing warnings elsewhere are unrelated to this file)
  • cd apps/web && npx tsc -b — clean
  • Manually verified the three cases the issue named: no ports (-), one port, and several ports, plus a port with an empty PublicPort

…ports

renderPort took `ports: any[]`, was redefined inside ContainerTable on
every render even though it closes over nothing, and only ever showed
ports[0] — a container publishing three ports rendered as if it
published one, with no indication of the rest.

Moved it to module scope next to the other helpers, typed the
parameter with the existing `Port` type from types/api.ts, and joined
every mapping instead of dropping all but the first. Also handles
PublicPort being empty (a port that's exposed but not published),
which previously rendered as a bare ":80" — it now renders just the
private port.

Closes Open-Source-Kigali#165
@rodriguecyber
rodriguecyber merged commit a1c3f81 into Open-Source-Kigali:develop Aug 31, 2026
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.

renderPort uses any[], is rebuilt every render, and hides all but the first port

2 participants