Skip to content

Commit 8cfb16e

Browse files
committed
fix pr comments
1 parent e638988 commit 8cfb16e

File tree

7 files changed

+35
-30
lines changed

7 files changed

+35
-30
lines changed

redisinsight/ui/src/components/monitor-config/MonitorConfig.spec.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { cloneDeep } from 'lodash'
33
import React from 'react'
44
import MockedSocket from 'socket.io-mock'
55
import socketIO from 'socket.io-client'
6-
import { monitorSelector, setLoadingPause, setSocket, stopMonitor } from 'uiSrc/slices/cli/monitor'
6+
import { monitorSelector, setMonitorLoadingPause, setSocket, stopMonitor } from 'uiSrc/slices/cli/monitor'
77
import { cleanup, mockedStore, render } from 'uiSrc/utils/test-utils'
88
import { MonitorEvent, SocketEvent } from 'uiSrc/constants'
99
import MonitorConfig from './MonitorConfig'
@@ -52,7 +52,7 @@ describe('MonitorConfig', () => {
5252
const { unmount } = render(<MonitorConfig />)
5353
const afterRenderActions = [
5454
setSocket(socket),
55-
setLoadingPause(true)
55+
setMonitorLoadingPause(true)
5656
]
5757
expect(store.getActions()).toEqual([...afterRenderActions])
5858

@@ -75,7 +75,7 @@ describe('MonitorConfig', () => {
7575

7676
const afterRenderActions = [
7777
setSocket(socket),
78-
setLoadingPause(true)
78+
setMonitorLoadingPause(true)
7979
]
8080
expect(store.getActions()).toEqual([...afterRenderActions])
8181

@@ -99,7 +99,7 @@ describe('MonitorConfig', () => {
9999

100100
const afterRenderActions = [
101101
setSocket(socket),
102-
setLoadingPause(true),
102+
setMonitorLoadingPause(true),
103103
stopMonitor()
104104
]
105105
expect(store.getActions()).toEqual([...afterRenderActions])
@@ -123,7 +123,7 @@ describe('MonitorConfig', () => {
123123

124124
const afterRenderActions = [
125125
setSocket(socket),
126-
setLoadingPause(true),
126+
setMonitorLoadingPause(true),
127127
stopMonitor()
128128
]
129129
expect(store.getActions()).toEqual([...afterRenderActions])
@@ -143,7 +143,7 @@ describe('MonitorConfig', () => {
143143

144144
const afterRenderActions = [
145145
setSocket(socket),
146-
setLoadingPause(true),
146+
setMonitorLoadingPause(true),
147147
stopMonitor()
148148
]
149149
expect(store.getActions()).toEqual([...afterRenderActions])

redisinsight/ui/src/components/monitor-config/MonitorConfig.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
setError,
1212
resetMonitorItems,
1313
setStartTimestamp,
14-
setLoadingPause
14+
setMonitorLoadingPause
1515
} from 'uiSrc/slices/cli/monitor'
1616
import { getBaseApiUrl } from 'uiSrc/utils'
1717
import { MonitorErrorMessages, MonitorEvent, SocketErrors, SocketEvent } from 'uiSrc/constants'
@@ -60,7 +60,7 @@ const MonitorConfig = ({ retryDelay = 10000 } : IProps) => {
6060
let payloads: IMonitorDataPayload[] = []
6161

6262
const handleMonitorEvents = () => {
63-
dispatch(setLoadingPause(false))
63+
dispatch(setMonitorLoadingPause(false))
6464
newSocket.on(MonitorEvent.MonitorData, (payload: IMonitorData[]) => {
6565
payloads = payloads.concat(payload)
6666

@@ -125,11 +125,11 @@ const MonitorConfig = ({ retryDelay = 10000 } : IProps) => {
125125
if (!isRunning) return
126126

127127
const pauseUnpause = async () => {
128-
!isPaused && await new Promise<void>((resolve) => { socket?.emit(MonitorEvent.Monitor, () => resolve()) })
128+
!isPaused && await new Promise<void>((resolve) => socket?.emit(MonitorEvent.Monitor, () => resolve()))
129129
isPaused && await new Promise<void>((resolve) => socket?.emit(MonitorEvent.Pause, () => resolve()))
130-
dispatch(setLoadingPause(false))
130+
dispatch(setMonitorLoadingPause(false))
131131
}
132-
dispatch(setLoadingPause(true))
132+
dispatch(setMonitorLoadingPause(true))
133133
pauseUnpause().catch(console.error)
134134
}, [isPaused, isRunning])
135135

redisinsight/ui/src/components/monitor/Monitor/Monitor.tsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import AutoSizer from 'react-virtualized-auto-sizer'
1414
import { IMonitorDataPayload } from 'uiSrc/slices/interfaces'
1515
import { ReactComponent as BanIcon } from 'uiSrc/assets/img/monitor/ban.svg'
1616

17-
import MonitorLog from '../MonitorLog/MonitorLog'
17+
import MonitorLog from '../MonitorLog'
1818
import MonitorOutputList from '../MonitorOutputList'
1919

2020
import styles from './styles.module.scss'
@@ -87,14 +87,12 @@ const Monitor = (props: Props) => {
8787
content="Profiler log is saved to a file on your local machine with no size limitation.
8888
The temporary log file will be automatically rewritten when the Profiler is reset"
8989
>
90-
<>
91-
<EuiSwitch
92-
compressed
93-
label={<span>Save Log</span>}
94-
checked={saveLogValue}
95-
onChange={(e) => setSaveLogValue(e.target.checked)}
96-
/>
97-
</>
90+
<EuiSwitch
91+
compressed
92+
label={<span>Save Log</span>}
93+
checked={saveLogValue}
94+
onChange={(e) => setSaveLogValue(e.target.checked)}
95+
/>
9896
</EuiToolTip>
9997
</div>
10098
</div>

redisinsight/ui/src/components/monitor/MonitorLog/MonitorLog.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import { monitorSelector, resetProfiler, stopMonitor } from 'uiSrc/slices/cli/mo
99
import { cutDurationText, getBaseApiUrl } from 'uiSrc/utils'
1010

1111
import styles from './styles.module.scss'
12-
import 'react-virtualized/styles.css'
12+
13+
const MIDDLE_SCREEN_RESOLUTION = 460
14+
const SMALL_SCREEN_RESOLUTION = 360
1315

1416
const MonitorLog = () => {
1517
const { timestamp } = useSelector(monitorSelector)
@@ -40,8 +42,8 @@ const MonitorLog = () => {
4042
}
4143

4244
const getPaddingByWidth = (width: number): number => {
43-
if (width < 360) return 6
44-
if (width < 460) return 12
45+
if (width < SMALL_SCREEN_RESOLUTION) return 6
46+
if (width < MIDDLE_SCREEN_RESOLUTION) return 12
4547
return 18
4648
}
4749

@@ -60,7 +62,7 @@ const MonitorLog = () => {
6062
{format(timestamp.paused, 'hh:mm:ss')}
6163
&nbsp;(
6264
{duration}
63-
{width > 360 && ' Running time'}
65+
{width > SMALL_SCREEN_RESOLUTION && ' Running time'}
6466
)
6567
</EuiText>
6668
<EuiFlexGroup
@@ -83,7 +85,7 @@ const MonitorLog = () => {
8385
data-testid="download-log-btn"
8486
{...downloadBtnProps}
8587
>
86-
{width > 360 && ' Download '}
88+
{width > SMALL_SCREEN_RESOLUTION && ' Download '}
8789
Log
8890
</EuiButton>
8991
</EuiToolTip>
@@ -99,7 +101,7 @@ const MonitorLog = () => {
99101
data-testid="reset-profiler-btn"
100102
>
101103
Reset
102-
{width > 360 && ' Profiler'}
104+
{width > SMALL_SCREEN_RESOLUTION && ' Profiler'}
103105
</EuiButton>
104106
</EuiFlexItem>
105107
</EuiFlexGroup>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import MonitorLog from './MonitorLog'
2+
3+
export default MonitorLog

redisinsight/ui/src/components/monitor/MonitorOutputList/MonitorOutputList.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export interface Props {
1717
}
1818

1919
const PROTRUDING_OFFSET = 2
20+
const MIDDLE_SCREEN_RESOLUTION = 460
21+
const SMALL_SCREEN_RESOLUTION = 360
2022

2123
const MonitorOutputList = (props: Props) => {
2224
const { compressed, items = [], width = 0, height = 0 } = props
@@ -67,13 +69,13 @@ const MonitorOutputList = (props: Props) => {
6769
<div onLoad={measure} className={styles.item} ref={registerChild} style={style}>
6870
{!isError && (
6971
<>
70-
{width > 460 && (
72+
{width > MIDDLE_SCREEN_RESOLUTION && (
7173
<span className={cx(styles.time)}>
7274
{getFormatTime(time)}
7375
&nbsp;
7476
</span>
7577
)}
76-
{width > 360 && (<span>{`[${database} ${source}] `}</span>)}
78+
{width > SMALL_SCREEN_RESOLUTION && (<span>{`[${database} ${source}] `}</span>)}
7779
<span>{getArgs(args)}</span>
7880
</>
7981
)}

redisinsight/ui/src/slices/cli/monitor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ const monitorSlice = createSlice({
8181
}
8282
},
8383

84-
setLoadingPause: (state, { payload }) => {
84+
setMonitorLoadingPause: (state, { payload }) => {
8585
state.loadingPause = payload
8686
},
8787

@@ -139,7 +139,7 @@ export const {
139139
togglePauseMonitor,
140140
startMonitor,
141141
setStartTimestamp,
142-
setLoadingPause,
142+
setMonitorLoadingPause,
143143
stopMonitor,
144144
resetProfiler,
145145
concatMonitorItems,

0 commit comments

Comments
 (0)