mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 01:53:33 -06:00
* wip for pagination * kind of doing pagination, but only for the root folder * wip * wip * refactor paginated fetchChildren * make sure dashboards are loaded if a folder contains only dashboards * rename lastKindHasMoreItems * load additional root pages * undo accidental commit * return promise from loadMoreChildren, and prevent loading additional page while a request is already in flight * rename browseDashboards/fetchChildren action so it's more clear * starting to revalidate children after an action * unset general uid * comment * clean up * fix tests omg * cleanup * fix items not loading after invalidating loaded cache * comment * fix lints
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import { createSlice } from '@reduxjs/toolkit';
|
|
|
|
import { BrowseDashboardsState } from '../types';
|
|
|
|
import { fetchNextChildrenPage, refetchChildren } from './actions';
|
|
import * as allReducers from './reducers';
|
|
|
|
const { fetchNextChildrenPageFulfilled, refetchChildrenFulfilled, ...baseReducers } = allReducers;
|
|
|
|
const initialState: BrowseDashboardsState = {
|
|
rootItems: undefined,
|
|
childrenByParentUID: {},
|
|
openFolders: {},
|
|
selectedItems: {
|
|
dashboard: {},
|
|
folder: {},
|
|
panel: {},
|
|
$all: false,
|
|
},
|
|
};
|
|
|
|
const browseDashboardsSlice = createSlice({
|
|
name: 'browseDashboards',
|
|
initialState,
|
|
reducers: baseReducers,
|
|
|
|
extraReducers: (builder) => {
|
|
builder.addCase(fetchNextChildrenPage.fulfilled, fetchNextChildrenPageFulfilled);
|
|
builder.addCase(refetchChildren.fulfilled, refetchChildrenFulfilled);
|
|
},
|
|
});
|
|
|
|
export const browseDashboardsReducer = browseDashboardsSlice.reducer;
|
|
|
|
export const { setFolderOpenState, setItemSelectionState, setAllSelection } = browseDashboardsSlice.actions;
|
|
|
|
export default {
|
|
browseDashboards: browseDashboardsReducer,
|
|
};
|