with pagination nwo with the proper view selection
This commit is contained in:
@@ -29,6 +29,11 @@ class ModuleStatus extends Model
|
||||
'description',
|
||||
'version',
|
||||
'sort_order',
|
||||
'icon',
|
||||
'category',
|
||||
'vendor_type',
|
||||
'author',
|
||||
'notes',
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,6 +9,7 @@ use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\View\View;
|
||||
use mpba\Modules\Support\DatabaseModuleRegistry;
|
||||
use RuntimeException;
|
||||
|
||||
class ModuleControlController extends Controller
|
||||
{
|
||||
@@ -19,24 +20,18 @@ class ModuleControlController extends Controller
|
||||
public function index(Request $request): View
|
||||
{
|
||||
$search = trim((string) $request->query('search', ''));
|
||||
$status = (string) $request->query('status', 'all');
|
||||
$status = in_array($status, ['all', 'enabled', 'disabled'], true) ? $status : 'all';
|
||||
$filter = (string) $request->query('filter', $request->query('status', 'all'));
|
||||
$filter = in_array($filter, ['all', 'enabled', 'disabled', 'core', 'optional', 'mpba', 'third-party', 'updates', 'missing-dependencies'], true) ? $filter : 'all';
|
||||
$sort = (string) $request->query('sort', 'order');
|
||||
$sort = in_array($sort, ['order', 'name', 'status', 'version', 'updated'], true) ? $sort : 'order';
|
||||
$perPage = 4;
|
||||
$page = max(1, (int) $request->query('page', 1));
|
||||
|
||||
$allModules = $this->registry->all();
|
||||
$filteredModules = $this->applyFilter($allModules, $filter);
|
||||
|
||||
$filteredModules = $allModules;
|
||||
|
||||
if ($status === 'enabled') {
|
||||
$filteredModules = $filteredModules->where('enabled', true)->values();
|
||||
} elseif ($status === 'disabled') {
|
||||
$filteredModules = $filteredModules->where('enabled', false)->values();
|
||||
}
|
||||
|
||||
$filteredModules = $search === ''
|
||||
? $filteredModules
|
||||
: $filteredModules->filter(function (array $module) use ($search): bool {
|
||||
if ($search !== '') {
|
||||
$filteredModules = $filteredModules->filter(function (array $module) use ($search): bool {
|
||||
$haystack = implode(' ', array_filter([
|
||||
$module['name'] ?? null,
|
||||
$module['alias'] ?? null,
|
||||
@@ -45,11 +40,18 @@ class ModuleControlController extends Controller
|
||||
$module['version'] ?? null,
|
||||
$module['database_version'] ?? null,
|
||||
$module['disk_version'] ?? null,
|
||||
$module['category'] ?? null,
|
||||
$module['vendor_type'] ?? null,
|
||||
$module['author'] ?? null,
|
||||
$module['composer_name'] ?? null,
|
||||
$module['path'] ?? null,
|
||||
]));
|
||||
|
||||
return Str::contains(Str::lower($haystack), Str::lower($search));
|
||||
})->values();
|
||||
}
|
||||
|
||||
$filteredModules = $this->applySort($filteredModules, $sort);
|
||||
|
||||
$modules = new LengthAwarePaginator(
|
||||
$filteredModules->forPage($page, $perPage)->values(),
|
||||
@@ -67,7 +69,10 @@ class ModuleControlController extends Controller
|
||||
'allModules' => $allModules,
|
||||
'filteredCount' => $filteredModules->count(),
|
||||
'search' => $search,
|
||||
'status' => $status,
|
||||
'filter' => $filter,
|
||||
'status' => $filter,
|
||||
'sort' => $sort,
|
||||
'stats' => $this->stats($allModules),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -84,6 +89,11 @@ class ModuleControlController extends Controller
|
||||
'description' => ['nullable', 'string', 'max:2000'],
|
||||
'version' => ['nullable', 'string', 'max:50'],
|
||||
'sort_order' => ['nullable', 'integer', 'min:0', 'max:999999'],
|
||||
'icon' => ['nullable', 'string', 'max:80'],
|
||||
'category' => ['nullable', 'string', 'max:80'],
|
||||
'vendor_type' => ['nullable', 'string', 'max:80'],
|
||||
'author' => ['nullable', 'string', 'max:120'],
|
||||
'notes' => ['nullable', 'string', 'max:5000'],
|
||||
]);
|
||||
|
||||
$this->registry->update($module, $data);
|
||||
@@ -102,21 +112,84 @@ class ModuleControlController extends Controller
|
||||
->with('status', 'Module database statuses synced.');
|
||||
}
|
||||
|
||||
public function bulk(Request $request): RedirectResponse
|
||||
{
|
||||
$data = $request->validate([
|
||||
'action' => ['required', 'in:enable,disable'],
|
||||
'modules' => ['array'],
|
||||
'modules.*' => ['string'],
|
||||
]);
|
||||
|
||||
$result = $this->registry->bulk($data['action'], $data['modules'] ?? []);
|
||||
$message = $result['changed'].' module'.($result['changed'] === 1 ? '' : 's').' updated.';
|
||||
|
||||
if ($result['blocked'] !== []) {
|
||||
return back()
|
||||
->with('warning', $message.' Some modules were blocked: '.implode(' ', $result['blocked']));
|
||||
}
|
||||
|
||||
return back()->with('status', $message);
|
||||
}
|
||||
|
||||
public function enable(string $module): RedirectResponse
|
||||
{
|
||||
$this->registry->enable($module);
|
||||
|
||||
return redirect()
|
||||
->route('modules.control.index')
|
||||
->with('status', "{$module} enabled in the database.");
|
||||
return back()->with('status', "{$module} enabled in the database.");
|
||||
}
|
||||
|
||||
public function disable(string $module): RedirectResponse
|
||||
{
|
||||
$this->registry->disable($module);
|
||||
try {
|
||||
$this->registry->disable($module);
|
||||
} catch (RuntimeException $exception) {
|
||||
return back()->with('warning', $exception->getMessage());
|
||||
}
|
||||
|
||||
return redirect()
|
||||
->route('modules.control.index')
|
||||
->with('status', "{$module} disabled in the database.");
|
||||
return back()->with('status', "{$module} disabled in the database.");
|
||||
}
|
||||
|
||||
protected function applyFilter($modules, string $filter)
|
||||
{
|
||||
return match ($filter) {
|
||||
'enabled' => $modules->where('enabled', true)->values(),
|
||||
'disabled' => $modules->where('enabled', false)->values(),
|
||||
'core' => $modules->filter(fn (array $module): bool => strcasecmp((string) $module['category'], 'Core') === 0)->values(),
|
||||
'optional' => $modules->filter(fn (array $module): bool => strcasecmp((string) $module['category'], 'Optional') === 0)->values(),
|
||||
'mpba' => $modules->filter(fn (array $module): bool => strcasecmp((string) $module['vendor_type'], 'MPBA') === 0)->values(),
|
||||
'third-party' => $modules->filter(fn (array $module): bool => strcasecmp((string) $module['vendor_type'], 'Third-party') === 0)->values(),
|
||||
'updates' => $modules->where('has_update', true)->values(),
|
||||
'missing-dependencies' => $modules->where('has_missing_dependencies', true)->values(),
|
||||
default => $modules->values(),
|
||||
};
|
||||
}
|
||||
|
||||
protected function applySort($modules, string $sort)
|
||||
{
|
||||
return match ($sort) {
|
||||
'name' => $modules->sortBy('name')->values(),
|
||||
'status' => $modules->sortByDesc('enabled')->values(),
|
||||
'version' => $modules->sortBy('version')->values(),
|
||||
'updated' => $modules->sortByDesc(fn (array $module) => $module['updated_at']?->timestamp ?? 0)->values(),
|
||||
default => $modules->sortBy([
|
||||
fn (array $module) => $module['sort_order'],
|
||||
fn (array $module) => $module['name'],
|
||||
])->values(),
|
||||
};
|
||||
}
|
||||
|
||||
protected function stats($modules): array
|
||||
{
|
||||
return [
|
||||
'installed' => $modules->count(),
|
||||
'enabled' => $modules->where('enabled', true)->count(),
|
||||
'disabled' => $modules->where('enabled', false)->count(),
|
||||
'updates' => $modules->where('has_update', true)->count(),
|
||||
'missing' => $modules->where('has_missing_dependencies', true)->count(),
|
||||
'core' => $modules->filter(fn (array $module): bool => strcasecmp((string) $module['category'], 'Core') === 0)->count(),
|
||||
'optional' => $modules->filter(fn (array $module): bool => strcasecmp((string) $module['category'], 'Optional') === 0)->count(),
|
||||
'mpba' => $modules->filter(fn (array $module): bool => strcasecmp((string) $module['vendor_type'], 'MPBA') === 0)->count(),
|
||||
'third_party' => $modules->filter(fn (array $module): bool => strcasecmp((string) $module['vendor_type'], 'Third-party') === 0)->count(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,15 +2,20 @@
|
||||
|
||||
namespace mpba\Modules\Support;
|
||||
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Str;
|
||||
use mpba\Modules\Contracts\RepositoryInterface;
|
||||
use mpba\Modules\DevelopmentSupport\Entities\ModuleStatus;
|
||||
use mpba\Modules\Module;
|
||||
use RuntimeException;
|
||||
|
||||
class DatabaseModuleRegistry
|
||||
{
|
||||
public function __construct(
|
||||
protected RepositoryInterface $modules,
|
||||
protected Filesystem $files,
|
||||
) {}
|
||||
|
||||
public function all(): Collection
|
||||
@@ -21,10 +26,10 @@ class DatabaseModuleRegistry
|
||||
->get()
|
||||
->keyBy('module');
|
||||
|
||||
return collect($this->modules->all())
|
||||
->map(function (Module $module) use ($statuses): array {
|
||||
return $this->mapModule($module, $statuses->get($module->getName()));
|
||||
})
|
||||
$mapped = collect($this->modules->all())
|
||||
->map(fn (Module $module): array => $this->mapModule($module, $statuses->get($module->getName())));
|
||||
|
||||
return $mapped
|
||||
->sortBy([
|
||||
fn (array $module) => $module['sort_order'],
|
||||
fn (array $module) => $module['name'],
|
||||
@@ -43,26 +48,35 @@ class DatabaseModuleRegistry
|
||||
[
|
||||
'enabled' => $module->isEnabled(),
|
||||
'version' => $this->moduleVersion($module),
|
||||
'description' => $this->safeDescription($module),
|
||||
'icon' => $this->defaultIcon($module),
|
||||
'category' => $this->defaultCategory($module),
|
||||
'vendor_type' => $this->defaultVendorType($module),
|
||||
'author' => $this->author($module),
|
||||
'sort_order' => (int) $module->get('order', 0),
|
||||
]
|
||||
);
|
||||
|
||||
return $this->mapModule($module, $status);
|
||||
return $this->mapModule($module, $status, true);
|
||||
}
|
||||
|
||||
public function update(string $name, array $data): void
|
||||
{
|
||||
$module = $this->modules->findOrFail($name);
|
||||
$existing = ModuleStatus::query()->firstWhere('module', $module->getName());
|
||||
|
||||
ModuleStatus::query()->updateOrCreate(
|
||||
['module' => $module->getName()],
|
||||
[
|
||||
'enabled' => ModuleStatus::query()
|
||||
->where('module', $module->getName())
|
||||
->value('enabled') ?? $module->isEnabled(),
|
||||
'enabled' => $existing?->enabled ?? $module->isEnabled(),
|
||||
'description' => $data['description'] ?? null,
|
||||
'version' => $data['version'] ?? null,
|
||||
'sort_order' => (int) ($data['sort_order'] ?? 0),
|
||||
'icon' => $data['icon'] ?? null,
|
||||
'category' => $data['category'] ?? null,
|
||||
'vendor_type' => $data['vendor_type'] ?? null,
|
||||
'author' => $data['author'] ?? null,
|
||||
'notes' => $data['notes'] ?? null,
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -75,7 +89,13 @@ class DatabaseModuleRegistry
|
||||
['module' => $module->getName()],
|
||||
[
|
||||
'enabled' => true,
|
||||
'sort_order' => (int) $module->get('order', 0),
|
||||
'description' => ModuleStatus::query()->where('module', $module->getName())->value('description') ?? $this->safeDescription($module),
|
||||
'version' => ModuleStatus::query()->where('module', $module->getName())->value('version') ?? $this->moduleVersion($module),
|
||||
'icon' => ModuleStatus::query()->where('module', $module->getName())->value('icon') ?? $this->defaultIcon($module),
|
||||
'category' => ModuleStatus::query()->where('module', $module->getName())->value('category') ?? $this->defaultCategory($module),
|
||||
'vendor_type' => ModuleStatus::query()->where('module', $module->getName())->value('vendor_type') ?? $this->defaultVendorType($module),
|
||||
'author' => ModuleStatus::query()->where('module', $module->getName())->value('author') ?? $this->author($module),
|
||||
'sort_order' => ModuleStatus::query()->where('module', $module->getName())->value('sort_order') ?? (int) $module->get('order', 0),
|
||||
]
|
||||
);
|
||||
|
||||
@@ -85,18 +105,45 @@ class DatabaseModuleRegistry
|
||||
public function disable(string $name): void
|
||||
{
|
||||
$module = $this->modules->findOrFail($name);
|
||||
$blocking = $this->enabledDependents($module->getName());
|
||||
|
||||
if ($blocking !== []) {
|
||||
throw new RuntimeException($module->getName().' cannot be disabled because it is required by: '.implode(', ', $blocking).'.');
|
||||
}
|
||||
|
||||
ModuleStatus::query()->updateOrCreate(
|
||||
['module' => $module->getName()],
|
||||
[
|
||||
'enabled' => false,
|
||||
'sort_order' => (int) $module->get('order', 0),
|
||||
'sort_order' => ModuleStatus::query()->where('module', $module->getName())->value('sort_order') ?? (int) $module->get('order', 0),
|
||||
]
|
||||
);
|
||||
|
||||
$this->modules->disable($module->getName());
|
||||
}
|
||||
|
||||
public function bulk(string $action, array $names): array
|
||||
{
|
||||
$changed = 0;
|
||||
$blocked = [];
|
||||
|
||||
foreach (array_unique(array_filter($names)) as $name) {
|
||||
try {
|
||||
if ($action === 'enable') {
|
||||
$this->enable($name);
|
||||
$changed++;
|
||||
} elseif ($action === 'disable') {
|
||||
$this->disable($name);
|
||||
$changed++;
|
||||
}
|
||||
} catch (RuntimeException $exception) {
|
||||
$blocked[] = $exception->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
return ['changed' => $changed, 'blocked' => $blocked];
|
||||
}
|
||||
|
||||
public function syncMissingStatuses(): void
|
||||
{
|
||||
foreach ($this->modules->all() as $module) {
|
||||
@@ -104,42 +151,292 @@ class DatabaseModuleRegistry
|
||||
['module' => $module->getName()],
|
||||
[
|
||||
'enabled' => $module->isEnabled(),
|
||||
'description' => $this->safeDescription($module),
|
||||
'version' => $this->moduleVersion($module),
|
||||
'icon' => $this->defaultIcon($module),
|
||||
'category' => $this->defaultCategory($module),
|
||||
'vendor_type' => $this->defaultVendorType($module),
|
||||
'author' => $this->author($module),
|
||||
'sort_order' => (int) $module->get('order', 0),
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
protected function mapModule(Module $module, ?ModuleStatus $status): array
|
||||
protected function mapModule(Module $module, ?ModuleStatus $status, bool $withDetails = false): array
|
||||
{
|
||||
return [
|
||||
$requires = $this->safeRequires($module);
|
||||
$diskVersion = $this->moduleVersion($module);
|
||||
$databaseVersion = $this->databaseVersion($status);
|
||||
$composer = $this->composerData($module);
|
||||
$missingDependencies = $this->missingDependencies($requires);
|
||||
$enabledDependents = $this->enabledDependents($module->getName());
|
||||
|
||||
$mapped = [
|
||||
'name' => $module->getName(),
|
||||
'alias' => $module->getAlias(),
|
||||
'description' => $status?->description,
|
||||
'disk_description' => $module->getDescription(),
|
||||
'version' => $this->databaseVersion($status) ?? $this->moduleVersion($module),
|
||||
'database_version' => $this->databaseVersion($status),
|
||||
'disk_version' => $this->moduleVersion($module),
|
||||
'alias' => $this->safeString($module->get('alias', Str::kebab($module->getName()))),
|
||||
'description' => $this->databaseDescription($status) ?? $this->safeDescription($module),
|
||||
'database_description' => $this->databaseDescription($status),
|
||||
'disk_description' => $this->safeDescription($module),
|
||||
'version' => $databaseVersion ?? $diskVersion,
|
||||
'database_version' => $databaseVersion,
|
||||
'disk_version' => $diskVersion,
|
||||
'has_update' => $this->hasUpdate($databaseVersion, $diskVersion),
|
||||
'icon' => $this->databaseString($status?->icon) ?? $this->defaultIcon($module),
|
||||
'category' => $this->databaseString($status?->category) ?? $this->defaultCategory($module),
|
||||
'vendor_type' => $this->databaseString($status?->vendor_type) ?? $this->defaultVendorType($module),
|
||||
'author' => $this->databaseString($status?->author) ?? $this->author($module),
|
||||
'notes' => $status?->notes,
|
||||
'sort_order' => (int) ($status?->sort_order ?? $module->get('order', 0)),
|
||||
'path' => $module->getPath(),
|
||||
'requires' => $module->getRequires(),
|
||||
'requires' => $requires,
|
||||
'missing_dependencies' => $missingDependencies,
|
||||
'has_missing_dependencies' => $missingDependencies !== [],
|
||||
'enabled_dependents' => $enabledDependents,
|
||||
'can_disable' => $enabledDependents === [],
|
||||
'enabled' => (bool) ($status?->enabled ?? $module->isEnabled()),
|
||||
'status_record' => $status,
|
||||
'updated_at' => $status?->updated_at,
|
||||
'composer_name' => $composer['name'] ?? null,
|
||||
'composer_description' => $composer['description'] ?? null,
|
||||
'namespace' => $this->namespace($module),
|
||||
'git_commit' => $this->gitCommit($module),
|
||||
'build_date' => $this->buildDate($module),
|
||||
'module' => $module,
|
||||
];
|
||||
|
||||
if ($withDetails) {
|
||||
$mapped += $this->inspect($module);
|
||||
}
|
||||
|
||||
return $mapped;
|
||||
}
|
||||
|
||||
protected function inspect(Module $module): array
|
||||
{
|
||||
$path = $module->getPath();
|
||||
|
||||
return [
|
||||
'readme' => $this->readFirstExisting($path, ['README.md', 'readme.md'], 7000),
|
||||
'changelog' => $this->readFirstExisting($path, ['CHANGELOG.md', 'changelog.md', 'changelog.yaml'], 7000),
|
||||
'routes' => $this->filesUnder($path, ['Routes/*.php', 'routes/*.php']),
|
||||
'migrations' => $this->filesUnder($path, ['Database/Migrations/*.php', 'database/migrations/*.php']),
|
||||
'models' => $this->filesUnder($path, ['app/Models/*.php', 'Models/*.php', 'Entities/*.php', 'app/Entities/*.php']),
|
||||
'controllers' => $this->filesUnder($path, ['app/Http/Controllers/*.php', 'Http/Controllers/*.php']),
|
||||
'providers' => $this->filesUnder($path, ['app/Providers/*.php', 'Providers/*.php']),
|
||||
];
|
||||
}
|
||||
|
||||
protected function filesUnder(string $path, array $patterns): array
|
||||
{
|
||||
$files = [];
|
||||
|
||||
foreach ($patterns as $pattern) {
|
||||
foreach ($this->files->glob($path.'/'.$pattern) ?: [] as $file) {
|
||||
$files[] = str_replace($path.'/', '', $file);
|
||||
}
|
||||
}
|
||||
|
||||
return array_values(array_unique($files));
|
||||
}
|
||||
|
||||
protected function readFirstExisting(string $path, array $files, int $limit): ?string
|
||||
{
|
||||
foreach ($files as $file) {
|
||||
$candidate = $path.'/'.$file;
|
||||
|
||||
if ($this->files->exists($candidate)) {
|
||||
return Str::limit($this->files->get($candidate), $limit, "\n...");
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function enabledDependents(string $name): array
|
||||
{
|
||||
$dependents = [];
|
||||
$statuses = ModuleStatus::query()->get()->keyBy('module');
|
||||
|
||||
foreach ($this->modules->all() as $candidate) {
|
||||
if ($candidate->getName() === $name) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$status = $statuses->get($candidate->getName());
|
||||
$enabled = (bool) ($status?->enabled ?? $candidate->isEnabled());
|
||||
|
||||
if ($enabled && in_array($name, $this->safeRequires($candidate), true)) {
|
||||
$dependents[] = $candidate->getName();
|
||||
}
|
||||
}
|
||||
|
||||
sort($dependents);
|
||||
|
||||
return $dependents;
|
||||
}
|
||||
|
||||
protected function missingDependencies(array $requires): array
|
||||
{
|
||||
if ($requires === []) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$installed = collect($this->modules->all())
|
||||
->map(fn (Module $module): string => $module->getName())
|
||||
->all();
|
||||
|
||||
return array_values(array_diff($requires, $installed));
|
||||
}
|
||||
|
||||
protected function hasUpdate(?string $databaseVersion, ?string $diskVersion): bool
|
||||
{
|
||||
if (! $databaseVersion || ! $diskVersion) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return version_compare($diskVersion, $databaseVersion, '>');
|
||||
}
|
||||
|
||||
protected function databaseVersion(?ModuleStatus $status): ?string
|
||||
{
|
||||
$version = $status?->version;
|
||||
return $this->databaseString($status?->version);
|
||||
}
|
||||
|
||||
return is_string($version) && trim($version) !== '' ? trim($version) : null;
|
||||
protected function databaseDescription(?ModuleStatus $status): ?string
|
||||
{
|
||||
return $this->databaseString($status?->description);
|
||||
}
|
||||
|
||||
protected function moduleVersion(Module $module): ?string
|
||||
{
|
||||
$version = $module->get('version');
|
||||
|
||||
return is_string($version) && $version !== '' ? $version : null;
|
||||
return is_string($version) && trim($version) !== '' ? trim($version) : null;
|
||||
}
|
||||
|
||||
protected function safeDescription(Module $module): ?string
|
||||
{
|
||||
$description = $module->get('description');
|
||||
|
||||
return is_string($description) && trim($description) !== '' ? trim($description) : null;
|
||||
}
|
||||
|
||||
protected function safeRequires(Module $module): array
|
||||
{
|
||||
$requires = $module->get('requires', []);
|
||||
|
||||
return is_array($requires) ? array_values(array_filter($requires)) : [];
|
||||
}
|
||||
|
||||
protected function defaultIcon(Module $module): string
|
||||
{
|
||||
$icons = [
|
||||
'Analytics' => 'fa-chart-line',
|
||||
'Audit' => 'fa-clipboard-check',
|
||||
'AuditTrail' => 'fa-clipboard-list',
|
||||
'CarrierManagement' => 'fa-route',
|
||||
'ChatGPT' => 'fa-robot',
|
||||
'Configuration' => 'fa-sliders',
|
||||
'Countries' => 'fa-globe',
|
||||
'Documentation' => 'fa-book-open',
|
||||
'Helpdesk' => 'fa-headset',
|
||||
'InventoryManagement' => 'fa-boxes-stacked',
|
||||
'Platform' => 'fa-building-shield',
|
||||
'Pricing' => 'fa-tags',
|
||||
'Security' => 'fa-user-shield',
|
||||
'Warehouse' => 'fa-warehouse',
|
||||
];
|
||||
|
||||
return $icons[$module->getName()] ?? 'fa-puzzle-piece';
|
||||
}
|
||||
|
||||
protected function defaultCategory(Module $module): string
|
||||
{
|
||||
return in_array($module->getName(), ['Platform', 'Security', 'Configuration', 'InternalApi'], true) ? 'Core' : 'Optional';
|
||||
}
|
||||
|
||||
protected function defaultVendorType(Module $module): string
|
||||
{
|
||||
$composer = $this->composerData($module);
|
||||
$name = $composer['name'] ?? '';
|
||||
|
||||
return Str::startsWith($name, 'mpba/') || $name === '' ? 'MPBA' : 'Third-party';
|
||||
}
|
||||
|
||||
protected function author(Module $module): ?string
|
||||
{
|
||||
$authors = $this->composerData($module)['authors'] ?? null;
|
||||
|
||||
if (is_array($authors) && isset($authors[0]['name'])) {
|
||||
return $authors[0]['name'];
|
||||
}
|
||||
|
||||
return 'MPBA';
|
||||
}
|
||||
|
||||
protected function namespace(Module $module): ?string
|
||||
{
|
||||
$autoload = $this->composerData($module)['autoload']['psr-4'] ?? null;
|
||||
|
||||
if (is_array($autoload)) {
|
||||
return array_key_first($autoload);
|
||||
}
|
||||
|
||||
return 'Modules\\'.$module->getName().'\\';
|
||||
}
|
||||
|
||||
protected function composerData(Module $module): array
|
||||
{
|
||||
$path = $module->getPath().'/composer.json';
|
||||
|
||||
if (! $this->files->exists($path)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$data = json_decode($this->files->get($path), true);
|
||||
|
||||
return is_array($data) ? $data : [];
|
||||
}
|
||||
|
||||
protected function gitCommit(Module $module): ?string
|
||||
{
|
||||
$head = base_path('.git/HEAD');
|
||||
|
||||
if (! $this->files->exists($head)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$content = trim($this->files->get($head));
|
||||
|
||||
if (Str::startsWith($content, 'ref: ')) {
|
||||
$ref = trim(Str::after($content, 'ref: '));
|
||||
$refPath = base_path('.git/'.$ref);
|
||||
|
||||
if ($this->files->exists($refPath)) {
|
||||
return substr(trim($this->files->get($refPath)), 0, 12);
|
||||
}
|
||||
}
|
||||
|
||||
return substr($content, 0, 12) ?: null;
|
||||
}
|
||||
|
||||
protected function buildDate(Module $module): ?string
|
||||
{
|
||||
$path = $module->getPath().'/module.json';
|
||||
|
||||
return $this->files->exists($path)
|
||||
? date('Y-m-d H:i', $this->files->lastModified($path))
|
||||
: null;
|
||||
}
|
||||
|
||||
protected function databaseString(?string $value): ?string
|
||||
{
|
||||
return is_string($value) && trim($value) !== '' ? trim($value) : null;
|
||||
}
|
||||
|
||||
protected function safeString(?string $value): string
|
||||
{
|
||||
return is_string($value) ? $value : '';
|
||||
}
|
||||
}
|
||||
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('module_statuses', function (Blueprint $table): void {
|
||||
if (! Schema::hasColumn('module_statuses', 'icon')) {
|
||||
$table->string('icon')->nullable()->after('version');
|
||||
}
|
||||
|
||||
if (! Schema::hasColumn('module_statuses', 'category')) {
|
||||
$table->string('category')->nullable()->after('icon');
|
||||
}
|
||||
|
||||
if (! Schema::hasColumn('module_statuses', 'vendor_type')) {
|
||||
$table->string('vendor_type')->nullable()->after('category');
|
||||
}
|
||||
|
||||
if (! Schema::hasColumn('module_statuses', 'author')) {
|
||||
$table->string('author')->nullable()->after('vendor_type');
|
||||
}
|
||||
|
||||
if (! Schema::hasColumn('module_statuses', 'notes')) {
|
||||
$table->text('notes')->nullable()->after('author');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('module_statuses', function (Blueprint $table): void {
|
||||
foreach (['notes', 'author', 'vendor_type', 'category', 'icon'] as $column) {
|
||||
if (Schema::hasColumn('module_statuses', $column)) {
|
||||
$table->dropColumn($column);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
+224
-172
@@ -2,94 +2,129 @@
|
||||
<x-dynamic-component
|
||||
:component="config('modules.admin.hero_component', 'wms.page-hero')"
|
||||
title="Module Control"
|
||||
subtitle="Control installed modules from the database-backed module registry."
|
||||
subtitle="Manage installed modules, database metadata, dependencies and activation state."
|
||||
/>
|
||||
|
||||
@php
|
||||
$enabledCount = $allModules->where('enabled', true)->count();
|
||||
$disabledCount = $allModules->count() - $enabledCount;
|
||||
$filterCards = [
|
||||
['key' => 'all', 'label' => 'Installed', 'value' => $stats['installed'], 'icon' => 'fa-puzzle-piece', 'tone' => 'blue', 'hint' => 'All modules'],
|
||||
['key' => 'enabled', 'label' => 'Enabled', 'value' => $stats['enabled'], 'icon' => 'fa-circle-check', 'tone' => 'emerald', 'hint' => 'Active modules'],
|
||||
['key' => 'disabled', 'label' => 'Disabled', 'value' => $stats['disabled'], 'icon' => 'fa-circle-pause', 'tone' => 'red', 'hint' => 'Inactive modules'],
|
||||
['key' => 'updates', 'label' => 'Updates Available', 'value' => $stats['updates'], 'icon' => 'fa-arrow-up-from-bracket', 'tone' => 'amber', 'hint' => 'Disk version newer'],
|
||||
['key' => 'missing-dependencies', 'label' => 'Dependencies Missing', 'value' => $stats['missing'], 'icon' => 'fa-triangle-exclamation', 'tone' => 'orange', 'hint' => 'Requires attention'],
|
||||
];
|
||||
|
||||
$secondaryFilters = [
|
||||
'core' => 'Core',
|
||||
'optional' => 'Optional',
|
||||
'mpba' => 'Installed by MPBA',
|
||||
'third-party' => 'Third-party',
|
||||
];
|
||||
|
||||
$toneClasses = [
|
||||
'blue' => 'border-blue-500/40 bg-blue-500/10 text-blue-700 dark:text-blue-300',
|
||||
'emerald' => 'border-emerald-500/40 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300',
|
||||
'red' => 'border-red-500/40 bg-red-500/10 text-red-700 dark:text-red-300',
|
||||
'amber' => 'border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-300',
|
||||
'orange' => 'border-orange-500/40 bg-orange-500/10 text-orange-700 dark:text-orange-300',
|
||||
];
|
||||
@endphp
|
||||
|
||||
<div class="space-y-6">
|
||||
@if (session('status'))
|
||||
<div class="rounded-xl border border-emerald-500/30 bg-emerald-500/10 px-4 py-3 text-sm font-medium text-emerald-800 dark:text-emerald-200">
|
||||
{{ session('status') }}
|
||||
</div>
|
||||
@endif
|
||||
@foreach (['status' => 'emerald', 'warning' => 'amber', 'error' => 'red'] as $flash => $tone)
|
||||
@if (session($flash))
|
||||
<div class="rounded-2xl border px-4 py-3 text-sm font-medium {{ $toneClasses[$tone] ?? $toneClasses['blue'] }}">
|
||||
{{ session($flash) }}
|
||||
</div>
|
||||
@endif
|
||||
@endforeach
|
||||
|
||||
<div class="grid gap-4 md:grid-cols-3">
|
||||
<a
|
||||
href="{{ route('modules.control.index', array_filter(['search' => $search])) }}"
|
||||
class="rounded-2xl border p-5 shadow-sm transition hover:border-blue-400/60 hover:bg-blue-500/5 {{ $status === 'all' ? 'border-blue-500/50 bg-blue-500/10 dark:bg-blue-500/10' : 'border-zinc-200 bg-white dark:border-zinc-800 dark:bg-zinc-900' }}"
|
||||
>
|
||||
<div class="text-xs font-semibold uppercase tracking-wide text-zinc-500 dark:text-zinc-400">Installed</div>
|
||||
<div class="mt-2 text-3xl font-bold text-zinc-900 dark:text-zinc-100">{{ $allModules->count() }}</div>
|
||||
<div class="mt-1 text-xs text-zinc-500 dark:text-zinc-400">Show all modules</div>
|
||||
</a>
|
||||
|
||||
<a
|
||||
href="{{ route('modules.control.index', array_filter(['status' => 'enabled', 'search' => $search])) }}"
|
||||
class="rounded-2xl border p-5 shadow-sm transition hover:border-emerald-400/60 hover:bg-emerald-500/5 {{ $status === 'enabled' ? 'border-emerald-500/50 bg-emerald-500/10 dark:bg-emerald-500/10' : 'border-zinc-200 bg-white dark:border-zinc-800 dark:bg-zinc-900' }}"
|
||||
>
|
||||
<div class="text-xs font-semibold uppercase tracking-wide text-emerald-700 dark:text-emerald-300">Enabled</div>
|
||||
<div class="mt-2 text-3xl font-bold text-emerald-700 dark:text-emerald-300">{{ $enabledCount }}</div>
|
||||
<div class="mt-1 text-xs text-zinc-500 dark:text-zinc-400">Show enabled modules</div>
|
||||
</a>
|
||||
|
||||
<a
|
||||
href="{{ route('modules.control.index', array_filter(['status' => 'disabled', 'search' => $search])) }}"
|
||||
class="rounded-2xl border p-5 shadow-sm transition hover:border-red-400/60 hover:bg-red-500/5 {{ $status === 'disabled' ? 'border-red-500/50 bg-red-500/10 dark:bg-red-500/10' : 'border-zinc-200 bg-white dark:border-zinc-800 dark:bg-zinc-900' }}"
|
||||
>
|
||||
<div class="text-xs font-semibold uppercase tracking-wide text-red-700 dark:text-red-300">Disabled</div>
|
||||
<div class="mt-2 text-3xl font-bold text-red-700 dark:text-red-300">{{ $disabledCount }}</div>
|
||||
<div class="mt-1 text-xs text-zinc-500 dark:text-zinc-400">Show disabled modules</div>
|
||||
</a>
|
||||
<div class="grid gap-4 md:grid-cols-2 xl:grid-cols-5">
|
||||
@foreach ($filterCards as $card)
|
||||
<a
|
||||
href="{{ route('modules.control.index', array_filter(['filter' => $card['key'] === 'all' ? null : $card['key'], 'search' => $search, 'sort' => $sort === 'order' ? null : $sort])) }}"
|
||||
class="group rounded-2xl border p-5 shadow-sm transition hover:-translate-y-0.5 hover:shadow-md {{ $filter === $card['key'] ? ($toneClasses[$card['tone']] ?? $toneClasses['blue']) : 'border-zinc-200 bg-white text-zinc-900 dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-100' }}"
|
||||
>
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div>
|
||||
<div class="text-xs font-semibold uppercase tracking-wide text-zinc-500 dark:text-zinc-400">{{ $card['label'] }}</div>
|
||||
<div class="mt-2 text-3xl font-bold">{{ $card['value'] }}</div>
|
||||
<div class="mt-1 text-xs text-zinc-500 dark:text-zinc-400">{{ $card['hint'] }}</div>
|
||||
</div>
|
||||
<span class="rounded-xl border border-zinc-200 bg-white/70 p-3 text-zinc-600 dark:border-zinc-700 dark:bg-zinc-950/60 dark:text-zinc-300">
|
||||
<i class="fa-solid {{ $card['icon'] }}" aria-hidden="true"></i>
|
||||
</span>
|
||||
</div>
|
||||
</a>
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-4 rounded-2xl border border-zinc-200 bg-white p-5 shadow-sm dark:border-zinc-800 dark:bg-zinc-900 xl:flex-row xl:items-end xl:justify-between">
|
||||
<div>
|
||||
<h2 class="text-lg font-semibold text-zinc-900 dark:text-zinc-100">Installed modules</h2>
|
||||
<p class="text-sm text-zinc-500 dark:text-zinc-400">
|
||||
Enabled state, sort order, custom descriptions, and version numbers are stored only in the database.
|
||||
</p>
|
||||
<div class="rounded-2xl border border-zinc-200 bg-white p-5 shadow-sm dark:border-zinc-800 dark:bg-zinc-900">
|
||||
<div class="flex flex-col gap-5 xl:flex-row xl:items-end xl:justify-between">
|
||||
<div>
|
||||
<h2 class="text-lg font-semibold text-zinc-950 dark:text-zinc-100">Installed modules</h2>
|
||||
<p class="mt-1 text-sm text-zinc-500 dark:text-zinc-400">
|
||||
Descriptions, versions, display metadata and sort order are stored in the database only.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-3 lg:flex-row lg:items-center">
|
||||
<form method="GET" action="{{ route('modules.control.index') }}" class="flex flex-col gap-2 sm:flex-row sm:items-center">
|
||||
@if ($filter !== 'all')
|
||||
<input type="hidden" name="filter" value="{{ $filter }}" />
|
||||
@endif
|
||||
<input
|
||||
type="search"
|
||||
name="search"
|
||||
value="{{ $search }}"
|
||||
placeholder="Search name, description, version, author..."
|
||||
class="w-full rounded-xl border border-zinc-300 bg-white px-4 py-2 text-sm text-zinc-900 placeholder:text-zinc-400 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100 dark:placeholder:text-zinc-500 sm:w-80"
|
||||
/>
|
||||
<select
|
||||
name="sort"
|
||||
class="rounded-xl border border-zinc-300 bg-white px-3 py-2 text-sm text-zinc-900 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100"
|
||||
>
|
||||
<option value="order" @selected($sort === 'order')>Sort: Order</option>
|
||||
<option value="name" @selected($sort === 'name')>Sort: Name</option>
|
||||
<option value="status" @selected($sort === 'status')>Sort: Status</option>
|
||||
<option value="version" @selected($sort === 'version')>Sort: Version</option>
|
||||
<option value="updated" @selected($sort === 'updated')>Sort: Last updated</option>
|
||||
</select>
|
||||
<button type="submit" class="rounded-xl border border-blue-500/40 bg-blue-600 px-4 py-2 text-sm font-semibold text-white shadow-sm hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500/30">
|
||||
Search
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<form method="POST" action="{{ route('modules.control.sync') }}">
|
||||
@csrf
|
||||
<button type="submit" class="rounded-xl border border-zinc-300 px-4 py-2 text-sm font-semibold text-zinc-800 hover:bg-zinc-50 dark:border-zinc-700 dark:text-zinc-100 dark:hover:bg-zinc-800">
|
||||
Sync Database
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-3 sm:flex-row sm:items-center">
|
||||
<form method="GET" action="{{ route('modules.control.index') }}" class="flex flex-col gap-2 sm:flex-row sm:items-center">
|
||||
@if ($status !== 'all')
|
||||
<input type="hidden" name="status" value="{{ $status }}" />
|
||||
@endif
|
||||
<label for="module-search" class="sr-only">Search modules</label>
|
||||
<input
|
||||
id="module-search"
|
||||
type="search"
|
||||
name="search"
|
||||
value="{{ $search }}"
|
||||
placeholder="Search modules..."
|
||||
class="w-full rounded-xl border border-zinc-300 bg-white px-4 py-2 text-sm text-zinc-900 placeholder:text-zinc-400 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100 dark:placeholder:text-zinc-500 sm:w-72"
|
||||
/>
|
||||
<button type="submit" class="rounded-xl border border-blue-500/40 bg-blue-600 px-4 py-2 text-sm font-semibold text-white shadow-sm hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500/30">
|
||||
Search
|
||||
</button>
|
||||
@if ($search !== '')
|
||||
<a href="{{ route('modules.control.index', $status === 'all' ? [] : ['status' => $status]) }}" class="rounded-xl border border-zinc-300 px-4 py-2 text-sm font-semibold text-zinc-800 hover:bg-zinc-50 dark:border-zinc-700 dark:text-zinc-100 dark:hover:bg-zinc-800">
|
||||
Clear
|
||||
</a>
|
||||
@endif
|
||||
</form>
|
||||
<div class="mt-5 flex flex-wrap gap-2">
|
||||
@foreach ($secondaryFilters as $key => $label)
|
||||
<a
|
||||
href="{{ route('modules.control.index', array_filter(['filter' => $key, 'search' => $search, 'sort' => $sort === 'order' ? null : $sort])) }}"
|
||||
class="rounded-full border px-3 py-1 text-xs font-semibold transition {{ $filter === $key ? 'border-blue-500/40 bg-blue-500/10 text-blue-700 dark:text-blue-300' : 'border-zinc-300 text-zinc-600 hover:bg-zinc-50 dark:border-zinc-700 dark:text-zinc-300 dark:hover:bg-zinc-800' }}"
|
||||
>
|
||||
{{ $label }}
|
||||
</a>
|
||||
@endforeach
|
||||
|
||||
<form method="POST" action="{{ route('modules.control.sync') }}">
|
||||
@csrf
|
||||
<button type="submit" class="rounded-xl border border-zinc-300 px-4 py-2 text-sm font-semibold text-zinc-800 hover:bg-zinc-50 dark:border-zinc-700 dark:text-zinc-100 dark:hover:bg-zinc-800">
|
||||
Sync Database
|
||||
</button>
|
||||
</form>
|
||||
@if ($filter !== 'all' || $search !== '')
|
||||
<a href="{{ route('modules.control.index') }}" class="rounded-full border border-zinc-300 px-3 py-1 text-xs font-semibold text-zinc-600 hover:bg-zinc-50 dark:border-zinc-700 dark:text-zinc-300 dark:hover:bg-zinc-800">
|
||||
Clear filters
|
||||
</a>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-1 text-sm text-zinc-500 dark:text-zinc-400 sm:flex-row sm:items-center sm:justify-between">
|
||||
<div>
|
||||
Showing {{ $modules->firstItem() ?? 0 }}-{{ $modules->lastItem() ?? 0 }} of {{ $modules->total() }} {{ $status === 'all' ? '' : $status }} modules.
|
||||
Showing {{ $modules->firstItem() ?? 0 }}-{{ $modules->lastItem() ?? 0 }} of {{ $modules->total() }} modules.
|
||||
@if ($search !== '')
|
||||
Search: <span class="font-semibold text-zinc-800 dark:text-zinc-200">{{ $search }}</span>
|
||||
@endif
|
||||
@@ -97,109 +132,126 @@
|
||||
<div>4 modules per page</div>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-4 xl:grid-cols-2">
|
||||
@forelse ($modules as $module)
|
||||
<article class="rounded-2xl border border-zinc-200 bg-white p-5 shadow-sm transition hover:border-zinc-300 hover:shadow-md dark:border-zinc-800 dark:bg-zinc-900 dark:hover:border-zinc-700">
|
||||
<div class="flex items-start justify-between gap-4">
|
||||
<div class="min-w-0">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<h3 class="text-base font-semibold text-zinc-950 dark:text-zinc-100">
|
||||
{{ $module['name'] }}
|
||||
</h3>
|
||||
<form method="POST" action="{{ route('modules.control.bulk') }}" class="space-y-4">
|
||||
@csrf
|
||||
|
||||
@if ($module['enabled'])
|
||||
<span class="rounded-full border border-emerald-500/30 bg-emerald-500/10 px-2.5 py-1 text-xs font-semibold text-emerald-700 dark:text-emerald-300">
|
||||
Enabled
|
||||
</span>
|
||||
@else
|
||||
<span class="rounded-full border border-red-500/30 bg-red-500/10 px-2.5 py-1 text-xs font-semibold text-red-700 dark:text-red-300">
|
||||
Disabled
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<div class="mt-3 rounded-xl border border-zinc-200 bg-zinc-50 p-3 dark:border-zinc-800 dark:bg-zinc-950/60">
|
||||
<div class="text-xs font-semibold uppercase tracking-wide text-zinc-500 dark:text-zinc-400">
|
||||
Database description
|
||||
</div>
|
||||
<p class="mt-1 line-clamp-3 text-sm leading-6 text-zinc-700 dark:text-zinc-300">
|
||||
{{ $module['description'] ?: 'No database description saved yet.' }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@if ($module['disk_description'])
|
||||
<p class="mt-2 line-clamp-2 text-xs leading-5 text-zinc-500 dark:text-zinc-500">
|
||||
Disk description: {{ $module['disk_description'] }}
|
||||
</p>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<div class="shrink-0 text-right text-xs text-zinc-500">
|
||||
<div>DB ID: {{ $module['status_record']?->id ?? '—' }}</div>
|
||||
<div>Order: {{ $module['sort_order'] }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<dl class="mt-4 grid gap-3 border-t border-zinc-100 pt-4 text-sm dark:border-zinc-800 sm:grid-cols-3">
|
||||
<div>
|
||||
<dt class="text-xs font-semibold uppercase text-zinc-500">Alias</dt>
|
||||
<dd class="mt-1 text-zinc-800 dark:text-zinc-200">{{ $module['alias'] }}</dd>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<dt class="text-xs font-semibold uppercase text-zinc-500">Version</dt>
|
||||
<dd class="mt-1 text-zinc-800 dark:text-zinc-200">
|
||||
{{ $module['version'] ?: '—' }}
|
||||
@if ($module['database_version'])
|
||||
<span class="ml-1 text-xs text-blue-600 dark:text-blue-300">DB</span>
|
||||
@endif
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<dt class="text-xs font-semibold uppercase text-zinc-500">Requires</dt>
|
||||
<dd class="mt-1 text-zinc-800 dark:text-zinc-200">{{ empty($module['requires']) ? 'None' : count($module['requires']) }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
|
||||
<div class="mt-4 truncate text-xs text-zinc-400">
|
||||
{{ $module['path'] }}
|
||||
</div>
|
||||
|
||||
<div class="mt-5 flex flex-wrap justify-end gap-2">
|
||||
<a href="{{ route('modules.control.show', $module['name']) }}"
|
||||
class="rounded-xl border border-zinc-300 px-4 py-2 text-sm font-semibold text-zinc-800 hover:bg-zinc-50 dark:border-zinc-700 dark:text-zinc-100 dark:hover:bg-zinc-800">
|
||||
View / Edit
|
||||
</a>
|
||||
|
||||
@if ($module['enabled'])
|
||||
<form method="POST" action="{{ route('modules.control.disable', $module['name']) }}">
|
||||
@csrf
|
||||
<button type="submit" class="rounded-xl border border-red-500/40 bg-red-600 px-4 py-2 text-sm font-semibold text-white shadow-sm hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-red-500/30">
|
||||
Disable
|
||||
</button>
|
||||
</form>
|
||||
@else
|
||||
<form method="POST" action="{{ route('modules.control.enable', $module['name']) }}">
|
||||
@csrf
|
||||
<button type="submit" class="rounded-xl border border-emerald-500/40 bg-emerald-600 px-4 py-2 text-sm font-semibold text-white shadow-sm hover:bg-emerald-700 focus:outline-none focus:ring-2 focus:ring-emerald-500/30">
|
||||
Enable
|
||||
</button>
|
||||
</form>
|
||||
@endif
|
||||
</div>
|
||||
</article>
|
||||
@empty
|
||||
<div class="rounded-2xl border border-zinc-200 bg-white p-8 text-center text-sm text-zinc-500 dark:border-zinc-800 dark:bg-zinc-900">
|
||||
No modules found on disk.
|
||||
<div class="flex flex-col gap-3 rounded-2xl border border-zinc-200 bg-white p-4 shadow-sm dark:border-zinc-800 dark:bg-zinc-900 sm:flex-row sm:items-center sm:justify-between">
|
||||
<div class="text-sm text-zinc-600 dark:text-zinc-400">
|
||||
Select modules on this page and apply a bulk action.
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<select name="action" class="rounded-xl border border-zinc-300 bg-white px-3 py-2 text-sm text-zinc-900 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100">
|
||||
<option value="enable">Enable selected</option>
|
||||
<option value="disable">Disable selected</option>
|
||||
</select>
|
||||
<button type="submit" class="rounded-xl border border-zinc-300 px-4 py-2 text-sm font-semibold text-zinc-800 hover:bg-zinc-50 dark:border-zinc-700 dark:text-zinc-100 dark:hover:bg-zinc-800">
|
||||
Apply
|
||||
</button>
|
||||
</div>
|
||||
@endforelse
|
||||
</div>
|
||||
|
||||
@if ($modules->hasPages())
|
||||
<div class="rounded-2xl border border-zinc-200 bg-white p-4 shadow-sm dark:border-zinc-800 dark:bg-zinc-900">
|
||||
{{ $modules->links() }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="overflow-hidden rounded-2xl border border-zinc-200 bg-white shadow-sm dark:border-zinc-800 dark:bg-zinc-900">
|
||||
<div class="overflow-x-auto">
|
||||
<table class="min-w-full divide-y divide-zinc-200 dark:divide-zinc-800">
|
||||
<thead class="bg-zinc-50 dark:bg-zinc-950/70">
|
||||
<tr>
|
||||
<th class="w-10 px-4 py-3 text-left"><span class="sr-only">Select</span></th>
|
||||
<th class="px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-zinc-500">Module</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-zinc-500">Description</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-zinc-500">Version</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-zinc-500">Status</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-zinc-500">Last Updated</th>
|
||||
<th class="px-4 py-3 text-right text-xs font-semibold uppercase tracking-wide text-zinc-500">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody class="divide-y divide-zinc-200 dark:divide-zinc-800">
|
||||
@forelse ($modules as $module)
|
||||
<tr class="align-top transition hover:bg-zinc-50 dark:hover:bg-zinc-950/50">
|
||||
<td class="px-4 py-4">
|
||||
<input type="checkbox" name="modules[]" value="{{ $module['name'] }}" class="rounded border-zinc-300 text-blue-600 focus:ring-blue-500 dark:border-zinc-700 dark:bg-zinc-950" />
|
||||
</td>
|
||||
<td class="px-4 py-4">
|
||||
<div class="flex gap-3">
|
||||
<div class="flex h-11 w-11 shrink-0 items-center justify-center rounded-xl border border-zinc-200 bg-zinc-50 text-zinc-700 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-200">
|
||||
<i class="fa-solid {{ $module['icon'] ?: 'fa-puzzle-piece' }}" aria-hidden="true"></i>
|
||||
</div>
|
||||
<div class="min-w-0">
|
||||
<div class="font-semibold text-zinc-950 dark:text-zinc-100">{{ $module['name'] }}</div>
|
||||
<div class="mt-1 text-xs text-zinc-500">{{ $module['alias'] }}</div>
|
||||
<div class="mt-2 flex flex-wrap gap-1.5">
|
||||
<span class="rounded-full border border-zinc-300 px-2 py-0.5 text-[11px] font-semibold text-zinc-600 dark:border-zinc-700 dark:text-zinc-300">{{ $module['category'] }}</span>
|
||||
<span class="rounded-full border border-zinc-300 px-2 py-0.5 text-[11px] font-semibold text-zinc-600 dark:border-zinc-700 dark:text-zinc-300">{{ $module['vendor_type'] }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="max-w-md px-4 py-4">
|
||||
<p class="line-clamp-3 text-sm leading-6 text-zinc-700 dark:text-zinc-300">
|
||||
{{ $module['description'] ?: 'No database description saved.' }}
|
||||
</p>
|
||||
@if ($module['has_missing_dependencies'])
|
||||
<div class="mt-2 rounded-lg border border-orange-500/30 bg-orange-500/10 px-2 py-1 text-xs font-semibold text-orange-700 dark:text-orange-300">
|
||||
Missing: {{ implode(', ', $module['missing_dependencies']) }}
|
||||
</div>
|
||||
@endif
|
||||
</td>
|
||||
<td class="px-4 py-4 text-sm text-zinc-700 dark:text-zinc-300">
|
||||
<div>{{ $module['version'] ?: '—' }}</div>
|
||||
@if ($module['has_update'])
|
||||
<span class="mt-1 inline-flex rounded-full border border-amber-500/30 bg-amber-500/10 px-2 py-0.5 text-xs font-semibold text-amber-700 dark:text-amber-300">Update available</span>
|
||||
@elseif ($module['database_version'])
|
||||
<span class="mt-1 inline-flex text-xs text-blue-600 dark:text-blue-300">Database</span>
|
||||
@endif
|
||||
</td>
|
||||
<td class="px-4 py-4">
|
||||
@if ($module['enabled'])
|
||||
<span class="inline-flex items-center gap-1.5 rounded-full border border-emerald-500/30 bg-emerald-500/10 px-3 py-1 text-xs font-semibold text-emerald-700 dark:text-emerald-300">
|
||||
<i class="fa-solid fa-circle-check" aria-hidden="true"></i> Enabled
|
||||
</span>
|
||||
@else
|
||||
<span class="inline-flex items-center gap-1.5 rounded-full border border-red-500/30 bg-red-500/10 px-3 py-1 text-xs font-semibold text-red-700 dark:text-red-300">
|
||||
<i class="fa-solid fa-circle-pause" aria-hidden="true"></i> Disabled
|
||||
</span>
|
||||
@endif
|
||||
</td>
|
||||
<td class="px-4 py-4 text-sm text-zinc-600 dark:text-zinc-400">
|
||||
{{ $module['updated_at']?->format('d M Y H:i') ?? '—' }}
|
||||
</td>
|
||||
<td class="px-4 py-4">
|
||||
<div class="flex justify-end gap-2">
|
||||
<a href="{{ route('modules.control.show', $module['name']) }}" class="rounded-lg border border-zinc-300 px-3 py-1.5 text-sm font-semibold text-zinc-800 hover:bg-zinc-50 dark:border-zinc-700 dark:text-zinc-100 dark:hover:bg-zinc-800">View</a>
|
||||
@if ($module['enabled'])
|
||||
<button type="submit" formaction="{{ route('modules.control.disable', $module['name']) }}" class="rounded-lg border border-red-500/40 bg-red-600 px-3 py-1.5 text-sm font-semibold text-white hover:bg-red-700" @disabled(! $module['can_disable'])>
|
||||
Disable
|
||||
</button>
|
||||
@else
|
||||
<button type="submit" formaction="{{ route('modules.control.enable', $module['name']) }}" class="rounded-lg border border-emerald-500/40 bg-emerald-600 px-3 py-1.5 text-sm font-semibold text-white hover:bg-emerald-700">
|
||||
Enable
|
||||
</button>
|
||||
@endif
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="7" class="px-4 py-12 text-center">
|
||||
<div class="mx-auto flex h-12 w-12 items-center justify-center rounded-full border border-zinc-200 bg-zinc-50 text-zinc-500 dark:border-zinc-800 dark:bg-zinc-950">
|
||||
<i class="fa-solid fa-magnifying-glass" aria-hidden="true"></i>
|
||||
</div>
|
||||
<div class="mt-3 font-semibold text-zinc-900 dark:text-zinc-100">No modules found</div>
|
||||
<div class="mt-1 text-sm text-zinc-500 dark:text-zinc-400">Adjust the search or filter and try again.</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div>
|
||||
{{ $modules->links() }}
|
||||
</div>
|
||||
</div>
|
||||
</x-layouts.app>
|
||||
|
||||
+220
-152
@@ -2,176 +2,244 @@
|
||||
<x-dynamic-component
|
||||
:component="config('modules.admin.hero_component', 'wms.page-hero')"
|
||||
:title="$module['name'].' Module'"
|
||||
subtitle="Database-backed module details and activation state."
|
||||
subtitle="Database metadata, dependencies, developer information and activation controls."
|
||||
/>
|
||||
|
||||
@php
|
||||
$fileGroups = [
|
||||
'Routes' => $module['routes'] ?? [],
|
||||
'Migrations' => $module['migrations'] ?? [],
|
||||
'Models' => $module['models'] ?? [],
|
||||
'Controllers' => $module['controllers'] ?? [],
|
||||
'Service Providers' => $module['providers'] ?? [],
|
||||
];
|
||||
@endphp
|
||||
|
||||
<div class="space-y-6">
|
||||
@if (session('status'))
|
||||
<div class="rounded-xl border border-emerald-500/30 bg-emerald-500/10 px-4 py-3 text-sm font-medium text-emerald-800 dark:text-emerald-200">
|
||||
{{ session('status') }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="grid gap-6 xl:grid-cols-3">
|
||||
<div class="rounded-2xl border border-zinc-200 bg-white p-6 shadow-sm dark:border-zinc-800 dark:bg-zinc-900 xl:col-span-2">
|
||||
<h2 class="text-lg font-semibold text-zinc-950 dark:text-zinc-100">Database metadata</h2>
|
||||
<p class="mt-1 text-sm text-zinc-500 dark:text-zinc-400">
|
||||
Description, version, and sort order are stored in the module_statuses table only. This does not edit module.json.
|
||||
</p>
|
||||
|
||||
<form method="POST" action="{{ route('modules.control.update', $module['name']) }}" class="mt-6 space-y-5">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
@foreach (['status' => 'emerald', 'warning' => 'amber', 'error' => 'red'] as $flash => $tone)
|
||||
@if (session($flash))
|
||||
<div class="rounded-2xl border px-4 py-3 text-sm font-medium {{ $tone === 'emerald' ? 'border-emerald-500/40 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300' : ($tone === 'amber' ? 'border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-300' : 'border-red-500/40 bg-red-500/10 text-red-700 dark:text-red-300') }}">
|
||||
{{ session($flash) }}
|
||||
</div>
|
||||
@endif
|
||||
@endforeach
|
||||
|
||||
<div class="grid gap-4 lg:grid-cols-4">
|
||||
<div class="rounded-2xl border border-zinc-200 bg-white p-5 shadow-sm dark:border-zinc-800 dark:bg-zinc-900">
|
||||
<div class="flex items-center gap-3">
|
||||
<div class="flex h-12 w-12 items-center justify-center rounded-xl border border-zinc-200 bg-zinc-50 text-zinc-700 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-200">
|
||||
<i class="fa-solid {{ $module['icon'] ?: 'fa-puzzle-piece' }}" aria-hidden="true"></i>
|
||||
</div>
|
||||
<div>
|
||||
<label for="description" class="block text-sm font-semibold text-zinc-800 dark:text-zinc-200">
|
||||
Description
|
||||
</label>
|
||||
<textarea
|
||||
id="description"
|
||||
name="description"
|
||||
rows="5"
|
||||
class="mt-2 w-full rounded-xl border border-zinc-300 bg-white px-4 py-3 text-sm text-zinc-900 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100"
|
||||
placeholder="Add the database-only module description..."
|
||||
>{{ old('description', $module['description']) }}</textarea>
|
||||
@error('description')
|
||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
||||
@enderror
|
||||
<div class="text-xs font-semibold uppercase text-zinc-500">Module</div>
|
||||
<div class="font-semibold text-zinc-950 dark:text-zinc-100">{{ $module['name'] }}</div>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-5 md:grid-cols-2">
|
||||
<div>
|
||||
<label for="version" class="block text-sm font-semibold text-zinc-800 dark:text-zinc-200">
|
||||
Version
|
||||
</label>
|
||||
<input
|
||||
id="version"
|
||||
name="version"
|
||||
type="text"
|
||||
maxlength="50"
|
||||
value="{{ old('version', $module['database_version'] ?? $module['version']) }}"
|
||||
class="mt-2 w-full rounded-xl border border-zinc-300 bg-white px-4 py-2 text-sm text-zinc-900 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100"
|
||||
placeholder="Example: 1.0.0"
|
||||
/>
|
||||
<p class="mt-2 text-xs text-zinc-500 dark:text-zinc-400">
|
||||
Saved only in the database. Disk version: {{ $module['disk_version'] ?: '—' }}
|
||||
</p>
|
||||
@error('version')
|
||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="sort_order" class="block text-sm font-semibold text-zinc-800 dark:text-zinc-200">
|
||||
Sort order
|
||||
</label>
|
||||
<input
|
||||
id="sort_order"
|
||||
name="sort_order"
|
||||
type="number"
|
||||
min="0"
|
||||
value="{{ old('sort_order', $module['sort_order']) }}"
|
||||
class="mt-2 w-full rounded-xl border border-zinc-300 bg-white px-4 py-2 text-sm text-zinc-900 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100"
|
||||
/>
|
||||
@error('sort_order')
|
||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap gap-3">
|
||||
<button type="submit" class="rounded-xl border border-blue-500/40 bg-blue-600 px-4 py-2 text-sm font-semibold text-white shadow-sm hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500/30">
|
||||
Save Module Metadata
|
||||
</button>
|
||||
|
||||
<a href="{{ route('modules.control.index') }}" class="rounded-xl border border-zinc-300 px-4 py-2 text-sm font-semibold text-zinc-800 hover:bg-zinc-50 dark:border-zinc-700 dark:text-zinc-100 dark:hover:bg-zinc-800">
|
||||
Back
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="rounded-2xl border border-zinc-200 bg-white p-6 shadow-sm dark:border-zinc-800 dark:bg-zinc-900">
|
||||
<h2 class="text-lg font-semibold text-zinc-950 dark:text-zinc-100">Activation</h2>
|
||||
|
||||
<div class="mt-4">
|
||||
<div class="rounded-2xl border border-zinc-200 bg-white p-5 shadow-sm dark:border-zinc-800 dark:bg-zinc-900">
|
||||
<div class="text-xs font-semibold uppercase text-zinc-500">Status</div>
|
||||
<div class="mt-2">
|
||||
@if ($module['enabled'])
|
||||
<span class="rounded-full border border-emerald-500/30 bg-emerald-500/10 px-3 py-1 text-xs font-semibold text-emerald-700 dark:text-emerald-300">Enabled</span>
|
||||
<span class="inline-flex items-center gap-1.5 rounded-full border border-emerald-500/30 bg-emerald-500/10 px-3 py-1 text-xs font-semibold text-emerald-700 dark:text-emerald-300"><i class="fa-solid fa-circle-check"></i> Enabled</span>
|
||||
@else
|
||||
<span class="rounded-full border border-red-500/30 bg-red-500/10 px-3 py-1 text-xs font-semibold text-red-700 dark:text-red-300">Disabled</span>
|
||||
<span class="inline-flex items-center gap-1.5 rounded-full border border-red-500/30 bg-red-500/10 px-3 py-1 text-xs font-semibold text-red-700 dark:text-red-300"><i class="fa-solid fa-circle-pause"></i> Disabled</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-6">
|
||||
@if ($module['enabled'])
|
||||
<form method="POST" action="{{ route('modules.control.disable', $module['name']) }}">
|
||||
@csrf
|
||||
<button type="submit" class="w-full rounded-xl border border-red-500/40 bg-red-600 px-4 py-2 text-sm font-semibold text-white shadow-sm hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-red-500/30">
|
||||
Disable Module
|
||||
</button>
|
||||
</form>
|
||||
@else
|
||||
<form method="POST" action="{{ route('modules.control.enable', $module['name']) }}">
|
||||
@csrf
|
||||
<button type="submit" class="w-full rounded-xl border border-emerald-500/40 bg-emerald-600 px-4 py-2 text-sm font-semibold text-white shadow-sm hover:bg-emerald-700 focus:outline-none focus:ring-2 focus:ring-emerald-500/30">
|
||||
Enable Module
|
||||
</button>
|
||||
</form>
|
||||
@endif
|
||||
<div class="rounded-2xl border border-zinc-200 bg-white p-5 shadow-sm dark:border-zinc-800 dark:bg-zinc-900">
|
||||
<div class="text-xs font-semibold uppercase text-zinc-500">Version</div>
|
||||
<div class="mt-2 font-semibold text-zinc-950 dark:text-zinc-100">{{ $module['version'] ?: '—' }}</div>
|
||||
@if ($module['has_update'])
|
||||
<div class="mt-1 text-xs font-semibold text-amber-700 dark:text-amber-300">Update available</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<div class="rounded-2xl border border-zinc-200 bg-white p-5 shadow-sm dark:border-zinc-800 dark:bg-zinc-900">
|
||||
<div class="text-xs font-semibold uppercase text-zinc-500">Dependencies</div>
|
||||
<div class="mt-2 font-semibold {{ $module['has_missing_dependencies'] ? 'text-orange-700 dark:text-orange-300' : 'text-zinc-950 dark:text-zinc-100' }}">
|
||||
{{ count($module['requires']) }} required
|
||||
</div>
|
||||
@if ($module['has_missing_dependencies'])
|
||||
<div class="mt-1 text-xs text-orange-700 dark:text-orange-300">Missing dependency</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="rounded-2xl border border-zinc-200 bg-white p-6 shadow-sm dark:border-zinc-800 dark:bg-zinc-900">
|
||||
<h2 class="text-lg font-semibold text-zinc-950 dark:text-zinc-100">Module details</h2>
|
||||
|
||||
<dl class="mt-6 grid gap-5 md:grid-cols-2">
|
||||
<div>
|
||||
<dt class="text-xs font-semibold uppercase text-zinc-500">Module</dt>
|
||||
<dd class="mt-1 text-sm text-zinc-900 dark:text-zinc-100">{{ $module['name'] }}</dd>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<dt class="text-xs font-semibold uppercase text-zinc-500">Alias</dt>
|
||||
<dd class="mt-1 text-sm text-zinc-900 dark:text-zinc-100">{{ $module['alias'] }}</dd>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<dt class="text-xs font-semibold uppercase text-zinc-500">Version</dt>
|
||||
<dd class="mt-1 text-sm text-zinc-900 dark:text-zinc-100">
|
||||
{{ $module['version'] ?: '—' }}
|
||||
@if ($module['database_version'])
|
||||
<span class="ml-2 rounded-full border border-blue-500/30 bg-blue-500/10 px-2 py-0.5 text-xs font-semibold text-blue-700 dark:text-blue-300">Database</span>
|
||||
@elseif ($module['disk_version'])
|
||||
<span class="ml-2 rounded-full border border-zinc-300 px-2 py-0.5 text-xs font-semibold text-zinc-500 dark:border-zinc-700">Disk</span>
|
||||
@endif
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<dt class="text-xs font-semibold uppercase text-zinc-500">Database record</dt>
|
||||
<dd class="mt-1 text-sm text-zinc-900 dark:text-zinc-100">ID {{ $module['status_record']?->id ?? '—' }}</dd>
|
||||
</div>
|
||||
|
||||
<div class="md:col-span-2">
|
||||
<dt class="text-xs font-semibold uppercase text-zinc-500">Path</dt>
|
||||
<dd class="mt-1 break-all text-sm text-zinc-900 dark:text-zinc-100">{{ $module['path'] }}</dd>
|
||||
</div>
|
||||
|
||||
<div class="md:col-span-2">
|
||||
<dt class="text-xs font-semibold uppercase text-zinc-500">Requires</dt>
|
||||
<dd class="mt-1 text-sm text-zinc-900 dark:text-zinc-100">
|
||||
{{ empty($module['requires']) ? 'None' : implode(', ', $module['requires']) }}
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
@if ($module['disk_description'])
|
||||
<div class="md:col-span-2">
|
||||
<dt class="text-xs font-semibold uppercase text-zinc-500">Disk description</dt>
|
||||
<dd class="mt-1 text-sm text-zinc-900 dark:text-zinc-100">{{ $module['disk_description'] }}</dd>
|
||||
<div class="grid gap-6 xl:grid-cols-3">
|
||||
<div class="space-y-6 xl:col-span-2">
|
||||
<div class="rounded-2xl border border-zinc-200 bg-white p-6 shadow-sm dark:border-zinc-800 dark:bg-zinc-900">
|
||||
<div class="flex items-start justify-between gap-4">
|
||||
<div>
|
||||
<h2 class="text-lg font-semibold text-zinc-950 dark:text-zinc-100">Database metadata</h2>
|
||||
<p class="mt-1 text-sm text-zinc-500 dark:text-zinc-400">These fields are saved only in the module_statuses table.</p>
|
||||
</div>
|
||||
<a href="{{ route('modules.control.index') }}" class="rounded-xl border border-zinc-300 px-4 py-2 text-sm font-semibold text-zinc-800 hover:bg-zinc-50 dark:border-zinc-700 dark:text-zinc-100 dark:hover:bg-zinc-800">Back</a>
|
||||
</div>
|
||||
@endif
|
||||
</dl>
|
||||
|
||||
<form method="POST" action="{{ route('modules.control.update', $module['name']) }}" class="mt-6 space-y-5">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
|
||||
<div>
|
||||
<label for="description" class="block text-sm font-semibold text-zinc-800 dark:text-zinc-200">Description</label>
|
||||
<textarea id="description" name="description" rows="5" class="mt-2 w-full rounded-xl border border-zinc-300 bg-white px-4 py-3 text-sm text-zinc-900 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100" placeholder="Add the database-only module description...">{{ old('description', $module['database_description'] ?? $module['description']) }}</textarea>
|
||||
@error('description')<p class="mt-2 text-sm text-red-600">{{ $message }}</p>@enderror
|
||||
</div>
|
||||
|
||||
<div class="grid gap-5 md:grid-cols-2">
|
||||
<div>
|
||||
<label for="version" class="block text-sm font-semibold text-zinc-800 dark:text-zinc-200">Version</label>
|
||||
<input id="version" name="version" type="text" maxlength="50" value="{{ old('version', $module['database_version'] ?? $module['version']) }}" class="mt-2 w-full rounded-xl border border-zinc-300 bg-white px-4 py-2 text-sm text-zinc-900 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100" placeholder="Example: 1.0.0" />
|
||||
<p class="mt-2 text-xs text-zinc-500 dark:text-zinc-400">Disk version: {{ $module['disk_version'] ?: '—' }}</p>
|
||||
@error('version')<p class="mt-2 text-sm text-red-600">{{ $message }}</p>@enderror
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="sort_order" class="block text-sm font-semibold text-zinc-800 dark:text-zinc-200">Sort order</label>
|
||||
<input id="sort_order" name="sort_order" type="number" min="0" value="{{ old('sort_order', $module['sort_order']) }}" class="mt-2 w-full rounded-xl border border-zinc-300 bg-white px-4 py-2 text-sm text-zinc-900 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100" />
|
||||
@error('sort_order')<p class="mt-2 text-sm text-red-600">{{ $message }}</p>@enderror
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="icon" class="block text-sm font-semibold text-zinc-800 dark:text-zinc-200">Font Awesome icon</label>
|
||||
<input id="icon" name="icon" type="text" maxlength="80" value="{{ old('icon', $module['icon']) }}" class="mt-2 w-full rounded-xl border border-zinc-300 bg-white px-4 py-2 text-sm text-zinc-900 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100" placeholder="fa-puzzle-piece" />
|
||||
@error('icon')<p class="mt-2 text-sm text-red-600">{{ $message }}</p>@enderror
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="category" class="block text-sm font-semibold text-zinc-800 dark:text-zinc-200">Category</label>
|
||||
<select id="category" name="category" class="mt-2 w-full rounded-xl border border-zinc-300 bg-white px-4 py-2 text-sm text-zinc-900 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100">
|
||||
@foreach (['Core', 'Optional'] as $option)
|
||||
<option value="{{ $option }}" @selected(old('category', $module['category']) === $option)>{{ $option }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@error('category')<p class="mt-2 text-sm text-red-600">{{ $message }}</p>@enderror
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="vendor_type" class="block text-sm font-semibold text-zinc-800 dark:text-zinc-200">Vendor type</label>
|
||||
<select id="vendor_type" name="vendor_type" class="mt-2 w-full rounded-xl border border-zinc-300 bg-white px-4 py-2 text-sm text-zinc-900 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100">
|
||||
@foreach (['MPBA', 'Third-party'] as $option)
|
||||
<option value="{{ $option }}" @selected(old('vendor_type', $module['vendor_type']) === $option)>{{ $option }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@error('vendor_type')<p class="mt-2 text-sm text-red-600">{{ $message }}</p>@enderror
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="author" class="block text-sm font-semibold text-zinc-800 dark:text-zinc-200">Author</label>
|
||||
<input id="author" name="author" type="text" maxlength="120" value="{{ old('author', $module['author']) }}" class="mt-2 w-full rounded-xl border border-zinc-300 bg-white px-4 py-2 text-sm text-zinc-900 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100" />
|
||||
@error('author')<p class="mt-2 text-sm text-red-600">{{ $message }}</p>@enderror
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="notes" class="block text-sm font-semibold text-zinc-800 dark:text-zinc-200">Internal notes</label>
|
||||
<textarea id="notes" name="notes" rows="4" class="mt-2 w-full rounded-xl border border-zinc-300 bg-white px-4 py-3 text-sm text-zinc-900 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100">{{ old('notes', $module['notes']) }}</textarea>
|
||||
@error('notes')<p class="mt-2 text-sm text-red-600">{{ $message }}</p>@enderror
|
||||
</div>
|
||||
|
||||
<button type="submit" class="rounded-xl border border-blue-500/40 bg-blue-600 px-4 py-2 text-sm font-semibold text-white shadow-sm hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500/30">Save Module Metadata</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-6 lg:grid-cols-2">
|
||||
<div class="rounded-2xl border border-zinc-200 bg-white p-6 shadow-sm dark:border-zinc-800 dark:bg-zinc-900">
|
||||
<h2 class="text-lg font-semibold text-zinc-950 dark:text-zinc-100">Dependencies</h2>
|
||||
<div class="mt-4 space-y-3 text-sm">
|
||||
<div>
|
||||
<div class="text-xs font-semibold uppercase text-zinc-500">Required modules</div>
|
||||
<div class="mt-1 text-zinc-800 dark:text-zinc-200">{{ empty($module['requires']) ? 'None' : implode(', ', $module['requires']) }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="text-xs font-semibold uppercase text-zinc-500">Missing dependencies</div>
|
||||
<div class="mt-1 {{ $module['has_missing_dependencies'] ? 'text-orange-700 dark:text-orange-300' : 'text-zinc-800 dark:text-zinc-200' }}">{{ empty($module['missing_dependencies']) ? 'None' : implode(', ', $module['missing_dependencies']) }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="text-xs font-semibold uppercase text-zinc-500">Enabled dependents</div>
|
||||
<div class="mt-1 {{ $module['can_disable'] ? 'text-zinc-800 dark:text-zinc-200' : 'text-orange-700 dark:text-orange-300' }}">{{ empty($module['enabled_dependents']) ? 'None' : implode(', ', $module['enabled_dependents']) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="rounded-2xl border border-zinc-200 bg-white p-6 shadow-sm dark:border-zinc-800 dark:bg-zinc-900">
|
||||
<h2 class="text-lg font-semibold text-zinc-950 dark:text-zinc-100">Activation</h2>
|
||||
<p class="mt-2 text-sm text-zinc-500 dark:text-zinc-400">Disabling is blocked when another enabled module depends on this module.</p>
|
||||
<div class="mt-5">
|
||||
@if ($module['enabled'])
|
||||
<form method="POST" action="{{ route('modules.control.disable', $module['name']) }}">
|
||||
@csrf
|
||||
<button type="submit" class="w-full rounded-xl border border-red-500/40 bg-red-600 px-4 py-2 text-sm font-semibold text-white shadow-sm hover:bg-red-700 disabled:cursor-not-allowed disabled:opacity-50" @disabled(! $module['can_disable'])>Disable Module</button>
|
||||
</form>
|
||||
@else
|
||||
<form method="POST" action="{{ route('modules.control.enable', $module['name']) }}">
|
||||
@csrf
|
||||
<button type="submit" class="w-full rounded-xl border border-emerald-500/40 bg-emerald-600 px-4 py-2 text-sm font-semibold text-white shadow-sm hover:bg-emerald-700">Enable Module</button>
|
||||
</form>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="rounded-2xl border border-zinc-200 bg-white p-6 shadow-sm dark:border-zinc-800 dark:bg-zinc-900">
|
||||
<h2 class="text-lg font-semibold text-zinc-950 dark:text-zinc-100">Developer files</h2>
|
||||
<div class="mt-5 grid gap-4 md:grid-cols-2 xl:grid-cols-3">
|
||||
@foreach ($fileGroups as $label => $files)
|
||||
<div class="rounded-xl border border-zinc-200 bg-zinc-50 p-4 dark:border-zinc-800 dark:bg-zinc-950/60">
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<h3 class="text-sm font-semibold text-zinc-900 dark:text-zinc-100">{{ $label }}</h3>
|
||||
<span class="rounded-full border border-zinc-300 px-2 py-0.5 text-xs font-semibold text-zinc-600 dark:border-zinc-700 dark:text-zinc-300">{{ count($files) }}</span>
|
||||
</div>
|
||||
<ul class="mt-3 max-h-36 space-y-1 overflow-auto text-xs text-zinc-600 dark:text-zinc-400">
|
||||
@forelse ($files as $file)
|
||||
<li class="break-all">{{ $file }}</li>
|
||||
@empty
|
||||
<li>None found.</li>
|
||||
@endforelse
|
||||
</ul>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-6 lg:grid-cols-2">
|
||||
<div class="rounded-2xl border border-zinc-200 bg-white p-6 shadow-sm dark:border-zinc-800 dark:bg-zinc-900">
|
||||
<h2 class="text-lg font-semibold text-zinc-950 dark:text-zinc-100">README preview</h2>
|
||||
<pre class="mt-4 max-h-96 overflow-auto whitespace-pre-wrap rounded-xl border border-zinc-200 bg-zinc-50 p-4 text-xs leading-6 text-zinc-700 dark:border-zinc-800 dark:bg-zinc-950 dark:text-zinc-300">{{ $module['readme'] ?: 'No README found.' }}</pre>
|
||||
</div>
|
||||
|
||||
<div class="rounded-2xl border border-zinc-200 bg-white p-6 shadow-sm dark:border-zinc-800 dark:bg-zinc-900">
|
||||
<h2 class="text-lg font-semibold text-zinc-950 dark:text-zinc-100">Changelog preview</h2>
|
||||
<pre class="mt-4 max-h-96 overflow-auto whitespace-pre-wrap rounded-xl border border-zinc-200 bg-zinc-50 p-4 text-xs leading-6 text-zinc-700 dark:border-zinc-800 dark:bg-zinc-950 dark:text-zinc-300">{{ $module['changelog'] ?: 'No changelog found.' }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<aside class="space-y-6">
|
||||
<div class="rounded-2xl border border-zinc-200 bg-white p-6 shadow-sm dark:border-zinc-800 dark:bg-zinc-900">
|
||||
<h2 class="text-lg font-semibold text-zinc-950 dark:text-zinc-100">Developer information</h2>
|
||||
<dl class="mt-5 space-y-4 text-sm">
|
||||
<div><dt class="text-xs font-semibold uppercase text-zinc-500">Installed path</dt><dd class="mt-1 break-all text-zinc-900 dark:text-zinc-100">{{ $module['path'] }}</dd></div>
|
||||
<div><dt class="text-xs font-semibold uppercase text-zinc-500">Namespace</dt><dd class="mt-1 break-all text-zinc-900 dark:text-zinc-100">{{ $module['namespace'] ?: '—' }}</dd></div>
|
||||
<div><dt class="text-xs font-semibold uppercase text-zinc-500">Composer package</dt><dd class="mt-1 break-all text-zinc-900 dark:text-zinc-100">{{ $module['composer_name'] ?: '—' }}</dd></div>
|
||||
<div><dt class="text-xs font-semibold uppercase text-zinc-500">Git commit</dt><dd class="mt-1 text-zinc-900 dark:text-zinc-100">{{ $module['git_commit'] ?: '—' }}</dd></div>
|
||||
<div><dt class="text-xs font-semibold uppercase text-zinc-500">Build date</dt><dd class="mt-1 text-zinc-900 dark:text-zinc-100">{{ $module['build_date'] ?: '—' }}</dd></div>
|
||||
<div><dt class="text-xs font-semibold uppercase text-zinc-500">Database record</dt><dd class="mt-1 text-zinc-900 dark:text-zinc-100">ID {{ $module['status_record']?->id ?? '—' }}</dd></div>
|
||||
<div><dt class="text-xs font-semibold uppercase text-zinc-500">Last updated</dt><dd class="mt-1 text-zinc-900 dark:text-zinc-100">{{ $module['updated_at']?->format('d M Y H:i') ?? '—' }}</dd></div>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
<div class="rounded-2xl border border-zinc-200 bg-white p-6 shadow-sm dark:border-zinc-800 dark:bg-zinc-900">
|
||||
<h2 class="text-lg font-semibold text-zinc-950 dark:text-zinc-100">Disk metadata</h2>
|
||||
<dl class="mt-5 space-y-4 text-sm">
|
||||
<div><dt class="text-xs font-semibold uppercase text-zinc-500">Alias</dt><dd class="mt-1 text-zinc-900 dark:text-zinc-100">{{ $module['alias'] }}</dd></div>
|
||||
<div><dt class="text-xs font-semibold uppercase text-zinc-500">Disk version</dt><dd class="mt-1 text-zinc-900 dark:text-zinc-100">{{ $module['disk_version'] ?: '—' }}</dd></div>
|
||||
<div><dt class="text-xs font-semibold uppercase text-zinc-500">Disk description</dt><dd class="mt-1 text-zinc-900 dark:text-zinc-100">{{ $module['disk_description'] ?: '—' }}</dd></div>
|
||||
</dl>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
</x-layouts.app>
|
||||
|
||||
@@ -9,6 +9,7 @@ Route::middleware(config('modules.admin.middleware', ['web', 'auth']))
|
||||
->group(function (): void {
|
||||
Route::get('/', [ModuleControlController::class, 'index'])->name('index');
|
||||
Route::post('/sync', [ModuleControlController::class, 'sync'])->name('sync');
|
||||
Route::post('/bulk', [ModuleControlController::class, 'bulk'])->name('bulk');
|
||||
Route::get('/{module}', [ModuleControlController::class, 'show'])->name('show');
|
||||
Route::put('/{module}', [ModuleControlController::class, 'update'])->name('update');
|
||||
Route::post('/{module}/enable', [ModuleControlController::class, 'enable'])->name('enable');
|
||||
|
||||
Reference in New Issue
Block a user