Skip to content

Commit

Permalink
Merge pull request #216 from Icinga/render-sni-tab-next-to-jobs-tab
Browse files Browse the repository at this point in the history
Render `SNI` config tab next to the `Jobs` tab
  • Loading branch information
yhabteab authored Oct 27, 2023
2 parents 9f59918 + 38a144a commit 1f15f2f
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 30 deletions.
6 changes: 6 additions & 0 deletions application/controllers/JobsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ class JobsController extends CompatController
public function indexAction()
{
$this->addTitleTab($this->translate('Jobs'));
$this->getTabs()->add('sni', [
'title' => $this->translate('Configure SNI'),
'label' => $this->translate('SNI'),
'url' => 'x509/sni',
'baseTarget' => '_main'
]);

$jobs = X509Job::on($this->getDb());
if ($this->hasPermission('config/x509')) {
Expand Down
29 changes: 24 additions & 5 deletions application/controllers/SniController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,34 @@
use Icinga\Exception\NotFoundError;
use Icinga\Module\X509\Forms\Config\SniConfigForm;
use Icinga\Module\X509\SniIniRepository;
use Icinga\Web\Controller;
use Icinga\Web\Url;
use ipl\Html\HtmlString;
use ipl\Web\Compat\CompatController;
use ipl\Web\Url;
use ipl\Web\Widget\ButtonLink;

class SniController extends Controller
class SniController extends CompatController
{
/**
* List all maps
*/
public function indexAction()
{
$this->view->tabs = $this->Module()->getConfigTabs()->activate('sni');
$this->getTabs()->add('jobs', [
'title' => $this->translate('Configure Jobs'),
'label' => $this->translate('Jobs'),
'url' => 'x509/jobs',
'baseTarget' => '_main'

]);
$this->addTitleTab($this->translate('SNI'));

$this->addControl(
(new ButtonLink($this->translate('New SNI Map'), Url::fromPath('x509/sni/new'), 'plus'))
->openInModal()
);
$this->controls->getAttributes()->add('class', 'default-layout');

$this->view->controls = $this->controls;

$repo = new SniIniRepository();

Expand All @@ -29,11 +46,13 @@ public function indexAction()
*/
public function newAction()
{
$this->addTitleTab($this->translate('New SNI Map'));

$form = $this->prepareForm()->add();

$form->handleRequest();

$this->renderForm($form, $this->translate('New SNI Map'));
$this->addContent(new HtmlString($form->render()));
}

/**
Expand Down
1 change: 0 additions & 1 deletion application/forms/Config/SniConfigForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ protected function createInsertElements(array $formData)
]
]);

$this->setTitle($this->translate('Create a New SNI Map'));
$this->setSubmitLabel($this->translate('Create'));
}

Expand Down
17 changes: 1 addition & 16 deletions application/views/scripts/sni/index.phtml
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
<div class="controls">
<?= /** @var \Icinga\Web\Widget\Tabs $tabs */ $tabs ?>
</div>
<?= $this->controls->render() ?>
<div class="content">
<div class="actions">
<?= $this->qlink(
$this->translate('Create a New SNI Map') ,
'x509/sni/new',
null,
[
'class' => 'button-link',
'data-base-target' => '_next',
'icon' => 'plus',
'title' => $this->translate('Create a New SNI Map')
]
) ?>
</div>
<?php /** @var \Icinga\Repository\RepositoryQuery $sni */ if (! $sni->hasResult()): ?>
<p><?= $this->escape($this->translate('No SNI maps configured yet.')) ?></p>
<?php else: ?>
Expand Down
10 changes: 2 additions & 8 deletions configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,14 @@
'priority' => 20
));

$section->add(N_('Jobs'), [
$section->add(N_('Configuration'), [
'url' => 'x509/jobs',
'priority' => 100,
'description' => $this->translate('Configure the scan jobs')
'description' => $this->translate('Configure the scan jobs and SNI map')
]);

$this->provideConfigTab('backend', array(
'title' => $this->translate('Configure the database backend'),
'label' => $this->translate('Backend'),
'url' => 'config/backend'
));

$this->provideConfigTab('sni', array(
'title' => $this->translate('Configure SNI'),
'label' => $this->translate('SNI'),
'url' => 'sni'
));

0 comments on commit 1f15f2f

Please sign in to comment.