feat: add profile selector to backup records view
Generic: Repo Health / Access control (push) Has been cancelled
Generic: Repo Health / Site Health (push) Has been cancelled
Generic: Repo Health / Release configuration (push) Has been cancelled
Generic: Repo Health / Scripts governance (push) Has been cancelled
Generic: Repo Health / Repository health (push) Has been cancelled
Generic: Repo Health / Report Issues (push) Has been cancelled

The Backup Now button was hardcoded to profile 1. Now the backups
view shows a profile dropdown with all published profiles, displaying
name and type (full/database/files). The selected profile is passed
to the stepped backup engine.

Authored-by: Moko Consulting
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jonathan Miller
2026-06-02 15:40:03 -05:00
parent 8a2a6bf067
commit 40402bb6a0
3 changed files with 42 additions and 1 deletions
@@ -145,6 +145,9 @@ COM_MOKOBACKUP_FIELDSET_REMOTE="Remote Storage"
COM_MOKOBACKUP_FIELDSET_FTP="FTP Settings"
COM_MOKOBACKUP_FIELDSET_GDRIVE="Google Drive Settings"
; Backup profile selector
COM_MOKOBACKUP_BACKUP_PROFILE="Backup Profile"
; Restore
COM_MOKOBACKUP_TOOLBAR_RESTORE="Restore"
COM_MOKOBACKUP_RESTORE_CONFIRM="WARNING: Restoring will overwrite your current site files and/or database. Are you sure you want to continue?"
@@ -12,6 +12,7 @@ namespace Joomla\Component\MokoBackup\Administrator\View\Backups;
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Toolbar\ToolbarHelper;
@@ -23,6 +24,7 @@ class HtmlView extends BaseHtmlView
protected $state;
public $filterForm;
public $activeFilters = [];
public $profiles = [];
public function display($tpl = null): void
{
@@ -32,6 +34,16 @@ class HtmlView extends BaseHtmlView
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');
// Load published profiles for the backup selector
$db = Factory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName(['id', 'title', 'backup_type']))
->from($db->quoteName('#__mokobackup_profiles'))
->where($db->quoteName('published') . ' = 1')
->order($db->quoteName('ordering') . ' ASC');
$db->setQuery($query);
$this->profiles = $db->loadObjectList() ?: [];
$this->addToolbar();
parent::display($tpl);
@@ -28,6 +28,29 @@ $listDirn = $this->escape($this->state->get('list.direction'));
<div class="row">
<div class="col-md-12">
<div id="j-main-container" class="j-main-container">
<!-- Profile selector for Backup Now -->
<?php if (!empty($this->profiles)) : ?>
<div class="card mb-3">
<div class="card-body d-flex align-items-center gap-3">
<label for="mb-profile-select" class="form-label mb-0 fw-bold">
<?php echo Text::_('COM_MOKOBACKUP_BACKUP_PROFILE'); ?>:
</label>
<select id="mb-profile-select" class="form-select" style="max-width:300px;">
<?php foreach ($this->profiles as $profile) : ?>
<option value="<?php echo (int) $profile->id; ?>">
<?php echo $this->escape($profile->title); ?>
(<?php echo $this->escape($profile->backup_type); ?>)
</option>
<?php endforeach; ?>
</select>
<button type="button" class="btn btn-primary" onclick="window.mokobackupStart()">
<span class="icon-download" aria-hidden="true"></span>
<?php echo Text::_('COM_MOKOBACKUP_TOOLBAR_BACKUP_NOW'); ?>
</button>
</div>
</div>
<?php endif; ?>
<?php echo LayoutHelper::render('joomla.searchtools.default', ['view' => $this]); ?>
<?php if (empty($this->items)) : ?>
@@ -196,6 +219,9 @@ $listDirn = $this->escape($this->state->get('list.direction'));
}
async function startSteppedBackup() {
const profileSelect = document.getElementById('mb-profile-select');
const profileId = profileSelect ? profileSelect.value : '1';
showModal();
updateProgress(0, 'Initializing backup...', 'init');
@@ -203,7 +229,7 @@ $listDirn = $this->escape($this->state->get('list.direction'));
// Init
const initResult = await postAjax({
task: 'ajax.init',
profile_id: '1'
profile_id: profileId
});
if (initResult.error) {