-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
[ResponseOps][Cases] Allow users to create case using templates #187138
Conversation
## Summary Implements #181573 This PR allows users to create, update and delete templates using existing configure API Flaky test runner: https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/5846 Test via Postman: - Can create the template - Can update the template - Can delete the template - Maximum 10 templates allowed - Template cases fields are validated as per the existing schema - custom fields within templates are validated as per the existing schema ### Checklist - [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 - [x] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed
## Summary Parent issue: #181309 This PR adds optional tags field in template. ### Checklist - [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: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
## Summary Merging into feature branch. Implements create functionality #181864 Add template from case settings page. <img width="1728" alt="image" src="https://github.com/elastic/kibana/assets/117571355/4a4565e5-3ca8-4a7c-a5c9-0ac15b72a0d0"> **How to test** - Go to Cases > Settings - Click on add templates - Fill the form - Save Scenarios: - Create template with different custom fields - Create template with connector Flaky test runner [here](https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/6213) ### Checklist Delete any items that are not applicable to this PR. - [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/packages/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [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 - [x] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [x] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/)) - [x] This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server)) --------- Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
## Summary Merging into feature branch. Implements edit and delete functionality #181864 Edit or delete template from case settings page. https://github.com/elastic/kibana/assets/117571355/f6fd45fa-c1eb-45ab-8936-02c764dbadc4 **How to test** - Go to Cases > Settings - Add a template - Click on edit template icon - Update the fields - Click save - Click on delete template icon - Click on confirm modal - Click save **Scenarios:** - Edit template with different custom fields - Edit template with connector - Delete template **Flaky Test** [here](https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/6331) ### Checklist - [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 - [x] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [x] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/)) --------- Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
… template's custom fields via API (#186608) ## Summary Parent issue: #181309 This PR takes care of below scenario: When user deletes custom fields via API, those custom fields need to be removed from templates as well. [Flaky test runner](https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/6377) **Testing** - create a custom field in settings page - create a template with that custom field in settings page - Get configuration via postman for same owner, should have customFields and templates attribute similar to this: ``` [ { "customFields": [ { "key": "new_custom_field_key_2", "type": "toggle", "label": "My toggle custom field", "required": "false", } ], "templates": [ { "key": "template_key_1", "name": "Template with CF1", "caseFields": { "customFields": [ { "key": "new_custom_field_key_2", "type": "toggle", "value": false } ] }, }, ], "version": ${config_version} "id": ${config_id} } ] ``` - run the patch request via postman to delete the custom field, e.g: ``` path: https://localhost:5601/api/cases/configure/config_id body: { "customFields": [], "templates": [ { "key": "new_template_key_1", "name": "New template", "caseFields": { "customFields": [ { "key": "new_custom_field_key_2", "type": "toggle", "value": true } ] } } ], "version": "test-version" } ``` - validate that custom field is removed from templates as well ### Checklist - [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: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Pinging @elastic/response-ops (Team:ResponseOps) |
Pinging @elastic/response-ops-cases (Feature:Cases) |
## Summary This PR adds the ability for users to select a template when creating a case. When a user selects a template the cases form fields are populated with the values from the template. The solution picker in the flyout changed as: <img width="1281" alt="Screenshot 2024-06-20 at 1 26 14 PM" src="https://github.com/elastic/kibana/assets/7871006/30859c61-94e7-4f0a-97d1-cb081bd72c36"> ## Bug fixes 1. Changing the solution through the solution picket in the flyout would not respect the connector's configuration. 2. Bug where the lazy loading of connectors' icons was causing the flyout to open and close when you selected a solution picket. This bug appeared when the first bug was fixed. ## Testing 1. Go to all solutions and create cases setting all fields (including all fields of all supported connectors) without using templates. Verify that everything is working as expected. 2. 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. 3. 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. 4. 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. Fixes: #181871 Depends on: #185877 ### Checklist Delete any items that are not applicable to this PR. - [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 - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed ### For maintainers - [x] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) --------- Co-authored-by: Janki Salvi <117571355+js-jankisalvi@users.noreply.github.com> Co-authored-by: adcoelho <antonio.coelho@elastic.co>
@@ -65,6 +65,7 @@ export const attachTimeline = (newCase: TestCase) => { | |||
cy.get('body').type('{esc}'); | |||
cy.get(INSERT_TIMELINE_BTN).click(); | |||
cy.get(LOADING_INDICATOR).should('not.exist'); | |||
cy.get('[data-test-subj="selectable-input"]').click(); |
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.
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.
@js-jankisalvi some questions for you.
- I created a template and saved it. Does it means I have to always apply the template when creating a new case? Would I be able to create a new case without a template applied?
Screen.Recording.2024-07-01.at.11.05.00.mov
- I deleted the case template from settings, then go back to case and create a new case. The new case had an empty template input that I had no options in as the first step. At the same time, the template information I deleted seemed still applying to my new case. Could you please double check this behaviour? Thanks.
Screen.Recording.2024-07-01.at.11.08.43.mov
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
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 |
In the first video, I wasn't able to unselected the template after selecting one, adding an option
I think I clicked |
Yes, agree. |
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.
Code change for threat hunting ✅
Created a bug for case description: #187236 |
connectors={connectors} | ||
isLoading={isLoadingConnectors || isLoadingCaseConfiguration} | ||
withSteps={withSteps} | ||
draftStorageKey={draftStorageKey} |
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.
I think this line is the source of this bug.
We could make the draftStorageKey
optional and not include it in the creation form. What do you guys think?
The draft was originally implemented for the comments in the edit case page.
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.
yes it's fine to not have description storage while creating a case. It is more useful for edit description scenario.
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.
What is the current behavior on main? What if you spent a lot of time writing the description on the case and you made a mistake (refresh the browser, etc)?
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.
Currently in main, we save session for description while creating a case. It is removed when we cancel
the create case. But stays when we use back to cases
button.
What if you spent a lot of time writing the description on the case and you made a mistake (refresh the browser, etc)?
That is a good point. Maybe we can keep the session but it should be removed when we click Back to cases
?
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.
Yes, let's do this! It can be done on another PR.
If I have a default 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? |
Fixed here 6319822 |
I was messing around with custom field default values and whatnot. If I:
I am having trouble uploading the screen recording so ping me offline if the description above is not clear 😅 |
yup, it's different.
No, every field should be optional in templates. I quickly checked the code and it seems only |
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. |
I found another issue with the toggle custom field. If I create a custom field with the default value set to |
Yes, let's handle it on another PR and update the issue as you said. |
I cannot reproduce it. Probably a mistake on my part. |
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 discussed offline a couple of bugs will be fixed after. Besides that I tested it and it works as expected.
Nice work! 🔥
Created an issue for custom fields bugs |
💛 Build succeeded, but was flaky
Failed CI StepsMetrics [docs]Module Count
Async chunks
Page load bundle
Unknown metric groupsESLint disabled in files
ESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
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.
I tested all possible scenarions with connectors, custom fields, case fields, etc in different solutions. I also tested the case flyout in solutions and outside of solutions. Everything is working as expected. I found two small bugs but we can fix them on another PR:
- When selecting template tags I can see duplicates
- When I delete a connector and I edit a template the selection is empty. I think we should set it to the
none
connector when the user views the template. On the backend we can leave it as it is with the connector. We do the same with cases.
Great work!! 🚀
Summary
Fixes #181309
This PR
template.demo.mov
Testing
Checklist
Delete any items that are not applicable to this PR.
Flaky test runner: https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/6425
For maintainers
Release notes
Allow users to create case using templates.