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

[Feature] Toggleable taxon #11287

Merged
merged 24 commits into from
Jul 9, 2020
Merged

Conversation

mmenozzi
Copy link
Contributor

@mmenozzi mmenozzi commented Mar 25, 2020

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no?
Deprecations? no
Related tickets implement #8785
License MIT
  • Enabled property
  • Adjustment of repository methods to filter for enabled / maybe new methods to get all (also disabled)
  • Showing in admin that a taxon is disabled in taxon create/update page
  • Showing in admin that a taxon is disabled in products list page

@probot-autolabeler probot-autolabeler bot added Admin AdminBundle related issues and PRs. Shop ShopBundle related issues and PRs. labels May 4, 2020
@mmenozzi mmenozzi marked this pull request as ready for review May 4, 2020 20:07
@mmenozzi mmenozzi requested a review from a team as a code owner May 4, 2020 20:07
@mmenozzi
Copy link
Contributor Author

mmenozzi commented May 5, 2020

Hi @pamil and @lchrusciel, I don't know why but this PR won't trigger the Travis CI build. Do you know why? Anyway it's ready for review.

@LucaGallinari
Copy link
Contributor

Hi @pamil and @lchrusciel this PR is ready for review

Copy link
Member

@Zales0123 Zales0123 left a comment

Choose a reason for hiding this comment

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

Sorry for the long response time @mmenozzi, it's a nice piece of code 👌

@@ -0,0 +1,29 @@
@homepage
Feature: Viewing only enabled taxons in taxon menu
In order to not access disabled taxons
Copy link
Member

Choose a reason for hiding this comment

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

In order to browse only available categories? We should think about the benefit or the Visitor/Customer. They do no think about disabled/enabled entities, but about the merch, they see in the shop :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, good point. I am ok in changing this only in the that specific line of the feature definition. Because i have some doubts in rewording this in the other parts of this feature: the taxon availability is not only related to the fact that it is enabled but even to the fact that it should be associated to the current channel. This features only test enabled/disabled taxon and not their belonging to a specific channel.
I don't know if i expressed correctly what i am thinking =)

Then I should see "Accessories Caps" and "Caps" in the menu
And I should not see "Clothes", "T-Shirts", "Coats" and "Belts" in the menu

@api
Copy link
Member

Choose a reason for hiding this comment

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

Move this tag to the previous step (@ui @api) and we save some lines 💃

Copy link
Contributor

Choose a reason for hiding this comment

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

One of the step is sligthly different. Before i pushed the changes i had put them together in a single scenario but test failed at step 'Then I should see "Accessories Caps" and "Caps" in the menu' cause @ui and @api seems to fill the test attributes of the menu differently. For a parent category the @ui prints "[Parent name] [List of children names]", instead @api prints "[Parent name]". I don't think this should be solved with this PR.

Given the "Clothes" taxon is disabled
And the "Belts" taxon is disabled
When I check available taxons
Then I should see "Accessories Caps" and "Caps" in the menu
Copy link
Member

Choose a reason for hiding this comment

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

We should use as little context-related words as possible (especially as we want to use this scenario both for UI and API). So maybe something like Then taxons "Accessories Caps" and "Caps" should be available?

Copy link
Contributor

Choose a reason for hiding this comment

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

I followed this file features/homepage/viewing_only_taxons_from_menu_taxon.feature and it uses "i should see"

Background:
Given the store operates on a single channel in "United States"

@ui
Copy link
Member

Choose a reason for hiding this comment

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

We could also make it in API - check do we get 404 on some specific request

Copy link
Contributor

Choose a reason for hiding this comment

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

A disabled taxon should still be available through API. Can you show some example for this case? Only a not existent taxon should lead to a 404 on API calls

Copy link
Member

Choose a reason for hiding this comment

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

From the shop perspective disabled taxon should not be available I suppose. However, the admin user should still have access to it

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, you are totally right, dunno why i thought of it as an admin API

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @lchrusciel, did you mean that we should open a separate PR for the Sylius/ShopApiPlugin? Am I right?

Basically a PR to change here:

https://github.com/Sylius/ShopApiPlugin/blob/master/src/Controller/Taxon/ShowTaxonDetailsAction.php#L47

with something like:

$taxon = $this->taxonRepository->findOneBy(['code' => $code, 'enabled' => true]);

Copy link
Member

Choose a reason for hiding this comment

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

Let's split the problem into two parts.

First of all this repo: I just meant, that the current scenario makes sense and should be covered with UI. What (I think) @Zales0123 meant was about our new implementation of integration with Api Platform.

Secondly, Shop API is a totally different topic and can be covered after 1.8 release :)

src/Sylius/Behat/Page/Admin/Taxon/UpdatePage.php Outdated Show resolved Hide resolved
@@ -32,6 +33,10 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'entry_type' => TaxonTranslationType::class,
'label' => 'sylius.form.taxon.name',
])
->add('enabled', CheckboxType::class, [
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't it be true as default?

Copy link
Contributor

Choose a reason for hiding this comment

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

I followed what has been done for the enabled field in other entities and it is as this: no default value (as it true/checked as default) and required=>false. I am ok in changing this btw

@@ -56,6 +56,8 @@
</field>

<gedmo:tree type="nested" />

<field name="enabled" column="enabled" type="boolean" />
Copy link
Member

Choose a reason for hiding this comment

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

redundant column attribute

Copy link
Member

Choose a reason for hiding this comment

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

But we have the practice to leave them in Core

@LucaGallinari
Copy link
Contributor

Hi @lchrusciel the build does not trigger continuous-integration/travis-ci/pr. It happened even few weeks ago and you resolved by closing and reopening, can you do the same?

@lchrusciel lchrusciel closed this May 27, 2020
@lchrusciel lchrusciel reopened this May 27, 2020
@lchrusciel
Copy link
Member

of course ;)

@LucaGallinari LucaGallinari force-pushed the toggleable-taxon branch 2 times, most recently from 8e2f97e to a2e5ab2 Compare June 3, 2020 07:28
@LucaGallinari
Copy link
Contributor

I made the requested changes and commented others. Ready to be reviewed again

@LucaGallinari LucaGallinari force-pushed the toggleable-taxon branch 2 times, most recently from 3f6d255 to 12b3e88 Compare June 18, 2020 09:39
@LucaGallinari
Copy link
Contributor

Hi guys @lchrusciel @pamil @Zales0123 , I made the requested changes and commented others. This PR is ready to be reviewed again.
The build is failing on some features but it doesn't seem to be related to my changes. It's strange that it's green for 7.4 and not for 7.3

@mmenozzi mmenozzi force-pushed the toggleable-taxon branch from 12b3e88 to c51226e Compare July 6, 2020 09:36
@mmenozzi
Copy link
Contributor Author

mmenozzi commented Jul 6, 2020

Hi @lchrusciel @pamil @Zales0123, I resolved a conflict in this PR related to the inheritdoc removal.
I think that this PR is ready to merge.
It would be great if we could have this feature in Sylius 1.8.

Let me know if there's something I can do to help.

Background:
Given the store operates on a single channel in "United States"

@ui
Copy link
Member

Choose a reason for hiding this comment

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

From the shop perspective disabled taxon should not be available I suppose. However, the admin user should still have access to it

@lchrusciel lchrusciel merged commit b643117 into Sylius:master Jul 9, 2020
@lchrusciel
Copy link
Member

lchrusciel commented Jul 9, 2020

Thanks a lot, Manuele and Luca! 🎉 It was a lot of work but also quite a lot of waiting for us. Sorry about that. However, it is finally there and the whole community will take advantage of it after the next release ;)

Also, can you apply changes from #11287 (comment) in separate PR?

@mmenozzi
Copy link
Contributor Author

Thanks a lot, Manuele and Luca! 🎉 It was a lot of work but also quite a lot of waiting for us. Sorry about that. However, it is finally there and the whole community will take advantage of it after the next release ;)

Thanks to you and the whole Sylius team! I'm happy that this feature will be available in Sylius 1.8.   🎉

Also, can you apply changes from #11287 (comment) in separate PR?

Sure, will do it ASAP!

@LucaGallinari
Copy link
Contributor

Thank you guys!

@loevgaard
Copy link
Contributor

Great work, guys! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Admin AdminBundle related issues and PRs. Shop ShopBundle related issues and PRs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants