Skip to content
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

Merge branch '2.3' of ezsystems/ezplatform-admin-ui into 4.5 #856

Merged
merged 4 commits into from
Aug 3, 2023
Merged
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
1 change: 1 addition & 0 deletions src/bundle/Resources/encore/ibexa.js.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ if (fs.existsSync(fieldTypesPath)) {

module.exports = (Encore) => {
Encore.addEntry('ibexa-admin-ui-layout-js', layout)
.addEntry('ibexa-admin-ui-error-page-js', [path.resolve(__dirname, '../public/js/scripts/admin.error.page.js')])
.addEntry('ibexa-admin-ui-bookmark-list-js', [
path.resolve(__dirname, '../public/js/scripts/button.state.toggle.js'),
path.resolve(__dirname, '../public/js/scripts/button.content.edit.js'),
Expand Down
42 changes: 42 additions & 0 deletions src/bundle/Resources/public/js/scripts/admin.error.page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
(function (global, doc, iconPaths) {
const notificationsContainer = doc.querySelector('.ibexa-notifications-container');
const notifications = JSON.parse(notificationsContainer.dataset.notifications);
const { template } = notificationsContainer.dataset;
const iconsMap = {
info: 'system-information',
error: 'circle-close',
warning: 'warning-triangle',
success: 'checkmark',
};
const escapeHTML = (string) => {
const stringTempNode = doc.createElement('div');

stringTempNode.appendChild(doc.createTextNode(string));

return stringTempNode.innerHTML;
};
const addNotification = ({ detail }) => {
const { label, message } = detail;
const container = doc.createElement('div');
const iconSetPath = iconPaths.iconSets[iconPaths.defaultIconSet];
const iconPath = `${iconSetPath}#${iconsMap[label]}`;
const finalMessage = escapeHTML(message);

const notification = template
.replace('{{ label }}', label)
.replace('{{ message }}', finalMessage)
.replace('{{ icon_path }}', iconPath);

container.insertAdjacentHTML('beforeend', notification);

const notificationNode = container.querySelector('.alert');

notificationsContainer.append(notificationNode);
};

Object.entries(notifications).forEach(([label, messages]) => {
messages.forEach((message) => addNotification({ detail: { label, message } }));
});

doc.body.addEventListener('ibexa-notify', addNotification, false);
})(window, window.document, window.ibexa.iconPaths);
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends '@ibexadesign/ui/layout.html.twig' %}
{% extends '@ibexadesign/ui/layout_error.html.twig' %}

{% block content %}
<div class="ibexa-error-page">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends '@ibexadesign/ui/layout.html.twig' %}
{% extends '@ibexadesign/ui/layout_error.html.twig' %}

{% block user_menu %}{% endblock %}
{% block left_sidebar %}{% endblock %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends '@ibexadesign/ui/layout.html.twig' %}
{% extends '@ibexadesign/ui/layout_error.html.twig' %}

{% block content %}
<div class="ibexa-error-page">
Expand Down
85 changes: 85 additions & 0 deletions src/bundle/Resources/views/themes/admin/ui/layout_error.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<!DOCTYPE html>
<html lang="{{ app.request.locale }}">
<head>
<meta charset="UTF-8" />
<script>
window.ibexa = {};
window.ibexa.iconPaths = {{ ibexa_admin_ui_config.iconPaths|json_encode|raw }};
</script>
{% if app.request.locale == 'ach_UG' %}
<script type="text/javascript">
var _jipt = [];
_jipt.push(['project', 'ibexa']);
</script>
<script type="text/javascript" src="//cdn.crowdin.com/jipt/jipt.js"></script>
{% endif %}
<title>{% block title %}Ibexa DXP{% endblock %}</title>
{{ encore_entry_link_tags('ibexa-admin-ui-layout-css', null, 'ibexa') }}
{% block stylesheets %}{% endblock %}
<link rel="icon" type="image/x-icon" href="{{ asset('bundles/ibexaadminui/img/favicon.ico') }}" />
<link rel="icon" type="image/png" sizes="16x16" href="{{ asset('bundles/ibexaadminui/img/favicon-16x16.png') }}" />
<link rel="icon" type="image/png" sizes="32x32" href="{{ asset('bundles/ibexaadminui/img/favicon-32x32.png') }}" />

<script src="{{ asset('bundles/ibexaadminuiassets/vendors/bootstrap/dist/js/bootstrap.min.js') }}"></script>
</head>
<body class="{% block body_class %}{% endblock %}">
{% block header_row %}
<header class="ibexa-main-header">
<div class="ibexa-main-header__brand-column">
<a class="ibexa-main-header__brand" href="{{ url('ibexa.dashboard') }}">
<img class="ibexa-main-header__brand-image" src="{{ asset('bundles/ibexaadminui/img/ibexa-logo.svg') }}" alt="Ibexa" />
</a>
</div>
<div class="ibexa-main-header__user-menu-column">
{% block user_menu %}
{{ knp_menu_render('ezplatform_admin_ui.menu.user', {
'depth': 1,
'template': '@ibexadesign/ui/menu/user.html.twig'
}) }}
{% endblock %}
</div>
</header>
{% endblock %}

{% block main_container %}
<main class="ibexa-main-container {% block main_container_class %}{% endblock %}">
{% block content_column %}
<div
class="ibexa-main-container__content-column
{%- if not is_back_to_top_disabled|default(false) %} ibexa-back-to-top-scroll-container{% endif %}"
>
<div class="container ibexa-back-to-top-anchor">
{% block content %}{% endblock %}
</div>
</div>
{% endblock %}

</main>
{% endblock %}
<div
class="ibexa-notifications-container"
data-notifications="{{ app.flashes|json_encode() }}"
data-template="{{ include('@ibexadesign/ui/notification.html.twig', {
label: '{{ label }}',
message: '{{ message }}',
})|e('html_attr') }}"></div>

{% if not is_back_to_top_disabled|default(false) %}
{% block back_to_top %}
<div class="ibexa-back-to-top">
<button type="button" class="btn ibexa-btn ibexa-btn--tertiary ibexa-btn--no-text ibexa-back-to-top__btn">
<span class="ibexa-back-to-top__title">
{{ 'back.to.top'|trans|desc('Go to top') }}
</span>
<svg class="ibexa-icon ibexa-icon--medium ibexa-back-to-top__icon">
<use xlink:href="{{ ibexa_icon_path('back') }}"></use>
</svg>
</button>
</div>
{% endblock %}
{% endif %}

{{ encore_entry_script_tags('ibexa-admin-ui-error-page-js', null, 'ibexa') }}
{{ ibexa_render_component_group('stylesheet-body') }}
</body>
</html>
20 changes: 7 additions & 13 deletions src/lib/UI/Module/ContentTree/NodeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,6 @@ public function createNode(
): Node {
$uninitializedContentInfoList = [];
$containerLocations = [];

$userBookmarks = $this->bookmarkService->loadBookmarks(0, -1);
$bookmarkLocations = array_flip(array_column($userBookmarks->items, 'id'));

$node = $this->buildNode(
$location,
$uninitializedContentInfoList,
Expand All @@ -107,18 +103,16 @@ public function createNode(
$loadChildren,
$depth,
$sortClause,
$sortOrder,
$bookmarkLocations
$sortOrder
);

$contentById = $this->contentService->loadContentListByContentInfo($uninitializedContentInfoList);
$versionInfoById = $this->contentService->loadVersionInfoListByContentInfo($uninitializedContentInfoList);

$aggregatedChildrenCount = null;
if ($this->searchService->supports(SearchService::CAPABILITY_AGGREGATIONS)) {
$aggregatedChildrenCount = $this->countAggregatedSubitems($containerLocations);
}

$this->supplyTranslatedContentName($node, $contentById);
$this->supplyTranslatedContentName($node, $versionInfoById);
$this->supplyChildrenCount($node, $aggregatedChildrenCount);

return $node;
Expand Down Expand Up @@ -395,16 +389,16 @@ static function (Repository $repository) use ($contentInfo): int {
}

/**
* @param \Ibexa\Contracts\Core\Repository\Values\Content\Content[] $contentById
* @param \Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo[] $versionInfoById
*/
private function supplyTranslatedContentName(Node $node, array $contentById): void
private function supplyTranslatedContentName(Node $node, array $versionInfoById): void
{
if ($node->contentId !== self::TOP_NODE_CONTENT_ID) {
$node->name = $this->translationHelper->getTranslatedContentName($contentById[$node->contentId]);
$node->name = $this->translationHelper->getTranslatedContentNameByVersionInfo($versionInfoById[$node->contentId]);
}

foreach ($node->children as $child) {
$this->supplyTranslatedContentName($child, $contentById);
$this->supplyTranslatedContentName($child, $versionInfoById);
}
}

Expand Down
Loading