Skip to content
Draft
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
3 changes: 3 additions & 0 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ Vrij en open source onder de EUPL-1.2-licentie.
<!-- REQ-ACK-009: a widget that asks for a read confirmation gets its
announcement key, so Read receipts shows for it. -->
<step>OCA\LaunchPad\Repair\MintAnnouncementKeys</step>
<!-- REQ-TILE-041: the address links stored inside tile groups become
tile nodes the tile form edits. Idempotent. -->
<step>OCA\LaunchPad\Repair\ConvertGroupLinksToTiles</step>
</post-migration>
<install>
<step>OCA\LaunchPad\Repair\InitializeActions</step>
Expand Down
96 changes: 96 additions & 0 deletions lib/Repair/ConvertGroupLinksToTiles.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?php
/**
* ConvertGroupLinksToTiles
*
* Repair step: the address links stored inside groups become tile nodes, so
* every tile in a group is a full tile the tile form edits (REQ-TILE-041).
*
* @category Repair
* @package OCA\LaunchPad\Repair
*
* @author Conduction Development Team <info@conduction.nl>
* @copyright 2026 Conduction B.V.
* @license EUPL-1.2 https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
*
* @version GIT: <git-id>
*
* @link https://conduction.nl
*
* SPDX-FileCopyrightText: 2026 Conduction B.V. <info@conduction.nl>
* SPDX-License-Identifier: EUPL-1.2
*/

declare(strict_types=1);

namespace OCA\LaunchPad\Repair;

use OCA\LaunchPad\Db\WidgetPlacementMapper;
use OCA\LaunchPad\Service\GroupTileNode;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
use Psr\Log\LoggerInterface;
use Throwable;

/**
* Turn the address links of every stored group into tile nodes. Idempotent:
* a group with no address links left is not written again.
*
* @spec openspec/changes/tile-form-board-sync/specs/tiles/spec.md#requirement-a-tiles-group-and-the-groups-order-req-tile-041
*/
class ConvertGroupLinksToTiles implements IRepairStep {
/**
* Constructor.
*
* @param WidgetPlacementMapper $placements The placement store.
* @param LoggerInterface $logger PSR-3 logger.
*/
public function __construct(
private readonly WidgetPlacementMapper $placements,
private readonly LoggerInterface $logger,
) {
}//end __construct()

/**
* Return the human-readable name of this repair step.
*
* @return string The step name.
*
* @spec openspec/changes/tile-form-board-sync/specs/tiles/spec.md#requirement-a-tiles-group-and-the-groups-order-req-tile-041
*/
public function getName(): string {
return 'Turn the links inside tile groups into tiles';
}//end getName()

/**
* Run the step. A failure is a warning, never a failed upgrade.
*
* @param IOutput $output Migration output stream.
*
* @return void
*
* @spec openspec/changes/tile-form-board-sync/specs/tiles/spec.md#requirement-a-tiles-group-and-the-groups-order-req-tile-041
*/
public function run(IOutput $output): void {
$groups = 0;
$tiles = 0;
try {
foreach ($this->placements->findByWidgetId(widgetId: 'container') as $placement) {
$result = GroupTileNode::convertGroup(content: $placement->getContentArray());
if ($result['changed'] === 0) {
continue;
}

$placement->setContentArray(content: $result['content']);
$this->placements->update(entity: $placement);
$groups++;
$tiles += $result['changed'];
}
} catch (Throwable $e) {
$this->logger->warning(message: '[ConvertGroupLinksToTiles] could not turn the group links into tiles: ' . $e->getMessage());
$output->warning(message: 'The links inside tile groups were not turned into tiles: ' . $e->getMessage());
return;
}

$output->info(message: sprintf('%d link(s) in %d group(s) became tiles.', $tiles, $groups));
}//end run()
}//end class
9 changes: 6 additions & 3 deletions lib/Service/BookmarkImportPlan.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,18 +225,21 @@ public function layout(int $bottom): array {
}//end layout()

/**
* The link children of a container, two to a row of its four-column grid.
* The tiles of a container, two to a row of its four-column grid. Each
* bookmark is a full tile node (REQ-TILE-041), so the tile form edits it.
*
* @param list<array{title: string, url: string}> $bookmarks The folder's bookmarks.
*
* @return list<array<string, mixed>>
*
* @spec openspec/changes/tile-form-board-sync/specs/tiles/spec.md#requirement-a-tiles-group-and-the-groups-order-req-tile-041
*/
private static function children(array $bookmarks): array {
$children = [];
foreach (array_values($bookmarks) as $index => $bookmark) {
$children[] = [
'type' => 'link',
'content' => ['label' => $bookmark['title'], 'url' => $bookmark['url'], 'actionType' => 'external'],
'type' => 'tile',
'content' => ['title' => $bookmark['title'], 'iconType' => 'svg', 'linkType' => 'url', 'linkValue' => $bookmark['url']],
'gridX' => (($index % 2) * self::TILE_SIZE),
'gridY' => (intdiv($index, 2) * self::TILE_SIZE),
'gridWidth' => self::TILE_SIZE,
Expand Down
142 changes: 142 additions & 0 deletions lib/Service/GroupTileNode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
<?php
/**
* GroupTileNode
*
* The tiles inside a group (a `container` widget) are full tile nodes: a
* child `{type: tile, content: {title, linkType, linkValue, ...}}`. A child
* written as a link that only opens one address (a bookmark import wrote
* those) is turned into such a node here.
*
* @category Service
* @package OCA\LaunchPad\Service
*
* @author Conduction Development Team <info@conduction.nl>
* @copyright 2026 Conduction B.V.
* @license EUPL-1.2 https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
*
* @version GIT: <git-id>
*
* @link https://conduction.nl
*
* SPDX-FileCopyrightText: 2026 Conduction B.V. <info@conduction.nl>
* SPDX-License-Identifier: EUPL-1.2
*/

declare(strict_types=1);

namespace OCA\LaunchPad\Service;

/**
* Turns the address links of a group into tile nodes, in a group's content
* and in the groups nested in it. A link that runs an action or lists
* several links stays a link; every other key of a child is kept.
*
* @spec openspec/changes/tile-form-board-sync/specs/tiles/spec.md#requirement-a-tiles-group-and-the-groups-order-req-tile-041
*/
final class GroupTileNode {

/**
* The link actions that only open an address.
*/
private const ADDRESS_ACTIONS = ['', 'external', 'internal'];

/**
* The keys of a link child that the tile node replaces. A link's icon is an
* icon name, which a tile does not draw, so it goes too.
*/
private const LINK_ONLY_KEYS = ['label', 'url', 'actionType', 'icon', 'iconType'];

/**
* The tile node for an address link child, or null for any other child.
*
* @param array<string, mixed> $child The container child.
*
* @return array<string, mixed>|null
*
* @spec openspec/changes/tile-form-board-sync/specs/tiles/spec.md#requirement-a-tiles-group-and-the-groups-order-req-tile-041
*/
public static function fromLink(array $child): ?array {
$content = $child['content'] ?? null;
if (($child['type'] ?? null) !== 'link' || is_array($content) === false || self::isAddressLink(content: $content) === false) {
return null;
}

$tile = array_diff_key($content, array_flip(self::LINK_ONLY_KEYS));
$tile['title'] = trim((string) ($content['label'] ?? ''));
$tile['iconType'] = 'svg';
$tile['linkType'] = 'url';
$tile['linkValue'] = trim((string) $content['url']);

$child['type'] = 'tile';
$child['content'] = $tile;
return $child;
}//end fromLink()

/**
* A group's content with every address link, also in nested groups, as a
* tile node. Content without children comes back unchanged.
*
* @param array<string, mixed> $content The group's content.
*
* @return array{content: array<string, mixed>, changed: int} The content and how many children changed.
*
* @spec openspec/changes/tile-form-board-sync/specs/tiles/spec.md#requirement-a-tiles-group-and-the-groups-order-req-tile-041
*/
public static function convertGroup(array $content): array {
$children = $content['placements'] ?? null;
if (is_array($children) === false) {
return ['content' => $content, 'changed' => 0];
}

$changed = 0;
foreach ($children as $index => $child) {
if (is_array($child) === false) {
continue;
}

[$children[$index], $count] = self::convertChild(child: $child);
$changed += $count;
}

$content['placements'] = $children;
return ['content' => $content, 'changed' => $changed];
}//end convertGroup()

/**
* One child as a tile node, or with its own group converted.
*
* @param array<string, mixed> $child The container child.
*
* @return array{0: array<string, mixed>, 1: int} The child and how many children changed.
*/
private static function convertChild(array $child): array {
$tile = self::fromLink(child: $child);
if ($tile !== null) {
return [$tile, 1];
}

if (is_array($child['content'] ?? null) === false) {
return [$child, 0];
}

$nested = self::convertGroup(content: $child['content']);
$child['content'] = $nested['content'];
return [$child, $nested['changed']];
}//end convertChild()

/**
* Whether a link's content only opens one address.
*
* @param array<string, mixed> $content The link child's content.
*
* @return bool
*/
private static function isAddressLink(array $content): bool {
$url = $content['url'] ?? null;
$action = (string) ($content['actionType'] ?? '');
return is_string($url) === true
&& trim($url) !== ''
&& is_array($content['links'] ?? null) === false
&& in_array($action, self::ADDRESS_ACTIONS, true) === true;
}//end isAddressLink()
}//end class
3 changes: 2 additions & 1 deletion openspec/changes/tile-form-board-sync/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

- [x] Tile form layout: name and group, type and open-in as choice cards, addresses side by side, icon with upload, swatches (from icon-only-app-tiles), sort order, availability switch (the colour keeps its two pickers until icon-only-app-tiles lands its swatches)
- [x] Group field and the group's sort order (last used first, alphabetical, random, as placed): a tile inside a group opens the tile form from its own tile menu, with the group's name and order; the save writes the tile into the group's `content.placements` and the order onto the container's `content.sortBy` in one update (src/utils/groupTiles.js, ContainerChild, ContainerWidget, Views, TileEditor `inGroup`). Decision: a tile in a group has no placement of its own on the server and renders through the shared tile renderer, so its form offers only a web address (no launch types, internal address, Open in or availability check); settings of that kind it carries are kept, not dropped; a bookmark link child becomes a tile node when saved
- [ ] Moving a tile into a group keeps its launch, health and network settings (the child is a full tile node, 25 Nov decision), and a repair step turns stored link children `{type: link, content: {label, url, actionType}}` into tile nodes
- [x] Stored link children become tile nodes: a repair step (lib/Repair/ConvertGroupLinksToTiles.php, via lib/Service/GroupTileNode.php) turns every address link `{type: link, content: {label, url, actionType}}` inside a group, also in nested groups, into `{type: tile, content: {title, iconType, linkType: url, linkValue}}`, keeping its layout and other keys; the bookmark import writes tile nodes directly. An action link or a link list stays a link
- [ ] Moving a tile from the dashboard into a group keeps its launch, health and network settings (the child is a full tile node, 25 Nov decision). There is no move-into-group yet: the inner grid accepts a drop (GridStack `acceptWidgets`) but nothing stores it, so this is a new drag interaction that needs a live drag check
- [x] Last availability result under the switch (reachable or not, with the time)
- [x] Delete tile at the bottom left, Cancel and Save at the right
- [x] Translations in every shipped locale
Expand Down
10 changes: 6 additions & 4 deletions src/utils/groupTiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ const FORM_KEYS = Object.freeze([
/** The link actions that only open an address, so a tile can take them over. */
const ADDRESS_ACTIONS = Object.freeze(['', 'external', 'internal'])

/** The keys of a link child that the tile node replaces. */
const LINK_ONLY_KEYS = Object.freeze(['label', 'url', 'actionType'])
/**
* The keys of a link child that the tile node replaces. A link's icon is an
* icon name, which a tile does not draw, so it goes too.
*/
const LINK_ONLY_KEYS = Object.freeze(['label', 'url', 'actionType', 'icon', 'iconType'])

/**
* Whether a container child is a tile the tile form can edit: a `tile` child
Expand Down Expand Up @@ -116,8 +119,7 @@ function setFormFields(source) {
function linkToTile(content) {
return setFormFields({
title: content.label,
icon: content.icon,
iconType: isSet(content.iconType) ? content.iconType : 'svg',
iconType: 'svg',
linkType: 'url',
linkValue: content.url,
})
Expand Down
Loading