-
Notifications
You must be signed in to change notification settings - Fork 34
Restrict maximum nesting of groups #63
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Closed
Code Coverage ReportCoverage after merging max-depth-for-groups into master
Coverage Report
|
588ba02
to
1321b49
Compare
Add `maxDepth` to config for restricting depth of the query builder.
Have `maxDepthExeeded` to be passed on to the GroupCtrlSlot prop. This allows the custom slot handler to identify if the max. depth has been reached. In this case, the `newGroup` callable will behave as a noop.
The `maxDepth` policy is authoritative. Whenever we detect the query or `maxDepth` has changed, prune unnecessary children and let the update propagate .
Don't allow dragging groups into another group `maxDepth` policy would be exceeded.
If we drop a deep nested group to another, the end-result may violate the maxDepth policy. Therefore, decline dropping where this may happen.
d77fbfe
to
2fcf689
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Introduce new, optional setting
maxDepth
. This setting can be used to restrict maximum nesting of groups.Configuration:
If
maxDepth
isundefined
, users may have an arbitrary depth of nested groups. This reflects in the current behavior and is backwards compatible.If
typeof maxDepth === 'number'
and0 <= n <= maxDepth
, users are only allowed to create up to n groups in deep. If n is 0, users are effectively not allowed to create any groups at all.groupCtrlSlotProps:
For slots of type
groupCtrlSlotProps
, thenewGroup()
callback, passed as slot prop, becomes a noop, if a group has exceeded themaxDepth
policy. Additionally, a boolean flag with asmaxDepthExeeded
property is provided to the slot prop object, so the slot can apply somev-if
condition logic for hiding a create-new-group handler.Drag'n'drop:
Prior dropping a dragged group into another group, the library checks if the max depth policy would be violated and prevents dropping. The user will notice that the drag'n'drop preview will not adjust as usually expected.
Config change at runtime
It is possible and valid to change
maxDepth
at runtime. As a special chase, if the givenquery
has a higher nested depth and a config change restricts themaxDepth
to a lower depth, the library (intentionally) removes any child groups, exceeding the present config limit. This ensures consistency with themaxDepth
policy. It's the component's parent responsibility of checking if settingmaxDepth
may not result in an unwanted side-effect of removing any children from the given query tree.Bonus
yarn serve
's testing setup got a panel for quick config changes at runtime.TODO:
closes #61