Skip to content
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

Show categories' parents in product view #4846

Merged
merged 21 commits into from
May 17, 2024

Conversation

Cloud11PL
Copy link
Member

@Cloud11PL Cloud11PL commented May 8, 2024

What type of PR is this?

  • 💅 Refactor
  • 🌟 Feature
  • 🔥 Bug Fix
  • 🔩 Maintenance
  • 🛠 Workflow CI/CD changes

Related Issues or Documents

  • closes #

Usage Instructions, Screenshots, Recordings

CleanShot 2024-05-13 at 10 23 33

CleanShot 2024-05-13 at 10 24 01

Selected category with ancestors:
CleanShot 2024-05-13 at 10 24 32

Have you written tests?

  • Yes!
  • No... here is why: Writing tests are mandatory, please replace this text with why test are not included in this PR

[Optional] Description

Copy link

changeset-bot bot commented May 8, 2024

🦋 Changeset detected

Latest commit: 00770f8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
saleor-dashboard Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot temporarily deployed to pr-4846 May 8, 2024 07:29 Destroyed
@github-actions github-actions bot temporarily deployed to pr-4846 May 8, 2024 10:34 Destroyed
@Cloud11PL Cloud11PL marked this pull request as ready for review May 8, 2024 10:58
@Cloud11PL Cloud11PL requested a review from a team as a code owner May 8, 2024 10:58
@Cloud11PL Cloud11PL requested review from witoszekdev, krzysztofzuraw and a team May 8, 2024 10:58
@github-actions github-actions bot temporarily deployed to pr-4846 May 8, 2024 10:58 Destroyed
@github-actions github-actions bot temporarily deployed to pr-4846 May 8, 2024 12:34 Destroyed
@Cloud11PL Cloud11PL requested a review from poulch May 8, 2024 12:47
@mirekm
Copy link
Member

mirekm commented May 8, 2024

Parents should also be rendered once selected.
subcats

@github-actions github-actions bot temporarily deployed to pr-4846 May 9, 2024 10:19 Destroyed
@@ -14,6 +14,14 @@ export const searchCategories = gql`
node {
id
name
ancestors(first: $first) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you pass here the same variable as for the root query (categories), which is wrong, this number should be either configured separately or even hardcoded so now the number of loaded categories indicates also amount of ancestors, which is not really expected here: having eg first 2 categories I still want eg. to have 3 ancestors (not 2)

Consider:

  • keep number of ancestors as separate variable
  • search categories query is used in several places, do you need ancestors in each? perhaps a separated query is more reasonable here? (think about it if you have time)

@github-actions github-actions bot temporarily deployed to pr-4846 May 10, 2024 13:03 Destroyed
@Cloud11PL
Copy link
Member Author

@mirekm We've decided to reverse the order to "Grandparent / parent / category"

@github-actions github-actions bot temporarily deployed to pr-4846 May 13, 2024 08:56 Destroyed
@github-actions github-actions bot temporarily deployed to pr-4846 May 13, 2024 10:10 Destroyed
@github-actions github-actions bot temporarily deployed to pr-4846 May 13, 2024 13:37 Destroyed
andrzejewsky
andrzejewsky previously approved these changes May 13, 2024
@github-actions github-actions bot temporarily deployed to pr-4846 May 14, 2024 14:13 Destroyed
@github-actions github-actions bot temporarily deployed to pr-4846 May 15, 2024 07:15 Destroyed
@github-actions github-actions bot temporarily deployed to pr-4846 May 15, 2024 07:36 Destroyed
@github-actions github-actions bot temporarily deployed to pr-4846 May 15, 2024 16:13 Destroyed
@andrzejewsky andrzejewsky self-requested a review May 15, 2024 16:27
andrzejewsky
andrzejewsky previously approved these changes May 15, 2024
@Cloud11PL Cloud11PL force-pushed the MERX-392-improve-nested-categories branch from 0241511 to ebd3a1c Compare May 17, 2024 09:54
@github-actions github-actions bot temporarily deployed to pr-4846 May 17, 2024 09:56 Destroyed
Comment on lines 179 to 183
let availableCategories = categories;

if (selectedProductCategory) {
availableCategories = [...categories, selectedProductCategory];
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: I think we should avoid using let if it can be solved with a ternary operator

Suggested change
let availableCategories = categories;
if (selectedProductCategory) {
availableCategories = [...categories, selectedProductCategory];
}
const availableCategories = selectedProductCategory ? [...categories, selectedProductCategory] : categories;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right, thanks 😸

@andrzejewsky andrzejewsky self-requested a review May 17, 2024 11:50
@Cloud11PL Cloud11PL merged commit 528fef0 into main May 17, 2024
14 of 15 checks passed
@Cloud11PL Cloud11PL deleted the MERX-392-improve-nested-categories branch May 17, 2024 11:51
karola312 pushed a commit that referenced this pull request May 23, 2024
* show categories' ancestors

* add tests

* cleanup

* changeset

* cr fixes

* show parents when category is selected

* show only parent and grandparent category

* reverse order

* properly align input with adornment

* fix test

* improve categories display

* fix

* fix

* fix display while loading

* improve ancestor categories display

* fix tests

* show ancestors of saved category on first load

* gql cleanup

* fix tests

* update macaw

* cr fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants