Skip to content

Commit

Permalink
[4] Blank State for com_cache (#33325)
Browse files Browse the repository at this point in the history
* add com_cache blank slate

* Dont display toolbar if no cache items

* Add blank state language strings

* namespace \count function calls

* /s/you/if

* Update administrator/components/com_cache/tmpl/cache/blankstate.php

Co-authored-by: Brian Teeman <brian@teeman.net>

* Update administrator/components/com_cache/tmpl/cache/blankstate.php

Co-authored-by: Brian Teeman <brian@teeman.net>

* Update administrator/language/en-GB/com_cache.ini

Co-authored-by: Brian Teeman <brian@teeman.net>

* Add icon

Signed-off-by: Phil E. Taylor <phil@phil-taylor.com>

* a-z lang strings

Signed-off-by: Phil E. Taylor <phil@phil-taylor.com>

* s/blankslate/emptystate

* Short array syntax

* Update administrator/language/en-GB/com_cache.ini

Co-authored-by: Brian Teeman <brian@teeman.net>

Co-authored-by: Brian Teeman <brian@teeman.net>
Co-authored-by: Quy <quy@fluxbb.org>
  • Loading branch information
3 people authored Apr 30, 2021
1 parent 9632877 commit 30aa741
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
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')))
{
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 = [
'textPrefix' => 'COM_CACHE',
'helpURL' => 'https://docs.joomla.org/Special:MyLanguage/Cache',
'icon' => 'icon-bolt clear',
];

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"
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 be displayed here."
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

0 comments on commit 30aa741

Please sign in to comment.