Skip to content

[FEATURE](table): equivalent of Grafana absolute thresholds to cellSettings - #808

Open
colivi wants to merge 1 commit into
perses:mainfrom
colivi:feat/table-migrate-thresholds-color-text
Open

[FEATURE](table): equivalent of Grafana absolute thresholds to cellSettings#808
colivi wants to merge 1 commit into
perses:mainfrom
colivi:feat/table-migrate-thresholds-color-text

Conversation

@colivi

@colivi colivi commented Sep 10, 2026

Copy link
Copy Markdown

Description

Equivalent of Grafana table "fieldConfig.defaults.thresholds" (absolute mode) into Perses Table "cellSettings" with "Range" conditions.

When

  • "color.mode" is "thresholds"
  • "thresholds.mode" is "absolute"
  • at least one step has a numeric "value"
  • cell style is "color-text" (defaults or byName override) or "color-background"

How

  • Steps ordered highest "min" first (Table UI: first match wins)
  • Base step ("value: null") → "Range" with "min: 0"
  • "color-text" → "textColor"; "color-background" → "backgroundColor"
  • Named colors via "common/migrate" color map; hex colors passed through
  • Skips plain "auto" cellOptions and base-only ladders (e.g. green@null only) so existing migrate fixtures stay stable

Test

  • "table/schemas/migrate/tests/thresholds-color-text-absolute" (Uptime-style blue / green@1d / yellow@90d / red@180d)

Screenshots

N/A — migrate schema only (no UI change).

Checklist

  • Pull request has a descriptive title and context useful to a reviewer.
  • Pull request title follows the "[<catalog_entry>] " naming convention using one of the
    following "catalog_entry" values: "FEATURE", "ENHANCEMENT", "BUGFIX", "BREAKINGCHANGE", "DOC","IGNORE".
  • All commits have DCO signoffs.

UI Changes

  • Changes that impact the UI include screenshots and/or screencasts of the relevant changes.
  • Code follows the UI guidelines.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Threshold migration loses field-override scope and mishandles base ranges for negative values.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds Grafana absolute-threshold migration to Perses Table conditional cell formatting.

Changes:

  • Converts threshold steps into ordered Range cell settings.
  • Maps threshold colors to text or background colors.
  • Adds an Uptime migration fixture.
File summaries
File Description
table/schemas/migrate/migrate.cue Implements threshold conversion.
table/schemas/migrate/tests/thresholds-color-text-absolute/input.json Provides Grafana input coverage.
table/schemas/migrate/tests/thresholds-color-text-absolute/expected.json Defines expected Perses output.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 2
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread table/schemas/migrate/migrate.cue Outdated
Comment on lines +312 to +316
_hasColorTextOverride: len([
for o in (*#panel.fieldConfig.overrides | [])
for p in (*o.properties | [])
if p.id == "custom.cellOptions" if (*p.value.type | "") == "color-text" {true},
]) > 0
Comment thread table/schemas/migrate/migrate.cue Outdated
[for b in _thresholdBaseColors {
condition: {
kind: "Range"
spec: min: 0
@shahrokni
shahrokni self-requested a review September 11, 2026 11:11
@colivi
colivi force-pushed the feat/table-migrate-thresholds-color-text branch from de015f2 to f3e0aba Compare September 12, 2026 14:50
Map fieldConfig.defaults.thresholds (absolute) to Range cellSettings when
color.mode is thresholds and cellOptions is color-text (or color-background).

- Highest min first (Perses first-match evaluation)
- textColor for color-text; backgroundColor for color-background
- Named Grafana colors via shared migrate color map; pass through hex
- Skip base-only green@null ladders and plain auto cellOptions
- Field-scoped color-text/color-background overrides attach the ladder on
  columnSettings[].cellSettings; global only for default cell style
- Base threshold covers values below the lowest numeric step (incl. negatives)
- Fix empty list.Min when no numeric steps; Range max always paired with min

Test fixture mirrors network Uptime Max (blue/green/yellow/red seconds).

Signed-off-by: colivi <charles.olivi@gmail.com>
@colivi
colivi force-pushed the feat/table-migrate-thresholds-color-text branch from f3e0aba to e340365 Compare September 12, 2026 14:51
@colivi
colivi requested a review from a team as a code owner September 12, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants