Skip to content

refactor to use existing sizeCellInner function more #3276

Closed

Description

@charliepark

As I was running #3214 through a few checks and the robot noticed that several locations in the codebase use variations of the code in sizeCellInner to render stylized "size + unit" text on the screen.

The pattern formatBytes(x) → {value} <span className="text-tertiary">{unit}</span> is hand-rolled in several places rather than going through sizeCellInner:

- InstanceResourceCell.tsx:22 — {memory.value} <span className="text-tertiary">{memory.unit}</span>. This is byte-identical to sizeCellInner's output and could just be sizeCellInner(value.memory). The one exact duplicate.
- InstancesPage.tsx:117-120 (memory column) — same shape but the unit span adds ml-1 on top of the literal space, so it's a double gap. Near-duplicate, not identical.
- InstancePage.tsx:222-224 (ram) — split into a text-default span plus a text-tertiary ml-1 span with a leading space.
- SledPage.tsx:78-79 (usable physical ram) — text-default pr-0.5 + text-tertiary.
- SiloQuotasTab.tsx:35 — its own Unit = classed.span\ml-1 text-secondary`(note:text-secondary, not text-tertiary`).

I haven't verified each of these locations, but it seems like we could clean them up pretty easily.

Also note that "sizeCellInner" might make more sense with a different name (and possibly located elsewhere) once these various places in the UI are updated to use the common component / helper.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions