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

CPLAT-3873 Function Components #606

Merged

Conversation

sydneyjodon-wk
Copy link
Contributor

@sydneyjodon-wk sydneyjodon-wk commented Jul 8, 2020

Motivation

Now that we've migrated to the new boilerplate, we need to implement function components so they can be used in over_react.

Changes

  • Add function component supporting APIs (uiFunction, PropsFactory) (implemented in Greg's spike branch)
  • Update parsing logic to validate function components.
  • Update codegen for functional components.
    • Generate props config for each factory.
  • Write tests
    • component integration tests
    • parsing tests (validate that the correct errors are raised by the builder when there is something wrong with the boilerplate)
  • Update documentation
    • Show how to declare in README, and uiFunction
  • Add snippet

Release Notes

Review

See CONTRIBUTING.md for more details on review types (+1 / QA +1 / +10) and code review process.

Please review:

QA Checklist

  • Tests were updated and provide good coverage of the changeset and other affected code
  • Manual testing was performed if needed

Merge Checklist

While we perform many automated checks before auto-merging, some manual checks are needed:

  • A Client Platform member has reviewed these changes
  • There are no unaddressed comments - this check can be automated if reviewers use the "Request Changes" feature
  • For release PRs - Version metadata in Rosie comment is correct

@aviary3-wk
Copy link

Security Insights

No security relevant content was detected by automated scans.

Action Items

  • Review PR for security impact; comment "security review required" if needed or unsure
  • Verify aviary.yaml coverage of security relevant code

Questions or Comments? Reach out on Slack: #support-infosec.

Copy link
Contributor

@greglittlefield-wf greglittlefield-wf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I got a notification when this PR was opened and couldn't help but take a peek 😅

I have one question around the use of v5 and reusing existing grouping logic; let me know if you'd like to talk it over in person!

lib/src/builder/parsing/declarations_from_members.dart Outdated Show resolved Hide resolved
Copy link
Contributor

@aaronlademann-wf aaronlademann-wf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 705 of doc/new_boilerplate_migration.md needs to be updated to remove the "coming soon" bit from the heading.

README.md Outdated
Comment on lines 861 to 862
// Return the rendered component contents here.
// The `props` variable is typed; no need for string keys!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we return something here to demonstrate things like prop forwarding, etc.?

doc/new_boilerplate_migration.md Show resolved Hide resolved
example/builder/src/function_component.dart Outdated Show resolved Hide resolved
}
final genericFactory = uiFunction<UiProps>(GenericFactory, null);

final basicFactory = uiFunction<BasicProps>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO we should also have one utilizing forwardRef.

@@ -46,7 +46,7 @@ abstract class TypedMapImplGenerator extends BoilerplateDeclarationGenerator {

TypedMapNames get names;
bool get isComponent2;
FactoryNames get factoryNames;
List<FactoryNames> get factoryNames;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the tldr; on this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to generate a props config for every function component factory (even if they share the same props mixin) so that the display name is set up correctly. This has to be a list in order to get all the factory names from PropsMapViewOrFunctionComponentDeclaration.factories. In all other cases factoryNames would have a single element -- I just added an assert for that in _generateFactory.

lib/src/component_declaration/function_component.dart Outdated Show resolved Hide resolved
pubspec.yaml Outdated Show resolved Hide resolved
Copy link
Contributor

@greglittlefield-wf greglittlefield-wf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments around generation, but this looks awesome!!

README.md Outdated Show resolved Hide resolved
lib/src/builder/codegen/typed_map_impl_generator.dart Outdated Show resolved Hide resolved
lib/src/builder/codegen/typed_map_impl_generator.dart Outdated Show resolved Hide resolved
lib/src/builder/parsing/declarations_from_members.dart Outdated Show resolved Hide resolved
lib/src/component_declaration/function_component.dart Outdated Show resolved Hide resolved
lib/src/component_declaration/function_component.dart Outdated Show resolved Hide resolved
lib/src/builder/parsing/declarations_from_members.dart Outdated Show resolved Hide resolved
test/vm_tests/builder/declaration_parsing_test.dart Outdated Show resolved Hide resolved
test/vm_tests/builder/declaration_parsing_test.dart Outdated Show resolved Hide resolved
@aaronlademann-wf aaronlademann-wf changed the base branch from master to function-components-wip July 23, 2020 15:15
@sydneyjodon-wk sydneyjodon-wk dismissed stale reviews from greglittlefield-wf and aaronlademann-wf July 24, 2020 18:54

Addressed feedback

Copy link
Contributor Author

@sydneyjodon-wk sydneyjodon-wk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @aaronlademann-wf @greglittlefield-wf I think I addressed all your feedback except that one discussion on FunctionComponentConfig which I put in slack. So this is ready for another round of review when you have time!

lib/src/builder/parsing/members/factory.dart Outdated Show resolved Hide resolved
lib/src/builder/parsing/ast_util.dart Outdated Show resolved Hide resolved
lib/src/builder/codegen.dart Outdated Show resolved Hide resolved
Copy link
Contributor

@greglittlefield-wf greglittlefield-wf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple minor things; this is looking awesome! I'll try and start QAing soon

lib/src/component_declaration/function_component.dart Outdated Show resolved Hide resolved
}

/// Helper class used to keep track of generated information for [uiFunction].
@protected
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we accept it as an argument to uiFunction, this class and its members shouldn't be @protected anymore

example/builder/src/function_component.dart Show resolved Hide resolved
doc/new_boilerplate_migration.md Outdated Show resolved Hide resolved
Copy link
Contributor

@greglittlefield-wf greglittlefield-wf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

QAing now...

Copy link
Contributor

@greglittlefield-wf greglittlefield-wf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Test coverage looks good
  • Examples look good and render as expected
  • Builder changes don't affect existing code

+10 🎉

@greglittlefield-wf greglittlefield-wf merged commit 62e05d8 into function-components-wip Jul 27, 2020
@sydneyjodon-wk sydneyjodon-wk deleted the CPLAT-3873-function-components branch January 28, 2022 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants