Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/Controller/ApiTablesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ public function createFromScheme(string $title, string $emoji, string $descripti

$this->viewService->update($newView->getId(), ViewUpdateInput::fromInputArray(
array_merge($inputColumnsArray, [
'description' => $view['description'] ?? '',
'sort' => $newSort,
'filter' => $newFilter,
])
Expand Down
2 changes: 1 addition & 1 deletion lib/Model/ViewUpdateInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function updateDetail(): Generator {
if ($this->technicalName !== null) {
yield ViewUpdatableParameters::TECHNICAL_NAME => $this->technicalName;
}
if ($this->description) {
if ($this->description !== null) {
yield ViewUpdatableParameters::DESCRIPTION => $this->description;
}
if ($this->emoji) {
Expand Down
40 changes: 40 additions & 0 deletions tests/unit/Model/ViewUpdateInputTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCA\Tables\Tests\Unit\Model;

use OCA\Tables\Constants\ViewUpdatableParameters;
use OCA\Tables\Model\ViewUpdateInput;
use PHPUnit\Framework\TestCase;

class ViewUpdateInputTest extends TestCase {

public function testUpdateDetailIncludesDescription(): void {
$input = ViewUpdateInput::fromInputArray(['description' => 'Imported view description']);
$updates = [];

foreach ($input->updateDetail() as $parameter => $value) {
$updates[$parameter->value] = $value;
}

$this->assertSame('Imported view description', $updates[ViewUpdatableParameters::DESCRIPTION->value]);
}

public function testUpdateDetailIncludesEmptyDescription(): void {
$input = ViewUpdateInput::fromInputArray(['description' => '']);
$updates = [];

foreach ($input->updateDetail() as $parameter => $value) {
$updates[$parameter->value] = $value;
}

$this->assertArrayHasKey(ViewUpdatableParameters::DESCRIPTION->value, $updates);
$this->assertSame('', $updates[ViewUpdatableParameters::DESCRIPTION->value]);
}
}