Commit 966351c8 authored by Claus Due's avatar Claus Due Committed by Christian Kuhn
Browse files

[BUGFIX] Compact clear cache button when one item exists

This change makes the clear cache toolbar item dynamically
either render a drop-down as it did before, or render a single
link directly if there is only a single clear cache action.

If any hooks or permissions add additional items the drop-
down is rendered again.

Change-Id: Iadac80405bf1152a849d4d4269a9bc0728b0b459
Releases: master
Resolves: #78656
Reviewed-on: https://review.typo3.org/50594

Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: Philipp Gampe's avatarPhilipp Gampe <philipp.gampe@typo3.org>
Tested-by: Philipp Gampe's avatarPhilipp Gampe <philipp.gampe@typo3.org>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent d9bca574
......@@ -122,14 +122,22 @@ class ClearCacheToolbarItem implements ToolbarItemInterface
*/
public function getItem()
{
$icon = $this->iconFactory->getIcon('apps-toolbar-menu-cache', Icon::SIZE_SMALL)->render('inline');
$view = $this->getFluidTemplateObject('ClearCacheToolbarItem.html');
$view->assignMultiple([
if ($this->hasDropDown()) {
$templateReference = 'ClearCacheToolbarItem.html';
$icon = $this->iconFactory->getIcon('apps-toolbar-menu-cache', Icon::SIZE_SMALL)->render('inline');
$variables = [
'title' => 'LLL:EXT:lang/locallang_core.xlf:rm.clearCache_clearCache',
'icon' => $icon
]
);
];
} else {
$templateReference = 'ClearCacheToolbarItemSingle.html';
$cacheAction = end($this->cacheActions);
$variables['link'] = $cacheAction['href'];
$variables['title'] = $cacheAction['title'];
$variables['icon'] = $cacheAction['icon'];
}
$view = $this->getFluidTemplateObject($templateReference);
$view->assignMultiple($variables);
return $view->render();
}
......@@ -168,7 +176,7 @@ class ClearCacheToolbarItem implements ToolbarItemInterface
*/
public function hasDropDown()
{
return true;
return count($this->cacheActions) > 1;
}
/**
......
{namespace core = TYPO3\CMS\Core\ViewHelpers}
<span class="toolbar-item-icon" title="{f:translate(key: title, htmlEscape: 'TRUE')}">{icon -> f:format.raw()}</span>
<span class="toolbar-item-icon" title="{f:translate(key: title, htmlEscape: 'TRUE', default: title)}">{icon -> f:format.raw()}</span>
<span class="toolbar-item-title">{f:translate(key: title, htmlEscape: 'FALSE')}</span>
\ No newline at end of file
......@@ -5,7 +5,7 @@
<div class="dropdown-table">
<f:for each="{cacheActions}" as="cacheAction">
<div class="dropdown-table-row">
<f:link.typolink parameter="{cacheAction.href}">
<f:link.typolink parameter="{cacheAction.href}" class="toolbar-cache-flush-action">
<div class="dropdown-table-column dropdown-table-column-top dropdown-table-icon">
{cacheAction.icon -> f:format.raw()}
</div>
......
<f:link.typolink parameter="{link}" class="toolbar-cache-flush-action toolbar-item-link" title="{title}">
<f:render partial="ToolbarItem" arguments="{title: title, icon: icon}"/>
</f:link.typolink>
......@@ -27,7 +27,7 @@ define(['jquery', 'TYPO3/CMS/Backend/Icons', 'TYPO3/CMS/Backend/Notification'],
var ClearCacheMenu = {
options: {
containerSelector: '#typo3-cms-backend-backend-toolbaritems-clearcachetoolbaritem',
menuItemSelector: '.dropdown-menu a',
menuItemSelector: 'a.toolbar-cache-flush-action',
toolbarIconSelector: '.toolbar-item-icon .t3js-icon',
}
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment