Skip to content

Commit

Permalink
Check connection on configurator change
Browse files Browse the repository at this point in the history
  • Loading branch information
seveneleven committed Apr 29, 2024
1 parent dc24790 commit 6385fb8
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,22 @@ class DatabaseModel extends React.Component<DatabaseModelPropsModel & DatabaseMo
this.setState({ activeTab: tabId });
}

public getValidationState(entryName: string) {
private getValidationState(entryName: string): React.JSX.ElementAttributesProperty {
const result = this.props.DataModel.possibleConfigurators.find((x) => x.configuratorTypename === this.props.DataModel.config.configuratorTypename)
?.properties.find((x) => x.name === entryName).required
? (this.props.DataModel.config.entries[entryName]
? { error: false }
: { error: true })
: { error: false };

return result;
return { props: result };
}

public onConfiguratorTypeChanged(e: React.ChangeEvent<HTMLInputElement>): void {
this.props.DataModel.config.configuratorTypename = e.target.value;
this.props.DataModel.config.entries = this.getConfigWithDefaultValue(e.target.value);

this.onTestConnection();
}

public onInputChanged(e: string, entryName: string): void {
Expand All @@ -116,7 +118,7 @@ class DatabaseModel extends React.Component<DatabaseModelPropsModel & DatabaseMo
this.setState({ selectedBackup: e.target.value });
}

public createEntriesInput() {
private createEntriesInput(): React.JSX.Element[] {
return Object.keys(this.props.DataModel.config.entries)?.map((element) => {
return (
<TextField
Expand All @@ -135,15 +137,15 @@ class DatabaseModel extends React.Component<DatabaseModelPropsModel & DatabaseMo
});
}

public getConfigEntries() {
private getConfigEntries(): any {
const newEntries: any = {};
this.props.DataModel.possibleConfigurators[0].properties.forEach((property) => {
newEntries[property.name] = "";
});
return newEntries;
}

public getConfigWithDefaultValue(configuratorName: string) {
private getConfigWithDefaultValue(configuratorName: string): any {
const newEntries: any = {};
this.props.DataModel.possibleConfigurators
.find((x) => x.configuratorTypename === configuratorName)
Expand Down Expand Up @@ -325,7 +327,7 @@ class DatabaseModel extends React.Component<DatabaseModelPropsModel & DatabaseMo
}
}

public getMigrations() {
private getMigrations(): DbMigrationsModel[] {
return this.props.DataModel.availableMigrations;
}

Expand Down

0 comments on commit 6385fb8

Please sign in to comment.