fix: Adapt reset of the update methods to use the new archived flag

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2024-02-22 17:44:51 +01:00
parent 32e3100e83
commit c2bb58b579
4 changed files with 17 additions and 7 deletions

View File

@ -17,7 +17,7 @@ return [
// -> tables // -> tables
['name' => 'api1#index', 'url' => '/api/1/tables', 'verb' => 'GET'], ['name' => 'api1#index', 'url' => '/api/1/tables', 'verb' => 'GET'],
['name' => 'api1#createTable', 'url' => '/api/1/tables', 'verb' => 'POST'], ['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#getTable', 'url' => '/api/1/tables/{tableId}', 'verb' => 'GET'],
['name' => 'api1#deleteTable', 'url' => '/api/1/tables/{tableId}', 'verb' => 'DELETE'], ['name' => 'api1#deleteTable', 'url' => '/api/1/tables/{tableId}', 'verb' => 'DELETE'],
// -> views // -> views
@ -61,7 +61,7 @@ return [
['name' => 'table#index', 'url' => '/table', 'verb' => 'GET'], ['name' => 'table#index', 'url' => '/table', 'verb' => 'GET'],
['name' => 'table#show', 'url' => '/table/{id}', 'verb' => 'GET'], ['name' => 'table#show', 'url' => '/table/{id}', 'verb' => 'GET'],
['name' => 'table#create', 'url' => '/table', 'verb' => 'POST'], ['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'], ['name' => 'table#destroy', 'url' => '/table/{id}', 'verb' => 'DELETE'],
// view // view
@ -115,7 +115,7 @@ return [
['name' => 'ApiTables#index', 'url' => '/api/2/tables', 'verb' => 'GET'], ['name' => 'ApiTables#index', 'url' => '/api/2/tables', 'verb' => 'GET'],
['name' => 'ApiTables#show', 'url' => '/api/2/tables/{id}', 'verb' => 'GET'], ['name' => 'ApiTables#show', 'url' => '/api/2/tables/{id}', 'verb' => 'GET'],
['name' => 'ApiTables#create', 'url' => '/api/2/tables', 'verb' => 'POST'], ['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#destroy', 'url' => '/api/2/tables/{id}', 'verb' => 'DELETE'],
['name' => 'ApiTables#transfer', 'url' => '/api/2/tables/{id}/transfer', 'verb' => 'PUT'], ['name' => 'ApiTables#transfer', 'url' => '/api/2/tables/{id}/transfer', 'verb' => 'PUT'],

View File

@ -44,7 +44,8 @@ class RenameTable extends Command {
protected function configure(): void { protected function configure(): void {
$this $this
->setName('tables:rename') ->setName('tables:update')
->setAliases('tables:rename')
->setDescription('Rename a table.') ->setDescription('Rename a table.')
->addArgument( ->addArgument(
'ID', 'ID',
@ -62,6 +63,12 @@ class RenameTable extends Command {
InputOption::VALUE_OPTIONAL, InputOption::VALUE_OPTIONAL,
'New emoji.' 'New emoji.'
) )
->addOption(
'archived',
'a',
InputOption::VALUE_NONE,
'Archived'
)
; ;
} }
@ -74,9 +81,10 @@ class RenameTable extends Command {
$id = $input->getArgument('ID'); $id = $input->getArgument('ID');
$title = $input->getArgument('title'); $title = $input->getArgument('title');
$emoji = $input->getOption('emoji'); $emoji = $input->getOption('emoji');
$archived = $input->getOption('archived');
try { try {
$table = $this->tableService->update($id, $title, $emoji, ''); $table = $this->tableService->update($id, $title, $emoji, $archived, '');
$arr = $table->jsonSerialize(); $arr = $table->jsonSerialize();
unset($arr['hasShares']); unset($arr['hasShares']);

View File

@ -178,9 +178,9 @@ class Api1Controller extends ApiController {
* 403: No permissions * 403: No permissions
* 404: Not found * 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 { 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) { } catch (PermissionError $e) {
$this->logger->warning('A permission error occurred: ' . $e->getMessage()); $this->logger->warning('A permission error occurred: ' . $e->getMessage());
$message = ['message' => $e->getMessage()]; $message = ['message' => $e->getMessage()];

View File

@ -44,6 +44,8 @@ namespace OCA\Tables;
* createdAt: string, * createdAt: string,
* lastEditBy: string, * lastEditBy: string,
* lastEditAt: string, * lastEditAt: string,
* archived: bool,
* favorite: bool,
* isShared: bool, * isShared: bool,
* onSharePermissions: ?array{ * onSharePermissions: ?array{
* read: bool, * read: bool,