Skip to content

Commit

Permalink
chore(deps): minor redux related package upgrades (#2607)
Browse files Browse the repository at this point in the history
## Summary

Minor updates to `redux` related packages, if possible to bring the versions in line with what is used in Kibana (elastic/kibana#175017).

- Upgrades `@types/react-redux` from `7.1.1` to `7.1.20`.
- Upgrades `react-redux` from `7.1.0` to `7.2.8`.
- Upgrades `redux` from `4.0.4` to `4.2.1`.
- Upgrades `reselect` from `4.0.0` to `4.1.8`.
  • Loading branch information
walterra authored Feb 4, 2025
1 parent f48f136 commit 988352c
Show file tree
Hide file tree
Showing 19 changed files with 77 additions and 95 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
"@types/marked": "^2.0.1",
"@types/moment-timezone": "^0.5.30",
"@types/react-dom": "^16.9.8",
"@types/react-redux": "^7.1.1",
"@types/react-redux": "^7.1.20",
"@types/seedrandom": "^2.4.28",
"@types/url-parse": "^1.4.3",
"@types/uuid": "^8.3.4",
Expand Down
6 changes: 3 additions & 3 deletions packages/charts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
"d3-shape": "^2.0.0",
"prop-types": "^15.7.2",
"re-reselect": "^3.4.0",
"react-redux": "^7.1.0",
"redux": "^4.0.4",
"reselect": "^4.0.0",
"react-redux": "^7.2.8",
"redux": "^4.2.1",
"reselect": "^4.1.8",
"ts-debounce": "^4.0.0",
"utility-types": "^3.10.0",
"uuid": "^9",
Expand Down
10 changes: 3 additions & 7 deletions packages/charts/src/chart_types/bullet_graph/chart_state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,11 @@ import { getTooltipInfo } from './selectors/get_tooltip_info';
import { isTooltipVisible } from './selectors/is_tooltip_visible';
import { ChartType } from '../../chart_types';
import { DEFAULT_CSS_CURSOR } from '../../common/constants';
import { LegendItem } from '../../common/legend';
import { EMPTY_LEGEND_LIST, EMPTY_LEGEND_ITEM_EXTRA_VALUES } from '../../common/legend';
import { Tooltip } from '../../components/tooltip/tooltip';
import { BackwardRef, GlobalChartState, InternalChartState } from '../../state/chart_state';
import { InitStatus } from '../../state/selectors/get_internal_is_intialized';
import { LegendItemLabel } from '../../state/selectors/get_legend_items_labels';

const EMPTY_MAP = new Map();
const EMPTY_LEGEND_LIST: LegendItem[] = [];
const EMPTY_LEGEND_ITEM_LIST: LegendItemLabel[] = [];
import { EMPTY_LEGEND_ITEM_LIST } from '../../state/selectors/get_legend_items_labels';

/** @internal */
export class BulletState implements InternalChartState {
Expand All @@ -43,7 +39,7 @@ export class BulletState implements InternalChartState {
isChartEmpty = () => false;
getLegendItems = () => EMPTY_LEGEND_LIST;
getLegendItemsLabels = () => EMPTY_LEGEND_ITEM_LIST;
getLegendExtraValues = () => EMPTY_MAP;
getLegendExtraValues = () => EMPTY_LEGEND_ITEM_EXTRA_VALUES;
getPointerCursor = () => DEFAULT_CSS_CURSOR;
isTooltipVisible(globalState: GlobalChartState) {
return isTooltipVisible(globalState);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import { FlameWithTooltip } from './flame_chart';
import { ChartType } from '..';
import { DEFAULT_CSS_CURSOR } from '../../common/constants';
import { LegendItemExtraValues } from '../../common/legend';
import { SeriesKey } from '../../common/series_id';
import { EMPTY_LEGEND_ITEM_EXTRA_VALUES, EMPTY_LEGEND_LIST } from '../../common/legend';
import { InternalChartState } from '../../state/chart_state';
import { InitStatus } from '../../state/selectors/get_internal_is_intialized';
import { EMPTY_LEGEND_ITEM_LIST } from '../../state/selectors/get_legend_items_labels';

/** @internal */
export class FlameState implements InternalChartState {
Expand All @@ -27,9 +27,9 @@ export class FlameState implements InternalChartState {
isBrushing = () => false;
isChartEmpty = () => false;
canDisplayChartTitles = () => false;
getLegendItemsLabels = () => [];
getLegendItems = () => [];
getLegendExtraValues = () => new Map<SeriesKey, LegendItemExtraValues>();
getLegendItemsLabels = () => EMPTY_LEGEND_ITEM_LIST;
getLegendItems = () => EMPTY_LEGEND_LIST;
getLegendExtraValues = () => EMPTY_LEGEND_ITEM_EXTRA_VALUES;
getPointerCursor = () => DEFAULT_CSS_CURSOR;
getTooltipAnchor = () => ({ x: 0, y: 0, width: 0, height: 0 });
isTooltipVisible = () => ({ visible: false, isExternal: false, displayOnly: false, isPinnable: false });
Expand Down
10 changes: 3 additions & 7 deletions packages/charts/src/chart_types/goal_chart/state/chart_state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,16 @@ import { createOnElementOverCaller } from './selectors/on_element_over_caller';
import { getTooltipInfoSelector } from './selectors/tooltip';
import { ChartType } from '../..';
import { DEFAULT_CSS_CURSOR } from '../../../common/constants';
import { LegendItem } from '../../../common/legend';
import { EMPTY_LEGEND_LIST, EMPTY_LEGEND_ITEM_EXTRA_VALUES } from '../../../common/legend';
import { Tooltip } from '../../../components/tooltip/tooltip';
import { InternalChartState, GlobalChartState, BackwardRef, TooltipVisibility } from '../../../state/chart_state';
import { getActivePointerPosition } from '../../../state/selectors/get_active_pointer_position';
import { InitStatus } from '../../../state/selectors/get_internal_is_intialized';
import { LegendItemLabel } from '../../../state/selectors/get_legend_items_labels';
import { EMPTY_LEGEND_ITEM_LIST } from '../../../state/selectors/get_legend_items_labels';
import { DebugState } from '../../../state/types';
import { Dimensions } from '../../../utils/dimensions';
import { Goal } from '../renderer/canvas/connected_component';

const EMPTY_MAP = new Map();
const EMPTY_LEGEND_LIST: LegendItem[] = [];
const EMPTY_LEGEND_ITEM_LIST: LegendItemLabel[] = [];

/** @internal */
export class GoalState implements InternalChartState {
chartType = ChartType.Goal;
Expand Down Expand Up @@ -72,7 +68,7 @@ export class GoalState implements InternalChartState {
}

getLegendExtraValues() {
return EMPTY_MAP;
return EMPTY_LEGEND_ITEM_EXTRA_VALUES;
}

chartRenderer(containerRef: BackwardRef, forwardStageRef: RefObject<HTMLCanvasElement>) {
Expand Down
5 changes: 2 additions & 3 deletions packages/charts/src/chart_types/heatmap/state/chart_state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { createOnElementOverCaller } from './selectors/on_element_over_caller';
import { createOnPointerUpdateCaller } from './selectors/on_pointer_update_caller';
import { getTooltipInfoSelector } from './selectors/tooltip';
import { ChartType } from '../..';
import { EMPTY_LEGEND_ITEM_EXTRA_VALUES } from '../../../common/legend';
import { SmallMultiplesSeriesDomains } from '../../../common/panel_utils';
import { BrushTool } from '../../../components/brush/brush';
import { Tooltip } from '../../../components/tooltip/tooltip';
Expand All @@ -38,8 +39,6 @@ import { Heatmap } from '../renderer/canvas/connected_component';
import { CursorBand } from '../renderer/dom/cursor_band';
import { HighlighterFromBrush } from '../renderer/dom/highlighter_brush';

const EMPTY_MAP = new Map();

/** @internal */
export class HeatmapState implements InternalChartState {
chartType = ChartType.Heatmap;
Expand Down Expand Up @@ -79,7 +78,7 @@ export class HeatmapState implements InternalChartState {
}

getLegendExtraValues() {
return EMPTY_MAP;
return EMPTY_LEGEND_ITEM_EXTRA_VALUES;
}

chartRenderer(containerRef: BackwardRef, forwardStageRef: RefObject<HTMLCanvasElement>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { DragCheckProps, hasDragged } from '../../../../utils/events';
export function createOnBrushEndCaller(): (state: GlobalChartState) => void {
let prevProps: DragCheckProps | null = null;
let selector: OutputSelector<
GlobalChartState,
Array<(state: GlobalChartState) => GlobalChartState>,
void,
(res1: DragState | null, res3: SettingsSpec, res4: HeatmapBrushEvent | null) => void
> | null = null;
Expand Down
10 changes: 3 additions & 7 deletions packages/charts/src/chart_types/metric/state/chart_state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,12 @@ import React from 'react';
import { canDisplayChartTitles } from './selectors/can_display_chart_titles';
import { ChartType } from '../..';
import { DEFAULT_CSS_CURSOR } from '../../../common/constants';
import { LegendItem } from '../../../common/legend';
import { EMPTY_LEGEND_LIST, EMPTY_LEGEND_ITEM_EXTRA_VALUES } from '../../../common/legend';
import { GlobalChartState, InternalChartState } from '../../../state/chart_state';
import { InitStatus } from '../../../state/selectors/get_internal_is_intialized';
import { LegendItemLabel } from '../../../state/selectors/get_legend_items_labels';
import { EMPTY_LEGEND_ITEM_LIST } from '../../../state/selectors/get_legend_items_labels';
import { Metric } from '../renderer/dom';

const EMPTY_MAP = new Map();
const EMPTY_LEGEND_LIST: LegendItem[] = [];
const EMPTY_LEGEND_ITEM_LIST: LegendItemLabel[] = [];

/** @internal */
export class MetricState implements InternalChartState {
chartType = ChartType.Metric;
Expand All @@ -32,7 +28,7 @@ export class MetricState implements InternalChartState {
isChartEmpty = () => false;
getLegendItems = () => EMPTY_LEGEND_LIST;
getLegendItemsLabels = () => EMPTY_LEGEND_ITEM_LIST;
getLegendExtraValues = () => EMPTY_MAP;
getLegendExtraValues = () => EMPTY_LEGEND_ITEM_EXTRA_VALUES;
getPointerCursor = () => DEFAULT_CSS_CURSOR;
isTooltipVisible = () => ({
visible: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,14 @@ import { createOnElementOverCaller } from './selectors/on_element_over_caller';
import { getPartitionSpec } from './selectors/partition_spec';
import { getTooltipInfoSelector } from './selectors/tooltip';
import { ChartType } from '../..';
import { LegendItemExtraValues } from '../../../common/legend';
import { SeriesKey } from '../../../common/series_id';
import { EMPTY_LEGEND_ITEM_EXTRA_VALUES } from '../../../common/legend';
import { BackwardRef, GlobalChartState, InternalChartState } from '../../../state/chart_state';
import { getActivePointerPosition } from '../../../state/selectors/get_active_pointer_position';
import { InitStatus } from '../../../state/selectors/get_internal_is_intialized';
import { DebugState } from '../../../state/types';
import { Dimensions } from '../../../utils/dimensions';
import { render } from '../renderer/dom/layered_partition_chart';

const EMPTY_MAP = new Map<SeriesKey, LegendItemExtraValues>();

/** @internal */
export class PartitionState implements InternalChartState {
chartType = ChartType.Partition;
Expand Down Expand Up @@ -75,7 +72,7 @@ export class PartitionState implements InternalChartState {
}

getLegendExtraValues() {
return EMPTY_MAP;
return EMPTY_LEGEND_ITEM_EXTRA_VALUES;
}

chartRenderer(containerRef: BackwardRef, forwardStageRef: RefObject<HTMLCanvasElement>) {
Expand Down
10 changes: 5 additions & 5 deletions packages/charts/src/chart_types/timeslip/internal_chart_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import { TimeslipWithTooltip } from './timeslip_chart';
import { ChartType } from '..';
import { DEFAULT_CSS_CURSOR } from '../../common/constants';
import { LegendItemExtraValues } from '../../common/legend';
import { SeriesKey } from '../../common/series_id';
import { EMPTY_LEGEND_ITEM_EXTRA_VALUES, EMPTY_LEGEND_LIST } from '../../common/legend';
import { InternalChartState } from '../../state/chart_state';
import { InitStatus } from '../../state/selectors/get_internal_is_intialized';
import { EMPTY_LEGEND_ITEM_LIST } from '../../state/selectors/get_legend_items_labels';

/** @internal */
export class TimeslipState implements InternalChartState {
Expand All @@ -26,9 +26,9 @@ export class TimeslipState implements InternalChartState {
isBrushAvailable = () => false;
isBrushing = () => false;
isChartEmpty = () => false;
getLegendItemsLabels = () => [];
getLegendItems = () => [];
getLegendExtraValues = () => new Map<SeriesKey, LegendItemExtraValues>();
getLegendItemsLabels = () => EMPTY_LEGEND_ITEM_LIST;
getLegendItems = () => EMPTY_LEGEND_LIST;
getLegendExtraValues = () => EMPTY_LEGEND_ITEM_EXTRA_VALUES;
getPointerCursor = () => DEFAULT_CSS_CURSOR;
getTooltipAnchor = () => ({ x: 0, y: 0, width: 0, height: 0 });
isTooltipVisible = () => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,14 @@ import React from 'react';
import { getWordcloudSpecSelector } from './selectors/wordcloud_spec';
import { ChartType } from '../..';
import { DEFAULT_CSS_CURSOR } from '../../../common/constants';
import { LegendItem } from '../../../common/legend';
import { EMPTY_LEGEND_ITEM_EXTRA_VALUES, EMPTY_LEGEND_LIST } from '../../../common/legend';
import { InternalChartState, GlobalChartState } from '../../../state/chart_state';
import { InitStatus } from '../../../state/selectors/get_internal_is_intialized';
import { LegendItemLabel } from '../../../state/selectors/get_legend_items_labels';
import { EMPTY_LEGEND_ITEM_LIST } from '../../../state/selectors/get_legend_items_labels';
import { DebugState } from '../../../state/types';
import { Dimensions } from '../../../utils/dimensions';
import { Wordcloud } from '../renderer/svg/connected_component';

const EMPTY_MAP = new Map();
const EMPTY_LEGEND_LIST: LegendItem[] = [];
const EMPTY_LEGEND_ITEM_LIST: LegendItemLabel[] = [];
const EMPTY_TOOLTIP = Object.freeze({ header: null, values: [] });

/** @internal */
Expand Down Expand Up @@ -53,7 +50,7 @@ export class WordcloudState implements InternalChartState {
}

getLegendExtraValues() {
return EMPTY_MAP;
return EMPTY_LEGEND_ITEM_EXTRA_VALUES;
}

chartRenderer() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { getChartTypeDescriptionSelector } from './selectors/get_chart_type_desc
import { getPointerCursorSelector } from './selectors/get_cursor_pointer';
import { getDebugStateSelector } from './selectors/get_debug_state';
import { getLegendItemExtraValuesSelector } from './selectors/get_legend_item_extra_values';
import { getLegendItemsLabelsSelector } from './selectors/get_legend_items_labels';
import { getSeriesSpecsSelector } from './selectors/get_specs';
import { getTooltipAnchorPositionSelector } from './selectors/get_tooltip_anchor_position';
import { getTooltipInfoSelector } from './selectors/get_tooltip_values_highlighted_geoms';
Expand All @@ -37,6 +36,7 @@ import { Tooltip } from '../../../components/tooltip/tooltip';
import { InternalChartState, GlobalChartState, BackwardRef } from '../../../state/chart_state';
import { getChartContainerDimensionsSelector } from '../../../state/selectors/get_chart_container_dimensions';
import { InitStatus } from '../../../state/selectors/get_internal_is_intialized';
import { EMPTY_LEGEND_ITEM_LIST } from '../../../state/selectors/get_legend_items_labels';
import { isBrushingSelector } from '../../../state/selectors/is_brushing';
import { htmlIdGenerator } from '../../../utils/common';
import { XYChart } from '../renderer/canvas/xy_chart';
Expand Down Expand Up @@ -103,8 +103,8 @@ export class XYAxisChartState implements InternalChartState {
return getBrushAreaSelector(globalState);
}

getLegendItemsLabels(globalState: GlobalChartState) {
return getLegendItemsLabelsSelector(globalState);
getLegendItemsLabels() {
return EMPTY_LEGEND_ITEM_LIST;
}

getLegendItems(globalState: GlobalChartState) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@

import { getComputedScalesSelector } from './get_computed_scales';
import { getTooltipInfoAndGeomsSelector } from './get_tooltip_values_highlighted_geoms';
import { LegendItemExtraValues } from '../../../../common/legend';
import { LegendItemExtraValues, EMPTY_LEGEND_ITEM_EXTRA_VALUES } from '../../../../common/legend';
import { SeriesKey } from '../../../../common/series_id';
import { ScaleType } from '../../../../scales/constants';
import { createCustomCachedSelector } from '../../../../state/create_selector';
import { getLegendItemExtraValues } from '../../tooltip/tooltip';

const EMPTY_MAP = new Map();
/** @internal */
export const getLegendItemExtraValuesSelector = createCustomCachedSelector(
[getTooltipInfoAndGeomsSelector, getComputedScalesSelector],
({ tooltip: { values } }, { xScale: { type } }): Map<SeriesKey, LegendItemExtraValues> =>
// See https://github.com/elastic/elastic-charts/issues/2050
type === ScaleType.Ordinal ? EMPTY_MAP : getLegendItemExtraValues(values),
type === ScaleType.Ordinal ? EMPTY_LEGEND_ITEM_EXTRA_VALUES : getLegendItemExtraValues(values),
);

This file was deleted.

7 changes: 6 additions & 1 deletion packages/charts/src/common/legend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { $Values } from 'utility-types';

import { CategoryKey, CategoryLabel } from './category';
import { Color } from './colors';
import { SeriesIdentifier } from './series_id';
import { SeriesKey, SeriesIdentifier } from './series_id';
import { PrimitiveValue } from '../chart_types/partition_chart/layout/utils/group_by_rollup';
import { SeriesType } from '../specs';
import { LegendPath } from '../state/actions/legend';
Expand Down Expand Up @@ -119,3 +119,8 @@ export const legendValueTitlesMap = {
[LegendValue.Difference]: 'Diff',
[LegendValue.DifferencePercent]: 'Diff %',
};

/** @internal */
export const EMPTY_LEGEND_ITEM_EXTRA_VALUES = new Map<SeriesKey, LegendItemExtraValues>();
/** @internal */
export const EMPTY_LEGEND_LIST: LegendItem[] = [];
8 changes: 4 additions & 4 deletions packages/charts/src/state/create_selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,16 @@ export const globalSelectorCache = new GlobalSelectorCache();

/**
* Wrapper around `createCachedSelector` to provide `keySelector` and `cacheObject`
* for all selector instances in on place. This should be used in place of `createCachedSelector`.
* for all selector instances in one place. This should be used in place of `createCachedSelector`.
*
* The types defining `createCachedSelector` are very complex and essentially hardcoded overloads for having any
* number of selector inputs up to about 20 with genetic types. Thus the types are extremely hard to duplciate.
* number of selector inputs up to about 20 with generic types. Thus the types are extremely hard to duplciate.
* To fix this I used the type of `createSelector` which is what is the same as that of `createCachedSelector`
* method with the added curring for the cached options which this wrapper handles.
*
* @internal
*/
export const createCustomCachedSelector: typeof createSelector = (...args: any[]) => {
export const createCustomCachedSelector = ((...args: any[]) => {
// @ts-ignore - forced types to simplify usage. All types align correctly
return createCachedSelector(...args)(globalSelectorCache.getNewOptions());
};
}) as unknown as typeof createSelector;
4 changes: 1 addition & 3 deletions packages/charts/src/state/selectors/get_legend_items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
* Side Public License, v 1.
*/

import { LegendItem } from '../../common/legend';
import { LegendItem, EMPTY_LEGEND_LIST } from '../../common/legend';
import { GlobalChartState } from '../chart_state';

const EMPTY_LEGEND_LIST: LegendItem[] = [];

/** @internal */
export const getLegendItemsSelector = (state: GlobalChartState): LegendItem[] => {
if (state.internalChartState) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ export interface LegendItemLabel {
/** @internal */
export const getLegendItemsLabelsSelector = (state: GlobalChartState): LegendItemLabel[] =>
state.internalChartState?.getLegendItemsLabels(state) ?? [];

/** @internal */
export const EMPTY_LEGEND_ITEM_LIST: LegendItemLabel[] = [];
Loading

0 comments on commit 988352c

Please sign in to comment.