Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions docs/contributing/dashboard-tables.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Dashboard table panels

Table panels list rows from **canvas memory** (recommended for ephemeral environment
dashboards) or from executions / runs. Configuration lives on each panel's
`content` object and can be edited via the panel form or YAML tab.

## Memory source

```yaml
type: table
content:
dataSource:
kind: memory
namespace: environments
render:
kind: table
columns:
- field: pr_number
label: PR
- field: status
label: Health
format: status
- field: created_at
label: Uptime
format: relative
where:
- field: status
op: neq
value: destroyed
rowActions:
- kind: trigger
label: Destroy
node: start
template: destroy
variant: danger
confirm: "Destroy PR #{{ pr_number }}?"
show: 'status == "running"'
payload:
issue.number: "{{ pr_number }}"
```

The editor scans live canvas memory and suggests namespaces and field names.

## Row actions

Row actions invoke a **trigger node** on the canvas (`InvokeNodeTriggerHook`).
Downstream steps (such as HTTP Request) run when that trigger fires.

- `node` — trigger node id or name (required)
- `hook` — defaults to `run`
- `template` — Start template name when applicable
- `payload` — map of dot-paths to literals or `{{ CEL }}` templates merged into the run payload
- `confirm` — optional confirmation dialog (supports `{{ }}` interpolation)
- `show` — CEL `{{ }}`, legacy `field == "value"`, or dashboard expressions

## CEL

Fields wrapped in `{{ ... }}` use [CEL](https://github.com/google/cel-spec).
Each row exposes its memory keys plus `now` (Unix seconds).

## Filters (`where`)

Structured filters are ANDed:

| `op` | Meaning |
|------|---------|
| `eq` / `neq` | String equality |
| `contains` / `not_contains` | Substring |
| `gt` / `lt` | Numeric compare |
| `exists` / `not_exists` | Non-empty / empty field |
17 changes: 6 additions & 11 deletions pkg/grpc/actions/canvases/dashboard_serialization.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package canvases

import (
"encoding/json"
"fmt"

"github.com/superplanehq/superplane/pkg/models"
Expand All @@ -10,8 +9,12 @@ import (
"google.golang.org/protobuf/types/known/timestamppb"
)

const MaxDashboardPanels = 50
const MaxDashboardPayloadBytes = 1024 * 1024
// MaxDashboardPanels and MaxDashboardPayloadBytes are re-exported from the
// models package so existing gRPC tests/callers keep working unchanged.
const (
MaxDashboardPanels = models.MaxDashboardPanels
MaxDashboardPayloadBytes = models.MaxDashboardPayloadBytes
)

func serializeCanvasDashboard(dashboard *models.CanvasDashboard) (*pb.CanvasDashboard, error) {
panels := dashboard.Panels.Data()
Expand Down Expand Up @@ -132,11 +135,3 @@ func toStructpbCompatible(v any) any {
return v
}
}

func encodedDashboardPanelsSize(panels []models.DashboardPanel) (int, error) {
encoded, err := json.Marshal(panels)
if err != nil {
return 0, err
}
return len(encoded), nil
}
48 changes: 2 additions & 46 deletions pkg/grpc/actions/canvases/update_canvas_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,52 +70,8 @@ func UpdateCanvasDashboard(ctx context.Context, organizationID, canvasID string,
}

func validateDashboardInput(panels []models.DashboardPanel, layout []models.DashboardLayoutItem) error {
if len(panels) > MaxDashboardPanels {
return status.Errorf(codes.InvalidArgument, "too many panels (max %d)", MaxDashboardPanels)
if err := models.ValidateDashboardContent(panels, layout); err != nil {
return status.Errorf(codes.InvalidArgument, "%v", err)
}

panelIDs := make(map[string]struct{}, len(panels))
for _, panel := range panels {
if panel.ID == "" {
return status.Error(codes.InvalidArgument, "panel id is required")
}
if panel.Type == "" {
return status.Errorf(codes.InvalidArgument, "panel %q type is required", panel.ID)
}
if _, exists := panelIDs[panel.ID]; exists {
return status.Errorf(codes.InvalidArgument, "duplicate panel id %q", panel.ID)
}
panelIDs[panel.ID] = struct{}{}
}

size, err := encodedDashboardPanelsSize(panels)
if err != nil {
return status.Error(codes.Internal, "failed to validate panel size")
}
if size > MaxDashboardPayloadBytes {
return status.Errorf(codes.InvalidArgument, "panels payload exceeds %d bytes", MaxDashboardPayloadBytes)
}

layoutIDs := make(map[string]struct{}, len(layout))
for _, item := range layout {
if item.I == "" {
return status.Error(codes.InvalidArgument, "layout item i is required")
}
if _, exists := layoutIDs[item.I]; exists {
return status.Errorf(codes.InvalidArgument, "duplicate layout id %q", item.I)
}
layoutIDs[item.I] = struct{}{}

if _, ok := panelIDs[item.I]; !ok {
return status.Errorf(codes.InvalidArgument, "layout item %q does not reference any panel", item.I)
}
if item.W <= 0 || item.H <= 0 {
return status.Errorf(codes.InvalidArgument, "layout item %q must have positive width and height", item.I)
}
if item.X < 0 || item.Y < 0 {
return status.Errorf(codes.InvalidArgument, "layout item %q must have non-negative x and y", item.I)
}
}

return nil
}
Loading
Loading