Skip to content

Commit

Permalink
Bump immer, redux and @reduxjs/toolkit (#110962) (#114341)
Browse files Browse the repository at this point in the history
Co-authored-by: Xavier Mouligneau <189600+XavierM@users.noreply.github.com>

Co-authored-by: Thomas Watson <w@tson.dk>
Co-authored-by: Xavier Mouligneau <189600+XavierM@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 14, 2021
1 parent 18fc38e commit 923aa4e
Show file tree
Hide file tree
Showing 24 changed files with 143 additions and 126 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
"@mapbox/mapbox-gl-draw": "1.3.0",
"@mapbox/mapbox-gl-rtl-text": "0.2.3",
"@mapbox/vector-tile": "1.3.1",
"@reduxjs/toolkit": "^1.5.1",
"@reduxjs/toolkit": "^1.6.1",
"@slack/webhook": "^5.0.4",
"@turf/along": "6.0.1",
"@turf/area": "6.0.1",
Expand Down Expand Up @@ -252,7 +252,7 @@
"i18n-iso-countries": "^4.3.1",
"icalendar": "0.7.1",
"idx": "^2.5.6",
"immer": "^8.0.1",
"immer": "^9.0.6",
"inline-style": "^2.0.0",
"intl": "^1.2.5",
"intl-format-cache": "^2.1.0",
Expand Down Expand Up @@ -361,7 +361,7 @@
"reactcss": "1.2.3",
"recompose": "^0.26.0",
"reduce-reducers": "^1.0.4",
"redux": "^4.0.5",
"redux": "^4.1.0",
"redux-actions": "^2.6.5",
"redux-devtools-extension": "^2.13.8",
"redux-logger": "^3.0.6",
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/canvas/types/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

import { KibanaContext } from 'src/plugins/data/common';
import {
AnyExpressionFunctionDefinition,
Datatable,
ExpressionValueFilter,
ExpressionImage,
ExpressionFunction,
PointSeries,
Render,
Style,
Expand All @@ -34,7 +34,7 @@ export interface AppState {

interface StoreAppState {
basePath: string;
serverFunctions: ExpressionFunction[];
serverFunctions: AnyExpressionFunctionDefinition[];
ready: boolean;
}

Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/lens/public/app_plugin/mounter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import React, { FC, useCallback } from 'react';
import { DeepPartial } from '@reduxjs/toolkit';
import { PreloadedState } from '@reduxjs/toolkit';
import { AppMountParameters, CoreSetup, CoreStart } from 'kibana/public';
import { FormattedMessage, I18nProvider } from '@kbn/i18n/react';
import { HashRouter, Route, RouteComponentProps, Switch } from 'react-router-dom';
Expand Down Expand Up @@ -192,7 +192,7 @@ export async function mountApp(
const emptyState = getPreloadedState(storeDeps) as LensAppState;
const lensStore: LensRootStore = makeConfigureStore(storeDeps, {
lens: emptyState,
} as DeepPartial<LensState>);
} as PreloadedState<LensState>);

const EditorRenderer = React.memo(
(props: { id?: string; history: History<unknown>; editByValue?: boolean }) => {
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/lens/public/mocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import moment from 'moment';
import { Provider } from 'react-redux';
import { act } from 'react-dom/test-utils';
import { ReactExpressionRendererProps } from 'src/plugins/expressions/public';
import { DeepPartial } from '@reduxjs/toolkit';
import { PreloadedState } from '@reduxjs/toolkit';
import { LensPublicStart } from '.';
import { visualizationTypes } from './xy_visualization/types';
import { navigationPluginMock } from '../../../../src/plugins/navigation/public/mocks';
Expand Down Expand Up @@ -479,7 +479,7 @@ export function makeLensStore({
resolvedDateRange: getResolvedDateRange(data.query.timefilter.timefilter),
...preloadedState,
},
} as DeepPartial<LensState>);
} as PreloadedState<LensState>);

const origDispatch = store.dispatch;
store.dispatch = jest.fn(dispatch || origDispatch);
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/lens/public/state_management/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { configureStore, getDefaultMiddleware, DeepPartial } from '@reduxjs/toolkit';
import { configureStore, getDefaultMiddleware, PreloadedState } from '@reduxjs/toolkit';
import { createLogger } from 'redux-logger';
import { useDispatch, useSelector, TypedUseSelectorHook } from 'react-redux';
import { makeLensReducer, lensActions } from './lens_slice';
Expand Down Expand Up @@ -36,7 +36,7 @@ export const {

export const makeConfigureStore = (
storeDeps: LensStoreDeps,
preloadedState: DeepPartial<LensState>
preloadedState: PreloadedState<LensState>
) => {
const middleware = [
...getDefaultMiddleware({
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,13 @@ export const OsqueryManagedPolicyCreateImportExtension = React.memo<
// }, [editMode, replace]);

const scheduledQueryGroupTableData = useMemo(() => {
const policyWithoutEmptyQueries = produce<
NewPackagePolicy,
OsqueryManagerPackagePolicy,
OsqueryManagerPackagePolicy
>(newPolicy, (draft) => {
draft.inputs[0].streams = filter(['compiled_stream.id', null], draft.inputs[0].streams);
return draft;
});
const policyWithoutEmptyQueries = produce<NewPackagePolicy, OsqueryManagerPackagePolicy>(
newPolicy,
(draft) => {
draft.inputs[0].streams = filter(['compiled_stream.id', null], draft.inputs[0].streams);
return draft;
}
);

return policyWithoutEmptyQueries;
}, [newPolicy]);
Expand Down Expand Up @@ -198,6 +197,7 @@ export const OsqueryManagedPolicyCreateImportExtension = React.memo<
<EuiFlexGroup>
<EuiFlexItem>
<ScheduledQueryGroupQueriesTable
// @ts-expect-error update
data={scheduledQueryGroupTableData.inputs[0].streams}
/>
</EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const PackQueriesFieldComponent = ({ field }) => {
(newQuery) =>
setValue(
produce((draft) => {
// @ts-expect-error update
draft.push({
interval: newQuery.interval,
query: newQuery.query.attributes.query,
Expand All @@ -56,6 +57,7 @@ const PackQueriesFieldComponent = ({ field }) => {
);

const handleRemoveQuery = useCallback(
// @ts-expect-error update
(query) => setValue(produce((draft) => reject(['id', query.id], draft))),
[setValue]
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,33 +138,42 @@ const QueriesFieldComponent: React.FC<QueriesFieldProps> = ({
if (showEditQueryFlyout >= 0) {
setValue(
produce((draft) => {
// @ts-expect-error update
draft[0].streams[showEditQueryFlyout].vars.id.value = updatedQuery.id;
// @ts-expect-error update
draft[0].streams[showEditQueryFlyout].vars.interval.value = updatedQuery.interval;
// @ts-expect-error update
draft[0].streams[showEditQueryFlyout].vars.query.value = updatedQuery.query;

if (updatedQuery.platform?.length) {
// @ts-expect-error update
draft[0].streams[showEditQueryFlyout].vars.platform = {
type: 'text',
value: updatedQuery.platform,
};
} else {
// @ts-expect-error update
delete draft[0].streams[showEditQueryFlyout].vars.platform;
}

if (updatedQuery.version?.length) {
// @ts-expect-error update
draft[0].streams[showEditQueryFlyout].vars.version = {
type: 'text',
value: updatedQuery.version,
};
} else {
// @ts-expect-error update
delete draft[0].streams[showEditQueryFlyout].vars.version;
}

if (updatedQuery.ecs_mapping) {
// @ts-expect-error update
draft[0].streams[showEditQueryFlyout].vars.ecs_mapping = {
value: updatedQuery.ecs_mapping,
};
} else {
// @ts-expect-error update
delete draft[0].streams[showEditQueryFlyout].vars.ecs_mapping;
}

Expand All @@ -185,6 +194,7 @@ const QueriesFieldComponent: React.FC<QueriesFieldProps> = ({
setValue(
produce((draft) => {
draft[0].streams.push(
// @ts-expect-error update
getNewStream({
...newQuery,
scheduledQueryGroupId,
Expand Down Expand Up @@ -221,6 +231,7 @@ const QueriesFieldComponent: React.FC<QueriesFieldProps> = ({
produce((draft) => {
forEach(parsedContent.queries, (newQuery, newQueryId) => {
draft[0].streams.push(
// @ts-expect-error update
getNewStream({
id: isOsqueryPackSupported ? newQueryId : `pack_${packName}_${newQueryId}`,
interval: newQuery.interval ?? parsedContent.interval,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ export interface ECSMappingEditorFieldRef {
}

export interface ECSMappingEditorFieldProps {
field: FieldHook<string>;
field: FieldHook<Record<string, unknown>>;
query: string;
fieldRef: MutableRefObject<ECSMappingEditorFieldRef>;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
* 2.0.
*/

import { IFieldSubType } from '@kbn/es-query';
import type { IIndexPattern } from 'src/plugins/data/public';
import { IEsSearchRequest, IEsSearchResponse } from '../../../../../../src/plugins/data/common';
import { DocValueFields, Maybe } from '../common';
import type { IFieldSubType } from '@kbn/es-query';

import type {
IEsSearchRequest,
IEsSearchResponse,
IIndexPattern,
} from '../../../../../../src/plugins/data/common';
import type { DocValueFields, Maybe } from '../common';

interface FieldInfo {
category: string;
Expand Down Expand Up @@ -66,12 +70,7 @@ export interface BrowserField {
name: string;
searchable: boolean;
type: string;
subType?: {
[key: string]: unknown;
nested?: {
path: string;
};
};
subType?: IFieldSubType;
}

export type BrowserFields = Readonly<Record<string, Partial<BrowserField>>>;
Expand Down
17 changes: 7 additions & 10 deletions x-pack/plugins/security_solution/public/app/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
Action,
Store,
Dispatch,
PreloadedState,
StateFromReducersMapObject,
CombinedState,
} from 'redux';
Expand All @@ -39,7 +38,7 @@ import { TimelineState } from '../timelines/store/timeline/types';
export { SecurityPageName } from '../../common/constants';

export interface SecuritySubPluginStore<K extends SecuritySubPluginKeyStore, T> {
initialState: Record<K, T | undefined>;
initialState: Record<K, T>;
reducer: Record<K, Reducer<T, AnyAction>>;
middleware?: Array<Middleware<{}, State, Dispatch<AppAction | Immutable<AppAction>>>>;
}
Expand Down Expand Up @@ -70,14 +69,12 @@ export interface SecuritySubPluginWithStore<K extends SecuritySubPluginKeyStore,

export interface SecuritySubPlugins extends SecuritySubPlugin {
store: {
initialState: PreloadedState<
CombinedState<
StateFromReducersMapObject<
/** SubPluginsInitReducer, being an interface, will not work in `StateFromReducersMapObject`.
* Picking its keys does the trick.
**/
Pick<SubPluginsInitReducer, keyof SubPluginsInitReducer>
>
initialState: CombinedState<
StateFromReducersMapObject<
/** SubPluginsInitReducer, being an interface, will not work in `StateFromReducersMapObject`.
* Picking its keys does the trick.
**/
Pick<SubPluginsInitReducer, keyof SubPluginsInitReducer>
>
>;
reducer: SubPluginsInitReducer;
Expand Down
Loading

0 comments on commit 923aa4e

Please sign in to comment.