From d58b3e14a2ea0d47099d0a36a34c3cd6ced2fec2 Mon Sep 17 00:00:00 2001 From: Sychev Andrey <44414066+SychevAndrey@users.noreply.github.com> Date: Tue, 15 Jul 2025 11:47:34 +0200 Subject: [PATCH] dbeaver/pro#6105 fix: form validation fails on test in GCP (#3583) Removed active state from Options component resources because it unload resources when we switch to other tabs which leads to broken connection form state and entails data inconsistency. For example, the check driver?.useCustomPage fails because driver resource has been unloaded and the component renders standard Parameters from instead of custom taking state from the wrong destination. Co-authored-by: Daria Marutkina <125263541+dariamarutkina@users.noreply.github.com> --- .../src/ConnectionForm/Options/Options.tsx | 39 +++++-------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/webapp/packages/plugin-connections/src/ConnectionForm/Options/Options.tsx b/webapp/packages/plugin-connections/src/ConnectionForm/Options/Options.tsx index e79c16ac45..8804d6cedb 100644 --- a/webapp/packages/plugin-connections/src/ConnectionForm/Options/Options.tsx +++ b/webapp/packages/plugin-connections/src/ConnectionForm/Options/Options.tsx @@ -48,7 +48,7 @@ import { useService } from '@cloudbeaver/core-di'; import { ProjectInfoResource } from '@cloudbeaver/core-projects'; import { EAdminPermission, ServerConfigResource } from '@cloudbeaver/core-root'; import { DriverConfigurationType } from '@cloudbeaver/core-sdk'; -import { type TabContainerPanelComponent, TabsContext, useTab } from '@cloudbeaver/core-ui'; +import { type TabContainerPanelComponent, TabsContext } from '@cloudbeaver/core-ui'; import { EMPTY_ARRAY } from '@cloudbeaver/core-utils'; import { ProjectSelect } from '@cloudbeaver/plugin-projects'; @@ -86,11 +86,8 @@ const driverConfiguration: IDriverConfiguration[] = [ ]; export const Options: TabContainerPanelComponent = observer(function Options({ formState, tabId }) { - const { selected } = useTab(tabId); const isAdmin = usePermission(EAdminPermission.admin); - const serverConfigResource = useResource(Options, ServerConfigResource, undefined, { - active: selected, - }); + const serverConfigResource = useResource(Options, ServerConfigResource, undefined); const projectInfoResource = useService(ProjectInfoResource); const formRef = useRef(null); const translate = useTranslate(); @@ -98,15 +95,9 @@ export const Options: TabContainerPanelComponent = observe const tabsState = useContext(TabsContext); const isSharedProject = projectInfoResource.isProjectShared(formState.state.projectId); const optionsPart = getConnectionFormOptionsPart(formState); - const connectionInfoAuthResource = useResource(Options, ConnectionInfoAuthPropertiesResource, optionsPart.connectionKey, { - active: selected && !!optionsPart.connectionKey, - }); - const connectionInfoOriginResource = useResource(Options, ConnectionInfoOriginResource, optionsPart.connectionKey, { - active: selected && !!optionsPart.connectionKey, - }); - const connectionInfoAuthPropertiesResource = useResource(Options, ConnectionInfoAuthPropertiesResource, optionsPart.connectionKey, { - active: selected && !!optionsPart.connectionKey, - }); + const connectionInfoAuthResource = useResource(Options, ConnectionInfoAuthPropertiesResource, optionsPart.connectionKey); + const connectionInfoOriginResource = useResource(Options, ConnectionInfoOriginResource, optionsPart.connectionKey); + const connectionInfoAuthPropertiesResource = useResource(Options, ConnectionInfoAuthPropertiesResource, optionsPart.connectionKey); const configurationTypeLabel = translate('connections_connection_configuration'); //@TODO it's here until the profile implementation in the CloudBeaver @@ -115,17 +106,10 @@ export const Options: TabContainerPanelComponent = observe useFormValidator(formState.validationTask, formRef.current); const { credentialsSavingEnabled } = useAdministrationSettings(); - const driverMap = useResource( - Options, - DBDriverResource, - { - key: optionsPart.state.driverId || null, - includes: ['includeProviderProperties', 'includeMainProperties', 'includeDriverProperties'] as const, - }, - { - active: selected, - }, - ); + const driverMap = useResource(Options, DBDriverResource, { + key: optionsPart.state.driverId || null, + includes: ['includeProviderProperties', 'includeMainProperties', 'includeDriverProperties'] as const, + }); const driver = driverMap.data; const configurationTypes = driverConfiguration.filter(configuration => driver && configuration.isVisible(driver)); @@ -136,9 +120,6 @@ export const Options: TabContainerPanelComponent = observe Options, DatabaseAuthModelsResource, getComputed(() => optionsPart.state.authModelId || connectionInfoAuthResource.data?.authModel || driver?.defaultAuthModel || null), - { - active: selected, - }, ); const authModel = authModelLoader.data; @@ -188,7 +169,7 @@ export const Options: TabContainerPanelComponent = observe await optionsPart.setDriverId(driverId); } - useAutoLoad(Options, optionsPart, selected); + useAutoLoad(Options, optionsPart); return (