[Streams] Add suggested name#253652
Conversation
|
Pinging @elastic/kibana-management (Team:Kibana Management) |
| await waitFor(() => expect(onSave).toHaveBeenCalledWith('new-policy')); | ||
| }); | ||
|
|
||
| it('pre-populates the policy name field with the original policy name', () => { |
There was a problem hiding this comment.
nit: It's not really the original policy name but original + "-2" so we can change it for clarity.
| it('pre-populates the policy name field with the original policy name', () => { | |
| it('pre-populates with the default copy name', () => { |
gbamparop
left a comment
There was a problem hiding this comment.
Code only review for x-pack/platform/plugins/shared/streams_app/public/components/data_management/stream_detail_lifecycle/hooks/use_ilm_lifecycle_summary.tsx LGTM
damian-polewski
left a comment
There was a problem hiding this comment.
LGTM! Added one small non-blocking nit.
| // If the shortest candidate is already too long, any other single-digit suffix will be too. | ||
| if (getPolicyNameIsBeyondMaxBytes(`${originalPolicyName}-2`)) { | ||
| return ''; | ||
| } | ||
|
|
||
| for (let i = 2; i <= 9; i++) { | ||
| const candidate = `${originalPolicyName}-${i}`; | ||
| if (!existing.has(candidate) && !getPolicyNameIsBeyondMaxBytes(candidate)) { | ||
| return candidate; | ||
| } | ||
| } |
There was a problem hiding this comment.
Do we need to check both before and inside the loop?
There was a problem hiding this comment.
I don't think that's needed. {name}-2 and {name}-9 (max number) would have the same UTF‑8 byte length, so checking inside the loop is redundan
💔 Build Failed
Failed CI Steps
Test Failures
Metrics [docs]
History
cc @SoniaSanzV |
## Summary
Small change in the `CreatePolicyModal`. The modal now needs a new prop
with the name of the original policy from which is being copied, in
order of pre-populate a name that would help the user. It tries to
suggest a name by adding a small number to the end of the original name:
first `{original-policy-name}-2`, if that already exists then
`{original-policy-name}-3`, then `{original-policy-name}-4`, up to
`{original-policy-name}-9`; if all of those already exist, it leaves the
field empty so the user can choose a name.
### How to test
View and test the component in Storybook:
```bash
yarn storybook streams_app
```
It can also be tested in the Streams UI:
* Create a policy with some downsampling steps
* Assign it to a couple of streams, remove a downsampling step from one
of them.
* Click save as new
* Verify the text field is filled with a suggested name
https://github.com/user-attachments/assets/aa1bb08d-b311-48c7-bd49-6bdfcefb676b
## Summary
Small change in the `CreatePolicyModal`. The modal now needs a new prop
with the name of the original policy from which is being copied, in
order of pre-populate a name that would help the user. It tries to
suggest a name by adding a small number to the end of the original name:
first `{original-policy-name}-2`, if that already exists then
`{original-policy-name}-3`, then `{original-policy-name}-4`, up to
`{original-policy-name}-9`; if all of those already exist, it leaves the
field empty so the user can choose a name.
### How to test
View and test the component in Storybook:
```bash
yarn storybook streams_app
```
It can also be tested in the Streams UI:
* Create a policy with some downsampling steps
* Assign it to a couple of streams, remove a downsampling step from one
of them.
* Click save as new
* Verify the text field is filled with a suggested name
https://github.com/user-attachments/assets/aa1bb08d-b311-48c7-bd49-6bdfcefb676b
Summary
Small change in the
CreatePolicyModal. The modal now needs a new prop with the name of the original policy from which is being copied, in order of pre-populate a name that would help the user. It tries to suggest a name by adding a small number to the end of the original name: first{original-policy-name}-2, if that already exists then{original-policy-name}-3, then{original-policy-name}-4, up to{original-policy-name}-9; if all of those already exist, it leaves the field empty so the user can choose a name.How to test
View and test the component in Storybook:
It can also be tested in the Streams UI:
Screen.Recording.2026-02-18.at.11.57.18.mov