kibana icon indicating copy to clipboard operation
kibana copied to clipboard

[ResponseOps][Cases] Allow users to create case using templates

Open js-jankisalvi opened this issue 1 year ago • 3 comments

Summary

Fixes https://github.com/elastic/kibana/issues/181309

This PR

  • allows users to create, edit or delete templates via cases > settings page
  • allows users to create case using templates

https://github.com/elastic/kibana/assets/117571355/39226aa4-9d9a-41a8-a900-ca765ed98e1b

Testing

  1. Go to all solutions and create cases with all fields (including all fields of all supported connectors) without using templates. Verify that everything is working as expected.
  2. Go to all solutions and create and edit templates with various fields. Verify that everything is working as expected.
  3. Go to all solutions, create different templates on each solution, and verify that when creating a case you can use templates and everything is working as expected.
  4. Go to the alerts table of o11y and security and attach alerts to a new case. Verify that in the flyout the templates are working as expected.
  5. Go to ML and try to attach an ML visualization to a new case. Verify that the solution picker is working as expected and it resets the form when changing solutions.

Checklist

Delete any items that are not applicable to this PR.

For maintainers

Release notes

Allow users to create case using templates.

js-jankisalvi avatar Jun 28 '24 10:06 js-jankisalvi

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

elasticmachine avatar Jun 28 '24 10:06 elasticmachine

Pinging @elastic/response-ops-cases (Feature:Cases)

elasticmachine avatar Jun 28 '24 10:06 elasticmachine

@angorayc

Does it means I have to always apply the template when creating a new case?

You don't have to pick any template in that dropdown. It is supposed to serve as a way to prefill fields when creating cases but it is totally optional. You can always create a case without a template applied 🙂

However, your video makes me think we could have a no template option in the templates dropdown. I don't like that after we select a template there is no going back besides leaving the page 🤔 What do you think @js-jankisalvi ?

  1. [...] At the same time, the template information I deleted seemed still applying to my new case.

I managed to reproduce this but I am not sure it is connected to templates. I get the same behaviour if I manually populate the description. (I'll check if we already have an issue for this.)

When you were initially in the Create Case page did you leave by pressing back to cases or cancel?

Screenshot 2024-07-01 at 12 15 51

adcoelho avatar Jul 01 '24 10:07 adcoelho

@angorayc

Does it means I have to always apply the template when creating a new case?

You don't have to pick any template in that dropdown. It is supposed to serve as a way to prefill fields when creating cases but it is totally optional. You can always create a case without a template applied 🙂

However, your video makes me think we could have a no template option in the templates dropdown. I don't like that after we select a template there is no going back besides leaving the page 🤔 What do you think @js-jankisalvi ?

In the first video, I wasn't able to unselected the template after selecting one, adding an option No template might be useful here.

  1. [...] At the same time, the template information I deleted seemed still applying to my new case.

I managed to reproduce this but I am not sure it is connected to templates. I get the same behaviour if I manually populate the description. (I'll check if we already have an issue for this.)

When you were initially in the Create Case page did you leave by pressing back to cases or cancel?

Screenshot 2024-07-01 at 12 15 51

I think I clicked back to cases

angorayc avatar Jul 01 '24 10:07 angorayc

However, your video makes me think we could have a no template option in the templates dropdown. I don't like that after we select a template there is no going back besides leaving the page 🤔 What do you think @js-jankisalvi ?

Yes, agree. no template option makes sense. created an issue for it: https://github.com/elastic/kibana/issues/187233

js-jankisalvi avatar Jul 01 '24 10:07 js-jankisalvi

  1. [...] At the same time, the template information I deleted seemed still applying to my new case.

I managed to reproduce this but I am not sure it is connected to templates. I get the same behaviour if I manually populate the description. (I'll check if we already have an issue for this.) When you were initially in the Create Case page did you leave by pressing back to cases or cancel?

I think I clicked back to cases

Created a bug for case description: https://github.com/elastic/kibana/issues/187236

js-jankisalvi avatar Jul 01 '24 10:07 js-jankisalvi

In the case configuration page, the ui gets broken if we have too many tags.

Screenshot 2024-07-01 at 14 51 50

adcoelho avatar Jul 01 '24 12:07 adcoelho

If I have a default External Incident Management System in the configuration and try to create a template I get the following error.

Screenshot 2024-07-01 at 15 10 25

I am aware of this issue but I don't think it is the same.

Does it make sense to have "required" fields in the template?

adcoelho avatar Jul 01 '24 13:07 adcoelho

In the case configuration page, the ui gets broken if we have too many tags.

Fixed here 6319822

Now it looks like this: image

js-jankisalvi avatar Jul 01 '24 13:07 js-jankisalvi

I was messing around with custom field default values and whatnot.

If I:

  1. Create a template(named X, whatever 😄 )
  2. Create a toggle custom field with true as the default value
  3. Go straight to the case creation page and select my template the toggle will be true with that template selected
  4. If I go back to the case configuration page and edit the template, the toggle will have value false.

I am having trouble uploading the screen recording so ping me offline if the description above is not clear 😅

adcoelho avatar Jul 01 '24 14:07 adcoelho

I am aware of this issue but I don't think it is the same.

yup, it's different.

Does it make sense to have "required" fields in the template?

No, every field should be optional in templates. I quickly checked the code and it seems only Jira connector's issueTypes field has this validation. Maybe we can ignore this validation for templates. I could update this issue to handle it.

js-jankisalvi avatar Jul 01 '24 14:07 js-jankisalvi

Flaky Test Runner Stats

🎉 All tests passed! - kibana-flaky-test-suite-runner#6425

[✅] x-pack/test_serverless/functional/test_suites/security/config.ts: 25/25 tests passed. [✅] x-pack/test_serverless/functional/test_suites/observability/config.ts: 25/25 tests passed. [✅] x-pack/test/functional_with_es_ssl/apps/cases/group2/config.ts: 25/25 tests passed. [✅] x-pack/test/functional_with_es_ssl/apps/cases/group1/config.ts: 25/25 tests passed. [✅] x-pack/test/cases_api_integration/security_and_spaces/config_basic.ts: 25/25 tests passed.

see run history

kibanamachine avatar Jul 01 '24 15:07 kibanamachine

I found another issue with the toggle custom field. If I create a custom field with the default value set to true (toggle on) and go to create a template the default value is not populated correctly. The text field is working as expected.

cnasikas avatar Jul 01 '24 16:07 cnasikas

No, every field should be optional in templates. I quickly checked the code and it seems only Jira connector's issueTypes field has this validation. Maybe we can ignore this validation for templates. I could update https://github.com/elastic/kibana/issues/187087 to handle it.

Yes, let's handle it on another PR and update the issue as you said.

cnasikas avatar Jul 01 '24 16:07 cnasikas

I found another issue with the toggle custom field. If I create a custom field with the default value set to true (toggle on) and go to create a template the default value is not populated correctly. The text field is working as expected.

I cannot reproduce it. Probably a mistake on my part.

cnasikas avatar Jul 01 '24 16:07 cnasikas

Created an issue for custom fields bugs

js-jankisalvi avatar Jul 02 '24 09:07 js-jankisalvi

:yellow_heart: Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
cases 755 772 +17

Async chunks

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

id before after diff
cases 479.4KB 497.7KB +18.3KB

Page load bundle

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

id before after diff
cases 151.7KB 153.4KB +1.8KB
Unknown metric groups

ESLint disabled in files

id before after diff
cases 16 17 +1

ESLint disabled line counts

id before after diff
cases 61 62 +1

Total ESLint disabled count

id before after diff
cases 77 79 +2

History

  • :yellow_heart: Build #218789 was flaky daebf7fa97c2f6eafcd623cdf6a70ee291dce755
  • :green_heart: Build #218704 succeeded 4632959cef908e63079d099469ca5d45f140944d
  • :green_heart: Build #218539 succeeded db94f1cbb90ea91e47caa7a2f67679d13f15e035
  • :broken_heart: Build #218524 failed 9a8b6295f41cb0d98e4e375f8d9e35e06e14c93d
  • :broken_heart: Build #218470 failed 97dadf7364af4c3ed2d09d8962979e537c43a005
  • :green_heart: Build #218443 succeeded 9369d61f500e11799ff7eaee457beecef8019b9e

To update your PR or re-run it, just comment with: @elasticmachine merge upstream

cc @js-jankisalvi

kibana-ci avatar Jul 02 '24 10:07 kibana-ci