Skip to content

Commit

Permalink
[Admin][Channel] Revert Sylius#10860
Browse files Browse the repository at this point in the history
  • Loading branch information
lchrusciel committed Jan 22, 2020
1 parent bd31f17 commit e9ec260
Show file tree
Hide file tree
Showing 27 changed files with 54 additions and 184 deletions.
25 changes: 0 additions & 25 deletions app/migrations/Version20191119131635.php

This file was deleted.

1 change: 0 additions & 1 deletion features/channel/managing_channels/adding_channel.feature
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ Feature: Adding a new channel
And I set its hostname as "m.avengers-gear.com"
And I set its contact email as "contact@avengers-gear.com"
And I define its color as "blue"
And I define its type as mobile
And I choose "Euro" as the base currency
And I choose "English (United States)" as a default locale
And I allow to skip shipping step if only one shipping method is available
Expand Down
9 changes: 0 additions & 9 deletions features/channel/managing_channels/editing_channel.feature
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,3 @@ Feature: Editing channel
Scenario: Seeing disabled base currency field during channel edition
When I want to modify a channel "Web Channel"
Then the base currency field should be disabled

@ui
Scenario: Changing type of channel
Given the channel "Web Channel" with a mobile type
When I want to modify a channel "Web Channel"
And I change its type to website
And I save my changes
Then I should be notified that it has been successfully edited
And this channel type should be website
9 changes: 0 additions & 9 deletions src/Sylius/Behat/Context/Setup/ChannelContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,6 @@ public function channelBillingDataIs(
$this->channelManager->flush();
}

/**
* @Given /^the (channel "[^"]+") with a (mobile|website|pos) type$/
*/
public function theChannelIsAType(ChannelInterface $channel, string $type): void
{
$channel->setType($type);

$this->channelManager->flush();
}

/**
* @Given channel :channel has menu taxon :taxon
Expand Down
26 changes: 1 addition & 25 deletions src/Sylius/Behat/Context/Ui/Admin/ManagingChannelsContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
use Behat\Behat\Context\Context;
use Sylius\Behat\NotificationType;
use Sylius\Behat\Page\Admin\Channel\CreatePageInterface;
use Sylius\Behat\Page\Admin\Channel\IndexPageInterface;
use Sylius\Behat\Page\Admin\Channel\UpdatePageInterface;
use Sylius\Behat\Page\Admin\Crud\IndexPageInterface;
use Sylius\Behat\Service\NotificationCheckerInterface;
use Sylius\Behat\Service\Resolver\CurrentPageResolverInterface;
use Sylius\Component\Core\Formatter\StringInflector;
Expand Down Expand Up @@ -282,14 +282,6 @@ public function iSaveMyChanges()
$this->updatePage->saveChanges();
}

/**
* @When /^I define its type as (mobile|website|pos)$/
*/
public function iDefineItsTypeAs(string $type): void
{
$this->createPage->setType($type);
}

/**
* @Then I should be notified that channel with this code already exists
*/
Expand Down Expand Up @@ -477,14 +469,6 @@ public function theDefaultTaxZoneForTheChannelShouldBe(ChannelInterface $channel
Assert::true($this->updatePage->isDefaultTaxZoneChosen($taxZone));
}

/**
* @When /^I change its type to (mobile|website|pos)$/
*/
public function iChangeItsTypeTo(string $type): void
{
$this->updatePage->changeType($type);
}

/**
* @Given channel :channel should not have default tax zone
*/
Expand Down Expand Up @@ -524,14 +508,6 @@ public function iShouldBeNotifiedThatTheDefaultLocaleHasToBeEnabled(): void
);
}

/**
* @Then /^this channel type should be (mobile|website|pos)$/
*/
public function thisChannelTypeShouldBe(string $type): void
{
Assert::same($this->updatePage->getType(), $type);
}

/**
* @Given /^(this channel) menu taxon should be "([^"]+)"$/
* @Given the channel :channel should have :menuTaxon as a menu taxon
Expand Down
14 changes: 10 additions & 4 deletions src/Sylius/Behat/Context/Ui/ThemeContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace Sylius\Behat\Context\Ui;

use Behat\Behat\Context\Context;
use Sylius\Behat\Page\Admin\Channel\IndexPageInterface;
use Sylius\Behat\Page\Admin\Channel\UpdatePageInterface;
use Sylius\Behat\Page\Shop\HomePageInterface;
use Sylius\Behat\Service\SharedStorageInterface;
Expand All @@ -26,6 +27,9 @@ final class ThemeContext implements Context
/** @var SharedStorageInterface */
private $sharedStorage;

/** @var IndexPageInterface */
private $channelIndexPage;

/** @var UpdatePageInterface */
private $channelUpdatePage;

Expand All @@ -34,10 +38,12 @@ final class ThemeContext implements Context

public function __construct(
SharedStorageInterface $sharedStorage,
IndexPageInterface $channelIndexPage,
UpdatePageInterface $channelUpdatePage,
HomePageInterface $homePage
) {
$this->sharedStorage = $sharedStorage;
$this->channelIndexPage = $channelIndexPage;
$this->channelUpdatePage = $channelUpdatePage;
$this->homePage = $homePage;
}
Expand Down Expand Up @@ -70,19 +76,19 @@ public function iUnsetThemeOnChannel(ChannelInterface $channel)
*/
public function channelShouldNotUseAnyTheme(ChannelInterface $channel)
{
$this->channelUpdatePage->open(['id' => $channel->getId()]);
$this->channelIndexPage->open();

Assert::isEmpty($this->channelUpdatePage->getUsedTheme($channel->getCode()));
Assert::same($this->channelIndexPage->getUsedThemeName($channel->getCode()), 'Default');
}

/**
* @Then /^(that channel) should use (that theme)$/
*/
public function channelShouldUseTheme(ChannelInterface $channel, ThemeInterface $theme)
{
$this->channelUpdatePage->open(['id' => $channel->getId()]);
$this->channelIndexPage->open();

Assert::same($this->channelUpdatePage->getUsedTheme($channel->getCode()), $theme->getName());
Assert::same($this->channelIndexPage->getUsedThemeName($channel->getCode()), $theme->getName());
}

/**
Expand Down
8 changes: 1 addition & 7 deletions src/Sylius/Behat/Page/Admin/Channel/CreatePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,6 @@ public function allowToSkipPaymentStep(): void
$this->getDocument()->checkField('Skip payment step if only one payment method is available?');
}

public function setType(string $type): void
{
$this->getElement('type')->selectOption($type);
}

public function specifyMenuTaxon(string $menuTaxon): void
{
$menuTaxonElement = $this->getElement('menu_taxon')->getParent();
Expand All @@ -108,15 +103,14 @@ protected function getToggleableElement(): NodeElement
protected function getDefinedElements(): array
{
return array_merge(parent::getDefinedElements(), [
'base_currency' => '#sylius_channel_baseCurrency',
'code' => '#sylius_channel_code',
'currencies' => '#sylius_channel_currencies',
'base_currency' => '#sylius_channel_baseCurrency',
'default_locale' => '#sylius_channel_defaultLocale',
'enabled' => '#sylius_channel_enabled',
'locales' => '#sylius_channel_locales',
'menu_taxon' => '#sylius_channel_menuTaxon',
'name' => '#sylius_channel_name',
'type' => '#sylius_channel_type',
]);
}
}
2 changes: 0 additions & 2 deletions src/Sylius/Behat/Page/Admin/Channel/CreatePageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,5 @@ public function allowToSkipShippingStep(): void;

public function allowToSkipPaymentStep(): void;

public function setType(string $type): void;

public function specifyMenuTaxon(string $menuTaxon): void;
}
28 changes: 28 additions & 0 deletions src/Sylius/Behat/Page/Admin/Channel/IndexPage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Sylius\Behat\Page\Admin\Channel;

use Sylius\Behat\Page\Admin\Crud\IndexPage as BaseIndexPage;

class IndexPage extends BaseIndexPage implements IndexPageInterface
{
public function getUsedThemeName(string $channelCode): ?string
{
$table = $this->getDocument()->find('css', 'table');

$row = $this->getTableAccessor()->getRowWithFields($table, ['code' => $channelCode]);

return trim($this->getTableAccessor()->getFieldFromRow($table, $row, 'themeName')->getText());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,11 @@

declare(strict_types=1);

namespace Sylius\Component\Channel\Model;
namespace Sylius\Behat\Page\Admin\Channel;

final class ChannelTypes
{
public const TYPE_WEBSITE = 'website';

public const TYPE_MOBILE = 'mobile';
use Sylius\Behat\Page\Admin\Crud\IndexPageInterface as BaseIndexPageInterface;

public const TYPE_POS = 'pos';

private function __construct()
{
}
interface IndexPageInterface extends BaseIndexPageInterface
{
public function getUsedThemeName(string $channelCode): ?string;
}
12 changes: 0 additions & 12 deletions src/Sylius/Behat/Page/Admin/Channel/UpdatePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,6 @@ public function isBaseCurrencyDisabled(): bool
return $this->getElement('base_currency')->hasAttribute('disabled');
}

public function changeType(string $type): void
{
$this->getElement('type')->selectOption($type);
}

public function getType(): string
{
return $this->getElement('type')->getValue();
}

public function changeMenuTaxon(string $menuTaxon): void
{
$menuTaxonElement = $this->getElement('menu_taxon')->getParent();
Expand Down Expand Up @@ -138,8 +128,6 @@ protected function getDefinedElements(): array
'menu_taxon' => '#sylius_channel_menuTaxon',
'name' => '#sylius_channel_name',
'tax_calculation_strategy' => '#sylius_channel_taxCalculationStrategy',
'theme' => '#sylius_channel_themeName',
'type' => '#sylius_channel_type',
]);
}
}
4 changes: 0 additions & 4 deletions src/Sylius/Behat/Page/Admin/Channel/UpdatePageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ public function isTaxCalculationStrategyChosen(string $taxCalculationStrategy):

public function isBaseCurrencyDisabled(): bool;

public function changeType(string $type): void;

public function getType(): string;

public function changeMenuTaxon(string $menuTaxon): void;

public function getMenuTaxon(): string;
Expand Down
1 change: 1 addition & 0 deletions src/Sylius/Behat/Resources/config/services/contexts/ui.xml
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@

<service id="sylius.behat.context.ui.theme" class="Sylius\Behat\Context\Ui\ThemeContext">
<argument type="service" id="sylius.behat.shared_storage" />
<argument type="service" id="sylius.behat.page.admin.channel.index" />
<argument type="service" id="sylius.behat.page.admin.channel.update" />
<argument type="service" id="sylius.behat.page.shop.home" />
</service>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<parameters>
<parameter key="sylius.behat.page.admin.channel.create.class">Sylius\Behat\Page\Admin\Channel\CreatePage</parameter>
<parameter key="sylius.behat.page.admin.channel.index.class">%sylius.behat.page.admin.crud.index.class%</parameter>
<parameter key="sylius.behat.page.admin.channel.update.class">Sylius\Behat\Page\Admin\Channel\UpdatePage</parameter>
<parameter key="sylius.behat.page.admin.channel.index.class">Sylius\Behat\Page\Admin\Channel\IndexPage</parameter>
</parameters>

<services>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ sylius_grid:
sortable: code
options:
template: "@SyliusAdmin/Channel/Grid/Field/code.html.twig"
type:
themeName:
type: twig
label: sylius.form.channel.type
label: sylius.ui.theme
sortable: ~
options:
template: "@SyliusAdmin/Channel/Grid/Field/type.html.twig"
template: "@SyliusAdmin/Channel/Grid/Field/themeName.html.twig"
enabled:
type: twig
label: sylius.ui.enabled
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
<div class="ui attached segment">
{{ form_errors(form) }}
<div class="fields">
<div class="five wide field">
<div class="six wide field">
{{ form_row(form.code) }}
</div>
<div class="six wide field">
<div class="seven wide field">
{{ form_row(form.name) }}
</div>
<div class="three wide filed">{{ form_row(form.type) }}</div>
<div class="one wide field">
<div class="three wide field">
{{ form_row(form.color) }}
</div>
</div>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
{% import '@SyliusAdmin/Common/Macro/icons.html.twig' as icons %}

{% if channel is defined %}
<div class="channel">
{% if channel.type is not empty %}
{{ icons.channelType(channel.type) }}
{% endif %}
<span class="ui medium empty circular label channel__item" style="background-color: {{ channel.color|default('#000') }}"></span>

<span class="channel__item">
{{ channel.name|default(channel.code) }}
</span>
Expand Down
Loading

0 comments on commit e9ec260

Please sign in to comment.