Skip to content

Commit

Permalink
PMM-12608 Match validation to table stats + fix table stats
Browse files Browse the repository at this point in the history
  • Loading branch information
matejkubinec committed Nov 13, 2023
1 parent 11d3cfa commit b8ff0a9
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { FormApi } from 'final-form';
import React, { FC, useEffect, useMemo, useState } from 'react';
import React, { FC, useEffect, useState } from 'react';

import { useStyles2 } from '@grafana/ui';
import { InstanceAvailableType, RemoteInstanceCredentials } from 'app/percona/add-instance/panel.types';
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 @@ -45,7 +44,6 @@ export const AdditionalOptionsFormPart: FC<AdditionalOptionsFormPartProps> = ({
export const PostgreSQLAdditionalOptions: FC<PostgreSQLAdditionalOptionsProps> = ({ form, isRDS, isAzure }) => {
const selectedOption = form.getState()?.values?.autoDiscoveryOptions;
const [selectedValue, setSelectedValue] = useState<string>(selectedOption || AutoDiscoveryOptionsInterface.enabled);
const autoDiscoveryValidators = useMemo(() => [validators.min(0)], []);
const styles = useStyles2(getStyles);

const getAutoDiscoveryLimitValue = (type: AutoDiscoveryOptionsInterface) =>
Expand Down Expand Up @@ -83,7 +81,7 @@ export const PostgreSQLAdditionalOptions: FC<PostgreSQLAdditionalOptionsProps> =
name="autoDiscoveryLimit"
defaultValue={0}
disabled={selectedValue !== AutoDiscoveryOptionsInterface.custom}
validators={autoDiscoveryValidators}
validate={platformCoreValidators.containsNumber}
label={Messages.form.labels.postgresqlDetails.autoDiscoveryLimit}
tooltipText={Messages.form.tooltips.postgresqlDetails.autoDiscoveryLimit}
/>
Expand All @@ -109,7 +107,8 @@ const MySQLOptions = ({ form }: { form: FormApi }) => {
useEffect(() => {
setSelectedValue(selectedOption);
form.change('tablestats_group_table_limit', getTablestatValues(selectedOption));
}, [selectedOption, form]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [selectedOption]);

return (
<>
Expand Down

0 comments on commit b8ff0a9

Please sign in to comment.