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 form datamodel to requiredDataModels for renderComponentOnly #815

Merged
merged 1 commit into from
Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -292,11 +292,13 @@ describe('amplify form renderer tests', () => {
'datastore/project-team-model',
);

const teamAlias = importCollection.importAlias.get(ImportSource.LOCAL_MODELS)?.get('Team');
const teamAlias = importCollection.getMappedAlias(ImportSource.LOCAL_MODELS, 'Team');

const includesTeam = requiredDataModels.includes('Team');
const includesMember = requiredDataModels.includes('Member');
expect(teamAlias).toBe('Team0');
expect(includesTeam).toBe(true);
expect(includesMember).toBe(true);
expect(importCollection).toBeDefined();
});

Expand Down
1 change: 1 addition & 0 deletions packages/codegen-ui-react/lib/forms/react-form-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ export abstract class ReactFormTemplateRenderer extends StudioTemplateRenderer<

// add model import for datastore type
if (dataSourceType === 'DataStore') {
this.requiredDataModels.push(dataTypeName);
modelName = this.importCollection.addImport(ImportSource.LOCAL_MODELS, dataTypeName);
}

Expand Down