From 739506d1bad833cb4c48f164ccfffcb96877ce75 Mon Sep 17 00:00:00 2001 From: Mark Gregory Date: Wed, 1 Jul 2026 11:51:17 +0100 Subject: [PATCH] with pagination nwo with the proper view selection --- CHANGELOG.md | 9 + .../Entities/ModuleStatus.php | 5 + .../Controllers/ModuleControlController.php | 115 ++++- src/Support/DatabaseModuleRegistry.php | 341 ++++++++++++++- ...trol_metadata_to_module_statuses_table.php | 44 ++ src/resources/views/index.blade.php | 396 ++++++++++-------- src/resources/views/show.blade.php | 372 +++++++++------- src/routes/web.php | 1 + 8 files changed, 916 insertions(+), 367 deletions(-) create mode 100644 src/database/migrations/2026_07_01_000300_add_module_control_metadata_to_module_statuses_table.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 079366b..2dac7cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -567,3 +567,12 @@ All Notable changes to `laravel-modules` will be documented in this file. ## 0.1 - 2016-06-27 Initial release + +## 2026-07-01 - Module Control Administration Enhancements + +- Added professional module control dashboard cards for installed, enabled, disabled, updates available, and missing dependency states. +- Added searchable, sortable, paginated module index with database-only descriptions, version metadata, icons, categories, vendor type, author and last-updated details. +- Added filter support for all, enabled, disabled, core, optional, MPBA, third-party, updates, and missing dependencies. +- Added bulk enable/disable actions with dependency safety checks. +- Added module detail developer cards for dependencies, dependents, README, changelog, routes, migrations, models, controllers, providers and package metadata. +- Added module_statuses metadata columns for icon, category, vendor type, author and notes. diff --git a/src/DevelopmentSupport/Entities/ModuleStatus.php b/src/DevelopmentSupport/Entities/ModuleStatus.php index 627e538..ca94c55 100644 --- a/src/DevelopmentSupport/Entities/ModuleStatus.php +++ b/src/DevelopmentSupport/Entities/ModuleStatus.php @@ -29,6 +29,11 @@ class ModuleStatus extends Model 'description', 'version', 'sort_order', + 'icon', + 'category', + 'vendor_type', + 'author', + 'notes', ]; /** diff --git a/src/Http/Controllers/ModuleControlController.php b/src/Http/Controllers/ModuleControlController.php index db10ee1..8037fa1 100644 --- a/src/Http/Controllers/ModuleControlController.php +++ b/src/Http/Controllers/ModuleControlController.php @@ -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(), + ]; } } diff --git a/src/Support/DatabaseModuleRegistry.php b/src/Support/DatabaseModuleRegistry.php index f09433e..e51598f 100644 --- a/src/Support/DatabaseModuleRegistry.php +++ b/src/Support/DatabaseModuleRegistry.php @@ -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 : ''; } } diff --git a/src/database/migrations/2026_07_01_000300_add_module_control_metadata_to_module_statuses_table.php b/src/database/migrations/2026_07_01_000300_add_module_control_metadata_to_module_statuses_table.php new file mode 100644 index 0000000..494b3f5 --- /dev/null +++ b/src/database/migrations/2026_07_01_000300_add_module_control_metadata_to_module_statuses_table.php @@ -0,0 +1,44 @@ +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); + } + } + }); + } +}; diff --git a/src/resources/views/index.blade.php b/src/resources/views/index.blade.php index 9881463..ec7f9a2 100644 --- a/src/resources/views/index.blade.php +++ b/src/resources/views/index.blade.php @@ -2,94 +2,129 @@ @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
- @if (session('status')) -
- {{ session('status') }} -
- @endif + @foreach (['status' => 'emerald', 'warning' => 'amber', 'error' => 'red'] as $flash => $tone) + @if (session($flash)) +
+ {{ session($flash) }} +
+ @endif + @endforeach -
- -
Installed
-
{{ $allModules->count() }}
-
Show all modules
-
- - -
Enabled
-
{{ $enabledCount }}
-
Show enabled modules
-
- - -
Disabled
-
{{ $disabledCount }}
-
Show disabled modules
-
+ -
-
-

Installed modules

-

- Enabled state, sort order, custom descriptions, and version numbers are stored only in the database. -

+
+
+
+

Installed modules

+

+ Descriptions, versions, display metadata and sort order are stored in the database only. +

+
+ +
+
+ @if ($filter !== 'all') + + @endif + + + +
+ +
+ @csrf + +
+
-
-
- @if ($status !== 'all') - - @endif - - - - @if ($search !== '') - - Clear - - @endif -
+
+ @foreach ($secondaryFilters as $key => $label) + + {{ $label }} + + @endforeach -
- @csrf - -
+ @if ($filter !== 'all' || $search !== '') + + Clear filters + + @endif
- 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: {{ $search }} @endif @@ -97,109 +132,126 @@
4 modules per page
-
- @forelse ($modules as $module) -
-
-
-
-

- {{ $module['name'] }} -

+
+ @csrf - @if ($module['enabled']) - - Enabled - - @else - - Disabled - - @endif -
- -
-
- Database description -
-

- {{ $module['description'] ?: 'No database description saved yet.' }} -

-
- - @if ($module['disk_description']) -

- Disk description: {{ $module['disk_description'] }} -

- @endif -
- -
-
DB ID: {{ $module['status_record']?->id ?? '—' }}
-
Order: {{ $module['sort_order'] }}
-
-
- -
-
-
Alias
-
{{ $module['alias'] }}
-
- -
-
Version
-
- {{ $module['version'] ?: '—' }} - @if ($module['database_version']) - DB - @endif -
-
- -
-
Requires
-
{{ empty($module['requires']) ? 'None' : count($module['requires']) }}
-
-
- -
- {{ $module['path'] }} -
- -
- - View / Edit - - - @if ($module['enabled']) - - @csrf - - - @else -
- @csrf - -
- @endif -
-
- @empty -
- No modules found on disk. +
+
+ Select modules on this page and apply a bulk action. +
+
+ +
- @endforelse -
- - @if ($modules->hasPages()) -
- {{ $modules->links() }}
- @endif + +
+
+ + + + + + + + + + + + + + + @forelse ($modules as $module) + + + + + + + + + + @empty + + + + @endforelse + +
SelectModuleDescriptionVersionStatusLast UpdatedActions
+ + +
+
+ +
+
+
{{ $module['name'] }}
+
{{ $module['alias'] }}
+
+ {{ $module['category'] }} + {{ $module['vendor_type'] }} +
+
+
+
+

+ {{ $module['description'] ?: 'No database description saved.' }} +

+ @if ($module['has_missing_dependencies']) +
+ Missing: {{ implode(', ', $module['missing_dependencies']) }} +
+ @endif +
+
{{ $module['version'] ?: '—' }}
+ @if ($module['has_update']) + Update available + @elseif ($module['database_version']) + Database + @endif +
+ @if ($module['enabled']) + + Enabled + + @else + + Disabled + + @endif + + {{ $module['updated_at']?->format('d M Y H:i') ?? '—' }} + +
+ View + @if ($module['enabled']) + + @else + + @endif +
+
+
+ +
+
No modules found
+
Adjust the search or filter and try again.
+
+
+
+ + +
+ {{ $modules->links() }} +
diff --git a/src/resources/views/show.blade.php b/src/resources/views/show.blade.php index 6702ae8..c6bdbf1 100644 --- a/src/resources/views/show.blade.php +++ b/src/resources/views/show.blade.php @@ -2,176 +2,244 @@ + @php + $fileGroups = [ + 'Routes' => $module['routes'] ?? [], + 'Migrations' => $module['migrations'] ?? [], + 'Models' => $module['models'] ?? [], + 'Controllers' => $module['controllers'] ?? [], + 'Service Providers' => $module['providers'] ?? [], + ]; + @endphp +
- @if (session('status')) -
- {{ session('status') }} -
- @endif - -
-
-

Database metadata

-

- Description, version, and sort order are stored in the module_statuses table only. This does not edit module.json. -

- -
- @csrf - @method('PUT') + @foreach (['status' => 'emerald', 'warning' => 'amber', 'error' => 'red'] as $flash => $tone) + @if (session($flash)) +
+ {{ session($flash) }} +
+ @endif + @endforeach +
+
+
+
+ +
- - - @error('description') -

{{ $message }}

- @enderror +
Module
+
{{ $module['name'] }}
- -
-
- - -

- Saved only in the database. Disk version: {{ $module['disk_version'] ?: '—' }} -

- @error('version') -

{{ $message }}

- @enderror -
- -
- - - @error('sort_order') -

{{ $message }}

- @enderror -
-
- -
- - - - Back - -
- +
-
-

Activation

- -
+
+
Status
+
@if ($module['enabled']) - Enabled + Enabled @else - Disabled + Disabled @endif
+
-
- @if ($module['enabled']) -
- @csrf - -
- @else -
- @csrf - -
- @endif +
+
Version
+
{{ $module['version'] ?: '—' }}
+ @if ($module['has_update']) +
Update available
+ @endif +
+ +
+
Dependencies
+
+ {{ count($module['requires']) }} required
+ @if ($module['has_missing_dependencies']) +
Missing dependency
+ @endif
-
-

Module details

- -
-
-
Module
-
{{ $module['name'] }}
-
- -
-
Alias
-
{{ $module['alias'] }}
-
- -
-
Version
-
- {{ $module['version'] ?: '—' }} - @if ($module['database_version']) - Database - @elseif ($module['disk_version']) - Disk - @endif -
-
- -
-
Database record
-
ID {{ $module['status_record']?->id ?? '—' }}
-
- -
-
Path
-
{{ $module['path'] }}
-
- -
-
Requires
-
- {{ empty($module['requires']) ? 'None' : implode(', ', $module['requires']) }} -
-
- - @if ($module['disk_description']) -
-
Disk description
-
{{ $module['disk_description'] }}
+
+
+
+
+
+

Database metadata

+

These fields are saved only in the module_statuses table.

+
+ Back
- @endif -
+ +
+ @csrf + @method('PUT') + +
+ + + @error('description')

{{ $message }}

@enderror +
+ +
+
+ + +

Disk version: {{ $module['disk_version'] ?: '—' }}

+ @error('version')

{{ $message }}

@enderror +
+ +
+ + + @error('sort_order')

{{ $message }}

@enderror +
+ +
+ + + @error('icon')

{{ $message }}

@enderror +
+ +
+ + + @error('category')

{{ $message }}

@enderror +
+ +
+ + + @error('vendor_type')

{{ $message }}

@enderror +
+ +
+ + + @error('author')

{{ $message }}

@enderror +
+
+ +
+ + + @error('notes')

{{ $message }}

@enderror +
+ + +
+
+ +
+
+

Dependencies

+
+
+
Required modules
+
{{ empty($module['requires']) ? 'None' : implode(', ', $module['requires']) }}
+
+
+
Missing dependencies
+
{{ empty($module['missing_dependencies']) ? 'None' : implode(', ', $module['missing_dependencies']) }}
+
+
+
Enabled dependents
+
{{ empty($module['enabled_dependents']) ? 'None' : implode(', ', $module['enabled_dependents']) }}
+
+
+
+ +
+

Activation

+

Disabling is blocked when another enabled module depends on this module.

+
+ @if ($module['enabled']) +
+ @csrf + +
+ @else +
+ @csrf + +
+ @endif +
+
+
+ +
+

Developer files

+
+ @foreach ($fileGroups as $label => $files) +
+
+

{{ $label }}

+ {{ count($files) }} +
+
    + @forelse ($files as $file) +
  • {{ $file }}
  • + @empty +
  • None found.
  • + @endforelse +
+
+ @endforeach +
+
+ +
+
+

README preview

+
{{ $module['readme'] ?: 'No README found.' }}
+
+ +
+

Changelog preview

+
{{ $module['changelog'] ?: 'No changelog found.' }}
+
+
+
+ +
diff --git a/src/routes/web.php b/src/routes/web.php index 560e4be..bab184b 100644 --- a/src/routes/web.php +++ b/src/routes/web.php @@ -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');