Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Splitting up the massive #540 into smaller parts. After #553 and #554, this PR is the big one with the whole engine for evaluating expressions, and everything needed to at last implement support for expressions in
app-frontend-react
. The last PR will utilize the functionality implemented here intoGenericComponent
etc (and that PR will arrive when this has been merged).The overview of the functionality in this PR can be seen from the folder structure:
src/features/expressions
index.ts
prettyErrors
, which allows for listing multiple errors deep into a structured object and printing them colored to the consoleuseExpressions
as a react hook, which lets you evaluate expressions (also inside an object) in your componentsrc/utils/databindings/Databinding.ts
src/utils/layout/hierarchy*
A core concept in this structure is a new term for
app-frontend-react
; anode
. Currently we have used the namecomponent
for the components defined in the layout definitions. And we often refer to a specificcomponent
, even when that component is possibly rendered multiple times (in a repeating group). I use the termnode
here for that case - and my definition of a node is that it's an instance of acomponent
(for which there might be multiplenodes
when dealing with repeating groups).The work around converting a flat layout into a hierarchical structure with nodes as component instances can be seen as a precursor to what's needed to implement #345. The tools in
src/utils/layout/hierarchy*
are optional now, and will be used in expressions and validation, but in time I believe these concepts should replace the structure of our current redux store and should be used everywhere.Related Issue(s)
Verification
Documentation
[ ] User documentation is updated with a separate linked PR in altinn-studio-docs. (if applicable)