Skip to content

Commit

Permalink
Update configuration on changes in category/advanced configurations i…
Browse files Browse the repository at this point in the history
…n configView (elastic#195567)

## Closes elastic/search-team#6557

## Summary

Fixes a known bug for Network Drive connector (as this feature is only
used in it). The problem happens when there are Rich Configurable Fields
that are marked as "advanced" and depend on certain fields - in some
cases this field will not be shown until the page is fully reloaded.

Criteria that makes the bug happen:

1. Have some RCFs that are marked as "advanced":
https://github.com/elastic/connectors/blob/main/connectors/sources/network_drive.py#L405-L414.
(`"ui_restrictions": ["advanced"]`)
2. Make it so that this RCF depends on another field, and by default is
hidden - for example this field depends on a field "OS" that has
"Windows" and "Linux" as available options and Windows is default, but
this RCF depends on it being "Linux"
3. Try satisfying the dependency and see if the RCF is displayed - it
won't be, unless you save the form and reload it

The problem happens because for changes in "advanced" section the
configuration is not updated, so the view that's rendered still thinks
that the dependency is not satisfied and the field should not be
rendered

Before:


https://github.com/user-attachments/assets/51f9f8b0-a57a-4d96-a183-6dbbd36a919e

After:


https://github.com/user-attachments/assets/be32f434-0810-4345-bc4e-dc82f617705c


### Checklist

- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))

### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
  • Loading branch information
artem-shelkovnikov authored Oct 10, 2024
1 parent 8ebd793 commit 72c76f9
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 72c76f9

Please sign in to comment.