Add support for groupedPredicates filter type in useResourceFilters#1122
Draft
gciotola wants to merge 6 commits into
Draft
Add support for groupedPredicates filter type in useResourceFilters#1122gciotola wants to merge 6 commits into
gciotola wants to merge 6 commits into
Conversation
✅ Deploy Preview for commercelayer-app-elements ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a new groupedPredicates filter instruction type for useResourceFilters, enabling a single UI filter component (currently inputToggleButton) to control multiple underlying SDK predicates via selectable options.
Changes:
- Added
FilterItemGroupedPredicatesinstruction type + type guard to the filters instruction model. - Implemented
FieldGroupedPredicatesand wired it into the filters form and nav label rendering. - Extended URL→form and form→SDK adapters to support the new virtual predicate stored in URL/form state.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/app-elements/src/ui/resources/useResourceFilters/types.ts | Adds the groupedPredicates instruction type and a type guard. |
| packages/app-elements/src/ui/resources/useResourceFilters/mockedInstructions.ts | Adds a mocked groupedPredicates example instruction (quantity_filter). |
| packages/app-elements/src/ui/resources/useResourceFilters/FiltersNav.tsx | Adds button-label resolution for groupedPredicates when a single option is selected. |
| packages/app-elements/src/ui/resources/useResourceFilters/FiltersForm.tsx | Renders the new FieldGroupedPredicates for groupedPredicates instructions. |
| packages/app-elements/src/ui/resources/useResourceFilters/FieldGroupedPredicates.tsx | New field component rendering a hooked toggle button for grouped predicates. |
| packages/app-elements/src/ui/resources/useResourceFilters/adaptUrlQueryToFormValues.ts | Parses grouped predicate virtual field values from the URL query string. |
| packages/app-elements/src/ui/resources/useResourceFilters/adaptUrlQueryToFormValues.test.ts | Updates expectations to include the new virtual field in default form values. |
| packages/app-elements/src/ui/resources/useResourceFilters/adaptFormValuesToSdk.ts | Maps selected grouped option values into their underlying SDK predicates/values. |
Comments suppressed due to low confidence (1)
packages/app-elements/src/ui/resources/useResourceFilters/adaptUrlQueryToFormValues.test.ts:30
- The new
groupedPredicatesbehavior isn’t covered by tests yet. The current expectations only addquantity_filter: undefined, but there are no assertions thatquantity_filteris parsed correctly from the query string (valid/invalid values, and bothmode: "single"andmode: "multi"). Adding dedicated cases would prevent regressions in URL parsing.
test("should build proper form value object", () => {
expect(
adaptUrlQueryToFormValues({
queryString:
"market_id_in=dFDdasdgAN&market_id_in=KToVGDooQp&status_in=cancelled&number_or_email_cont=foobar&viewTitle=Awaiting%20Approval",
instructions,
}),
).toStrictEqual({
market_id_in: ["dFDdasdgAN", "KToVGDooQp"],
status_in: ["cancelled"],
payment_status_eq: undefined,
fulfillment_status_in: [],
quantity_filter: undefined,
archived_at_null: undefined,
timePreset: undefined,
timeFrom: undefined,
timeTo: undefined,
name_eq: undefined,
number_or_email_cont: "foobar",
viewTitle: "Awaiting Approval",
total_amount_cents: {
from: undefined,
to: undefined,
currencyCode: undefined,
},
})
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
commit: |
Comment on lines
+167
to
+171
| // single grouped predicates option: store one option value in URL | ||
| if ( | ||
| instructionItem.type === "groupedPredicates" && | ||
| instructionItem.render.props.mode === "single" | ||
| ) { |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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
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.
Closes #1121
What I did
This PR adds support for
groupedPredicatesfilter type.This means that is now possibile to group multiple predicates in a single UI component (InputToggleButton).
Example:
How to test
Checklist