-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Feature/attribute values search #6301
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
Changes from all commits
ec0ca8a
423634b
64daac3
80ccc7f
a0352ed
b67bd3b
9f40d75
78930ad
8092807
d80b8a3
b7f8948
f7454a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "saleor-dashboard": patch | ||
| --- | ||
|
|
||
| Attribute configuration: allow users to filter attribute values by slug or name when there are more than 5 values. | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,7 +1,9 @@ | ||||||
| import { rippleAttributeValuesSearch } from "@dashboard/attributes/ripples/attributeValuesSearch"; | ||||||
| import { DashboardCard } from "@dashboard/components/Card"; | ||||||
| import { iconSize, iconStrokeWidthBySize } from "@dashboard/components/icons"; | ||||||
| import { Placeholder } from "@dashboard/components/Placeholder"; | ||||||
| import { ResponsiveTable } from "@dashboard/components/ResponsiveTable"; | ||||||
| import { SearchInput } from "@dashboard/components/SearchInput/SearchInput"; | ||||||
| import { SortableTableBody, SortableTableRow } from "@dashboard/components/SortableTable"; | ||||||
| import { TablePagination } from "@dashboard/components/TablePagination"; | ||||||
| import TableRowLink from "@dashboard/components/TableRowLink"; | ||||||
|
|
@@ -11,6 +13,7 @@ import { | |||||
| AttributeValueListFragment, | ||||||
| } from "@dashboard/graphql"; | ||||||
| import { renderCollection, stopPropagation } from "@dashboard/misc"; | ||||||
| import { Ripple } from "@dashboard/ripples/components/Ripple"; | ||||||
| import { ListProps, PaginateListProps, RelayToFlat, ReorderAction } from "@dashboard/types"; | ||||||
| import { TableCell, TableHead } from "@material-ui/core"; | ||||||
| import { makeStyles } from "@saleor/macaw-ui"; | ||||||
|
|
@@ -28,6 +31,8 @@ interface AttributeValuesProps | |||||
| onValueReorder: ReorderAction; | ||||||
| onValueUpdate: (id: string) => void; | ||||||
| inputType: AttributeInputTypeEnum; | ||||||
| searchQuery?: string; | ||||||
| onSearchChange?: (query: string) => void; | ||||||
| } | ||||||
|
|
||||||
| const useStyles = makeStyles( | ||||||
|
|
@@ -72,6 +77,7 @@ const getSwatchCellStyle = (value?: AttributeValueFragment | undefined) => { | |||||
| ? { backgroundImage: `url(${value.file.url})` } | ||||||
| : { backgroundColor: value.value ?? undefined }; | ||||||
| }; | ||||||
|
|
||||||
| const AttributeValues = ({ | ||||||
| disabled, | ||||||
| onValueAdd, | ||||||
|
|
@@ -85,11 +91,16 @@ const AttributeValues = ({ | |||||
| onNextPage, | ||||||
| onPreviousPage, | ||||||
| inputType, | ||||||
| searchQuery = "", | ||||||
| onSearchChange, | ||||||
| }: AttributeValuesProps) => { | ||||||
| const classes = useStyles({}); | ||||||
| const intl = useIntl(); | ||||||
| const isSwatch = inputType === AttributeInputTypeEnum.SWATCH; | ||||||
|
|
||||||
| // Show search when callback is provided (controlled by parent) | ||||||
| const showSearch = Boolean(onSearchChange); | ||||||
|
Comment on lines
+101
to
+102
|
||||||
|
|
||||||
| return ( | ||||||
| <DashboardCard data-test-id="attribute-values-section"> | ||||||
| <DashboardCard.Header> | ||||||
|
|
@@ -118,113 +129,151 @@ const AttributeValues = ({ | |||||
| <DashboardCard.Content> | ||||||
| {values === undefined ? ( | ||||||
| <Skeleton /> | ||||||
| ) : values.length === 0 ? ( | ||||||
| <Placeholder> | ||||||
| <FormattedMessage | ||||||
| id="dAst+b" | ||||||
| defaultMessage="No values found" | ||||||
| description="attribute values list: no attribute values found" | ||||||
| /> | ||||||
| </Placeholder> | ||||||
| ) : ( | ||||||
| <ResponsiveTable | ||||||
| footer={ | ||||||
| <TablePagination | ||||||
| hasNextPage={pageInfo && !disabled ? pageInfo.hasNextPage : false} | ||||||
| onNextPage={onNextPage} | ||||||
| hasPreviousPage={pageInfo && !disabled ? pageInfo.hasPreviousPage : false} | ||||||
| onPreviousPage={onPreviousPage} | ||||||
| settings={settings} | ||||||
| onUpdateListSettings={onUpdateListSettings} | ||||||
| /> | ||||||
| } | ||||||
| > | ||||||
| <TableHead> | ||||||
| <TableRowLink> | ||||||
| <TableCell className={classes.columnDrag} /> | ||||||
| {isSwatch && ( | ||||||
| <TableCell className={classes.columnSwatch}> | ||||||
| <FormattedMessage | ||||||
| id="NUevU9" | ||||||
| defaultMessage="Swatch" | ||||||
| description="attribute values list: slug column header" | ||||||
| /> | ||||||
| </TableCell> | ||||||
| )} | ||||||
| <TableCell className={classes.columnAdmin}> | ||||||
| <FormattedMessage | ||||||
| id="3psvRS" | ||||||
| defaultMessage="Admin" | ||||||
| description="attribute values list: slug column header" | ||||||
| /> | ||||||
| </TableCell> | ||||||
| <TableCell className={classes.columnStore}> | ||||||
| <FormattedMessage | ||||||
| id="H60H6L" | ||||||
| defaultMessage="Default Store View" | ||||||
| description="attribute values list: name column header" | ||||||
| <Box display="flex" flexDirection="column" gap={4}> | ||||||
| {/* Search input - always visible when search is enabled */} | ||||||
|
||||||
| {/* Search input - always visible when search is enabled */} | |
| {/* Search input - rendered when onSearchChange is provided (visibility controlled by parent) */} |
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR description states "Search only appears when there are more than 5 values to avoid UI clutter", but the implementation always shows the search input when the onSearchChange callback is provided, regardless of the number of values. The search is unconditionally passed in AttributeDetails and displayed whenever values are not undefined in AttributeValues. Consider either:
- Implementing the conditional display logic based on value count (e.g.,
showSearch && values.length > 5), or - Updating the PR description to accurately reflect the implementation
mirekm marked this conversation as resolved.
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1 @@ | ||
| export { default } from "./AttributeValues"; | ||
| export * from "./AttributeValues"; | ||
| export { AttributeValues } from "./AttributeValues"; | ||
mirekm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changeset description states that users can filter "when there are more than 5 values", but this condition is not implemented in the code. The search feature is always available regardless of the number of values. Either update this description to match the actual implementation, or implement the condition as described.