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

[ResponseOps][Cases] Fix template's custom fields bugs #187591

Merged

Conversation

js-jankisalvi
Copy link
Contributor

@js-jankisalvi js-jankisalvi commented Jul 4, 2024

Summary

Fixes #187333

Testing behaviour:

Issue 1: verify similar behaviour from API as well.

  1. Create a template
  2. Add new toggle custom field with default value as true
  3. Go to create case, See that new toggle custom field has value: true
  4. Select recently created template
  5. Toggle custom field new custom field with it's default value

Issue 2: verify similar behaviour from API as well.

  1. Create a text custom field with default value
  2. Create a template
  3. Set text custom field value to empty
  4. Save template
  5. Go to create case
  6. Select recently created template
  7. See that text custom field value is updated as per template's custom field value

@js-jankisalvi js-jankisalvi added bug Fixes for quality problems that affect the customer experience release_note:skip Skip the PR/issue when compiling release notes Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) Feature:Cases Cases feature v8.15.0 labels Jul 4, 2024
@js-jankisalvi js-jankisalvi self-assigned this Jul 4, 2024
@js-jankisalvi js-jankisalvi requested a review from a team as a code owner July 4, 2024 16:53
@elasticmachine
Copy link
Contributor

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

@elasticmachine
Copy link
Contributor

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

Copy link
Contributor

@adcoelho adcoelho left a comment

Choose a reason for hiding this comment

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

Tested and it's working as expected 👍
Left some small comments.

Copy link
Member

@cnasikas cnasikas left a comment

Choose a reason for hiding this comment

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

Tested and everything is working as expected. LGTM!

@@ -436,8 +436,13 @@ export async function create(
fieldName: 'customFields',
});

await validateTemplates({
const updatedTemplates = transformTemplateCustomFields({
Copy link
Member

Choose a reason for hiding this comment

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

I was thinking that, only for the create scenario, it may be fine if we throw a bad request error because the user tries to create a configuration with invalid custom fields in templates. Wdyt?

Copy link
Contributor Author

@js-jankisalvi js-jankisalvi Jul 11, 2024

Choose a reason for hiding this comment

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

Updated create configuration scenario to throw error

  • when templates don't have custom fields but request payload has custom fields.
  • when templates have custom fields but request payload doesn't have custom fields.

x-pack/plugins/cases/server/client/utils.ts Outdated Show resolved Hide resolved
x-pack/plugins/cases/server/client/utils.ts Outdated Show resolved Hide resolved
@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Async chunks

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

id before after diff
cases 501.9KB 502.6KB +684.0B

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.8KB 151.8KB +66.0B

History

cc @js-jankisalvi

@js-jankisalvi js-jankisalvi merged commit 6b0d628 into elastic:main Jul 11, 2024
21 checks passed
@js-jankisalvi js-jankisalvi deleted the templates-custom-fields-bug-fix branch July 11, 2024 16:13
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jul 11, 2024
## Summary

Fixes elastic#187333

## Testing behaviour:
Issue 1: verify similar behaviour from API as well.

1. Create a template
2. Add new toggle custom field with default value as true
3. Go to create case, See that new toggle custom field has value: true
4. Select recently created template
5. Toggle custom field new custom field with it's default value

Issue 2: verify similar behaviour from API as well.
1. Create a text custom field with default value
2. Create a template
3. Set text custom field value to empty
4. Save template
5. Go to create case
6. Select recently created template
7. See that text custom field value is updated as per template's custom
field value

(cherry picked from commit 6b0d628)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.15

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 Jul 11, 2024
…187591) (#188135)

# Backport

This will backport the following commits from `main` to `8.15`:
- [[ResponseOps][Cases] Fix template's custom fields bugs
(#187591)](#187591)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Janki
Salvi","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-07-11T16:13:19Z","message":"[ResponseOps][Cases]
Fix template's custom fields bugs (#187591)\n\n## Summary\r\n\r\nFixes
https://github.com/elastic/kibana/issues/187333\r\n\r\n## Testing
behaviour: \r\nIssue 1: verify similar behaviour from API as
well.\r\n\r\n1. Create a template\r\n2. Add new toggle custom field with
default value as true\r\n3. Go to create case, See that new toggle
custom field has value: true\r\n4. Select recently created
template\r\n5. Toggle custom field new custom field with it's default
value\r\n\r\nIssue 2: verify similar behaviour from API as well.\r\n1.
Create a text custom field with default value\r\n2. Create a
template\r\n3. Set text custom field value to empty\r\n4. Save
template\r\n5. Go to create case\r\n6. Select recently created
template\r\n7. See that text custom field value is updated as per
template's custom\r\nfield
value","sha":"6b0d62805352c391fc7bfdb47ff848c0a46080ee","branchLabelMapping":{"^v8.16.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","Team:ResponseOps","Feature:Cases","v8.15.0","v8.16.0"],"title":"[ResponseOps][Cases]
Fix template's custom fields
bugs","number":187591,"url":"https://github.com/elastic/kibana/pull/187591","mergeCommit":{"message":"[ResponseOps][Cases]
Fix template's custom fields bugs (#187591)\n\n## Summary\r\n\r\nFixes
https://github.com/elastic/kibana/issues/187333\r\n\r\n## Testing
behaviour: \r\nIssue 1: verify similar behaviour from API as
well.\r\n\r\n1. Create a template\r\n2. Add new toggle custom field with
default value as true\r\n3. Go to create case, See that new toggle
custom field has value: true\r\n4. Select recently created
template\r\n5. Toggle custom field new custom field with it's default
value\r\n\r\nIssue 2: verify similar behaviour from API as well.\r\n1.
Create a text custom field with default value\r\n2. Create a
template\r\n3. Set text custom field value to empty\r\n4. Save
template\r\n5. Go to create case\r\n6. Select recently created
template\r\n7. See that text custom field value is updated as per
template's custom\r\nfield
value","sha":"6b0d62805352c391fc7bfdb47ff848c0a46080ee"}},"sourceBranch":"main","suggestedTargetBranches":["8.15"],"targetPullRequestStates":[{"branch":"8.15","label":"v8.15.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/187591","number":187591,"mergeCommit":{"message":"[ResponseOps][Cases]
Fix template's custom fields bugs (#187591)\n\n## Summary\r\n\r\nFixes
https://github.com/elastic/kibana/issues/187333\r\n\r\n## Testing
behaviour: \r\nIssue 1: verify similar behaviour from API as
well.\r\n\r\n1. Create a template\r\n2. Add new toggle custom field with
default value as true\r\n3. Go to create case, See that new toggle
custom field has value: true\r\n4. Select recently created
template\r\n5. Toggle custom field new custom field with it's default
value\r\n\r\nIssue 2: verify similar behaviour from API as well.\r\n1.
Create a text custom field with default value\r\n2. Create a
template\r\n3. Set text custom field value to empty\r\n4. Save
template\r\n5. Go to create case\r\n6. Select recently created
template\r\n7. See that text custom field value is updated as per
template's custom\r\nfield
value","sha":"6b0d62805352c391fc7bfdb47ff848c0a46080ee"}}]}] BACKPORT-->

Co-authored-by: Janki Salvi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Feature:Cases Cases feature 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.15.0 v8.16.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ResponseOps][Cases] Template's custom field issues
5 participants