1
1
import { createSlice , PayloadAction } from '@reduxjs/toolkit'
2
2
import { AxiosError } from 'axios'
3
- import { ApiEndpoints , DEFAULT_SLOWLOG_DURATION_UNIT , DurationUnits } from 'uiSrc/constants'
4
- import { apiService , getDBConfigStorageField } from 'uiSrc/services'
3
+ import { ApiEndpoints , DurationUnits } from 'uiSrc/constants'
4
+ import { apiService } from 'uiSrc/services'
5
+ import { setSlowLogUnits } from 'uiSrc/slices/app/context'
5
6
import { addErrorNotification } from 'uiSrc/slices/app/notifications'
6
7
import { StateSlowLog } from 'uiSrc/slices/interfaces/analytics'
7
- import { ConfigDBStorageItem } from 'uiSrc/constants/storage'
8
- import { getApiErrorMessage , getUrl , isStatusSuccessful , Nullable } from 'uiSrc/utils'
8
+ import { getApiErrorMessage , getUrl , isStatusSuccessful } from 'uiSrc/utils'
9
9
import { SlowLog , SlowLogConfig } from 'apiSrc/modules/slow-log/models'
10
10
11
11
import { AppDispatch , RootState } from '../store'
@@ -15,7 +15,6 @@ export const initialState: StateSlowLog = {
15
15
error : '' ,
16
16
data : [ ] ,
17
17
lastRefreshTime : null ,
18
- durationUnit : DurationUnits . microSeconds ,
19
18
config : null
20
19
}
21
20
@@ -29,11 +28,10 @@ const slowLogSlice = createSlice({
29
28
} ,
30
29
getSlowLogsSuccess : (
31
30
state ,
32
- { payload : [ data , durationUnit ] } : PayloadAction < [ SlowLog [ ] , DurationUnits ] >
31
+ { payload : data } : PayloadAction < SlowLog [ ] >
33
32
) => {
34
33
state . loading = false
35
34
state . data = data
36
- state . durationUnit = durationUnit
37
35
state . lastRefreshTime = Date . now ( )
38
36
} ,
39
37
getSlowLogsError : ( state , { payload } ) => {
@@ -56,14 +54,10 @@ const slowLogSlice = createSlice({
56
54
} ,
57
55
getSlowLogConfigSuccess : (
58
56
state ,
59
- { payload : [ data , durationUnit ] } : PayloadAction < [ SlowLogConfig , Nullable < DurationUnits > ] >
57
+ { payload : data } : PayloadAction < SlowLogConfig >
60
58
) => {
61
59
state . loading = false
62
60
state . config = data
63
-
64
- if ( durationUnit ) {
65
- state . durationUnit = durationUnit
66
- }
67
61
} ,
68
62
getSlowLogConfigError : ( state , { payload } ) => {
69
63
state . loading = false
@@ -113,13 +107,7 @@ export function fetchSlowLogsAction(
113
107
)
114
108
115
109
if ( isStatusSuccessful ( status ) ) {
116
- dispatch (
117
- getSlowLogsSuccess ( [
118
- data ,
119
- getDBConfigStorageField ( instanceId , ConfigDBStorageItem . slowLogDurationUnit )
120
- || DEFAULT_SLOWLOG_DURATION_UNIT
121
- ] )
122
- )
110
+ dispatch ( getSlowLogsSuccess ( data ) )
123
111
124
112
onSuccessAction ?.( data )
125
113
}
@@ -183,7 +171,7 @@ export function getSlowLogConfigAction(
183
171
)
184
172
185
173
if ( isStatusSuccessful ( status ) ) {
186
- dispatch ( getSlowLogConfigSuccess ( [ data , null ] ) )
174
+ dispatch ( getSlowLogConfigSuccess ( data ) )
187
175
188
176
onSuccessAction ?.( )
189
177
}
@@ -218,7 +206,8 @@ export function patchSlowLogConfigAction(
218
206
)
219
207
220
208
if ( isStatusSuccessful ( status ) ) {
221
- dispatch ( getSlowLogConfigSuccess ( [ data , durationUnit ] ) )
209
+ dispatch ( getSlowLogConfigSuccess ( data ) )
210
+ dispatch ( setSlowLogUnits ( durationUnit ) )
222
211
223
212
onSuccessAction ?.( )
224
213
}
0 commit comments