Skip to content

Commit

Permalink
feat: various workflow cleanup (#383)
Browse files Browse the repository at this point in the history
  • Loading branch information
dpilch authored and alharris-at committed Feb 25, 2022
1 parent 91f6786 commit db2c7c6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion packages/codegen-ui-react/lib/react-component-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class ReactComponentRenderer<TPropIn> extends ComponentRendererBase<
.map(([key]) =>
buildOpeningElementControlEvents(
getSetStateName({ componentName: this.component.name || '', property: key }),
'change', // TODO: use component event mapping
'change',
),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class ReactComponentWithChildrenRenderer<TPropIn> extends ComponentWithCh
.map(([key]) =>
buildOpeningElementControlEvents(
getSetStateName({ componentName: this.component.name || '', property: key }),
'change', // TODO: use component event mapping
'change',
),
);

Expand Down
33 changes: 18 additions & 15 deletions packages/codegen-ui-react/lib/workflow/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,11 @@ export function buildUseActionStatement(
factory.createIdentifier(identifier),
undefined,
undefined,
factory.createCallExpression(factory.createIdentifier(actionHookImportValue), undefined, [
buildActionParameters(action, importCollection),
]),
factory.createCallExpression(
factory.createIdentifier(actionHookImportValue),
undefined,
buildActionArguments(action, importCollection),
),
),
],
ts.NodeFlags.Const,
Expand Down Expand Up @@ -165,24 +167,25 @@ export function buildMutationActionStatement(component: StudioComponent, action:
*
* model and fields are special cases. All other fields are StudioComponentProperty
*/
export function buildActionParameters(
export function buildActionArguments(
action: ActionStudioComponentEvent,
importCollection: ImportCollection,
): ObjectLiteralExpression {
): ObjectLiteralExpression[] | undefined {
if (action.parameters) {
// TODO: add special case for model and fields
return factory.createObjectLiteralExpression(
Object.entries(action.parameters).map(([key, value]) =>
factory.createPropertyAssignment(
factory.createIdentifier(key),
getActionParameterValue(key, value, importCollection),
return [
factory.createObjectLiteralExpression(
Object.entries(action.parameters).map(([key, value]) =>
factory.createPropertyAssignment(
factory.createIdentifier(key),
getActionParameterValue(key, value, importCollection),
),
),
false,
),
false,
);
];
}
// TODO: determine what should be used when no parameters
return factory.createObjectLiteralExpression([], false);

return undefined;
}

export function getActionParameterValue(
Expand Down

0 comments on commit db2c7c6

Please sign in to comment.