Skip to content

Commit

Permalink
PMM-12971 Update default max connection logic
Browse files Browse the repository at this point in the history
  • Loading branch information
YashSartanpara1 committed May 21, 2024
1 parent 49b9dd3 commit 912d148
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ export const PostgreSQLAdditionalOptions: FC<PostgreSQLAdditionalOptionsProps> =
const getAutoDiscoveryLimitValue = (type: AutoDiscoveryOptionsInterface) =>
type === AutoDiscoveryOptionsInterface.disabled ? -1 : 10;

const getMaxConnectionLimitValue = (type: MaxConnectionLimitOptionsInterface) => 5;
const getMaxConnectionLimitValue = (type: MaxConnectionLimitOptionsInterface) =>
type === MaxConnectionLimitOptionsInterface.disabled ? null : 5;

useEffect(() => {
setSelectedValue(selectedOption);
Expand Down Expand Up @@ -120,8 +121,8 @@ export const PostgreSQLAdditionalOptions: FC<PostgreSQLAdditionalOptionsProps> =
key="maxExporterConnections"
name="maxExporterConnections"
defaultValue={5}
placeholder={'5'}
disabled={maxConnSelectedValue !== MaxConnectionLimitOptionsInterface.enabled}
validators={validators}
label={Messages.form.labels.postgresqlDetails.maxConnectionLimit}
tooltipText={Messages.form.tooltips.postgresqlDetails.maxConnectionLimit}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ export enum AutoDiscoveryOptionsInterface {
export enum MaxConnectionLimitOptionsInterface {
enabled = 'enabled',
disabled = 'disabled',
custom = 'custom',
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,4 @@ describe('PostgreSQL connection details:: ', () => {

expect(screen.getByTestId('maxQueryLength-text-input')).toHaveValue('1000');
});

it('should have max connection field for pg and rds pg', () => {
render(
<Form
onSubmit={jest.fn()}
render={() => <PostgreSQLConnectionDetails remoteInstanceCredentials={{ isAzure: false }} />}
/>
);
const connectionlimitInput = screen.queryByTestId('maxExporterConnections-text-input');
expect(connectionlimitInput).toBeInTheDocument();
});

it('should not have max connection field for Azure', () => {
render(
<Form
onSubmit={jest.fn()}
render={() => <PostgreSQLConnectionDetails remoteInstanceCredentials={{ isAzure: true }} />}
/>
);
const connectionlimitInput = screen.queryByTestId('maxExporterConnections-text-input');
expect(connectionlimitInput).not.toBeInTheDocument();
});
});

0 comments on commit 912d148

Please sign in to comment.