convertPanel()

in scripts/dashboard-importer/src/dashboards/converter/converter.ts [124:161]


  convertPanel(panel: Panel) {
    const targets = panel.targets || [];

    if (panel.type === 'row') {
      this.warnings.push(
        `Panel '${panel.title}': Collapsible groups currently are not yet fully supported. Charts will be unnested`,
      );
    }
    if (panel.panels && panel.panels.length > 0) {
      const panels = panel.panels || [];
      for (const subpanel of panels) {
        this.convertPanel(subpanel);
      }
    } else {
      const tile = this.constructTile(panel, targets);
      // Monitoring dashboard API has a hard cap of 40 tiles per dashboard
      if (this.tiles.length === MAX_TILE_COUNT) {
        this.warnings.push(
          `Panel '${panel.title}' was skipped as the maximum number of tiles: ${MAX_TILE_COUNT} has been reached`,
        );
      }
      if (
        tile &&
        Object.keys(tile).length &&
        this.tiles.length < MAX_TILE_COUNT
      ) {
        // update the grid to track which coordinates are in use
        const updateGridSuceeded = updateGrid(tile, this.grid);
        if (updateGridSuceeded) {
          this.tiles.push(tile);
        } else {
          this.warnings.push(
            `Panel '${panel.title}' unexpectedly overlaps with existing tiles and was skipped`,
          );
        }
      }
    }
  }