-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ui: reduce frequent Metrics page re-rendering
Before, many components on Metrics page relied on `nodesSummarySelector` selector that in turn relies on `NodeStatus` that change constantly with every request (and we request it periodically every 10 seconds). `NodeStatus` include lots of unnecessary data for Metrics page (ie. node's and stores last metrics that aren't used on charts) but these changes forces react components to be re-rendered. This patch refactors selectors that are used by metrics page in a way to provide only relevant subset of NodeStatus's info. Release note: None
- Loading branch information
Showing
18 changed files
with
459 additions
and
303 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
pkg/ui/workspaces/db-console/src/test-utils/renderWithProviders.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React from "react"; | ||
import { configureStore } from "@reduxjs/toolkit"; | ||
import type { PreloadedState } from "@reduxjs/toolkit"; | ||
import { Provider } from "react-redux"; | ||
|
||
import { AdminUIState } from "src/redux/state"; | ||
import { createMemoryHistory } from "history"; | ||
import { apiReducersReducer } from "src/redux/apiReducers"; | ||
import { hoverReducer } from "src/redux/hover"; | ||
import { localSettingsReducer } from "src/redux/localsettings"; | ||
import { metricsReducer } from "src/redux/metrics"; | ||
import { sqlActivityReducer } from "src/redux/sqlActivity"; | ||
import { queryManagerReducer } from "src/redux/queryManager/reducer"; | ||
import { timeScaleReducer } from "src/redux/timeScale"; | ||
import { uiDataReducer } from "src/redux/uiData"; | ||
import { loginReducer } from "src/redux/login"; | ||
import { connectRouter } from "connected-react-router"; | ||
|
||
export function renderWithProviders( | ||
element: React.ReactElement, | ||
preloadedState?: PreloadedState<AdminUIState>, | ||
): React.ReactElement { | ||
const history = createMemoryHistory({ | ||
initialEntries: ["/"], | ||
}); | ||
const routerReducer = connectRouter(history); | ||
const store = configureStore<AdminUIState>({ | ||
reducer: { | ||
cachedData: apiReducersReducer, | ||
hover: hoverReducer, | ||
localSettings: localSettingsReducer, | ||
metrics: metricsReducer, | ||
sqlActivity: sqlActivityReducer, | ||
queryManager: queryManagerReducer, | ||
router: routerReducer, | ||
timeScale: timeScaleReducer, | ||
uiData: uiDataReducer, | ||
login: loginReducer, | ||
}, | ||
preloadedState, | ||
}); | ||
return <Provider store={store}>{element}</Provider>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.