@@ -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' ;
@@ -490,6 +490,30 @@ export default function PodDetails(props: PodDetailsProps) {
490490 const { name = params . name , namespace = params . namespace , cluster } = props ;
491491 const { t } = useTranslation ( 'glossary' ) ;
492492 const dispatchHeadlampEvent = useEventCallback ( ) ;
493+ //Get query parameters:
494+ const location = useLocation ( ) ;
495+ const query = new URLSearchParams ( location . search ) ;
496+ const autoLaunchView = query . get ( 'view' ) ;
497+ //Only Launch Once:
498+ const hasAutoLaunched = React . useRef ( false ) ;
499+
500+ //Helper to launch logs (used by both button and deep link):
501+ const launchLogs = ( item : Pod ) => {
502+ Activity . launch ( {
503+ id : 'logs-' + item . metadata . uid ,
504+ title : t ( 'Logs' ) + ': ' + item . metadata . name ,
505+ cluster : item . cluster ,
506+ icon : < Icon icon = "mdi:file-document-box-outline" width = "100%" height = "100%" /> ,
507+ location : 'full' ,
508+ content : < PodLogViewer noDialog open item = { item } onClose = { ( ) => { } } /> ,
509+ } ) ;
510+ dispatchHeadlampEvent ( {
511+ type : HeadlampEventType . LOGS ,
512+ data : {
513+ status : EventStatus . OPENED ,
514+ } ,
515+ } ) ;
516+ } ;
493517
494518 function prepareExtraInfo ( item : Pod | null ) {
495519 let extraInfo : {
@@ -589,33 +613,24 @@ export default function PodDetails(props: PodDetailsProps) {
589613 namespace = { namespace }
590614 cluster = { cluster }
591615 withEvents
592- actions = { item =>
593- item && [
616+ actions = { item => {
617+ if ( item && autoLaunchView === 'logs' && ! hasAutoLaunched . current ) {
618+ hasAutoLaunched . current = true ;
619+ //Set Timeout to prevent Rendering Issues:
620+ setTimeout ( ( ) => launchLogs ( item ) , 0 ) ;
621+ }
622+
623+ if ( ! item ) return null ;
624+
625+ return [
594626 {
595627 id : DefaultHeaderAction . POD_LOGS ,
596628 action : (
597629 < AuthVisible item = { item } authVerb = "get" subresource = "log" >
598630 < ActionButton
599631 description = { t ( 'Show Logs' ) }
600632 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- } }
633+ onClick = { ( ) => launchLogs ( item ) }
619634 />
620635 </ AuthVisible >
621636 ) ,
@@ -678,8 +693,8 @@ export default function PodDetails(props: PodDetailsProps) {
678693 </ AuthVisible >
679694 ) ,
680695 } ,
681- ]
682- }
696+ ] ;
697+ } }
683698 extraInfo = { item => prepareExtraInfo ( item ) }
684699 extraSections = { item =>
685700 item && [
0 commit comments