Skip to content

Conversation

@azech-hqs
Copy link
Contributor

This PR concerns an automatic way of building the dependency tree for RJSF schemas based on a given model subtree and a given schema reference.

@@ -1,3 +1,5 @@
import lodash from "lodash";
Copy link
Member

Choose a reason for hiding this comment

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

It's better to load only lodash functions that we actually need in the module, not a whole lodash library.
https://stackoverflow.com/questions/35250500/correct-way-to-import-lodash

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point! I adjusted it for all lodash imports in the repo

Copy link
Member

Choose a reason for hiding this comment

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

@k0stik - the idea is good, provided that readability doesn't suffer, but let's deal with it in a separate task, pls see #40 (comment)

* @notes Should hold static data only (see `setData` method), no classes or functions
*/
import lodash from "lodash";
import capitalize from "lodash/capitalize";
Copy link
Member

Choose a reason for hiding this comment

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

I understand where you're coming from on this, but I have to go with readability on this: lodash.get is way more understandable than get when reading the code. Plus, the 150.5KB size is not as important for us, given that the bundle size is measured in MBs. You can put a separate task for it, if you'd like.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok no problem, I can change it back

...getEnumValues(nodes),
},
};
forEach(mod, (extraFields, key) => {
Copy link
Member

Choose a reason for hiding this comment

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

Why not use the built-in Array.forEach?

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 is due to calling forEach on an object. I can also implement it using Array.forEach where mod is a list of objects.

@azech-hqs azech-hqs marked this pull request as ready for review January 30, 2023 23:23
@azech-hqs azech-hqs merged commit e5a71be into main Feb 4, 2023
@azech-hqs azech-hqs deleted the chore/SOF-6428 branch February 4, 2023 01:58
k0stik pushed a commit that referenced this pull request Jul 31, 2023
* chore: add draft for function to build dependency tree

* chore: adjust dependency builder to support dataSelector node property

* chore: add utility function for calling map on a tree

* test: add test for buildDependencies

* chore: add mapTree to utils index

* chore: add function to determine schema type

* chore: add function for building schema with dependency

* refactor: buildDependencyCase function

* test: getSchemaWithDependencies

* test: typeofSchema

* test: mapTree

* docs: add docstring for getSchemaWithDependencies

* test: adding enum dynamically to main schema

* chore: add getSchemaWithDependencies to index

* chore: use single lodash imports

* revert: single lodash imports
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants