|
|
|
@ -22,7 +22,8 @@ import { DefaultGridLayoutManager } from './layout-default/DefaultGridLayoutMana |
|
|
|
|
import { DashboardRepeatsProcessedEvent } from './types/DashboardRepeatsProcessedEvent'; |
|
|
|
|
|
|
|
|
|
export class DashboardSceneUrlSync implements SceneObjectUrlSyncHandler { |
|
|
|
|
private _eventSub?: Unsubscribable; |
|
|
|
|
private _viewEventSub?: Unsubscribable; |
|
|
|
|
private _inspectEventSub?: Unsubscribable; |
|
|
|
|
|
|
|
|
|
constructor(private _scene: DashboardScene) {} |
|
|
|
|
|
|
|
|
@ -78,6 +79,14 @@ export class DashboardSceneUrlSync implements SceneObjectUrlSyncHandler { |
|
|
|
|
if (typeof values.inspect === 'string') { |
|
|
|
|
let panel = findVizPanelByKey(this._scene, values.inspect); |
|
|
|
|
if (!panel) { |
|
|
|
|
// If we are trying to view a repeat clone that can't be found it might be that the repeats have not been processed yet
|
|
|
|
|
// Here we check if the key contains the clone key so we force the repeat processing
|
|
|
|
|
// It doesn't matter if the element or the ancestors are clones or not, just that the key contains the clone key
|
|
|
|
|
if (containsCloneKey(values.inspect)) { |
|
|
|
|
this._handleInspectRepeatClone(values.inspect); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
appEvents.emit(AppEvents.alertError, ['Panel not found']); |
|
|
|
|
locationService.partial({ inspect: null }); |
|
|
|
|
return; |
|
|
|
@ -177,12 +186,27 @@ export class DashboardSceneUrlSync implements SceneObjectUrlSyncHandler { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private _handleInspectRepeatClone(inspect: string) { |
|
|
|
|
if (!this._inspectEventSub) { |
|
|
|
|
this._inspectEventSub = this._scene.subscribeToEvent(DashboardRepeatsProcessedEvent, () => { |
|
|
|
|
const panel = findVizPanelByKey(this._scene, inspect); |
|
|
|
|
if (panel) { |
|
|
|
|
this._inspectEventSub?.unsubscribe(); |
|
|
|
|
this._scene.setState({ |
|
|
|
|
inspectPanelKey: inspect, |
|
|
|
|
overlay: new PanelInspectDrawer({ panelRef: panel.getRef() }), |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private _handleViewRepeatClone(viewPanel: string) { |
|
|
|
|
if (!this._eventSub) { |
|
|
|
|
this._eventSub = this._scene.subscribeToEvent(DashboardRepeatsProcessedEvent, () => { |
|
|
|
|
if (!this._viewEventSub) { |
|
|
|
|
this._viewEventSub = this._scene.subscribeToEvent(DashboardRepeatsProcessedEvent, () => { |
|
|
|
|
const panel = findVizPanelByKey(this._scene, viewPanel); |
|
|
|
|
if (panel) { |
|
|
|
|
this._eventSub?.unsubscribe(); |
|
|
|
|
this._viewEventSub?.unsubscribe(); |
|
|
|
|
this._scene.setState({ viewPanelScene: new ViewPanelScene({ panelRef: panel.getRef() }) }); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|