PanelModel: Removes the isAngularPlugin function (#110799)
Chore: removes isAngularPlugin function from PanelModel
This commit is contained in:
@@ -83,14 +83,12 @@ export class SupportSnapshotService extends StateManagerBase<SupportSnapshotStat
|
||||
|
||||
let scene: SceneObject | undefined = undefined;
|
||||
|
||||
if (!panel.isAngularPlugin()) {
|
||||
try {
|
||||
const oldModel = new DashboardModel(snapshot, { isEmbedded: true });
|
||||
const dash = createDashboardSceneFromDashboardModel(oldModel, snapshot);
|
||||
scene = dash.state.body; // skip the wrappers
|
||||
} catch (ex) {
|
||||
console.log('Error creating scene:', ex);
|
||||
}
|
||||
try {
|
||||
const oldModel = new DashboardModel(snapshot, { isEmbedded: true });
|
||||
const dash = createDashboardSceneFromDashboardModel(oldModel, snapshot);
|
||||
scene = dash.state.body; // skip the wrappers
|
||||
} catch (ex) {
|
||||
console.log('Error creating scene:', ex);
|
||||
}
|
||||
|
||||
this.setState({ snapshot, snapshotText, markdownText, snapshotSize, snapshotUpdate: snapshotUpdate + 1, scene });
|
||||
|
||||
@@ -204,41 +204,6 @@ describe('panelEditor actions', () => {
|
||||
// expect configRev to be reset to 0 as it was saved
|
||||
expect(sourcePanel.hasChanged).toEqual(false);
|
||||
});
|
||||
|
||||
it('should apply changes when leaving panel edit with angular panel', async () => {
|
||||
const sourcePanel = new PanelModel({ id: 12, type: 'graph' });
|
||||
sourcePanel.plugin = getPanelPlugin({});
|
||||
sourcePanel.plugin.angularPanelCtrl = {};
|
||||
|
||||
const dashboard = createDashboardModelFixture({
|
||||
panels: [{ id: 12, type: 'graph' }],
|
||||
});
|
||||
|
||||
const panel = dashboard.initEditPanel(sourcePanel);
|
||||
|
||||
const state: PanelEditorState = {
|
||||
...initialState(),
|
||||
getPanel: () => panel,
|
||||
getSourcePanel: () => sourcePanel,
|
||||
};
|
||||
|
||||
// not using panel.setProperty here to simulate any prop change done from angular
|
||||
panel.title = 'Changed title';
|
||||
|
||||
await thunkTester({
|
||||
panelEditor: state,
|
||||
panels: {},
|
||||
dashboard: {
|
||||
getModel: () => dashboard,
|
||||
},
|
||||
})
|
||||
.givenThunk(exitPanelEditor)
|
||||
.whenThunkIsDispatched();
|
||||
|
||||
expect(sourcePanel.isAngularPlugin()).toBe(true);
|
||||
expect(sourcePanel.title).toEqual('Changed title');
|
||||
expect(sourcePanel.configRev).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('skipPanelUpdate', () => {
|
||||
|
||||
@@ -161,7 +161,7 @@ export function exitPanelEditor(): ThunkResult<void> {
|
||||
}
|
||||
|
||||
function hasPanelChangedInPanelEdit(panel: PanelModel) {
|
||||
return panel.hasChanged || panel.hasSavedPanelEditChange || panel.isAngularPlugin();
|
||||
return panel.hasChanged || panel.hasSavedPanelEditChange;
|
||||
}
|
||||
|
||||
export function updatePanelEditorUIState(uiState: Partial<PanelEditorUIState>): ThunkResult<void> {
|
||||
|
||||
@@ -464,7 +464,7 @@ describe('PanelModel', () => {
|
||||
it('should call react onPanelTypeChanged', () => {
|
||||
expect(onPanelTypeChanged.mock.calls.length).toBe(1);
|
||||
expect(onPanelTypeChanged.mock.calls[0][1]).toBe('table');
|
||||
expect(onPanelTypeChanged.mock.calls[0][2].angular).toBeDefined();
|
||||
expect(onPanelTypeChanged.mock.calls[0][2].angular).not.toBeDefined();
|
||||
});
|
||||
|
||||
it('getQueryRunner() should return same instance after changing to another react panel', () => {
|
||||
|
||||
@@ -509,7 +509,8 @@ export class PanelModel implements DataConfigSource, IPanelModel {
|
||||
const oldOptions = this.getOptionsToRemember();
|
||||
const prevFieldConfig = this.fieldConfig;
|
||||
const oldPluginId = this.type;
|
||||
const wasAngular = this.isAngularPlugin() || Boolean(autoMigrateAngular[oldPluginId]);
|
||||
const angularId = this.autoMigrateFrom || oldPluginId;
|
||||
const wasAngular = Boolean(autoMigrateAngular[angularId]);
|
||||
this.cachedPluginOptions[oldPluginId] = {
|
||||
properties: oldOptions,
|
||||
fieldConfig: prevFieldConfig,
|
||||
@@ -618,12 +619,6 @@ export class PanelModel implements DataConfigSource, IPanelModel {
|
||||
return this.title && this.title.length > 0;
|
||||
}
|
||||
|
||||
isAngularPlugin(): boolean {
|
||||
return (
|
||||
(this.plugin && this.plugin.angularPanelCtrl) !== undefined || (this.plugin?.meta?.angular?.detected ?? false)
|
||||
);
|
||||
}
|
||||
|
||||
destroy() {
|
||||
this.events.removeAllListeners();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user