Profilseite: Kommentare der Person
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 3m41s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 3m32s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 4m11s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 3m55s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 5m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 5m30s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 4m39s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 4m30s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m3s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 3m41s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 3m32s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 4m11s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 3m55s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 5m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 5m30s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 4m39s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 4m30s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m3s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
53df8918f6
commit
8a59023569
118 changed files with 620 additions and 438 deletions
|
|
@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
|||
|
||||
use App\Http\Resources\PersonResource;
|
||||
use App\Models\User;
|
||||
use App\Profile\ProfilePanels;
|
||||
use App\Search\GlobalSearch;
|
||||
use App\Support\ContactCards;
|
||||
use App\Support\ProfileFields;
|
||||
|
|
@ -134,6 +135,8 @@ class PeopleController extends Controller
|
|||
'reports' => PersonResource::collection($user->reports()->active()->orderBy('name')->limit(12)->get())->resolve(),
|
||||
],
|
||||
'isOwnProfile' => $user->is(auth()->user()),
|
||||
// Bereiche aus Plugins, z. B. Kommentare aus den Neuigkeiten
|
||||
'panels' => app(ProfilePanels::class)->resolve($user, auth()->user()),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
57
app/Profile/ProfilePanels.php
Normal file
57
app/Profile/ProfilePanels.php
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
namespace App\Profile;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Plugins\PluginAccess;
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Zusätzliche Bereiche auf der Profilseite einer Person (/personen/{id}),
|
||||
* beigesteuert von Plugins – z. B. „Kommentare“ aus den Neuigkeiten.
|
||||
* Die Vue-Komponente liegt unter plugins-core/<plugin>/resources/js/profile-panels/<Name>.vue
|
||||
* („<plugin>::Name“).
|
||||
*/
|
||||
class ProfilePanels
|
||||
{
|
||||
/** @var array<string, array{component: string, sort: int, props: Closure}> */
|
||||
private array $panels = [];
|
||||
|
||||
/**
|
||||
* @param Closure(User $person, User $viewer): (array<string, mixed>|null) $props null = nicht zeigen
|
||||
*/
|
||||
public function add(string $key, string $component, int $sort, Closure $props): void
|
||||
{
|
||||
$this->panels[$key] = compact('component', 'sort', 'props');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{key: string, component: string, props: array<string, mixed>}>
|
||||
*/
|
||||
public function resolve(User $person, User $viewer): array
|
||||
{
|
||||
$result = [];
|
||||
|
||||
foreach (collect($this->panels)->sortBy('sort') as $key => $panel) {
|
||||
if (! app(PluginAccess::class)->allows($key, $viewer)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
$props = ($panel['props'])($person, $viewer);
|
||||
} catch (Throwable $e) {
|
||||
Log::error("Profilbereich {$key} fehlgeschlagen: ".$e->getMessage());
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($props !== null) {
|
||||
$result[] = ['key' => $key, 'component' => $panel['component'], 'props' => $props];
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ use App\Dashboard\Widgets;
|
|||
use App\Plugins\Hooks;
|
||||
use App\Plugins\PluginManager;
|
||||
use App\Plugins\PluginState;
|
||||
use App\Profile\ProfilePanels;
|
||||
use App\Profile\ProfileSections;
|
||||
use App\Support\Abilities;
|
||||
use App\Support\Navigation;
|
||||
|
|
@ -26,6 +27,7 @@ class PluginServiceProvider extends ServiceProvider
|
|||
$this->app->singleton(Widgets::class);
|
||||
$this->app->singleton(Abilities::class);
|
||||
$this->app->singleton(ProfileSections::class);
|
||||
$this->app->singleton(ProfilePanels::class);
|
||||
|
||||
$this->app->make(PluginManager::class)->registerAll();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,5 +9,5 @@ namespace App;
|
|||
*/
|
||||
final class Version
|
||||
{
|
||||
public const VERSION = '0.19.0';
|
||||
public const VERSION = '0.19.1';
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue