Skip to content

Commit 83405b0

Browse files
Merge pull request #1469 from devtron-labs/fix/log-analyser-default-opt
fix: change default opt
2 parents 07e6bb2 + 0114d1f commit 83405b0

File tree

4 files changed

+48
-12
lines changed

4 files changed

+48
-12
lines changed

src/components/ResourceBrowser/ResourceList/ResourceList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ export default function ResourceList() {
551551
replace({
552552
pathname: `${URLS.RESOURCE_BROWSER}/${_clusterId}/${
553553
namespace || ALL_NAMESPACE_OPTION.value
554-
}/${SIDEBAR_KEYS.overviewGVK.Kind.toLowerCase()}/${K8S_EMPTY_GROUP}${searchParam}`,
554+
}/${SIDEBAR_KEYS.nodeGVK.Kind.toLowerCase()}/${K8S_EMPTY_GROUP}${searchParam}`,
555555
})
556556
}
557557
setSelectedResource({

src/components/v2/appDetails/k8Resource/NodeTreeTabList.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { ReactComponent as Cross } from '../../../../assets/icons/ic-close.svg'
99
import Tippy from '@tippyjs/react'
1010
import { ConditionalWrap } from '../../../common'
1111
import './NodeTreeTabList.scss'
12+
import ReactGA from 'react-ga4'
1213

1314
export default function NodeTreeTabList({ logSearchTerms, setLogSearchTerms, tabRef }: NodeTreeTabListProps) {
1415
const { nodeType } = useParams<{ nodeType: string }>()
@@ -45,6 +46,16 @@ export default function NodeTreeTabList({ logSearchTerms, setLogSearchTerms, tab
4546
}, 1)
4647
}
4748

49+
const sendLogAnalyserEvent = (tab: ApplicationObject) => {
50+
if (tab.name === AppDetailsTabs.log_analyzer) {
51+
ReactGA.event({
52+
category: 'log analyser',
53+
action: 'log-analyser-clicked',
54+
label: '',
55+
})
56+
}
57+
}
58+
4859
const getTabNavLink = (tab: ApplicationObject) => {
4960
return (
5061
<NavLink
@@ -53,6 +64,7 @@ export default function NodeTreeTabList({ logSearchTerms, setLogSearchTerms, tab
5364
className="resource-tree__tab-hover tab-list__tab resource-tab__node cursor cn-9 fw-6 dc__no-decor m-0-imp"
5465
>
5566
<div
67+
onClick={() => sendLogAnalyserEvent(tab)}
5668
className={`flex left ${tab.isSelected ? 'cn-9' : ''} ${
5769
tab.isDeleted ? 'tab-list__deleted cr-5' : ''
5870
}`}
@@ -104,7 +116,12 @@ export default function NodeTreeTabList({ logSearchTerms, setLogSearchTerms, tab
104116
}
105117
wrap={(children) => {
106118
return (
107-
<Tippy className="default-tt dc_max-width__max-content" arrow={false} placement="top" content={tab.title}>
119+
<Tippy
120+
className="default-tt dc_max-width__max-content"
121+
arrow={false}
122+
placement="top"
123+
content={tab.title}
124+
>
108125
{children}
109126
</Tippy>
110127
)

src/components/v2/appDetails/k8Resource/nodeDetail/NodeDetailTabs/Logs.component.tsx

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { getLogsURL } from '../nodeDetail.api'
1010
import IndexStore from '../../../index.store'
1111
import WebWorker from '../../../../../app/WebWorker'
1212
import sseWorker from '../../../../../app/grepSSEworker'
13-
import { Checkbox, CHECKBOX_VALUE, Host} from '@devtron-labs/devtron-fe-common-lib';
13+
import { Checkbox, CHECKBOX_VALUE, Host } from '@devtron-labs/devtron-fe-common-lib'
1414
import { Subject } from '../../../../../../util/Subject'
1515
import LogViewerComponent from './LogViewer.component'
1616
import { useKeyDown } from '../../../../../common'
@@ -33,6 +33,7 @@ import {
3333
getSelectedPodList,
3434
} from '../nodeDetail.util'
3535
import './nodeDetailTab.scss'
36+
import ReactGA from 'react-ga4'
3637

3738
const subject: Subject<string> = new Subject()
3839
const commandLineParser = require('command-line-parser')
@@ -77,6 +78,14 @@ function LogsComponent({
7778
}
7879

7980
const handlePodSelection = (selectedOption: string) => {
81+
if (selectedOption.startsWith('All ')) {
82+
ReactGA.event({
83+
category: 'log analyser',
84+
action: 'all-pods-selected',
85+
label: '',
86+
})
87+
}
88+
8089
const pods = getSelectedPodList(selectedOption)
8190
const containers = new Set(pods[0].containers ?? [])
8291
const selectedContainer = containers.has(logState.selectedContainerOption)
@@ -146,7 +155,11 @@ function LogsComponent({
146155
subject.publish(log)
147156
if (prevContainer) {
148157
for (const _co of podContainerOptions.containerOptions) {
149-
if ( _co.selected && log.toString() === `previous terminated container "${_co.name}" in pod "${podContainerOptions.podOptions[0].name}" not found`) {
158+
if (
159+
_co.selected &&
160+
log.toString() ===
161+
`previous terminated container "${_co.name}" in pod "${podContainerOptions.podOptions[0].name}" not found`
162+
) {
150163
setNoPrevContainer(log.toString())
151164
}
152165
}
@@ -410,10 +423,11 @@ function LogsComponent({
410423
<Select
411424
placeholder="Select Pod"
412425
options={getPodGroups()}
413-
defaultValue={getFirstOrNull(
414-
podContainerOptions.podOptions
415-
.filter((_pod) => _pod.selected)
416-
.map((_pod) => ({ label: _pod.name, value: _pod.name })),
426+
defaultValue={getFirstOrNull<{ label: string; value: string }>(
427+
podContainerOptions.podOptions.map((_pod) => ({
428+
label: _pod.name,
429+
value: _pod.name,
430+
})),
417431
)}
418432
onChange={(selected) => handlePodSelection(selected.value)}
419433
styles={{

src/components/v2/appDetails/k8Resource/nodeDetail/nodeDetail.util.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,16 @@ export function getInitialPodContainerSelection(
221221
}
222222
}
223223

224-
export function getFirstOrNull<T>(arr: T[]): T | null {
225-
if (arr.length > 0) {
226-
return arr[0]
224+
export function getFirstOrNull<T extends {label:string}>(arr: T[]): T | null {
225+
226+
if(arr.length === 0){
227+
return null
227228
}
228-
return null
229+
// remove all pods in 'ALL PODS FOR' category, to get only 'INDIVIDUAL PODS' list
230+
const indvPodsList: T[] = arr.filter((_pod) => !_pod.label.startsWith('All '))
231+
232+
// select first pod from the 'INDIVIDUAL PODS' list
233+
return indvPodsList.length > 0 ? indvPodsList[0] : null
229234
}
230235

231236
export const getContainerSelectStyles = () => {

0 commit comments

Comments
 (0)