Skip to content

Commit

Permalink
laFix: Dynamic Data value initialization fix (#1799)
Browse files Browse the repository at this point in the history
* Fixed issue

* Added extra specification to include the /

* Improved the catch for openApi parameters
  • Loading branch information
rllyy97 committed Mar 23, 2023
1 parent 7feac29 commit dd3750c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
17 changes: 12 additions & 5 deletions libs/designer/src/lib/core/utils/parameters/dynamicdata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import type {
} from '@microsoft/parsers-logic-apps';
import {
parseEx,
splitEx,
removeConnectionPrefix,
isLegacyDynamicValuesExtension,
ExtensionProperties,
Expand Down Expand Up @@ -396,11 +397,13 @@ function getManifestBasedInputParameters(
// Load the entire input if the key is the entire input.
clonedInputParameter.value = stepInputs;
} else {
// Compare the object value with the last segment of the key.
// If the key is something simple like 'inputs.$.foo', we take just 'foo'.
// If the key is something complex like 'inputs.$.foo.foo/bar.foo/bar/baz', we take 'foo/bar/baz'.
const parsedKey = parseEx(inputParameter.key.replace(`${keyPrefix}.`, ''));
const inputPath = `${parsedKey.pop()?.value}`;
/*
We have two formats to support:
Default: inputs.$.foo.bar.baz => foo.bar.baz
OpenApi: inputs.$.foo.foo/bar.foo/bar/baz => foo/bar/baz
*/
let inputPath = inputParameter.key.replace(`${keyPrefix}.`, '');
if (isOpenApiParameter(inputParameter)) inputPath = splitEx(inputPath)?.at(-1) ?? '';
clonedInputParameter.value = stepInputsAreNonEmptyObject ? getObjectValue(inputPath, stepInputs) : undefined;
}
result.push(clonedInputParameter);
Expand Down Expand Up @@ -577,3 +580,7 @@ function getSwaggerTypeFromVariableType(variableType: string): string | undefine
return undefined;
}
}

function isOpenApiParameter(param: InputParameter): boolean {
return !!param?.alias;
}
2 changes: 1 addition & 1 deletion libs/designer/src/lib/ui/settings/settingsection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ const Setting = ({ id, settings, isReadOnly }: { id?: string; settings: Settings
key: (setting.settingProp as any).id,
text: (setting.settingProp as any).label,
}))}
style={{ width: '80%', margin: '24px auto 0 auto' }}
style={{ margin: '24px auto 0 auto' }}
selectedKeys={conditionalVisibilityTempArray}
onChange={(_e: any, item: any) => {
if (item?.key) {
Expand Down
8 changes: 8 additions & 0 deletions libs/parsers/src/lib/common/helpers/keysutility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ export function parseEx(key: string | null | undefined): Segment[] {
return key.split(_separator).map(_decodeSegment);
}

export function splitEx(key: string | null | undefined): string[] {
if (isNullOrUndefined(key)) {
return [];
}

return key.split(_separator);
}

export function encodePropertySegment(segment: string): string {
segment = _replaceCharacter(segment, _escapeCharacter, _encodedEscapeCharacter);
_codeBook.forEach((entry) => {
Expand Down

0 comments on commit dd3750c

Please sign in to comment.