Completed
Push — master ( ac44f9...7d4d5b )
by Klochok
05:18
created

IpDetailMenu::items()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 33
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 33
ccs 0
cts 24
cp 0
rs 8.8571
cc 1
eloc 22
nc 1
nop 0
crap 2
1
<?php
2
3
namespace hipanel\modules\hosting\menus;
4
5
use hipanel\widgets\ModalButton;
6
use hiqdev\menumanager\Menu;
7
use Yii;
8
use yii\helpers\Html;
9
10
class IpDetailMenu extends Menu
11
{
12
    public $model;
13
14
    public function items()
15
    {
16
        $actions = IpActionsMenu::create(['model' => $this->model])->items();
17
        $items = array_merge($actions, [
18
            [
19
                'label' => ModalButton::widget([
20
                    'model' => $this->model,
21
                    'scenario' => 'delete',
22
                    'button' => [
23
                        'label' => '<i class="fa fa-fw fa-trash-o"></i> ' . Yii::t('hipanel', 'Delete'),
24
                    ],
25
                    'modal' => [
26
                        'header' => Html::tag('h4', Yii::t('hipanel:hosting', 'Confirm IP address deleting')),
27
                        'headerOptions' => ['class' => 'label-danger'],
28
                        'footer' => [
29
                            'label' => Yii::t('hipanel:hosting', 'Delete IP address'),
30
                            'data-loading-text' => Yii::t('hipanel:hosting', 'Deleting IP address...'),
31
                            'class' => 'btn btn-danger',
32
                        ]
33
                    ],
34
                    'body' => Yii::t('hipanel:hosting',
35
                        'Are you sure, that you want to delete IP address {ip}? All related objects might be deleted too!',
36
                        ['ip' => Html::tag('b', $this->model->ip)]
37
                    )
38
                ]),
39
                'encode' => false,
40
                'visible' => Yii::$app->user->can('admin'),
41
            ],
42
        ]);
43
        unset($items['view']);
44
45
        return $items;
46
    }
47
}
48