From 0001051b1804f148020080eb074ae812c1d23cc2 Mon Sep 17 00:00:00 2001 From: ccastrotrejo Date: Tue, 27 Feb 2024 09:36:24 -0800 Subject: [PATCH] Revert "feat(designer): [ConnectionCreation] Adding hidden parameter field in ConnectionCreationInfo to pass selected credential id (#4193)" This reverts commit 2d43902c95b9eeb9ec9536939309c3224431e8e9. --- .../_test__/createConnection.spec.tsx | 31 +------------------ .../createConnection/createConnection.tsx | 24 +++----------- .../createConnectionWrapper.tsx | 4 +-- .../src/lib/connection.ts | 1 - .../src/lib/standard/connection.ts | 3 -- 5 files changed, 7 insertions(+), 56 deletions(-) diff --git a/libs/designer/src/lib/ui/panel/connectionsPanel/createConnection/_test__/createConnection.spec.tsx b/libs/designer/src/lib/ui/panel/connectionsPanel/createConnection/_test__/createConnection.spec.tsx index ea21a9c8f51..b46e24ab09a 100644 --- a/libs/designer/src/lib/ui/panel/connectionsPanel/createConnection/_test__/createConnection.spec.tsx +++ b/libs/designer/src/lib/ui/panel/connectionsPanel/createConnection/_test__/createConnection.spec.tsx @@ -1,5 +1,5 @@ import { MockHttpClient } from '../../../../../__test__/mock-http-client'; -import { CreateConnection, parseParameterValues, type CreateConnectionProps } from '../createConnection'; +import { CreateConnection, type CreateConnectionProps } from '../createConnection'; import { UniversalConnectionParameter } from '../formInputs/universalConnectionParameter'; import { InitConnectionParameterEditorService, @@ -578,35 +578,6 @@ describe('ui/createConnection', () => { const mappingEditors = findParameterComponents(createConnection, CustomCredentialMappingEditor); expect(mappingEditors).toHaveLength(0); }); - - test('parseParameterValues', () => { - const parameterValues: Record = { - a: 'foobar', - b: 42, - c: null, - d: undefined, - e: { foo: 'bar' }, - f: ['id', 66], - }; - const capabilityEnabledParameters: Record = { - a: { type: 'connection' }, - z: { type: 'other' }, - }; - - const { visibleParameterValues, additionalParameterValues } = parseParameterValues(parameterValues, capabilityEnabledParameters); - expect(visibleParameterValues).toStrictEqual({ a: 'foobar' }); - expect(additionalParameterValues).toStrictEqual({ - b: 42, - c: null, - d: undefined, - e: { foo: 'bar' }, - f: ['id', 66], - }); - - const emptyParameters = parseParameterValues({}, capabilityEnabledParameters); - expect(emptyParameters.visibleParameterValues).toStrictEqual({}); - expect(emptyParameters.additionalParameterValues).toStrictEqual({}); - }); }); function findConnectionCreateDiv(createConnection: ReactElement) { diff --git a/libs/designer/src/lib/ui/panel/connectionsPanel/createConnection/createConnection.tsx b/libs/designer/src/lib/ui/panel/connectionsPanel/createConnection/createConnection.tsx index aabc1d03069..cff65ed1a04 100644 --- a/libs/designer/src/lib/ui/panel/connectionsPanel/createConnection/createConnection.tsx +++ b/libs/designer/src/lib/ui/panel/connectionsPanel/createConnection/createConnection.tsx @@ -60,8 +60,7 @@ export interface CreateConnectionProps { parameterValues?: Record, isOAuthConnection?: boolean, alternativeParameterValues?: Record, - identitySelected?: string, - additionalParameterValues?: Record + identitySelected?: string ) => void; cancelCallback?: () => void; hideCancelButton?: boolean; @@ -302,7 +301,9 @@ export const CreateConnection = (props: CreateConnectionProps) => { const canSubmit = useMemo(() => !isLoading && validParams, [isLoading, validParams]); const submitCallback = useCallback(() => { - const { visibleParameterValues, additionalParameterValues } = parseParameterValues(parameterValues, capabilityEnabledParameters); + const visibleParameterValues = Object.fromEntries( + Object.entries(parameterValues).filter(([key]) => Object.keys(capabilityEnabledParameters).includes(key)) ?? [] + ); // This value needs to be passed conditionally but the parameter is hidden, so we're manually inputting it here if ( @@ -325,8 +326,7 @@ export const CreateConnection = (props: CreateConnectionProps) => { visibleParameterValues, isUsingOAuth, alternativeParameterValues, - identitySelected, - additionalParameterValues + identitySelected ); }, [ parameterValues, @@ -654,17 +654,3 @@ const isServicePrincipalParameterVisible = (key: string, parameter: any): boolea if (constraints?.hidden === 'true' || constraints?.hideInUI === 'true') return false; return true; }; - -export function parseParameterValues( - parameterValues: Record, - capabilityEnabledParameters: Record -) { - const visibleParameterValues = Object.fromEntries( - Object.entries(parameterValues).filter(([key]) => Object.keys(capabilityEnabledParameters).includes(key)) ?? [] - ); - const additionalParameterValues = Object.fromEntries( - Object.entries(parameterValues).filter(([key]) => !Object.keys(capabilityEnabledParameters).includes(key)) ?? [] - ); - - return { visibleParameterValues, additionalParameterValues }; -} diff --git a/libs/designer/src/lib/ui/panel/connectionsPanel/createConnection/createConnectionWrapper.tsx b/libs/designer/src/lib/ui/panel/connectionsPanel/createConnection/createConnectionWrapper.tsx index a8da35fdcdf..c3073adb0b8 100644 --- a/libs/designer/src/lib/ui/panel/connectionsPanel/createConnection/createConnectionWrapper.tsx +++ b/libs/designer/src/lib/ui/panel/connectionsPanel/createConnection/createConnectionWrapper.tsx @@ -129,8 +129,7 @@ export const CreateConnectionWrapper = () => { parameterValues: Record = {}, isOAuthConnection?: boolean, alternativeParameterValues?: Record, - identitySelected?: string, - additionalParameterValues?: Record + identitySelected?: string ) => { if (!connector?.id) return; @@ -189,7 +188,6 @@ export const CreateConnectionWrapper = () => { : undefined, connectionParameters: outputParameterValues, alternativeParameterValues, - additionalParameterValues, }; const parametersMetadata: ConnectionParametersMetadata = { diff --git a/libs/services/designer-client-services/src/lib/connection.ts b/libs/services/designer-client-services/src/lib/connection.ts index 6c0a237b79b..04b21fd61c5 100644 --- a/libs/services/designer-client-services/src/lib/connection.ts +++ b/libs/services/designer-client-services/src/lib/connection.ts @@ -21,7 +21,6 @@ export interface ConnectionCreationInfo { displayName?: string; parameterName?: string; appSettings?: Record; - additionalParameterValues?: Record; } export interface ConnectionParametersMetadata { diff --git a/libs/services/designer-client-services/src/lib/standard/connection.ts b/libs/services/designer-client-services/src/lib/standard/connection.ts index 215db824691..23c40ff625c 100644 --- a/libs/services/designer-client-services/src/lib/standard/connection.ts +++ b/libs/services/designer-client-services/src/lib/standard/connection.ts @@ -48,7 +48,6 @@ interface ServiceProviderConnectionModel { }; parameterSetName?: string; displayName?: string; - additionalParameterValues?: Record; } interface FunctionsConnectionModel { @@ -606,7 +605,6 @@ function convertToServiceProviderConnectionsData( displayName, connectionParameters: connectionParameterValues, connectionParametersSet: connectionParametersSetValues, - additionalParameterValues, } = connectionInfo; const connectionParameters = connectionParametersSetValues ? connectionParameterMetadata.connectionParameterSet?.parameters @@ -628,7 +626,6 @@ function convertToServiceProviderConnectionsData( ...optional('parameterSetName', connectionParametersSetValues?.name), serviceProvider: { id: connectorId }, displayName, - ...optional('additionalParameterValues', additionalParameterValues), }, settings: connectionInfo.appSettings ?? {}, pathLocation: [serviceProviderLocation],