-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Search for product variants by SKU in quick search, show media #5495
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
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
843351c
add variant search by SKU
Cloud11PL a432512
show media if available
Cloud11PL 918c881
changeset + json messages
Cloud11PL 82b9fd1
add test
Cloud11PL faec660
cleanup
Cloud11PL dbe2cd3
add loading state to thumbnails
Cloud11PL a5b17e2
small UI changes
Cloud11PL 2960555
properly hide sku
Cloud11PL 9e675c9
handle label as react node
Cloud11PL 278f5c5
fix type issues
Cloud11PL 14aa733
i18n
Cloud11PL 3915fd5
Merge branch 'main' into BCK-1498-sku-search-console
Cloud11PL 8b3017b
Add missing commments
Cloud11PL bfa8f1e
restore original cmd
Cloud11PL 9b0d673
add description to messages
Cloud11PL 4bc2bd1
Merge branch 'main' into BCK-1498-sku-search-console
poulch 306ba21
Merge branch 'main' into BCK-1498-sku-search-console
Cloud11PL 5c82e04
Merge branch 'main' into BCK-1498-sku-search-console
Cloud11PL 04442d8
Merge branch 'main' into BCK-1498-sku-search-console
Cloud11PL bcf8c71
cr fixes
Cloud11PL 31b75eb
Merge branch 'main' into BCK-1498-sku-search-console
Cloud11PL 66a60ce
Merge branch 'main' into BCK-1498-sku-search-console
Cloud11PL File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "saleor-dashboard": patch | ||
| --- | ||
|
|
||
| In quick search you can now search for product variants with SKU. This means product variants are a new item added to the search catalogue. Catalogue items now show their media, if available. Category item display message if they don't have parents. |
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| import { Box, Skeleton } from "@saleor/macaw-ui-next"; | ||
| import React, { useState } from "react"; | ||
|
|
||
| const defaultProps = { | ||
| __height: "40px", | ||
| __width: "40px", | ||
| __minWidth: "40px", | ||
| }; | ||
|
|
||
| export const NavigatorThumbnail = ({ | ||
| src, | ||
| alt, | ||
| }: { | ||
| src: string | undefined; | ||
| alt: string | undefined; | ||
| }) => { | ||
| const [loading, setLoading] = useState(true); | ||
| const [error, setError] = useState(false || !src); | ||
|
|
||
| if (error) { | ||
| return ( | ||
| <Box | ||
| {...defaultProps} | ||
| backgroundColor="default2" | ||
| borderRadius={4} | ||
| borderStyle="solid" | ||
| borderColor="default1" | ||
| borderWidth={1} | ||
| marginRight={2} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <Box | ||
| display="flex" | ||
| alignItems="center" | ||
| justifyContent="center" | ||
| padding={0.5} | ||
| borderRadius={4} | ||
| borderStyle="solid" | ||
| borderWidth={1} | ||
| borderColor="default1" | ||
| overflow="hidden" | ||
| marginRight={2} | ||
| position="relative" | ||
| {...defaultProps} | ||
| > | ||
| {loading && ( | ||
| <Skeleton {...defaultProps} position="absolute" left={0} right={0} top={0} bottom={0} /> | ||
poulch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| )} | ||
| <Box | ||
| as="img" | ||
poulch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| width="100%" | ||
| height="100%" | ||
| objectFit="contain" | ||
| src={src} | ||
| alt={alt || ""} | ||
| borderRadius={2} | ||
| backgroundColor="default2" | ||
| onError={() => { | ||
| setError(true); | ||
| }} | ||
| onLoad={() => { | ||
| setLoading(false); | ||
| }} | ||
| /> | ||
| </Box> | ||
| ); | ||
| }; | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| import { SearchCatalogQuery } from "@dashboard/graphql"; | ||
| import { intlMock } from "@test/intl"; | ||
|
|
||
| import { searchInCatalog } from "./catalog"; | ||
|
|
||
| describe("NavigatorSearch / modes / searchInCatalog", () => { | ||
| const intl = intlMock; | ||
| const navigate = jest.fn(); | ||
|
|
||
| it("should return variants if search is a sku", () => { | ||
| // Arrange | ||
| const mockCatalog: SearchCatalogQuery = { | ||
| productVariants: { | ||
| edges: [ | ||
| { | ||
| node: { | ||
| id: "1", | ||
| name: "Small", | ||
| sku: "PROD-SMALL", | ||
| product: { | ||
| id: "prod1", | ||
| name: "T-Shirt", | ||
| thumbnail: null, | ||
| category: { | ||
| name: "Apparel", | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| } as SearchCatalogQuery; | ||
|
|
||
| // Act | ||
| const results = searchInCatalog("PROD-SMALL", intl, navigate, mockCatalog); | ||
|
|
||
| // Assert | ||
| expect(results).toHaveLength(1); | ||
| expect(results[0].searchValue).toContain("PROD-SMALL"); | ||
| }); | ||
|
|
||
| it("should return both product and its variant", () => { | ||
| // Arrange | ||
| const mockCatalog: SearchCatalogQuery = { | ||
| products: { | ||
| edges: [ | ||
| { | ||
| node: { | ||
| id: "prod1", | ||
| name: "T-Shirt", | ||
| thumbnail: null, | ||
| category: { | ||
| name: "Apparel", | ||
| }, | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| productVariants: { | ||
| edges: [ | ||
| { | ||
| node: { | ||
| id: "1", | ||
| name: "Small", | ||
| sku: "PROD-SMALL", | ||
| product: { | ||
| id: "prod1", | ||
| name: "T-Shirt", | ||
| thumbnail: null, | ||
| category: { | ||
| name: "Apparel", | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| } as SearchCatalogQuery; | ||
|
|
||
| // Act | ||
| const results = searchInCatalog("T-Shirt", intl, navigate, mockCatalog); | ||
|
|
||
| // Assert | ||
| expect(results).toHaveLength(2); | ||
| expect(results[0].label).toBe("T-Shirt"); | ||
| expect(results[1].searchValue).toContain("PROD-SMALL"); | ||
| }); | ||
| }); |
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.