Skip to content

Commit

Permalink
fix: switch pod logs (#5040)
Browse files Browse the repository at this point in the history
  • Loading branch information
zijiren233 authored Sep 5, 2024
1 parent 95ce6b8 commit 8eef22e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const LogsModal = ({
const watchLogs = useCallback(() => {
// podName is empty. pod may has been deleted
if (!podName) return closeFn();
setIsLoading(true);

const controller = new AbortController();
streamFetch({
Expand All @@ -60,6 +61,7 @@ const LogsModal = ({
abortSignal: controller,
firstResponse() {
setIsLoading(false);
setLogs('');
setTimeout(() => {
if (!LogBox.current) return;

Expand Down Expand Up @@ -96,7 +98,7 @@ const LogsModal = ({
return () => {
controller?.abort();
};
}, []);
}, [watchLogs]);

const exportLogs = useCallback(async () => {
const allLogs = await getPodLogs({
Expand All @@ -116,7 +118,7 @@ const LogsModal = ({
<Box fontSize={'xl'} fontWeight={'bold'}>
Pod {t('Log')}
</Box>
<Box px={3}>
<Box px={3} zIndex={10000}>
<SealosMenu
width={240}
Button={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ const Pods = ({
const [detailPodIndex, setDetailPodIndex] = useState<number>();
const [detailFilePodIndex, setDetailFilePodIndex] = useState<number>();

const closeFn = useCallback(() => setLogsPodIndex(undefined), [setLogsPodIndex]);

const { Loading } = useLoading();
const { openConfirm: openConfirmRestart, ConfirmChild: RestartConfirmChild } = useConfirm({
content: 'Please confirm to restart the Pod?'
Expand Down Expand Up @@ -306,7 +308,7 @@ const Pods = ({
setLogsPodName={(name: string) =>
setLogsPodIndex(pods.findIndex((item) => item.podName === name))
}
closeFn={() => setLogsPodIndex(undefined)}
closeFn={closeFn}
/>
)}
{detailPodIndex !== undefined && (
Expand Down

0 comments on commit 8eef22e

Please sign in to comment.