mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Explore Metrics: Remove disabled state from exploration button (#96910)
This commit is contained in:
parent
c2cd08ee84
commit
b3b339d5bb
@ -18,7 +18,6 @@ export interface AddToExplorationButtonState extends SceneObjectState {
|
|||||||
fieldName?: string;
|
fieldName?: string;
|
||||||
context?: ExtensionContext;
|
context?: ExtensionContext;
|
||||||
|
|
||||||
disabledLinks: string[];
|
|
||||||
queries: DataQuery[];
|
queries: DataQuery[];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,8 +36,8 @@ interface ExtensionContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class AddToExplorationButton extends SceneObjectBase<AddToExplorationButtonState> {
|
export class AddToExplorationButton extends SceneObjectBase<AddToExplorationButtonState> {
|
||||||
constructor(state: Omit<AddToExplorationButtonState, 'disabledLinks' | 'queries'>) {
|
constructor(state: Omit<AddToExplorationButtonState, 'queries'>) {
|
||||||
super({ ...state, disabledLinks: [], queries: [] });
|
super({ ...state, queries: [] });
|
||||||
|
|
||||||
this.addActivationHandler(this._onActivate.bind(this));
|
this.addActivationHandler(this._onActivate.bind(this));
|
||||||
}
|
}
|
||||||
@ -98,7 +97,7 @@ export class AddToExplorationButton extends SceneObjectBase<AddToExplorationButt
|
|||||||
};
|
};
|
||||||
|
|
||||||
public static Component = ({ model }: SceneComponentProps<AddToExplorationButton>) => {
|
public static Component = ({ model }: SceneComponentProps<AddToExplorationButton>) => {
|
||||||
const { context, disabledLinks } = model.useState();
|
const { context } = model.useState();
|
||||||
const { links } = usePluginLinks({ extensionPointId, context, limitPerPlugin: 1 });
|
const { links } = usePluginLinks({ extensionPointId, context, limitPerPlugin: 1 });
|
||||||
const link = links.find((link) => link.pluginId === explorationsPluginId);
|
const link = links.find((link) => link.pluginId === explorationsPluginId);
|
||||||
|
|
||||||
@ -109,7 +108,6 @@ export class AddToExplorationButton extends SceneObjectBase<AddToExplorationButt
|
|||||||
return (
|
return (
|
||||||
<IconButton
|
<IconButton
|
||||||
tooltip={link.description}
|
tooltip={link.description}
|
||||||
disabled={link.category === 'disabled' || disabledLinks.includes(link.id)}
|
|
||||||
aria-label={addToExplorationsButtonLabel} // this is overriden by the `tooltip`
|
aria-label={addToExplorationsButtonLabel} // this is overriden by the `tooltip`
|
||||||
key={link.id}
|
key={link.id}
|
||||||
name={link.icon ?? 'panel-add'}
|
name={link.icon ?? 'panel-add'}
|
||||||
@ -117,7 +115,6 @@ export class AddToExplorationButton extends SceneObjectBase<AddToExplorationButt
|
|||||||
if (link.onClick) {
|
if (link.onClick) {
|
||||||
link.onClick(e);
|
link.onClick(e);
|
||||||
}
|
}
|
||||||
model.setState({ disabledLinks: [...disabledLinks, link.id] });
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user