mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-29 08:44:10 +02:00
migrations/index: Let the migrate all button submit the migration form
This commit is contained in:
parent
8a1c224461
commit
4a8d171aec
@ -14,6 +14,7 @@ use Icinga\Web\Notification;
|
|||||||
use Icinga\Web\Widget\ItemList\MigrationList;
|
use Icinga\Web\Widget\ItemList\MigrationList;
|
||||||
use Icinga\Web\Widget\Tabextension\OutputFormat;
|
use Icinga\Web\Widget\Tabextension\OutputFormat;
|
||||||
use ipl\Html\Attributes;
|
use ipl\Html\Attributes;
|
||||||
|
use ipl\Html\FormElement\SubmitButtonElement;
|
||||||
use ipl\Html\HtmlElement;
|
use ipl\Html\HtmlElement;
|
||||||
use ipl\Html\Text;
|
use ipl\Html\Text;
|
||||||
use ipl\Web\Compat\CompatController;
|
use ipl\Web\Compat\CompatController;
|
||||||
@ -53,22 +54,25 @@ class MigrationsController extends CompatController
|
|||||||
}
|
}
|
||||||
|
|
||||||
$migrateListForm = new MigrationForm();
|
$migrateListForm = new MigrationForm();
|
||||||
|
$migrateListForm->setAttribute('id', $this->getRequest()->protectId('migration-form'));
|
||||||
$migrateListForm->setRenderDatabaseUserChange(! $mm->validateDatabasePrivileges());
|
$migrateListForm->setRenderDatabaseUserChange(! $mm->validateDatabasePrivileges());
|
||||||
|
|
||||||
$migrateGlobalForm = new MigrationForm();
|
|
||||||
$migrateGlobalForm->getAttributes()->set('name', sprintf('migrate-%s', DbMigrationHook::ALL_MIGRATIONS));
|
|
||||||
|
|
||||||
if ($canApply && $mm->hasPendingMigrations()) {
|
if ($canApply && $mm->hasPendingMigrations()) {
|
||||||
$migrateGlobalForm->addElement('submit', sprintf('migrate-%s', DbMigrationHook::ALL_MIGRATIONS), [
|
$migrateAllButton = new SubmitButtonElement(sprintf('migrate-%s', DbMigrationHook::ALL_MIGRATIONS), [
|
||||||
'required' => true,
|
'form' => $migrateListForm->getAttribute('id')->getValue(),
|
||||||
'label' => $this->translate('Migrate All'),
|
'label' => $this->translate('Migrate All'),
|
||||||
'title' => $this->translate('Migrate all pending migrations')
|
'title' => $this->translate('Migrate all pending migrations')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->controls->getAttributes()->add('class', 'default-layout');
|
// Is the first button, so will be cloned and that the visible
|
||||||
$this->handleMigrateRequest($migrateGlobalForm);
|
// button is outside the form doesn't matter for Web's JS
|
||||||
|
$migrateListForm->registerElement($migrateAllButton);
|
||||||
|
|
||||||
$this->addControl($migrateGlobalForm);
|
// Make sure it looks familiar, even if not inside a form
|
||||||
|
$migrateAllButton->setWrapper(new HtmlElement('div', Attributes::create(['class' => 'icinga-controls'])));
|
||||||
|
|
||||||
|
$this->controls->getAttributes()->add('class', 'default-layout');
|
||||||
|
$this->addControl($migrateAllButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->handleFormatRequest($mm->toArray());
|
$this->handleFormatRequest($mm->toArray());
|
||||||
|
@ -6,7 +6,6 @@ namespace Icinga\Forms;
|
|||||||
|
|
||||||
use Icinga\Application\MigrationManager;
|
use Icinga\Application\MigrationManager;
|
||||||
use ipl\Html\Attributes;
|
use ipl\Html\Attributes;
|
||||||
use ipl\Html\Form;
|
|
||||||
use ipl\Html\FormElement\CheckboxElement;
|
use ipl\Html\FormElement\CheckboxElement;
|
||||||
use ipl\Html\FormElement\FieldsetElement;
|
use ipl\Html\FormElement\FieldsetElement;
|
||||||
use ipl\Html\HtmlElement;
|
use ipl\Html\HtmlElement;
|
||||||
@ -15,10 +14,11 @@ use ipl\I18n\Translation;
|
|||||||
use ipl\Validator\CallbackValidator;
|
use ipl\Validator\CallbackValidator;
|
||||||
use ipl\Web\Common\CsrfCounterMeasure;
|
use ipl\Web\Common\CsrfCounterMeasure;
|
||||||
use ipl\Web\Common\FormUid;
|
use ipl\Web\Common\FormUid;
|
||||||
|
use ipl\Web\Compat\CompatForm;
|
||||||
use ipl\Web\FormDecorator\IcingaFormDecorator;
|
use ipl\Web\FormDecorator\IcingaFormDecorator;
|
||||||
use PDOException;
|
use PDOException;
|
||||||
|
|
||||||
class MigrationForm extends Form
|
class MigrationForm extends CompatForm
|
||||||
{
|
{
|
||||||
use CsrfCounterMeasure;
|
use CsrfCounterMeasure;
|
||||||
use FormUid;
|
use FormUid;
|
||||||
@ -50,6 +50,12 @@ class MigrationForm extends Form
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function hasDefaultElementDecorator()
|
||||||
|
{
|
||||||
|
// The base implementation registers a decorator we don't want here
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
protected function assemble(): void
|
protected function assemble(): void
|
||||||
{
|
{
|
||||||
$this->addHtml($this->createUidElement());
|
$this->addHtml($this->createUidElement());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user