Skip to content
This repository was archived by the owner on Jun 26, 2023. It is now read-only.

Add "selected" field to custom template variable when multi=false #258

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

DifferentialOrange
Copy link
Contributor

@DifferentialOrange DifferentialOrange commented Aug 26, 2020

Adds "selected" field to custom template variable when multi=false. Select first value as current if current is not specified.

Change was introduced in #222 merge request, reworked due to #232 merge request contribution.

In current version of grafonnet-lib "selected" field added to custom template variable only when multi is true. But Grafana behavior is different.

If we create simple custom variable
image
Grafana's dashboard code will contain the following object:

{
    "allValue": null,
    "current": {
      "selected": false,
      "text": "1",
      "value": "1"
    },
    "hide": 0,
    "includeAll": false,
    "label": null,
    "multi": false,
    "name": "custom",
    "options": [
         {
            "selected": true,
            "text": "1",
            "value": "1"
         },
         {
            "selected": false,
            "text": "10",
            "value": "10"
         }
     ],
    "query": "1, 10",
    "skipUrlSync": false,
    "type": "custom"
}

i.e. Grafana adds "selected" field even if "multi" is false and, moreover, selects first value as current if user don't set current value. The behavior is the same if "Include All option" is enabled.

Unverified

This user has not yet uploaded their public signing key.
Add "selected" field to custom template variable when multi=false, based on Grafana behavior.
Select first value if current is not specified.
@bcdady
Copy link

bcdady commented May 18, 2022

I see that this was pointed to in favor of #222, however this has not yet been merged.
Is there something else that needs to happen to get this merged?
It will also be very helpful to see an example implementation.

@bcdady
Copy link

bcdady commented May 18, 2022

@DifferentialOrange, can you please elaborate on how/why this is favorable over #222?
How does this MR/PR offer advantages for defining a template variable with type='constant' in grafonnet?

@DifferentialOrange
Copy link
Contributor Author

DifferentialOrange commented May 20, 2022

@DifferentialOrange, can you please elaborate on how/why this is favorable over #222?

As far as I remember (sorry, two years have passed) #222 was separated into two independent PRs: #257 and #258, considering up to date master. #257 and #258 should introduce the same functionality as #222, it's more like a formalization.

How does this MR/PR offer advantages for defining a template variable with type='constant' in grafonnet?

It doesn't. This PR is about custom variable. For constant variable, refer to #257

@CLAassistant
Copy link

CLAassistant commented Jun 15, 2022

CLA assistant check
All committers have signed the CLA.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants