Skip to content

Commit

Permalink
fixup: explicitly pass in the proxy feature flag to the connection form
Browse files Browse the repository at this point in the history
  • Loading branch information
addaleax committed Aug 27, 2024
1 parent fa14cef commit 03fe506
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export function useConnectionFormPreferences() {
const protectConnectionStringsForNewConnections = usePreference(
'protectConnectionStringsForNewConnections'
);
const showProxySettings = usePreference('enableProxySupport');

return useMemo(
() => ({
Expand All @@ -23,6 +24,7 @@ export function useConnectionFormPreferences() {
enableOidc,
enableDebugUseCsfleSchemaMap,
protectConnectionStringsForNewConnections,
showProxySettings,
}),
[
protectConnectionStrings,
Expand All @@ -32,6 +34,7 @@ export function useConnectionFormPreferences() {
enableOidc,
enableDebugUseCsfleSchemaMap,
protectConnectionStringsForNewConnections,
showProxySettings,
]
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { errorMessageByFieldName } from '../../../utils/validation';
import { getConnectionStringUsername } from '../../../utils/connection-string-helpers';
import type { OIDCOptions } from '../../../utils/oidc-handler';
import { useConnectionFormPreference } from '../../../hooks/use-connect-form-preferences';
import { usePreference } from 'compass-preferences-model/provider';

type AuthFlowType = NonNullable<OIDCOptions['allowedFlows']>[number];

Expand Down Expand Up @@ -59,11 +58,8 @@ function AuthenticationOIDC({
() => openSettingsModal?.('proxy'),
[openSettingsModal]
);
const enableProxySupport = usePreference('enableProxySupport');
const showProxySettings =
useConnectionFormPreference('showProxySettings') &&
enableProxySupport &&
openSettingsModal;
useConnectionFormPreference('showProxySettings') && openSettingsModal;
return (
<>
<FormFieldContainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const renderWithOptionsAndUrl = (
connectionOptions={connectionOptions}
connectionStringUrl={connectionStringUrl}
updateConnectionFormField={updateConnectionFormField}
_showProxySettingsForTesting={true}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import SshTunnelPassword from './ssh-tunnel-password';
import Socks from './socks';
import { AppProxy } from './app-proxy';
import type { ConnectionFormError } from '../../../utils/validation';
import { usePreference } from 'compass-preferences-model/provider';
import { useConnectionFormPreference } from '../../../hooks/use-connect-form-preferences';

interface TabOption {
Expand Down Expand Up @@ -114,14 +113,12 @@ function ProxyAndSshTunnelTab({
updateConnectionFormField,
errors,
connectionStringUrl,
_showProxySettingsForTesting,
openSettingsModal,
}: {
errors: ConnectionFormError[];
connectionStringUrl: ConnectionStringUrl;
updateConnectionFormField: UpdateConnectionFormField;
connectionOptions?: ConnectionOptions;
_showProxySettingsForTesting?: boolean;
openSettingsModal?: (tab?: string) => void;
}): React.ReactElement {
const selectedTunnelType: TunnelType = getSelectedTunnelType(
Expand All @@ -130,10 +127,7 @@ function ProxyAndSshTunnelTab({
);

const options = [...tabOptions];
const enableProxySupport = usePreference('enableProxySupport');
const showProxySettings =
(useConnectionFormPreference('showProxySettings') && enableProxySupport) ||
_showProxySettingsForTesting;
const showProxySettings = useConnectionFormPreference('showProxySettings');
if (showProxySettings) {
options.push({
title: 'Application-level Proxy',
Expand Down

0 comments on commit 03fe506

Please sign in to comment.