Skip to content

Commit 48dc96e

Browse files
author
Mukul Tayal
committed
PR comments and disable download for nor prev container
1 parent f1e5a1b commit 48dc96e

File tree

3 files changed

+28
-26
lines changed

3 files changed

+28
-26
lines changed

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

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,6 @@ function LogsComponent({
127127
setPrevContainer(false)
128128
}
129129

130-
const handleLogsShown = (option) => {
131-
setLogsShownOption({
132-
prev: logsShownOption.current,
133-
current: option,
134-
})
135-
}
136-
137130
const handleSearchTextChange = (searchText: string) => {
138131
if (!searchText) {
139132
setLogState({
@@ -365,6 +358,18 @@ function LogsComponent({
365358
}
366359
}
367360

361+
const handleLogOptionChange = (selected) => {
362+
setLogsShownOption({
363+
prev: logsShownOption.current,
364+
current: selected,
365+
})
366+
if (selected.value !== CUSTOM_LOGS_FILTER.CUSTOM) {
367+
setNewFilteredLogs(true)
368+
} else {
369+
setShowCustomOptionsMoadal(true)
370+
}
371+
}
372+
368373
useEffect(() => {
369374
logsPausedRef.current = logsPaused
370375
}, [logsPaused])
@@ -662,14 +667,7 @@ function LogsComponent({
662667
<LinesIcon className="icon-dim-16 mr-8" />
663668
<Select
664669
options={getPodLogsOptions()}
665-
onChange={(selected) => {
666-
handleLogsShown(selected)
667-
if (selected.value !== CUSTOM_LOGS_FILTER.CUSTOM) {
668-
setNewFilteredLogs(true)
669-
} else {
670-
setShowCustomOptionsMoadal(true)
671-
}
672-
}}
670+
onChange={handleLogOptionChange}
673671
value={logsShownOption.current}
674672
styles={{
675673
...multiSelectStyles,
@@ -690,9 +688,10 @@ function LogsComponent({
690688
<Tippy className="default-tt" arrow={false} placement="top" content={'Download logs'}>
691689
<Download
692690
className={`icon-dim-16 mr-8 cursor ${
693-
(podContainerOptions?.containerOptions ?? []).length > 0
694-
? ''
695-
: 'cursor-not-allowed dc__opacity-0_5'
691+
(podContainerOptions?.containerOptions ?? []).length === 0 ||
692+
(prevContainer && showNoPrevContainer != '')
693+
? 'cursor-not-allowed dc__opacity-0_5'
694+
: ''
696695
}`}
697696
onClick={handleDownloadLogs}
698697
/>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ export const getLogsURL = (
229229
clusterId?: number,
230230
namespace?: string,
231231
) => {
232+
//similar logic exists in downloadLogs function also, recheck changes there also or extract this logic in a common function
232233
let filter = ''
233234
if (logsOption.value === CUSTOM_LOGS_FILTER.CUSTOM) {
234235
filter = getFilterWithValue(customOption.option, customOption.value, customOption.unit)

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -350,14 +350,16 @@ export const excludeFutureTimingsOptions = (allOptions, index) => {
350350
}
351351

352352
export const getTimeFromTimestamp = (timestamp) => {
353-
const date = new Date(+timestamp * 1000);
354-
const hours = date.getHours();
355-
const minutes = date.getMinutes();
356-
const seconds = date.getSeconds();
357-
const value= `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`
358-
return ALLOW_UNTIL_TIME_OPTIONS.filter((option) => {
359-
return option.value == value
360-
})
353+
const date = new Date(+timestamp * 1000)
354+
const hours = date.getHours()
355+
const minutes = date.getMinutes()
356+
const seconds = date.getSeconds()
357+
const value = `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${seconds
358+
.toString()
359+
.padStart(2, '0')}`
360+
return ALLOW_UNTIL_TIME_OPTIONS.filter((option) => {
361+
return option.value == value
362+
})
361363
}
362364

363365
export const getDurationUnits = () => [

0 commit comments

Comments
 (0)