Skip to content

Commit fc26b9d

Browse files
authored
Revert "Voyager ui refactor"
1 parent 45c31f1 commit fc26b9d

File tree

3 files changed

+44
-77
lines changed

3 files changed

+44
-77
lines changed

resources/views/browse.blade.php

Lines changed: 35 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
@section('page_header')
44
<h1 class="page-title">
55
<i class="voyager-hook"></i> Hooks
6-
<a class="btn btn-success refresh" href="{{ route('voyager.hooks.cache.refresh') }}">
7-
<i class="voyager-refresh"></i> Update cache
8-
</a>
6+
<div class="btn btn-success install">
7+
<i class="voyager-plus"></i> Add hook
8+
</div>
99
</h1>
1010
@stop
1111

@@ -46,25 +46,14 @@
4646
<?= ($hook->enabled ? '<i class="voyager-check"></i> ENABLED' : '<i class="voyager-x"></i> DISABLED') ?>
4747
</td>
4848
<td class="no-sort no-click">
49-
@if ($hook->installed)
50-
<a href="javascript:;" class="btn-sm btn-danger pull-right uninstall"
51-
data-id="{{ $hook->name }}" id="uninstall-{{ $hook->name }}">
52-
<i class="voyager-trash"></i> Uninstall
53-
</a>
54-
<a href="{{ route('voyager.hooks.'.($hook->enabled ? 'disable' : 'enable'), $hook->name) }}"
55-
class="btn-sm btn-{{ $hook->enabled ? 'danger' : 'primary' }} pull-right edit">
56-
<i class="voyager-edit"></i> {{ $hook->enabled ? 'Disable' : 'Enable' }}
57-
</a>
58-
@else
59-
<a href="{{ route('voyager.hooks.install', $hook->name) }}"
60-
class="btn-sm btn-primary pull-right install">
61-
<i class="voyager-plus"></i> Install
62-
</a>
63-
@endif
64-
49+
<div class="btn-sm btn-danger pull-right delete" data-id="{{ $hook->name }}" id="delete-{{ $hook->name }}">
50+
<i class="voyager-trash"></i> Uninstall
51+
</div>
52+
<a href="{{ route('voyager.hooks.'.($hook->enabled ? 'disable' : 'enable'), $hook->name) }}" class="btn-sm btn-primary pull-right edit">
53+
<i class="voyager-edit"></i> {{ $hook->enabled ? 'Disable' : 'Enable' }}
54+
</a>
6555
@if ($hook->hasUpdateAvailable())
66-
<a href="{{ route('voyager.hooks.update', $hook->name) }}"
67-
class="btn-sm btn-warning pull-right update">
56+
<a href="{{ route('voyager.hooks.update', $hook->name) }}" class="btn-sm btn-warning pull-right update">
6857
<i class="voyager-edit"></i> Update
6958
</a>
7059
@endif
@@ -79,23 +68,21 @@ class="btn-sm btn-warning pull-right update">
7968
</div>
8069
</div>
8170

82-
<div class="modal modal-danger fade" tabindex="-1" id="uninstall_modal" role="dialog">
71+
<div class="modal modal-danger fade" tabindex="-1" id="delete_modal" role="dialog">
8372
<div class="modal-dialog">
8473
<div class="modal-content">
8574
<div class="modal-header">
8675
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
8776
aria-hidden="true">&times;</span></button>
88-
<h4 class="modal-title">
89-
<i class="voyager-trash"></i>
90-
Are you sure you want to uninstall this hook?
91-
</h4>
77+
<h4 class="modal-title"><i class="voyager-trash"></i> Are you sure you want to uninstall
78+
this hook?</h4>
9279
</div>
9380
<div class="modal-footer">
94-
<form action="{{ route('voyager.hooks') }}" id="uninstall_form" method="POST">
81+
<form action="{{ route('voyager.hooks') }}" id="delete_form" method="POST">
9582
{{ method_field("DELETE") }}
9683
{{ csrf_field() }}
97-
<input type="submit" class="btn btn-danger pull-right uninstall-confirm"
98-
value="Yes, Uninstall This Hook">
84+
<input type="submit" class="btn btn-danger pull-right delete-confirm"
85+
value="Yes, Delete This Hook">
9986
</form>
10087
<button type="button" class="btn btn-default pull-right" data-dismiss="modal">Cancel</button>
10188
</div>
@@ -105,16 +92,25 @@ class="btn-sm btn-warning pull-right update">
10592

10693
<div class="modal modal-success fade" tabindex="-1" id="install_modal" role="dialog">
10794
<div class="modal-dialog">
108-
<div class="modal-content">
95+
<form class="modal-content" action="{{ route('voyager.hooks') }}" id="install_form" method="POST">
10996
<div class="modal-header">
11097
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
11198
aria-hidden="true">&times;</span></button>
112-
<h4 class="modal-title"><i class="voyager-plus"></i> Installing hook</h4>
99+
<h4 class="modal-title"><i class="voyager-plus"></i>Install new hook.</h4>
113100
</div>
114101
<div class="modal-body">
115-
<p>Please be patience, installation in process...</p>
102+
<div class="form-group">
103+
<label for="name">Name</label>
104+
<input type="text" name="name" class="form-control" id="name" placeholder="Name of hook">
105+
</div>
116106
</div>
117-
</div><!-- /.modal-content -->
107+
<div class="modal-footer">
108+
{{ csrf_field() }}
109+
<input type="submit" class="btn btn-success pull-right install-confirm"
110+
value="Install">
111+
<button type="button" class="btn btn-default pull-right" data-dismiss="modal">Cancel</button>
112+
</div>
113+
</form><!-- /.modal-content -->
118114
</div><!-- /.modal-dialog -->
119115
</div><!-- /.modal -->
120116
@stop
@@ -126,22 +122,18 @@ class="btn-sm btn-warning pull-right update">
126122
$('#dataTable').DataTable({ "order": [] });
127123
});
128124
129-
/**
130-
* Install Hook
131-
*/
132-
$('td').on('click', '.install', function (e) {
125+
$('.page-title').on('click', '.install', function (e) {
126+
var form = $('#install_form')[0];
127+
133128
$('#install_modal').modal('show');
134129
});
135130
136-
/**
137-
* Install Hook
138-
*/
139-
$('td').on('click', '.uninstall', function (e) {
140-
var form = $('#uninstall_form')[0];
131+
$('td').on('click', '.delete', function (e) {
132+
var form = $('#delete_form')[0];
141133
142134
form.action = parseActionUrl(form.action, $(this).data('id'));
143135
144-
$('#uninstall_modal').modal('show');
136+
$('#delete_modal').modal('show');
145137
});
146138
147139
function parseActionUrl(action, id) {

src/Controllers/HooksController.php

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Larapack\VoyagerHooks\Controllers;
44

55
use Carbon\Carbon;
6+
use Illuminate\Http\Request;
67
use Illuminate\Routing\Controller;
78
use Larapack\Hooks\Hooks;
89

@@ -31,63 +32,38 @@ public function index()
3132
]);
3233
}
3334

34-
public function install($name)
35+
public function install(Request $request)
3536
{
36-
$this->hooks->install($name);
37+
$this->hooks->install($request->get('name'));
3738

38-
return redirect(route('voyager.hooks'))->with([
39-
'message' => 'Hook '.$name.' was Installed',
40-
'alert-type' => 'success',
41-
]);
39+
return redirect(route('voyager.hooks'));
4240
}
4341

4442
public function uninstall($name)
4543
{
4644
$this->hooks->uninstall($name);
4745

48-
return redirect(route('voyager.hooks'))->with([
49-
'message' => 'Hook '.$name.' was Uninstalled',
50-
'alert-type' => 'success',
51-
]);
46+
return redirect(route('voyager.hooks'));
5247
}
5348

5449
public function update($name)
5550
{
5651
$this->hooks->update($name);
5752

58-
return redirect(route('voyager.hooks'))->with([
59-
'message' => 'Hook '.$name.' was Updated',
60-
'alert-type' => 'success',
61-
]);
53+
return redirect(route('voyager.hooks'));
6254
}
6355

6456
public function enable($name)
6557
{
6658
$this->hooks->enable($name);
6759

68-
return redirect(route('voyager.hooks'))->with([
69-
'message' => 'Hook '.$name.' is Enabled',
70-
'alert-type' => 'success',
71-
]);
60+
return redirect(route('voyager.hooks'));
7261
}
7362

7463
public function disable($name)
7564
{
7665
$this->hooks->disable($name);
7766

78-
return redirect(route('voyager.hooks'))->with([
79-
'message' => 'Hook '.$name.' was Disabled',
80-
'alert-type' => 'success',
81-
]);
82-
}
83-
84-
public function cacheRefresh()
85-
{
86-
$this->hooks->refreshCache();
87-
88-
return redirect(route('voyager.hooks'))->with([
89-
'message' => 'Hooks Cache Updated',
90-
'alert-type' => 'success',
91-
]);
67+
return redirect(route('voyager.hooks'));
9268
}
9369
}

src/VoyagerHooksServiceProvider.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@ public function addHookRoute($router)
5252
$router->get('hooks/{name}/enable', ['uses' => $namespacePrefix.'HooksController@enable', 'as' => 'hooks.enable']);
5353
$router->get('hooks/{name}/disable', ['uses' => $namespacePrefix.'HooksController@disable', 'as' => 'hooks.disable']);
5454
$router->get('hooks/{name}/update', ['uses' => $namespacePrefix.'HooksController@update', 'as' => 'hooks.update']);
55-
$router->get('hooks/{name}/install', ['uses' => $namespacePrefix.'HooksController@install', 'as' => 'hooks.install']);
55+
$router->post('hooks', ['uses' => $namespacePrefix.'HooksController@install', 'as' => 'hooks.install']);
5656
$router->delete('hooks/{name}', ['uses' => $namespacePrefix.'HooksController@uninstall', 'as' => 'hooks.uninstall']);
57-
$router->get('hooks/cache/refresh', ['uses' => $namespacePrefix.'HooksController@cacheRefresh', 'as' => 'hooks.cache.refresh']);
5857
}
5958

6059
public function addHookMenuItem(Menu $menu)

0 commit comments

Comments
 (0)