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;
|
sort?: number;
|
||||||
streaming?: boolean;
|
streaming?: boolean;
|
||||||
unlicensed?: boolean;
|
unlicensed?: boolean;
|
||||||
|
backend?: boolean;
|
||||||
isBackend?: boolean;
|
isBackend?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ export function loadDataSourceMeta(dataSource: DataSourceSettings): ThunkResult<
|
|||||||
const isBackend = plugin.DataSourceClass.prototype instanceof DataSourceWithBackend;
|
const isBackend = plugin.DataSourceClass.prototype instanceof DataSourceWithBackend;
|
||||||
const meta = {
|
const meta = {
|
||||||
...pluginInfo,
|
...pluginInfo,
|
||||||
isBackend: isBackend,
|
isBackend: pluginInfo.backend || isBackend,
|
||||||
};
|
};
|
||||||
|
|
||||||
dispatch(dataSourceMetaLoaded(meta));
|
dispatch(dataSourceMetaLoaded(meta));
|
||||||
|
@ -7,9 +7,10 @@ interface ActionComponentProps {
|
|||||||
onChangeDataSource?: (ds: DataSourceInstanceSettings) => void;
|
onChangeDataSource?: (ds: DataSourceInstanceSettings) => void;
|
||||||
timeRange?: TimeRange;
|
timeRange?: TimeRange;
|
||||||
dataSource?: DataSourceInstanceSettings;
|
dataSource?: DataSourceInstanceSettings;
|
||||||
|
key: string | number;
|
||||||
}
|
}
|
||||||
|
|
||||||
type QueryActionComponent = React.ComponentType<ActionComponentProps>;
|
type QueryActionComponent = (props: ActionComponentProps) => JSX.Element | null;
|
||||||
|
|
||||||
class QueryActionComponents {
|
class QueryActionComponents {
|
||||||
extraRenderActions: QueryActionComponent[] = [];
|
extraRenderActions: QueryActionComponent[] = [];
|
||||||
|
@ -305,16 +305,18 @@ export class QueryEditorRow<TQuery extends DataQuery> extends PureComponent<Prop
|
|||||||
|
|
||||||
renderExtraActions = () => {
|
renderExtraActions = () => {
|
||||||
const { query, queries, data, onAddQuery, dataSource } = this.props;
|
const { query, queries, data, onAddQuery, dataSource } = this.props;
|
||||||
return RowActionComponents.getAllExtraRenderAction().map((c, index) => {
|
return RowActionComponents.getAllExtraRenderAction()
|
||||||
return React.createElement(c, {
|
.map((action, index) =>
|
||||||
query,
|
action({
|
||||||
queries,
|
query,
|
||||||
timeRange: data.timeRange,
|
queries,
|
||||||
onAddQuery: onAddQuery as (query: DataQuery) => void,
|
timeRange: data.timeRange,
|
||||||
dataSource: dataSource,
|
onAddQuery: onAddQuery as (query: DataQuery) => void,
|
||||||
key: index,
|
dataSource,
|
||||||
});
|
key: index,
|
||||||
});
|
})
|
||||||
|
)
|
||||||
|
.filter(Boolean);
|
||||||
};
|
};
|
||||||
|
|
||||||
renderActions = (props: QueryOperationRowRenderProps) => {
|
renderActions = (props: QueryOperationRowRenderProps) => {
|
||||||
|
@ -306,13 +306,15 @@ export class QueryGroup extends PureComponent<Props, State> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
renderExtraActions() {
|
renderExtraActions() {
|
||||||
return GroupActionComponents.getAllExtraRenderAction().map((c, index) => {
|
return GroupActionComponents.getAllExtraRenderAction()
|
||||||
return React.createElement(c, {
|
.map((action, index) =>
|
||||||
onAddQuery: this.onAddQuery,
|
action({
|
||||||
onChangeDataSource: this.onChangeDataSource,
|
onAddQuery: this.onAddQuery,
|
||||||
key: index,
|
onChangeDataSource: this.onChangeDataSource,
|
||||||
});
|
key: index,
|
||||||
});
|
})
|
||||||
|
)
|
||||||
|
.filter(Boolean);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderAddQueryRow(dsSettings: DataSourceInstanceSettings, styles: QueriesTabStyles) {
|
renderAddQueryRow(dsSettings: DataSourceInstanceSettings, styles: QueriesTabStyles) {
|
||||||
|
Loading…
Reference in New Issue
Block a user