[ResponseOps][MaintenanceWindows] Move recurring schedule form to dedicated package#220535
Conversation
…urring-schedule-form-to-package
|
Pinging @elastic/response-ops (Team:ResponseOps) |
...es/shared/response-ops/recurring-schedule-form/components/custom_recurring_schedule.test.tsx
Outdated
Show resolved
Hide resolved
| target: { value: Frequency.MONTHLY }, | ||
| } | ||
| ); | ||
| await waitFor(() => expect(screen.getByTestId('bymonth-field')).toBeInTheDocument()); |
There was a problem hiding this comment.
| await waitFor(() => expect(screen.getByTestId('bymonth-field')).toBeInTheDocument()); | |
| expect(await screen.findByTestId('bymonth-field')).toBeInTheDocument(); |
| return ( | ||
| <UseField<RecurringSchedule, FormProps> path={path}> | ||
| {({ value, setValue, setErrors }) => ( | ||
| <RecurringScheduleForm |
There was a problem hiding this comment.
I tried to change the recurring schedule form as little as possible, keeping the existing form-lib-based implementation and adding an intermediate layer to embed the editing UI in larger forms (i.e., MW form). While this is not particularly elegant, it allows us to build on top of an existing, tested codebase and to leverage form-lib's validation and state management capabilities.
I am still a bit unsure about this.
I'll up my conclusions after reading the code, and let me know if they are right:
RecurringSchedulewas previously used in MWRecurringScheduleused to be just a wrapper around multipleUseFields.RecurringSchedulewas moved to a package and wrapped in<Form>.
Now, in MW we have something like:
<Form> // <CreateMaintenanceWindowForm>
...
<ABunchOfOtherFields>
...
<UseField> // <RecurringScheduleField>
<Form> // <RecurringScheduleForm>
<UseField> // the same as the previous RecurringSchedule implementation
...
I'm not sure I like the Form > UseField > Form approach, or rather, I'm unsure what to expect in its behavior.
For example, the recurringSchedule schema was removed from maintenance_windows/components/schema.ts, which now comes from RecurringScheduleForm. What should be expected when submitting CreateMaintenanceWindowForm?
Validation appears to be working fine(I tested the PR a bit), but maybe there is a simpler solution.
Why not split RecurringScheduleForm in the package into Form and Fields, and import here only the fields(similar to what was done before)?
There was a problem hiding this comment.
I'm not sure I like the Form > UseField > Form approach, I'm unsure what to expect in its behavior.
+1 on that. This would be a simpler solution to have Fields (frequency, interval etc.) as one component which could be used in RecurringScheduleForm and imported to MW and used directly in CreateMaintenanceWindowForm.
There was a problem hiding this comment.
Although not very elegant, the intention was to hide the form lib editing functionality inside the schedule component and just expose a value/onChange prop API to the exterior so the same component could be used in other types of forms or editing UIs too. Since all the forms that use this schedule fields are currently all form-lib-based, and you too have doubts on the encapsulated solution, I switched to exporting the schema and the fields separately. We can always move to a more generic solution later if needed.
...hared/alerting/public/pages/maintenance_windows/components/recurring_schedule_field.test.tsx
Outdated
Show resolved
Hide resolved
js-jankisalvi
left a comment
There was a problem hiding this comment.
Verified locally, works as expected. Had only one concern about wrapping a form inside field mentioned above
…urring-schedule-form-to-package
b1f975d to
55c5526
Compare
💚 Build Succeeded
Metrics [docs]Module Count
Async chunks
Unknown metric groupsESLint disabled line counts
Total ESLint disabled count
History
|
|
Starting backport for target branches: 8.19 |
💔 All backports failed
Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…icated package (elastic#220535) ## Summary Moves the recurring schedule (rrule) form from the Maintenance Windows form to a dedicated package. ## Implementation details ~~Because of the tight time constraints we have for this epic, I tried to change the recurring schedule form as little as possible, keeping the existing form-lib-based implementation and adding an intermediate layer to embed the editing UI in larger forms (i.e. MW form). While this is not particularly elegant, it allows us to build on top of an existing, tested codebase and to leverage form-lib's validation and state management capabilities.~~ ~~In the context of the MW form, the recurring schedule editor is treated as a single field. Value and error updates are synced through form-lib's field hook API:~~ https://github.com/elastic/kibana/blob/acd6a4823e5b9c53ae7cbed59a246972ab32cfe0/x-pack/platform/plugins/shared/alerting/public/pages/maintenance_windows/components/recurring_schedule_field.tsx#L21-L34 ~~Errors are handled internally by the schedule editor, but must still be surfaced up to the parent form in order to have a consistent validity state (otherwise submits are not prevented even if errors are shown in the UI).~~ The recurring schedule form schema and form fields are exported to be reused in larger form-lib forms. ## References Closes elastic#219454 ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit 664a435) # Conflicts: # src/platform/packages/shared/response-ops/recurring-schedule-form/utils/convert_to_rrule.ts # src/platform/packages/shared/response-ops/recurring-schedule-form/utils/parse_schedule.ts # src/platform/packages/shared/response-ops/recurring-schedule-form/utils/recurring_summary.ts # x-pack/platform/plugins/shared/alerting/public/pages/maintenance_windows/components/recurring_schedule_form/custom_recurring_schedule.test.tsx # x-pack/platform/plugins/shared/alerting/public/pages/maintenance_windows/components/recurring_schedule_form/custom_recurring_schedule.tsx # x-pack/platform/plugins/shared/alerting/public/pages/maintenance_windows/components/recurring_schedule_form/recurring_schedule.test.tsx # x-pack/platform/plugins/shared/alerting/public/pages/maintenance_windows/components/recurring_schedule_form/recurring_schedule.tsx # x-pack/platform/plugins/shared/alerting/public/pages/maintenance_windows/constants.ts
… to dedicated package (#220535) (#223203) # Backport This will backport the following commits from `main` to `8.19`: - [[ResponseOps][MaintenanceWindows] Move recurring schedule form to dedicated package (#220535)](#220535) <!--- Backport version: 10.0.0 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Umberto Pepato","email":"umbopepato@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-06-10T08:50:22Z","message":"[ResponseOps][MaintenanceWindows] Move recurring schedule form to dedicated package (#220535)\n\n## Summary\n\nMoves the recurring schedule (rrule) form from the Maintenance Windows\nform to a dedicated package.\n\n## Implementation details\n\n~~Because of the tight time constraints we have for this epic, I tried\nto change the recurring schedule form as little as possible, keeping the\nexisting form-lib-based implementation and adding an intermediate layer\nto embed the editing UI in larger forms (i.e. MW form). While this is\nnot particularly elegant, it allows us to build on top of an existing,\ntested codebase and to leverage form-lib's validation and state\nmanagement capabilities.~~\n\n~~In the context of the MW form, the recurring schedule editor is\ntreated as a single field. Value and error updates are synced through\nform-lib's field hook API:~~\n\n\nhttps://github.com/elastic/kibana/blob/acd6a4823e5b9c53ae7cbed59a246972ab32cfe0/x-pack/platform/plugins/shared/alerting/public/pages/maintenance_windows/components/recurring_schedule_field.tsx#L21-L34\n\n~~Errors are handled internally by the schedule editor, but must still\nbe surfaced up to the parent form in order to have a consistent validity\nstate (otherwise submits are not prevented even if errors are shown in\nthe UI).~~\n\nThe recurring schedule form schema and form fields are exported to be\nreused in larger form-lib forms.\n\n## References\n\nCloses #219454\n\n### Checklist\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"664a435e6c20444217c9215bfa280c3f8fe9320e","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:ResponseOps","backport:version","v9.1.0","v8.19.0"],"title":"[ResponseOps][MaintenanceWindows] Move recurring schedule form to dedicated package","number":220535,"url":"https://github.com/elastic/kibana/pull/220535","mergeCommit":{"message":"[ResponseOps][MaintenanceWindows] Move recurring schedule form to dedicated package (#220535)\n\n## Summary\n\nMoves the recurring schedule (rrule) form from the Maintenance Windows\nform to a dedicated package.\n\n## Implementation details\n\n~~Because of the tight time constraints we have for this epic, I tried\nto change the recurring schedule form as little as possible, keeping the\nexisting form-lib-based implementation and adding an intermediate layer\nto embed the editing UI in larger forms (i.e. MW form). While this is\nnot particularly elegant, it allows us to build on top of an existing,\ntested codebase and to leverage form-lib's validation and state\nmanagement capabilities.~~\n\n~~In the context of the MW form, the recurring schedule editor is\ntreated as a single field. Value and error updates are synced through\nform-lib's field hook API:~~\n\n\nhttps://github.com/elastic/kibana/blob/acd6a4823e5b9c53ae7cbed59a246972ab32cfe0/x-pack/platform/plugins/shared/alerting/public/pages/maintenance_windows/components/recurring_schedule_field.tsx#L21-L34\n\n~~Errors are handled internally by the schedule editor, but must still\nbe surfaced up to the parent form in order to have a consistent validity\nstate (otherwise submits are not prevented even if errors are shown in\nthe UI).~~\n\nThe recurring schedule form schema and form fields are exported to be\nreused in larger form-lib forms.\n\n## References\n\nCloses #219454\n\n### Checklist\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"664a435e6c20444217c9215bfa280c3f8fe9320e"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/220535","number":220535,"mergeCommit":{"message":"[ResponseOps][MaintenanceWindows] Move recurring schedule form to dedicated package (#220535)\n\n## Summary\n\nMoves the recurring schedule (rrule) form from the Maintenance Windows\nform to a dedicated package.\n\n## Implementation details\n\n~~Because of the tight time constraints we have for this epic, I tried\nto change the recurring schedule form as little as possible, keeping the\nexisting form-lib-based implementation and adding an intermediate layer\nto embed the editing UI in larger forms (i.e. MW form). While this is\nnot particularly elegant, it allows us to build on top of an existing,\ntested codebase and to leverage form-lib's validation and state\nmanagement capabilities.~~\n\n~~In the context of the MW form, the recurring schedule editor is\ntreated as a single field. Value and error updates are synced through\nform-lib's field hook API:~~\n\n\nhttps://github.com/elastic/kibana/blob/acd6a4823e5b9c53ae7cbed59a246972ab32cfe0/x-pack/platform/plugins/shared/alerting/public/pages/maintenance_windows/components/recurring_schedule_field.tsx#L21-L34\n\n~~Errors are handled internally by the schedule editor, but must still\nbe surfaced up to the parent form in order to have a consistent validity\nstate (otherwise submits are not prevented even if errors are shown in\nthe UI).~~\n\nThe recurring schedule form schema and form fields are exported to be\nreused in larger form-lib forms.\n\n## References\n\nCloses #219454\n\n### Checklist\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"664a435e6c20444217c9215bfa280c3f8fe9320e"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
…icated package (elastic#220535) ## Summary Moves the recurring schedule (rrule) form from the Maintenance Windows form to a dedicated package. ## Implementation details ~~Because of the tight time constraints we have for this epic, I tried to change the recurring schedule form as little as possible, keeping the existing form-lib-based implementation and adding an intermediate layer to embed the editing UI in larger forms (i.e. MW form). While this is not particularly elegant, it allows us to build on top of an existing, tested codebase and to leverage form-lib's validation and state management capabilities.~~ ~~In the context of the MW form, the recurring schedule editor is treated as a single field. Value and error updates are synced through form-lib's field hook API:~~ https://github.com/elastic/kibana/blob/acd6a4823e5b9c53ae7cbed59a246972ab32cfe0/x-pack/platform/plugins/shared/alerting/public/pages/maintenance_windows/components/recurring_schedule_field.tsx#L21-L34 ~~Errors are handled internally by the schedule editor, but must still be surfaced up to the parent form in order to have a consistent validity state (otherwise submits are not prevented even if errors are shown in the UI).~~ The recurring schedule form schema and form fields are exported to be reused in larger form-lib forms. ## References Closes elastic#219454 ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
…icated package (elastic#220535) ## Summary Moves the recurring schedule (rrule) form from the Maintenance Windows form to a dedicated package. ## Implementation details ~~Because of the tight time constraints we have for this epic, I tried to change the recurring schedule form as little as possible, keeping the existing form-lib-based implementation and adding an intermediate layer to embed the editing UI in larger forms (i.e. MW form). While this is not particularly elegant, it allows us to build on top of an existing, tested codebase and to leverage form-lib's validation and state management capabilities.~~ ~~In the context of the MW form, the recurring schedule editor is treated as a single field. Value and error updates are synced through form-lib's field hook API:~~ https://github.com/elastic/kibana/blob/acd6a4823e5b9c53ae7cbed59a246972ab32cfe0/x-pack/platform/plugins/shared/alerting/public/pages/maintenance_windows/components/recurring_schedule_field.tsx#L21-L34 ~~Errors are handled internally by the schedule editor, but must still be surfaced up to the parent form in order to have a consistent validity state (otherwise submits are not prevented even if errors are shown in the UI).~~ The recurring schedule form schema and form fields are exported to be reused in larger form-lib forms. ## References Closes elastic#219454 ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
## Summary > [!IMPORTANT] > This PR is targeting the `scheduled-reports-ui` feature branch, where the backend changes from the `scheduled-reports` branch are temporarily integrated while waiting for #221028 to be merged (see the squashed `[TMP] ...` commit message). Implements the flyout UI for the creation and read-only viewing of scheduled reports (exports). <img height="500" alt="image" src="https://github.com/user-attachments/assets/6bbd274b-1bbb-481f-ac40-4d7131be6d85" /> <details> <summary> ## Known issues </summary> - Console error due to `compressed` attribute wrongly forwarded by form-hook-lib to DOM element (this is likely a form lib issue): <img width="916" alt="image" src="https://github.com/user-attachments/assets/09d20ba9-8781-46d6-bcfa-862d8a4cbf90" /> - Email validation errors accumulate instead of replacing the previous one (again looks like a fom lib issue): https://github.com/user-attachments/assets/f2dc7a46-a3a9-465d-b8a1-3187b200f9b9 </details> <details> <summary> ## Screenshots </summary> Health API error: <img height="500" alt="Screenshot 2025-05-31 at 10 48 40" src="https://github.com/user-attachments/assets/dd069597-971c-489f-9c07-eb5edfd7bede" /> Health API loading state: <img height="500" alt="Screenshot 2025-05-31 at 10 49 04" src="https://github.com/user-attachments/assets/27d95bf3-bf7d-42c7-9a40-2826f38aa837" /> Health API success with some missing prerequisites: <img width="449" alt="Screenshot 2025-06-17 at 16 59 57" src="https://github.com/user-attachments/assets/c44afa97-70ff-4618-8b73-41b816514459" /> Form validation: <img height="500" alt="image" src="https://github.com/user-attachments/assets/a8d4cae1-2819-4f71-a911-9300a6cf81f8" /> Success toast: <img width="480" alt="image" src="https://github.com/user-attachments/assets/a87c3af5-dbb0-40e8-915a-fc9d7e1d97f2" /> Failure toast: <img width="518" alt="image" src="https://github.com/user-attachments/assets/908f9dea-b5cb-4da9-b4a5-76e313837f18" /> Print format toggle: <img width="502" alt="image" src="https://github.com/user-attachments/assets/602f3ab9-07ef-4689-a305-dc1b2b5495cd" /> Missing notifications email connector callout: <img width="499" alt="image" src="https://github.com/user-attachments/assets/fe4997a5-75e6-4450-85e5-7d853049e085" /> </details> ## References Closes #216321 Stacked on #220535 --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Eyo O. Eyo <7893459+eokoneyo@users.noreply.github.com>
Summary
Moves the recurring schedule (rrule) form from the Maintenance Windows form to a dedicated package.
Implementation details
Because of the tight time constraints we have for this epic, I tried to change the recurring schedule form as little as possible, keeping the existing form-lib-based implementation and adding an intermediate layer to embed the editing UI in larger forms (i.e. MW form). While this is not particularly elegant, it allows us to build on top of an existing, tested codebase and to leverage form-lib's validation and state management capabilities.In the context of the MW form, the recurring schedule editor is treated as a single field. Value and error updates are synced through form-lib's field hook API:kibana/x-pack/platform/plugins/shared/alerting/public/pages/maintenance_windows/components/recurring_schedule_field.tsx
Lines 21 to 34 in acd6a48
Errors are handled internally by the schedule editor, but must still be surfaced up to the parent form in order to have a consistent validity state (otherwise submits are not prevented even if errors are shown in the UI).The recurring schedule form schema and form fields are exported to be reused in larger form-lib forms.
References
Closes #219454
Checklist