diff --git a/webapp/packages/plugin-connections/src/ConnectionForm/Options/ConnectionFormOptionsPart.ts b/webapp/packages/plugin-connections/src/ConnectionForm/Options/ConnectionFormOptionsPart.ts index 32e4d579544..faa3500696a 100644 --- a/webapp/packages/plugin-connections/src/ConnectionForm/Options/ConnectionFormOptionsPart.ts +++ b/webapp/packages/plugin-connections/src/ConnectionForm/Options/ConnectionFormOptionsPart.ts @@ -49,11 +49,11 @@ const MAIN_PROPERTY_HOST_KEY = 'host'; const MAIN_PROPERTY_PORT_KEY = 'port'; const MAIN_PROPERTY_SERVER_KEY = 'server'; -const defaultStateGetter = (connectionId?: string, credentials?: Record) => +const defaultStateGetter = (connectionId?: string) => ({ connectionId, configurationType: DriverConfigurationType.Manual, - credentials: credentials ?? {}, + credentials: {}, mainPropertyValues: {}, expertSettingsValues: {}, networkHandlersConfig: [], @@ -185,14 +185,12 @@ export class ConnectionFormOptionsPart extends FormPart { if (this.formState.mode === 'create') { - const credentials = this.state.authModelId - ? getObjectPropertyDefaults(await this.getConnectionAuthModelProperties(this.state.authModelId)) - : undefined; - - this.setInitialState(defaultStateGetter(this.initialState.connectionId ?? this.formState.state.connectionId, credentials)); + const defaults = await this.getDefaults(); await this.setDriverId(this.state.driverId); + this.setInitialState(defaults); + return; } @@ -340,6 +338,36 @@ export class ConnectionFormOptionsPart extends FormPart, contexts: IExecutionContextProvider>, diff --git a/webapp/packages/plugin-connections/src/ConnectionForm/Options/Options.tsx b/webapp/packages/plugin-connections/src/ConnectionForm/Options/Options.tsx index c43f7e38cd9..bc291083e41 100644 --- a/webapp/packages/plugin-connections/src/ConnectionForm/Options/Options.tsx +++ b/webapp/packages/plugin-connections/src/ConnectionForm/Options/Options.tsx @@ -113,7 +113,7 @@ export const Options: TabContainerPanelComponent = observe const driverMap = useResource(Options, DBDriverResource, { key: optionsPart.state.driverId || null, - includes: ['includeProviderProperties', 'includeMainProperties', 'includeDriverProperties'] as const, + includes: ['includeProviderProperties', 'includeMainProperties'] as const, }); const driver = driverMap.data; diff --git a/webapp/packages/plugin-connections/src/PublicConnectionForm/PublicConnectionFormService.ts b/webapp/packages/plugin-connections/src/PublicConnectionForm/PublicConnectionFormService.ts index 80d3e0e6c80..be248642e08 100644 --- a/webapp/packages/plugin-connections/src/PublicConnectionForm/PublicConnectionFormService.ts +++ b/webapp/packages/plugin-connections/src/PublicConnectionForm/PublicConnectionFormService.ts @@ -91,7 +91,10 @@ export class PublicConnectionFormService { connectionId: config.connectionId, }).setMode(config.connectionId ? FormMode.Edit : FormMode.Create); - await this.optionsPart?.load(); + // Don't call load in create mode. There we rely on the defaults set here, and useAutoLoad will load the part on mount. + if (this.formState.mode === FormMode.Edit) { + await this.optionsPart?.load(); + } if (config.driverId) { await this.optionsPart?.setDriverId(config.driverId);