Skip to content

Commit

Permalink
[8.9] [Unified Search] Enable filtersBuilder depth of 1 (#160691) (#1…
Browse files Browse the repository at this point in the history
…60884)

# Backport

This will backport the following commits from `main` to `8.9`:
- [[Unified Search] Enable filtersBuilder depth of 1
(#160691)](#160691)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Kevin
Qualters","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-06-29T12:44:59Z","message":"[Unified
Search] Enable filtersBuilder depth of 1 (#160691)\n\n##
Summary\r\n\r\nThink the filters builder component does not allow a
maxDepth of 1\r\ncorrectly, as behavior in that state is
indistinguishable from usage of\r\nthe component with a maxDepth of 0,
both states only allow top level\r\nANDs only. With this change, it's
possible to have 1 level of nesting of\r\neither type, but no deeper.
The renderedLevel prop will never go above 0\r\nwithout this change with
0 or 1 as well, it now matches maxDepth.\r\n\r\nAfter:\r\n<img
width=\"639\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/56408403/405098d6-4e3a-43b3-9bf9-b783abb9eb0a\">\r\n\r\nBefore
maxDepth 0:\r\n<img width=\"658\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/56408403/a3e11bc0-1b9f-4bf2-a1fa-4d8d34be5907\">\r\n\r\n(Or
is never an option)\r\n\r\nBefore maxDepth 1: \r\n<img width=\"683\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/56408403/bde6bb59-2b41-4496-922b-6fd6d6eb29dc\">\r\n\r\n(Or
is never an option)\r\n\r\nBefore maxDepth 2:\r\n<img width=\"656\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/56408403/32f407ee-d1f5-42cb-bbef-6e8dc4ff115b\">\r\nWorks
as
expected","sha":"065ded6ff71d793183314db0cc72ddbf5bd6d88d","branchLabelMapping":{"^v8.10.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Visualizations","release_note:skip","Feature:Unified
search","v8.9.0","v8.10.0"],"number":160691,"url":"https://github.com/elastic/kibana/pull/160691","mergeCommit":{"message":"[Unified
Search] Enable filtersBuilder depth of 1 (#160691)\n\n##
Summary\r\n\r\nThink the filters builder component does not allow a
maxDepth of 1\r\ncorrectly, as behavior in that state is
indistinguishable from usage of\r\nthe component with a maxDepth of 0,
both states only allow top level\r\nANDs only. With this change, it's
possible to have 1 level of nesting of\r\neither type, but no deeper.
The renderedLevel prop will never go above 0\r\nwithout this change with
0 or 1 as well, it now matches maxDepth.\r\n\r\nAfter:\r\n<img
width=\"639\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/56408403/405098d6-4e3a-43b3-9bf9-b783abb9eb0a\">\r\n\r\nBefore
maxDepth 0:\r\n<img width=\"658\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/56408403/a3e11bc0-1b9f-4bf2-a1fa-4d8d34be5907\">\r\n\r\n(Or
is never an option)\r\n\r\nBefore maxDepth 1: \r\n<img width=\"683\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/56408403/bde6bb59-2b41-4496-922b-6fd6d6eb29dc\">\r\n\r\n(Or
is never an option)\r\n\r\nBefore maxDepth 2:\r\n<img width=\"656\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/56408403/32f407ee-d1f5-42cb-bbef-6e8dc4ff115b\">\r\nWorks
as
expected","sha":"065ded6ff71d793183314db0cc72ddbf5bd6d88d"}},"sourceBranch":"main","suggestedTargetBranches":["8.9"],"targetPullRequestStates":[{"branch":"8.9","label":"v8.9.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.10.0","labelRegex":"^v8.10.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/160691","number":160691,"mergeCommit":{"message":"[Unified
Search] Enable filtersBuilder depth of 1 (#160691)\n\n##
Summary\r\n\r\nThink the filters builder component does not allow a
maxDepth of 1\r\ncorrectly, as behavior in that state is
indistinguishable from usage of\r\nthe component with a maxDepth of 0,
both states only allow top level\r\nANDs only. With this change, it's
possible to have 1 level of nesting of\r\neither type, but no deeper.
The renderedLevel prop will never go above 0\r\nwithout this change with
0 or 1 as well, it now matches maxDepth.\r\n\r\nAfter:\r\n<img
width=\"639\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/56408403/405098d6-4e3a-43b3-9bf9-b783abb9eb0a\">\r\n\r\nBefore
maxDepth 0:\r\n<img width=\"658\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/56408403/a3e11bc0-1b9f-4bf2-a1fa-4d8d34be5907\">\r\n\r\n(Or
is never an option)\r\n\r\nBefore maxDepth 1: \r\n<img width=\"683\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/56408403/bde6bb59-2b41-4496-922b-6fd6d6eb29dc\">\r\n\r\n(Or
is never an option)\r\n\r\nBefore maxDepth 2:\r\n<img width=\"656\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/56408403/32f407ee-d1f5-42cb-bbef-6e8dc4ff115b\">\r\nWorks
as expected","sha":"065ded6ff71d793183314db0cc72ddbf5bd6d88d"}}]}]
BACKPORT-->

Co-authored-by: Kevin Qualters <[email protected]>
  • Loading branch information
kibanamachine and kqualters-elastic authored Jun 29, 2023
1 parent cf2b27f commit 606b48a
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const FilterGroup = ({
} = useContext(FiltersBuilderContextType);

const pathInArray = getPathInArray(path);
const isDepthReached = maxDepth <= pathInArray.length;
const isDepthReached = maxDepth <= pathInArray.length && renderedLevel > 0;
const orDisabled = hideOr || (isDepthReached && booleanRelation === BooleanRelation.AND);
const andDisabled = isDepthReached && booleanRelation === BooleanRelation.OR;

Expand Down

0 comments on commit 606b48a

Please sign in to comment.