-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Security Solution][Detections] Fix rule creation/editing forms #130825
[Security Solution][Detections] Fix rule creation/editing forms #130825
Conversation
Pinging @elastic/security-detections-response (Team:Detections and Resp) |
2cffc6e
to
4dbb898
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for breaking your form by making that change. 😞 I still think I'd like to keep the change in the form lib and not rely on controlling the form values by changing the defaultValue
object
const { form } = useForm({
defaultValue: { ... } // this object will always be new on re-render of the component
});
I am happy to zoom and have a look at your form to see why you rely on the defaultValue (which is normally only used to declare the initial values of the fields) to swap field values.
You can use either the reset()
method (which will also reset the states like isSubmitted
) or now the new updateFieldValues()
to update the form when needed.
Ping me if you want to zoom and have a look 😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved from quality perspective:
- Executed the Cypress tests on my local and worked fine
- Did a bit of exploratory testing and everything is working as expected. The only issue I found is the following one: [Security Solution] Not able to create a rule after adding an action and then change the frequency to
perform no actions
during the rule creation #130869 that I don't consider a blocker for this PR since it is already happening on previous versions.
Lots of thanks for the quick fix!!
c3d73cc
to
3dcef9a
Compare
@@ -29,7 +29,7 @@ import * as i18n from './translations'; | |||
export interface FieldValueQueryBar { | |||
filters: Filter[]; | |||
query: Query; | |||
saved_id?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI there is an option you can pass to the form to not strip undefined value (https://docs.elastic.dev/form-lib/core/use-form#stripemptyfields)
@@ -659,6 +659,15 @@ export function useForm<T extends FormData = FormData, I extends FormData = T>( | |||
// ---------------------------------- | |||
// -- EFFECTS | |||
// ---------------------------------- | |||
useEffect(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in my previous comment, please don't put the useEffect
back. We can discuss over Zoom how to solve your form without counting on this.
@sebelga thank you for your review. And sorry, I had to switch to another topic but will get back to this PR later, maybe next week or so. I think I'll need your help with this one so thank you for offering it 🙏 I'll ping you later, thanks again! |
c7bf08c
to
7bac4cf
Compare
7bac4cf
to
5e738f3
Compare
ca9c0dd
to
227376c
Compare
f90719b
to
34ec0a1
Compare
You won't solve the jest failure
until you remove the IMO you should first remove the change to the form lib before fixing the form. 😊 |
…ped recursively by the forms lib
34ec0a1
to
28c998a
Compare
💔 Build FailedFailed CI StepsTest Failures
Metrics [docs]Module Count
Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: cc @banderror |
**Addresses:** #130767, #130770 Related to [this PR](#130825). @banderror described the reason for the problems in his PR. There was [ask ](#130825 (review)) to not return the `useEffect` to the form lib. The fix of the form clears the values [in this commit](df0b7bb) Then I cherry-pick commits from @banderror PR to fix form stripping undefined values and also fixed some tests ### Checklist Delete any items that are not applicable to this PR. - [ ] [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
**Addresses:** #130767, #130770 Related to [this PR](#130825). @banderror described the reason for the problems in his PR. There was [ask ](#130825 (review)) to not return the `useEffect` to the form lib. The fix of the form clears the values [in this commit](df0b7bb) Then I cherry-pick commits from @banderror PR to fix form stripping undefined values and also fixed some tests ### Checklist Delete any items that are not applicable to this PR. - [ ] [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 (cherry picked from commit 52bdf9a)
Closing this PR as @nkhristinin fixed the issues in #132834 |
**Addresses:** elastic#130767, elastic#130770 Related to [this PR](elastic#130825). @banderror described the reason for the problems in his PR. There was [ask ](elastic#130825 (review)) to not return the `useEffect` to the form lib. The fix of the form clears the values [in this commit](elastic@df0b7bb) Then I cherry-pick commits from @banderror PR to fix form stripping undefined values and also fixed some tests ### Checklist Delete any items that are not applicable to this PR. - [ ] [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 (cherry picked from commit 52bdf9a)
**Addresses:** #130767, #130770 Related to [this PR](#130825). @banderror described the reason for the problems in his PR. There was [ask ](#130825 (review)) to not return the `useEffect` to the form lib. The fix of the form clears the values [in this commit](df0b7bb) Then I cherry-pick commits from @banderror PR to fix form stripping undefined values and also fixed some tests ### Checklist Delete any items that are not applicable to this PR. - [ ] [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 (cherry picked from commit 52bdf9a) Co-authored-by: Khristinin Nikita <[email protected]>
Addresses: #130767, #130770
Related to: #130771
Summary
A bug in the forms library presumably introduced in #130544 broke Rule Creation and Editing pages in Security Solution in the
main
branch. Cypress tests haven't been run in this PR, so it was merged which caused Cypress tests inmain
to start failing. @MadameSheema skipped those failing tests in #130771.This PR:
useForm
hook which has been deleted in [Form lib] Add "updateFieldValues" to the form hook API #130544.Changes in
src/plugins/es_ui_shared/static/forms/hook_form_lib/hooks/use_form.ts
@elastic/platform-deployment-management @sebelga @yuliacech please review the commit
Fix 1: get back the deleted effect in useForm
.In Security Solution, we have multiple forms on the same rule creation/editing page for every step of the creation/editing process. We show or hide the forms depending on which step is currently active, so only one of the forms is visible at the same time. Without the effect that was deleted previously in #130544, it seems the
useForm
hook doesn't work on the mentioned pages.