mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
add support for conditionally rendering extraRenderActions (#41783)
This commit is contained in:
parent
2e3e7a7e55
commit
dad54d499b
@ -128,6 +128,7 @@ export interface DataSourcePluginMeta<T extends KeyValue = {}> extends PluginMet
|
||||
sort?: number;
|
||||
streaming?: boolean;
|
||||
unlicensed?: boolean;
|
||||
backend?: boolean;
|
||||
isBackend?: boolean;
|
||||
}
|
||||
|
||||
|
@ -135,7 +135,7 @@ export function loadDataSourceMeta(dataSource: DataSourceSettings): ThunkResult<
|
||||
const isBackend = plugin.DataSourceClass.prototype instanceof DataSourceWithBackend;
|
||||
const meta = {
|
||||
...pluginInfo,
|
||||
isBackend: isBackend,
|
||||
isBackend: pluginInfo.backend || isBackend,
|
||||
};
|
||||
|
||||
dispatch(dataSourceMetaLoaded(meta));
|
||||
|
@ -7,9 +7,10 @@ interface ActionComponentProps {
|
||||
onChangeDataSource?: (ds: DataSourceInstanceSettings) => void;
|
||||
timeRange?: TimeRange;
|
||||
dataSource?: DataSourceInstanceSettings;
|
||||
key: string | number;
|
||||
}
|
||||
|
||||
type QueryActionComponent = React.ComponentType<ActionComponentProps>;
|
||||
type QueryActionComponent = (props: ActionComponentProps) => JSX.Element | null;
|
||||
|
||||
class QueryActionComponents {
|
||||
extraRenderActions: QueryActionComponent[] = [];
|
||||
|
@ -305,16 +305,18 @@ export class QueryEditorRow<TQuery extends DataQuery> extends PureComponent<Prop
|
||||
|
||||
renderExtraActions = () => {
|
||||
const { query, queries, data, onAddQuery, dataSource } = this.props;
|
||||
return RowActionComponents.getAllExtraRenderAction().map((c, index) => {
|
||||
return React.createElement(c, {
|
||||
return RowActionComponents.getAllExtraRenderAction()
|
||||
.map((action, index) =>
|
||||
action({
|
||||
query,
|
||||
queries,
|
||||
timeRange: data.timeRange,
|
||||
onAddQuery: onAddQuery as (query: DataQuery) => void,
|
||||
dataSource: dataSource,
|
||||
dataSource,
|
||||
key: index,
|
||||
});
|
||||
});
|
||||
})
|
||||
)
|
||||
.filter(Boolean);
|
||||
};
|
||||
|
||||
renderActions = (props: QueryOperationRowRenderProps) => {
|
||||
|
@ -306,13 +306,15 @@ export class QueryGroup extends PureComponent<Props, State> {
|
||||
}
|
||||
|
||||
renderExtraActions() {
|
||||
return GroupActionComponents.getAllExtraRenderAction().map((c, index) => {
|
||||
return React.createElement(c, {
|
||||
return GroupActionComponents.getAllExtraRenderAction()
|
||||
.map((action, index) =>
|
||||
action({
|
||||
onAddQuery: this.onAddQuery,
|
||||
onChangeDataSource: this.onChangeDataSource,
|
||||
key: index,
|
||||
});
|
||||
});
|
||||
})
|
||||
)
|
||||
.filter(Boolean);
|
||||
}
|
||||
|
||||
renderAddQueryRow(dsSettings: DataSourceInstanceSettings, styles: QueriesTabStyles) {
|
||||
|
Loading…
Reference in New Issue
Block a user