Skip to content

table panel builder: hideFrom viz doesn't work #1348

@LarsStegman

Description

@LarsStegman

Hello,

I am building a custom visualisation. Before I used this to hide all columns except specific ones:

return PanelBuilders.table()
  .setCustomFieldConfig('hidden', true)
  .setOverrides((b) => {
    b.matchFieldsWithName('name')
      .overrideCustomFieldConfig('hidden', false)
  })
  .build()

However in the newer versions you're supposed to use hideFrom instead of hidden.

return PanelBuilders.table()
  .setCustomFieldConfig('hideFrom', { viz: true })
  .setOverrides((b) => {
    b.matchFieldsWithName('name')
      .overrideCustomFieldConfig('hideFrom', { viz: false })
//                                             ^^^ this breaks because legend and tooltip are also required
  })
  .build()

legend and tooltip are also required in the override. That's fine, then we'll add them.

return PanelBuilders.table()
  .setCustomFieldConfig('hideFrom', { viz: true })
  .setOverrides((b) => {
    b.matchFieldsWithName('name')
      .overrideCustomFieldConfig('hideFrom', { viz: false, legend: false, tooltip: false })
  })
  .build()

Now this compiles, but it doesn't actually work. When looking at the scene-debugger the override for hideFrom is completely gone and no data shows.

So I looked at a dashboard JSON. This stores the overrides like this:

        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "name"
            },
            "properties": [
              {
                "id": "custom.hideFrom.viz",
                       ^^^^ this is the weird part
                "value": true
              }
            ]
          }
        ]

Then I tried to use the PanelBuilder like this:

return PanelBuilders.table()
  .setCustomFieldConfig('hideFrom', { viz: true })
  .setOverrides((b) => {
    b.matchFieldsWithName('name')
      .overrideCustomFieldConfig('hideFrom.viz', false)
  })
  .build()

And this actually works, but it does give an error in the compiler!

Interestingly enough, the transformer organize, stores the fieldConfig like this:

          "custom": {
            "align": "auto",
            "cellOptions": {
              "type": "auto"
            },
            "footer": {
              "reducers": []
            },
            "hideFrom": {
              "viz": false
            },
            "inspect": false
          },

Which is the structured way again.

With the hidden fields overrides broken, my custom UI doesn't work anymore.

For now I've suppressed the error with // @ts-ignore

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions