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

[Cases] Custom fields types #165671

Merged

Conversation

adcoelho
Copy link
Contributor

@adcoelho adcoelho commented Sep 5, 2023

Connected with #160236

Merging into a Feature Branch

Summary

This PR defines the customField in the Cases API and Domain types.

For now, we only allow the custom fields string, boolean, and list.

This PR does not include the case configuration types.

The default value for the field is [].

@adcoelho adcoelho 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.11.0 labels Sep 5, 2023
@adcoelho adcoelho self-assigned this Sep 5, 2023
@adcoelho adcoelho changed the title Custom fields types [Cases] Custom fields types Sep 5, 2023
@adcoelho adcoelho marked this pull request as ready for review September 5, 2023 16:11
@adcoelho adcoelho requested review from a team as code owners September 5, 2023 16:12
@elasticmachine
Copy link
Contributor

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

@elasticmachine
Copy link
Contributor

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

Copy link
Member

@afharo afharo left a comment

Choose a reason for hiding this comment

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

Destructive mapping changes are not allowed since 8.9.

CI also claimed that https://buildkite.com/elastic/kibana-pull-request/builds/156536#018a661a-466f-4416-a98d-5eee69e13ea5 😇

Copy link
Contributor

@js-jankisalvi js-jankisalvi left a comment

Choose a reason for hiding this comment

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

LGTM, Nice work 👍

x-pack/plugins/cases/common/types/api/case/v1.test.ts Outdated Show resolved Hide resolved
x-pack/plugins/cases/common/types/api/case/v1.test.ts Outdated Show resolved Hide resolved
x-pack/plugins/cases/common/types/domain/case/v1.ts Outdated Show resolved Hide resolved
x-pack/plugins/cases/common/types/api/case/v1.ts Outdated Show resolved Hide resolved
x-pack/plugins/cases/common/types/api/case/v1.ts Outdated Show resolved Hide resolved
x-pack/plugins/cases/common/types/domain/case/v1.test.ts Outdated Show resolved Hide resolved
x-pack/plugins/cases/common/types/api/case/v1.test.ts Outdated Show resolved Hide resolved
x-pack/plugins/cases/common/types/domain/case/v1.test.ts Outdated Show resolved Hide resolved
x-pack/plugins/cases/common/types/domain/case/v1.test.ts Outdated Show resolved Hide resolved
x-pack/plugins/cases/server/client/cases/update.test.ts Outdated Show resolved Hide resolved
x-pack/plugins/cases/server/common/types/case.ts Outdated Show resolved Hide resolved
x-pack/plugins/cases/server/common/utils.test.ts Outdated Show resolved Hide resolved
x-pack/plugins/cases/server/services/cases/transform.ts Outdated Show resolved Hide resolved
x-pack/plugins/cases/server/services/cases/transform.ts Outdated Show resolved Hide resolved
x-pack/plugins/cases/server/services/cases/transform.ts Outdated Show resolved Hide resolved
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.

Thank you for your patient with my review!

@@ -174,6 +178,9 @@ export function transformSavedObjectToExternalModel(
SEVERITY_ESMODEL_TO_EXTERNAL[caseSavedObjectAttributes.severity] ?? CaseSeverity.LOW;
const status = STATUS_ESMODEL_TO_EXTERNAL[caseSavedObjectAttributes.status] ?? CaseStatuses.open;
const category = !caseSavedObjectAttributes.category ? null : caseSavedObjectAttributes.category;
const customFields = !caseSavedObjectAttributes.customFields
? []
: (caseSavedObjectAttributes.customFields as unknown as CaseCustomFields);
Copy link
Member

Choose a reason for hiding this comment

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

nit: unknown is not needed.

@adcoelho
Copy link
Contributor Author

Nah, thank you for finding all those things @cnasikas :D

@kibana-ci
Copy link
Collaborator

kibana-ci commented Sep 12, 2023

💔 Build Failed

Failed CI Steps

Test Failures

  • [job] [logs] Serverless Security Explore Cypress Tests #1 / Cases connector incident fields Correct incident fields show when connector is changed Correct incident fields show when connector is changed
  • [job] [logs] Cases Cypress Tests on Security Solution / Cases connector incident fields Correct incident fields show when connector is changed Correct incident fields show when connector is changed
  • [job] [logs] Serverless Security Explore Cypress Tests #1 / Cases connector incident fields Correct incident fields show when connector is changed Correct incident fields show when connector is changed
  • [job] [logs] Cases Cypress Tests on Security Solution / Cases connector incident fields Correct incident fields show when connector is changed Correct incident fields show when connector is changed

Metrics [docs]

Page load bundle

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

id before after diff
cases 152.1KB 152.7KB +537.0B

History

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

cc @adcoelho

@adcoelho adcoelho merged commit a5eaad9 into elastic:cases-custom-fields-feature-branch Sep 12, 2023
1 check passed
adcoelho added a commit that referenced this pull request Sep 14, 2023
## Summary

This was missing in my previous PR #165671
js-jankisalvi added a commit that referenced this pull request Oct 2, 2023
## Summary

This PR implements an MPV for custom fields in Cases. Specifically:

- Users can add, delete, or edit custom fields from the configuration
page
- Users can set custom fields when creating a case
- Users can set custom fields when editing a case
- Only the `Text` custom field type is supported. The `Toggle` is
implemented to test the framework.
- Users with a basic license can enter the configuration page and set
custom fields
- The configuration page header changed to "Settings"
- The "Edit external connection" button changed to "Settings"
- APIs:
    - Users cannot post custom fields with duplicate keys
    - Users cannot change the type of the custom field
    - Users cannot add custom fields that are not configured
    - Required fields should be present
- If some of the custom fields are omitted from the request the backend
will fill them with `null` values
- Limits:
    - Maximum 10 custom fields configured
    - Maximum 50 chars in custom field labels
    - Maximum 160 chars for the value of the `Text` custom field type
    - Users cannot change the type of a custom field
- The key of the custom fields should contain only lowercase letters
(a-z), numbers (0-9), '_', and '-'
    - Required fields needs a value

## Testing
- Cases created before custom fields are working as expected (create
some on `main` before switching to the feature branch)
- Environments without configuration are working as expected (clear ES
data)
- Environments with existing configurations are working as expected
- Try to create cases with custom fields (required & optional) and
delete some of them
- Try to create cases with custom fields (required & optional) and then
configure new custom fields. Existing cases with old custom fields
should work as expected
- User actions are working as expected especially with the combinations
described in the previous two bullets
- Users with a basic license can configure custom fields but cannot
configure connectors
- Users with a gold+ license can configure custom fields and connectors
- Users with read access cannot configure or edit custom fields

Resolves: #160236

PRs:

- #165671
- #166353
- #166439
- #166483
- #166815
- #166940
- #166962
- #166969
- #166975
- #167029
- #167047
- #167105
- #167131
- #167144
- #167166
- #167167
- #167310
- #167386
- #167481
- #167495
- #167398
- #167472

### 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)
- [x]
[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

### 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)

## Release notes
Allow users to configure custom fields in Cases. Supported field types:
Text. Coming soon: Multi-text, List, Number, Toggle, Date, IP, Email,
etc.

---------

Co-authored-by: adcoelho <[email protected]>
Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Christos Nasikas <[email protected]>
Co-authored-by: Julian Gernun <[email protected]>
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.11.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants