Skip to content

Conversation

@P0lip
Copy link
Contributor

@P0lip P0lip commented Jul 13, 2019

List of changes:

Needed to unyalc JSV in Studio.

@chris-miaskowski
Copy link

Hey @P0lip , need a hand with this refactoring?

@P0lip P0lip marked this pull request as ready for review August 2, 2019 17:35
@P0lip P0lip requested a review from billiegoose August 2, 2019 17:36
validations={{
...('annotations' in schemaNode &&
schemaNode.annotations.default && { default: schemaNode.annotations.default }),
...('validations' in schemaNode && schemaNode.validations),

Choose a reason for hiding this comment

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

@P0lip it might be just me but I find it a bit intimidating to read. Would you mind wrapping this with a small helper function? E.g. getAnnotations() + getValidations()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good to me.

const { hideTopBar, name, treeStore, maxRows, className, onGoToRef } = props;
const { hideTopBar, name, treeStore, maxRows, className, onGoToRef, rowRenderer: customRowRenderer } = props;

React.useEffect(

Choose a reason for hiding this comment

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

I was thinking the other day on our code coverage in our React repos. It's tough to test React I agree but here's a though: why don't we embrace a pattern where we encapsulate all 'logic' before the return/render function inside external controller?

The idea is that you would move those effects in a separate component / function which could then be unit tested very easily.

[onGoToRef, node],
);

return (

Choose a reason for hiding this comment

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

Similarly to my other comment all code between line 14 and return should/could be unit tested. What do you think?

Copy link

@chris-miaskowski chris-miaskowski left a comment

Choose a reason for hiding this comment

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

I gave your code a light pass and left some comments, curious to hear your thoughts.
I'll leave it up to @lottamus to give the final approval (trying to encourage the 'code owners' thingy and seems that you and Chris mostly own this bit)

@marbemac
Copy link
Contributor

marbemac commented Aug 7, 2019

Going to go ahead and merge this to keep things moving along. Regarding the extra unit tests, I think it does still make sense and perhaps we tackle it in a separate PR?

@marbemac marbemac merged commit dcc8eea into master Aug 7, 2019
@marbemac marbemac deleted the refactor/cleanup branch August 7, 2019 08:08
@stoplight-bot
Copy link
Collaborator

🎉 This PR is included in version 2.6.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants