Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Rework variable handling in dashboards #250

Closed
ricoberger opened this issue Dec 25, 2021 · 0 comments · Fixed by #262
Closed

[core] Rework variable handling in dashboards #250

ricoberger opened this issue Dec 25, 2021 · 0 comments · Fixed by #262
Assignees
Labels
enhancement New feature or request

Comments

@ricoberger
Copy link
Member

ricoberger commented Dec 25, 2021

Is your feature request related to a problem? Please describe

At the moment it is difficult to extend the supported variables in the Dashboard component with new options, e.g. an option from the Azure plugin, which loads all resource groups or an option in the klogs plugin which allows users to select a value from a field.

The problem is that all options for the variables are defined within the following function:

const { isError, error, data, refetch } = useQuery<IVariableValues[] | null, Error>(

Describe the solution you'd like

A better solution would be to define the options to load variable values in the plugin, for example we can add a new optional field to the IPluginComponent interface:

export interface IPluginComponent {
  home?: React.FunctionComponent<IPluginPageProps>;
  icon: string;
  page?: React.FunctionComponent<IPluginPageProps>;
  panel: React.FunctionComponent<IPluginPanelProps>;
  preview?: React.FunctionComponent<IPluginPreviewProps>;
  variables?: (variable: IVariable) => IVariableValues;
}

With the new variables field we can then define function for each plugin which takes the user defined variable (type: IVariable), then runs the plugin logic / executes the API request and returns the variable values (type: IVariableValues).

Additional context

  • With this new implementation it is also possible that variables can be defined via community plugins.
  • We have to find a new home for the Variable Plugin Options documentation. At the moment I think the best would be to add a new Variables heading on the same level as the Configuration and Options headings.
@ricoberger ricoberger added the enhancement New feature or request label Dec 25, 2021
@ricoberger ricoberger self-assigned this Dec 27, 2021
ricoberger added a commit that referenced this issue Dec 28, 2021
This commit changes the variables handling, like it was discussed in
issue #250. This means that each plugin can now export a "variables"
function to load variables in a dashboard. The only exception is the
"core" plugin, where the variables are still handled within the
Dashboards component.

This change allows us, to introduced variables for more plugins, like a
list of resource groups via the Azure plugin or a list of field values
via the klogs plugin.

We also adjusted the naming and location of some interfaces for this
change. So that the interfaces for the CRDs are now prefixed with the
name of the CRD (e.g. "IPlaceholder" becomes "IDashboardPlaceholder").
This was necessary to reduce conflicts in names and to avoid cycle
imports.

The documentation for the variables options which can be used in a
dashboard, should be placed on the corresponding plugin page and a link
should be added to the "Variable Plugin Options" section in the
dashboards documentation.

Closes #250.
ricoberger added a commit that referenced this issue Dec 28, 2021
This commit changes the variables handling, like it was discussed in
issue #250. This means that each plugin can now export a "variables"
function to load variables in a dashboard. The only exception is the
"core" plugin, where the variables are still handled within the
Dashboards component.

This change allows us, to introduced variables for more plugins, like a
list of resource groups via the Azure plugin or a list of field values
via the klogs plugin.

We also adjusted the naming and location of some interfaces for this
change. So that the interfaces for the CRDs are now prefixed with the
name of the CRD (e.g. "IPlaceholder" becomes "IDashboardPlaceholder").
This was necessary to reduce conflicts in names and to avoid cycle
imports.

The documentation for the variables options which can be used in a
dashboard, should be placed on the corresponding plugin page and a link
should be added to the "Variable Plugin Options" section in the
dashboards documentation.

Closes #250.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant