Notify panel plugin on queries changes

Hello dear Grafana community,
Im actually working on a react panel plugin wich is actually developed for Grafana >=7.0.0
Im using the “Cascader” component, wich allow me to select a query from the query list on left bottom side of the panel. like this:

The problem is the following : on panel load, my cascader component see all the existing queries, but when i create or delete a query, the cascader is not notified except if i click on the relad panel button

without using the reload button

After using the reload button

I already searched if it was possible to use an eventbus but i didnt found any solution.
when i add or remove a query, the context prop is not updated…
here is the code that generate the cascader options
(The component DisplayOptions is called in the customEditor component, context is passed as a prop)

export default function DisplayOptions({ context, dataBinding, onChangeBinding }: DisplayOptionsProps) {
  const generateOptions = (): CascaderOption[] => {
    return context.data.map((dataFrame: DataFrame) => ({
      label: dataFrame.refId ?? 'Undefined query name',
      value: dataFrame.refId ?? 'Undefined query name',
      items: dataFrame.fields.map(({ name }) => ({
        label: name,
        value: `${dataFrame.refId ?? 'Undefined query name'}/${name}`,
      })),
    }));
  };
...

All i need is a way to keep the cascader updated, without the need to click on the reload button each times i create / remove / edit a query.
thanks in advance for anyone who can help me :slight_smile:

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.