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 Rule Form Flyout v2 #206685

Open
wants to merge 67 commits into
base: main
Choose a base branch
from

Conversation

Zacqary
Copy link
Contributor

@Zacqary Zacqary commented Jan 14, 2025

Summary

Part of #195211

Replaces the create/edit rule flyout with the new rule flyout

Screenshot 2025-01-14 at 3 12 30 PM Screenshot 2025-01-14 at 3 12 52 PM

Restores the confirmation prompt before canceling or saving a rule without actions defined.

Also fixes most of the design papercuts in the Actions step:

Screenshot 2025-01-14 at 3 11 06 PM Screenshot 2025-01-14 at 3 11 01 PM

Checklist

@Zacqary Zacqary added Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v9.0.0 release_note:feature Makes this part of the condensed release notes Feature:Alerting/RulesManagement Issues related to the Rules Management UX backport:version Backport to applied version labels v8.18.0 labels Jan 14, 2025
@Zacqary
Copy link
Contributor Author

Zacqary commented Jan 15, 2025

@elastic/kibana-design This PR is still in draft but could use some feedback on these two design elements as they weren't in the Figma:

Screenshot 2025-01-14 at 3 11 45 PM Screenshot 2025-01-14 at 3 11 38 PM

I'm particularly unsure about the confirmation screen, it's definitely Not A Flyout Opening A Modal™ but it's also a ton of blank space

@Zacqary Zacqary force-pushed the 195211-replace-flyout branch 2 times, most recently from c3b25e9 to cbf1333 Compare January 17, 2025 17:36
@MichaelMarcialis
Copy link
Contributor

@elastic/kibana-design This PR is still in draft but could use some feedback on these two design elements as they weren't in the Figma:

Hey, @Zacqary. I'm not certain who the designer was on this, so I'll defer to them if they disagree with any of the following opinions. That said, I'd suggest the following:

Discard changes screenshot

You made mention of not triggering the confirmation modal from the flyout. Is there a compelling reason not to do so? Personally, I'm wondering if it might be a more common/familiar pattern to open a confirmation modal instead of repurposing the content area of the flyout. It'll also be more forgiving for short messages such as this.

No actions configured screenshot

Since it's allowed, I'm wondering if we should change the color="warning" prop on the EuiCallout to the default primary color, to avoid scaring folks. If it's truly just an informational message and not a warning (i.e. nothing is going awry), then we should style it as such. You'll likely also want to change or remove the icon as well.

Additionally, since the message is most relevant at the moment the user leaves the "Actions" step and moves to the "Details" step, perhaps it would make sense to move the callout up towards the top of the flyout (just below the header).

@Zacqary
Copy link
Contributor Author

Zacqary commented Jan 21, 2025

Additionally, since the message is most relevant at the moment the user leaves the "Actions" step and moves to the "Details" step, perhaps it would make sense to move the callout up towards the top of the flyout (just below the header).

The reason I put the callout on the footer is because it's replacing something the full page Rule Form shows as a confirmation popup. It's a message that we're usually displaying to the user right as they're making the decision to save the rule.

I'm happy to move the callout to the top of the screen, but if flyouts are allowed to open confirmation modals I could also just have it pop up the same modal as the rule page instead.

@joana-cps
Copy link

Thanks, @MichaelMarcialis for your comment and thoughts. I forgot to add these screens on Figma and missed the notification for the PR review. @Zacqary is now aware that I'm the one responsible for this area.

Discard changes screenshot
Regarding modals and flyouts I agree with avoiding it when we're talking about modals in the middle of a flyout flow, like the action connector and show request for example. Since this is a validation, the most common pattern around kibana is just a simple confirmation modal. The only thing that we need to be aware of is adding the background so the user can only interact with the confirmation modal.

This behavior is already in use if you create/edit a Rule from Observability:
Screenshot 2025-01-22 at 10 41 29

No actions configured screenshot
Let's use the same modal that we use on the Rule page for consistency. We already show that actions are optional in the actions step, this is just a confirmation modal.
Screenshot 2025-01-22 at 10 52 26

@Zacqary
Copy link
Contributor Author

Zacqary commented Jan 28, 2025

@jughosta I've done some investigating and it looks like this error is expected on CI. Can confirm that editing x-pack/platform/plugins/shared/alerting/server/plugin.ts so that the error always fires, and then testing locally, does not stop the tests from passing.

--- a/x-pack/platform/plugins/shared/alerting/server/plugin.ts
+++ b/x-pack/platform/plugins/shared/alerting/server/plugin.ts
@@ -569,11 +569,11 @@ export class AlertingPlugin {
     });
 
     const getRulesClientWithRequest = async (request: KibanaRequest) => {
-      if (isESOCanEncrypt !== true) {
-        throw new Error(
-          `Unable to create alerts client because the Encrypted Saved Objects plugin is missing encryption key. Please set xpack.encryptedSavedObjects.encryptionKey in the kibana.yml or use the bin/kibana-encryption-keys command.`
-        );
-      }
+      //if (isESOCanEncrypt !== true) {
+      throw new Error(
+        `Unable to create alerts client because the Encrypted Saved Objects plugin is missing encryption key. Please set xpack.encryptedSavedObjects.encryptionKey in the kibana.yml or use the bin/kibana-encryption-keys command.`
+      );
+      //}
       return rulesClientFactory!.create(request, core.savedObjects);
     };

There's something else about the CI environment that's causing Discover to behave differently. I don't want to skip this test but I'm going to need your team's help debugging if we want to get this PR through. I'm hitting a wall here.

// until one day somebody makes another change to this package and, for mysterious, unknowable reasons,
// Webpack decides that today the bundle size shall be engorged once again.
// To avoid all that maybe just don't delete this dynamic import.
ecsFlat.current = await import('@elastic/ecs').then((ecs) => ecs.EcsFlat);
Copy link
Contributor

@jughosta jughosta Jan 29, 2025

Choose a reason for hiding this comment

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

return triggersActionsUi?.getAddRuleFlyout({
metadata: discoverMetadata,
return triggersActionsUi?.getRuleFormFlyout<EsQueryAlertMetaData>({
plugins: services,
Copy link
Contributor

@jughosta jughosta Jan 29, 2025

Choose a reason for hiding this comment

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

The change in how plugins are accessed could cause the test to fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ruleTypeRegistry and actionTypeRegistry are added by the triggersActionsUI export. That's also how the v1 flyout worked. We haven't yet come up with a solution to allow solutions to directly import the flyout from the @kbn/response-ops-rule-form package so it's still relying on tAUI

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note the code of triggersActionsUI.getRuleFormFlyout:

     getRuleFormFlyout: (props) => {
        return getRuleFormFlyoutLazy({
          ...props,
          plugins: {
            ...validateRuleFormPlugins(props.plugins),
            actionTypeRegistry: this.actionTypeRegistry,
            ruleTypeRegistry: this.ruleTypeRegistry,
          },
        });
      },

validateRuleFormPlugins throws an error if the passed props.plugins doesn't contain anything that's required by getRuleFormFlyout, defined by:

type RequiredRuleFormPlugins = Omit<
  RuleFormProps['plugins'],
  'actionTypeRegistry' | 'ruleTypeRegistry'
>;

And then the two registries are added from triggersActionsUi

expect(await testSubjects.exists('addRuleFlyoutTitle')).to.be(true);
// Increase timeout. The rule flyout has to load asynchronously when the user clicks the create rule button,
// so a higher timeout here reduces flakiness in the test
expect(await testSubjects.exists('addRuleFlyoutTitle', { timeout: 20000 })).to.be(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

We can try to update test/functional/apps/discover/group1/config.ts with the following:

export default async function ({ readConfigFile }: FtrConfigProviderContext) {
  const functionalConfig = await readConfigFile(require.resolve('../../../config.base.js'));

  return {
    ...functionalConfig.getAll(),
    kbnTestServer: {
      ...functionalConfig.get('kbnTestServer'),
      serverArgs: [
        ...functionalConfig.get('kbnTestServer.serverArgs'),
        '--xpack.encryptedSavedObjects.encryptionKey="wuGNaIhoMpk5sO4UBxgr3NyW1sFcLgIf"', // it's required for alerts plugin to work
      ],
    },
    testFiles: [require.resolve('.')],
  };
}

@elasticmachine
Copy link
Contributor

elasticmachine commented Jan 31, 2025

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #56 / EQL execution logic API @ess @serverless @serverlessQA EQL type rules parses shard failures for EQL event query

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
observability 1353 1365 +12
triggersActionsUi 944 956 +12
total +24

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/alerts-ui-shared 287 288 +1
@kbn/response-ops-rule-form 158 181 +23
triggersActionsUi 570 568 -2
total +22

Async chunks

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

id before after diff
apm 4.0MB 4.0MB +16.0B
discover 846.6KB 846.6KB +3.0B
infra 1.2MB 1.2MB +214.0B
ml 4.7MB 4.7MB -70.0B
monitoring 515.2KB 515.2KB +53.0B
observability 1.3MB 1.3MB +9.5KB
slo 898.4KB 898.5KB +100.0B
stackAlerts 75.2KB 75.3KB +132.0B
synthetics 921.4KB 921.5KB +58.0B
transform 470.1KB 470.1KB -24.0B
triggersActionsUi 1.7MB 1.7MB +26.6KB
uptime 462.1KB 462.2KB +64.0B
total +36.7KB

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
@kbn/response-ops-rule-form 7 6 -1
triggersActionsUi 51 49 -2
total -3

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
triggersActionsUi 130.2KB 130.4KB +207.0B
Unknown metric groups

API count

id before after diff
@kbn/alerts-ui-shared 303 304 +1
@kbn/response-ops-rule-form 159 182 +23
triggersActionsUi 596 594 -2
total +22

async chunk count

id before after diff
observability 21 22 +1
triggersActionsUi 65 67 +2
total +3

History

@Zacqary Zacqary marked this pull request as ready for review January 31, 2025 20:10
@Zacqary Zacqary requested review from a team as code owners January 31, 2025 20:10
@elasticmachine
Copy link
Contributor

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

@Zacqary Zacqary requested a review from jughosta January 31, 2025 20:10
@Zacqary
Copy link
Contributor Author

Zacqary commented Jan 31, 2025

@jughosta Thanks for the help, test is passing now. Confused about why that broke it on CI but not locally, but I'll take the win.

PR is out of draft now if you're able to review the Discover codeowner changes

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 ci:cloud-deploy Create or update a Cloud deployment Feature:Alerting/RulesManagement Issues related to the Rules Management UX release_note:feature Makes this part of the condensed 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.

6 participants