Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add getOverrideProps to StorageManager #1020

Merged
merged 3 commits into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24984,6 +24984,7 @@ export default function CreateProductForm(props) {
label={\\"Images\\"}
isRequired={false}
isReadOnly={false}
{...getOverrideProps(overrides, \\"imgKeys\\")}
>
<StorageManager
onUploadSuccess={({ key }) => {
Expand Down Expand Up @@ -25021,6 +25022,7 @@ export default function CreateProductForm(props) {
showThumbnails={false}
maxFileCount={5}
maxSize={1024}
{...getOverrideProps(overrides, \\"imgKeys\\")}
></StorageManager>
</Field>
<Flex
Expand Down Expand Up @@ -25211,6 +25213,7 @@ export default function UpdateProductForm(props) {
label={\\"Images\\"}
isRequired={false}
isReadOnly={false}
{...getOverrideProps(overrides, \\"imgKeys\\")}
>
{productRecord && (
<StorageManager
Expand Down Expand Up @@ -25248,6 +25251,7 @@ export default function UpdateProductForm(props) {
acceptedFileTypes={[\\".doc\\", \\".pdf\\"]}
isResumable={false}
showThumbnails={true}
{...getOverrideProps(overrides, \\"imgKeys\\")}
></StorageManager>
)}
</Field>
Expand Down Expand Up @@ -25486,6 +25490,7 @@ export default function UpdateProductForm(props) {
descriptiveText={\\"Limited to One Image\\"}
isRequired={false}
isReadOnly={false}
{...getOverrideProps(overrides, \\"singleImgKey\\")}
>
{productRecord && (
<StorageManager
Expand Down Expand Up @@ -25525,6 +25530,7 @@ export default function UpdateProductForm(props) {
showThumbnails={false}
maxFileCount={1}
maxSize={1024}
{...getOverrideProps(overrides, \\"singleImgKey\\")}
></StorageManager>
)}
</Field>
Expand Down
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,24 @@ export const renderStorageFieldComponent = (
}
});

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

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