Skip to content

Commit fa1b324

Browse files
committed
frontend: pod: Add deeplink params to view pod logs
1 parent b228929 commit fa1b324

File tree

13 files changed

+42
-31
lines changed

13 files changed

+42
-31
lines changed

frontend/src/components/pod/Details.tsx

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { Terminal as XTerminal } from '@xterm/xterm';
2626
import _ from 'lodash';
2727
import React from 'react';
2828
import { useTranslation } from 'react-i18next';
29-
import { useParams } from 'react-router-dom';
29+
import { useLocation, useParams } from 'react-router-dom';
3030
import { KubeContainerStatus } from '../../lib/k8s/cluster';
3131
import Pod from '../../lib/k8s/pod';
3232
import { DefaultHeaderAction } from '../../redux/actionButtonsSlice';
@@ -491,6 +491,43 @@ 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+
const [podItem, setPodItem] = React.useState<Pod | null>(null);
499+
500+
const launchLogs = React.useCallback(
501+
(item: Pod) => {
502+
Activity.launch({
503+
id: 'logs-' + item.metadata.uid,
504+
title: t('Logs: {{ itemName }}', { itemName: 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+
},
517+
[t, dispatchHeadlampEvent]
518+
);
519+
520+
React.useEffect(() => {
521+
if (
522+
podItem &&
523+
autoLaunchView === 'logs' &&
524+
lastAutoLaunchedPod.current !== podItem.metadata.uid
525+
) {
526+
lastAutoLaunchedPod.current = podItem.metadata.uid;
527+
launchLogs(podItem);
528+
}
529+
}, [podItem, launchLogs, autoLaunchView]);
530+
494531
function prepareExtraInfo(item: Pod | null) {
495532
let extraInfo: {
496533
name: string;
@@ -589,6 +626,9 @@ export default function PodDetails(props: PodDetailsProps) {
589626
namespace={namespace}
590627
cluster={cluster}
591628
withEvents
629+
onResourceUpdate={item => {
630+
setPodItem(item);
631+
}}
592632
actions={item =>
593633
item && [
594634
{
@@ -598,24 +638,7 @@ export default function PodDetails(props: PodDetailsProps) {
598638
<ActionButton
599639
description={t('Show Logs')}
600640
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-
}}
641+
onClick={() => launchLogs(item)}
619642
/>
620643
</AuthVisible>
621644
),

frontend/src/i18n/locales/de/glossary.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@
162162
"QoS Class": "QoS-Klasse",
163163
"Priority": "Priorität",
164164
"Show Logs": "Ereignisprotokolle anzeigen",
165-
"Logs": "",
166165
"Terminal / Exec": "Terminal / Befehl ausführen",
167166
"Attach": "Anhängen",
168167
"Restarts": "Neustarts",

frontend/src/i18n/locales/en/glossary.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@
162162
"QoS Class": "QoS Class",
163163
"Priority": "Priority",
164164
"Show Logs": "Show Logs",
165-
"Logs": "Logs",
166165
"Terminal / Exec": "Terminal / Exec",
167166
"Attach": "Attach",
168167
"Restarts": "Restarts",

frontend/src/i18n/locales/es/glossary.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@
162162
"QoS Class": "Clase QoS",
163163
"Priority": "Prioridad",
164164
"Show Logs": "Mostrar Registros",
165-
"Logs": "",
166165
"Terminal / Exec": "Terminal / Exec",
167166
"Attach": "Adjuntar",
168167
"Restarts": "Reinicios",

frontend/src/i18n/locales/fr/glossary.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@
162162
"QoS Class": "Classe QoS",
163163
"Priority": "Priorité",
164164
"Show Logs": "Afficher les journaux",
165-
"Logs": "",
166165
"Terminal / Exec": "Terminal / Exécution",
167166
"Attach": "Attacher",
168167
"Restarts": "Redémarrages",

frontend/src/i18n/locales/hi/glossary.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@
162162
"QoS Class": "QoS क्लास",
163163
"Priority": "प्राथमिकता",
164164
"Show Logs": "लॉग्स दिखाएं",
165-
"Logs": "",
166165
"Terminal / Exec": "टर्मिनल / एक्जेक",
167166
"Attach": "अटैच",
168167
"Restarts": "रीस्टार्ट",

frontend/src/i18n/locales/it/glossary.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@
162162
"QoS Class": "Classe QoS",
163163
"Priority": "Priorità",
164164
"Show Logs": "Mostra Log",
165-
"Logs": "",
166165
"Terminal / Exec": "Terminale / Esegui",
167166
"Attach": "Collega",
168167
"Restarts": "Riavvii",

frontend/src/i18n/locales/ja/glossary.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@
162162
"QoS Class": "QoS クラス",
163163
"Priority": "優先度",
164164
"Show Logs": "ログの表示",
165-
"Logs": "",
166165
"Terminal / Exec": "ターミナル / 実行",
167166
"Attach": "アタッチ",
168167
"Restarts": "再起動",

frontend/src/i18n/locales/ko/glossary.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@
162162
"QoS Class": "QoS 클래스",
163163
"Priority": "우선순위",
164164
"Show Logs": "로그 보기",
165-
"Logs": "",
166165
"Terminal / Exec": "터미널 / 실행",
167166
"Attach": "연결",
168167
"Restarts": "재시작",

frontend/src/i18n/locales/pt/glossary.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@
162162
"QoS Class": "Classe QoS",
163163
"Priority": "Prioridade",
164164
"Show Logs": "Mostrar Registos",
165-
"Logs": "",
166165
"Terminal / Exec": "Terminal / Exec",
167166
"Attach": "Anexar",
168167
"Restarts": "Reinícios",

0 commit comments

Comments
 (0)