mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
Revert "[Synthetics UI] Serialize errors before sending to redux store to prevent warnings (#142259)"
This reverts commit b3a749e55a
.
This commit is contained in:
parent
3c0086b764
commit
f1c12a097a
14 changed files with 33 additions and 41 deletions
|
@ -5,11 +5,10 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import type { IHttpFetchError } from '@kbn/core-http-browser';
|
||||
import { createAction } from '@reduxjs/toolkit';
|
||||
import { StatesIndexStatus } from '../../../../../common/runtime_types';
|
||||
import { IHttpSerializedFetchError } from '../utils/http_error';
|
||||
|
||||
export const getIndexStatus = createAction<void>('[INDEX STATUS] GET');
|
||||
export const getIndexStatusSuccess = createAction<StatesIndexStatus>('[INDEX STATUS] GET SUCCESS');
|
||||
export const getIndexStatusFail =
|
||||
createAction<IHttpSerializedFetchError>('[INDEX STATUS] GET FAIL');
|
||||
export const getIndexStatusFail = createAction<IHttpFetchError>('[INDEX STATUS] GET FAIL');
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
import { IHttpSerializedFetchError } from '../utils/http_error';
|
||||
import { IHttpSerializedFetchError, serializeHttpFetchError } from '../utils/http_error';
|
||||
import { StatesIndexStatus } from '../../../../../common/runtime_types';
|
||||
|
||||
import { getIndexStatus, getIndexStatusSuccess, getIndexStatusFail } from './actions';
|
||||
|
@ -33,7 +33,7 @@ export const indexStatusReducer = createReducer(initialState, (builder) => {
|
|||
state.loading = false;
|
||||
})
|
||||
.addCase(getIndexStatusFail, (state, action) => {
|
||||
state.error = action.payload;
|
||||
state.error = serializeHttpFetchError(action.payload);
|
||||
state.loading = false;
|
||||
});
|
||||
});
|
||||
|
|
|
@ -5,8 +5,9 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { IHttpFetchError, ResponseErrorBody } from '@kbn/core/public';
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
import { IHttpSerializedFetchError } from '../utils/http_error';
|
||||
import { IHttpSerializedFetchError, serializeHttpFetchError } from '../utils/http_error';
|
||||
import {
|
||||
getMonitorRecentPingsAction,
|
||||
setMonitorDetailsLocationAction,
|
||||
|
@ -46,7 +47,7 @@ export const monitorDetailsReducer = createReducer(initialState, (builder) => {
|
|||
state.loading = false;
|
||||
})
|
||||
.addCase(getMonitorRecentPingsAction.fail, (state, action) => {
|
||||
state.error = action.payload;
|
||||
state.error = serializeHttpFetchError(action.payload as IHttpFetchError<ResponseErrorBody>);
|
||||
state.loading = false;
|
||||
})
|
||||
|
||||
|
@ -58,7 +59,7 @@ export const monitorDetailsReducer = createReducer(initialState, (builder) => {
|
|||
state.syntheticsMonitorLoading = false;
|
||||
})
|
||||
.addCase(getMonitorAction.fail, (state, action) => {
|
||||
state.error = action.payload;
|
||||
state.error = serializeHttpFetchError(action.payload as IHttpFetchError<ResponseErrorBody>);
|
||||
state.syntheticsMonitorLoading = false;
|
||||
});
|
||||
});
|
||||
|
|
|
@ -5,13 +5,13 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { IHttpFetchError } from '@kbn/core-http-browser';
|
||||
import { createAction } from '@reduxjs/toolkit';
|
||||
import {
|
||||
EncryptedSyntheticsMonitor,
|
||||
MonitorManagementListResult,
|
||||
} from '../../../../../common/runtime_types';
|
||||
import { createAsyncAction } from '../utils/actions';
|
||||
import { IHttpSerializedFetchError } from '../utils/http_error';
|
||||
|
||||
import { MonitorListPageState } from './models';
|
||||
|
||||
|
@ -29,8 +29,7 @@ export const fetchUpsertSuccessAction = createAction<{
|
|||
id: string;
|
||||
attributes: { enabled: boolean };
|
||||
}>('fetchUpsertMonitorSuccess');
|
||||
export const fetchUpsertFailureAction = createAction<{
|
||||
id: string;
|
||||
error: IHttpSerializedFetchError;
|
||||
}>('fetchUpsertMonitorFailure');
|
||||
export const fetchUpsertFailureAction = createAction<{ id: string; error: IHttpFetchError }>(
|
||||
'fetchUpsertMonitorFailure'
|
||||
);
|
||||
export const clearMonitorUpsertStatus = createAction<string>('clearMonitorUpsertStatus');
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { IHttpFetchError } from '@kbn/core-http-browser';
|
||||
import { PayloadAction } from '@reduxjs/toolkit';
|
||||
import { call, put, takeEvery, takeLeading } from 'redux-saga/effects';
|
||||
import { fetchEffectFactory } from '../utils/fetch_effect';
|
||||
import { serializeHttpFetchError } from '../utils/http_error';
|
||||
import {
|
||||
fetchMonitorListAction,
|
||||
fetchUpsertFailureAction,
|
||||
|
@ -40,7 +40,7 @@ export function* upsertMonitorEffect() {
|
|||
);
|
||||
} catch (error) {
|
||||
yield put(
|
||||
fetchUpsertFailureAction({ id: action.payload.id, error: serializeHttpFetchError(error) })
|
||||
fetchUpsertFailureAction({ id: action.payload.id, error: error as IHttpFetchError })
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import { FETCH_STATUS } from '@kbn/observability-plugin/public';
|
|||
|
||||
import { ConfigKey, MonitorManagementListResult } from '../../../../../common/runtime_types';
|
||||
|
||||
import { IHttpSerializedFetchError } from '../utils/http_error';
|
||||
import { IHttpSerializedFetchError, serializeHttpFetchError } from '../utils/http_error';
|
||||
|
||||
import { MonitorListPageState } from './models';
|
||||
import {
|
||||
|
@ -58,7 +58,7 @@ export const monitorListReducer = createReducer(initialState, (builder) => {
|
|||
})
|
||||
.addCase(fetchMonitorListAction.fail, (state, action) => {
|
||||
state.loading = false;
|
||||
state.error = action.payload;
|
||||
state.error = serializeHttpFetchError(action.payload);
|
||||
})
|
||||
.addCase(fetchUpsertMonitorAction, (state, action) => {
|
||||
state.monitorUpsertStatuses[action.payload.id] = {
|
||||
|
|
|
@ -9,7 +9,7 @@ import { createReducer } from '@reduxjs/toolkit';
|
|||
|
||||
import { MonitorOverviewResult, OverviewStatus } from '../../../../../common/runtime_types';
|
||||
|
||||
import { IHttpSerializedFetchError } from '../utils/http_error';
|
||||
import { IHttpSerializedFetchError, serializeHttpFetchError } from '../utils/http_error';
|
||||
|
||||
import { MonitorOverviewPageState } from './models';
|
||||
import {
|
||||
|
@ -60,13 +60,13 @@ export const monitorOverviewReducer = createReducer(initialState, (builder) => {
|
|||
})
|
||||
.addCase(fetchMonitorOverviewAction.fail, (state, action) => {
|
||||
state.loading = false;
|
||||
state.error = action.payload;
|
||||
state.error = serializeHttpFetchError(action.payload);
|
||||
})
|
||||
.addCase(quietFetchOverviewAction.success, (state, action) => {
|
||||
state.data = action.payload;
|
||||
})
|
||||
.addCase(quietFetchOverviewAction.fail, (state, action) => {
|
||||
state.error = action.payload;
|
||||
state.error = serializeHttpFetchError(action.payload);
|
||||
})
|
||||
.addCase(setOverviewPerPageAction, (state, action) => {
|
||||
state.pageState = {
|
||||
|
|
|
@ -7,13 +7,10 @@
|
|||
|
||||
import { createAction } from '@reduxjs/toolkit';
|
||||
import { ServiceLocations, ThrottlingOptions } from '../../../../../common/runtime_types';
|
||||
import { IHttpSerializedFetchError } from '../utils/http_error';
|
||||
|
||||
export const getServiceLocations = createAction('[SERVICE LOCATIONS] GET');
|
||||
export const getServiceLocationsSuccess = createAction<{
|
||||
throttling: ThrottlingOptions | undefined;
|
||||
locations: ServiceLocations;
|
||||
}>('[SERVICE LOCATIONS] GET SUCCESS');
|
||||
export const getServiceLocationsFailure = createAction<IHttpSerializedFetchError>(
|
||||
'[SERVICE LOCATIONS] GET FAILURE'
|
||||
);
|
||||
export const getServiceLocationsFailure = createAction<Error>('[SERVICE LOCATIONS] GET FAILURE');
|
||||
|
|
|
@ -11,7 +11,6 @@ import {
|
|||
ServiceLocations,
|
||||
ThrottlingOptions,
|
||||
} from '../../../../../common/runtime_types';
|
||||
import { IHttpSerializedFetchError } from '../utils/http_error';
|
||||
|
||||
import {
|
||||
getServiceLocations,
|
||||
|
@ -23,7 +22,7 @@ export interface ServiceLocationsState {
|
|||
locations: ServiceLocations;
|
||||
throttling: ThrottlingOptions | null;
|
||||
loading: boolean;
|
||||
error: IHttpSerializedFetchError | null;
|
||||
error: Error | null;
|
||||
locationsLoaded?: boolean;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,24 +7,23 @@
|
|||
|
||||
import { createAction } from '@reduxjs/toolkit';
|
||||
import { MonitorManagementEnablementResult } from '../../../../../common/runtime_types';
|
||||
import { IHttpSerializedFetchError } from '../utils/http_error';
|
||||
|
||||
export const getSyntheticsEnablement = createAction('[SYNTHETICS_ENABLEMENT] GET');
|
||||
export const getSyntheticsEnablementSuccess = createAction<MonitorManagementEnablementResult>(
|
||||
'[SYNTHETICS_ENABLEMENT] GET SUCCESS'
|
||||
);
|
||||
export const getSyntheticsEnablementFailure = createAction<IHttpSerializedFetchError>(
|
||||
export const getSyntheticsEnablementFailure = createAction<Error>(
|
||||
'[SYNTHETICS_ENABLEMENT] GET FAILURE'
|
||||
);
|
||||
|
||||
export const disableSynthetics = createAction('[SYNTHETICS_ENABLEMENT] DISABLE');
|
||||
export const disableSyntheticsSuccess = createAction<{}>('[SYNTHETICS_ENABLEMENT] DISABLE SUCCESS');
|
||||
export const disableSyntheticsFailure = createAction<IHttpSerializedFetchError>(
|
||||
export const disableSyntheticsFailure = createAction<Error>(
|
||||
'[SYNTHETICS_ENABLEMENT] DISABLE FAILURE'
|
||||
);
|
||||
|
||||
export const enableSynthetics = createAction('[SYNTHETICS_ENABLEMENT] ENABLE');
|
||||
export const enableSyntheticsSuccess = createAction<{}>('[SYNTHETICS_ENABLEMENT] ENABLE SUCCESS');
|
||||
export const enableSyntheticsFailure = createAction<IHttpSerializedFetchError>(
|
||||
export const enableSyntheticsFailure = createAction<Error>(
|
||||
'[SYNTHETICS_ENABLEMENT] ENABLE FAILURE'
|
||||
);
|
||||
|
|
|
@ -18,11 +18,10 @@ import {
|
|||
getSyntheticsEnablementFailure,
|
||||
} from './actions';
|
||||
import { MonitorManagementEnablementResult } from '../../../../../common/runtime_types';
|
||||
import { IHttpSerializedFetchError } from '../utils/http_error';
|
||||
|
||||
export interface SyntheticsEnablementState {
|
||||
loading: boolean;
|
||||
error: IHttpSerializedFetchError | null;
|
||||
error: Error | null;
|
||||
enablement: MonitorManagementEnablementResult | null;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,13 +6,13 @@
|
|||
*/
|
||||
|
||||
import { createAction } from '@reduxjs/toolkit';
|
||||
import type { IHttpSerializedFetchError } from './http_error';
|
||||
import type { IHttpFetchError } from '@kbn/core-http-browser';
|
||||
|
||||
export function createAsyncAction<Payload, SuccessPayload>(actionStr: string) {
|
||||
return {
|
||||
get: createAction<Payload>(actionStr),
|
||||
success: createAction<SuccessPayload>(`${actionStr}_SUCCESS`),
|
||||
fail: createAction<IHttpSerializedFetchError>(`${actionStr}_FAIL`),
|
||||
fail: createAction<IHttpFetchError>(`${actionStr}_FAIL`),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
import { call, put } from 'redux-saga/effects';
|
||||
import { PayloadAction } from '@reduxjs/toolkit';
|
||||
import type { IHttpFetchError } from '@kbn/core-http-browser';
|
||||
import { IHttpSerializedFetchError, serializeHttpFetchError } from './http_error';
|
||||
|
||||
/**
|
||||
* Factory function for a fetch effect. It expects three action creators,
|
||||
|
@ -24,7 +23,7 @@ import { IHttpSerializedFetchError, serializeHttpFetchError } from './http_error
|
|||
export function fetchEffectFactory<T, R, S, F>(
|
||||
fetch: (request: T) => Promise<R>,
|
||||
success: (response: R) => PayloadAction<S>,
|
||||
fail: (error: IHttpSerializedFetchError) => PayloadAction<F>
|
||||
fail: (error: IHttpFetchError) => PayloadAction<F>
|
||||
) {
|
||||
return function* (action: PayloadAction<T>): Generator {
|
||||
try {
|
||||
|
@ -33,14 +32,14 @@ export function fetchEffectFactory<T, R, S, F>(
|
|||
// eslint-disable-next-line no-console
|
||||
console.error(response);
|
||||
|
||||
yield put(fail(serializeHttpFetchError(response as IHttpFetchError)));
|
||||
yield put(fail(response as IHttpFetchError));
|
||||
} else {
|
||||
yield put(success(response as R));
|
||||
}
|
||||
} catch (error) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(error);
|
||||
yield put(fail(serializeHttpFetchError(error)));
|
||||
yield put(fail(error as IHttpFetchError));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { IHttpFetchError, ResponseErrorBody } from '@kbn/core/public';
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
import { AgentPolicy } from '@kbn/fleet-plugin/common';
|
||||
import { IHttpSerializedFetchError } from '../../../apps/synthetics/state';
|
||||
import {
|
||||
getAgentPoliciesAction,
|
||||
setAddingNewPrivateLocation,
|
||||
|
@ -24,7 +24,7 @@ export interface AgentPoliciesList {
|
|||
export interface AgentPoliciesState {
|
||||
data: AgentPoliciesList | null;
|
||||
loading: boolean;
|
||||
error: IHttpSerializedFetchError | null;
|
||||
error: IHttpFetchError<ResponseErrorBody> | null;
|
||||
isManageFlyoutOpen?: boolean;
|
||||
isAddingNewPrivateLocation?: boolean;
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ export const agentPoliciesReducer = createReducer(initialState, (builder) => {
|
|||
state.loading = false;
|
||||
})
|
||||
.addCase(getAgentPoliciesAction.fail, (state, action) => {
|
||||
state.error = action.payload;
|
||||
state.error = action.payload as IHttpFetchError<ResponseErrorBody>;
|
||||
state.loading = false;
|
||||
})
|
||||
.addCase(setManageFlyoutOpen, (state, action) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue