Issues (213)

src/menus/HubActionsMenu.php (1 issue)

1
<?php
2
/**
3
 * Server module for HiPanel
4
 *
5
 * @link      https://github.com/hiqdev/hipanel-module-server
6
 * @package   hipanel-module-server
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\modules\server\menus;
12
13
use hipanel\widgets\AjaxModalWithTemplatedButton;
14
use hiqdev\yii2\menus\Menu;
15
use yii\helpers\Html;
16
use Yii;
17
use yii\web\JsExpression;
18
19
class HubActionsMenu extends Menu
20
{
21
    public $model;
22
23
    public function items(): array
24
    {
25
        return [
26
            'view' => [
27
                'label' => Yii::t('hipanel', 'View'),
28
                'icon' => 'fa-info',
29
                'url' => ['@hub/view', 'id' => $this->model->id],
30
                'visible' => Yii::$app->user->can('hub.read'),
0 ignored issues
show
The method can() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

30
                'visible' => Yii::$app->user->/** @scrutinizer ignore-call */ can('hub.read'),

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
31
            ],
32
            [
33
                'label' => Yii::t('hipanel', 'Update'),
34
                'icon' => 'fa-pencil',
35
                'url' => ['@hub/update', 'id' => $this->model->id],
36
                'visible' => Yii::$app->user->can('hub.update'),
37
            ],
38
            [
39
                'label' => Yii::t('hipanel:server:hub', 'Options'),
40
                'icon' => 'fa-cogs',
41
                'url' => ['@hub/options', 'id' => $this->model->id],
42
                'visible' => Yii::$app->user->can('hub.update'),
43
            ],
44
            'assign-switches' => [
45
                'label' => Yii::t('hipanel:server', 'Switches'),
46
                'icon' => 'fa-plug',
47
                'url' => ['@hub/assign-switches', 'id' => $this->model->id],
48
                'linkOptions' => [
49
                    'data-pjax' => 0,
50
                ],
51
            ],
52
            'monitoring-settings' => [
53
                'label' => AjaxModalWithTemplatedButton::widget([
54
                    'ajaxModalOptions' => [
55
                        'id' => "monitoring-settings-modal-{$this->model->id}",
56
                        'bulkPage' => true,
57
                        'header' => Html::tag('h4', Yii::t('hipanel:server', 'Monitoring properties'), ['class' => 'modal-title']),
58
                        'scenario' => 'default',
59
                        'actionUrl' => ['monitoring-settings', 'id' => $this->model->id],
60
                        'handleSubmit' => ['monitoring-settings', 'id' => $this->model->id],
61
                        'toggleButton' => [
62
                            'tag' => 'a',
63
                            'label' => Html::tag('i', null, ['class' => 'fa fa-fw fa-area-chart']) . '&nbsp;' . Yii::t('hipanel:server', 'Monitoring properties'),
64
                            'style' => 'cursor: pointer;',
65
                            'onClick' => new JsExpression("$(this).parents('.menu-button').find('.popover').popover('hide');"),
66
                        ],
67
                    ],
68
                    'toggleButtonTemplate' => '{toggleButton}',
69
                ]),
70
                'encode' => false,
71
                'visible' => Yii::$app->user->can('server.manage-settings'),
72
            ],
73
        ];
74
    }
75
}
76