Skip to content

Commit

Permalink
Merge branch 'ux-improve-tags-system' of https://github.com/andersonj…
Browse files Browse the repository at this point in the history
…eccel/mautic into ux-improve-tags-system
  • Loading branch information
andersonjeccel committed Apr 26, 2024
2 parents cb0d486 + 13095e5 commit 9949a64
Show file tree
Hide file tree
Showing 112 changed files with 14,131 additions and 10,464 deletions.
18 changes: 18 additions & 0 deletions app/bundles/ApiBundle/ApiEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,22 @@ final class ApiEvents
* @var string
*/
public const API_ON_ENTITY_POST_SAVE = 'mautic.api_on_entity_post_save';

/**
* The mautic.api_pre_serialization_context event is dispatched before the serialization context is created for the view.
*
* The event listener receives a Mautic\ApiBundle\Event\ApiSerializationContextEvent instance.
*
* @var string
*/
public const API_PRE_SERIALIZATION_CONTEXT = 'mautic.api_pre_serialization_context';

/**
* The mautic.api_post_serialization_context event is dispatched after the serialization context is created for the view.
*
* The event listener receives a Mautic\ApiBundle\Event\ApiSerializationContextEvent instance.
*
* @var string
*/
public const API_POST_SERIALIZATION_CONTEXT = 'mautic.api_post_serialization_context';
}
15 changes: 15 additions & 0 deletions app/bundles/ApiBundle/Controller/FetchCommonApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
use FOS\RestBundle\Controller\AbstractFOSRestController;
use FOS\RestBundle\View\View;
use JMS\Serializer\Exclusion\ExclusionStrategyInterface;
use Mautic\ApiBundle\ApiEvents;
use Mautic\ApiBundle\Event\ApiSerializationContextEvent;
use Mautic\ApiBundle\Helper\BatchIdToEntityHelper;
use Mautic\ApiBundle\Helper\EntityResultHelper;
use Mautic\ApiBundle\Serializer\Exclusion\ParentChildrenExclusionStrategy;
Expand Down Expand Up @@ -679,6 +681,13 @@ protected function setBatchError(int $key, string $msg, int $code, array &$error
protected function setSerializationContext(View $view): void
{
$context = $view->getContext();

if ($this->dispatcher->hasListeners(ApiEvents::API_PRE_SERIALIZATION_CONTEXT)) {
$apiSerializationContextEvent = new ApiSerializationContextEvent($context, $this->getCurrentRequest());
$this->dispatcher->dispatch($apiSerializationContextEvent, ApiEvents::API_PRE_SERIALIZATION_CONTEXT);
$context = $apiSerializationContextEvent->getContext();
}

if (!empty($this->serializerGroups)) {
$context->setGroups($this->serializerGroups);
}
Expand All @@ -705,6 +714,12 @@ protected function setSerializationContext(View $view): void
$context->setSerializeNull(true);
}

if ($this->dispatcher->hasListeners(ApiEvents::API_POST_SERIALIZATION_CONTEXT)) {
$apiSerializationContextEvent = new ApiSerializationContextEvent($context, $this->getCurrentRequest());
$this->dispatcher->dispatch($apiSerializationContextEvent, ApiEvents::API_POST_SERIALIZATION_CONTEXT);
$context = $apiSerializationContextEvent->getContext();
}

$view->setContext($context);
}

Expand Down
31 changes: 31 additions & 0 deletions app/bundles/ApiBundle/Event/ApiSerializationContextEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace Mautic\ApiBundle\Event;

use FOS\RestBundle\Context\Context;
use Mautic\CoreBundle\Event\CommonEvent;
use Symfony\Component\HttpFoundation\Request;

final class ApiSerializationContextEvent extends CommonEvent
{
public function __construct(private Context $context, private Request $request)
{
}

public function getContext(): Context
{
return $this->context;
}

public function setContext(Context $context): void
{
$this->context = $context;
}

public function getRequest(): Request
{
return $this->request;
}
}
2 changes: 1 addition & 1 deletion app/bundles/AssetBundle/Entity/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class Asset extends FormEntity
/**
* @var bool|null
*/
private $disallow = false;
private $disallow = true;

public static function loadMetadata(ORM\ClassMetadata $metadata): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
{% block listResults %}
{% if items|length %}
<div class="table-responsive">
<table class="table table-hover table-striped table-bordered asset-list" id="assetTable">
<table class="table table-hover asset-list" id="assetTable">
<thead>
<tr>
{{- include(
Expand Down
1 change: 1 addition & 0 deletions app/bundles/CampaignBundle/Assets/css/campaign.css
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@
width: 206px;
padding: 10px 15px;
border-radius: 6px;
margin-bottom: 10px;
}

.campaign-builder .builder-active {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

{% if items|length > 0 %}
<div class="table-responsive">
<table class="table table-hover table-striped table-bordered campaign-list" id="campaignTable">
<table class="table table-hover campaign-list" id="campaignTable">
<thead>
<tr>
{{- include('@MauticCore/Helper/tableheader.html.twig', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
{% block listResults %}
{% if items|length %}
<div class="table-responsive">
<table class="table table-hover table-striped table-bordered category-list" id="categoryTable">
<table class="table table-hover category-list" id="categoryTable">
<thead>
<tr>
{{- include('@MauticCore/Helper/tableheader.html.twig', {
Expand Down
11 changes: 9 additions & 2 deletions app/bundles/CoreBundle/Assets/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -2767,6 +2767,9 @@ ul.line-legend li {
.table-responsive-force > .table-bordered > tfoot > tr:last-child > td {
border-bottom: 0;
}
.table-hover > tbody > tr:hover {
transition: var(--all);
}
.progress {
background-color: #ebedf0;
-webkit-box-shadow: none;
Expand Down Expand Up @@ -4951,10 +4954,14 @@ body.noscroll {
.table .input-group-sm > .input-group-addon {
font-size: 10px;
line-height: 1em;
background-color: transparent;
border: 0;
padding: 0;
}
.table .input-group-sm .dropdown-toggle {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
border: 0;
background-color: transparent;
padding: 5px 8px;
}
.input-group .input-group-btn button {
height: 32px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,9 @@

}
}

.table-hover {
> tbody > tr:hover {
transition: var(--all);
}
}
8 changes: 6 additions & 2 deletions app/bundles/CoreBundle/Assets/css/app/less/custom.less
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,15 @@ body.noscroll {
& > .input-group-addon {
font-size: 10px;
line-height: 1em;
background-color: transparent;
border: 0;
padding: 0;
}

.dropdown-toggle {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
border: 0;
background-color: transparent;
padding: 5px 8px;
}
}

Expand Down
13 changes: 13 additions & 0 deletions app/bundles/CoreBundle/Assets/js/11.editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,19 @@ Mautic.GetCkEditorConfigOptions = function(ckEditorToolbarOptions, tokenCallbac
fontSize: {
options: [8, 9, 10, 11, 12, 14, 18, 24, 30, 36, 48, 72],
supportAllValues : true
},
link: {
decorators: {
// based on: https://ckeditor.com/docs/ckeditor5/latest/features/link.html#adding-target-and-rel-attributes-to-external-links
openInNewTab: {
mode: 'manual',
label: 'Open in a new tab',
attributes: {
target: '_blank',
rel: 'noopener noreferrer'
}
}
}
}
};

Expand Down
33 changes: 3 additions & 30 deletions app/bundles/CoreBundle/Form/Type/ConfigType.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,8 @@
*/
class ConfigType extends AbstractType
{
private array $supportedLanguages;

public function __construct(
private TranslatorInterface $translator,
private LanguageHelper $langHelper,
private IpLookupFactory $ipLookupFactory,
private ?AbstractLookup $ipLookup,
private Shortener $shortenerFactory,
private CoreParametersHelper $coreParametersHelper,
) {
$this->supportedLanguages = $langHelper->getSupportedLanguages();
public function __construct(private TranslatorInterface $translator, private LanguageHelper $langHelper, private IpLookupFactory $ipLookupFactory, private ?AbstractLookup $ipLookup, private Shortener $shortenerFactory, private CoreParametersHelper $coreParametersHelper)
{
}

public function buildForm(FormBuilderInterface $builder, array $options): void
Expand Down Expand Up @@ -181,7 +172,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'locale',
ChoiceType::class,
[
'choices' => $this->getLanguageChoices(),
'choices' => $this->langHelper->getLanguageChoices(),
'label' => 'mautic.core.config.form.locale',
'required' => false,
'attr' => [
Expand Down Expand Up @@ -713,24 +704,6 @@ public function getBlockPrefix()
return 'coreconfig';
}

private function getLanguageChoices(): array
{
// Get the list of available languages
$languages = $this->langHelper->fetchLanguages(false, false);
$choices = [];

foreach ($languages as $code => $langData) {
$choices[$langData['name']] = $code;
}

$choices = array_merge($choices, array_flip($this->supportedLanguages));

// Alpha sort the languages by name
ksort($choices, SORT_FLAG_CASE | SORT_NATURAL);

return $choices;
}

private function getIpServicesChoices(): array
{
$choices = [];
Expand Down
31 changes: 31 additions & 0 deletions app/bundles/CoreBundle/Helper/LanguageHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public function __construct(
$this->cacheFile = $pathsHelper->getSystemPath('cache').'/../languageList.txt';
}

/**
* @return array<string>
*/
public function getSupportedLanguages(): array
{
if (!empty($this->supportedLanguages)) {
Expand Down Expand Up @@ -210,6 +213,13 @@ public function fetchPackage($languageCode): array
$this->fetchLanguages();
}

if (!is_readable($this->cacheFile)) {
return [
'error' => true,
'message' => 'mautic.core.language.helper.error.fetching.languages',
];
}

$cacheData = json_decode(file_get_contents($this->cacheFile), true);

// Make sure the language actually exists
Expand Down Expand Up @@ -355,4 +365,25 @@ private function loadSupportedLanguages(): void
$this->supportedLanguages[$locale] = (!empty($config['name'])) ? $config['name'] : $locale;
}
}

/**
* @return array<string>
*/
public function getLanguageChoices(): array
{
// Get the list of available languages
$languages = $this->fetchLanguages(false, false);
$choices = [];

foreach ($languages as $code => $langData) {
$choices[$langData['name']] = $code;
}

$choices = array_merge($choices, array_flip($this->getSupportedLanguages()));

// Alpha sort the languages by name
ksort($choices, SORT_FLAG_CASE | SORT_NATURAL);

return $choices;
}
}
5 changes: 5 additions & 0 deletions app/bundles/CoreBundle/IpLookup/AbstractLocalDataLookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ public function downloadRemoteDataStore()
{
$package = $this->getRemoteDateStoreDownloadUrl();

if (empty($package)) {
$this->logger->error('Failed to fetch remote IP data: Invalid or inactive MaxMind license key');

return false;
}
try {
$data = $this->client->get($package, [
RequestOptions::ALLOW_REDIRECTS => true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ id="{{ id|escape }}" name="{{ full_name|escape }}" {{ disabled ? 'disabled="disa
<label {% for k, v in label_attr %}
{{ '%s="%s" '|format(k|escape, v|escape)|raw }}
{% endfor %}{{ tooltip ? 'data-toggle="tooltip" data-container="body" data-placement="top" title="%s"'|format(tooltip)|raw : ''}}>
{{ label|trans({}, translation_domain)|escape }}{{ tooltip ? ' <i class="fa fa-question-circle"></i>' : '' }}</label>
{{ label_html ? label|trans({}, translation_domain)|purify : label|trans({}, translation_domain)|escape }}{{ tooltip ? ' <i class="fa fa-question-circle"></i>' : '' }}</label>
{% endif %}
{% endblock form_label %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<div class="col-xs-4 col-sm-2 pl-0 pr-0 pt-10 pb-10 text-right">
<i class="hidden-xs fa {{ typeOneIconClass }} fa-lg"></i>
<button class="visible-xs pull-right btn btn-sm btn-default btn-nospin text-primary" onclick="{{ typeOneOnClick }}">
{{ 'mautic.core.select' }}
{{ 'mautic.core.select'|trans }}
</button>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
),
'data-toggle': editMode
}),
iconClass: 'ri-edit-circle-line',
iconClass: 'ri-edit-line',
btnText: 'mautic.core.form.edit'|trans,
primary: true
}) }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@

{% set firstItem = items|first %}
<div class="table-responsive">
<table class="table table-hover table-striped table-bordered {{ sessionVar }}-list">
<table class="table table-hover {{ sessionVar }}-list">
<thead>
<tr>
{% if ignoreStandardColumns is empty %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{% if items|length %}
<div class="table-responsive">
<table class="table table-hover table-striped table-bordered theme-list" id="themeTable">
<table class="table table-hover theme-list" id="themeTable">
<thead>
<tr>
{{ include('@MauticCore/Helper/tableheader.html.twig', {
Expand Down

0 comments on commit 9949a64

Please sign in to comment.