Skip to content

Commit

Permalink
Changes after CR
Browse files Browse the repository at this point in the history
  • Loading branch information
mpysiak committed May 17, 2024
1 parent d8e1758 commit f7378ae
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
9 changes: 4 additions & 5 deletions src/Sylius/Behat/Page/Admin/Product/ShowPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function isSimpleProductPage(): bool

public function isShowInShopButtonDisabled(): bool
{
return $this->getElement('show_product_single_button')->hasClass('disabled');
return $this->getElement('show_product_button')->hasClass('disabled');
}

public function getAppliedCatalogPromotionsLinks(string $variantName, string $channelName): array
Expand Down Expand Up @@ -60,12 +60,12 @@ public function getRouteName(): string

public function showProductInChannel(string $channel): void
{
$this->getElement('show_product_dropdown')->clickLink($channel);
$this->getElement('show_product_button')->clickLink($channel);
}

public function showProductInSingleChannel(): void
{
$this->getElement('show_product_single_button')->click();
$this->getElement('show_product_button')->click();
}

public function showProductEditPage(): void
Expand All @@ -85,8 +85,7 @@ protected function getDefinedElements(): array
'edit_product_button' => '#edit-product',
'edit_variant_button' => '#variants .variants-accordion__title:contains("%variantCode%") .edit-variant',
'product_name' => '#header h1 .content > span',
'show_product_dropdown' => '[data-test-view-in-store]',
'show_product_single_button' => '[data-test-view-in-store]',
'show_product_button' => '[data-test-view-in-store]',
'variants' => '#variants',
]);
}
Expand Down
11 changes: 5 additions & 6 deletions src/Sylius/Behat/Page/Admin/Product/UpdateSimpleProductPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,22 +285,22 @@ public function goToVariantGeneration(): void

public function getShowProductInSingleChannelUrl(): string
{
return $this->getElement('show_product_single_button')->getAttribute('href');
return $this->getElement('show_product_button')->getAttribute('href');
}

public function isShowInShopButtonDisabled(): bool
{
return $this->getElement('show_product_single_button')->hasClass('disabled');
return $this->getElement('show_product_button')->hasClass('disabled');
}

public function showProductInChannel(string $channel): void
{
$this->getElement('show_product_dropdown')->clickLink($channel);
$this->getElement('show_product_button')->clickLink($channel);
}

public function showProductInSingleChannel(): void
{
$this->getElement('show_product_single_button')->click();
$this->getElement('show_product_button')->click();
}

public function disable(): void
Expand Down Expand Up @@ -365,8 +365,7 @@ protected function getDefinedElements(): array
'product_taxon' => '#sylius-product-taxonomy-tree .item .header:contains("%taxonName%") input',
'product_taxons' => '#sylius_product_productTaxons',
'shipping_required' => '#sylius_product_variant_shippingRequired',
'show_product_dropdown' => '[data-test-view-in-store]',
'show_product_single_button' => '[data-test-view-in-store]',
'show_product_button' => '[data-test-view-in-store]',
'slug' => '#sylius_product_translations_%locale%_slug',
'tab' => '.menu [data-tab="%name%"]',
'taxonomy' => 'a[data-tab="taxonomy"]',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
{% from '@SyliusAdmin/shared/helper/icon.html.twig' import icon as _icon %}

{% set product = (hookable_metadata.context.resource) %}
{% set enabledChannels = product.channels|filter(channel => channel.enabled == true) %}
{% set enabled_channels = product.channels|filter(channel => channel.enabled == true) %}

{% if sylius_bundle_loaded_checker('SyliusShopBundle') %}
{% if not product.enabled or enabledChannels|length < 1 %}
{% if not product.enabled or enabled_channels|length < 1 %}
<a class="btn disabled" href="{{ (url is not defined) ? '#' : url|raw }}" target="_blank" {{ sylius_test_html_attribute('view-in-store') }}>
{{ _icon({ icon: 'arrow-up-right', class: 'icon icon-tabler' }) }}
{{ 'sylius.ui.view_in_store'|trans }}
</a>
{% elseif enabledChannels|length > 1 %}
{% elseif enabled_channels|length > 1 %}
<div class="dropdown">
<button class="btn dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
{{ 'sylius.ui.view_in_store'|trans }}
</button>
<ul class="dropdown-menu" {{ sylius_test_html_attribute('view-in-store') }}>
{% for channel in enabledChannels %}
{% for channel in enabled_channels %}
{% set product_translation = sylius_product_translation(product, channel) %}
{% if product_translation is not null %}
{% set url = sylius_channel_url(path('sylius_shop_product_show', {'slug': product_translation.slug, '_locale': product_translation.locale}), channel) %}
Expand All @@ -35,7 +35,7 @@
</ul>
</div>
{% else %}
{% for channel in enabledChannels %}
{% for channel in enabled_channels %}
{% set product_translation = sylius_product_translation(product, channel) %}
{% if product_translation is not null %}
{% set url = sylius_channel_url(path('sylius_shop_product_show', {'slug': product_translation.slug, '_locale': product_translation.locale}), channel) %}
Expand Down

0 comments on commit f7378ae

Please sign in to comment.