Skip to content

Commit

Permalink
added DomainDetailsMenu
Browse files Browse the repository at this point in the history
  • Loading branch information
hiqsol committed Nov 18, 2016
1 parent 451ed56 commit a9e087a
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 47 deletions.
10 changes: 10 additions & 0 deletions src/menus/DomainActionsMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,17 @@ class DomainActionsMenu extends \hiqdev\menumanager\Menu

public function items()
{
$url = 'http://' . $this->model->domain . '/';

return [
[
'icon' => 'globe',
'label' => Yii::t('hipanel:domain', 'Go to site {link}', ['link' => \yii\helpers\StringHelper::truncate($url, 15)]),
'url' => $url,
'linkOptions' => [
'target' => '_blank',
],
],
[
'label' => '<i class="fa fa-fw fa-info"></i> ' . Yii::t('hipanel', 'View'),
'url' => ['@domain/view', 'id' => $this->model->id],
Expand Down
60 changes: 60 additions & 0 deletions src/menus/DomainDetailsMenu.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

namespace hipanel\modules\domain\menus;

use hipanel\modules\domain\models\Domain;
use hipanel\widgets\AjaxModal;
use Yii;
use yii\bootstrap\Modal;
use yii\helpers\Html;

class DomainDetailsMenu extends \hiqdev\menumanager\Menu
{
public $model;

public function items()
{
$actions = DomainActionsMenu::create([
'model' => $this->model,
])->items();

return array_merge($actions, [
[
'label' => AjaxModal::widget([
'id' => 'push-modal-link',
'header' => Html::tag('h4', Yii::t('hipanel:domain', 'Push domain') . ': ' . Html::tag('b', $this->title), ['class' => 'modal-title']),
'scenario' => 'push',
'actionUrl' => ['domain-push-modal', 'id' => $this->model->id],
'size' => Modal::SIZE_DEFAULT,
'toggleButton' => [
'label' => '<i class="fa fa-fw fa-paper-plane-o"></i>' . Yii::t('hipanel:domain', 'Push domain'),
'class' => 'clickable',
'data-pjax' => 0,
'tag' => 'a',
],
]),
'encode' => false,
],
[
'visible' => $this->model->canRenew() && Yii::$app->user->can('domain.pay'),
'label' => Yii::t('hipanel:domain', 'Renew domain'),
'icon' => 'forward',
'url' => ['add-to-cart-renewal', 'model_id' => $this->model->id],
'linkOptions' => [
'data-pjax' => 0,
],
],
[
'label' => Yii::t('hipanel', 'Delete'),
'url' => ['@domain/delete', 'id' => $this->model->id],
'linkOptions' => [
'data' => [
'confirm' => Yii::t('hipanel:domain', 'Are you sure you want to delete domain {domain}?', ['domain' => $this->model->domain]),
'method' => 'post',
'data-pjax' => '0',
]
],
],
]);
}
}
49 changes: 2 additions & 47 deletions src/views/domain/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@

use hipanel\modules\dns\widgets\DnsZoneEditWidget;
use hipanel\modules\domain\grid\DomainGridView;
use hipanel\modules\domain\menus\DomainActionsMenu;
use hipanel\modules\domain\menus\DomainDetailsMenu;
use hipanel\widgets\DetailMenu;
use hipanel\modules\domain\widgets\AuthCode;
use hipanel\modules\domain\widgets\NsWidget;
use hipanel\widgets\AjaxModal;
use hipanel\widgets\Box;
use hipanel\widgets\ClientSellerLink;
use hipanel\widgets\Pjax;
use hiqdev\bootstrap_switch\BootstrapSwitchColumn;
use yii\bootstrap\Modal;
use yii\data\ArrayDataProvider;
use yii\helpers\Html;
use yii\helpers\Url;
Expand Down Expand Up @@ -52,7 +50,6 @@
<div class="row" xmlns="http://www.w3.org/1999/html">

<div class="col-md-3">

<?php Box::begin([
'options' => [
'class' => 'box-solid',
Expand All @@ -71,49 +68,7 @@
</p>

<div class="profile-usermenu">
<?= DomainActionsMenu::create(['model' => $model])->render(DetailMenu::class) ?>
<ul class="nav">
<li>
<?php $url = 'http://' . $model->domain . '/' ?>
<?= Html::a('<i class="fa fa-fw fa-globe"></i>' . Yii::t('hipanel:domain', 'Go to site {link}', [
'link' => \yii\helpers\StringHelper::truncate($url, 15)
]), $url, ['target' => '_blank']); ?>
</li>
<li>
<?= AjaxModal::widget([
'id' => 'push-modal-link',
'header' => Html::tag('h4', Yii::t('hipanel:domain', 'Push domain') . ': ' . Html::tag('b', $this->title), ['class' => 'modal-title']),
'scenario' => 'push',
'actionUrl' => ['domain-push-modal', 'id' => $model->id],
'size' => Modal::SIZE_DEFAULT,
'toggleButton' => [
'label' => '<i class="fa fa-fw fa-paper-plane-o"></i>' . Yii::t('hipanel:domain', 'Push domain'),
'class' => 'clickable',
'data-pjax' => 0,
'tag' => 'a',
],
]) ?>
</li>
<?php if ($model->canRenew() && Yii::$app->user->can('deposit')) : ?>
<li>
<?= Html::a('<i class="fa fa-fw fa-forward"></i>' . Yii::t('hipanel:domain', 'Renew domain'), ['add-to-cart-renewal', 'model_id' => $model->id], ['data-pjax' => 0]) ?>
</li>
<?php endif ?>
<?= $this->render('_holdButtons', compact('model')) ?>
<li>
<?= Html::a('<i class="fa fa-fw fa-trash"></i>' . Yii::t('hipanel', 'Delete'), ['@domain/delete', 'id' => $model->id], [
'data' => [
'confirm' => Yii::t('hipanel:domain', 'Are you sure you want to delete domain {domain}?', ['domain' => $model->domain]),
'method' => 'post',
'data-pjax' => '0',
]
]) ?>
</li>
<?php if (Yii::$app->user->can('support') && Yii::$app->user->not($model->client_id)) : ?>
<li><?= $this->render('_syncButton', compact('model')) ?></li>
<?php endif ?>
<?= $this->render('_freezeButtons', compact('model')) ?>
</ul>
<?= DomainDetailsMenu::create(['model' => $model])->render(DetailMenu::class) ?>
</div>
<?php Box::end() ?>
</div>
Expand Down

0 comments on commit a9e087a

Please sign in to comment.