diff --git a/app/Http/Middleware/EnsureAdmin.php b/app/Http/Middleware/EnsureAdmin.php
index 68d29cc..7c6acc8 100644
--- a/app/Http/Middleware/EnsureAdmin.php
+++ b/app/Http/Middleware/EnsureAdmin.php
@@ -19,7 +19,9 @@ class EnsureAdmin
{
$user = $request->user();
- if ($user instanceof User && $user->is_admin && ! $user->isOperator()) {
+ // Only a genuinely un-migrated legacy admin (is_admin, but NO roles at
+ // all) is promoted — never override an intentional demotion/other role.
+ if ($user instanceof User && $user->is_admin && $user->roles->isEmpty()) {
$user->assignRole('Owner');
}
diff --git a/app/Livewire/Admin/EditDatacenter.php b/app/Livewire/Admin/EditDatacenter.php
index 87444d7..dbf02f1 100644
--- a/app/Livewire/Admin/EditDatacenter.php
+++ b/app/Livewire/Admin/EditDatacenter.php
@@ -22,6 +22,9 @@ class EditDatacenter extends ModalComponent
public string $location = '';
+ /** The location present when the modal opened — a pre-curation free-form value. */
+ public string $originalLocation = '';
+
public function mount(string $uuid): void
{
$this->authorize('datacenters.manage'); // modals are reachable without the route middleware
@@ -30,15 +33,22 @@ class EditDatacenter extends ModalComponent
$this->code = $dc->code;
$this->name = $dc->name;
$this->location = (string) $dc->location;
+ $this->originalLocation = (string) $dc->location;
}
public function save()
{
$this->authorize('datacenters.manage');
- // Validate the country against the configured list so add + edit stay in sync.
+ // Accept the configured countries plus the record's own legacy value, so a
+ // datacenter created before the curated list can still be edited (e.g. a
+ // name-only change) without being forced to replace a free-form location.
+ $allowed = array_keys((array) config('countries'));
+ if ($this->originalLocation !== '') {
+ $allowed[] = $this->originalLocation;
+ }
$data = $this->validate([
'name' => 'required|string|max:255',
- 'location' => 'nullable|in:'.implode(',', array_keys((array) config('countries'))),
+ 'location' => 'nullable|in:'.implode(',', $allowed),
]);
Datacenter::query()->where('uuid', $this->uuid)->update([
diff --git a/resources/views/livewire/admin/edit-datacenter.blade.php b/resources/views/livewire/admin/edit-datacenter.blade.php
index a8763de..49ad576 100644
--- a/resources/views/livewire/admin/edit-datacenter.blade.php
+++ b/resources/views/livewire/admin/edit-datacenter.blade.php
@@ -14,6 +14,9 @@