]> BookStack Code Mirror - bookstack/blobdiff - app/Http/Controllers/WebhookController.php
Revised webhooks list to new format
[bookstack] / app / Http / Controllers / WebhookController.php
index 81e3b77925aa7d4827503126475d5196413756aa..23120c7e4c72b6c11ca5d07bb796974a5a295416 100644 (file)
@@ -3,6 +3,7 @@
 namespace BookStack\Http\Controllers;
 
 use BookStack\Actions\ActivityType;
+use BookStack\Actions\Queries\WebhooksAllPaginatedAndSorted;
 use BookStack\Actions\Webhook;
 use Illuminate\Http\Request;
 
@@ -18,14 +19,23 @@ class WebhookController extends Controller
     /**
      * Show all webhooks configured in the system.
      */
-    public function index()
+    public function index(Request $request)
     {
-        $webhooks = Webhook::query()
-            ->orderBy('name', 'desc')
-            ->with('trackedEvents')
-            ->get();
+        $listDetails = [
+            'search' => $request->get('search', ''),
+            'sort'   => setting()->getForCurrentUser('webhooks_sort', 'name'),
+            'order'  => setting()->getForCurrentUser('webhooks_sort_order', 'asc'),
+        ];
+
+        $webhooks = (new WebhooksAllPaginatedAndSorted())->run(20, $listDetails);
+        $webhooks->appends(['search' => $listDetails['search']]);
 
-        return view('settings.webhooks.index', ['webhooks' => $webhooks]);
+        $this->setPageTitle(trans('settings.webhooks'));
+
+        return view('settings.webhooks.index', [
+            'webhooks'    => $webhooks,
+            'listDetails' => $listDetails,
+        ]);
     }
 
     /**
@@ -33,6 +43,8 @@ class WebhookController extends Controller
      */
     public function create()
     {
+        $this->setPageTitle(trans('settings.webhooks_create'));
+
         return view('settings.webhooks.create');
     }
 
@@ -69,6 +81,8 @@ class WebhookController extends Controller
             ->with('trackedEvents')
             ->findOrFail($id);
 
+        $this->setPageTitle(trans('settings.webhooks_edit'));
+
         return view('settings.webhooks.edit', ['webhook' => $webhook]);
     }
 
@@ -105,6 +119,8 @@ class WebhookController extends Controller
         /** @var Webhook $webhook */
         $webhook = Webhook::query()->findOrFail($id);
 
+        $this->setPageTitle(trans('settings.webhooks_delete'));
+
         return view('settings.webhooks.delete', ['webhook' => $webhook]);
     }