From c2bb58b579a1ad19bb74fc4d138ec0e274cf9964 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Thu, 22 Feb 2024 17:44:51 +0100 Subject: [PATCH] fix: Adapt reset of the update methods to use the new archived flag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- appinfo/routes.php | 6 +++--- lib/Command/RenameTable.php | 12 ++++++++++-- lib/Controller/Api1Controller.php | 4 ++-- lib/ResponseDefinitions.php | 2 ++ 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/appinfo/routes.php b/appinfo/routes.php index e58ee8e4..5f733dfb 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -17,7 +17,7 @@ return [ // -> tables ['name' => 'api1#index', 'url' => '/api/1/tables', 'verb' => 'GET'], ['name' => 'api1#createTable', 'url' => '/api/1/tables', 'verb' => 'POST'], - ['name' => 'api1#updateTable', 'url' => '/api/1/tables/{tableId}', 'verb' => 'PUT'], // needs archived + ['name' => 'api1#updateTable', 'url' => '/api/1/tables/{tableId}', 'verb' => 'PUT'], ['name' => 'api1#getTable', 'url' => '/api/1/tables/{tableId}', 'verb' => 'GET'], ['name' => 'api1#deleteTable', 'url' => '/api/1/tables/{tableId}', 'verb' => 'DELETE'], // -> views @@ -61,7 +61,7 @@ return [ ['name' => 'table#index', 'url' => '/table', 'verb' => 'GET'], ['name' => 'table#show', 'url' => '/table/{id}', 'verb' => 'GET'], ['name' => 'table#create', 'url' => '/table', 'verb' => 'POST'], - ['name' => 'table#update', 'url' => '/table/{id}', 'verb' => 'PUT'], // needs archived + ['name' => 'table#update', 'url' => '/table/{id}', 'verb' => 'PUT'], ['name' => 'table#destroy', 'url' => '/table/{id}', 'verb' => 'DELETE'], // view @@ -115,7 +115,7 @@ return [ ['name' => 'ApiTables#index', 'url' => '/api/2/tables', 'verb' => 'GET'], ['name' => 'ApiTables#show', 'url' => '/api/2/tables/{id}', 'verb' => 'GET'], ['name' => 'ApiTables#create', 'url' => '/api/2/tables', 'verb' => 'POST'], - ['name' => 'ApiTables#update', 'url' => '/api/2/tables/{id}', 'verb' => 'PUT'], // needs archived + ['name' => 'ApiTables#update', 'url' => '/api/2/tables/{id}', 'verb' => 'PUT'], ['name' => 'ApiTables#destroy', 'url' => '/api/2/tables/{id}', 'verb' => 'DELETE'], ['name' => 'ApiTables#transfer', 'url' => '/api/2/tables/{id}/transfer', 'verb' => 'PUT'], diff --git a/lib/Command/RenameTable.php b/lib/Command/RenameTable.php index 6e8c4f41..f2a3f57b 100644 --- a/lib/Command/RenameTable.php +++ b/lib/Command/RenameTable.php @@ -44,7 +44,8 @@ class RenameTable extends Command { protected function configure(): void { $this - ->setName('tables:rename') + ->setName('tables:update') + ->setAliases('tables:rename') ->setDescription('Rename a table.') ->addArgument( 'ID', @@ -62,6 +63,12 @@ class RenameTable extends Command { InputOption::VALUE_OPTIONAL, 'New emoji.' ) + ->addOption( + 'archived', + 'a', + InputOption::VALUE_NONE, + 'Archived' + ) ; } @@ -74,9 +81,10 @@ class RenameTable extends Command { $id = $input->getArgument('ID'); $title = $input->getArgument('title'); $emoji = $input->getOption('emoji'); + $archived = $input->getOption('archived'); try { - $table = $this->tableService->update($id, $title, $emoji, ''); + $table = $this->tableService->update($id, $title, $emoji, $archived, ''); $arr = $table->jsonSerialize(); unset($arr['hasShares']); diff --git a/lib/Controller/Api1Controller.php b/lib/Controller/Api1Controller.php index a9d9a856..65b6654f 100644 --- a/lib/Controller/Api1Controller.php +++ b/lib/Controller/Api1Controller.php @@ -178,9 +178,9 @@ class Api1Controller extends ApiController { * 403: No permissions * 404: Not found */ - public function updateTable(int $tableId, string $title = null, string $emoji = null): DataResponse { + public function updateTable(int $tableId, string $title = null, string $emoji = null, ?bool $archived = false): DataResponse { try { - return new DataResponse($this->tableService->update($tableId, $title, $emoji, $this->userId)->jsonSerialize()); + return new DataResponse($this->tableService->update($tableId, $title, $emoji, $archived, $this->userId)->jsonSerialize()); } catch (PermissionError $e) { $this->logger->warning('A permission error occurred: ' . $e->getMessage()); $message = ['message' => $e->getMessage()]; diff --git a/lib/ResponseDefinitions.php b/lib/ResponseDefinitions.php index 42668bce..beec25b7 100644 --- a/lib/ResponseDefinitions.php +++ b/lib/ResponseDefinitions.php @@ -44,6 +44,8 @@ namespace OCA\Tables; * createdAt: string, * lastEditBy: string, * lastEditAt: string, + * archived: bool, + * favorite: bool, * isShared: bool, * onSharePermissions: ?array{ * read: bool,