Skip to content
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

[Response Ops] [Rule Form] Add Show Request and Add Action screens to flyout #206154

Merged
merged 23 commits into from
Jan 22, 2025

Conversation

Zacqary
Copy link
Contributor

@Zacqary Zacqary commented Jan 10, 2025

Summary

Part of #195211

  • Adds Show Request screen to the new rule form flyout
Screenshot Screenshot 2025-01-10 at 1 30 15 PM
  • Renders the action connectors UI within the flyout instead of opening a modal
Screenshot Screenshot 2025-01-10 at 1 28 38 PM
  • Duplicates the dropdown filter design from the flyout UI within the action connectors modal when displayed on a smaller screen
Screenshot Screenshot 2025-01-10 at 1 30 28 PM

Implementation notes

In order to get the action connectors UI to render the same way in both a modal and the flyout, without duplicating a large amount of code, I had to introduce a little bit of complexity. Within the Rule Page, it's as simple as opening the UI inside a modal, but the flyout cannot open a second flyout; it has to know when and how to completely replace its own contents.

  • The bulk of the action connectors UI is now moved to <RuleActionsConnectorsBody>. <RuleActionsConnectorsModal> and <RuleFlyoutSelectConnector> act as wrappers for this component.
  • The <RuleActions> step no longer handles rendering the connector UI, because it's not at a high enough level to know if it's in the <RulePage> or the <RuleFlyout>. Instead, it simply sends a signal up the context hierarchy to setIsConnectorsScreenVisible.
  • A new context called RuleFormScreenContext keeps track of isConnectorsScreenVisible, a state for whether or not the action connectors "screen" is open, regardless of whether that screen is displayed in a modal or a flyout.
  • The Rule Page uses isConnectorsScreenVisible to determine whether to render the modal. This works the same way as it used to, but handled by the <RulePage> instead of the <RuleActions> component.
  • The Rule Flyout uses isConnectorsScreenVisible to determine whether to continue to render <RuleFlyoutBody> or to completely replace its contents with <RuleFlyoutSelectConnector>

For consistency, this PR also moves the Show Request modal/flyout screen into the same system.

Testing

To test the new flyout, edit packages/response-ops/rule_form/src/create_rule_form.tsx and packages/response-ops/rule_form/src/edit_rule_form.tsx so that they render <RuleFlyout> instead of <RulePage>.

Use this diff block
diff --git a/packages/response-ops/rule_form/src/create_rule_form.tsx b/packages/response-ops/rule_form/src/create_rule_form.tsx
index 2f5e0472dcd..564744b96ec 100644
--- a/packages/response-ops/rule_form/src/create_rule_form.tsx
+++ b/packages/response-ops/rule_form/src/create_rule_form.tsx
@@ -31,6 +31,7 @@ import {
   parseRuleCircuitBreakerErrorMessage,
 } from './utils';
 import { RULE_CREATE_SUCCESS_TEXT, RULE_CREATE_ERROR_TEXT } from './translations';
+import { RuleFlyout } from './rule_flyout';
 
 export interface CreateRuleFormProps {
   ruleTypeId: string;
@@ -199,7 +200,7 @@ export const CreateRuleForm = (props: CreateRuleFormProps) => {
           }),
         }}
       >
-        <RulePage isEdit={false} isSaving={isSaving} onCancel={onCancel} onSave={onSave} />
+        <RuleFlyout isEdit={false} isSaving={isSaving} onCancel={onCancel} onSave={onSave} />
       </RuleFormStateProvider>
     </div>
   );
diff --git a/packages/response-ops/rule_form/src/edit_rule_form.tsx b/packages/response-ops/rule_form/src/edit_rule_form.tsx
index 392447114ed..41aecd7245a 100644
--- a/packages/response-ops/rule_form/src/edit_rule_form.tsx
+++ b/packages/response-ops/rule_form/src/edit_rule_form.tsx
@@ -26,6 +26,7 @@ import {
 import { RULE_EDIT_ERROR_TEXT, RULE_EDIT_SUCCESS_TEXT } from './translations';
 import { getAvailableRuleTypes, parseRuleCircuitBreakerErrorMessage } from './utils';
 import { DEFAULT_VALID_CONSUMERS, getDefaultFormData } from './constants';
+import { RuleFlyout } from './rule_flyout';
 
 export interface EditRuleFormProps {
   id: string;
@@ -193,7 +194,7 @@ export const EditRuleForm = (props: EditRuleFormProps) => {
           showMustacheAutocompleteSwitch,
         }}
       >
-        <RulePage isEdit={true} isSaving={isSaving} onSave={onSave} onCancel={onCancel} />
+        <RuleFlyout isEdit={true} isSaving={isSaving} onSave={onSave} onCancel={onCancel} />
       </RuleFormStateProvider>
     </div>
   );

Still Todo

  1. Replace all instances of the v1 rule flyout with this new one (it's used heavily in solutions, not in Stack Management)

Checklist

@Zacqary Zacqary added release_note:skip Skip the PR/issue when compiling release notes Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v9.0.0 Feature:Alerting/RulesManagement Issues related to the Rules Management UX v8.18.0 labels Jan 10, 2025
@Zacqary Zacqary force-pushed the 195211-demodalize-flyout branch 3 times, most recently from 2191969 to 553f892 Compare January 13, 2025 18:37
@Zacqary Zacqary force-pushed the 195211-demodalize-flyout branch from 553f892 to ddca944 Compare January 15, 2025 15:39
@Zacqary Zacqary force-pushed the 195211-demodalize-flyout branch from ddca944 to fb3027e Compare January 15, 2025 15:44
@Zacqary Zacqary marked this pull request as ready for review January 15, 2025 15:44
@Zacqary Zacqary requested review from a team as code owners January 15, 2025 15:45
@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops (Team:ResponseOps)

@Zacqary Zacqary added the backport:version Backport to applied version labels label Jan 15, 2025
Copy link
Contributor

@ryankeairns ryankeairns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SCSS

Congrats on breaking ground with container queries :)

@ryankeairns
Copy link
Contributor

@joana-cps fyi if you'd like to QA the design; I approved only the SCSS change.

@cnasikas cnasikas requested a review from jcger January 16, 2025 09:23
@jcger
Copy link
Contributor

jcger commented Jan 17, 2025

Screenshot 2025-01-17 at 09 56 30

I'm seeing the flyout like this after applying this changes, is there anything else?

Diff
diff --git a/src/platform/packages/shared/response-ops/rule_form/src/create_rule_form.tsx b/src/platform/packages/shared/response-ops/rule_form/src/create_rule_form.tsx
index 7b0a6f8fb3d..7d98683e089 100644
--- a/src/platform/packages/shared/response-ops/rule_form/src/create_rule_form.tsx
+++ b/src/platform/packages/shared/response-ops/rule_form/src/create_rule_form.tsx
@@ -31,6 +31,7 @@ import {
   parseRuleCircuitBreakerErrorMessage,
 } from './utils';
 import { RULE_CREATE_SUCCESS_TEXT, RULE_CREATE_ERROR_TEXT } from './translations';
+import { RuleFlyout } from './rule_flyout';
 
 export interface CreateRuleFormProps {
   ruleTypeId: string;
@@ -198,7 +199,7 @@ export const CreateRuleForm = (props: CreateRuleFormProps) => {
           }),
         }}
       >
-        <RulePage isEdit={false} isSaving={isSaving} onCancel={onCancel} onSave={onSave} />
+        <RuleFlyout isEdit={false} isSaving={isSaving} onCancel={onCancel} onSave={onSave} />
       </RuleFormStateProvider>
     </div>
   );
diff --git a/src/platform/packages/shared/response-ops/rule_form/src/edit_rule_form.tsx b/src/platform/packages/shared/response-ops/rule_form/src/edit_rule_form.tsx
index d1bdb8afab8..ac7563c56c9 100644
--- a/src/platform/packages/shared/response-ops/rule_form/src/edit_rule_form.tsx
+++ b/src/platform/packages/shared/response-ops/rule_form/src/edit_rule_form.tsx
@@ -26,6 +26,7 @@ import {
 import { RULE_EDIT_ERROR_TEXT, RULE_EDIT_SUCCESS_TEXT } from './translations';
 import { getAvailableRuleTypes, parseRuleCircuitBreakerErrorMessage } from './utils';
 import { DEFAULT_VALID_CONSUMERS, getDefaultFormData } from './constants';
+import { RuleFlyout } from './rule_flyout';
 
 export interface EditRuleFormProps {
   id: string;
@@ -211,7 +212,7 @@ export const EditRuleForm = (props: EditRuleFormProps) => {
           showMustacheAutocompleteSwitch,
         }}
       >
-        <RulePage isEdit={true} isSaving={isSaving} onSave={onSave} onCancel={onCancel} />
+        <RuleFlyout isEdit={true} isSaving={isSaving} onSave={onSave} onCancel={onCancel} />
       </RuleFormStateProvider>
     </div>
   );

@Zacqary
Copy link
Contributor Author

Zacqary commented Jan 17, 2025

@jcger Looks like 8d58b28 didn't actually work and broke the containers. Reverted, it should be working correctly now

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
triggersActionsUi 933 939 +6

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
triggersActionsUi 1.7MB 1.7MB +3.3KB

History

@Zacqary
Copy link
Contributor Author

Zacqary commented Jan 17, 2025

@elasticmachine merge upstream

import { DEFAULT_FREQUENCY } from '../constants';
import { getDefaultParams } from '../utils';

export const useOnSelectConnector = ({ onClose }: { onClose: () => void }) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like it's not being used anywhere

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was trying something here and I forgot to remove it

* This provides logic that works on both the Rule Page, which displays these screens in a modal,
* and the Rule Flyout, which displays these screens by replacing the entire content of the flyout.
*/
const initialRuleFormScreenContextState = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure what "screen" is referring to. I would think "element" might be fitting too, but not sure. Could you please elaborate a little bit on the reasoning behind "screen"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idk naming things is hard. I don't think it's an "element" because it could either be a modal or a full replacement of the content of the flyout, and there isn't a specific DOM element that corresponds to in both cases. "View" maybe? Remember when it was 2015 and we had model-view-controllers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to think of a good word that conveys "replace the entire contents of this thing, or show this thing in a modal, depending on how we do things" and I guess "screen" came to mind. Open to whatever.

@Zacqary Zacqary merged commit 8004e3e into elastic:main Jan 22, 2025
8 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/12915083592

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jan 22, 2025
… flyout (elastic#206154)

## Summary

Part of elastic#195211

- Adds Show Request screen to the new rule form flyout

<details>
<summary>Screenshot</summary>
<img width="585" alt="Screenshot 2025-01-10 at 1 30 15 PM"
src="https://github.com/user-attachments/assets/72500b0d-d959-4d17-944e-a7dc0894fb98"
/>
</details>

- Renders the action connectors UI within the flyout instead of opening
a modal

<details>
<summary>Screenshot</summary>
<img width="505" alt="Screenshot 2025-01-10 at 1 28 38 PM"
src="https://github.com/user-attachments/assets/b5b464c0-7359-43ab-bea1-93d2981a5794"
/>
</details>

- Duplicates the dropdown filter design from the flyout UI within the
action connectors modal when displayed on a smaller screen

<details>
<summary>Screenshot</summary>
<img width="809" alt="Screenshot 2025-01-10 at 1 30 28 PM"
src="https://github.com/user-attachments/assets/5ef28458-1b6d-4a29-961d-fbcc1640e706"
/>
</details>

### Implementation notes

In order to get the action connectors UI to render the same way in both
a modal and the flyout, without duplicating a large amount of code, I
had to introduce a little bit of complexity. Within the Rule Page, it's
as simple as opening the UI inside a modal, but the flyout cannot open a
second flyout; it has to know when and how to completely replace its own
contents.

- The bulk of the action connectors UI is now moved to
`<RuleActionsConnectorsBody>`. `<RuleActionsConnectorsModal>` and
`<RuleFlyoutSelectConnector>` act as wrappers for this component.
- The `<RuleActions>` step no longer handles rendering the connector UI,
because it's not at a high enough level to know if it's in the
`<RulePage>` or the `<RuleFlyout>`. Instead, it simply sends a signal up
the context hierarchy to `setIsConnectorsScreenVisible`.
- A new context called `RuleFormScreenContext` keeps track of
`isConnectorsScreenVisible`, a state for whether or not the action
connectors "screen" is open, regardless of whether that screen is
displayed in a modal or a flyout.
- The Rule Page uses `isConnectorsScreenVisible` to determine whether to
render the modal. This works the same way as it used to, but handled by
the `<RulePage>` instead of the `<RuleActions>` component.
- The Rule Flyout uses `isConnectorsScreenVisible` to determine whether
to continue to render `<RuleFlyoutBody>` or to completely replace its
contents with `<RuleFlyoutSelectConnector>`

For consistency, this PR also moves the Show Request modal/flyout screen
into the same system.

### Testing

To test the new flyout, edit
`packages/response-ops/rule_form/src/create_rule_form.tsx` and
`packages/response-ops/rule_form/src/edit_rule_form.tsx` so that they
render `<RuleFlyout>` instead of `<RulePage>`.

<details>
<summary><strong>Use this diff block</strong></summary>

```diff
diff --git a/packages/response-ops/rule_form/src/create_rule_form.tsx b/packages/response-ops/rule_form/src/create_rule_form.tsx
index 2f5e0472dcd..564744b96ec 100644
--- a/packages/response-ops/rule_form/src/create_rule_form.tsx
+++ b/packages/response-ops/rule_form/src/create_rule_form.tsx
@@ -31,6 +31,7 @@ import {
   parseRuleCircuitBreakerErrorMessage,
 } from './utils';
 import { RULE_CREATE_SUCCESS_TEXT, RULE_CREATE_ERROR_TEXT } from './translations';
+import { RuleFlyout } from './rule_flyout';

 export interface CreateRuleFormProps {
   ruleTypeId: string;
@@ -199,7 +200,7 @@ export const CreateRuleForm = (props: CreateRuleFormProps) => {
           }),
         }}
       >
-        <RulePage isEdit={false} isSaving={isSaving} onCancel={onCancel} onSave={onSave} />
+        <RuleFlyout isEdit={false} isSaving={isSaving} onCancel={onCancel} onSave={onSave} />
       </RuleFormStateProvider>
     </div>
   );
diff --git a/packages/response-ops/rule_form/src/edit_rule_form.tsx b/packages/response-ops/rule_form/src/edit_rule_form.tsx
index 392447114ed..41aecd7245a 100644
--- a/packages/response-ops/rule_form/src/edit_rule_form.tsx
+++ b/packages/response-ops/rule_form/src/edit_rule_form.tsx
@@ -26,6 +26,7 @@ import {
 import { RULE_EDIT_ERROR_TEXT, RULE_EDIT_SUCCESS_TEXT } from './translations';
 import { getAvailableRuleTypes, parseRuleCircuitBreakerErrorMessage } from './utils';
 import { DEFAULT_VALID_CONSUMERS, getDefaultFormData } from './constants';
+import { RuleFlyout } from './rule_flyout';

 export interface EditRuleFormProps {
   id: string;
@@ -193,7 +194,7 @@ export const EditRuleForm = (props: EditRuleFormProps) => {
           showMustacheAutocompleteSwitch,
         }}
       >
-        <RulePage isEdit={true} isSaving={isSaving} onSave={onSave} onCancel={onCancel} />
+        <RuleFlyout isEdit={true} isSaving={isSaving} onSave={onSave} onCancel={onCancel} />
       </RuleFormStateProvider>
     </div>
   );
```

</details>

### Still Todo

1. Replace all instances of the v1 rule flyout with this new one (it's
used heavily in solutions, not in Stack Management)

### Checklist

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [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: Elastic Machine <[email protected]>
(cherry picked from commit 8004e3e)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Jan 22, 2025
…ens to flyout (#206154) (#207903)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Response Ops] [Rule Form] Add Show Request and Add Action screens to
flyout (#206154)](#206154)

<!--- 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-22T18:53:08Z","message":"[Response
Ops] [Rule Form] Add Show Request and Add Action screens to flyout
(#206154)\n\n## Summary\r\n\r\nPart of #195211\r\n\r\n- Adds Show
Request screen to the new rule form
flyout\r\n\r\n<details>\r\n<summary>Screenshot</summary>\r\n<img
width=\"585\" alt=\"Screenshot 2025-01-10 at 1 30
15 PM\"\r\nsrc=\"https://github.com/user-attachments/assets/72500b0d-d959-4d17-944e-a7dc0894fb98\"\r\n/>\r\n</details>\r\n\r\n-
Renders the action connectors UI within the flyout instead of
opening\r\na modal\r\n
\r\n<details>\r\n<summary>Screenshot</summary>\r\n<img width=\"505\"
alt=\"Screenshot 2025-01-10 at 1 28
38 PM\"\r\nsrc=\"https://github.com/user-attachments/assets/b5b464c0-7359-43ab-bea1-93d2981a5794\"\r\n/>\r\n</details>\r\n\r\n-
Duplicates the dropdown filter design from the flyout UI within
the\r\naction connectors modal when displayed on a smaller
screen\r\n\r\n<details>\r\n<summary>Screenshot</summary>\r\n<img
width=\"809\" alt=\"Screenshot 2025-01-10 at 1 30
28 PM\"\r\nsrc=\"https://github.com/user-attachments/assets/5ef28458-1b6d-4a29-961d-fbcc1640e706\"\r\n/>\r\n</details>\r\n\r\n###
Implementation notes\r\n\r\nIn order to get the action connectors UI to
render the same way in both\r\na modal and the flyout, without
duplicating a large amount of code, I\r\nhad to introduce a little bit
of complexity. Within the Rule Page, it's\r\nas simple as opening the UI
inside a modal, but the flyout cannot open a\r\nsecond flyout; it has to
know when and how to completely replace its own\r\ncontents.\r\n\r\n-
The bulk of the action connectors UI is now moved
to\r\n`<RuleActionsConnectorsBody>`. `<RuleActionsConnectorsModal>`
and\r\n`<RuleFlyoutSelectConnector>` act as wrappers for this
component.\r\n- The `<RuleActions>` step no longer handles rendering the
connector UI,\r\nbecause it's not at a high enough level to know if it's
in the\r\n`<RulePage>` or the `<RuleFlyout>`. Instead, it simply sends a
signal up\r\nthe context hierarchy to
`setIsConnectorsScreenVisible`.\r\n- A new context called
`RuleFormScreenContext` keeps track of\r\n`isConnectorsScreenVisible`, a
state for whether or not the action\r\nconnectors \"screen\" is open,
regardless of whether that screen is\r\ndisplayed in a modal or a
flyout.\r\n- The Rule Page uses `isConnectorsScreenVisible` to determine
whether to\r\nrender the modal. This works the same way as it used to,
but handled by\r\nthe `<RulePage>` instead of the `<RuleActions>`
component.\r\n- The Rule Flyout uses `isConnectorsScreenVisible` to
determine whether\r\nto continue to render `<RuleFlyoutBody>` or to
completely replace its\r\ncontents with
`<RuleFlyoutSelectConnector>`\r\n\r\nFor consistency, this PR also moves
the Show Request modal/flyout screen\r\ninto the same system.\r\n\r\n###
Testing\r\n\r\nTo test the new flyout,
edit\r\n`packages/response-ops/rule_form/src/create_rule_form.tsx`
and\r\n`packages/response-ops/rule_form/src/edit_rule_form.tsx` so that
they\r\nrender `<RuleFlyout>` instead of
`<RulePage>`.\r\n\r\n<details>\r\n<summary><strong>Use this diff
block</strong></summary>\r\n\r\n```diff\r\ndiff --git
a/packages/response-ops/rule_form/src/create_rule_form.tsx
b/packages/response-ops/rule_form/src/create_rule_form.tsx\r\nindex
2f5e0472dcd..564744b96ec 100644\r\n---
a/packages/response-ops/rule_form/src/create_rule_form.tsx\r\n+++
b/packages/response-ops/rule_form/src/create_rule_form.tsx\r\n@@ -31,6
+31,7 @@ import {\r\n parseRuleCircuitBreakerErrorMessage,\r\n } from
'./utils';\r\n import { RULE_CREATE_SUCCESS_TEXT, RULE_CREATE_ERROR_TEXT
} from './translations';\r\n+import { RuleFlyout } from
'./rule_flyout';\r\n \r\n export interface CreateRuleFormProps {\r\n
ruleTypeId: string;\r\n@@ -199,7 +200,7 @@ export const CreateRuleForm =
(props: CreateRuleFormProps) => {\r\n }),\r\n }}\r\n >\r\n- <RulePage
isEdit={false} isSaving={isSaving} onCancel={onCancel} onSave={onSave}
/>\r\n+ <RuleFlyout isEdit={false} isSaving={isSaving}
onCancel={onCancel} onSave={onSave} />\r\n </RuleFormStateProvider>\r\n
</div>\r\n );\r\ndiff --git
a/packages/response-ops/rule_form/src/edit_rule_form.tsx
b/packages/response-ops/rule_form/src/edit_rule_form.tsx\r\nindex
392447114ed..41aecd7245a 100644\r\n---
a/packages/response-ops/rule_form/src/edit_rule_form.tsx\r\n+++
b/packages/response-ops/rule_form/src/edit_rule_form.tsx\r\n@@ -26,6
+26,7 @@ import {\r\n import { RULE_EDIT_ERROR_TEXT,
RULE_EDIT_SUCCESS_TEXT } from './translations';\r\n import {
getAvailableRuleTypes, parseRuleCircuitBreakerErrorMessage } from
'./utils';\r\n import { DEFAULT_VALID_CONSUMERS, getDefaultFormData }
from './constants';\r\n+import { RuleFlyout } from './rule_flyout';\r\n
\r\n export interface EditRuleFormProps {\r\n id: string;\r\n@@ -193,7
+194,7 @@ export const EditRuleForm = (props: EditRuleFormProps) =>
{\r\n showMustacheAutocompleteSwitch,\r\n }}\r\n >\r\n- <RulePage
isEdit={true} isSaving={isSaving} onSave={onSave} onCancel={onCancel}
/>\r\n+ <RuleFlyout isEdit={true} isSaving={isSaving} onSave={onSave}
onCancel={onCancel} />\r\n </RuleFormStateProvider>\r\n </div>\r\n
);\r\n```\r\n\r\n</details>\r\n\r\n### Still Todo\r\n\r\n1. Replace all
instances of the v1 rule flyout with this new one (it's\r\nused heavily
in solutions, not in Stack Management)\r\n\r\n### Checklist\r\n\r\n- [x]
Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\r\n-
[x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine
<[email protected]>","sha":"8004e3e70ad63b938d724eafd561533eeb225cd9","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":"[Response
Ops] [Rule Form] Add Show Request and Add Action screens to
flyout","number":206154,"url":"https://github.com/elastic/kibana/pull/206154","mergeCommit":{"message":"[Response
Ops] [Rule Form] Add Show Request and Add Action screens to flyout
(#206154)\n\n## Summary\r\n\r\nPart of #195211\r\n\r\n- Adds Show
Request screen to the new rule form
flyout\r\n\r\n<details>\r\n<summary>Screenshot</summary>\r\n<img
width=\"585\" alt=\"Screenshot 2025-01-10 at 1 30
15 PM\"\r\nsrc=\"https://github.com/user-attachments/assets/72500b0d-d959-4d17-944e-a7dc0894fb98\"\r\n/>\r\n</details>\r\n\r\n-
Renders the action connectors UI within the flyout instead of
opening\r\na modal\r\n
\r\n<details>\r\n<summary>Screenshot</summary>\r\n<img width=\"505\"
alt=\"Screenshot 2025-01-10 at 1 28
38 PM\"\r\nsrc=\"https://github.com/user-attachments/assets/b5b464c0-7359-43ab-bea1-93d2981a5794\"\r\n/>\r\n</details>\r\n\r\n-
Duplicates the dropdown filter design from the flyout UI within
the\r\naction connectors modal when displayed on a smaller
screen\r\n\r\n<details>\r\n<summary>Screenshot</summary>\r\n<img
width=\"809\" alt=\"Screenshot 2025-01-10 at 1 30
28 PM\"\r\nsrc=\"https://github.com/user-attachments/assets/5ef28458-1b6d-4a29-961d-fbcc1640e706\"\r\n/>\r\n</details>\r\n\r\n###
Implementation notes\r\n\r\nIn order to get the action connectors UI to
render the same way in both\r\na modal and the flyout, without
duplicating a large amount of code, I\r\nhad to introduce a little bit
of complexity. Within the Rule Page, it's\r\nas simple as opening the UI
inside a modal, but the flyout cannot open a\r\nsecond flyout; it has to
know when and how to completely replace its own\r\ncontents.\r\n\r\n-
The bulk of the action connectors UI is now moved
to\r\n`<RuleActionsConnectorsBody>`. `<RuleActionsConnectorsModal>`
and\r\n`<RuleFlyoutSelectConnector>` act as wrappers for this
component.\r\n- The `<RuleActions>` step no longer handles rendering the
connector UI,\r\nbecause it's not at a high enough level to know if it's
in the\r\n`<RulePage>` or the `<RuleFlyout>`. Instead, it simply sends a
signal up\r\nthe context hierarchy to
`setIsConnectorsScreenVisible`.\r\n- A new context called
`RuleFormScreenContext` keeps track of\r\n`isConnectorsScreenVisible`, a
state for whether or not the action\r\nconnectors \"screen\" is open,
regardless of whether that screen is\r\ndisplayed in a modal or a
flyout.\r\n- The Rule Page uses `isConnectorsScreenVisible` to determine
whether to\r\nrender the modal. This works the same way as it used to,
but handled by\r\nthe `<RulePage>` instead of the `<RuleActions>`
component.\r\n- The Rule Flyout uses `isConnectorsScreenVisible` to
determine whether\r\nto continue to render `<RuleFlyoutBody>` or to
completely replace its\r\ncontents with
`<RuleFlyoutSelectConnector>`\r\n\r\nFor consistency, this PR also moves
the Show Request modal/flyout screen\r\ninto the same system.\r\n\r\n###
Testing\r\n\r\nTo test the new flyout,
edit\r\n`packages/response-ops/rule_form/src/create_rule_form.tsx`
and\r\n`packages/response-ops/rule_form/src/edit_rule_form.tsx` so that
they\r\nrender `<RuleFlyout>` instead of
`<RulePage>`.\r\n\r\n<details>\r\n<summary><strong>Use this diff
block</strong></summary>\r\n\r\n```diff\r\ndiff --git
a/packages/response-ops/rule_form/src/create_rule_form.tsx
b/packages/response-ops/rule_form/src/create_rule_form.tsx\r\nindex
2f5e0472dcd..564744b96ec 100644\r\n---
a/packages/response-ops/rule_form/src/create_rule_form.tsx\r\n+++
b/packages/response-ops/rule_form/src/create_rule_form.tsx\r\n@@ -31,6
+31,7 @@ import {\r\n parseRuleCircuitBreakerErrorMessage,\r\n } from
'./utils';\r\n import { RULE_CREATE_SUCCESS_TEXT, RULE_CREATE_ERROR_TEXT
} from './translations';\r\n+import { RuleFlyout } from
'./rule_flyout';\r\n \r\n export interface CreateRuleFormProps {\r\n
ruleTypeId: string;\r\n@@ -199,7 +200,7 @@ export const CreateRuleForm =
(props: CreateRuleFormProps) => {\r\n }),\r\n }}\r\n >\r\n- <RulePage
isEdit={false} isSaving={isSaving} onCancel={onCancel} onSave={onSave}
/>\r\n+ <RuleFlyout isEdit={false} isSaving={isSaving}
onCancel={onCancel} onSave={onSave} />\r\n </RuleFormStateProvider>\r\n
</div>\r\n );\r\ndiff --git
a/packages/response-ops/rule_form/src/edit_rule_form.tsx
b/packages/response-ops/rule_form/src/edit_rule_form.tsx\r\nindex
392447114ed..41aecd7245a 100644\r\n---
a/packages/response-ops/rule_form/src/edit_rule_form.tsx\r\n+++
b/packages/response-ops/rule_form/src/edit_rule_form.tsx\r\n@@ -26,6
+26,7 @@ import {\r\n import { RULE_EDIT_ERROR_TEXT,
RULE_EDIT_SUCCESS_TEXT } from './translations';\r\n import {
getAvailableRuleTypes, parseRuleCircuitBreakerErrorMessage } from
'./utils';\r\n import { DEFAULT_VALID_CONSUMERS, getDefaultFormData }
from './constants';\r\n+import { RuleFlyout } from './rule_flyout';\r\n
\r\n export interface EditRuleFormProps {\r\n id: string;\r\n@@ -193,7
+194,7 @@ export const EditRuleForm = (props: EditRuleFormProps) =>
{\r\n showMustacheAutocompleteSwitch,\r\n }}\r\n >\r\n- <RulePage
isEdit={true} isSaving={isSaving} onSave={onSave} onCancel={onCancel}
/>\r\n+ <RuleFlyout isEdit={true} isSaving={isSaving} onSave={onSave}
onCancel={onCancel} />\r\n </RuleFormStateProvider>\r\n </div>\r\n
);\r\n```\r\n\r\n</details>\r\n\r\n### Still Todo\r\n\r\n1. Replace all
instances of the v1 rule flyout with this new one (it's\r\nused heavily
in solutions, not in Stack Management)\r\n\r\n### Checklist\r\n\r\n- [x]
Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\r\n-
[x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine
<[email protected]>","sha":"8004e3e70ad63b938d724eafd561533eeb225cd9"}},"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/206154","number":206154,"mergeCommit":{"message":"[Response
Ops] [Rule Form] Add Show Request and Add Action screens to flyout
(#206154)\n\n## Summary\r\n\r\nPart of #195211\r\n\r\n- Adds Show
Request screen to the new rule form
flyout\r\n\r\n<details>\r\n<summary>Screenshot</summary>\r\n<img
width=\"585\" alt=\"Screenshot 2025-01-10 at 1 30
15 PM\"\r\nsrc=\"https://github.com/user-attachments/assets/72500b0d-d959-4d17-944e-a7dc0894fb98\"\r\n/>\r\n</details>\r\n\r\n-
Renders the action connectors UI within the flyout instead of
opening\r\na modal\r\n
\r\n<details>\r\n<summary>Screenshot</summary>\r\n<img width=\"505\"
alt=\"Screenshot 2025-01-10 at 1 28
38 PM\"\r\nsrc=\"https://github.com/user-attachments/assets/b5b464c0-7359-43ab-bea1-93d2981a5794\"\r\n/>\r\n</details>\r\n\r\n-
Duplicates the dropdown filter design from the flyout UI within
the\r\naction connectors modal when displayed on a smaller
screen\r\n\r\n<details>\r\n<summary>Screenshot</summary>\r\n<img
width=\"809\" alt=\"Screenshot 2025-01-10 at 1 30
28 PM\"\r\nsrc=\"https://github.com/user-attachments/assets/5ef28458-1b6d-4a29-961d-fbcc1640e706\"\r\n/>\r\n</details>\r\n\r\n###
Implementation notes\r\n\r\nIn order to get the action connectors UI to
render the same way in both\r\na modal and the flyout, without
duplicating a large amount of code, I\r\nhad to introduce a little bit
of complexity. Within the Rule Page, it's\r\nas simple as opening the UI
inside a modal, but the flyout cannot open a\r\nsecond flyout; it has to
know when and how to completely replace its own\r\ncontents.\r\n\r\n-
The bulk of the action connectors UI is now moved
to\r\n`<RuleActionsConnectorsBody>`. `<RuleActionsConnectorsModal>`
and\r\n`<RuleFlyoutSelectConnector>` act as wrappers for this
component.\r\n- The `<RuleActions>` step no longer handles rendering the
connector UI,\r\nbecause it's not at a high enough level to know if it's
in the\r\n`<RulePage>` or the `<RuleFlyout>`. Instead, it simply sends a
signal up\r\nthe context hierarchy to
`setIsConnectorsScreenVisible`.\r\n- A new context called
`RuleFormScreenContext` keeps track of\r\n`isConnectorsScreenVisible`, a
state for whether or not the action\r\nconnectors \"screen\" is open,
regardless of whether that screen is\r\ndisplayed in a modal or a
flyout.\r\n- The Rule Page uses `isConnectorsScreenVisible` to determine
whether to\r\nrender the modal. This works the same way as it used to,
but handled by\r\nthe `<RulePage>` instead of the `<RuleActions>`
component.\r\n- The Rule Flyout uses `isConnectorsScreenVisible` to
determine whether\r\nto continue to render `<RuleFlyoutBody>` or to
completely replace its\r\ncontents with
`<RuleFlyoutSelectConnector>`\r\n\r\nFor consistency, this PR also moves
the Show Request modal/flyout screen\r\ninto the same system.\r\n\r\n###
Testing\r\n\r\nTo test the new flyout,
edit\r\n`packages/response-ops/rule_form/src/create_rule_form.tsx`
and\r\n`packages/response-ops/rule_form/src/edit_rule_form.tsx` so that
they\r\nrender `<RuleFlyout>` instead of
`<RulePage>`.\r\n\r\n<details>\r\n<summary><strong>Use this diff
block</strong></summary>\r\n\r\n```diff\r\ndiff --git
a/packages/response-ops/rule_form/src/create_rule_form.tsx
b/packages/response-ops/rule_form/src/create_rule_form.tsx\r\nindex
2f5e0472dcd..564744b96ec 100644\r\n---
a/packages/response-ops/rule_form/src/create_rule_form.tsx\r\n+++
b/packages/response-ops/rule_form/src/create_rule_form.tsx\r\n@@ -31,6
+31,7 @@ import {\r\n parseRuleCircuitBreakerErrorMessage,\r\n } from
'./utils';\r\n import { RULE_CREATE_SUCCESS_TEXT, RULE_CREATE_ERROR_TEXT
} from './translations';\r\n+import { RuleFlyout } from
'./rule_flyout';\r\n \r\n export interface CreateRuleFormProps {\r\n
ruleTypeId: string;\r\n@@ -199,7 +200,7 @@ export const CreateRuleForm =
(props: CreateRuleFormProps) => {\r\n }),\r\n }}\r\n >\r\n- <RulePage
isEdit={false} isSaving={isSaving} onCancel={onCancel} onSave={onSave}
/>\r\n+ <RuleFlyout isEdit={false} isSaving={isSaving}
onCancel={onCancel} onSave={onSave} />\r\n </RuleFormStateProvider>\r\n
</div>\r\n );\r\ndiff --git
a/packages/response-ops/rule_form/src/edit_rule_form.tsx
b/packages/response-ops/rule_form/src/edit_rule_form.tsx\r\nindex
392447114ed..41aecd7245a 100644\r\n---
a/packages/response-ops/rule_form/src/edit_rule_form.tsx\r\n+++
b/packages/response-ops/rule_form/src/edit_rule_form.tsx\r\n@@ -26,6
+26,7 @@ import {\r\n import { RULE_EDIT_ERROR_TEXT,
RULE_EDIT_SUCCESS_TEXT } from './translations';\r\n import {
getAvailableRuleTypes, parseRuleCircuitBreakerErrorMessage } from
'./utils';\r\n import { DEFAULT_VALID_CONSUMERS, getDefaultFormData }
from './constants';\r\n+import { RuleFlyout } from './rule_flyout';\r\n
\r\n export interface EditRuleFormProps {\r\n id: string;\r\n@@ -193,7
+194,7 @@ export const EditRuleForm = (props: EditRuleFormProps) =>
{\r\n showMustacheAutocompleteSwitch,\r\n }}\r\n >\r\n- <RulePage
isEdit={true} isSaving={isSaving} onSave={onSave} onCancel={onCancel}
/>\r\n+ <RuleFlyout isEdit={true} isSaving={isSaving} onSave={onSave}
onCancel={onCancel} />\r\n </RuleFormStateProvider>\r\n </div>\r\n
);\r\n```\r\n\r\n</details>\r\n\r\n### Still Todo\r\n\r\n1. Replace all
instances of the v1 rule flyout with this new one (it's\r\nused heavily
in solutions, not in Stack Management)\r\n\r\n### Checklist\r\n\r\n- [x]
Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\r\n-
[x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine
<[email protected]>","sha":"8004e3e70ad63b938d724eafd561533eeb225cd9"}},{"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]>
viduni94 pushed a commit to viduni94/kibana that referenced this pull request Jan 23, 2025
… flyout (elastic#206154)

## Summary

Part of elastic#195211

- Adds Show Request screen to the new rule form flyout

<details>
<summary>Screenshot</summary>
<img width="585" alt="Screenshot 2025-01-10 at 1 30 15 PM"
src="https://github.com/user-attachments/assets/72500b0d-d959-4d17-944e-a7dc0894fb98"
/>
</details>

- Renders the action connectors UI within the flyout instead of opening
a modal
 
<details>
<summary>Screenshot</summary>
<img width="505" alt="Screenshot 2025-01-10 at 1 28 38 PM"
src="https://github.com/user-attachments/assets/b5b464c0-7359-43ab-bea1-93d2981a5794"
/>
</details>

- Duplicates the dropdown filter design from the flyout UI within the
action connectors modal when displayed on a smaller screen

<details>
<summary>Screenshot</summary>
<img width="809" alt="Screenshot 2025-01-10 at 1 30 28 PM"
src="https://github.com/user-attachments/assets/5ef28458-1b6d-4a29-961d-fbcc1640e706"
/>
</details>

### Implementation notes

In order to get the action connectors UI to render the same way in both
a modal and the flyout, without duplicating a large amount of code, I
had to introduce a little bit of complexity. Within the Rule Page, it's
as simple as opening the UI inside a modal, but the flyout cannot open a
second flyout; it has to know when and how to completely replace its own
contents.

- The bulk of the action connectors UI is now moved to
`<RuleActionsConnectorsBody>`. `<RuleActionsConnectorsModal>` and
`<RuleFlyoutSelectConnector>` act as wrappers for this component.
- The `<RuleActions>` step no longer handles rendering the connector UI,
because it's not at a high enough level to know if it's in the
`<RulePage>` or the `<RuleFlyout>`. Instead, it simply sends a signal up
the context hierarchy to `setIsConnectorsScreenVisible`.
- A new context called `RuleFormScreenContext` keeps track of
`isConnectorsScreenVisible`, a state for whether or not the action
connectors "screen" is open, regardless of whether that screen is
displayed in a modal or a flyout.
- The Rule Page uses `isConnectorsScreenVisible` to determine whether to
render the modal. This works the same way as it used to, but handled by
the `<RulePage>` instead of the `<RuleActions>` component.
- The Rule Flyout uses `isConnectorsScreenVisible` to determine whether
to continue to render `<RuleFlyoutBody>` or to completely replace its
contents with `<RuleFlyoutSelectConnector>`

For consistency, this PR also moves the Show Request modal/flyout screen
into the same system.

### Testing

To test the new flyout, edit
`packages/response-ops/rule_form/src/create_rule_form.tsx` and
`packages/response-ops/rule_form/src/edit_rule_form.tsx` so that they
render `<RuleFlyout>` instead of `<RulePage>`.

<details>
<summary><strong>Use this diff block</strong></summary>

```diff
diff --git a/packages/response-ops/rule_form/src/create_rule_form.tsx b/packages/response-ops/rule_form/src/create_rule_form.tsx
index 2f5e0472dcd..564744b96ec 100644
--- a/packages/response-ops/rule_form/src/create_rule_form.tsx
+++ b/packages/response-ops/rule_form/src/create_rule_form.tsx
@@ -31,6 +31,7 @@ import {
   parseRuleCircuitBreakerErrorMessage,
 } from './utils';
 import { RULE_CREATE_SUCCESS_TEXT, RULE_CREATE_ERROR_TEXT } from './translations';
+import { RuleFlyout } from './rule_flyout';
 
 export interface CreateRuleFormProps {
   ruleTypeId: string;
@@ -199,7 +200,7 @@ export const CreateRuleForm = (props: CreateRuleFormProps) => {
           }),
         }}
       >
-        <RulePage isEdit={false} isSaving={isSaving} onCancel={onCancel} onSave={onSave} />
+        <RuleFlyout isEdit={false} isSaving={isSaving} onCancel={onCancel} onSave={onSave} />
       </RuleFormStateProvider>
     </div>
   );
diff --git a/packages/response-ops/rule_form/src/edit_rule_form.tsx b/packages/response-ops/rule_form/src/edit_rule_form.tsx
index 392447114ed..41aecd7245a 100644
--- a/packages/response-ops/rule_form/src/edit_rule_form.tsx
+++ b/packages/response-ops/rule_form/src/edit_rule_form.tsx
@@ -26,6 +26,7 @@ import {
 import { RULE_EDIT_ERROR_TEXT, RULE_EDIT_SUCCESS_TEXT } from './translations';
 import { getAvailableRuleTypes, parseRuleCircuitBreakerErrorMessage } from './utils';
 import { DEFAULT_VALID_CONSUMERS, getDefaultFormData } from './constants';
+import { RuleFlyout } from './rule_flyout';
 
 export interface EditRuleFormProps {
   id: string;
@@ -193,7 +194,7 @@ export const EditRuleForm = (props: EditRuleFormProps) => {
           showMustacheAutocompleteSwitch,
         }}
       >
-        <RulePage isEdit={true} isSaving={isSaving} onSave={onSave} onCancel={onCancel} />
+        <RuleFlyout isEdit={true} isSaving={isSaving} onSave={onSave} onCancel={onCancel} />
       </RuleFormStateProvider>
     </div>
   );
```

</details>

### Still Todo

1. Replace all instances of the v1 rule flyout with this new one (it's
used heavily in solutions, not in Stack Management)

### Checklist

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [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: Elastic Machine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:version Backport to applied version labels Feature:Alerting/RulesManagement Issues related to the Rules Management UX release_note:skip Skip the PR/issue when compiling release notes Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v8.18.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants