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] Remove configuration's deleted custom field from template's custom fields via API #186608

Conversation

js-jankisalvi
Copy link
Contributor

@js-jankisalvi js-jankisalvi commented Jun 21, 2024

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

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

@js-jankisalvi js-jankisalvi 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) Feature:Cases Cases feature v8.15.0 labels Jun 21, 2024
@js-jankisalvi js-jankisalvi self-assigned this Jun 21, 2024
@js-jankisalvi js-jankisalvi requested a review from a team as a code owner June 21, 2024 10:30
@elasticmachine
Copy link
Contributor

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

@elasticmachine
Copy link
Contributor

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

@js-jankisalvi js-jankisalvi changed the title [ResponseOps][Cases] Removed configuration's deleted custom field from template's custom fields API [ResponseOps][Cases] Remove configuration's deleted custom field from template's custom fields via API Jun 21, 2024
Copy link
Contributor

@doakalexi doakalexi left a comment

Choose a reason for hiding this comment

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

Tested locally and works as expected, LGTM!

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.

LGTM left a minimal comment 👍

@js-jankisalvi
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

Flaky Test Runner Stats

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

[✅] x-pack/test/cases_api_integration/security_and_spaces/config_basic.ts: 25/25 tests passed.
[✅] x-pack/test/cases_api_integration/security_and_spaces/config_trial.ts: 25/25 tests passed.

see run history

@kibanamachine
Copy link
Contributor

Flaky Test Runner Stats

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

[✅] x-pack/test/cases_api_integration/security_and_spaces/config_basic.ts: 25/25 tests passed.
[✅] x-pack/test/cases_api_integration/security_and_spaces/config_trial.ts: 25/25 tests passed.

see run history

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.

LGTM!

x-pack/plugins/cases/server/client/utils.test.ts Outdated Show resolved Hide resolved
x-pack/plugins/cases/server/client/utils.test.ts Outdated Show resolved Hide resolved
@js-jankisalvi js-jankisalvi merged commit 822d78c into elastic:feat/case_templates Jun 25, 2024
4 of 7 checks passed
@js-jankisalvi js-jankisalvi deleted the api-custom-fields-deletion branch June 25, 2024 09:43
@kibana-ci
Copy link
Collaborator

💔 Build Failed

Failed CI Steps

Metrics [docs]

‼️ ERROR: no builds found for mergeBase sha [7e92302]

History

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

cc @js-jankisalvi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants