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

   Fixes #3165
   
   ## Summary
   
   Maintenance windows (alert silences) can now be edited after creation 
instead of
   only being ended. The silence form in the System Alerts page gains an 
**Edit**
   action per window; opening it prefills the existing window (times converted 
from
   stored UTC into the window's time zone, scope fields, recurrence settings and
   reason) and submits an update.
   
   Backend:
   
   - `UpdateAlertSilenceDTO` carries the window `id` plus the same editable 
fields
     as `CreateAlertSilenceDTO`.
   - `POST /api/alert-silences/update` updates an existing window.
   - `AlertSilenceService.update` loads the current record (404 when missing),
     reuses the exact create-time validation (end after start, valid IANA time
     zone, recurrence end required and after the first window, daily/weekly 
window
     duration caps, ISO weekdays 1-7, bounded labels/reason), and preserves the
     original `id`, `creator` and `gmt_create`.
   - Updates are written to the operation audit log as `UPDATE_ALERT_SILENCE` /
     `ALERT_SILENCE`, mirroring the existing create/delete audit entries.
   - `MybatisPlusAlertSilenceRepository.update` sets every editable column
     explicitly via `UpdateWrapper`, so clearing a scope (e.g. empty labels,
     `ONCE` recurrence) is persisted as SQL `NULL` instead of being skipped by
     MyBatis-Plus `updateById`'s null-field strategy; `created_by` is never
     touched.
   
   Frontend:
   
   - `updateAlertSilence` API function and mock-mode service support.
   - Edit button next to the existing End action; the create/update form is
     prefilled and the modal switches to Update mode, then refreshes the list.
   
   ## Why
   
   Maintenance windows are used to suppress notifications during planned work.
   Today an admin who mistypes a time, needs a different scope, or wants to
   reschedule a recurring window must delete the window and recreate it, losing
   the original record id and creator and requiring the whole form to be filled
   again. Editing reuses all create-time validation so an invalid edit can never
   produce an invalid window.
   
   ## Testing
   
   - Backend (`mvn test 
-Dtest=AlertSilenceServiceTest,AlertSilenceControllerTest,MybatisPlusAlertSilenceRepositoryTest`):
     - update succeeds and keeps the original id/creator; audit records
       `UPDATE_ALERT_SILENCE`.
     - update of an unknown id returns 404; missing id is rejected.
     - invalid recurrence (weekly without weekdays) is rejected by the shared
       validation and nothing is persisted.
     - repository update sets every editable column explicitly (including null
       clears) and never sets `created_by`/`gmt_create`; `findById` restores the
       VO.
     - controller binds `POST /api/alert-silences/update`, returns the updated
       schedule, and rejects a body without `id` with 400.
   - Frontend (`vitest run src/api/ops.test.ts 
src/pages/ops/__tests__/SystemAlertsPage.test.tsx`):
     - the update API posts to `/alert-silences/update`.
     - page test: clicking Edit prefills the weekly window in its IANA time 
zone,
       submitting calls `updateAlertSilence` with converted UTC instants and the
       original recurrence scope, does not call create, refreshes the list and
       shows the success message.
   - `tsc -b tsconfig.app.json` passes.
   


-- 
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