Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CB-5197 create main connection fields dynamically #2693

Merged

Conversation

yagudin10
Copy link
Member

No description provided.

@devnaumov devnaumov marked this pull request as ready for review June 12, 2024 12:26
@Property
public Map<String, String> getMainProperties() {
Map<String, String> mainProperties = new LinkedHashMap<>();
mainProperties.put(DBConstants.PROP_HOST, dataSourceContainer.getConnectionConfiguration().getHostName());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may be move dataSourceContainer.getConnectionConfiguration() to parameter

@@ -248,6 +248,10 @@ type DriverInfo {
# Driver parameters (map name->value)
driverParameters: Object!

# Main driver properties
# Contains info about main fields (host, port, database, server name)
mainProperties: [ObjectPropertyInfo!]! @since(version: "24.1.1")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mainProperties sounds strange 🤔

databaseName: String @deprecated(reason: "24.1.1, use mainProperties")

# Host, port, serverName, databaseName are stored and mainProperties
mainProperties: Object @since(version: "24.1.1")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Comment on lines 407 to +410

const config = contexts.getContext(connectionConfigContext);
const stateContext = contexts.getContext(formStateContext);
const driver = await this.dbDriverResource.load(data.config.driverId!, ['includeProviderProperties']);
const driver = await this.dbDriverResource.load(data.config.driverId!, ['includeProviderProperties', 'includeMainProperties']);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may be like this? i dont like when we trick TS like this with "!"

Suggested change
const config = contexts.getContext(connectionConfigContext);
const stateContext = contexts.getContext(formStateContext);
const driver = await this.dbDriverResource.load(data.config.driverId!, ['includeProviderProperties']);
const driver = await this.dbDriverResource.load(data.config.driverId!, ['includeProviderProperties', 'includeMainProperties']);
if (!data.info || !data.config.driverId) {
return;
}
const config = contexts.getContext(connectionConfigContext);
const stateContext = contexts.getContext(formStateContext);
const driver = await this.dbDriverResource.load(data.config.driverId, ['includeProviderProperties', 'includeMainProperties']);

}

const driverConfiguration: IDriverConfiguration[] = [
{
name: 'Manual',
value: DriverConfigurationType.Manual,
isVisible: driver => driver.configurationTypes.includes(DriverConfigurationType.Manual),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we add here also extra check that some properties are exists like you did in DriverConfigurationType.Custom a little bit below?

},
{
name: 'URL',
value: DriverConfigurationType.Url,
isVisible: driver => driver.configurationTypes.includes(DriverConfigurationType.Url),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

@sergeyteleshev sergeyteleshev requested a review from Wroud June 18, 2024 10:01
Comment on lines 340 to 342
if (tempConfig.configurationType === DriverConfigurationType.Custom && !!driver.mainProperties?.length) {
tempConfig.mainProperties = this.prepareDynamicProperties(driver.mainProperties, tempConfig.mainProperties, tempConfig.configurationType);
}
Copy link
Member

@Wroud Wroud Jun 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i will suggest to use switch(tempConfig.configurationType) to exclude unwanted effects from different types of configuration so you can be sure that you'll sent only state related to selected configuration

for example:
tempConfig.mainProperties = toJS(state.config.mainProperties); always set

it can reflect on:

if (tempConfig.configurationType === DriverConfigurationType.Custom && !!driver.mainProperties?.length) {
      tempConfig.mainProperties = this.prepareDynamicProperties(driver.mainProperties, tempConfig.mainProperties, tempConfig.configurationType);
    }

@yagudin10 yagudin10 force-pushed the CB-5197-create-connection-fields-dynamically branch from b8a74ac to e7b0225 Compare June 27, 2024 15:39
@alexander-skoblikov alexander-skoblikov merged commit 49875e4 into devel Jul 1, 2024
7 of 8 checks passed
@devnaumov devnaumov deleted the CB-5197-create-connection-fields-dynamically branch July 12, 2024 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants