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-12196: @Component2 annotation parity for function components #655

Merged
merged 6 commits into from
Jan 27, 2021

Conversation

greglittlefield-wf
Copy link
Contributor

@greglittlefield-wf greglittlefield-wf commented Jan 6, 2021

Motivation

The @Component2 annotation can't be used with function components, preventing consumers from specifying arguments like isWrapper and subtypeOf.

Changes

  • Add setTypeMeta extension method to UiFactory, providing parity with the @Component2 annotation for function components
    • Add tests
  • Tweak arguments to private setComponentTypeMeta and ComponentTypeMeta to use raw component types in case the ReactComponentFactoryProxy isn't available
    • Increase test coverage for these utilities

Examples of equivalent configuration for class-based vs function components:

// Class components:

@Component2(isWrapper: true)
class FooComponent extends UiComponent2<FooProps> { ... }

@Component2(subtypeOf: FooComponent)
class BarComponent ... {...}

// Function components:

UiFactory<FooProps> Foo = uiFunction(...)
  ..setComponentMeta(isWrapper: true);

UiFactory<FooProps> Bar = uiFunction(...)
  ..setComponentMeta(subtypeOfFactory: Foo);

Release Notes

  • Add extension method UiFactory.setComponentMeta, which brings @Component2 annotation configuration to function components

Review

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

Please review:

QA Checklist

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.


testComponentTypeChecking({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This shared suite still exists, I just moved some tests out of it that didn't make sense to be shared

@greglittlefield-wf greglittlefield-wf changed the title @Component annotation parity for function components - rough pass @Component annotation parity for function components Jan 8, 2021
@greglittlefield-wf greglittlefield-wf changed the title @Component annotation parity for function components @Component2 annotation parity for function components Jan 8, 2021
@greglittlefield-wf greglittlefield-wf changed the title @Component2 annotation parity for function components CPLAT-12196: @Component2 annotation parity for function components Jan 8, 2021
@greglittlefield-wf greglittlefield-wf marked this pull request as ready for review January 8, 2021 21:30
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.

+1

@@ -225,7 +225,7 @@ UiFactory<TProps> Function(UiFactory<TProps>) forwardRef<TProps extends UiProps>
}

ReactComponentFactoryProxy hoc = react_interop.forwardRef(wrapProps, displayName: displayName);
setComponentTypeMeta(hoc, isHoc: true, parentType: factory().componentFactory);
setComponentTypeMeta(hoc.type, isHoc: true, parentType: factory().componentFactory.type);
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this something you discovered was not working correctly - or is this necessary for these changes to work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was working fine before; this was necessary since I changed setComponentTypeMeta, a private API, to expect the raw type instead of the proxy.

lib/src/component_declaration/component_type_checking.dart Outdated Show resolved Hide resolved
joebingham-wk
joebingham-wk previously approved these changes Jan 11, 2021
Copy link
Contributor

@joebingham-wk joebingham-wk left a comment

Choose a reason for hiding this comment

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

+1! And I can QA in the morning!

lib/src/component_declaration/component_type_checking.dart Outdated Show resolved Hide resolved
@sydneyjodon-wk
Copy link
Contributor

It looks like some related tests are failing.

Co-authored-by: Aaron Lademann <aaron.lademann@workiva.com>
Co-authored-by: joebingham-wk <46691367+joebingham-wk@users.noreply.github.com>
@greglittlefield-wf
Copy link
Contributor Author

All issues have been addressed!

Copy link
Contributor

@joebingham-wk joebingham-wk left a comment

Choose a reason for hiding this comment

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

+10

@greglittlefield-wf
Copy link
Contributor Author

@Workiva/release-management-p

Copy link

@rmconsole-wf rmconsole-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 from RM

@rmconsole5-wk rmconsole5-wk merged commit c0d44df into master Jan 27, 2021
@rmconsole5-wk rmconsole5-wk deleted the function-component-type-meta branch January 27, 2021 21:36
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.

7 participants