Don't render migrate button in detailed file list view

This commit is contained in:
Yonas Habteab 2023-09-15 12:48:23 +02:00 committed by Johannes Meyer
parent 501ab81416
commit 99e8a2322d
1 changed files with 7 additions and 25 deletions

View File

@ -4,7 +4,6 @@
namespace Icinga\Controllers; namespace Icinga\Controllers;
use Exception;
use Icinga\Application\Hook\DbMigrationHook; use Icinga\Application\Hook\DbMigrationHook;
use Icinga\Application\Icinga; use Icinga\Application\Icinga;
use Icinga\Application\MigrationManager; use Icinga\Application\MigrationManager;
@ -105,7 +104,10 @@ class MigrationsController extends CompatController
/** @var ?string $module */ /** @var ?string $module */
$module = $this->getRequest()->getParam(DbMigrationHook::MIGRATION_PARAM); $module = $this->getRequest()->getParam(DbMigrationHook::MIGRATION_PARAM);
if ($module === null) { if ($module === null) {
throw new MissingParameterException(t('Required parameter \'%s\' missing'), DbMigrationHook::MIGRATION_PARAM); throw new MissingParameterException(
$this->translate('Required parameter \'%s\' missing'),
DbMigrationHook::MIGRATION_PARAM
);
} }
$mm = MigrationManager::instance(); $mm = MigrationManager::instance();
@ -161,33 +163,11 @@ class MigrationsController extends CompatController
) )
); );
} else { } else {
$migrateForm = (new MigrationForm())
->addElement(
'submit',
sprintf('migrate-%s', $hook->getModuleName()),
[
'required' => true,
'label' => $this->translate('Migrate'),
'title' => sprintf(
$this->translatePlural(
'Migrate %d pending migration',
'Migrate all %d pending migrations',
$hook->count()
),
$hook->count()
)
]
);
$migrateForm->getAttributes()->add('class', 'inline');
$this->handleMigrateRequest($migrateForm);
$this->addControl( $this->addControl(
new HtmlElement( new HtmlElement(
'div', 'div',
Attributes::create(['class' => 'migration-controls']), Attributes::create(['class' => 'migration-controls']),
new HtmlElement('span', null, Text::create($hook->getName())), new HtmlElement('span', null, Text::create($hook->getName()))
$migrateForm
) )
); );
} }
@ -239,6 +219,8 @@ class MigrationsController extends CompatController
} }
} }
$this->sendExtraUpdates(['#col2' => '__CLOSE__']);
$this->redirectNow('migrations'); $this->redirectNow('migrations');
})->handleRequest($this->getServerRequest()); })->handleRequest($this->getServerRequest());
} }