From: Marcel Werk Date: Tue, 3 Dec 2024 14:42:38 +0000 (+0100) Subject: Unify RPC endpoint naming X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=733e442ab447e6c3c870907a383c6d3d4567222e;p=GitHub%2FWoltLab%2FWCF.git Unify RPC endpoint naming --- diff --git a/ts/WoltLabSuite/Core/Api/Gridviews/GetRows.ts b/ts/WoltLabSuite/Core/Api/Gridviews/GetRows.ts index 142f6b15b6..3ebbc399b0 100644 --- a/ts/WoltLabSuite/Core/Api/Gridviews/GetRows.ts +++ b/ts/WoltLabSuite/Core/Api/Gridviews/GetRows.ts @@ -16,7 +16,7 @@ export async function getRows( filters?: Map, gridViewParameters?: Map, ): Promise> { - const url = new URL(`${window.WSC_RPC_API_URL}core/gridviews/rows`); + const url = new URL(`${window.WSC_RPC_API_URL}core/grid-views/rows`); url.searchParams.set("gridView", gridViewClass); url.searchParams.set("pageNo", pageNo.toString()); url.searchParams.set("sortField", sortField); diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Api/Gridviews/GetRows.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Api/Gridviews/GetRows.js index 8e0931892b..f85f33a7d7 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Api/Gridviews/GetRows.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Api/Gridviews/GetRows.js @@ -3,7 +3,7 @@ define(["require", "exports", "WoltLabSuite/Core/Ajax/Backend", "../Result"], fu 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`); + const url = new URL(`${window.WSC_RPC_API_URL}core/grid-views/rows`); url.searchParams.set("gridView", gridViewClass); url.searchParams.set("pageNo", pageNo.toString()); url.searchParams.set("sortField", sortField); diff --git a/wcfsetup/install/files/lib/bootstrap/com.woltlab.wcf.php b/wcfsetup/install/files/lib/bootstrap/com.woltlab.wcf.php index 22f5a5a0a2..60ddb452b2 100644 --- a/wcfsetup/install/files/lib/bootstrap/com.woltlab.wcf.php +++ b/wcfsetup/install/files/lib/bootstrap/com.woltlab.wcf.php @@ -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 new file mode 100644 index 0000000000..a4b8185909 --- /dev/null +++ b/wcfsetup/install/files/lib/system/endpoint/controller/core/gridViews/GetRows.class.php @@ -0,0 +1,82 @@ + + * @since 6.2 + */ +#[GetRequest('/core/grid-views/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 deleted file mode 100644 index a2dc415696..0000000000 --- a/wcfsetup/install/files/lib/system/endpoint/controller/core/gridviews/GetRows.class.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @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, - ) {} -}