88import type { PayloadAction } from '@reduxjs/toolkit' ;
99import { createReducer } from '@reduxjs/toolkit' ;
1010
11- import type { WritableDraft } from 'immer/dist/types/types-external ' ;
11+ import type { Draft } from 'immer' ;
1212import type { IHttpFetchError } from '@kbn/core-http-browser' ;
1313
1414import type { ActionPayload } from '../utils/actions' ;
@@ -51,7 +51,7 @@ export const manualTestRunsReducer = createReducer(initialState, (builder) => {
5151 builder
5252 . addCase (
5353 String ( manualTestMonitorAction . get ) ,
54- ( state : WritableDraft < ManualTestRunsState > , action : PayloadAction < TestNowPayload > ) => {
54+ ( state : Draft < ManualTestRunsState > , action : PayloadAction < TestNowPayload > ) => {
5555 state = Object . values ( state ) . reduce ( ( acc , curr ) => {
5656 acc [ curr . configId ] = {
5757 ...curr ,
@@ -70,10 +70,7 @@ export const manualTestRunsReducer = createReducer(initialState, (builder) => {
7070 )
7171 . addCase (
7272 String ( manualTestMonitorAction . success ) ,
73- (
74- state : WritableDraft < ManualTestRunsState > ,
75- { payload } : PayloadAction < EnrichedTestNowResponse >
76- ) => {
73+ ( state : Draft < ManualTestRunsState > , { payload } : PayloadAction < EnrichedTestNowResponse > ) => {
7774 state [ payload . configId ] = {
7875 configId : payload . configId ,
7976 testRunId : payload . testRunId ,
@@ -86,7 +83,7 @@ export const manualTestRunsReducer = createReducer(initialState, (builder) => {
8683 . addCase (
8784 String ( manualTestMonitorAction . fail ) ,
8885 (
89- state : WritableDraft < ManualTestRunsState > ,
86+ state : Draft < ManualTestRunsState > ,
9087 action : ActionPayload < EnrichedTestNowResponse , TestNowPayload >
9188 ) => {
9289 const fetchError = action . payload as unknown as IHttpFetchError ;
@@ -118,7 +115,7 @@ export const manualTestRunsReducer = createReducer(initialState, (builder) => {
118115 return state ;
119116 }
120117 )
121- . addCase ( manualTestRunUpdateAction , ( state : WritableDraft < ManualTestRunsState > , action ) => {
118+ . addCase ( manualTestRunUpdateAction , ( state : Draft < ManualTestRunsState > , action ) => {
122119 const { testRunId, ...rest } = action . payload ;
123120 const configId = Object . keys ( state ) . find ( ( key ) => state [ key ] . testRunId === testRunId ) ;
124121 if ( configId ) {
@@ -128,7 +125,7 @@ export const manualTestRunsReducer = createReducer(initialState, (builder) => {
128125 } ;
129126 }
130127 } )
131- . addCase ( toggleTestNowFlyoutAction , ( state : WritableDraft < ManualTestRunsState > , action ) => {
128+ . addCase ( toggleTestNowFlyoutAction , ( state : Draft < ManualTestRunsState > , action ) => {
132129 state = Object . values ( state ) . reduce ( ( acc , curr ) => {
133130 acc [ curr . configId ] = {
134131 ...curr ,
@@ -143,7 +140,7 @@ export const manualTestRunsReducer = createReducer(initialState, (builder) => {
143140 isTestNowFlyoutOpen : ! state [ action . payload ] . isTestNowFlyoutOpen ,
144141 } ;
145142 } )
146- . addCase ( hideTestNowFlyoutAction , ( state : WritableDraft < ManualTestRunsState > ) => {
143+ . addCase ( hideTestNowFlyoutAction , ( state : Draft < ManualTestRunsState > ) => {
147144 state = Object . values ( state ) . reduce ( ( acc , curr ) => {
148145 acc [ curr . configId ] = {
149146 ...curr ,
@@ -156,7 +153,7 @@ export const manualTestRunsReducer = createReducer(initialState, (builder) => {
156153 } )
157154 . addCase (
158155 String ( clearTestNowMonitorAction ) ,
159- ( state : WritableDraft < ManualTestRunsState > , action : PayloadAction < string > ) => {
156+ ( state : Draft < ManualTestRunsState > , action : PayloadAction < string > ) => {
160157 delete state [ action . payload ] ;
161158 }
162159 ) ;
0 commit comments