Skip to content

Commit 9b86833

Browse files
committed
frontend: pod: Added deeplink params to view pod logs
1 parent b228929 commit 9b86833

File tree

13 files changed

+37
-31
lines changed

13 files changed

+37
-31
lines changed

frontend/src/components/pod/Details.tsx

Lines changed: 37 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,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
),

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)