Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.x] [ResponseOps] [Rule Form] Move rule form steps to hook with pro…
…gress tracking (#205944) (#206346) # Backport This will backport the following commits from `main` to `8.x`: - [[ResponseOps] [Rule Form] Move rule form steps to hook with progress tracking (#205944)](#205944) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Zacqary Adam Xeper","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-01-10T21:08:14Z","message":"[ResponseOps] [Rule Form] Move rule form steps to hook with progress tracking (#205944)\n\n## Summary\r\n\r\nPart of #195211 \r\n\r\nIn preparation for the horizontal rule form layout, move the generation\r\nof the rule form steps into three hooks:\r\n\r\n- `useCommonRuleFormSteps`: private hook that generates a series of\r\nobjects specifying the rule form steps, how to display them, and what\r\norder to display them in\r\n- `useRuleFormSteps`: hook that calls `useCommonRuleFormSteps` and\r\ntransforms them into data for the standard vertical `EuiSteps`, along\r\nwith progress tracking based on `onBlur` events\r\n- `useRuleFormHorizontalSteps`: hook that calls hook that calls\r\n`useCommonRuleFormSteps` and transforms them into data for\r\n`EuiStepsHorizontal`, plus navigation functions. ***These will be used\r\nin the smaller rule form flyout in a second PR***\r\n\r\nBecause `EuiStepsHorizontal` rely more heavily on the `EuiSteps`\r\n`status` property, I took this opportunity to improve progress tracking\r\nin the standard vertical steps. Most rule types will load the create\r\npage with Step 1: Rule Definition already being in a `danger` state,\r\nbecause an incomplete rule definition component immediately sends\r\nerrors, and the error API doesn't distinguish between invalid data or\r\nincomplete data.\r\n\r\nThis PR wraps each step in a `reportOnBlur` higher-order component,\r\nwhich will report the first time a step triggers an `onBlur` event.\r\nSteps with errors will now report `incomplete` until they first trigger\r\nan `onBlur`. The result:\r\n\r\n1. The user loads the Create Rule page. Rule Definition is marked\r\n`incomplete`\r\n2. The user interacts with Rule Definition, but does not yet complete\r\nthe definition.\r\n3. The user interacts with the Actions step, the Rule Details step, or\r\nanother part of the page. The Rule Definition is now marked `danger`.\r\n\r\nThis is inelegant compared to an error API that can actually distinguish\r\nbetween an incomplete form and an invalid form, but it's an improvement\r\nfor now.\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <[email protected]>","sha":"d8b0b6e926f0198dd654cf5115af9660cb8ef663","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:ResponseOps","v9.0.0","Feature:Alerting/RulesManagement","backport:version","v8.18.0"],"title":"[ResponseOps] [Rule Form] Move rule form steps to hook with progress tracking","number":205944,"url":"https://github.com/elastic/kibana/pull/205944","mergeCommit":{"message":"[ResponseOps] [Rule Form] Move rule form steps to hook with progress tracking (#205944)\n\n## Summary\r\n\r\nPart of #195211 \r\n\r\nIn preparation for the horizontal rule form layout, move the generation\r\nof the rule form steps into three hooks:\r\n\r\n- `useCommonRuleFormSteps`: private hook that generates a series of\r\nobjects specifying the rule form steps, how to display them, and what\r\norder to display them in\r\n- `useRuleFormSteps`: hook that calls `useCommonRuleFormSteps` and\r\ntransforms them into data for the standard vertical `EuiSteps`, along\r\nwith progress tracking based on `onBlur` events\r\n- `useRuleFormHorizontalSteps`: hook that calls hook that calls\r\n`useCommonRuleFormSteps` and transforms them into data for\r\n`EuiStepsHorizontal`, plus navigation functions. ***These will be used\r\nin the smaller rule form flyout in a second PR***\r\n\r\nBecause `EuiStepsHorizontal` rely more heavily on the `EuiSteps`\r\n`status` property, I took this opportunity to improve progress tracking\r\nin the standard vertical steps. Most rule types will load the create\r\npage with Step 1: Rule Definition already being in a `danger` state,\r\nbecause an incomplete rule definition component immediately sends\r\nerrors, and the error API doesn't distinguish between invalid data or\r\nincomplete data.\r\n\r\nThis PR wraps each step in a `reportOnBlur` higher-order component,\r\nwhich will report the first time a step triggers an `onBlur` event.\r\nSteps with errors will now report `incomplete` until they first trigger\r\nan `onBlur`. The result:\r\n\r\n1. The user loads the Create Rule page. Rule Definition is marked\r\n`incomplete`\r\n2. The user interacts with Rule Definition, but does not yet complete\r\nthe definition.\r\n3. The user interacts with the Actions step, the Rule Details step, or\r\nanother part of the page. The Rule Definition is now marked `danger`.\r\n\r\nThis is inelegant compared to an error API that can actually distinguish\r\nbetween an incomplete form and an invalid form, but it's an improvement\r\nfor now.\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <[email protected]>","sha":"d8b0b6e926f0198dd654cf5115af9660cb8ef663"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/205944","number":205944,"mergeCommit":{"message":"[ResponseOps] [Rule Form] Move rule form steps to hook with progress tracking (#205944)\n\n## Summary\r\n\r\nPart of #195211 \r\n\r\nIn preparation for the horizontal rule form layout, move the generation\r\nof the rule form steps into three hooks:\r\n\r\n- `useCommonRuleFormSteps`: private hook that generates a series of\r\nobjects specifying the rule form steps, how to display them, and what\r\norder to display them in\r\n- `useRuleFormSteps`: hook that calls `useCommonRuleFormSteps` and\r\ntransforms them into data for the standard vertical `EuiSteps`, along\r\nwith progress tracking based on `onBlur` events\r\n- `useRuleFormHorizontalSteps`: hook that calls hook that calls\r\n`useCommonRuleFormSteps` and transforms them into data for\r\n`EuiStepsHorizontal`, plus navigation functions. ***These will be used\r\nin the smaller rule form flyout in a second PR***\r\n\r\nBecause `EuiStepsHorizontal` rely more heavily on the `EuiSteps`\r\n`status` property, I took this opportunity to improve progress tracking\r\nin the standard vertical steps. Most rule types will load the create\r\npage with Step 1: Rule Definition already being in a `danger` state,\r\nbecause an incomplete rule definition component immediately sends\r\nerrors, and the error API doesn't distinguish between invalid data or\r\nincomplete data.\r\n\r\nThis PR wraps each step in a `reportOnBlur` higher-order component,\r\nwhich will report the first time a step triggers an `onBlur` event.\r\nSteps with errors will now report `incomplete` until they first trigger\r\nan `onBlur`. The result:\r\n\r\n1. The user loads the Create Rule page. Rule Definition is marked\r\n`incomplete`\r\n2. The user interacts with Rule Definition, but does not yet complete\r\nthe definition.\r\n3. The user interacts with the Actions step, the Rule Details step, or\r\nanother part of the page. The Rule Definition is now marked `danger`.\r\n\r\nThis is inelegant compared to an error API that can actually distinguish\r\nbetween an incomplete form and an invalid form, but it's an improvement\r\nfor now.\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <[email protected]>","sha":"d8b0b6e926f0198dd654cf5115af9660cb8ef663"}},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Zacqary Adam Xeper <[email protected]>
- Loading branch information