Browse Source

Expand rows for panels in collapsed rows

Torkel Ödegaard 6 years ago
parent
commit
aa2bf07c71

+ 6 - 1
public/app/features/dashboard/containers/DashboardPage.tsx

@@ -120,7 +120,12 @@ export class DashboardPage extends PureComponent<Props, State> {
   onEnterFullscreen() {
     const { dashboard, urlEdit, urlFullscreen, urlPanelId } = this.props;
 
-    const panel = dashboard.getPanelById(parseInt(urlPanelId, 10));
+    const panelId = parseInt(urlPanelId, 10);
+
+    // need to expand parent row if this panel is inside a row
+    dashboard.expandParentRowFor(panelId);
+
+    const panel = dashboard.getPanelById(panelId);
 
     if (panel) {
       dashboard.setViewMode(panel, urlFullscreen, urlEdit);

+ 7 - 1
public/app/features/dashboard/containers/SoloPanelPage.tsx

@@ -59,7 +59,13 @@ export class SoloPanelPage extends Component<Props, State> {
 
     // we just got the dashboard!
     if (!prevProps.dashboard) {
-      const panel = dashboard.getPanelById(parseInt(urlPanelId, 10));
+      const panelId = parseInt(urlPanelId, 10);
+
+      // need to expand parent row if this panel is inside a row
+      dashboard.expandParentRowFor(panelId);
+
+      const panel = dashboard.getPanelById(panelId);
+
       if (!panel) {
         this.setState({ notFound: true });
         return;

+ 14 - 0
public/app/features/dashboard/state/DashboardModel.ts

@@ -904,4 +904,18 @@ export class DashboardModel {
     this.processRepeats();
     this.events.emit('template-variable-value-updated');
   }
+
+  expandParentRowFor(panelId: number) {
+    for (const panel of this.panels) {
+      if (panel.collapsed) {
+        for (const rowPanel of panel.panels) {
+          if (rowPanel.id === panelId) {
+            this.toggleRow(panel);
+            return;
+          }
+        }
+      }
+    }
+  }
+
 }