-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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] Add custom fields: List type #194236
base: main
Are you sure you want to change the base?
Conversation
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
/ci |
Pinging @elastic/response-ops (Team:ResponseOps) |
Pinging @elastic/response-ops-cases (Feature:Cases) |
💛 Build succeeded, but was flaky
Failed CI StepsMetrics [docs]Module Count
Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: |
rt.strict({ type: CustomFieldListTypeRt }), | ||
CustomFieldConfigurationWithoutTypeRt, | ||
rt.strict({ | ||
options: rt.array(ListCustomFieldOptionRt), |
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.
Should we limit the number of options? @cnasikas
options: rt.array(ListCustomFieldOptionRt), | |
options: limitedArraySchema(ListCustomFieldOptionRt), |
<EuiFlexItem> | ||
<EuiButtonEmpty | ||
iconType={'plusInCircle'} | ||
onClick={onAddOption} |
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.
Testing this form one thing I missed from a user perspective was pressing Enter to add a new option.
That way I can type an option, press enter, type another, press enter, type another, etc
Instead of type, mouse, type, mouse.
UX-wise I really missed that option.
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 have a bug with the following scenario:
- Created a List custom field with two options(
b
andc
). - Created a case and set the custom field value to be
b
. - Went back to the settings and deleted the option
b
. - Now in the case the custom field has no value but I cannot edit it to set
c
. (See video.)
Screen.Recording.2024-10-14.at.11.25.02.mov
…ustom-field # Conflicts: # x-pack/plugins/cases/public/components/custom_fields/text/create.test.tsx
@adcoelho Feedback addressed. Added a 10 item limit to options on the UI side and the API side. Bug fixed as well. |
Found a couple of issues: 1. Moving an empty new option causes another one to be createdScreen recordingScreenshot.mov2.
|
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.
Great work!! 🎉
Found an issue in continuation to what @adcoelho found while deleting an option. Once the option which was selected as defaultValue is deleted, the next option is set as default in custom field.
However it is not visible when case is created.
See video:
List.cf.delete.mov
value: false, | ||
}, | ||
], | ||
// await waitFor(() => { |
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.
forgotten comment, if you are 100% you want to do this it should be removed, right? I personally would leave it as it was just because I'm to afraid of flakiness in CI. There is at least two more places where this happens, I don't want to spam with "same here"
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.
Thanks for catching that
))} | ||
</EuiDroppable> | ||
</EuiDragDropContext> | ||
{maxOptions && currentOptions.length < maxOptions && ( |
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.
should we test this?
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 probably, just added this feature and neglected to test, fixing now
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.
In the research issue, we went through all the available options and we picked the one that satisfies all of the criteria: filtering, searching, sorting, renaming, and deletion.
Key in Cases SO | Value in Cases SO | Filtering | Searching | Sorting | OFTB Renaming | OFTB Deletion |
---|---|---|---|---|---|---|
Custom field key (UUID) | Option key (UUID) | ✅ | ❌ | ❌ | ✅ | ❌ |
Custom field key + Option key | Actual value | ✅ | ✅ | ✅ | ❌ | ❌ |
You cannot sort or search in ES because the SO will have the UUID and not the actual value. For the second option in the above table, we can satisfy renaming or deletion but we need to use the task manager which requires extra work as described in the research issue.
Engineering this turned out to require major changes to the form UI library and the API transformation libraries, and it's a less drastic change to simply convert the key to a label when displaying the field.
As mentioned in #176491 there is no need to make changes in the form UI library. The library supports serializer and deserializer where we can convert the form (UI) data to the schema expected by the backend and vice-versa. Also, the transformer we have in place in the CasesService
can transform the data from what is expected by the cases client and the cases SO.
💔 Build Failed
Failed CI StepsTest Failures
Metrics [docs]Module Count
Async chunks
Page load bundle
History
|
I'm able to get as far as transforming the key/value pair to the dot notation in I imagine this might have something to do with saved object schemas but I'm unsure. Will keep investigating |
Schema is getting saved in the form successfully but deserializing it into the View and Edit components don't seem to be working properly. Trying to figure that out, it's not calling the deserializer where I expected it to but still somehow transforming the saved object value I think. |
Summary
Closes #176491
Adds the List custom field type to Cases. Also makes some changes to the custom field configuration type system to handle the new features added in this field type.
The List field type creates a
<select>
dropdown with a set ofoptions
determined by the custom field's configuration. Options are defined as{ key: UUID, label: String }
.When the user selects a value, it is saved to the case with the schema
{ key: Custom Field UUID, value: Option UUID }
. The option'slabel
is fetched at runtime by the UI from the custom field configuration, and displayed. This is a deviation from the research issue proposal, which specced a schema of{ key: ${Field UUID}.{Option UUID}, label: Option Label }
. Engineering this turned out to require major changes to the form UI library and the API transformation libraries, and it's a less drastic change to simply convert the key to a label when displaying the field.Option labels can be renamed for free using this new schema, since the UUID is the only thing stored in case saved objects. We don't need to create a new issue to add renaming support.
This PR also allows List fields to be filtered. This required a change from using static
filterOptions
in custom field configurations to a dynamicgetFilterOptions
function. The Toggle field was updated to use this new dynamic function.Known Issues
Due to elastic/eui#8027 drag-and-drop on the new
<OptionsField>
doesn't correctly render the current draggable element inside the flyout. EUI is aiming to fix this before 8.16.Checklist