summaryrefslogtreecommitdiffstats
path: root/library/Director/Web/ActionBar/AutomationObjectActionBar.php
blob: 247677fd063c69ae75bf850c59d5017cc4b376d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php

namespace Icinga\Module\Director\Web\ActionBar;

use gipfl\IcingaWeb2\Link;
use gipfl\Translation\TranslationHelper;
use gipfl\IcingaWeb2\Widget\ActionBar;
use Icinga\Web\Request;

class AutomationObjectActionBar extends ActionBar
{
    use TranslationHelper;

    /** @var Request */
    protected $request;

    protected $label;

    public function __construct(Request $request)
    {
        $this->request = $request;
    }

    protected function assemble()
    {
        $request = $this->request;
        $action = $request->getActionName();
        $controller = $request->getControllerName();
        $params = ['id' => $request->getParam('id')];
        $links = [
            'index' => Link::create(
                $this->translate('Overview'),
                "director/$controller",
                $params,
                ['class' => 'icon-info']
            ),
            'edit' => Link::create(
                $this->translate('Modify'),
                "director/$controller/edit",
                $params,
                ['class' => 'icon-edit']
            ),
            'clone' => Link::create(
                $this->translate('Clone'),
                "director/$controller/clone",
                $params,
                ['class' => 'icon-paste']
            ),
            /*
            // TODO: enable once handled in the controller
            'export' => Link::create(
                $this->translate('Download JSON'),
                $this->request->getUrl()->with('format', 'json'),
                null,
                [
                    'data-base-target' => '_blank',
                ]
            )
            */

        ];
        unset($links[$action]);
        $this->add($links);
    }
}