mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-20 19:18:45 +00:00
Merge pull request #5116 from thaingnguyen/agent/fix-stack-log-container-selection
fix: preserve selected stack log container
This commit is contained in:
@@ -72,16 +72,20 @@ export const ShowDockerLogsStack = ({
|
|||||||
const containers = data?.filter((container) => container.containerId);
|
const containers = data?.filter((container) => container.containerId);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (option === "native") {
|
const currentContainers = option === "native" ? containers : services;
|
||||||
if (containers && containers?.length > 0) {
|
|
||||||
setContainerId(containers[0]?.containerId);
|
if (currentContainers) {
|
||||||
}
|
const nextContainerId = currentContainers.some(
|
||||||
} else {
|
(container) => container.containerId === containerId,
|
||||||
if (services && services?.length > 0) {
|
)
|
||||||
setContainerId(services[0]?.containerId);
|
? containerId
|
||||||
|
: currentContainers[0]?.containerId;
|
||||||
|
|
||||||
|
if (nextContainerId !== containerId) {
|
||||||
|
setContainerId(nextContainerId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [option, services, containers]);
|
}, [option, services, containers, containerId]);
|
||||||
|
|
||||||
const isLoading = option === "native" ? containersLoading : servicesLoading;
|
const isLoading = option === "native" ? containersLoading : servicesLoading;
|
||||||
const containersLength =
|
const containersLength =
|
||||||
@@ -106,6 +110,7 @@ export const ShowDockerLogsStack = ({
|
|||||||
<Switch
|
<Switch
|
||||||
checked={option === "native"}
|
checked={option === "native"}
|
||||||
onCheckedChange={(checked) => {
|
onCheckedChange={(checked) => {
|
||||||
|
setContainerId(undefined);
|
||||||
setOption(checked ? "native" : "swarm");
|
setOption(checked ? "native" : "swarm");
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user