iloveeyjafjalla opened a new pull request, #6739:
URL: https://github.com/apache/rocketmq-dashboard/pull/6739

   ### Which Issue(s) This PR Fixes
   
   - Fixes #6738
   
   ### Brief Description
   
   The Metrics Explorer printed every instant it shows with 
`Date.toLocaleString(locale)`, so the same
   stored value read `2027/1/15 15:00:00` in the Chinese console and 
`1/15/2027, 3:00:00 PM` in the
   English one, while every other timestamp surface in the console prints the 
stable
   `YYYY-MM-DD HH:mm:ss` the shared formatter produces. #6479 changed exactly 
this for the LiteTopic
   instants yesterday, and #5225 / #4234 / #4221 did it for other pages; this 
is the remaining surface.
   
   - `web/src/components/MetricsExplorer.tsx`: `formatSeconds` and 
`formatMillis` keep their unit — epoch
     seconds and epoch milliseconds — and now go through `formatUtcDateTime(new 
Date(...))`, which renders
     the instant in the viewer's zone as `YYYY-MM-DD HH:mm:ss`.
   - The four call sites are unchanged: the result table's sample column, the 
info popover's
     query window / query time / first / last sample lines, the 指标查询历史 modal 
and the details panel.
   - The chart axis label stays locale-aware on purpose 
(`toLocaleTimeString(locale, { hour, minute })`):
     an axis tick is a short local label, not a data instant.
   
   ### How Did You Test This Change?
   
   Red first, on the current `rocketmq-studio` tip, with the added case in 
place and only the component
   reverted:
   
   ```
   $ cd web && npx vitest run src/components/__tests__/MetricsExplorer.test.tsx 
--maxWorkers=1 -t "renders metric instants"
    × renders metric instants through the shared formatter instead of the 
locale string
      TestingLibraryElementError: Unable to find an element with the text: 
/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/.
    Test Files  1 failed (1)
   ```
   
   Green with the change:
   
   ```
   $ cd web && npx vitest run src/components/__tests__/MetricsExplorer.test.tsx 
--maxWorkers=1
    Test Files  1 passed (1)
         Tests  53 passed (53)
   $ npx tsc -b          (clean)
   $ npx eslint src/components/MetricsExplorer.tsx 
src/components/__tests__/MetricsExplorer.test.tsx
     (clean)
   $ npx prettier --check src/components/MetricsExplorer.tsx 
src/components/__tests__/MetricsExplorer.test.tsx
    All matched files use Prettier code style!
   ```
   
   The case runs a custom PromQL query, opens the panel's info popover and 
asserts the rendered instants
   match `^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$` while no `YYYY/M/D` or 
`M/D/YYYY` string is present — the
   format is the assertion, so it holds in any viewer time zone instead of 
depending on the CI machine's.
   
   Against a running console (this branch served by the Vite dev server, one 
entry seeded into
   `rocketmq-studio-metrics-query-history` with `queriedAt` 1800000000000 and 
the window
   1799996400-1800000000), the 指标查询历史 modal renders:
   
   ```
   2027-01-15 15:00:00 - 2027-01-15 16:00:00 · 2027-01-15 16:00:00
   ```
   
   (UTC+8 viewer; the same instants read `2027/1/15 15:00:00` before the 
change.)
   
   ### Checklist
   
   - [x] One coherent change; unrelated modifications are not bundled in
   - [x] Commit subject follows Conventional Commits (`fix(metrics): ...`)
   - [x] Tests added or updated for non-trivial changes — the new case pins the 
rendered format for the
         instants the panel shows; the existing 53 cases still pass unchanged
   - [x] New UI text has both Chinese and English entries under `web/src/i18n/` 
— no UI text changed
   - [x] Architecture constraints stay green — no Java/backend change, so the 
ArchUnit checks are untouched
   - [x] New source files carry the ASF license header — no new files
   - [x] Documentation touched where behaviour changed — not applicable; the 
same instants render in the
         shared format
   
   Disclosed rather than left to be discovered on merge: #5728 (open, "survive 
blocked browser storage")
   also edits `MetricsExplorer.tsx` and its test, around the storage helpers 
rather than the formatters, so
   whichever merges second needs a small rebase at most.
   
   AI assistance: the analysis, the change and the tests were produced with AI 
assistance (an agent working
   in this repository) and reviewed by me before submission; the command output 
above is from the actual runs.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to