@@ -26,7 +26,7 @@ import { Terminal as XTerminal } from '@xterm/xterm';
2626import _ from 'lodash' ;
2727import React from 'react' ;
2828import { useTranslation } from 'react-i18next' ;
29- import { useParams } from 'react-router-dom' ;
29+ import { useLocation , useParams } from 'react-router-dom' ;
3030import { KubeContainerStatus } from '../../lib/k8s/cluster' ;
3131import Pod from '../../lib/k8s/pod' ;
3232import { DefaultHeaderAction } from '../../redux/actionButtonsSlice' ;
@@ -491,6 +491,31 @@ export default function PodDetails(props: PodDetailsProps) {
491491 const { t } = useTranslation ( 'glossary' ) ;
492492 const dispatchHeadlampEvent = useEventCallback ( ) ;
493493
494+ const lastAutoLaunchedPod = React . useRef < string | null > ( null ) ;
495+ const location = useLocation ( ) ;
496+ const queryParams = new URLSearchParams ( location . search ) ;
497+ const autoLaunchView = queryParams . get ( 'view' ) ;
498+
499+ const launchLogs = React . useCallback (
500+ ( item : Pod ) => {
501+ Activity . launch ( {
502+ id : 'logs-' + item . metadata . uid ,
503+ title : t ( 'Logs: {{ itemName }}' , { itemName : item . metadata . name } ) ,
504+ cluster : item . cluster ,
505+ icon : < Icon icon = "mdi:file-document-box-outline" width = "100%" height = "100%" /> ,
506+ location : 'full' ,
507+ content : < PodLogViewer noDialog open item = { item } onClose = { ( ) => { } } /> ,
508+ } ) ;
509+ dispatchHeadlampEvent ( {
510+ type : HeadlampEventType . LOGS ,
511+ data : {
512+ status : EventStatus . OPENED ,
513+ } ,
514+ } ) ;
515+ } ,
516+ [ t , dispatchHeadlampEvent ]
517+ ) ;
518+
494519 function prepareExtraInfo ( item : Pod | null ) {
495520 let extraInfo : {
496521 name : string ;
@@ -589,6 +614,16 @@ export default function PodDetails(props: PodDetailsProps) {
589614 namespace = { namespace }
590615 cluster = { cluster }
591616 withEvents
617+ onResourceUpdate = { item => {
618+ if (
619+ item &&
620+ autoLaunchView === 'logs' &&
621+ lastAutoLaunchedPod . current !== item . metadata . uid
622+ ) {
623+ lastAutoLaunchedPod . current = item . metadata . uid ;
624+ launchLogs ( item ) ;
625+ }
626+ } }
592627 actions = { item =>
593628 item && [
594629 {
@@ -598,24 +633,7 @@ export default function PodDetails(props: PodDetailsProps) {
598633 < ActionButton
599634 description = { t ( 'Show Logs' ) }
600635 icon = "mdi:file-document-box-outline"
601- onClick = { ( ) => {
602- Activity . launch ( {
603- id : 'logs-' + item . metadata . uid ,
604- title : t ( 'Logs' ) + ': ' + item . metadata . name ,
605- cluster : item . cluster ,
606- icon : (
607- < Icon icon = "mdi:file-document-box-outline" width = "100%" height = "100%" />
608- ) ,
609- location : 'full' ,
610- content : < PodLogViewer noDialog open item = { item } onClose = { ( ) => { } } /> ,
611- } ) ;
612- dispatchHeadlampEvent ( {
613- type : HeadlampEventType . LOGS ,
614- data : {
615- status : EventStatus . OPENED ,
616- } ,
617- } ) ;
618- } }
636+ onClick = { ( ) => launchLogs ( item ) }
619637 />
620638 </ AuthVisible >
621639 ) ,
0 commit comments