Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@
"require": {
"php": ">=8.1",
"ext-json": "*",
"doctrine/collections": "^1.6",
"doctrine/orm": "^2.7",
"doctrine/collections": "^1.6 || ^2.0",
"doctrine/orm": "^2.7 || ^3.0",
"doctrine/persistence": "^1.3 || ^2.0 || ^3.0",
"knplabs/knp-menu": "^3.1",
"league/flysystem": "^1.1 || ^2.1",
"league/flysystem-bundle": "^1.1 || ^2.4",
"league/flysystem": "^1.1 || ^2.1 || ^3.0",
"league/flysystem-bundle": "^1.1 || ^2.4 || ^3.0",
"liip/imagine-bundle": "^2.4",
"psr/event-dispatcher": "^1.0",
"psr/log": "^1.0 || ^2.0 || ^3.0",
"setono/doctrine-orm-batcher": "^0.6",
"setono/doctrine-orm-batcher-bundle": "^0.3.4",
"spatie/enum": "^3.7",
"sylius/channel": "^1.0",
"sylius/channel-bundle": "^1.0",
"sylius/core": "^1.0",
"sylius/core-bundle": "^1.0",
"sylius/inventory": "^1.0",
"sylius/locale": "^1.0",
"sylius/resource-bundle": "^1.6",
"sylius/ui-bundle": "^1.0",
"sylius/channel": "^1.0 || ^2.0",
"sylius/channel-bundle": "^1.0 || ^2.0",
"sylius/core": "^1.0 || ^2.0",
"sylius/core-bundle": "^1.0 || ^2.0",
"sylius/inventory": "^1.0 || ^2.0",
"sylius/locale": "^1.0 || ^2.0",
"sylius/resource-bundle": "^1.6 || ^2.0",
"sylius/ui-bundle": "^1.0 || ^2.0",
"symfony/config": "^6.4 || ^7.4",
"symfony/console": "^6.4 || ^7.4",
"symfony/dependency-injection": "^6.4 || ^7.4",
Expand Down
8 changes: 7 additions & 1 deletion src/DependencyInjection/Compiler/RegisterFilesystemPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use League\Flysystem\FilesystemOperator;
use RuntimeException;
use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Webmozart\Assert\Assert;
Expand Down Expand Up @@ -39,7 +40,12 @@ public function process(ContainerBuilder $container): void
throw new InvalidArgumentException(sprintf('No service definition exists with id "%s"', $parameterValue));
}

$definitionClass = $container->getDefinition($parameterValue)->getClass();
$definition = $container->getDefinition($parameterValue);
if ($definition->getClass() === null && $definition instanceof ChildDefinition) {
$definition = $container->getDefinition($definition->getParent());
}

$definitionClass = $definition->getClass();
Assert::notNull($definitionClass);

if (interface_exists(FilesystemInterface::class)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/routing/admin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ setono_sylius_feed_admin_feed_violations_index:
route:
parameters:
id: $id
template: '@SyliusAdmin/Crud/index.html.twig'
template: '@SyliusAdmin/shared/crud/index.html.twig'
grid: setono_sylius_feed_admin_violation
section: admin
permission: true
5 changes: 1 addition & 4 deletions src/Resources/views/Admin/Feed/Label/State/error.html.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
<span class="ui red label">
<i class="check icon"></i>
{{ value|trans }}
</span>
<span class="badge bg-danger">{{ value|trans }}</span>
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
<span class="ui yellow label">
<i class="check icon"></i>
{{ value|trans }}
</span>
<span class="badge bg-warning">{{ value|trans }}</span>
5 changes: 1 addition & 4 deletions src/Resources/views/Admin/Feed/Label/State/ready.html.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
<span class="ui teal label">
<i class="check icon"></i>
{{ value|trans }}
</span>
<span class="badge bg-success">{{ value|trans }}</span>
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
<span class="ui grey label">
<i class="check icon"></i>
{{ value|trans }}
</span>
<span class="badge bg-secondary">{{ value|trans }}</span>
17 changes: 7 additions & 10 deletions src/Resources/views/Admin/Feed/Show/_breadcrumb.html.twig
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
{% import '@SyliusAdmin/Macro/breadcrumb.html.twig' as breadcrumb %}

{% set breadcrumbs = [
{ label: 'sylius.ui.administration'|trans, url: path('sylius_admin_dashboard') },
{ label: 'setono_sylius_feed.ui.feeds'|trans, url: path('setono_sylius_feed_admin_feed_index') },
{ label: '#'~feed.id }
]
%}

{{ breadcrumb.crumble(breadcrumbs) }}
<nav aria-label="breadcrumb" class="my-3">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ path('sylius_admin_dashboard') }}">{{ 'sylius.ui.dashboard'|trans }}</a></li>
<li class="breadcrumb-item"><a href="{{ path('setono_sylius_feed_admin_feed_index') }}">{{ 'setono_sylius_feed.ui.feeds'|trans }}</a></li>
<li class="breadcrumb-item active">#{{ feed.id }}</li>
</ol>
</nav>
35 changes: 19 additions & 16 deletions src/Resources/views/Admin/Feed/Show/_header.html.twig
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
{# @var \Setono\SyliusFeedPlugin\Model\FeedInterface feed #}

<h1 class="ui header">
<i class="circular cart icon"></i>
<div class="content">
{{ 'setono_sylius_feed.ui.feed'|trans }} {{ feed.name }}
<div class="sub header">
<div class="ui horizontal divided list">
<div class="item">
{{ 'setono_sylius_feed.ui.feed_type'|trans ~ ': ' ~ feed.feedType }} {# todo output the label of the feed type #}
</div>
<div class="item">
<div class="ui label">{{ ('setono_sylius_feed.ui.' ~ feed.state)|trans }}</div>
</div>
</div>
<div class="d-flex justify-content-between align-items-center mb-3">
<div>
<h1 class="mb-1">
{{ 'setono_sylius_feed.ui.feed'|trans }} {{ feed.name }}
</h1>
<div class="text-muted">
{{ 'setono_sylius_feed.ui.feed_type'|trans }}: {{ feed.feedType }}
<span class="badge bg-{% if feed.state == 'ready' %}success{% elseif feed.state == 'processing' %}warning{% elseif feed.state == 'error' %}danger{% else %}secondary{% endif %} ms-2">
{{ ('setono_sylius_feed.ui.' ~ feed.state)|trans }}
</span>
</div>
</div>
</h1>
<div class="d-flex gap-2">
{% set menu = knp_menu_get('setono_sylius_feed.admin.feed.show', [], {'feed': feed}) %}
{% for child in menu.children %}
<a href="{{ child.uri }}" class="btn btn-{% if child.name == 'generate' %}primary{% else %}outline-secondary{% endif %}">
{{ child.label|trans }}
</a>
{% endfor %}
</div>
</div>
171 changes: 70 additions & 101 deletions src/Resources/views/Admin/Feed/show.html.twig
Original file line number Diff line number Diff line change
@@ -1,112 +1,81 @@
{% extends '@SyliusAdmin/layout.html.twig' %}

{# @var \Setono\SyliusFeedPlugin\Model\FeedInterface feed #}

{% block title %}{{ 'setono_sylius_feed.ui.feed'|trans ~' '~ feed.name }} {{ parent() }}{% endblock %}

{% block content %}
{{ sonata_block_render_event('setono_sylius_feed.admin.feed.show.before_header', {'resource': resource}) }}

<div class="ui stackable two column grid">
<div class="ten wide column">
{% include '@SetonoSyliusFeedPlugin/Admin/Feed/Show/_header.html.twig' %}
</div>

{% set menu = knp_menu_get('setono_sylius_feed.admin.feed.show', [], {'feed': feed}) %}
{{ knp_menu_render(menu, {'template': '@SyliusUi/Menu/top.html.twig'}) }}
</div>

{{ sonata_block_render_event('setono_sylius_feed.admin.feed.show.after_header', {'resource': resource}) }}

{% include '@SetonoSyliusFeedPlugin/Admin/Feed/Show/_breadcrumb.html.twig' %}

{{ sonata_block_render_event('setono_sylius_feed.admin.feed.show.after_breadcrumb', {'resource': resource}) }}

{% if workflow_has_marked_place(feed, constant('Setono\\SyliusFeedPlugin\\Workflow\\FeedGraph::STATE_READY')) or workflow_has_marked_place(feed, constant('Setono\\SyliusFeedPlugin\\Workflow\\FeedGraph::STATE_PROCESSING')) %}
<div class="ui segment spaceless">
<table class="ui basic celled table">
<thead>
<tr>
<th>{{ 'sylius.ui.channel'|trans }}</th>
<th>{{ 'sylius.ui.locale'|trans }}</th>
<th>{{ 'setono_sylius_feed.ui.link'|trans }}</th>
</tr>
</thead>
<tbody>
{% for channel in feed.channels %}
{% for locale in channel.locales %}
<tr class="item">
<td>{{ channel.name }}</td>
<td>{{ locale.name }}</td>
<td>
<div class="ui icon input" style="width: 100%;position: relative;">
<div class="ui pointing below label teal"
style="position:absolute; right: 10px; top: -100%; display: none"
id="link-copied-{{ loop.parent.loop.index }}-{{ loop.index }}">
<i class="check icon"></i> {{ 'setono_sylius_feed.ui.link_copied'|trans }}
</div>
<input id="link-{{ loop.parent.loop.index }}-{{ loop.index }}" type="text"
value="{{ setono_sylius_feed_generate_feed_url(feed, channel, locale) }}"
readonly>
<i class="copy link icon" data-link-id="link-{{ loop.parent.loop.index }}-{{ loop.index }}"
data-link-copied-id="link-copied-{{ loop.parent.loop.index }}-{{ loop.index }}"
data-content="{{ 'setono_sylius_feed.ui.click_to_copy'|trans }}"
data-position="top right"></i>
</div>
</td>
</tr>
{% endfor %}
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="ui segment">
<div class="ui info message">
<div class="header">
{{ 'setono_sylius_feed.ui.unprocessed_feed_header'|trans }}
</div>
<p>{{ 'setono_sylius_feed.ui.unprocessed_feed_body'|trans }}</p>
{% extends '@SyliusAdmin/shared/layout/base.html.twig' %}

{% block title %}{{ 'setono_sylius_feed.ui.feed'|trans ~ ' ' ~ feed.name }} {{ parent() }}{% endblock %}

{% block body %}
{% include '@SyliusAdmin/shared/crud/common/sidebar.html.twig' %}

<div class="page-wrapper">
{% include '@SyliusAdmin/shared/crud/common/navbar.html.twig' %}

<div class="page-body">
<div class="container-xl">
{% include '@SetonoSyliusFeedPlugin/Admin/Feed/Show/_header.html.twig' %}

{% include '@SetonoSyliusFeedPlugin/Admin/Feed/Show/_breadcrumb.html.twig' %}

{% if workflow_has_marked_place(feed, constant('Setono\\SyliusFeedPlugin\\Workflow\\FeedGraph::STATE_READY')) or workflow_has_marked_place(feed, constant('Setono\\SyliusFeedPlugin\\Workflow\\FeedGraph::STATE_PROCESSING')) %}
<div class="card mb-3">
<div class="table-responsive">
<table class="table table-bordered mb-0">
<thead>
<tr>
<th>{{ 'sylius.ui.channel'|trans }}</th>
<th>{{ 'sylius.ui.locale'|trans }}</th>
<th>{{ 'setono_sylius_feed.ui.link'|trans }}</th>
</tr>
</thead>
<tbody>
{% for channel in feed.channels %}
{% for locale in channel.locales %}
<tr>
<td>{{ channel.name }}</td>
<td>{{ locale.name }}</td>
<td>
<div class="input-group">
<input id="link-{{ loop.parent.loop.index }}-{{ loop.index }}" type="text" class="form-control form-control-sm" value="{{ setono_sylius_feed_generate_feed_url(feed, channel, locale) }}" readonly>
<button class="btn btn-outline-secondary btn-sm copy-link-btn" type="button" data-link-id="link-{{ loop.parent.loop.index }}-{{ loop.index }}">
{{ 'setono_sylius_feed.ui.click_to_copy'|trans }}
</button>
</div>
</td>
</tr>
{% endfor %}
{% endfor %}
</tbody>
</table>
</div>
</div>
{% else %}
<div class="alert alert-info">
<strong>{{ 'setono_sylius_feed.ui.unprocessed_feed_header'|trans }}</strong>
<p class="mb-0">{{ 'setono_sylius_feed.ui.unprocessed_feed_body'|trans }}</p>
</div>
{% endif %}

{% if feed.violations|length > 0 %}
<h2>{{ 'setono_sylius_feed.ui.violation_summary'|trans }}</h2>
<p>{{ 'setono_sylius_feed.ui.view_all_violations'|trans({'%path%': path('setono_sylius_feed_admin_feed_violations_index', {'id': feed.id})})|raw }}</p>
{{ render(controller('setono_sylius_feed.controller.action.admin.severity_count', {'feed': feed.id})) }}
{% endif %}
</div>
</div>
{% endif %}
{% if feed.violations|length > 0 %}
<h2 class="ui header">{{ 'setono_sylius_feed.ui.violation_summary'|trans }}</h2>

<p>{{ 'setono_sylius_feed.ui.view_all_violations'|trans({'%path%' : path('setono_sylius_feed_admin_feed_violations_index', {'id' : feed.id})})|raw }}</p>

{{ render(controller('setono_sylius_feed.controller.action.admin.severity_count', {'feed': feed.id})) }}
{% endif %}

{{ sonata_block_render_event('setono_sylius_feed.admin.feed.show.after_content', {'resource': resource}) }}
{% include '@SyliusAdmin/shared/crud/common/content/footer.html.twig' %}
</div>
{% endblock %}

{% block javascripts %}
{{ parent() }}

<script>
$('[data-content]').popup();

let timers = {};

$('i.copy').on('click', function () {
const linkId = $(this).data('link-id');
const linkCopiedId = $(this).data('link-copied-id');

const link = $('#' + linkId).get(0);
const $linkCopied = $('#' + linkCopiedId);

link.select();
link.setSelectionRange(0, 9999);

document.execCommand('copy');

$linkCopied.show();

clearTimeout(timers[linkId]);
timers[linkId] = setTimeout(function () {
$linkCopied.hide();
}, 3000);
document.querySelectorAll('.copy-link-btn').forEach(function(btn) {
btn.addEventListener('click', function() {
var input = document.getElementById(this.getAttribute('data-link-id'));
navigator.clipboard.writeText(input.value);
var original = this.textContent;
this.textContent = '✓';
setTimeout(function() { btn.textContent = original; }, 2000);
});
});
</script>
{% endblock %}
13 changes: 4 additions & 9 deletions src/Resources/views/Admin/Violation/Grid/Field/data.html.twig
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
<div class="ui accordion">
<div class="title">
<i class="dropdown icon"></i>
{{ 'sylius.ui.view'|trans }}
</div>
<div class="content">
<pre>{{ data }}</pre>
</div>
</div>
<details>
<summary>{{ 'sylius.ui.view'|trans }}</summary>
<pre class="mt-2">{{ data }}</pre>
</details>
35 changes: 18 additions & 17 deletions src/Resources/views/Admin/Violation/severity_count.html.twig
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
{# @var \Setono\SyliusFeedPlugin\DTO\SeverityCount[] severityCounts #}
<div class="ui segment spaceless">
<table class="ui basic celled table">
<thead>
<tr>
<th>{{ 'setono_sylius_feed.ui.severity'|trans }}</th>
<th>{{ 'setono_sylius_feed.ui.count'|trans }}</th>
</tr>
</thead>
<tbody>
{% set severityMap = {'error': 'negative', 'warning': 'warning', 'notice': ''} %}
{% for severityCount in severityCounts %}
<tr class="item {{ severityMap[severityCount.severity] }}">
<td>{{ ('setono_sylius_feed.ui.severities.' ~ severityCount.severity)|trans }}</td>
<td>{{ severityCount.count }}</td>
<div class="card mb-3">
<div class="table-responsive">
<table class="table table-bordered mb-0">
<thead>
<tr>
<th>{{ 'setono_sylius_feed.ui.severity'|trans }}</th>
<th>{{ 'setono_sylius_feed.ui.count'|trans }}</th>
</tr>
{% endfor %}
</tbody>
</table>
</thead>
<tbody>
{% for severityCount in severityCounts %}
<tr class="{% if severityCount.severity == 'error' %}table-danger{% elseif severityCount.severity == 'warning' %}table-warning{% endif %}">
<td>{{ ('setono_sylius_feed.ui.severities.' ~ severityCount.severity)|trans }}</td>
<td>{{ severityCount.count }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
Loading