User tests: Successful: Unsuccessful:
As an partial alternative to #33165
Adds a button to the sample data module which leads to the plugin manager. Sampledata plugins will be prefiltered.
This certainly needs improvement on the design aspect (where I suck badly). So if anyone has an idea how this can be improved I'm open to suggestions or PRs :-)
Just use the button
None
Status | New | ⇒ | Pending |
Category | ⇒ | Administration Language & Strings Modules |
Why not select
Unpublish
under the cog icon or addManage
to it if it is possible?
Because that cog icon comes from the module chrome (not from the module itself). To my knowledge the module can't manipulate this part.
Labels |
Added:
?
?
|
I have tested this item
about the design: removing bottom border, as shown here #33106 and maybe .float-end margin? to hv alignment with the other (Install)
A button to directly edit (or unpublish) the sample data plugin isn't possible easy because we don't know the ID of the plugin.
That would require changes in each sample data plugins onSampledataGetOverview method.
It can certainly be done, but has much more impact.
We need to fetch the db. here is the modified file
<?php
/**
* @package Joomla.Administrator
* @subpackage mod_sampledata
*
* @copyright (C) 2017 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\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Session\Session;
use Joomla\CMS\Uri\Uri;
$app->getDocument()->getWebAssetManager()
->registerAndUseScript('mod_sampledata', 'mod_sampledata/sampledata-process.js', [], ['defer' => true], ['core']);
Text::script('MOD_SAMPLEDATA_CONFIRM_START');
Text::script('MOD_SAMPLEDATA_ITEM_ALREADY_PROCESSED');
Text::script('MOD_SAMPLEDATA_INVALID_RESPONSE');
$app->getDocument()->addScriptOptions(
'sample-data',
[
'icon' => Uri::root(true) . '/media/system/images/ajax-loader.gif'
]
);
?>
<?php if ($items) : ?>
<ul id="sample-data-wrapper" class="list-group list-group-flush">
<?php foreach($items as $i => $item) : ?>
<?php
$db = Factory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('extension_id'))
->from($db->quoteName('#__extensions'))
->where(
[
$db->quoteName('folder') . ' = ' . $db->quote('sampledata'),
$db->quoteName('type') . ' = ' . $db->quote('plugin'),
$db->quoteName('element') . ' = ' . $db->quote($item->name),
]
);
$db->setQuery($query);
$id = $db->loadResult();
$loadUrl = 'index.php?option=com_plugins&view=plugin&task=plugin.edit&extension_id=' . $id . '&' . Session::getFormToken() . '=1';
?>
<li class="list-group-item sampledata-<?php echo $item->name; ?>">
<div class="d-flex justify-content-between align-items-center">
<div class="me-2">
<span class="icon-<?php echo $item->icon; ?>" aria-hidden="true"></span>
<?php echo htmlspecialchars($item->title, ENT_QUOTES, 'UTF-8'); ?>
</div>
<div class="btn-group">
<button type="button" class="btn btn-secondary btn-sm apply-sample-data" data-type="<?php echo $item->name; ?>" data-steps="<?php echo $item->steps; ?>">
<span class="icon-upload" aria-hidden="true"></span> <?php echo Text::_('JLIB_INSTALLER_INSTALL'); ?>
<span class="visually-hidden"><?php echo $item->title; ?></span>
</button>
<button type=button" class="btn btn-danger btn-sm manage-sample-data" onclick="location.href='<?php echo Route::_($loadUrl); ?>'">
<span class="icon-tasks" aria-hidden="true"></span> <?php echo Text::_('JACTION_EDIT'); ?>
<span class="visually-hidden"><?php echo Text::_('JACTION_EDIT'); ?></span>
</button>
</div>
</div>
<p class="small mt-1"><?php echo $item->description; ?></p>
<?php // Progress bar ?>
<div class="sampledata-progress-<?php echo $item->name; ?> d-none mb-3">
<div class="progress">
<div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar"></div>
</div>
</div>
<?php // Progress messages ?>
<div class="sampledata-progress-<?php echo $item->name; ?> d-none">
<ul class="list-unstyled"></ul>
</div>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
Fetching the DB is a no-go in my eyes. Also technically "name" doesn't necessary have to be the name of the plugin. It could be anything. It just happens to be the same name for the core plugins.
So if we want to have a direct button, we need to adjust the overview method so the plugin returns its own ID.
I have tested this item
@Bakual solution is straight forward and elegant. Only feedback is whether the button string should be "Manage Sample Data Plugins"
@infograf768 though I get what you're trying to allow for there, the buttons indicating "Edit" are misleading IMO... you're not "Editing" the sample data, you're managing the availability of the plugin.
Regarding the name of the button, I think "Manage Sample Data Plugins" gets to long. Maybe @brianteeman has a better idea for the text (I'm no no native english speaker).
Title |
|
Buttons:
You don't have e.g: Install Sample Data, therefore there is no need for: Manage Sample Data :-)
In short:
Install
Manage
I have tested this item
I have tested this item
Tested after code clean up and button name change. All works.
I have tested this item
Status | Pending | ⇒ | Ready to Commit |
RTC
Status | Ready to Commit | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2021-04-19 06:20:35 |
Closed_By | ⇒ | rdeutz | |
Labels |
Added:
?
|
Why not select
Unpublish
under the cog icon or addManage
to it if it is possible?