? ? ? Pending

User tests: Successful: Unsuccessful:

avatar Bakual
Bakual
16 Apr 2021

As an partial alternative to #33165

Summary of Changes

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 :-)

Testing Instructions

Just use the button

Actual result BEFORE applying this Pull Request

image

Expected result AFTER applying this Pull Request

image

Buttons leads to
image

Documentation Changes Required

None

avatar Bakual Bakual - open - 16 Apr 2021
avatar Bakual Bakual - change - 16 Apr 2021
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 16 Apr 2021
Category Administration Language & Strings Modules
avatar Quy
Quy - comment - 16 Apr 2021

Why not select Unpublish under the cog icon or add Manage to it if it is possible?

avatar Bakual
Bakual - comment - 16 Apr 2021

Why not select Unpublish under the cog icon or add Manage 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.

avatar Bakual Bakual - change - 16 Apr 2021
Labels Added: ? ?
avatar ChristineWk ChristineWk - test_item - 16 Apr 2021 - Tested successfully
avatar ChristineWk
ChristineWk - comment - 16 Apr 2021

I have tested this item successfully on df52e89

about the design: removing bottom border, as shown here #33106 and maybe .float-end margin? to hv alignment with the other (Install)


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/33169.

avatar infograf768
infograf768 - comment - 17 Apr 2021

please solve conflicts as #33168 was merged

avatar infograf768
infograf768 - comment - 17 Apr 2021

I may have another solution to directly edit the plugin (color can be modified)

sampledata_plugins

avatar Bakual
Bakual - comment - 17 Apr 2021

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.

avatar infograf768
infograf768 - comment - 17 Apr 2021

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 . '&amp;' . 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; ?>
avatar Bakual
Bakual - comment - 17 Apr 2021

I've resolved the conflicts and added some margins to the button.
The border was already removed with a different PR elsewhere.

Looks now like this:
image

avatar Bakual
Bakual - comment - 17 Apr 2021

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.

avatar particthistle particthistle - test_item - 17 Apr 2021 - Tested successfully
avatar particthistle
particthistle - comment - 17 Apr 2021

I have tested this item successfully on 91c4cac

@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.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/33169.

avatar Bakual
Bakual - comment - 17 Apr 2021

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).

avatar Bakual Bakual - change - 17 Apr 2021
Title
[4.0] RFC Adding a manage button to the sample data module
[4.0] Adding a manage button to the sample data module
avatar Bakual Bakual - edited - 17 Apr 2021
avatar ChristineWk
ChristineWk - comment - 17 Apr 2021

Buttons:
You don't have e.g: Install Sample Data, therefore there is no need for: Manage Sample Data :-)
In short:
Install
Manage


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/33169.

avatar Bakual
Bakual - comment - 17 Apr 2021

Good point with the string, thanks! Change it.

image

avatar ChristineWk ChristineWk - test_item - 17 Apr 2021 - Tested successfully
avatar ChristineWk
ChristineWk - comment - 17 Apr 2021

I have tested this item successfully on 29274b6


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/33169.

avatar particthistle particthistle - test_item - 18 Apr 2021 - Tested successfully
avatar particthistle
particthistle - comment - 18 Apr 2021

I have tested this item successfully on ab2019e

Tested after code clean up and button name change. All works.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/33169.

avatar ChristineWk ChristineWk - test_item - 18 Apr 2021 - Tested successfully
avatar ChristineWk
ChristineWk - comment - 18 Apr 2021

I have tested this item successfully on ab2019e


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/33169.

avatar Quy Quy - change - 18 Apr 2021
Status Pending Ready to Commit
avatar Quy
Quy - comment - 18 Apr 2021

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/33169.

avatar rdeutz rdeutz - change - 19 Apr 2021
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: ?
avatar rdeutz rdeutz - close - 19 Apr 2021
avatar rdeutz rdeutz - merge - 19 Apr 2021

Add a Comment

Login with GitHub to post a comment