[SR] Selected indices do not show when editing a policy created via console #55219
[SR] Selected indices do not show when editing a policy created via console #55219jkelastic wants to merge 12 commits intoelastic:masterfrom
Conversation
|
Pinging @elastic/es-ui (Team:Elasticsearch UI) |
alisonelizabeth
left a comment
There was a problem hiding this comment.
@jkelastic great start with this! I think there's still some more work to be done here around the logic determining when to show the custom vs. list view.
...ck/legacy/plugins/snapshot_restore/public/app/components/policy_form/steps/step_settings.tsx
Outdated
Show resolved
Hide resolved
|
@elasticmachine merge upstream |
9d273cd to
8f18841
Compare
|
@alisonelizabeth I need some help fixing the issues. Not sure what to do. |
|
@sebelga would you mind reviewing/testing this one? I’ve contributed with @jkelastic, so I’d like another set of eyes on it. While debugging this issue, I discovered a SLM policy may have indices defined as a comma-separated string (per the docs) or an array. In the UI, we were sending the data back differently depending if the user selected indices using the list or combobox. IMO this caused some unnecessary complexity, as there was logic to handle both cases to some extent, but even this wasn’t working 100%. I updated the deserialization function to convert the indices to an array if it is defined as a string. The UI will also only ever send back an array now. This should address the original bug outlined in #47156 and also clean up some of the logic. |
sebelga
left a comment
There was a problem hiding this comment.
I am still seeing the bug when opening the settings tab. It says 2 indices will be backed up but actually none are selected.
I also saw another bug, maybe it deserves another PR maybe not. When I select 1 index, then I unselect the index, the tab is invalid and the "Next" button is disabled. But I can still click on the "Logistic" step. At that moment I am blocked and can't do anything and need to cancel the editing.
| return Array.isArray(config.indices) && config.indices.includes(index); | ||
| }); | ||
|
|
||
| const policyIndicesLength = Array.isArray(config.indices) && config.indices.length; |
There was a problem hiding this comment.
This will return false if config.indices is not an Array.
We probably want something like this
const policyIndicesLength = Array.isArray(config.indices) ? config.indices.length : 0;There was a problem hiding this comment.
Also, isn't config.indices always an Array? Why do we need this check?
There was a problem hiding this comment.
@sebelga It was not always an Array and then we created the check to see if it was. Then we went ahead to converted the indices to an Array (always an Array) and forgot to remove the check. I can go ahead and remove it. Thanks.
There was a problem hiding this comment.
To clarify - a user is not required to define indices, so it is possible this will be undefined.
| // Policy indices (config.indices) can contain existing indices, index patterns, aliases or non-existing indices | ||
| // This returns the policy indices that exist in a user's system | ||
| const policyIndicesInAllIndices = indices.filter(index => { | ||
| return Array.isArray(config.indices) && config.indices.includes(index); |
There was a problem hiding this comment.
Isn't config.indices always an Array? Why do we need this check?
If we need the check, it would be better outside the loop
const policyIndicesInAllIndices = Array.isArray(config.indices)
? indices.filter(index => config.indices!.includes(index))
: [];There was a problem hiding this comment.
@sebelga Same as above, I will remove this.
| selectIndicesMode === 'custom' | ||
| ? indexPatterns.join(',') | ||
| : [...(indicesSelection || [])], | ||
| selectIndicesMode === 'custom' ? [...indexPatterns] : [...(indicesSelection || [])], |
There was a problem hiding this comment.
It seems like indicesSelection is always an Array, do we need the extra || [] ?
|
In the file interface Props {
indices?: string[];
} |
@sebelga You're correct. We didn't address this bug in the ticket. I didn't know if we're suppose to. We only address whether the page loads to the "customer index pattern" or "selected index" if the index is in the policy itself. Do we need to create a separate PR ticket for this?
I will need to take a look at this. Great found. |
I think the bug should be addressed in this PR as the PR description says that this fixes #47156. Thanks 👍 ! |
|
@jkelastic Actually it would be better to not increase the fixes/changes in this PR as I am preparing a PR that will move all the SR files to the "plugins" folder. So maybe update this PR description to specify exactly what it fixes (not 47156) and steps to reproduce. This way, if I merge first, you can easily re-apply the changes on a new branch out of master. |
…ot_restore_custom_pattern
@sebelga @jkelastic I confirmed this bug exists on master, and I think should be addressed separately. The same problem occurs if I have an invalid field on the retention step and try to go back to a previous step. I opened #58773. |
|
@sebelga would you mind taking another look at this PR? I believe I addressed the bug you found, as well as your other review comments. I also wanted to clarify that this PR is meant to fix #47156, so if there are any other issues found, they should be addressed. Thanks! /cc @jkelastic |
…ot_restore_custom_pattern
💔 Build FailedTest FailuresKibana Pipeline / x-pack-intake-agent / X-Pack Jest Tests.x-pack/plugins/spaces/server/lib/request_interceptors.onRequestInterceptor requests proxied to the legacy platform handles paths without a space identifierStandard OutStack TraceKibana Pipeline / x-pack-intake-agent / X-Pack Jest Tests.x-pack/plugins/spaces/server/lib/request_interceptors.onRequestInterceptor requests proxied to the legacy platform strips the Space URL Context from the requestStandard OutStack TraceHistory
To update your PR or re-run it, just comment with: |
|
@jkelastic now that #59109 is merged, can you work to update this branch and resolve the merge conflicts? Let me know if you need help. |
|
@jkelastic I think it would be easier to create a branch from master an apply the change from the 8 files modified in this PR. |
thanks, closing this for #59486 |


Summary
Fixes #47156 Rename index pattern to custom pattern and default to customer pattern page
Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n supportDocumentation was added for features that require explanation or tutorialsThis was checked for keyboard-only and screenreader accessibilityFor maintainers
Release note
This PR resolves an issue where the indices of a Snapshot Lifecycle Policy were not always displayed correctly in the Snapshot & Restore UI when editing an existing policy.