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

[4] Blank State for com_cache #33325

Merged
merged 13 commits into from
Apr 30, 2021
18 changes: 13 additions & 5 deletions administrator/components/com_cache/src/View/Cache/HtmlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,16 @@ public function display($tpl = null): void
$this->activeFilters = $model->getActiveFilters();

// Check for errors.
if (count($errors = $this->get('Errors')))
if (\count($errors = $this->get('Errors')))
PhilETaylor marked this conversation as resolved.
Show resolved Hide resolved
{
throw new GenericDataException(implode("\n", $errors), 500);
}

if (!\count($this->data))
{
$this->setLayout('emptystate');
}

$this->addToolbar();

parent::display($tpl);
Expand All @@ -125,10 +130,13 @@ protected function addToolbar(): void
// Get the toolbar object instance
$toolbar = Toolbar::getInstance('toolbar');

ToolbarHelper::custom('delete', 'delete', '', 'JTOOLBAR_DELETE', true);
ToolbarHelper::custom('deleteAll', 'remove', '', 'JTOOLBAR_DELETE_ALL', false);
$toolbar->appendButton('Confirm', 'COM_CACHE_RESOURCE_INTENSIVE_WARNING', 'delete', 'COM_CACHE_PURGE_EXPIRED', 'purge', false);
ToolbarHelper::divider();
if (\count($this->data))
{
ToolbarHelper::custom('delete', 'delete', '', 'JTOOLBAR_DELETE', true);
ToolbarHelper::custom('deleteAll', 'remove', '', 'JTOOLBAR_DELETE_ALL', false);
$toolbar->appendButton('Confirm', 'COM_CACHE_RESOURCE_INTENSIVE_WARNING', 'delete', 'COM_CACHE_PURGE_EXPIRED', 'purge', false);
ToolbarHelper::divider();
}

if (Factory::getUser()->authorise('core.admin', 'com_cache'))
{
Expand Down
20 changes: 20 additions & 0 deletions administrator/components/com_cache/tmpl/cache/emptystate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_cache
*
* @copyright (C) 2021 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;

use Joomla\CMS\Layout\LayoutHelper;

$displayData = array(
'textPrefix' => 'COM_CACHE',
'helpURL' => 'https://docs.joomla.org/Special:MyLanguage/Cache',
'icon' => 'icon-bolt clear',
);
Quy marked this conversation as resolved.
Show resolved Hide resolved

echo LayoutHelper::render('joomla.content.emptystate', $displayData);
2 changes: 2 additions & 0 deletions administrator/language/en-GB/com_cache.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
COM_CACHE="Cache"
PhilETaylor marked this conversation as resolved.
Show resolved Hide resolved
COM_CACHE_CLEAR_CACHE="Maintenance: Clear Cache"
COM_CACHE_CONFIGURATION="Cache: Options"
COM_CACHE_EMPTYSTATE_CONTENT="If you enable caching in Joomla Global Configuration, then any cached items will display here as they are generated."
PhilETaylor marked this conversation as resolved.
Show resolved Hide resolved
COM_CACHE_EMPTYSTATE_TITLE="You have no cached content."
COM_CACHE_ERROR_CACHE_CONNECTION_FAILED="Could not connect to the cache store to fetch the cache data."
COM_CACHE_ERROR_CACHE_DRIVER_UNSUPPORTED="Could not read the cache data, the configured cache handler is not supported by this environment."
COM_CACHE_EXPIRED_ITEMS_DELETE_ERROR="Error clearing cache group(s): %s."
Expand Down