mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
PanelState: Introduce a new separate redux panel state not keyed by panel.id (#40302)
* Initial pass to move panel state to it's own, and make it by key not panel.id * Progress * Not making much progress, having panel.key be mutable is causing a lot of issues * Think this is starting to work * Began fixing tests * Add selector * Bug fixes and changes to cleanup, and fixing all flicking when switching library panels * Removed console.log * fixes after merge * fixing tests * fixing tests * Added new test for changePlugin thunk
This commit is contained in:
@@ -6,7 +6,7 @@ import { LibraryElementDTO } from '../../types';
|
||||
import { PanelTypeCard } from 'app/features/dashboard/components/VizTypePicker/PanelTypeCard';
|
||||
import { DeleteLibraryPanelModal } from '../DeleteLibraryPanelModal/DeleteLibraryPanelModal';
|
||||
import { config } from '@grafana/runtime';
|
||||
import { getPanelPluginNotFound } from 'app/features/dashboard/dashgrid/PanelPluginError';
|
||||
import { getPanelPluginNotFound } from 'app/features/panel/components/PanelPluginError';
|
||||
|
||||
export interface LibraryPanelCardProps {
|
||||
libraryPanel: LibraryElementDTO;
|
||||
|
||||
@@ -7,10 +7,8 @@ import { Button, useStyles2, VerticalGroup } from '@grafana/ui';
|
||||
import { PanelModel } from 'app/features/dashboard/state';
|
||||
import { AddLibraryPanelModal } from '../AddLibraryPanelModal/AddLibraryPanelModal';
|
||||
import { LibraryPanelsView } from '../LibraryPanelsView/LibraryPanelsView';
|
||||
import { PanelDirectiveReadyEvent, PanelOptionsChangedEvent, PanelQueriesChangedEvent } from 'app/types/events';
|
||||
import { LibraryElementDTO } from '../../types';
|
||||
import { toPanelModelLibraryPanel } from '../../utils';
|
||||
import { changePanelPlugin } from 'app/features/dashboard/state/actions';
|
||||
import { changeToLibraryPanel } from 'app/features/panel/state/actions';
|
||||
import { getDashboardSrv } from 'app/features/dashboard/services/DashboardSrv';
|
||||
import { ChangeLibraryPanelModal } from '../ChangeLibraryPanelModal/ChangeLibraryPanelModal';
|
||||
import { PanelTypeFilter } from '../../../../core/components/PanelTypeFilter/PanelTypeFilter';
|
||||
@@ -38,29 +36,10 @@ export const PanelLibraryOptionsGroup: FC<Props> = ({ panel, searchQuery }) => {
|
||||
if (!changeToPanel) {
|
||||
return;
|
||||
}
|
||||
|
||||
setChangeToPanel(undefined);
|
||||
|
||||
const panelTypeChanged = panel.type !== changeToPanel.model.type;
|
||||
|
||||
if (panelTypeChanged) {
|
||||
await dispatch(changePanelPlugin(panel, changeToPanel.model.type));
|
||||
}
|
||||
|
||||
panel.restoreModel({
|
||||
...changeToPanel.model,
|
||||
gridPos: panel.gridPos,
|
||||
id: panel.id,
|
||||
libraryPanel: toPanelModelLibraryPanel(changeToPanel),
|
||||
});
|
||||
|
||||
panel.configRev = 0;
|
||||
panel.refresh();
|
||||
const unsubscribeEvent = panel.events.subscribe(PanelDirectiveReadyEvent, () => {
|
||||
panel.refresh();
|
||||
unsubscribeEvent.unsubscribe();
|
||||
});
|
||||
panel.events.publish(PanelQueriesChangedEvent);
|
||||
panel.events.publish(PanelOptionsChangedEvent);
|
||||
dispatch(changeToLibraryPanel(panel, changeToPanel));
|
||||
};
|
||||
|
||||
const onAddToPanelLibrary = () => {
|
||||
|
||||
Reference in New Issue
Block a user