Change RPC route to lowercase
authorMarcel Werk <burntime@woltlab.com>
Fri, 22 Nov 2024 11:19:03 +0000 (12:19 +0100)
committerMarcel Werk <burntime@woltlab.com>
Fri, 22 Nov 2024 11:19:03 +0000 (12:19 +0100)
ts/WoltLabSuite/Core/Api/GridViews/GetRows.ts [deleted file]
ts/WoltLabSuite/Core/Api/Gridviews/GetRows.ts [new file with mode: 0644]
ts/WoltLabSuite/Core/Component/GridView.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Api/GridViews/GetRows.js [deleted file]
wcfsetup/install/files/js/WoltLabSuite/Core/Api/Gridviews/GetRows.js [new file with mode: 0644]
wcfsetup/install/files/js/WoltLabSuite/Core/Component/GridView.js
wcfsetup/install/files/lib/bootstrap/com.woltlab.wcf.php
wcfsetup/install/files/lib/system/endpoint/controller/core/gridViews/GetRows.class.php [deleted file]
wcfsetup/install/files/lib/system/endpoint/controller/core/gridviews/GetRows.class.php [new file with mode: 0644]

diff --git a/ts/WoltLabSuite/Core/Api/GridViews/GetRows.ts b/ts/WoltLabSuite/Core/Api/GridViews/GetRows.ts
deleted file mode 100644 (file)
index a262a51..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-import { prepareRequest } from "WoltLabSuite/Core/Ajax/Backend";
-import { ApiResult, apiResultFromError, apiResultFromValue } from "../Result";
-
-type Response = {
-  template: string;
-  pages: number;
-  totalRows: number;
-  filterLabels: ArrayLike<string>;
-};
-
-export async function getRows(
-  gridViewClass: string,
-  pageNo: number,
-  sortField: string = "",
-  sortOrder: string = "ASC",
-  filters?: Map<string, string>,
-  gridViewParameters?: Map<string, string>,
-): Promise<ApiResult<Response>> {
-  const url = new URL(`${window.WSC_RPC_API_URL}core/gridViews/rows`);
-  url.searchParams.set("gridView", gridViewClass);
-  url.searchParams.set("pageNo", pageNo.toString());
-  url.searchParams.set("sortField", sortField);
-  url.searchParams.set("sortOrder", sortOrder);
-  if (filters) {
-    filters.forEach((value, key) => {
-      url.searchParams.set(`filters[${key}]`, value);
-    });
-  }
-  if (gridViewParameters) {
-    gridViewParameters.forEach((value, key) => {
-      url.searchParams.set(`gridViewParameters[${key}]`, value);
-    });
-  }
-
-  let response: Response;
-  try {
-    response = (await prepareRequest(url).get().allowCaching().disableLoadingIndicator().fetchAsJson()) as Response;
-  } catch (e) {
-    return apiResultFromError(e);
-  }
-
-  return apiResultFromValue(response);
-}
diff --git a/ts/WoltLabSuite/Core/Api/Gridviews/GetRows.ts b/ts/WoltLabSuite/Core/Api/Gridviews/GetRows.ts
new file mode 100644 (file)
index 0000000..142f6b1
--- /dev/null
@@ -0,0 +1,43 @@
+import { prepareRequest } from "WoltLabSuite/Core/Ajax/Backend";
+import { ApiResult, apiResultFromError, apiResultFromValue } from "../Result";
+
+type Response = {
+  template: string;
+  pages: number;
+  totalRows: number;
+  filterLabels: ArrayLike<string>;
+};
+
+export async function getRows(
+  gridViewClass: string,
+  pageNo: number,
+  sortField: string = "",
+  sortOrder: string = "ASC",
+  filters?: Map<string, string>,
+  gridViewParameters?: Map<string, string>,
+): Promise<ApiResult<Response>> {
+  const url = new URL(`${window.WSC_RPC_API_URL}core/gridviews/rows`);
+  url.searchParams.set("gridView", gridViewClass);
+  url.searchParams.set("pageNo", pageNo.toString());
+  url.searchParams.set("sortField", sortField);
+  url.searchParams.set("sortOrder", sortOrder);
+  if (filters) {
+    filters.forEach((value, key) => {
+      url.searchParams.set(`filters[${key}]`, value);
+    });
+  }
+  if (gridViewParameters) {
+    gridViewParameters.forEach((value, key) => {
+      url.searchParams.set(`gridViewParameters[${key}]`, value);
+    });
+  }
+
+  let response: Response;
+  try {
+    response = (await prepareRequest(url).get().allowCaching().disableLoadingIndicator().fetchAsJson()) as Response;
+  } catch (e) {
+    return apiResultFromError(e);
+  }
+
+  return apiResultFromValue(response);
+}
index ba0d4b751dfa5673a75aa5bab3c76b59c586844f..a0a82ba9c58ffe582f0dd40f30a798113618bb07 100644 (file)
@@ -1,4 +1,4 @@
-import { getRows } from "../Api/GridViews/GetRows";
+import { getRows } from "../Api/Gridviews/GetRows";
 import DomChangeListener from "../Dom/Change/Listener";
 import DomUtil from "../Dom/Util";
 import { promiseMutex } from "../Helper/PromiseMutex";
diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Api/GridViews/GetRows.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Api/GridViews/GetRows.js
deleted file mode 100644 (file)
index 3299f1a..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-define(["require", "exports", "WoltLabSuite/Core/Ajax/Backend", "../Result"], function (require, exports, Backend_1, Result_1) {
-    "use strict";
-    Object.defineProperty(exports, "__esModule", { value: true });
-    exports.getRows = getRows;
-    async function getRows(gridViewClass, pageNo, sortField = "", sortOrder = "ASC", filters, gridViewParameters) {
-        const url = new URL(`${window.WSC_RPC_API_URL}core/gridViews/rows`);
-        url.searchParams.set("gridView", gridViewClass);
-        url.searchParams.set("pageNo", pageNo.toString());
-        url.searchParams.set("sortField", sortField);
-        url.searchParams.set("sortOrder", sortOrder);
-        if (filters) {
-            filters.forEach((value, key) => {
-                url.searchParams.set(`filters[${key}]`, value);
-            });
-        }
-        if (gridViewParameters) {
-            gridViewParameters.forEach((value, key) => {
-                url.searchParams.set(`gridViewParameters[${key}]`, value);
-            });
-        }
-        let response;
-        try {
-            response = (await (0, Backend_1.prepareRequest)(url).get().allowCaching().disableLoadingIndicator().fetchAsJson());
-        }
-        catch (e) {
-            return (0, Result_1.apiResultFromError)(e);
-        }
-        return (0, Result_1.apiResultFromValue)(response);
-    }
-});
diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Api/Gridviews/GetRows.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Api/Gridviews/GetRows.js
new file mode 100644 (file)
index 0000000..8e09318
--- /dev/null
@@ -0,0 +1,30 @@
+define(["require", "exports", "WoltLabSuite/Core/Ajax/Backend", "../Result"], function (require, exports, Backend_1, Result_1) {
+    "use strict";
+    Object.defineProperty(exports, "__esModule", { value: true });
+    exports.getRows = getRows;
+    async function getRows(gridViewClass, pageNo, sortField = "", sortOrder = "ASC", filters, gridViewParameters) {
+        const url = new URL(`${window.WSC_RPC_API_URL}core/gridviews/rows`);
+        url.searchParams.set("gridView", gridViewClass);
+        url.searchParams.set("pageNo", pageNo.toString());
+        url.searchParams.set("sortField", sortField);
+        url.searchParams.set("sortOrder", sortOrder);
+        if (filters) {
+            filters.forEach((value, key) => {
+                url.searchParams.set(`filters[${key}]`, value);
+            });
+        }
+        if (gridViewParameters) {
+            gridViewParameters.forEach((value, key) => {
+                url.searchParams.set(`gridViewParameters[${key}]`, value);
+            });
+        }
+        let response;
+        try {
+            response = (await (0, Backend_1.prepareRequest)(url).get().allowCaching().disableLoadingIndicator().fetchAsJson());
+        }
+        catch (e) {
+            return (0, Result_1.apiResultFromError)(e);
+        }
+        return (0, Result_1.apiResultFromValue)(response);
+    }
+});
index 562d5dca5e94cb358a3d9a35b8a33e7aa37f66e4..addb5e72bd2c5bb42a43dcb15d2202bd219a8a75 100644 (file)
@@ -1,4 +1,4 @@
-define(["require", "exports", "tslib", "../Api/GridViews/GetRows", "../Dom/Change/Listener", "../Dom/Util", "../Helper/PromiseMutex", "../Ui/Dropdown/Simple", "./Dialog"], function (require, exports, tslib_1, GetRows_1, Listener_1, Util_1, PromiseMutex_1, Simple_1, Dialog_1) {
+define(["require", "exports", "tslib", "../Api/Gridviews/GetRows", "../Dom/Change/Listener", "../Dom/Util", "../Helper/PromiseMutex", "../Ui/Dropdown/Simple", "./Dialog"], function (require, exports, tslib_1, GetRows_1, Listener_1, Util_1, PromiseMutex_1, Simple_1, Dialog_1) {
     "use strict";
     Object.defineProperty(exports, "__esModule", { value: true });
     exports.GridView = void 0;
index 60ddb452b2c35066c45c23f862f4439c3dd2c443..22f5a5a0a2517187e1e846b45150155fdc294a3f 100644 (file)
@@ -135,7 +135,7 @@ return static function (): void {
             $event->register(new \wcf\system\endpoint\controller\core\comments\responses\RenderResponses);
             $event->register(new \wcf\system\endpoint\controller\core\comments\responses\UpdateResponse);
             $event->register(new \wcf\system\endpoint\controller\core\exceptions\RenderException);
-            $event->register(new \wcf\system\endpoint\controller\core\gridViews\GetRows);
+            $event->register(new \wcf\system\endpoint\controller\core\gridviews\GetRows);
             $event->register(new \wcf\system\endpoint\controller\core\messages\GetMentionSuggestions);
             $event->register(new \wcf\system\endpoint\controller\core\sessions\DeleteSession);
             $event->register(new \wcf\system\endpoint\controller\core\users\options\DeleteOption);
diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/gridViews/GetRows.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/gridViews/GetRows.class.php
deleted file mode 100644 (file)
index d1213a6..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-<?php
-
-namespace wcf\system\endpoint\controller\core\gridViews;
-
-use Laminas\Diactoros\Response\JsonResponse;
-use Psr\Http\Message\ResponseInterface;
-use Psr\Http\Message\ServerRequestInterface;
-use wcf\http\Helper;
-use wcf\system\endpoint\GetRequest;
-use wcf\system\endpoint\IController;
-use wcf\system\exception\PermissionDeniedException;
-use wcf\system\exception\UserInputException;
-use wcf\system\gridView\AbstractGridView;
-
-/**
- * Retrieves the rows for a grid view.
- *
- * @author      Marcel Werk
- * @copyright   2001-2024 WoltLab GmbH
- * @license     GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @since       6.2
- */
-#[GetRequest('/core/gridViews/rows')]
-final class GetRows implements IController
-{
-    #[\Override]
-    public function __invoke(ServerRequestInterface $request, array $variables): ResponseInterface
-    {
-        $parameters = Helper::mapApiParameters($request, GetRowsParameters::class);
-
-        if (!\is_subclass_of($parameters->gridView, AbstractGridView::class)) {
-            throw new UserInputException('gridView', 'invalid');
-        }
-
-        $view = new $parameters->gridView(...$parameters->gridViewParameters);
-        \assert($view instanceof AbstractGridView);
-
-        if (!$view->isAccessible()) {
-            throw new PermissionDeniedException();
-        }
-
-        $view->setPageNo($parameters->pageNo);
-        if ($parameters->sortField) {
-            $view->setSortField($parameters->sortField);
-        }
-        if ($parameters->sortOrder) {
-            $view->setSortOrder($parameters->sortOrder);
-        }
-
-        if ($parameters->filters !== []) {
-            $view->setActiveFilters($parameters->filters);
-        }
-
-        $filterLabels = [];
-        foreach (\array_keys($parameters->filters) as $key) {
-            $filterLabels[$key] = $view->getFilterLabel($key);
-        }
-
-        return new JsonResponse([
-            'template' => $view->renderRows(),
-            'pages' => $view->countPages(),
-            'totalRows' => $view->countRows(),
-            'filterLabels' => $filterLabels,
-        ]);
-    }
-}
-
-/** @internal */
-final class GetRowsParameters
-{
-    public function __construct(
-        /** @var non-empty-string */
-        public readonly string $gridView,
-        public readonly int $pageNo,
-        public readonly string $sortField,
-        public readonly string $sortOrder,
-        /** @var string[] */
-        public readonly array $filters,
-        /** @var string[] */
-        public readonly array $gridViewParameters,
-    ) {}
-}
diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/gridviews/GetRows.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/gridviews/GetRows.class.php
new file mode 100644 (file)
index 0000000..a2dc415
--- /dev/null
@@ -0,0 +1,82 @@
+<?php
+
+namespace wcf\system\endpoint\controller\core\gridviews;
+
+use Laminas\Diactoros\Response\JsonResponse;
+use Psr\Http\Message\ResponseInterface;
+use Psr\Http\Message\ServerRequestInterface;
+use wcf\http\Helper;
+use wcf\system\endpoint\GetRequest;
+use wcf\system\endpoint\IController;
+use wcf\system\exception\PermissionDeniedException;
+use wcf\system\exception\UserInputException;
+use wcf\system\gridView\AbstractGridView;
+
+/**
+ * Retrieves the rows for a grid view.
+ *
+ * @author      Marcel Werk
+ * @copyright   2001-2024 WoltLab GmbH
+ * @license     GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since       6.2
+ */
+#[GetRequest('/core/gridviews/rows')]
+final class GetRows implements IController
+{
+    #[\Override]
+    public function __invoke(ServerRequestInterface $request, array $variables): ResponseInterface
+    {
+        $parameters = Helper::mapApiParameters($request, GetRowsParameters::class);
+
+        if (!\is_subclass_of($parameters->gridView, AbstractGridView::class)) {
+            throw new UserInputException('gridView', 'invalid');
+        }
+
+        $view = new $parameters->gridView(...$parameters->gridViewParameters);
+        \assert($view instanceof AbstractGridView);
+
+        if (!$view->isAccessible()) {
+            throw new PermissionDeniedException();
+        }
+
+        $view->setPageNo($parameters->pageNo);
+        if ($parameters->sortField) {
+            $view->setSortField($parameters->sortField);
+        }
+        if ($parameters->sortOrder) {
+            $view->setSortOrder($parameters->sortOrder);
+        }
+
+        if ($parameters->filters !== []) {
+            $view->setActiveFilters($parameters->filters);
+        }
+
+        $filterLabels = [];
+        foreach (\array_keys($parameters->filters) as $key) {
+            $filterLabels[$key] = $view->getFilterLabel($key);
+        }
+
+        return new JsonResponse([
+            'template' => $view->renderRows(),
+            'pages' => $view->countPages(),
+            'totalRows' => $view->countRows(),
+            'filterLabels' => $filterLabels,
+        ]);
+    }
+}
+
+/** @internal */
+final class GetRowsParameters
+{
+    public function __construct(
+        /** @var non-empty-string */
+        public readonly string $gridView,
+        public readonly int $pageNo,
+        public readonly string $sortField,
+        public readonly string $sortOrder,
+        /** @var string[] */
+        public readonly array $filters,
+        /** @var string[] */
+        public readonly array $gridViewParameters,
+    ) {}
+}