-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add placeholder to price cells in product list #4972
Merged
Merged
Changes from 11 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
0fbd41c
add placeholder for product price
Cloud11PL b313e63
make filters have 'channel' preset when open
Cloud11PL 1c74dd6
changeset
Cloud11PL e946c19
small fix
Cloud11PL 6372dca
type fix
Cloud11PL 815063b
add tests
Cloud11PL 62bf0e9
fix types
Cloud11PL 11fdf51
add comments
Cloud11PL 62c5f88
extract messages
Cloud11PL bee72b4
make shortcut work with already selected filters
Cloud11PL 7bf6209
fix
Cloud11PL 46f8f9c
add comment
Cloud11PL 67e4e39
Merge branch 'main' into MERX-5-product-list-placeholder
Cloud11PL acce4de
change patch to minor
Cloud11PL 0ecbd47
encapsulate 'onPriceClick' logic
Cloud11PL ad55506
shorten changesets
Cloud11PL 9726652
Merge branch 'main' into MERX-5-product-list-placeholder
Cloud11PL 96506e5
Merge branch 'main' into MERX-5-product-list-placeholder
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 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 | ||
--- | ||
|
||
Product list no longer show a dash instead of product's price when channel is not selected. Instead 'Select channel' shortcut was added meaning that you can now use it to open filters window with 'channel' already selected. | ||
This file contains 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 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 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 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 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,15 @@ | ||
import { useState } from "react"; | ||
|
||
export interface FilterWindow { | ||
isOpen: boolean; | ||
setOpen: (open: boolean) => void; | ||
} | ||
|
||
export const useFilterWindow = () => { | ||
const [open, setOpen] = useState(false); | ||
|
||
return { | ||
isOpen: open, | ||
setOpen, | ||
}; | ||
}; |
This file contains 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 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 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,107 @@ | ||
import { GridMouseEventArgs } from "@glideapps/glide-data-grid"; | ||
import { render } from "@testing-library/react"; | ||
import { renderHook } from "@testing-library/react-hooks"; | ||
import React from "react"; | ||
|
||
import { useRowAnchor } from "./useRowAnchor"; | ||
|
||
jest.mock("@dashboard/hooks/useDebounce", () => jest.fn(fn => fn)); | ||
|
||
describe("useRowAnchor", () => { | ||
const props = { | ||
availableColumns: [ | ||
{ | ||
id: "name", | ||
title: "Name", | ||
width: 200, | ||
icon: "arrowUp", | ||
}, | ||
{ | ||
id: "description", | ||
title: "Description", | ||
width: 100, | ||
icon: "arrowUp", | ||
}, | ||
], | ||
getRowAnchorUrl: () => "test", | ||
rowMarkers: "checkbox-visible" as const, | ||
}; | ||
|
||
it("should return row anchor ref", () => { | ||
// Arrange & Act | ||
const { result } = renderHook(() => useRowAnchor(props)); | ||
|
||
render(<a ref={result.current.setRowAnchorRef} />); | ||
|
||
// Assert | ||
expect(result.current.rowAnchorRef).toBeDefined(); | ||
}); | ||
it("should have anchor set", () => { | ||
// Arrange | ||
const { result } = renderHook(() => useRowAnchor(props)); | ||
|
||
render(<a ref={result.current.setRowAnchorRef} />); | ||
|
||
// Act | ||
result.current.setAnchorPosition({ | ||
kind: "cell", | ||
location: [1, 0], | ||
bounds: { x: 0, y: 0, width: 0, height: 0 }, | ||
isEdge: false, | ||
shiftKey: false, | ||
ctrlKey: false, | ||
isFillHandle: false, | ||
metaKey: false, | ||
isTouch: false, | ||
localEventX: 81, | ||
localEventY: 39, | ||
button: 0, | ||
scrollEdge: [0, 0], | ||
}); | ||
|
||
// Assert | ||
expect(result.current.rowAnchorRef.current!).not.toBeNull(); | ||
expect(result.current.rowAnchorRef.current!.style.left).toBe("0px"); | ||
expect(result.current.rowAnchorRef.current!.href).toBe("http://localhost/test"); | ||
}); | ||
it("should not set anchor position when cell has action", () => { | ||
// Arrange | ||
const { result } = renderHook(() => | ||
useRowAnchor({ | ||
...props, | ||
availableColumns: [ | ||
...props.availableColumns, | ||
{ | ||
id: "price", | ||
title: "Price", | ||
width: 100, | ||
icon: "arrowUp", | ||
action: jest.fn(), | ||
}, | ||
], | ||
}), | ||
); | ||
|
||
render(<a ref={result.current.setRowAnchorRef} />); | ||
|
||
// Act | ||
result.current.setAnchorPosition({ | ||
kind: "cell", | ||
location: [2, 0], // note: 2 is the index of the "price" column (with 'action') | ||
bounds: { x: 0, y: 0, width: 0, height: 0 }, | ||
isEdge: false, | ||
shiftKey: false, | ||
ctrlKey: false, | ||
isFillHandle: false, | ||
metaKey: false, | ||
isTouch: false, | ||
localEventX: 81, | ||
localEventY: 39, | ||
button: 0, | ||
scrollEdge: [0, 0], | ||
} as GridMouseEventArgs); | ||
|
||
// Assert | ||
expect(result.current.rowAnchorRef.current!.href).toBe(""); | ||
}); | ||
}); |
This file contains 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 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.
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.
It can be simpler and a bit shorter:
You can now open channel selection by clicking "Select channel" within any price cell on the product list. This means the dash "-" sign is no longer displayed there