fix(terminal): distinguish application containers across servers
This commit is contained in:
parent
1e8a27b084
commit
d25edb8551
2 changed files with 9 additions and 4 deletions
|
|
@ -151,13 +151,18 @@ public function loadContainers(): void
|
|||
});
|
||||
|
||||
if ($this->containers->count() === 1) {
|
||||
$this->selected_container = data_get($this->containers->first(), 'container.Names');
|
||||
$this->selected_container = $this->containerTarget($this->containers->first());
|
||||
$this->connectToContainer();
|
||||
}
|
||||
|
||||
$this->containersLoaded = true;
|
||||
}
|
||||
|
||||
private function containerTarget(array $container): string
|
||||
{
|
||||
return data_get($container, 'server.uuid').':'.data_get($container, 'container.Names');
|
||||
}
|
||||
|
||||
public function updatedSelectedContainer()
|
||||
{
|
||||
if ($this->selected_container !== 'default') {
|
||||
|
|
@ -202,12 +207,12 @@ public function connectToContainer()
|
|||
try {
|
||||
$this->authorize('canAccessTerminal');
|
||||
// Validate container name format
|
||||
if (! ValidationPatterns::isValidContainerName($this->selected_container)) {
|
||||
if (! ValidationPatterns::isValidContainerName(str($this->selected_container)->after(':')->value())) {
|
||||
throw new \InvalidArgumentException('Invalid container name format');
|
||||
}
|
||||
|
||||
// Verify container exists in our allowed list
|
||||
$container = collect($this->containers)->firstWhere('container.Names', $this->selected_container);
|
||||
$container = $this->containers->first(fn ($candidate) => $this->containerTarget($candidate) === $this->selected_container);
|
||||
if (is_null($container)) {
|
||||
throw new \RuntimeException('Container not found.');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
$consoleThemeNames = collect($consoleThemes)->pluck('name', 'key');
|
||||
$consoleThemeAccents = collect($consoleThemes)->pluck('accent', 'key');
|
||||
$containerOptions = $containers->map(fn ($container) => [
|
||||
'value' => data_get($container, 'container.Names'),
|
||||
'value' => data_get($container, 'server.uuid').':'.data_get($container, 'container.Names'),
|
||||
'label' => data_get($container, 'container.Names').' · '.data_get($container, 'server.name'),
|
||||
])->values();
|
||||
@endphp
|
||||
|
|
|
|||
Loading…
Reference in a new issue