new updates
This commit is contained in:
@@ -27,6 +27,7 @@ class ModuleStatus extends Model
|
|||||||
'module',
|
'module',
|
||||||
'enabled',
|
'enabled',
|
||||||
'description',
|
'description',
|
||||||
|
'version',
|
||||||
'sort_order',
|
'sort_order',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ class ModuleControlController extends Controller
|
|||||||
{
|
{
|
||||||
$data = $request->validate([
|
$data = $request->validate([
|
||||||
'description' => ['nullable', 'string', 'max:2000'],
|
'description' => ['nullable', 'string', 'max:2000'],
|
||||||
|
'version' => ['nullable', 'string', 'max:50'],
|
||||||
'sort_order' => ['nullable', 'integer', 'min:0', 'max:999999'],
|
'sort_order' => ['nullable', 'integer', 'min:0', 'max:999999'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ class DatabaseModuleRegistry
|
|||||||
['module' => $module->getName()],
|
['module' => $module->getName()],
|
||||||
[
|
[
|
||||||
'enabled' => $module->isEnabled(),
|
'enabled' => $module->isEnabled(),
|
||||||
|
'version' => $this->moduleVersion($module),
|
||||||
'sort_order' => (int) $module->get('order', 0),
|
'sort_order' => (int) $module->get('order', 0),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
@@ -60,6 +61,7 @@ class DatabaseModuleRegistry
|
|||||||
->where('module', $module->getName())
|
->where('module', $module->getName())
|
||||||
->value('enabled') ?? $module->isEnabled(),
|
->value('enabled') ?? $module->isEnabled(),
|
||||||
'description' => $data['description'] ?? null,
|
'description' => $data['description'] ?? null,
|
||||||
|
'version' => $data['version'] ?? null,
|
||||||
'sort_order' => (int) ($data['sort_order'] ?? 0),
|
'sort_order' => (int) ($data['sort_order'] ?? 0),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
@@ -115,7 +117,9 @@ class DatabaseModuleRegistry
|
|||||||
'alias' => $module->getAlias(),
|
'alias' => $module->getAlias(),
|
||||||
'description' => $status?->description,
|
'description' => $status?->description,
|
||||||
'disk_description' => $module->getDescription(),
|
'disk_description' => $module->getDescription(),
|
||||||
'version' => $this->moduleVersion($module),
|
'version' => $this->databaseVersion($status) ?? $this->moduleVersion($module),
|
||||||
|
'database_version' => $this->databaseVersion($status),
|
||||||
|
'disk_version' => $this->moduleVersion($module),
|
||||||
'sort_order' => (int) ($status?->sort_order ?? $module->get('order', 0)),
|
'sort_order' => (int) ($status?->sort_order ?? $module->get('order', 0)),
|
||||||
'path' => $module->getPath(),
|
'path' => $module->getPath(),
|
||||||
'requires' => $module->getRequires(),
|
'requires' => $module->getRequires(),
|
||||||
@@ -125,6 +129,13 @@ class DatabaseModuleRegistry
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function databaseVersion(?ModuleStatus $status): ?string
|
||||||
|
{
|
||||||
|
$version = $status?->version;
|
||||||
|
|
||||||
|
return is_string($version) && trim($version) !== '' ? trim($version) : null;
|
||||||
|
}
|
||||||
|
|
||||||
protected function moduleVersion(Module $module): ?string
|
protected function moduleVersion(Module $module): ?string
|
||||||
{
|
{
|
||||||
$version = $module->get('version');
|
$version = $module->get('version');
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ return new class extends Migration
|
|||||||
$table->string('module')->unique();
|
$table->string('module')->unique();
|
||||||
$table->boolean('enabled')->default(true);
|
$table->boolean('enabled')->default(true);
|
||||||
$table->text('description')->nullable();
|
$table->text('description')->nullable();
|
||||||
|
$table->string('version')->nullable();
|
||||||
$table->unsignedInteger('sort_order')->default(0);
|
$table->unsignedInteger('sort_order')->default(0);
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
|
|||||||
+9
-1
@@ -19,8 +19,12 @@ return new class extends Migration
|
|||||||
$table->text('description')->nullable()->after('enabled');
|
$table->text('description')->nullable()->after('enabled');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! Schema::hasColumn('module_statuses', 'version')) {
|
||||||
|
$table->string('version')->nullable()->after('description');
|
||||||
|
}
|
||||||
|
|
||||||
if (! Schema::hasColumn('module_statuses', 'sort_order')) {
|
if (! Schema::hasColumn('module_statuses', 'sort_order')) {
|
||||||
$table->unsignedInteger('sort_order')->default(0)->after('description');
|
$table->unsignedInteger('sort_order')->default(0)->after('version');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -36,6 +40,10 @@ return new class extends Migration
|
|||||||
$table->dropColumn('sort_order');
|
$table->dropColumn('sort_order');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Schema::hasColumn('module_statuses', 'version')) {
|
||||||
|
$table->dropColumn('version');
|
||||||
|
}
|
||||||
|
|
||||||
if (Schema::hasColumn('module_statuses', 'description')) {
|
if (Schema::hasColumn('module_statuses', 'description')) {
|
||||||
$table->dropColumn('description');
|
$table->dropColumn('description');
|
||||||
}
|
}
|
||||||
|
|||||||
+36
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
if (! Schema::hasTable('module_statuses')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Schema::table('module_statuses', function (Blueprint $table): void {
|
||||||
|
if (! Schema::hasColumn('module_statuses', 'version')) {
|
||||||
|
$table->string('version')->nullable()->after('description');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
if (! Schema::hasTable('module_statuses')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Schema::table('module_statuses', function (Blueprint $table): void {
|
||||||
|
if (Schema::hasColumn('module_statuses', 'version')) {
|
||||||
|
$table->dropColumn('version');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -71,12 +71,17 @@
|
|||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p class="mt-2 line-clamp-2 text-sm leading-6 text-zinc-600 dark:text-zinc-400">
|
<div class="mt-3 rounded-xl border border-zinc-200 bg-zinc-50 p-3 dark:border-zinc-800 dark:bg-zinc-950/60">
|
||||||
{{ $module['description'] ?: 'No database description saved yet.' }}
|
<div class="text-xs font-semibold uppercase tracking-wide text-zinc-500 dark:text-zinc-400">
|
||||||
</p>
|
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['description'] && $module['disk_description'])
|
@if ($module['disk_description'])
|
||||||
<p class="mt-1 text-xs text-zinc-500">
|
<p class="mt-2 line-clamp-2 text-xs leading-5 text-zinc-500 dark:text-zinc-500">
|
||||||
Disk description: {{ $module['disk_description'] }}
|
Disk description: {{ $module['disk_description'] }}
|
||||||
</p>
|
</p>
|
||||||
@endif
|
@endif
|
||||||
@@ -96,7 +101,12 @@
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
<dt class="text-xs font-semibold uppercase text-zinc-500">Version</dt>
|
<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'] ?: '—' }}</dd>
|
<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>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
<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">
|
<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>
|
<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">
|
<p class="mt-1 text-sm text-zinc-500 dark:text-zinc-400">
|
||||||
This description is stored in the module_statuses table only. It does not edit module.json.
|
Description, version, and sort order are stored in the module_statuses table only. This does not edit module.json.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<form method="POST" action="{{ route('modules.control.update', $module['name']) }}" class="mt-6 space-y-5">
|
<form method="POST" action="{{ route('modules.control.update', $module['name']) }}" class="mt-6 space-y-5">
|
||||||
@@ -39,26 +39,49 @@
|
|||||||
@enderror
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="max-w-xs">
|
<div class="grid gap-5 md:grid-cols-2">
|
||||||
<label for="sort_order" class="block text-sm font-semibold text-zinc-800 dark:text-zinc-200">
|
<div>
|
||||||
Sort order
|
<label for="version" class="block text-sm font-semibold text-zinc-800 dark:text-zinc-200">
|
||||||
</label>
|
Version
|
||||||
<input
|
</label>
|
||||||
id="sort_order"
|
<input
|
||||||
name="sort_order"
|
id="version"
|
||||||
type="number"
|
name="version"
|
||||||
min="0"
|
type="text"
|
||||||
value="{{ old('sort_order', $module['sort_order']) }}"
|
maxlength="50"
|
||||||
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"
|
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"
|
||||||
@error('sort_order')
|
placeholder="Example: 1.0.0"
|
||||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
/>
|
||||||
@enderror
|
<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>
|
||||||
|
|
||||||
<div class="flex flex-wrap gap-3">
|
<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">
|
<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 Database Metadata
|
Save Module Metadata
|
||||||
</button>
|
</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">
|
<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">
|
||||||
@@ -115,7 +138,14 @@
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
<dt class="text-xs font-semibold uppercase text-zinc-500">Version</dt>
|
<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'] ?: '—' }}</dd>
|
<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>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
Reference in New Issue
Block a user