Skip to content

Commit

Permalink
PMM-12971 fix validation and rds parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
YashSartanpara1 committed May 24, 2024
1 parent f40197c commit f116cb3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export interface RDSPayload extends CommonRDSAzurePayload {
metrics_mode: string;
qan_postgresql_pgstatements: boolean;
agent_password: string;
max_exporter_connections: number;
max_postgresql_exporter_connections: number;
}

export interface MSAzurePayload extends CommonRDSAzurePayload {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { CheckboxField } from 'app/percona/shared/components/Elements/Checkbox';
import { NumberInputField } from 'app/percona/shared/components/Form/NumberInput';
import { RadioButtonGroupField } from 'app/percona/shared/components/Form/RadioButtonGroup';
import { Databases } from 'app/percona/shared/core';
import Validators from 'app/percona/shared/helpers/validators';
import { validators as platformCoreValidators } from 'app/percona/shared/helpers/validatorsForm';

import { rdsTrackingOptions, trackingOptions } from '../FormParts.constants';
Expand Down Expand Up @@ -53,7 +54,8 @@ export const PostgreSQLAdditionalOptions: FC<PostgreSQLAdditionalOptionsProps> =
maxConnSelectedOption || MaxConnectionLimitOptionsInterface.disabled
);
const styles = useStyles2(getStyles);
const validators = [platformCoreValidators.containsNumber, ...platformCoreValidators.int32];
const validators = [platformCoreValidators.containsNumber, platformCoreValidators.int32];
const maxConnValidators = [Validators.min(0), platformCoreValidators.int32];

const getAutoDiscoveryLimitValue = (type: AutoDiscoveryOptionsInterface) =>
type === AutoDiscoveryOptionsInterface.disabled ? -1 : 10;
Expand Down Expand Up @@ -118,10 +120,13 @@ export const PostgreSQLAdditionalOptions: FC<PostgreSQLAdditionalOptionsProps> =
fullWidth
/>
<NumberInputField
key="maxExporterConnections"
name="maxExporterConnections"
key={isRDS ? 'MaxPostgresqlExporterConnections' : 'maxExporterConnections'}
name={isRDS ? 'MaxPostgresqlExporterConnections' : 'maxExporterConnections'}
defaultValue={5}
placeholder={'5'}
validators={
maxConnSelectedValue === MaxConnectionLimitOptionsInterface.enabled ? maxConnValidators : undefined
}
disabled={maxConnSelectedValue !== MaxConnectionLimitOptionsInterface.enabled}
label={Messages.form.labels.postgresqlDetails.maxConnectionLimit}
tooltipText={Messages.form.tooltips.postgresqlDetails.maxConnectionLimit}
Expand Down
9 changes: 7 additions & 2 deletions public/app/percona/shared/helpers/validatorsForm/int32.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { INT_32 } from '../../core';

import { lessThan, greaterThan } from '.';
export const int32 = (value: string) => {
const num = parseFloat(value);
if (Number.isFinite(num) && Number.isInteger(num) && num > INT_32.min - 1 && num < INT_32.max + 1) {
return undefined;
}

export const int32 = [greaterThan(INT_32.min - 1), lessThan(INT_32.max + 1)];
return `Must be an Integer number`;
};

0 comments on commit f116cb3

Please sign in to comment.