I am refencing a dashboard in a custom panel in 8.1 using DashboardContainerInput interface. The dashboard displays "This dashboard is empty. You need additional privileges to edit this dashboard." (image below). This is a change from 7.10 where this refence worked fine.
I have all permissions granted to my user via a custom role and can access the dashboard from the dashboard manager just fine. Is there some new dashboard permission in the kibana yml that im not aware of?
Could anonyms access of embeddable objects be the underlining issue? refence : Authentication in Kibana | Kibana Guide [8.1] | Elastic
my dashboard class
import { CoreStart, SimpleSavedObject } from "kibana/public";
import React, { Component } from 'react';
import { DashboardContainerFactory, DashboardPanelState } from "../../../../../../src/plugins/dashboard/public/application";
import { DashboardContainerInput, SavedDashboardPanel } from "../../../../../../src/plugins/dashboard/public";
import { AppPluginStartDependencies } from "../../../types";
import { convertSavedDashboardPanelToPanelState } from "../converters/saved_objects_converters";
import { SavedObjectEmbeddableInput, ViewMode } from "../../../../../../src/plugins/embeddable/public";
import { createDashboardContainerByValueRenderer } from "./createdasboardcontainer";
import ReactDOM from 'react-dom';
import { FavoritedDash } from "../../../../common/types";
import { TimeRange, Filter, Query } from "../../../../../../src/plugins/data/common";
interface DashboardMeta{
filter:Filter[];
query:Query;
}
export interface SavedDashboard extends SimpleSavedObject{
attributes:{
kibanaSavedObjectMeta:{searchSourceJSON:string};
panelsJSON:string;
title:string;
}
}
export interface RawPanel extends SavedDashboardPanel{
panelRefName: string;
id:string;
type:string;
title: string;
embeddableConfig: any;
}
interface DashProps {
core:CoreStart;
plugins:AppPluginStartDependencies;
fav:FavoritedDash;
parentid:string;
}
interface DashState {
savedDashboard?:SavedDashboard;
dashmeta?:DashboardMeta;
dashboardFactory:DashboardContainerFactory;
embeddablesMap?:{[key: string]: DashboardPanelState<SavedObjectEmbeddableInput>;};
}
export class GenEmbeddedDashboard extends Component<DashProps,DashState>{
constructor(props:DashProps){
super(props)
var savedDashboard:SavedDashboard;
var dashboardFactory = props.plugins.embeddable.getEmbeddableFactory("dashboard") as DashboardContainerFactory;
this.state={
dashboardFactory:dashboardFactory
}
props.core.savedObjects.client.get("dashboard",props.fav.dashid).then(
async (res)=>{
const embeddablesMap: {
[key: string]: DashboardPanelState;
} = {};
savedDashboard=res as SavedDashboard
var dashmeta:DashboardMeta = JSON.parse(savedDashboard.attributes.kibanaSavedObjectMeta.searchSourceJSON)
var rawpanels = JSON.parse(savedDashboard.attributes.panelsJSON);
//props.plugins.embeddable.EmbeddablePanel
var ndx:number;
var idx:number = 0;
for (ndx=0;ndx<savedDashboard.references.length;ndx++){
for (idx=0; idx<rawpanels.length;idx++){
if (savedDashboard.references[ndx].name == rawpanels[idx].panelRefName){
rawpanels[idx].id = savedDashboard.references[ndx].id as string
rawpanels[idx].type = savedDashboard.references[ndx].type as string
await props.core.savedObjects.client.get(rawpanels[idx].type,rawpanels[idx].id).then((res)=>{
var temp = convertSavedDashboardPanelToPanelState(rawpanels[idx]);
// console.log(plugins.embeddable.getEmbeddablePanel(temp))
embeddablesMap[rawpanels[idx].panelIndex] = temp
})
}
}
}
this.setState({
savedDashboard:savedDashboard,
dashmeta:dashmeta,
embeddablesMap:embeddablesMap
})
}).catch(
(err)=>{console.log(err)})
console.log();
}
render(){
var id = "emebeddeddash-"+this.props.fav.dashid;
var element = <div id={id}></div>
const asyncRender = async ()=>{
var containerProps:DashboardContainerInput={
isEmbeddedExternally: false,
id: this.props.fav.dashid,
viewMode: ViewMode.VIEW,
filters: this.props.fav.showfilter ? this.props.fav?.filters as Filter[] : this.state.dashmeta!.filter,
panels: this.state.embeddablesMap!,
query: this.props.fav.showquery ? this.props.fav.query as Query : this.state.dashmeta!.query,
timeRange: this.props.fav.showtime ? this.props.fav.time as TimeRange : this.props.plugins.data.query.timefilter.timefilter.getTime(),
refreshConfig: this.props.fav.refreshInterval,
useMargins: true,
title: this.state.savedDashboard!.attributes.title,
isFullScreenMode: true,
timeRestore: false
};
var ContainerRenderer = createDashboardContainerByValueRenderer({factory:this.state.dashboardFactory})
ReactDOM.render(<ContainerRenderer input={containerProps}/>,document.getElementById(this.props.parentid))
}
if(this.state.embeddablesMap){
asyncRender()
}
return element
}
}