Skip to content

[ResponseOps][Cases] Remove configuration's deleted custom field from template's custom fields via API#186608

Merged
js-jankisalvi merged 5 commits intoelastic:feat/case_templatesfrom
js-jankisalvi:api-custom-fields-deletion
Jun 25, 2024
Merged

[ResponseOps][Cases] Remove configuration's deleted custom field from template's custom fields via API#186608
js-jankisalvi merged 5 commits intoelastic:feat/case_templatesfrom
js-jankisalvi:api-custom-fields-deletion

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 Platform ResponseOps team (formerly the Cases and Alerting teams) t// 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!

@js-jankisalvi js-jankisalvi merged commit 822d78c into elastic:feat/case_templates Jun 25, 2024
@js-jankisalvi js-jankisalvi deleted the api-custom-fields-deletion branch June 25, 2024 09:43
@kibana-ci
Copy link

💔 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 Platform ResponseOps team (formerly the Cases and Alerting teams) t// v8.15.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants