Skip to content

Commit

Permalink
fix: add getOverrideProps to StorageManager (#1020)
Browse files Browse the repository at this point in the history
* fix: add getOverrideProps to StorageManager

* fix: add overrideProps to Field component

* Revert "fix: add overrideProps to Field component"

This reverts commit 6393718.
  • Loading branch information
bombguy authored Jun 6, 2023
1 parent 1fbf44d commit 8ff282f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25021,6 +25021,7 @@ export default function CreateProductForm(props) {
showThumbnails={false}
maxFileCount={5}
maxSize={1024}
{...getOverrideProps(overrides, \\"imgKeys\\")}
></StorageManager>
</Field>
<Flex
Expand Down Expand Up @@ -25248,6 +25249,7 @@ export default function UpdateProductForm(props) {
acceptedFileTypes={[\\".doc\\", \\".pdf\\"]}
isResumable={false}
showThumbnails={true}
{...getOverrideProps(overrides, \\"imgKeys\\")}
></StorageManager>
)}
</Field>
Expand Down Expand Up @@ -25525,6 +25527,7 @@ export default function UpdateProductForm(props) {
showThumbnails={false}
maxFileCount={1}
maxSize={1024}
{...getOverrideProps(overrides, \\"singleImgKey\\")}
></StorageManager>
)}
</Field>
Expand Down
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 @@ -89,8 +89,8 @@ export class ReactComponentRenderer<TPropIn> extends ComponentRendererBase<
if (this.component.componentType === 'StorageField') {
this.importCollection.addImport(ImportSource.REACT_STORAGE, 'StorageManager');
this.importCollection.addImport(ImportSource.UI_REACT_INTERNAL, 'Field');
this.importCollection.addImport(ImportSource.UI_REACT_INTERNAL, ImportValue.GET_OVERRIDE_PROPS);
this.importCollection.addImport(ImportSource.UTILS, 'processFile');

return renderStorageFieldComponent(
this.component,
this.componentMetadata,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,7 @@ import {
ComponentMetadata,
isValidVariableName,
} from '@aws-amplify/codegen-ui';
import {
factory,
JsxAttribute,
JsxAttributeLike,
JsxChild,
JsxElement,
JsxExpression,
NodeFlags,
SyntaxKind,
} from 'typescript';
import { factory, JsxAttributeLike, JsxChild, JsxElement, JsxExpression, NodeFlags, SyntaxKind } from 'typescript';
import { getDecoratedLabel } from '../../forms/form-renderer-helper';
import { buildStorageManagerOnChangeStatement } from '../../forms/form-renderer-helper/event-handler-props';
import { propertyToExpression } from '../../react-component-render-helper';
Expand Down Expand Up @@ -339,8 +330,8 @@ export const renderStorageFieldComponent = (
const lowerCaseDataTypeName = lowerCaseFirst(dataTypeName);
const lowerCaseDataTypeNameRecord = `${lowerCaseDataTypeName}Record`;
const storageManagerComponentName = factory.createIdentifier('StorageManager');
const storageManagerAttributes: JsxAttribute[] = [];
const fieldAttributes: JsxAttribute[] = [];
const storageManagerAttributes: JsxAttributeLike[] = [];
const fieldAttributes: JsxAttributeLike[] = [];

if (componentMetadata.formMetadata) {
const errorKey =
Expand Down Expand Up @@ -494,6 +485,15 @@ export const renderStorageFieldComponent = (
}
});

storageManagerAttributes.push(
factory.createJsxSpreadAttribute(
factory.createCallExpression(factory.createIdentifier('getOverrideProps'), undefined, [
factory.createIdentifier('overrides'),
factory.createStringLiteral(componentName),
]),
),
);

const storageManager = factory.createJsxElement(
factory.createJsxOpeningElement(
storageManagerComponentName,
Expand Down

0 comments on commit 8ff282f

Please sign in to comment.