Skip to content
Merged
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
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,20 @@ All notable changes are written here, newest first, in the [Keep a Changelog](ht

## [Unreleased]

### Added

- **Group** widget on status screens: one card behind the widgets wholly inside it, which then draw no card of their own (**Show card** is locked off). Groups nest, a group moves with all it holds when dragged by the space between its widgets, and it cannot be made smaller than them. Its title is off by default.
- A screen's **Margin** around the grid and **Spacing** between its widgets: none, small, medium (as before) or large. With no spacing, tiles have square corners and neighbours share one border.
- The **QR code** widget's style: the Lumberjack logo on or off, the code's color and a background, its modules, its eyes as a set or outer and inner apart, and up to 3 filters, each picked from pictures of the QR library's own parts, with **Reset** per section. A style phones could not read reliably is refused when saved.
- What a screen's header shows: the logo, the title (or a title of its own), team, projects, environment, period, the count of widgets needing attention and the live state can each be turned off; offline always shows. The header comes in four sizes, and its title grows to the clock's size with nothing under it. The clock can show seconds and the date, in a format of five or one of its own from tokens (`ddd D. MMM`), in the app's language, the TV's own, or one picked.
- **Move to another team** in a project's danger zone, for owners and admins of both teams. The project's own alert rules and channels go with it; links to the old team's rules and channels, MCP token access, the old team's screens' references and assignees or watchers outside the new team are dropped. A taken slug or issue prefix is replaced in the dialog, and each move is in the audit log.
- MCP: `update_screen` sets `margin`, `gap` and `header`; the design guide covers groups and these settings.

### Changed

- Screen settings are in tabs (**Display**, **Look**, **Data**, **Header**); **Aspect** and **Orientation** moved there from the designer's toolbar.
- Spacing, alignment, text and title sizes, theme, fit, aspect and orientation are picked from pictures of what they do, and a screen's projects and header parts from switches.
- `list_widget_types` leaves out the designer's pictures of the QR code's parts.
- The **Mail domain** check's form and docs say what a DKIM selector is entered as (the name only, such as `dkim`) and where to find it.

## [0.11.1] - 2026-11-15
Expand Down
1 change: 1 addition & 0 deletions app/Domains/Administration/Enums/AdminAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ enum AdminAction: string
case PublicStatsRotated = 'public_stats_rotated';
case PublicStatsChanged = 'public_stats_changed';
case PublicStatsDisabled = 'public_stats_disabled';
case ProjectMoved = 'project_moved';
case ScreenShared = 'screen_shared';
case ScreenShareChanged = 'screen_share_changed';
case ScreenShareRotated = 'screen_share_rotated';
Expand Down
8 changes: 7 additions & 1 deletion app/Domains/Live/Observers/LiveModelObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,16 @@ private function retention(RetentionPolicy $policy): void

private function projectChanged(Project $project, bool $createdOrDeleted): void
{
if ($createdOrDeleted || $project->wasChanged(['name', 'slug'])) {
if ($createdOrDeleted || $project->wasChanged(['name', 'slug', 'team_id'])) {
$this->team->execute($project->team_id, TeamChangeKind::Projects);
}

// Moved to another team: the old one lists it no more.
if ($project->wasChanged('team_id')) {
$this->team->execute((int) $project->getPrevious()['team_id'], TeamChangeKind::Projects);
$this->admin->execute(AdminChangeKind::Teams);
}

if ($createdOrDeleted) {
$this->admin->execute(AdminChangeKind::Teams);

Expand Down
9 changes: 8 additions & 1 deletion app/Domains/Mcp/Tools/Screens/GetScreenDesignGuide.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,20 @@ class GetScreenDesignGuide extends Tool
## Widgets
{id, type, source, x, y, w, h, title, options, scope}
- id: unique on the screen, any short string; keep it when moving a widget.
- x, y from 0; w, h in cells. Inside the grid, no overlaps.
- x, y from 0; w, h in cells. Inside the grid, no overlaps, but for groups.
- A group (type group) is one card behind the widgets wholly inside it, on fewer cells than
it; those draw no card of their own. Groups nest. Moving a group, move what it holds too.
- source: an id from list_widget_types, for types that have sources.
- options: only the keys of the type's fields.
- scope: over the screen's scope: projects (uuids), environment, period, and for some sources
release, filter, domain. Empty projects means every project.
- rotate: on rotating types, source ids or {source, seconds, title, options, scope}.

## Screen settings
update_screen also sets the room around the grid (margin) and between widgets (gap), and what
the header shows (header: parts to hide, a title, the clock's date, its format and language,
seconds, size).

## Data sources
Use source external_json with options.data_source set to the uuid; a list wants a rows
source. Use source calendar for an iCalendar feed. A connected source fetches on first
Expand Down
14 changes: 13 additions & 1 deletion app/Domains/Mcp/Tools/Screens/ListWidgetTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,19 @@ public function handle(Request $request): Response
}

return isset($widgets[$type])
? Response::json(['type' => $type, 'schema' => $widgets[$type], 'sources' => $sources[$type] ?? []])
? Response::json(['type' => $type, 'schema' => self::withoutIcons($widgets[$type]), 'sources' => $sources[$type] ?? []])
: Response::error('Unknown widget type; see list_widget_types without a type.');
}

/**
* A type's sections without the pictures its choices have for the designer (the QR
* library's SVGs): an agent picks by name and label.
*
* @param list<array{id: string, fields: list<array<string, mixed>>}> $sections
* @return list<array{id: string, fields: list<array<string, mixed>>}>
*/
private static function withoutIcons(array $sections): array
{
return array_map(fn (array $section): array => [...$section, 'fields' => array_map(fn (array $field): array => array_diff_key($field, ['icons' => true]), $section['fields'])], $sections);
}
}
3 changes: 3 additions & 0 deletions app/Domains/Mcp/Tools/Screens/UpdateScreen.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@ public function schema(JsonSchema $schema): array
'aspect' => $schema->string(),
'orientation' => $schema->string(),
'fit' => $schema->string(),
'margin' => $schema->string()->description('Room around the grid: none, s, m or l.'),
'gap' => $schema->string()->description('Room between widgets: none, s, m or l.'),
'show_header' => $schema->boolean(),
'show_clock' => $schema->boolean(),
'clock_format' => $schema->string()->description('24 or 12.'),
'header' => $schema->object()->description('{hide: [logo|name|team|projects|environment|period|attention|live], title: a title instead of the name or null, date: bool, seconds: bool, date_format: short|long|medium|numeric|iso|custom, date_pattern: tokens for custom (YYYY YY MMMM MMM MM M DD D dddd ddd, [literal text]), locale: null for the app\'s language, browser, or a tag such as da or en-GB, size: s|m|l|xl, how large the header is}: the clock\'s date and seconds.'),
'light_from' => $schema->string()->description('HH:MM.'),
'light_to' => $schema->string()->description('HH:MM.'),
'timezone' => $schema->string()->description('Null: each viewer\'s own.'),
Expand Down
2 changes: 1 addition & 1 deletion app/Domains/Mcp/Tools/Screens/UpdateScreenLayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class UpdateScreenLayout extends Tool

protected string $name = 'update_screen_layout';

protected string $description = 'Replaces a screen grid and all its widgets, live on every TV showing it. Send every widget you want to keep. Widgets may not overlap.';
protected string $description = 'Replaces a screen grid and all its widgets, live on every TV showing it. Send every widget you want to keep. Widgets may not overlap, but for those wholly inside a group (type group).';

public function __construct(
private readonly UpdateScreenLayoutAction $update,
Expand Down
101 changes: 101 additions & 0 deletions app/Domains/Projects/Actions/MoveProjectToTeamAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?php

declare(strict_types=1);

namespace App\Domains\Projects\Actions;

use App\Domains\Administration\Actions\RecordAdminAuditAction;
use App\Domains\Administration\Enums\AdminAction;
use App\Domains\Projects\Models\Project;
use App\Domains\Screens\Actions\SaveScreenAction;
use App\Domains\Screens\Data\WidgetScope;
use App\Domains\Screens\Models\Screen;
use App\Domains\Teams\Models\Team;
use App\Models\User;
use Illuminate\Support\Facades\DB;

/**
* Moves a project, with all its data, to another team. Telemetry and project settings
* carry only the project and go along; what tied it to the old team is let go: its
* screens, its team-wide alert rules and channels, MCP tokens, and people not in the new team.
*/
class MoveProjectToTeamAction
{
public function __construct(
private readonly SaveScreenAction $saveScreen,
private readonly RecordAdminAuditAction $audit,
) {
}

/**
* @param string $slug free in the target team (validated by the caller), as is $issuePrefix
*/
public function execute(Project $project, Team $target, string $slug, string $issuePrefix, User $by): Project
{
DB::transaction(function () use ($project, $target, $slug, $issuePrefix, $by): void {
$project = Project::query()->whereKey($project->id)->lockForUpdate()->firstOrFail();
$from = $project->team;

// Its own channels go with it; the old team's are no longer its to send to.
DB::table('notification_channels')->where('project_id', $project->id)->update(['team_id' => $target->id]);
$staleRules = DB::table('alert_rules')->where('team_id', $from->id)->select('id');
$staleChannels = DB::table('notification_channels')->where('team_id', $from->id)->select('id');
DB::table('project_alert_rule_channel')->where('project_id', $project->id)
->where(fn ($q) => $q->whereIn('alert_rule_id', $staleRules)->orWhereIn('notification_channel_id', $staleChannels))
->delete();
DB::table('alert_rule_notification_channel')
->where(fn ($q) => $q->whereIn('alert_rule_id', DB::table('alert_rules')->where('project_id', $project->id)->select('id'))->whereIn('notification_channel_id', $staleChannels))
->orWhere(fn ($q) => $q->whereIn('alert_rule_id', $staleRules)->whereIn('notification_channel_id', DB::table('notification_channels')->where('project_id', $project->id)->select('id')))
->delete();

// Tokens of the new team get no access by themselves.
DB::table('mcp_token_project')->where('project_id', $project->id)->delete();

$members = DB::table('team_user')->where('team_id', $target->id)->select('user_id');
$issues = DB::table('issues')->where('project_id', $project->id)->select('id');
DB::table('issues')->where('project_id', $project->id)->whereNotNull('assigned_user_id')->whereNotIn('assigned_user_id', $members)->update(['assigned_user_id' => null]);
DB::table('issue_watchers')->whereIn('issue_id', $issues)->whereNotIn('user_id', $members)->delete();

$this->removeFromScreens($project, $from);

$project->update(['team_id' => $target->id, 'slug' => $slug, 'issue_prefix' => $issuePrefix]);
$this->audit->execute($by, AdminAction::ProjectMoved, $project->name, ['project' => $project->uuid, 'from' => $from->name, 'to' => $target->name]);
});

$project->refresh()->setRelation('team', $target);

return $project;
}

/**
* Takes the project out of every scope of the old team's screens. A scope left with no
* project would mean every project of the team, so it keeps NO_PROJECT instead and shows
* nothing, as a widget pointing only outside its screen's projects already does.
*/
private function removeFromScreens(Project $project, Team $from): void
{
$uuid = $project->uuid;
$strip = function (mixed $scope) use ($uuid): mixed {
$projects = is_array($scope) ? (array) ($scope['projects'] ?? []) : [];

if (! in_array($uuid, $projects, true)) {
return $scope;
}

return [...$scope, 'projects' => array_values(array_diff($projects, [$uuid])) ?: [WidgetScope::NO_PROJECT]];
};

// A widget has a scope, and so may each value it rotates through.
$scoped = fn (mixed $item): mixed => is_array($item) && array_key_exists('scope', $item) ? [...$item, 'scope' => $strip($item['scope'])] : $item;

// A screen it is not on stays as it is: saving skips an unchanged one.
Screen::query()->where('team_id', $from->id)->get()->each(function (Screen $screen) use ($strip, $scoped): void {
$screen->scope = $strip($screen->scope);
$screen->widgets = array_map(fn (array $widget): array => [
...$scoped($widget),
...(is_array($widget['rotate'] ?? null) ? ['rotate' => array_map($scoped, $widget['rotate'])] : []),
], $screen->widgets);
$this->saveScreen->execute($screen);
});
}
}
13 changes: 13 additions & 0 deletions app/Domains/Projects/Http/Controllers/ProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@
use App\Domains\Issues\Models\Issue;
use App\Domains\Projects\Actions\CreateProjectAction;
use App\Domains\Projects\Actions\DeleteProjectAction;
use App\Domains\Projects\Actions\MoveProjectToTeamAction;
use App\Domains\Projects\Http\Requests\MoveProjectRequest;
use App\Domains\Projects\Http\Requests\StoreProjectRequest;
use App\Domains\Projects\Models\Project;
use App\Domains\Projects\Models\ProjectAgent;
use App\Domains\Shared\Enums\Period;
use App\Domains\Shared\Support\Percentiles;
use App\Domains\Shared\Support\TimeSeries;
use App\Domains\Teams\Models\Team;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
Expand Down Expand Up @@ -119,4 +122,14 @@ public function destroy(Request $request, Project $project, DeleteProjectAction

return redirect()->route('projects.index')->with('status', __('projects.deleted'));
}

public function move(MoveProjectRequest $request, Project $project, MoveProjectToTeamAction $action): RedirectResponse
{
/** @var Team $target validated */
$target = $request->target();
$action->execute($project, $target, $request->string('slug')->toString(), $request->string('issue_prefix')->toString(), $request->user());

// Opening it there makes the new team the current one (FollowProjectTeam).
return redirect()->route('projects.settings', $project)->with('status', __('projects.moved', ['team' => $target->name]));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
use App\Domains\Retention\Presenters\RetentionPresenter;
use App\Domains\Shared\Support\Scrubber;
use App\Domains\SourceMaps\Models\SourceMap;
use App\Domains\Teams\Models\Team;
use App\Models\User;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
Expand Down Expand Up @@ -107,6 +109,7 @@ public function edit(Request $request, Project $project, ProjectPresenter $prese
],
// One entry per agent provider; Claude is the first.
'triage' => [app(ClaudeTriageWorkflow::class)->describe($project, url('/'))],
'move_targets' => $this->moveTargets($request->user(), $project),
'repository' => $repository === null ? null : [
'provider' => $repository->provider->value,
'repository' => $repository->repository,
Expand All @@ -117,6 +120,36 @@ public function edit(Request $request, Project $project, ProjectPresenter $prese
]);
}

/**
* The teams the user may move the project to, each with the slug and issue prefix it
* would have there: its own, or with a number added where the team has them already.
*
* @return list<array{uuid: string, name: string, slug: string, issue_prefix: string}>
*/
private function moveTargets(User $user, Project $project): array
{
$teams = ($user->isAdmin() ? Team::query()->get() : $user->teams)
->filter(fn (Team $team): bool => $user->can('move', [$project, $team]))
->sortBy('name');
$taken = Project::query()->whereIn('team_id', $teams->modelKeys())->get(['team_id', 'slug', 'issue_prefix'])->groupBy('team_id');

return array_values($teams->map(function (Team $team) use ($project, $taken): array {
$projects = $taken->get($team->id, collect());
$slug = $project->slug;
$prefix = $project->issuePrefix();

for ($n = 2; $projects->contains('slug', $slug); $n++) {
$slug = $project->slug.'-'.$n;
}

for ($n = 2; $projects->contains('issue_prefix', $prefix); $n++) {
$prefix = mb_substr($project->issuePrefix(), 0, 8 - strlen((string) $n)).$n;
}

return ['uuid' => $team->uuid, 'name' => $team->name, 'slug' => $slug, 'issue_prefix' => $prefix];
})->all());
}

public function update(UpdateProjectRequest $request, Project $project, UpdateProjectAction $action): RedirectResponse
{
$action->execute(
Expand Down
61 changes: 61 additions & 0 deletions app/Domains/Projects/Http/Requests/MoveProjectRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

declare(strict_types=1);

namespace App\Domains\Projects\Http\Requests;

use App\Domains\Projects\Models\Project;
use App\Domains\Teams\Models\Team;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Str;
use Illuminate\Validation\Rule;

class MoveProjectRequest extends FormRequest
{
public function project(): Project
{
/** @var Project */
return $this->route('project');
}

/** The team it moves to; null when there is none by that uuid, which validation reports. */
public function target(): ?Team
{
$uuid = (string) $this->input('team');

return once(fn (): ?Team => Str::isUuid($uuid) ? Team::query()->where('uuid', $uuid)->first() : null);
}

public function authorize(): bool
{
$target = $this->target();

return $target === null
? $this->user()?->can('update', $this->project()) ?? false
: $this->user()?->can('move', [$this->project(), $target]) ?? false;
}

protected function prepareForValidation(): void
{
$this->merge(['issue_prefix' => strtoupper(trim((string) $this->input('issue_prefix')))]);
}

/** @return array<string, string> */
public function messages(): array
{
return ['issue_prefix.regex' => __('projects.issue_prefix_invalid')];
}

/** @return array<string, mixed> */
public function rules(): array
{
$teamId = $this->target()?->id;

return [
'team' => ['bail', 'required', 'uuid', Rule::exists('teams', 'uuid')],
// Free in the team it moves to, as on creating one there.
'slug' => ['required', 'string', 'max:100', 'alpha_dash:ascii', Rule::unique('projects', 'slug')->where('team_id', $teamId)],
'issue_prefix' => ['required', 'string', 'min:2', 'max:8', 'regex:/^[A-Z][A-Z0-9]*$/', Rule::unique('projects', 'issue_prefix')->where('team_id', $teamId)],
];
}
}
9 changes: 9 additions & 0 deletions app/Domains/Projects/Policies/ProjectPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Domains\Projects\Policies;

use App\Domains\Projects\Models\Project;
use App\Domains\Teams\Models\Team;
use App\Models\User;

class ProjectPolicy
Expand All @@ -26,4 +27,12 @@ public function delete(User $user, Project $project): bool
{
return $user->canAdministerTeam($project->team);
}

/**
* Moving to another team takes administering both.
*/
public function move(User $user, Project $project, Team $target): bool
{
return $target->id !== $project->team_id && $user->canAdministerTeam($project->team) && $user->canAdministerTeam($target);
}
}
Loading
Loading