diff --git a/docs/powerpipe-hcl/category.md b/docs/powerpipe-hcl/category.md index 7f75fe9..3684d6d 100644 --- a/docs/powerpipe-hcl/category.md +++ b/docs/powerpipe-hcl/category.md @@ -137,9 +137,10 @@ category "iam_policy" { |-|-|-|- | `color` | String | The matching color from the default theme for the data series index. | A [valid color value](/docs/powerpipe-hcl/dashboard#color). This may be a named color, RGB or RGBA string, or a control status color. | The color to display for this category. | | `href` | String | Optional | A url that the item should link to. The `href` may use a [jq template](/docs/powerpipe-hcl/dashboard#jq-templates) to dynamically generate the link. | -| `icon` | String | Optional | An [icon](/docs/powerpipe-hcl/dashboard#icon) to use for the elements with this category. +| `icon` | String | Optional | An [icon](/docs/powerpipe-hcl/dashboard#icon) to use for the elements with this category. | `title` | String | Optional | A plain text [title](/docs/powerpipe-hcl/dashboard#title) to display for this category. | `fold` | Block | Optional | A `fold` block for this category. +| `property` | Block | Optional | `property` blocks that define custom display options for specific properties in the properties pane. @@ -156,6 +157,59 @@ By default, folding is enabled with a threshold of `3`. This means that if ther | `threshold` | Number | Optional | The number of items that should be displayed before folding. The default is `3`. +## Property Blocks + +The `property` block allows you to customize how individual properties are displayed in the properties pane of nodes and edges in [node/edge visualizations](/docs/powerpipe-hcl/graph#nodeedge-visualizations) (`graph`, `flow`, and `hierarchy`). You can use property blocks to add hyperlinks to specific property values, making it easy to navigate to related resources. + +Property blocks are defined within a `category` block and are identified by the property name. The property name must match a key in the `properties` column returned by your SQL query. + +### Property Block Arguments + +| Argument | Type | Optional? | Description +|-|-|-|- +| `display` | String | Optional | Controls whether the property is shown in the properties pane. Valid values are `all` (default, show property) or `none` (hide property). | +| `href` | String | Optional | A url that the property value should link to. The `href` may use a [jq template](/docs/powerpipe-hcl/dashboard#jq-templates) to dynamically generate the link. The jq template has direct access to all properties in the node or edge (without needing the `.properties.` prefix used in category-level hrefs). | +| `wrap` | String | Optional | Controls text wrapping for the property value. Valid values are `none` (default, truncate long text) or `all` (wrap text to multiple lines). | + +In this example, we define a category for AWS VPCs with a property block for the `vpc_id` property. The `href` uses a jq template to create a link to the AWS Console VPC details page, dynamically incorporating both the `region` and `vpc_id` properties: + +```hcl +category "aws_vpc" { + title = "VPC" + color = "#FF9900" + + property "vpc_id" { + href = "https://console.aws.amazon.com/vpc?region={{.region}}#VpcDetails:VpcId={{.vpc_id}}" + } +} + +dashboard "vpc_graph" { + graph { + category = category.aws_vpc + + node { + sql = <<-EOQ + select + vpc_id as id, + title, + 'aws_vpc' as category, + jsonb_build_object( + 'vpc_id', vpc_id, + 'region', region, + 'cidr_block', cidr_block, + 'is_default', is_default::text + ) as properties + from + aws_vpc + EOQ + } + } +} +``` + +In the properties pane for each VPC node, the `vpc_id` property will be displayed as a clickable link that opens the AWS Console to that specific VPC's details page. + +Note that the jq template in the property `href` has direct access to all properties defined in the `properties` jsonb object. In the example above, the template can reference `{{.region}}`, `{{.vpc_id}}`, `{{.cidr_block}}`, and `{{.is_default}}` directly. This is different from category-level `href` templates, which must use the `.properties.` prefix (e.g., `{{.properties.'vpc_id'}}`). ## More Examples