diff --git a/public/app/plugins/datasource/grafana-pyroscope-datasource/QueryEditor/QueryOptionGroup.tsx b/public/app/plugins/datasource/grafana-pyroscope-datasource/QueryEditor/QueryOptionGroup.tsx
new file mode 100644
index 00000000000..dfd42c81bf5
--- /dev/null
+++ b/public/app/plugins/datasource/grafana-pyroscope-datasource/QueryEditor/QueryOptionGroup.tsx
@@ -0,0 +1,82 @@
+import { css } from '@emotion/css';
+import React from 'react';
+import { useToggle } from 'react-use';
+
+import { GrafanaTheme2 } from '@grafana/data';
+import { Collapse, useStyles2, Stack } from '@grafana/ui';
+
+export interface Props {
+ title: string;
+ collapsedInfo: string[];
+ children: React.ReactNode;
+}
+
+export function QueryOptionGroup({ title, children, collapsedInfo }: Props) {
+ const [isOpen, toggleOpen] = useToggle(false);
+ const styles = useStyles2(getStyles);
+
+ return (
+
+
+ {title}
+ {!isOpen && (
+
+ {collapsedInfo.map((x, i) => (
+ {x}
+ ))}
+
+ )}
+
+ }
+ >
+ {children}
+
+
+ );
+}
+
+const getStyles = (theme: GrafanaTheme2) => {
+ return {
+ collapse: css({
+ backgroundColor: 'unset',
+ border: 'unset',
+ marginBottom: 0,
+
+ ['> button']: {
+ padding: theme.spacing(0, 1),
+ },
+ }),
+ wrapper: css({
+ width: '100%',
+ display: 'flex',
+ justifyContent: 'space-between',
+ alignItems: 'baseline',
+ }),
+ title: css({
+ flexGrow: 1,
+ overflow: 'hidden',
+ fontSize: theme.typography.bodySmall.fontSize,
+ fontWeight: theme.typography.fontWeightMedium,
+ margin: 0,
+ }),
+ description: css({
+ color: theme.colors.text.secondary,
+ fontSize: theme.typography.bodySmall.fontSize,
+ fontWeight: theme.typography.bodySmall.fontWeight,
+ paddingLeft: theme.spacing(2),
+ gap: theme.spacing(2),
+ display: 'flex',
+ }),
+ body: css({
+ display: 'flex',
+ gap: theme.spacing(2),
+ flexWrap: 'wrap',
+ }),
+ };
+};
diff --git a/public/app/plugins/datasource/grafana-pyroscope-datasource/QueryEditor/QueryOptions.tsx b/public/app/plugins/datasource/grafana-pyroscope-datasource/QueryEditor/QueryOptions.tsx
index 71a4a7f1f88..b31b6d42281 100644
--- a/public/app/plugins/datasource/grafana-pyroscope-datasource/QueryEditor/QueryOptions.tsx
+++ b/public/app/plugins/datasource/grafana-pyroscope-datasource/QueryEditor/QueryOptions.tsx
@@ -5,10 +5,10 @@ import { CoreApp, GrafanaTheme2, SelectableValue } from '@grafana/data';
import { config } from '@grafana/runtime';
import { useStyles2, RadioButtonGroup, MultiSelect, Input } from '@grafana/ui';
-import { QueryOptionGroup } from '../../prometheus/querybuilder/shared/QueryOptionGroup';
import { Query } from '../types';
import { EditorField } from './EditorField';
+import { QueryOptionGroup } from './QueryOptionGroup';
import { Stack } from './Stack';
export interface Props {
diff --git a/public/app/plugins/datasource/grafana-pyroscope-datasource/VariableSupport.ts b/public/app/plugins/datasource/grafana-pyroscope-datasource/VariableSupport.ts
index 80038991d82..99a3e24a394 100644
--- a/public/app/plugins/datasource/grafana-pyroscope-datasource/VariableSupport.ts
+++ b/public/app/plugins/datasource/grafana-pyroscope-datasource/VariableSupport.ts
@@ -2,8 +2,6 @@ import { from, map, Observable, of } from 'rxjs';
import { CustomVariableSupport, DataQueryRequest, DataQueryResponse, MetricFindValue } from '@grafana/data';
-import { getTimeSrv, TimeSrv } from '../../../features/dashboard/services/TimeSrv';
-
import { VariableQueryEditor } from './VariableQueryEditor';
import { PyroscopeDataSource } from './datasource';
import { ProfileTypeMessage, VariableQuery } from './types';
@@ -15,10 +13,7 @@ export interface DataAPI {
}
export class VariableSupport extends CustomVariableSupport {
- constructor(
- private readonly dataAPI: DataAPI,
- private readonly timeSrv: TimeSrv = getTimeSrv()
- ) {
+ constructor(private readonly dataAPI: DataAPI) {
super();
}
@@ -26,9 +21,7 @@ export class VariableSupport extends CustomVariableSupport
query(request: DataQueryRequest): Observable {
if (request.targets[0].type === 'profileType') {
- return from(
- this.dataAPI.getProfileTypes(this.timeSrv.timeRange().from.valueOf(), this.timeSrv.timeRange().to.valueOf())
- ).pipe(
+ return from(this.dataAPI.getProfileTypes(request.range.from.valueOf(), request.range.to.valueOf())).pipe(
map((values) => {
return { data: values.map((v) => ({ text: v.label, value: v.id })) };
})
@@ -42,8 +35,8 @@ export class VariableSupport extends CustomVariableSupport
return from(
this.dataAPI.getLabelNames(
request.targets[0].profileTypeId + '{}',
- this.timeSrv.timeRange().from.valueOf(),
- this.timeSrv.timeRange().to.valueOf()
+ request.range.from.valueOf(),
+ request.range.to.valueOf()
)
).pipe(
map((values) => {
@@ -60,8 +53,8 @@ export class VariableSupport extends CustomVariableSupport
this.dataAPI.getLabelValues(
request.targets[0].profileTypeId + '{}',
request.targets[0].labelName,
- this.timeSrv.timeRange().from.valueOf(),
- this.timeSrv.timeRange().to.valueOf()
+ request.range.from.valueOf(),
+ request.range.to.valueOf()
)
).pipe(
map((values) => {