From 7c4cfb43fc357b1b4b920e8db9aef46a49f9b71e Mon Sep 17 00:00:00 2001 From: Matthew Runyon Date: Fri, 26 Jan 2024 14:57:34 -0600 Subject: [PATCH] Change plugin data map to object --- packages/dashboard/src/redux/actions.ts | 12 +++++++----- packages/dashboard/src/redux/selectors.ts | 4 ++-- packages/redux/src/store.ts | 5 ++++- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/dashboard/src/redux/actions.ts b/packages/dashboard/src/redux/actions.ts index 7347efebd3..af297b474d 100644 --- a/packages/dashboard/src/redux/actions.ts +++ b/packages/dashboard/src/redux/actions.ts @@ -43,11 +43,12 @@ export const updateDashboardData = ); /** - * Action to update the dashboard data. Will combine the update with any existing dashboard data. + * Action to set the dashboard plugin data. + * Will replace any existing plugin data for the plugin in the dashboard with the data provided. * @param id The id of the dashboard to set the data on * @param pluginId The id of the plugin to set the data on * @param data The data to replace the existing plugin data with - * @returns + * @returns Thunk action to dispatch */ export const setDashboardPluginData = ( @@ -59,8 +60,9 @@ export const setDashboardPluginData = dispatch( setDashboardData(id, { ...getDashboardData(getState(), id), - pluginDataMap: new Map( - getPluginDataMapForDashboard(getState(), id) - ).set(pluginId, data), + pluginDataMap: { + ...getPluginDataMapForDashboard(getState(), id), + [pluginId]: data, + }, }) ); diff --git a/packages/dashboard/src/redux/selectors.ts b/packages/dashboard/src/redux/selectors.ts index 506013d37d..460c45615f 100644 --- a/packages/dashboard/src/redux/selectors.ts +++ b/packages/dashboard/src/redux/selectors.ts @@ -65,7 +65,7 @@ export const getPluginDataMapForDashboard = ( store: RootState, dashboardId: string ): PluginDataMap => - getDashboardData(store, dashboardId).pluginDataMap ?? EMPTY_MAP; + getDashboardData(store, dashboardId).pluginDataMap ?? EMPTY_OBJECT; /** * @param store The redux store @@ -77,4 +77,4 @@ export const getPluginDataForDashboard = ( store: RootState, dashboardId: string, pluginId: string -): PluginData => getPluginDataMapForDashboard(store, dashboardId).get(pluginId); +): PluginData => getPluginDataMapForDashboard(store, dashboardId)[pluginId]; diff --git a/packages/redux/src/store.ts b/packages/redux/src/store.ts index c8f536d7f6..f171163d5f 100644 --- a/packages/redux/src/store.ts +++ b/packages/redux/src/store.ts @@ -80,9 +80,12 @@ export interface Workspace { export type PluginData = unknown; -export type PluginDataMap = Map; +export type PluginDataMap = Record; export type DashboardData = Record & { + title?: string; + closed?: unknown[]; + filterSets?: unknown[]; pluginDataMap?: PluginDataMap; };