@@ -2,10 +2,6 @@ import React, { useCallback, useEffect } from "react";
2
2
import { useState } from "react" ;
3
3
import { useDispatch , useSelector } from "react-redux" ;
4
4
import styled from "styled-components" ;
5
- import {
6
- APP_HEADER_HEIGHT ,
7
- SUB_APP_HEADER_HEIGHT ,
8
- } from "../../../constants/ui" ;
9
5
import Session from "../../../interfaces/session" ;
10
6
import {
11
7
addPollingTask ,
@@ -24,11 +20,6 @@ import ParallelLayout, { Column } from "../layouts/parallel-layout";
24
20
import SerialLayout , { Row } from "../layouts/serial-layout" ;
25
21
import { TAB_HEADER_HEIGHT } from "../layouts/tab-layout" ;
26
22
import Centered from "../molecules/centered" ;
27
- import { SUMMARY_HEIGHT } from "./session-details" ;
28
-
29
- const LineNumber = styled . div `
30
- color: #6a707a;
31
- ` ;
32
23
33
24
const LogsEntry = styled . div `
34
25
padding: 3px 3px 3px 3px;
@@ -74,6 +65,23 @@ const Content = styled.div`
74
65
overflow: scroll;
75
66
` ;
76
67
68
+ //TODO: Refactor this. temporary changes
69
+ const StyledInput = styled ( Input ) `
70
+ background: transparent;
71
+ border-bottom: 1px solid #fff;
72
+
73
+ &&& input {
74
+ background: transparent;
75
+ color: #fff;
76
+ border: none;
77
+ }
78
+
79
+ &&& path {
80
+ background: #fff;
81
+ stroke: #fff;
82
+ }
83
+ ` ;
84
+
77
85
type PropsType = {
78
86
session : Session ;
79
87
parentHeight : number ;
@@ -85,22 +93,21 @@ export default function SessionDeviceLogs(props: PropsType) {
85
93
const logs = useLogs ( filterText ) ;
86
94
const isLoading = useSelector ( getisDeviceLogsLoading ) ;
87
95
const dispatch = useDispatch ( ) ;
88
- const [ enablePolling , setEnablePolling ] = useState ( true ) ;
96
+ const [ enablePolling , setEnablePolling ] = useState ( ! session . is_completed ) ;
89
97
90
98
useEffect ( ( ) => {
91
99
dispatch ( fetchSessionDeviceLogs ( session . session_id ) ) ;
92
- if ( enablePolling ) {
93
- togglePolling ( true ) ;
94
- }
95
100
96
101
if ( session . is_completed ) {
97
- dispatch ( removePollingTask ( fetchSessionDeviceLogs ( session . session_id ) ) ) ;
102
+ togglePolling ( false ) ;
103
+ } else if ( enablePolling ) {
104
+ togglePolling ( true ) ;
98
105
}
99
106
100
107
return ( ) => {
101
108
togglePolling ( false ) ;
102
109
} ;
103
- } , [ session . session_id ] ) ;
110
+ } , [ session . session_id , session . is_completed ] ) ;
104
111
105
112
const togglePolling = useCallback ( ( on : boolean ) => {
106
113
if ( on ) {
@@ -125,7 +132,7 @@ export default function SessionDeviceLogs(props: PropsType) {
125
132
< Header >
126
133
< ParallelLayout >
127
134
< Column grid = { 4 } >
128
- < Input
135
+ < StyledInput
129
136
name = "search"
130
137
type = "text"
131
138
leftIcon = "search"
@@ -134,13 +141,15 @@ export default function SessionDeviceLogs(props: PropsType) {
134
141
onChange = { ( e ) => setFilterText ( e . target . value ) }
135
142
/>
136
143
</ Column >
137
- < Column grid = { 4 } padding = "0px 10px" >
138
- < CheckboxComponent
139
- label = "Enable Polling"
140
- checked = { enablePolling }
141
- onChange = { ( checked : boolean ) => togglePolling ( checked ) }
142
- />
143
- </ Column >
144
+ { ! session . is_completed ? (
145
+ < Column grid = { 4 } padding = "0px 10px" >
146
+ < CheckboxComponent
147
+ label = "Enable Polling"
148
+ checked = { enablePolling }
149
+ onChange = { ( checked : boolean ) => togglePolling ( checked ) }
150
+ />
151
+ </ Column >
152
+ ) : null }
144
153
</ ParallelLayout >
145
154
</ Header >
146
155
</ Row >
0 commit comments