소스 검색

fix selected home dashboard should show as selected even though its not starred

Marcus Efraimsson 7 년 전
부모
커밋
52a71596eb
1개의 변경된 파일7개의 추가작업 그리고 1개의 파일을 삭제
  1. 7 1
      public/app/core/components/SharedPreferences/SharedPreferences.tsx

+ 7 - 1
public/app/core/components/SharedPreferences/SharedPreferences.tsx

@@ -30,7 +30,6 @@ export class SharedPreferences extends PureComponent<Props, State> {
 
 
   constructor(props) {
   constructor(props) {
     super(props);
     super(props);
-    console.log('props', props);
 
 
     this.state = {
     this.state = {
       homeDashboardId: 0,
       homeDashboardId: 0,
@@ -44,6 +43,13 @@ export class SharedPreferences extends PureComponent<Props, State> {
     const prefs = await this.backendSrv.get(`/api/${this.props.resourceUri}/preferences`);
     const prefs = await this.backendSrv.get(`/api/${this.props.resourceUri}/preferences`);
     const dashboards = await this.backendSrv.search({ starred: true });
     const dashboards = await this.backendSrv.search({ starred: true });
 
 
+    if (prefs.homeDashboardId > 0 && !dashboards.find(d => d.id === prefs.homeDashboardId)) {
+      const missing = await this.backendSrv.search({ dashboardIds: [prefs.homeDashboardId] });
+      if (missing && missing.length > 0) {
+        dashboards.push(missing[0]);
+      }
+    }
+
     this.setState({
     this.setState({
       homeDashboardId: prefs.homeDashboardId,
       homeDashboardId: prefs.homeDashboardId,
       theme: prefs.theme,
       theme: prefs.theme,