]> BookStack Code Mirror - bookstack/blobdiff - app/Http/Controllers/WebhookController.php
Added force option for update-url command
[bookstack] / app / Http / Controllers / WebhookController.php
index 81e3b77925aa7d4827503126475d5196413756aa..c72dcc51066d4af80bef78c6b2cb9340d1960962 100644 (file)
@@ -3,7 +3,9 @@
 namespace BookStack\Http\Controllers;
 
 use BookStack\Actions\ActivityType;
+use BookStack\Actions\Queries\WebhooksAllPaginatedAndSorted;
 use BookStack\Actions\Webhook;
+use BookStack\Util\SimpleListOptions;
 use Illuminate\Http\Request;
 
 class WebhookController extends Controller
@@ -18,14 +20,25 @@ 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();
+        $listOptions = SimpleListOptions::fromRequest($request, 'webhooks')->withSortOptions([
+            'name' => trans('common.sort_name'),
+            'endpoint'  => trans('settings.webhooks_endpoint'),
+            'created_at' => trans('common.sort_created_at'),
+            'updated_at' => trans('common.sort_updated_at'),
+            'active'     => trans('common.status'),
+        ]);
+
+        $webhooks = (new WebhooksAllPaginatedAndSorted())->run(20, $listOptions);
+        $webhooks->appends($listOptions->getPaginationAppends());
+
+        $this->setPageTitle(trans('settings.webhooks'));
 
-        return view('settings.webhooks.index', ['webhooks' => $webhooks]);
+        return view('settings.webhooks.index', [
+            'webhooks'    => $webhooks,
+            'listOptions' => $listOptions,
+        ]);
     }
 
     /**
@@ -33,6 +46,8 @@ class WebhookController extends Controller
      */
     public function create()
     {
+        $this->setPageTitle(trans('settings.webhooks_create'));
+
         return view('settings.webhooks.create');
     }
 
@@ -69,6 +84,8 @@ class WebhookController extends Controller
             ->with('trackedEvents')
             ->findOrFail($id);
 
+        $this->setPageTitle(trans('settings.webhooks_edit'));
+
         return view('settings.webhooks.edit', ['webhook' => $webhook]);
     }
 
@@ -105,6 +122,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]);
     }