[8.x] Update configuration on changes in category/advanced configurations in configView (#195567) (#195708)

# Backport

This will backport the following commits from `main` to `8.x`:
- [Update configuration on changes in category/advanced configurations
in configView (#195567)](https://github.com/elastic/kibana/pull/195567)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Artem
Shelkovnikov","email":"artem.shelkovnikov@elastic.co"},"sourceCommit":{"committedDate":"2024-10-10T07:34:17Z","message":"Update
configuration on changes in category/advanced configurations in
configView (#195567)\n\n## Closes
https://github.com/elastic/search-team/issues/6557\r\n\r\n##
Summary\r\n\r\nFixes a known bug for Network Drive connector (as this
feature is only\r\nused in it). The problem happens when there are Rich
Configurable Fields\r\nthat are marked as \"advanced\" and depend on
certain fields - in some\r\ncases this field will not be shown until the
page is fully reloaded.\r\n\r\nCriteria that makes the bug
happen:\r\n\r\n1. Have some RCFs that are marked as
\"advanced\":\r\nhttps://github.com/elastic/connectors/blob/main/connectors/sources/network_drive.py#L405-L414.\r\n(`\"ui_restrictions\":
[\"advanced\"]`)\r\n2. Make it so that this RCF depends on another
field, and by default is\r\nhidden - for example this field depends on a
field \"OS\" that has\r\n\"Windows\" and \"Linux\" as available options
and Windows is default, but\r\nthis RCF depends on it being
\"Linux\"\r\n3. Try satisfying the dependency and see if the RCF is
displayed - it\r\nwon't be, unless you save the form and reload
it\r\n\r\nThe problem happens because for changes in \"advanced\"
section the\r\nconfiguration is not updated, so the view that's rendered
still thinks\r\nthat the dependency is not satisfied and the field
should not
be\r\nrendered\r\n\r\nBefore:\r\n\r\n\r\nbe32f434-0810-4345-bc4e-dc82f617705c\r\n\r\n\r\n###
Checklist\r\n\r\n- [ ] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] This
renders correctly on smaller devices using a responsive\r\nlayout. (You
can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n\r\n###
For maintainers\r\n\r\n- [ ] This was checked for breaking API changes
and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"72c76f9ac9c43365bcfb70903c9d848012260291","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","v8.16.0","backport:version","v8.15.3"],"title":"Update
configuration on changes in category/advanced configurations in
configView","number":195567,"url":"https://github.com/elastic/kibana/pull/195567","mergeCommit":{"message":"Update
configuration on changes in category/advanced configurations in
configView (#195567)\n\n## Closes
https://github.com/elastic/search-team/issues/6557\r\n\r\n##
Summary\r\n\r\nFixes a known bug for Network Drive connector (as this
feature is only\r\nused in it). The problem happens when there are Rich
Configurable Fields\r\nthat are marked as \"advanced\" and depend on
certain fields - in some\r\ncases this field will not be shown until the
page is fully reloaded.\r\n\r\nCriteria that makes the bug
happen:\r\n\r\n1. Have some RCFs that are marked as
\"advanced\":\r\nhttps://github.com/elastic/connectors/blob/main/connectors/sources/network_drive.py#L405-L414.\r\n(`\"ui_restrictions\":
[\"advanced\"]`)\r\n2. Make it so that this RCF depends on another
field, and by default is\r\nhidden - for example this field depends on a
field \"OS\" that has\r\n\"Windows\" and \"Linux\" as available options
and Windows is default, but\r\nthis RCF depends on it being
\"Linux\"\r\n3. Try satisfying the dependency and see if the RCF is
displayed - it\r\nwon't be, unless you save the form and reload
it\r\n\r\nThe problem happens because for changes in \"advanced\"
section the\r\nconfiguration is not updated, so the view that's rendered
still thinks\r\nthat the dependency is not satisfied and the field
should not
be\r\nrendered\r\n\r\nBefore:\r\n\r\n\r\nbe32f434-0810-4345-bc4e-dc82f617705c\r\n\r\n\r\n###
Checklist\r\n\r\n- [ ] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] This
renders correctly on smaller devices using a responsive\r\nlayout. (You
can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n\r\n###
For maintainers\r\n\r\n- [ ] This was checked for breaking API changes
and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"72c76f9ac9c43365bcfb70903c9d848012260291"}},"sourceBranch":"main","suggestedTargetBranches":["8.x","8.15"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/195567","number":195567,"mergeCommit":{"message":"Update
configuration on changes in category/advanced configurations in
configView (#195567)\n\n## Closes
https://github.com/elastic/search-team/issues/6557\r\n\r\n##
Summary\r\n\r\nFixes a known bug for Network Drive connector (as this
feature is only\r\nused in it). The problem happens when there are Rich
Configurable Fields\r\nthat are marked as \"advanced\" and depend on
certain fields - in some\r\ncases this field will not be shown until the
page is fully reloaded.\r\n\r\nCriteria that makes the bug
happen:\r\n\r\n1. Have some RCFs that are marked as
\"advanced\":\r\nhttps://github.com/elastic/connectors/blob/main/connectors/sources/network_drive.py#L405-L414.\r\n(`\"ui_restrictions\":
[\"advanced\"]`)\r\n2. Make it so that this RCF depends on another
field, and by default is\r\nhidden - for example this field depends on a
field \"OS\" that has\r\n\"Windows\" and \"Linux\" as available options
and Windows is default, but\r\nthis RCF depends on it being
\"Linux\"\r\n3. Try satisfying the dependency and see if the RCF is
displayed - it\r\nwon't be, unless you save the form and reload
it\r\n\r\nThe problem happens because for changes in \"advanced\"
section the\r\nconfiguration is not updated, so the view that's rendered
still thinks\r\nthat the dependency is not satisfied and the field
should not
be\r\nrendered\r\n\r\nBefore:\r\n\r\n\r\nbe32f434-0810-4345-bc4e-dc82f617705c\r\n\r\n\r\n###
Checklist\r\n\r\n- [ ] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] This
renders correctly on smaller devices using a responsive\r\nlayout. (You
can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n\r\n###
For maintainers\r\n\r\n- [ ] This was checked for breaking API changes
and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"72c76f9ac9c43365bcfb70903c9d848012260291"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.15","label":"v8.15.3","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Artem Shelkovnikov <artem.shelkovnikov@elastic.co>
This commit is contained in:
Kibana Machine 2024-10-10 20:23:33 +11:00 committed by GitHub
parent 0aa261047e
commit f72f86660c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -109,6 +109,15 @@ export const ConnectorConfigurationForm: React.FC<ConnectorConfigurationForm> =
items={category.configEntries}
hasDocumentLevelSecurityEnabled={hasDocumentLevelSecurity}
setConfigEntry={(key, value) => {
const entry = localConfig[key];
if (entry && !isCategoryEntry(entry)) {
const newConfiguration: ConnectorConfiguration = {
...localConfig,
[key]: { ...entry, value },
};
setLocalConfig(newConfiguration);
}
const categories = configView.categories;
categories[index] = { ...categories[index], [key]: value };
setConfigView({
@ -136,6 +145,15 @@ export const ConnectorConfigurationForm: React.FC<ConnectorConfigurationForm> =
items={configView.advancedConfigurations}
hasDocumentLevelSecurityEnabled={hasDocumentLevelSecurity}
setConfigEntry={(key, value) => {
const entry = localConfig[key];
if (entry && !isCategoryEntry(entry)) {
const newConfiguration: ConnectorConfiguration = {
...localConfig,
[key]: { ...entry, value },
};
setLocalConfig(newConfiguration);
}
setConfigView({
...configView,
advancedConfigurations: configView.advancedConfigurations.map((config) =>