-
Notifications
You must be signed in to change notification settings - Fork 9
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
Saferpay's Transaction Logs in Admin Panel #46
Merged
Zales0123
merged 3 commits into
CommerceWeavers:main
from
jakubtobiasz:feature/transaction-logs-in-ap
Jun 5, 2023
Merged
Changes from all commits
Commits
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 |
---|---|---|
@@ -1,13 +1,21 @@ | ||
commerce_weavers_sylius_saferpay_admin_transaction_log_index: | ||
commerce_weavers_saferpay_transaction_log: | ||
resource: | | ||
alias: commerce_weavers_saferpay.transaction_log | ||
section: admin | ||
templates: "@SyliusAdmin\\Crud" | ||
only: ['index'] | ||
only: ['index', 'show'] | ||
redirect: update | ||
grid: commerce_weavers_saferpay_transaction_log | ||
vars: | ||
index: | ||
icon: 'th list' | ||
type: sylius.resource | ||
prefix: saferpay | ||
|
||
commerce_weavers_saferpay_admin_transaction_log_show: | ||
path: /saferpay/transaction-logs/{id} | ||
methods: [ GET ] | ||
defaults: | ||
_controller: commerce_weavers_saferpay.controller.transaction_log::showAction | ||
_sylius: | ||
template: '@CommerceWeaversSyliusSaferpayPlugin/Admin/TransactionLogs/show.html.twig' |
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,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use CommerceWeavers\SyliusSaferpayPlugin\TransactionLog\Menu\AdminMenuListener; | ||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; | ||
|
||
return static function (ContainerConfigurator $containerConfigurator) { | ||
$services = $containerConfigurator->services(); | ||
|
||
$services | ||
->set(AdminMenuListener::class) | ||
->tag('kernel.event_listener', [ | ||
'event' => 'sylius.menu.admin.main', | ||
'method' => 'addAdminMenuItems', | ||
]) | ||
; | ||
}; |
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,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace CommerceWeavers\SyliusSaferpayPlugin\TransactionLog\Menu; | ||
|
||
use Sylius\Bundle\UiBundle\Menu\Event\MenuBuilderEvent; | ||
|
||
final class AdminMenuListener | ||
{ | ||
public function addAdminMenuItems(MenuBuilderEvent $event): void | ||
{ | ||
$menu = $event->getMenu(); | ||
|
||
$newSubmenu = $menu | ||
->addChild('commerce_weavers_sylius_saferpay_plugin') | ||
->setLabel('commerce_weavers_saferpay.ui.plugin_name') | ||
; | ||
|
||
$newSubmenu | ||
->addChild('commerce_weavers_sylius_saferpay_plugin_transaction_log', [ | ||
'route' => 'commerce_weavers_saferpay_admin_transaction_log_index', | ||
]) | ||
->setLabel('commerce_weavers_saferpay.ui.transaction_logs') | ||
; | ||
} | ||
} |
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 @@ | ||
{{ ('commerce_weavers_saferpay.ui.type_' ~ _context.data)|trans }} |
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,50 @@ | ||
{% extends '@SyliusAdmin/layout.html.twig' %} | ||
|
||
{% block title %}{{ 'commerce_weavers_saferpay.ui.transaction_logs'|trans }} {{ parent() }}{% endblock %} | ||
|
||
{% block content %} | ||
<div id="header" class="ui stackable two column grid"> | ||
<div class="column"> | ||
<h1 class="ui header"> | ||
<i class="circular cube icon"></i> | ||
<div class="content"> | ||
<span>{{ 'commerce_weavers_saferpay.ui.transaction_log'|trans }}</span> | ||
<div class="sub header">{{ transaction_log.id }}</div> | ||
</div> | ||
</h1> | ||
{% import '@SyliusAdmin/Macro/breadcrumb.html.twig' as breadcrumb %} | ||
|
||
{% set breadcrumbs = [ | ||
{ label: 'sylius.ui.administration'|trans, url: path('sylius_admin_dashboard') }, | ||
{ label: 'commerce_weavers_saferpay.ui.transaction_logs'|trans, url: path('commerce_weavers_saferpay_admin_transaction_log_index') }, | ||
{ label: resource.name|default(resource.id) } | ||
] %} | ||
|
||
{{ breadcrumb.crumble(breadcrumbs) }} | ||
</div> | ||
</div> | ||
|
||
<div class="ui stackable grid"> | ||
<div class="eight wide column"> | ||
<div class="ui segment"> | ||
<h4 class="ui dividing header">{{ 'commerce_weavers_saferpay.ui.type'|trans }}</h4> | ||
<p {{ sylius_test_html_attribute('log-type') }}>{{ ('commerce_weavers_saferpay.ui.type_' ~ transaction_log.type)|trans }}</p> | ||
|
||
<h4 class="ui dividing header">{{ 'commerce_weavers_saferpay.ui.occurred_at'|trans }}</h4> | ||
<p>{{ transaction_log.occurredAt|date('Y-m-d H:i:s') }}</p> | ||
|
||
<h4 class="ui dividing header">{{ 'commerce_weavers_saferpay.ui.description'|trans }}</h4> | ||
<p {{ sylius_test_html_attribute('description') }}>{{ transaction_log.description }}</p> | ||
|
||
<h4 class="ui dividing header">{{ 'commerce_weavers_saferpay.ui.payment_id'|trans }}</h4> | ||
<p>{{ transaction_log.payment.id }} ({{ 'sylius.ui.order'|trans }}: #{{ transaction_log.payment.order.number }})</p> | ||
</div> | ||
</div> | ||
<div class="eight wide column"> | ||
<div class="ui segment"> | ||
<h4 class="ui dividing header">{{ 'commerce_weavers_saferpay.ui.context'|trans }}</h4> | ||
<pre {{ sylius_test_html_attribute('context') }}>{{ transaction_log.context|json_encode(constant('JSON_PRETTY_PRINT'))|trim|raw }}</pre> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock %} |
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,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\CommerceWeavers\SyliusSaferpayPlugin\Behat\Page\Admin\TransactionLog; | ||
|
||
use Behat\Mink\Element\NodeElement; | ||
use Sylius\Behat\Page\Admin\Crud\IndexPage as BaseIndexPage; | ||
|
||
class IndexPage extends BaseIndexPage implements IndexPageInterface | ||
{ | ||
public function openLogDetailsByOrderNumberAndDescription(string $orderNumber, string $description): void | ||
{ | ||
$row = $this->getRow($orderNumber, $description); | ||
$row->clickLink('Show'); | ||
} | ||
|
||
private function getRow(string $orderNumber, string $description): NodeElement | ||
{ | ||
$tableAccessor = $this->getTableAccessor(); | ||
$table = $this->getElement('table'); | ||
|
||
return $tableAccessor->getRowWithFields($table, ['orderNumber' => $orderNumber, 'description' => $description]); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
tests/Behat/Page/Admin/TransactionLog/IndexPageInterface.php
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,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\CommerceWeavers\SyliusSaferpayPlugin\Behat\Page\Admin\TransactionLog; | ||
|
||
use Sylius\Behat\Page\Admin\Crud\IndexPageInterface as BaseIndexPageInterface; | ||
|
||
interface IndexPageInterface extends BaseIndexPageInterface | ||
{ | ||
public function openLogDetailsByOrderNumberAndDescription(string $orderNumber, string $description): void; | ||
} |
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,39 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\CommerceWeavers\SyliusSaferpayPlugin\Behat\Page\Admin\TransactionLog; | ||
|
||
use FriendsOfBehat\PageObjectExtension\Page\SymfonyPage; | ||
|
||
class ShowPage extends SymfonyPage implements ShowPageInterface | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return $this->getElement('description')->getText(); | ||
} | ||
|
||
public function getLogType(): string | ||
{ | ||
return $this->getElement('log-type')->getText(); | ||
} | ||
|
||
public function getContext(): string | ||
{ | ||
return $this->getElement('context')->getText(); | ||
} | ||
|
||
public function getRouteName(): string | ||
{ | ||
return 'commerce_weavers_saferpay_admin_transaction_log_show'; | ||
} | ||
|
||
protected function getDefinedElements(): array | ||
{ | ||
return array_merge(parent::getDefinedElements(), [ | ||
'context' => '[data-test-context]', | ||
'description' => '[data-test-description]', | ||
'log-type' => '[data-test-log-type]', | ||
]); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
tests/Behat/Page/Admin/TransactionLog/ShowPageInterface.php
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,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\CommerceWeavers\SyliusSaferpayPlugin\Behat\Page\Admin\TransactionLog; | ||
|
||
use FriendsOfBehat\PageObjectExtension\Page\SymfonyPageInterface; | ||
|
||
interface ShowPageInterface extends SymfonyPageInterface | ||
{ | ||
public function getDescription(): string; | ||
|
||
public function getLogType(): string; | ||
|
||
public function getContext(): string; | ||
} |
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
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.
Lazy 😄 can we check it in more detail or there is no point we could determine them within the Behat scenario?
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.
I know it could be better, but not checking the whole context can always be called lazy :D. If I check whether there are only
request
andresponse
keys, there is still a change they're empty. So, the only "good" way is checking the whole context, which is really long, and it might make only a little bit more sense.