Skip to content

Commit

Permalink
[8.x] Update configuration on changes in category/advanced configurat…
Browse files Browse the repository at this point in the history
…ions 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)](#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":"[email protected]"},"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\nhttps://github.com/user-attachments/assets/51f9f8b0-a57a-4d96-a183-6dbbd36a919e\r\n\r\nAfter:\r\n\r\n\r\nhttps://github.com/user-attachments/assets/be32f434-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\nhttps://github.com/user-attachments/assets/51f9f8b0-a57a-4d96-a183-6dbbd36a919e\r\n\r\nAfter:\r\n\r\n\r\nhttps://github.com/user-attachments/assets/be32f434-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\nhttps://github.com/user-attachments/assets/51f9f8b0-a57a-4d96-a183-6dbbd36a919e\r\n\r\nAfter:\r\n\r\n\r\nhttps://github.com/user-attachments/assets/be32f434-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 <[email protected]>
  • Loading branch information
kibanamachine and artem-shelkovnikov authored Oct 10, 2024
1 parent 0aa2610 commit f72f866
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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) =>
Expand Down

0 comments on commit f72f866

Please sign in to comment.