@perses-dev/plugin-system 0.53.0-beta.0 → 0.53.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/dist/cjs/components/MultiQueryEditor/MultiQueryEditor.js +11 -4
  2. package/dist/cjs/components/MultiQueryEditor/QueryEditorContainer.js +71 -24
  3. package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +2 -0
  4. package/dist/cjs/components/PluginEditor/PluginEditor.js +8 -7
  5. package/dist/cjs/components/PluginEditor/plugin-editor-api.js +4 -4
  6. package/dist/cjs/components/PluginKindSelect/PluginKindSelect.js +9 -3
  7. package/dist/cjs/components/PluginRegistry/PluginRegistry.js +2 -2
  8. package/dist/cjs/components/PluginRegistry/plugin-indexes.js +2 -2
  9. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +5 -1
  10. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +15 -4
  11. package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +1 -1
  12. package/dist/cjs/components/Variables/variable-model.js +3 -3
  13. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +70 -33
  14. package/dist/cjs/runtime/TimeRangeProvider/{TimeRangeProviderWithQueryParams.js → TimeRangeProviders.js} +23 -5
  15. package/dist/cjs/runtime/TimeRangeProvider/index.js +1 -1
  16. package/dist/cjs/runtime/log-queries.js +2 -1
  17. package/dist/cjs/runtime/time-series-queries.js +10 -16
  18. package/dist/cjs/runtime/trace-queries.js +3 -13
  19. package/dist/cjs/test/utils.js +4 -4
  20. package/dist/cjs/utils/event.js +30 -0
  21. package/dist/cjs/utils/index.js +1 -0
  22. package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts +3 -0
  23. package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts.map +1 -1
  24. package/dist/components/MultiQueryEditor/MultiQueryEditor.js +11 -4
  25. package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -1
  26. package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts +3 -0
  27. package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts.map +1 -1
  28. package/dist/components/MultiQueryEditor/QueryEditorContainer.js +72 -25
  29. package/dist/components/MultiQueryEditor/QueryEditorContainer.js.map +1 -1
  30. package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -1
  31. package/dist/components/PanelSpecEditor/PanelSpecEditor.js +3 -1
  32. package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
  33. package/dist/components/PluginEditor/PluginEditor.d.ts.map +1 -1
  34. package/dist/components/PluginEditor/PluginEditor.js +8 -7
  35. package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
  36. package/dist/components/PluginEditor/plugin-editor-api.d.ts +2 -1
  37. package/dist/components/PluginEditor/plugin-editor-api.d.ts.map +1 -1
  38. package/dist/components/PluginEditor/plugin-editor-api.js +1 -1
  39. package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
  40. package/dist/components/PluginKindSelect/PluginKindSelect.d.ts +1 -0
  41. package/dist/components/PluginKindSelect/PluginKindSelect.d.ts.map +1 -1
  42. package/dist/components/PluginKindSelect/PluginKindSelect.js +9 -3
  43. package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
  44. package/dist/components/PluginRegistry/PluginRegistry.d.ts.map +1 -1
  45. package/dist/components/PluginRegistry/PluginRegistry.js +1 -1
  46. package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
  47. package/dist/components/PluginRegistry/plugin-indexes.d.ts.map +1 -1
  48. package/dist/components/PluginRegistry/plugin-indexes.js +1 -1
  49. package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
  50. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
  51. package/dist/components/TimeRangeControls/TimeRangeControls.js +5 -1
  52. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
  53. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
  54. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +16 -5
  55. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  56. package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts.map +1 -1
  57. package/dist/components/Variables/VariableEditorForm/VariablePreview.js +1 -1
  58. package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
  59. package/dist/components/Variables/variable-model.js +3 -3
  60. package/dist/components/Variables/variable-model.js.map +1 -1
  61. package/dist/model/time-series-queries.d.ts +0 -1
  62. package/dist/model/time-series-queries.d.ts.map +1 -1
  63. package/dist/model/time-series-queries.js.map +1 -1
  64. package/dist/runtime/DataQueriesProvider/model.d.ts +1 -1
  65. package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
  66. package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
  67. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts +2 -3
  68. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts.map +1 -1
  69. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +70 -33
  70. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
  71. package/dist/runtime/TimeRangeProvider/TimeRangeProviders.d.ts +10 -0
  72. package/dist/runtime/TimeRangeProvider/TimeRangeProviders.d.ts.map +1 -0
  73. package/dist/runtime/TimeRangeProvider/{TimeRangeProviderWithQueryParams.js → TimeRangeProviders.js} +13 -3
  74. package/dist/runtime/TimeRangeProvider/TimeRangeProviders.js.map +1 -0
  75. package/dist/runtime/TimeRangeProvider/index.d.ts +1 -1
  76. package/dist/runtime/TimeRangeProvider/index.d.ts.map +1 -1
  77. package/dist/runtime/TimeRangeProvider/index.js +1 -1
  78. package/dist/runtime/TimeRangeProvider/index.js.map +1 -1
  79. package/dist/runtime/log-queries.js +2 -1
  80. package/dist/runtime/log-queries.js.map +1 -1
  81. package/dist/runtime/profile-queries.d.ts.map +1 -1
  82. package/dist/runtime/profile-queries.js.map +1 -1
  83. package/dist/runtime/time-series-queries.d.ts.map +1 -1
  84. package/dist/runtime/time-series-queries.js +10 -16
  85. package/dist/runtime/time-series-queries.js.map +1 -1
  86. package/dist/runtime/trace-queries.d.ts +1 -5
  87. package/dist/runtime/trace-queries.d.ts.map +1 -1
  88. package/dist/runtime/trace-queries.js +3 -10
  89. package/dist/runtime/trace-queries.js.map +1 -1
  90. package/dist/test/utils.js +5 -5
  91. package/dist/test/utils.js.map +1 -1
  92. package/dist/utils/event.d.ts +8 -0
  93. package/dist/utils/event.d.ts.map +1 -0
  94. package/dist/utils/event.js +27 -0
  95. package/dist/utils/event.js.map +1 -0
  96. package/dist/utils/index.d.ts +1 -0
  97. package/dist/utils/index.d.ts.map +1 -1
  98. package/dist/utils/index.js +1 -0
  99. package/dist/utils/index.js.map +1 -1
  100. package/package.json +3 -3
  101. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.d.ts +0 -9
  102. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.d.ts.map +0 -1
  103. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.js.map +0 -1
@@ -48,8 +48,9 @@ function useLogQueries(definitions) {
48
48
  return (0, _reactquery.useQueries)({
49
49
  queries: definitions.map((definition)=>{
50
50
  const queryKey = [
51
+ 'query',
52
+ LOG_QUERY_KEY,
51
53
  definition,
52
- datasourceStore,
53
54
  absoluteTimeRange,
54
55
  variableValues
55
56
  ];
@@ -45,20 +45,20 @@ const _utils = require("./utils");
45
45
  const _variables = require("./variables");
46
46
  const TIME_SERIES_QUERY_KEY = 'TimeSeriesQuery';
47
47
  function getQueryOptions({ plugin, definition, context }) {
48
- const { timeRange, datasourceStore, suggestedStepMs, mode, variableState, refreshKey } = context;
48
+ const { timeRange, suggestedStepMs, mode, variableState } = context;
49
49
  const dependencies = plugin?.dependsOn ? plugin.dependsOn(definition.spec.plugin.spec, context) : {};
50
50
  const variableDependencies = dependencies?.variables;
51
51
  // Determine queryKey
52
52
  const filteredVariabledState = (0, _utils.filterVariableStateMap)(variableState, variableDependencies);
53
53
  const variablesValueKey = (0, _utils.getVariableValuesKey)(filteredVariabledState);
54
54
  const queryKey = [
55
+ 'query',
56
+ TIME_SERIES_QUERY_KEY,
55
57
  definition,
56
58
  timeRange,
57
- datasourceStore,
58
- suggestedStepMs,
59
- mode,
60
59
  variablesValueKey,
61
- refreshKey
60
+ suggestedStepMs,
61
+ mode
62
62
  ];
63
63
  // Determine queryEnabled
64
64
  let waitToLoad = false;
@@ -100,8 +100,8 @@ function useTimeSeriesQueries(definitions, options, queryOptions) {
100
100
  const { getPlugin } = (0, _pluginregistry.usePluginRegistry)();
101
101
  const context = {
102
102
  ...useTimeSeriesQueryContext(),
103
- // We need mode to be part query key because this drives the type of query done (instant VS range query)
104
- mode: options?.mode
103
+ mode: options?.mode,
104
+ suggestedStepMs: options?.suggestedStepMs
105
105
  };
106
106
  const pluginLoaderResponse = (0, _pluginregistry.usePlugins)(TIME_SERIES_QUERY_KEY, definitions.map((d)=>({
107
107
  kind: d.spec.plugin.kind
@@ -119,13 +119,8 @@ function useTimeSeriesQueries(definitions, options, queryOptions) {
119
119
  enabled: (queryOptions?.enabled ?? true) && queryEnabled,
120
120
  queryKey: queryKey,
121
121
  queryFn: async ({ signal })=>{
122
- const ctx = {
123
- ...context,
124
- // Keep suggested step changes out of the query key, so we don´t have to run again query when it changes
125
- suggestedStepMs: options?.suggestedStepMs
126
- };
127
122
  const plugin = await getPlugin(TIME_SERIES_QUERY_KEY, definition.spec.plugin.kind);
128
- const data = await plugin.getTimeSeriesData(definition.spec.plugin.spec, ctx, signal);
123
+ const data = await plugin.getTimeSeriesData(definition.spec.plugin.spec, context, signal);
129
124
  return data;
130
125
  }
131
126
  };
@@ -135,14 +130,13 @@ function useTimeSeriesQueries(definitions, options, queryOptions) {
135
130
  /**
136
131
  * Build the time series query context object from data available at runtime
137
132
  */ function useTimeSeriesQueryContext() {
138
- const { absoluteTimeRange, refreshKey } = (0, _TimeRangeProvider.useTimeRange)();
133
+ const { absoluteTimeRange } = (0, _TimeRangeProvider.useTimeRange)();
139
134
  const variableState = (0, _variables.useAllVariableValues)();
140
135
  const datasourceStore = (0, _datasources.useDatasourceStore)();
141
136
  return {
142
137
  timeRange: absoluteTimeRange,
143
138
  variableState,
144
- datasourceStore,
145
- refreshKey
139
+ datasourceStore
146
140
  };
147
141
  }
148
142
  function useActiveTimeSeriesQueries() {
@@ -24,14 +24,10 @@ _export(exports, {
24
24
  TRACE_QUERY_KEY: function() {
25
25
  return TRACE_QUERY_KEY;
26
26
  },
27
- getUnixTimeRange: function() {
28
- return getUnixTimeRange;
29
- },
30
27
  useTraceQueries: function() {
31
28
  return useTraceQueries;
32
29
  }
33
30
  });
34
- const _datefns = require("date-fns");
35
31
  const _reactquery = require("@tanstack/react-query");
36
32
  const _datasources = require("./datasources");
37
33
  const _pluginregistry = require("./plugin-registry");
@@ -39,13 +35,6 @@ const _TimeRangeProvider = require("./TimeRangeProvider");
39
35
  const _variables = require("./variables");
40
36
  const _utils = require("./utils");
41
37
  const TRACE_QUERY_KEY = 'TraceQuery';
42
- function getUnixTimeRange(timeRange) {
43
- const { start, end } = timeRange;
44
- return {
45
- start: Math.ceil((0, _datefns.getUnixTime)(start)),
46
- end: Math.ceil((0, _datefns.getUnixTime)(end))
47
- };
48
- }
49
38
  function useTraceQueries(definitions) {
50
39
  const { getPlugin } = (0, _pluginregistry.usePluginRegistry)();
51
40
  const context = useTraceQueryContext();
@@ -76,14 +65,15 @@ function useTraceQueries(definitions) {
76
65
  });
77
66
  }
78
67
  function getQueryOptions({ plugin, definition, context }) {
79
- const { datasourceStore, variableState, absoluteTimeRange } = context;
68
+ const { variableState, absoluteTimeRange } = context;
80
69
  const dependencies = plugin?.dependsOn ? plugin.dependsOn(definition.spec.plugin.spec, context) : {};
81
70
  const variableDependencies = dependencies?.variables;
82
71
  const filteredVariabledState = (0, _utils.filterVariableStateMap)(variableState, variableDependencies);
83
72
  const variablesValueKey = (0, _utils.getVariableValuesKey)(filteredVariabledState);
84
73
  const queryKey = [
74
+ 'query',
75
+ TRACE_QUERY_KEY,
85
76
  definition,
86
- datasourceStore,
87
77
  absoluteTimeRange,
88
78
  variablesValueKey
89
79
  ];
@@ -41,10 +41,10 @@ function getTestContextWrapper(contextOptions) {
41
41
  end: new Date()
42
42
  };
43
43
  return function Wrapper({ children }) {
44
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(_runtime.TimeRangeProvider, {
45
- timeRange: timeRange,
46
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactquery.QueryClientProvider, {
47
- client: queryClient,
44
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactquery.QueryClientProvider, {
45
+ client: queryClient,
46
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_runtime.TimeRangeProviderBasic, {
47
+ initialTimeRange: timeRange,
48
48
  children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.PluginRegistry, {
49
49
  pluginLoader: _testplugins.testPluginLoader,
50
50
  defaultPluginKinds: contextOptions?.defaultPluginKinds ?? {
@@ -0,0 +1,30 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "useEvent", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return useEvent;
21
+ }
22
+ });
23
+ const _react = require("react");
24
+ function useEvent(handler) {
25
+ const handlerRef = (0, _react.useRef)(handler);
26
+ (0, _react.useLayoutEffect)(()=>{
27
+ handlerRef.current = handler;
28
+ });
29
+ return (0, _react.useCallback)((...args)=>handlerRef.current(...args), []);
30
+ }
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
17
  _export_star(require("./action"), exports);
18
+ _export_star(require("./event"), exports);
18
19
  _export_star(require("./variables"), exports);
19
20
  function _export_star(from, to) {
20
21
  Object.keys(from).forEach(function(k) {
@@ -1,9 +1,12 @@
1
1
  /// <reference types="react" />
2
2
  import { QueryDefinition, QueryPluginType } from '@perses-dev/core';
3
+ import { QueryData } from '../../runtime';
3
4
  import { PluginEditorRef } from '../PluginEditor';
4
5
  export interface MultiQueryEditorProps {
5
6
  queryTypes: QueryPluginType[];
7
+ filteredQueryPlugins?: string[];
6
8
  queries?: QueryDefinition[];
9
+ queryResults?: QueryData[];
7
10
  onChange: (queries: QueryDefinition[]) => void;
8
11
  }
9
12
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"MultiQueryEditor.d.ts","sourceRoot":"","sources":["../../../src/components/MultiQueryEditor/MultiQueryEditor.tsx"],"names":[],"mappings":";AAiBA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEpE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGlD,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,eAAe,EAAE,CAAC;IAC9B,OAAO,CAAC,EAAE,eAAe,EAAE,CAAC;IAC5B,QAAQ,EAAE,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,IAAI,CAAC;CAChD;AAmCD;;;;;;;GAOG;AAEH,eAAO,MAAM,gBAAgB,mHAmF3B,CAAC"}
1
+ {"version":3,"file":"MultiQueryEditor.d.ts","sourceRoot":"","sources":["../../../src/components/MultiQueryEditor/MultiQueryEditor.tsx"],"names":[],"mappings":";AAiBA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,SAAS,EAAuD,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGlD,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,eAAe,EAAE,CAAC;IAC9B,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,OAAO,CAAC,EAAE,eAAe,EAAE,CAAC;IAC5B,YAAY,CAAC,EAAE,SAAS,EAAE,CAAC;IAC3B,QAAQ,EAAE,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,IAAI,CAAC;CAChD;AA4CD;;;;;;;GAOG;AAEH,eAAO,MAAM,gBAAgB,mHAqF3B,CAAC"}
@@ -17,7 +17,7 @@ import { Button, Stack } from '@mui/material';
17
17
  import AddIcon from 'mdi-material-ui/Plus';
18
18
  import { useListPluginMetadata, usePlugin, usePluginRegistry } from '../../runtime';
19
19
  import { QueryEditorContainer } from './QueryEditorContainer';
20
- function useDefaultQueryDefinition(queryTypes) {
20
+ function useDefaultQueryDefinition(queryTypes, filteredQueryPlugins) {
21
21
  // Build the default query plugin
22
22
  // This will be used only if the queries are empty, to open a starting query
23
23
  // Firs the default query type
@@ -26,7 +26,12 @@ function useDefaultQueryDefinition(queryTypes) {
26
26
  // Use as default the plugin kind explicitly set as default or the first in the list
27
27
  const { data: queryPlugins, isLoading } = useListPluginMetadata(queryTypes);
28
28
  const { defaultPluginKinds } = usePluginRegistry();
29
- const defaultQueryKind = defaultPluginKinds?.[defaultQueryType] ?? queryPlugins?.[0]?.spec.name ?? '';
29
+ let defaultQueryKind = '';
30
+ if (filteredQueryPlugins?.length) {
31
+ defaultQueryKind = queryPlugins?.find((i)=>filteredQueryPlugins.includes(i.spec.name)).spec.name ?? '';
32
+ } else {
33
+ defaultQueryKind = defaultPluginKinds?.[defaultQueryType] ?? queryPlugins?.[0]?.spec.name ?? '';
34
+ }
30
35
  const { data: defaultQueryPlugin } = usePlugin(defaultQueryType, defaultQueryKind, {
31
36
  useErrorBoundary: true,
32
37
  enabled: true
@@ -53,8 +58,8 @@ function useDefaultQueryDefinition(queryTypes) {
53
58
  * @param onChange The callback to call when the queries are modified
54
59
  * @constructor
55
60
  */ export const MultiQueryEditor = /*#__PURE__*/ forwardRef((props, ref)=>{
56
- const { queryTypes, queries = [], onChange } = props;
57
- const { defaultInitialQueryDefinition, isLoading } = useDefaultQueryDefinition(queryTypes);
61
+ const { queryTypes, queries = [], queryResults, filteredQueryPlugins, onChange } = props;
62
+ const { defaultInitialQueryDefinition, isLoading } = useDefaultQueryDefinition(queryTypes, filteredQueryPlugins);
58
63
  // State for which queries are collapsed
59
64
  const [queriesCollapsed, setQueriesCollapsed] = useState(queries.map(()=>false));
60
65
  // Query handlers
@@ -119,6 +124,8 @@ function useDefaultQueryDefinition(queryTypes) {
119
124
  queryTypes: queryTypes,
120
125
  index: i,
121
126
  query: query,
127
+ queryResult: queryResults?.[i],
128
+ filteredQueryPlugins: filteredQueryPlugins,
122
129
  isCollapsed: !!queriesCollapsed[i],
123
130
  onChange: handleQueryChange,
124
131
  onDelete: queries.length > 1 ? handleQueryDelete : undefined,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/MultiQueryEditor/MultiQueryEditor.tsx"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { forwardRef, ReactElement, useState } from 'react';\nimport { produce } from 'immer';\nimport { Button, Stack } from '@mui/material';\nimport AddIcon from 'mdi-material-ui/Plus';\nimport { QueryDefinition, QueryPluginType } from '@perses-dev/core';\nimport { useListPluginMetadata, usePlugin, usePluginRegistry } from '../../runtime';\nimport { PluginEditorRef } from '../PluginEditor';\nimport { QueryEditorContainer } from './QueryEditorContainer';\n\nexport interface MultiQueryEditorProps {\n queryTypes: QueryPluginType[];\n queries?: QueryDefinition[];\n onChange: (queries: QueryDefinition[]) => void;\n}\n\nfunction useDefaultQueryDefinition(queryTypes: QueryPluginType[]): {\n defaultInitialQueryDefinition: QueryDefinition;\n isLoading: boolean;\n} {\n // Build the default query plugin\n // This will be used only if the queries are empty, to open a starting query\n\n // Firs the default query type\n const defaultQueryType = queryTypes[0]!;\n\n // Then the default plugin kind\n // Use as default the plugin kind explicitly set as default or the first in the list\n const { data: queryPlugins, isLoading } = useListPluginMetadata(queryTypes);\n const { defaultPluginKinds } = usePluginRegistry();\n const defaultQueryKind = defaultPluginKinds?.[defaultQueryType] ?? queryPlugins?.[0]?.spec.name ?? '';\n\n const { data: defaultQueryPlugin } = usePlugin(defaultQueryType, defaultQueryKind, {\n useErrorBoundary: true,\n enabled: true,\n });\n\n // This default query definition is used if no query is provided initially or when we add a new query\n return {\n defaultInitialQueryDefinition: {\n kind: defaultQueryType,\n spec: {\n plugin: { kind: defaultQueryKind, spec: defaultQueryPlugin?.createInitialOptions() || {} },\n },\n },\n isLoading,\n };\n}\n\n/**\n * A component render a list of {@link QueryEditorContainer} for the given query definitions.\n * It allows adding, removing and editing queries.\n * @param queryTypes The list of query types that the underlying editor will propose\n * @param queries The list of query definitions to render\n * @param onChange The callback to call when the queries are modified\n * @constructor\n */\n\nexport const MultiQueryEditor = forwardRef<PluginEditorRef, MultiQueryEditorProps>((props, ref): ReactElement => {\n const { queryTypes, queries = [], onChange } = props;\n const { defaultInitialQueryDefinition, isLoading } = useDefaultQueryDefinition(queryTypes);\n // State for which queries are collapsed\n const [queriesCollapsed, setQueriesCollapsed] = useState(queries.map(() => false));\n\n // Query handlers\n const handleQueryChange = (index: number, queryDef: QueryDefinition): void => {\n onChange(\n produce(queries, (draft) => {\n if (draft) {\n draft[index] = queryDef;\n } else {\n draft = [queryDef];\n }\n })\n );\n };\n\n const handleQueryAdd = (): void => {\n onChange(\n produce(queries, (draft) => {\n if (draft) {\n draft.push(defaultInitialQueryDefinition);\n } else {\n draft = [...queries, defaultInitialQueryDefinition];\n }\n })\n );\n setQueriesCollapsed((queriesCollapsed) => {\n queriesCollapsed.push(false);\n return [...queriesCollapsed];\n });\n };\n\n const handleQueryDelete = (index: number): void => {\n onChange(\n produce(queries, (draft) => {\n draft.splice(index, 1);\n })\n );\n setQueriesCollapsed((queriesCollapsed) => {\n queriesCollapsed.splice(index, 1);\n return [...queriesCollapsed];\n });\n };\n\n const handleQueryCollapseExpand = (index: number): void => {\n setQueriesCollapsed((queriesCollapsed) => {\n queriesCollapsed[index] = !queriesCollapsed[index];\n return [...queriesCollapsed];\n });\n };\n\n // show one query input if queries is empty\n const queryDefinitions: QueryDefinition[] = queries.length\n ? queries\n : !isLoading\n ? [defaultInitialQueryDefinition]\n : [];\n\n return (\n <>\n <Stack spacing={1}>\n {queryDefinitions.map((query: QueryDefinition, i: number) => (\n <QueryEditorContainer\n ref={ref}\n queryTypes={queryTypes}\n key={i}\n index={i}\n query={query}\n isCollapsed={!!queriesCollapsed[i]}\n onChange={handleQueryChange}\n onDelete={queries.length > 1 ? handleQueryDelete : undefined}\n onCollapseExpand={handleQueryCollapseExpand}\n />\n ))}\n </Stack>\n <Button variant=\"contained\" startIcon={<AddIcon />} sx={{ marginTop: 1 }} onClick={handleQueryAdd}>\n Add Query\n </Button>\n </>\n );\n});\n\nMultiQueryEditor.displayName = 'MultiQueryEditor';\n"],"names":["forwardRef","useState","produce","Button","Stack","AddIcon","useListPluginMetadata","usePlugin","usePluginRegistry","QueryEditorContainer","useDefaultQueryDefinition","queryTypes","defaultQueryType","data","queryPlugins","isLoading","defaultPluginKinds","defaultQueryKind","spec","name","defaultQueryPlugin","useErrorBoundary","enabled","defaultInitialQueryDefinition","kind","plugin","createInitialOptions","MultiQueryEditor","props","ref","queries","onChange","queriesCollapsed","setQueriesCollapsed","map","handleQueryChange","index","queryDef","draft","handleQueryAdd","push","handleQueryDelete","splice","handleQueryCollapseExpand","queryDefinitions","length","spacing","query","i","isCollapsed","onDelete","undefined","onCollapseExpand","variant","startIcon","sx","marginTop","onClick","displayName"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,UAAU,EAAgBC,QAAQ,QAAQ,QAAQ;AAC3D,SAASC,OAAO,QAAQ,QAAQ;AAChC,SAASC,MAAM,EAAEC,KAAK,QAAQ,gBAAgB;AAC9C,OAAOC,aAAa,uBAAuB;AAE3C,SAASC,qBAAqB,EAAEC,SAAS,EAAEC,iBAAiB,QAAQ,gBAAgB;AAEpF,SAASC,oBAAoB,QAAQ,yBAAyB;AAQ9D,SAASC,0BAA0BC,UAA6B;IAI9D,iCAAiC;IACjC,4EAA4E;IAE5E,8BAA8B;IAC9B,MAAMC,mBAAmBD,UAAU,CAAC,EAAE;IAEtC,+BAA+B;IAC/B,oFAAoF;IACpF,MAAM,EAAEE,MAAMC,YAAY,EAAEC,SAAS,EAAE,GAAGT,sBAAsBK;IAChE,MAAM,EAAEK,kBAAkB,EAAE,GAAGR;IAC/B,MAAMS,mBAAmBD,oBAAoB,CAACJ,iBAAiB,IAAIE,cAAc,CAAC,EAAE,EAAEI,KAAKC,QAAQ;IAEnG,MAAM,EAAEN,MAAMO,kBAAkB,EAAE,GAAGb,UAAUK,kBAAkBK,kBAAkB;QACjFI,kBAAkB;QAClBC,SAAS;IACX;IAEA,qGAAqG;IACrG,OAAO;QACLC,+BAA+B;YAC7BC,MAAMZ;YACNM,MAAM;gBACJO,QAAQ;oBAAED,MAAMP;oBAAkBC,MAAME,oBAAoBM,0BAA0B,CAAC;gBAAE;YAC3F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E;IAER,qBACE;;0BACE,KAACnB;gBAAM0C,SAAS;0BACbF,iBAAiBV,GAAG,CAAC,CAACa,OAAwBC,kBAC7C,KAACvC;wBACCoB,KAAKA;wBACLlB,YAAYA;wBAEZyB,OAAOY;wBACPD,OAAOA;wBACPE,aAAa,CAAC,CAACjB,gBAAgB,CAACgB,EAAE;wBAClCjB,UAAUI;wBACVe,UAAUpB,QAAQe,MAAM,GAAG,IAAIJ,oBAAoBU;wBACnDC,kBAAkBT;uBANbK;;0BAUX,KAAC7C;gBAAOkD,SAAQ;gBAAYC,yBAAW,KAACjD;gBAAYkD,IAAI;oBAAEC,WAAW;gBAAE;gBAAGC,SAASlB;0BAAgB;;;;AAKzG,GAAG;AAEHZ,iBAAiB+B,WAAW,GAAG"}
1
+ {"version":3,"sources":["../../../src/components/MultiQueryEditor/MultiQueryEditor.tsx"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { forwardRef, ReactElement, useState } from 'react';\nimport { produce } from 'immer';\nimport { Button, Stack } from '@mui/material';\nimport AddIcon from 'mdi-material-ui/Plus';\nimport { QueryDefinition, QueryPluginType } from '@perses-dev/core';\nimport { QueryData, useListPluginMetadata, usePlugin, usePluginRegistry } from '../../runtime';\nimport { PluginEditorRef } from '../PluginEditor';\nimport { QueryEditorContainer } from './QueryEditorContainer';\n\nexport interface MultiQueryEditorProps {\n queryTypes: QueryPluginType[];\n filteredQueryPlugins?: string[];\n queries?: QueryDefinition[];\n queryResults?: QueryData[];\n onChange: (queries: QueryDefinition[]) => void;\n}\n\nfunction useDefaultQueryDefinition(\n queryTypes: QueryPluginType[],\n filteredQueryPlugins?: string[]\n): {\n defaultInitialQueryDefinition: QueryDefinition;\n isLoading: boolean;\n} {\n // Build the default query plugin\n // This will be used only if the queries are empty, to open a starting query\n\n // Firs the default query type\n const defaultQueryType = queryTypes[0]!;\n // Then the default plugin kind\n // Use as default the plugin kind explicitly set as default or the first in the list\n const { data: queryPlugins, isLoading } = useListPluginMetadata(queryTypes);\n const { defaultPluginKinds } = usePluginRegistry();\n\n let defaultQueryKind: string = '';\n\n if (filteredQueryPlugins?.length) {\n defaultQueryKind = queryPlugins?.find((i) => filteredQueryPlugins.includes(i.spec.name))!.spec.name ?? '';\n } else {\n defaultQueryKind = defaultPluginKinds?.[defaultQueryType] ?? queryPlugins?.[0]?.spec.name ?? '';\n }\n\n const { data: defaultQueryPlugin } = usePlugin(defaultQueryType, defaultQueryKind, {\n useErrorBoundary: true,\n enabled: true,\n });\n\n // This default query definition is used if no query is provided initially or when we add a new query\n return {\n defaultInitialQueryDefinition: {\n kind: defaultQueryType,\n spec: {\n plugin: { kind: defaultQueryKind, spec: defaultQueryPlugin?.createInitialOptions() || {} },\n },\n },\n isLoading,\n };\n}\n\n/**\n * A component render a list of {@link QueryEditorContainer} for the given query definitions.\n * It allows adding, removing and editing queries.\n * @param queryTypes The list of query types that the underlying editor will propose\n * @param queries The list of query definitions to render\n * @param onChange The callback to call when the queries are modified\n * @constructor\n */\n\nexport const MultiQueryEditor = forwardRef<PluginEditorRef, MultiQueryEditorProps>((props, ref): ReactElement => {\n const { queryTypes, queries = [], queryResults, filteredQueryPlugins, onChange } = props;\n const { defaultInitialQueryDefinition, isLoading } = useDefaultQueryDefinition(queryTypes, filteredQueryPlugins);\n // State for which queries are collapsed\n const [queriesCollapsed, setQueriesCollapsed] = useState(queries.map(() => false));\n\n // Query handlers\n const handleQueryChange = (index: number, queryDef: QueryDefinition): void => {\n onChange(\n produce(queries, (draft) => {\n if (draft) {\n draft[index] = queryDef;\n } else {\n draft = [queryDef];\n }\n })\n );\n };\n\n const handleQueryAdd = (): void => {\n onChange(\n produce(queries, (draft) => {\n if (draft) {\n draft.push(defaultInitialQueryDefinition);\n } else {\n draft = [...queries, defaultInitialQueryDefinition];\n }\n })\n );\n setQueriesCollapsed((queriesCollapsed) => {\n queriesCollapsed.push(false);\n return [...queriesCollapsed];\n });\n };\n\n const handleQueryDelete = (index: number): void => {\n onChange(\n produce(queries, (draft) => {\n draft.splice(index, 1);\n })\n );\n setQueriesCollapsed((queriesCollapsed) => {\n queriesCollapsed.splice(index, 1);\n return [...queriesCollapsed];\n });\n };\n\n const handleQueryCollapseExpand = (index: number): void => {\n setQueriesCollapsed((queriesCollapsed) => {\n queriesCollapsed[index] = !queriesCollapsed[index];\n return [...queriesCollapsed];\n });\n };\n\n // show one query input if queries is empty\n const queryDefinitions: QueryDefinition[] = queries.length\n ? queries\n : !isLoading\n ? [defaultInitialQueryDefinition]\n : [];\n\n return (\n <>\n <Stack spacing={1}>\n {queryDefinitions.map((query: QueryDefinition, i: number) => (\n <QueryEditorContainer\n ref={ref}\n queryTypes={queryTypes}\n key={i}\n index={i}\n query={query}\n queryResult={queryResults?.[i]}\n filteredQueryPlugins={filteredQueryPlugins}\n isCollapsed={!!queriesCollapsed[i]}\n onChange={handleQueryChange}\n onDelete={queries.length > 1 ? handleQueryDelete : undefined}\n onCollapseExpand={handleQueryCollapseExpand}\n />\n ))}\n </Stack>\n <Button variant=\"contained\" startIcon={<AddIcon />} sx={{ marginTop: 1 }} onClick={handleQueryAdd}>\n Add Query\n </Button>\n </>\n );\n});\n\nMultiQueryEditor.displayName = 'MultiQueryEditor';\n"],"names":["forwardRef","useState","produce","Button","Stack","AddIcon","useListPluginMetadata","usePlugin","usePluginRegistry","QueryEditorContainer","useDefaultQueryDefinition","queryTypes","filteredQueryPlugins","defaultQueryType","data","queryPlugins","isLoading","defaultPluginKinds","defaultQueryKind","length","find","i","includes","spec","name","defaultQueryPlugin","useErrorBoundary","enabled","defaultInitialQueryDefinition","kind","plugin","createInitialOptions","MultiQueryEditor","props","ref","queries","queryResults","onChange","queriesCollapsed","setQueriesCollapsed","map","handleQueryChange","index","queryDef","draft","handleQueryAdd","push","handleQueryDelete","splice","handleQueryCollapseExpand","queryDefinitions","spacing","query","queryResult","isCollapsed","onDelete","undefined","onCollapseExpand","variant","startIcon","sx","marginTop","onClick","displayName"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,UAAU,EAAgBC,QAAQ,QAAQ,QAAQ;AAC3D,SAASC,OAAO,QAAQ,QAAQ;AAChC,SAASC,MAAM,EAAEC,KAAK,QAAQ,gBAAgB;AAC9C,OAAOC,aAAa,uBAAuB;AAE3C,SAAoBC,qBAAqB,EAAEC,SAAS,EAAEC,iBAAiB,QAAQ,gBAAgB;AAE/F,SAASC,oBAAoB,QAAQ,yBAAyB;AAU9D,SAASC,0BACPC,UAA6B,EAC7BC,oBAA+B;IAK/B,iCAAiC;IACjC,4EAA4E;IAE5E,8BAA8B;IAC9B,MAAMC,mBAAmBF,UAAU,CAAC,EAAE;IACtC,+BAA+B;IAC/B,oFAAoF;IACpF,MAAM,EAAEG,MAAMC,YAAY,EAAEC,SAAS,EAAE,GAAGV,sBAAsBK;IAChE,MAAM,EAAEM,kBAAkB,EAAE,GAAGT;IAE/B,IAAIU,mBAA2B;IAE/B,IAAIN,sBAAsBO,QAAQ;QAChCD,mBAAmBH,cAAcK,KAAK,CAACC,IAAMT,qBAAqBU,QAAQ,CAACD,EAAEE,IAAI,CAACC,IAAI,GAAID,KAAKC,QAAQ;IACzG,OAAO;QACLN,mBAAmBD,oBAAoB,CAACJ,iBAAiB,IAAIE,cAAc,CAAC,EAAE,EAAEQ,KAAKC,QAAQ;IAC/F;IAEA,MAAM,EAAEV,MAAMW,kB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iB;QAC9B;IACF;IAEA,MAAMW,4BAA4B,CAACP;QACjCH,oBAAoB,CAACD;YACnBA,gBAAgB,CAACI,MAAM,GAAG,CAACJ,gBAAgB,CAACI,MAAM;YAClD,OAAO;mBAAIJ;aAAiB;QAC9B;IACF;IAEA,2CAA2C;IAC3C,MAAMY,mBAAsCf,QAAQhB,MAAM,GACtDgB,UACA,CAACnB,YACC;QAACY;KAA8B,GAC/B,EAAE;IAER,qBACE;;0BACE,KAACxB;gBAAM+C,SAAS;0BACbD,iBAAiBV,GAAG,CAAC,CAACY,OAAwB/B,kBAC7C,KAACZ;wBACCyB,KAAKA;wBACLvB,YAAYA;wBAEZ+B,OAAOrB;wBACP+B,OAAOA;wBACPC,aAAajB,cAAc,CAACf,EAAE;wBAC9BT,sBAAsBA;wBACtB0C,aAAa,CAAC,CAAChB,gBAAgB,CAACjB,EAAE;wBAClCgB,UAAUI;wBACVc,UAAUpB,QAAQhB,MAAM,GAAG,IAAI4B,oBAAoBS;wBACnDC,kBAAkBR;uBARb5B;;0BAYX,KAAClB;gBAAOuD,SAAQ;gBAAYC,yBAAW,KAACtD;gBAAYuD,IAAI;oBAAEC,WAAW;gBAAE;gBAAGC,SAASjB;0BAAgB;;;;AAKzG,GAAG;AAEHb,iBAAiB+B,WAAW,GAAG"}
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { QueryDefinition, QueryPluginType } from '@perses-dev/core';
3
+ import { QueryData } from '../../runtime';
3
4
  import { PluginEditorRef } from '../PluginEditor';
4
5
  /**
5
6
  * Properties for {@link QueryEditorContainer}
@@ -8,6 +9,8 @@ interface QueryEditorContainerProps {
8
9
  queryTypes: QueryPluginType[];
9
10
  index: number;
10
11
  query: QueryDefinition;
12
+ queryResult?: QueryData;
13
+ filteredQueryPlugins?: string[];
11
14
  onChange: (index: number, query: QueryDefinition) => void;
12
15
  onCollapseExpand: (index: number) => void;
13
16
  isCollapsed?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"QueryEditorContainer.d.ts","sourceRoot":"","sources":["../../../src/components/MultiQueryEditor/QueryEditorContainer.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAMpE,OAAO,EAAmC,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGnF;;GAEG;AACH,UAAU,yBAAyB;IACjC,UAAU,EAAE,eAAe,EAAE,CAAC;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,eAAe,CAAC;IACvB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;IAC1D,gBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC;AAED;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,oBAAoB,uHA2BhC,CAAC"}
1
+ {"version":3,"file":"QueryEditorContainer.d.ts","sourceRoot":"","sources":["../../../src/components/MultiQueryEditor/QueryEditorContainer.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAQpE,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAmC,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEnF;;GAEG;AACH,UAAU,yBAAyB;IACjC,UAAU,EAAE,eAAe,EAAE,CAAC;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,eAAe,CAAC;IACvB,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;IAC1D,gBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC;AAED;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,oBAAoB,uHAoFhC,CAAC"}
@@ -12,13 +12,14 @@
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  import { produce } from 'immer';
15
- import { Stack, IconButton, Typography, Box } from '@mui/material';
15
+ import { Stack, IconButton, Typography, Box, CircularProgress } from '@mui/material';
16
16
  import DeleteIcon from 'mdi-material-ui/DeleteOutline';
17
17
  import ChevronDown from 'mdi-material-ui/ChevronDown';
18
18
  import ChevronRight from 'mdi-material-ui/ChevronRight';
19
19
  import { forwardRef } from 'react';
20
+ import AlertIcon from 'mdi-material-ui/Alert';
21
+ import { InfoTooltip } from '@perses-dev/components';
20
22
  import { PluginEditor } from '../PluginEditor';
21
- import { useTimeRange } from '../../runtime';
22
23
  /**
23
24
  * Container for a query editor. This component is responsible for rendering the query editor, and make it collapsible
24
25
  * to not take too much space.
@@ -31,38 +32,82 @@ import { useTimeRange } from '../../runtime';
31
32
  * @param onCollapseExpand callback when the query is collapsed or expanded
32
33
  * @constructor
33
34
  */ export const QueryEditorContainer = /*#__PURE__*/ forwardRef((props, ref)=>{
34
- const { queryTypes, index, query, isCollapsed, onDelete, onChange, onCollapseExpand } = props;
35
+ const { queryTypes, index, query, queryResult, filteredQueryPlugins, isCollapsed, onDelete, onChange, onCollapseExpand } = props;
35
36
  return /*#__PURE__*/ _jsxs(Stack, {
36
37
  spacing: 1,
37
38
  children: [
38
39
  /*#__PURE__*/ _jsxs(Stack, {
39
40
  direction: "row",
40
41
  alignItems: "center",
42
+ justifyContent: "space-between",
41
43
  borderBottom: 1,
42
44
  borderColor: (theme)=>theme.palette.divider,
43
45
  children: [
44
- /*#__PURE__*/ _jsx(IconButton, {
45
- size: "small",
46
- onClick: ()=>onCollapseExpand(index),
47
- children: isCollapsed ? /*#__PURE__*/ _jsx(ChevronRight, {}) : /*#__PURE__*/ _jsx(ChevronDown, {})
48
- }),
49
- /*#__PURE__*/ _jsxs(Typography, {
50
- variant: "overline",
51
- component: "h4",
46
+ /*#__PURE__*/ _jsxs(Stack, {
47
+ direction: "row",
52
48
  children: [
53
- "Query #",
54
- index + 1
49
+ /*#__PURE__*/ _jsx(IconButton, {
50
+ size: "small",
51
+ onClick: ()=>onCollapseExpand(index),
52
+ children: isCollapsed ? /*#__PURE__*/ _jsx(ChevronRight, {}) : /*#__PURE__*/ _jsx(ChevronDown, {})
53
+ }),
54
+ /*#__PURE__*/ _jsxs(Typography, {
55
+ variant: "overline",
56
+ component: "h4",
57
+ children: [
58
+ "Query #",
59
+ index + 1
60
+ ]
61
+ })
55
62
  ]
56
63
  }),
57
- /*#__PURE__*/ _jsx(IconButton, {
58
- size: "small",
59
- // Use `visibility` to ensure that the row has the same height when delete button is visible or not visible
60
- sx: {
61
- marginLeft: 'auto',
62
- visibility: `${onDelete ? 'visible' : 'hidden'}`
63
- },
64
- onClick: ()=>onDelete && onDelete(index),
65
- children: /*#__PURE__*/ _jsx(DeleteIcon, {})
64
+ /*#__PURE__*/ _jsxs(Stack, {
65
+ direction: "row",
66
+ alignItems: "center",
67
+ children: [
68
+ queryResult?.isFetching && /*#__PURE__*/ _jsx(CircularProgress, {
69
+ "aria-label": "loading",
70
+ size: "1.125rem"
71
+ }),
72
+ queryResult?.error && /*#__PURE__*/ _jsx(InfoTooltip, {
73
+ description: queryResult.error.message,
74
+ children: /*#__PURE__*/ _jsxs(Stack, {
75
+ direction: "row",
76
+ alignItems: "center",
77
+ sx: {
78
+ color: (theme)=>theme.palette.error.main
79
+ },
80
+ children: [
81
+ /*#__PURE__*/ _jsx(IconButton, {
82
+ "aria-label": "query error",
83
+ size: "small",
84
+ sx: {
85
+ color: (theme)=>theme.palette.error.main
86
+ },
87
+ children: /*#__PURE__*/ _jsx(AlertIcon, {})
88
+ }),
89
+ /*#__PURE__*/ _jsx(Typography, {
90
+ sx: {
91
+ maxWidth: 300,
92
+ whiteSpace: 'nowrap',
93
+ overflow: 'hidden',
94
+ textOverflow: 'ellipsis',
95
+ '&:hover ::after': {
96
+ content: '"Click to copy"'
97
+ }
98
+ },
99
+ children: queryResult.error.message
100
+ })
101
+ ]
102
+ })
103
+ }),
104
+ onDelete && /*#__PURE__*/ _jsx(IconButton, {
105
+ "aria-label": "delete query",
106
+ size: "small",
107
+ onClick: ()=>onDelete && onDelete(index),
108
+ children: /*#__PURE__*/ _jsx(DeleteIcon, {})
109
+ })
110
+ ]
66
111
  })
67
112
  ]
68
113
  }),
@@ -70,6 +115,8 @@ import { useTimeRange } from '../../runtime';
70
115
  ref: ref,
71
116
  queryTypes: queryTypes,
72
117
  value: query,
118
+ queryResult: queryResult,
119
+ filteredQueryPlugins: filteredQueryPlugins,
73
120
  onChange: (next)=>onChange(index, next)
74
121
  })
75
122
  ]
@@ -83,8 +130,7 @@ QueryEditorContainer.displayName = 'QueryEditorContainer';
83
130
  * @param props
84
131
  * @constructor
85
132
  */ const QueryEditor = /*#__PURE__*/ forwardRef((props, ref)=>{
86
- const { value, onChange, queryTypes, ...others } = props;
87
- const { refresh } = useTimeRange();
133
+ const { value, onChange, queryTypes, queryResult, filteredQueryPlugins, ...others } = props;
88
134
  const handlePluginChange = (next)=>{
89
135
  onChange(produce(value, (draft)=>{
90
136
  draft.kind = next.selection.type;
@@ -95,7 +141,6 @@ QueryEditorContainer.displayName = 'QueryEditorContainer';
95
141
  return /*#__PURE__*/ _jsx(Box, {
96
142
  ...others,
97
143
  children: /*#__PURE__*/ _jsx(PluginEditor, {
98
- postExecuteRunQuery: refresh,
99
144
  ref: ref,
100
145
  withRunQueryButton: true,
101
146
  pluginTypes: queryTypes,
@@ -107,6 +152,8 @@ QueryEditorContainer.displayName = 'QueryEditorContainer';
107
152
  },
108
153
  spec: value.spec.plugin.spec
109
154
  },
155
+ filteredQueryPlugins: filteredQueryPlugins,
156
+ onQueryRefresh: queryResult?.refetch,
110
157
  onChange: handlePluginChange
111
158
  })
112
159
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/MultiQueryEditor/QueryEditorContainer.tsx"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { produce } from 'immer';\nimport { QueryDefinition, QueryPluginType } from '@perses-dev/core';\nimport { Stack, IconButton, Typography, BoxProps, Box } from '@mui/material';\nimport DeleteIcon from 'mdi-material-ui/DeleteOutline';\nimport ChevronDown from 'mdi-material-ui/ChevronDown';\nimport ChevronRight from 'mdi-material-ui/ChevronRight';\nimport { forwardRef, ReactElement } from 'react';\nimport { PluginEditor, PluginEditorProps, PluginEditorRef } from '../PluginEditor';\nimport { useTimeRange } from '../../runtime';\n\n/**\n * Properties for {@link QueryEditorContainer}\n */\ninterface QueryEditorContainerProps {\n queryTypes: QueryPluginType[];\n index: number;\n query: QueryDefinition;\n onChange: (index: number, query: QueryDefinition) => void;\n onCollapseExpand: (index: number) => void;\n isCollapsed?: boolean;\n onDelete?: (index: number) => void;\n}\n\n/**\n * Container for a query editor. This component is responsible for rendering the query editor, and make it collapsible\n * to not take too much space.\n * @param queryTypes the supported query types\n * @param index the index of the query in the list\n * @param query the query definition\n * @param isCollapsed whether the query editor is collapsed or not\n * @param onDelete callback when the query is deleted\n * @param onChange callback when the query is changed\n * @param onCollapseExpand callback when the query is collapsed or expanded\n * @constructor\n */\n\nexport const QueryEditorContainer = forwardRef<PluginEditorRef, QueryEditorContainerProps>(\n (props, ref): ReactElement => {\n const { queryTypes, index, query, isCollapsed, onDelete, onChange, onCollapseExpand } = props;\n return (\n <Stack key={index} spacing={1}>\n <Stack direction=\"row\" alignItems=\"center\" borderBottom={1} borderColor={(theme) => theme.palette.divider}>\n <IconButton size=\"small\" onClick={() => onCollapseExpand(index)}>\n {isCollapsed ? <ChevronRight /> : <ChevronDown />}\n </IconButton>\n <Typography variant=\"overline\" component=\"h4\">\n Query #{index + 1}\n </Typography>\n <IconButton\n size=\"small\"\n // Use `visibility` to ensure that the row has the same height when delete button is visible or not visible\n sx={{ marginLeft: 'auto', visibility: `${onDelete ? 'visible' : 'hidden'}` }}\n onClick={() => onDelete && onDelete(index)}\n >\n <DeleteIcon />\n </IconButton>\n </Stack>\n {!isCollapsed && (\n <QueryEditor ref={ref} queryTypes={queryTypes} value={query} onChange={(next) => onChange(index, next)} />\n )}\n </Stack>\n );\n }\n);\n\nQueryEditorContainer.displayName = 'QueryEditorContainer';\n\n// Props on MUI Box that we don't want people to pass because we're either redefining them or providing them in\n// this component\ntype OmittedMuiProps = 'children' | 'value' | 'onChange';\ninterface QueryEditorProps extends Omit<BoxProps, OmittedMuiProps> {\n queryTypes: QueryPluginType[];\n value: QueryDefinition;\n onChange: (next: QueryDefinition) => void;\n}\n\n/**\n * Editor for a query definition. This component is responsible for rendering the plugin editor for the given query.\n * This will allow user to select a plugin extending from the given supported query types, and then edit the plugin\n * spec for this plugin.\n * @param props\n * @constructor\n */\n\nconst QueryEditor = forwardRef<PluginEditorRef, QueryEditorProps>((props, ref): ReactElement => {\n const { value, onChange, queryTypes, ...others } = props;\n const { refresh } = useTimeRange();\n const handlePluginChange: PluginEditorProps['onChange'] = (next) => {\n onChange(\n produce(value, (draft) => {\n draft.kind = next.selection.type;\n draft.spec.plugin.kind = next.selection.kind;\n draft.spec.plugin.spec = next.spec;\n })\n );\n };\n\n return (\n <Box {...others}>\n <PluginEditor\n postExecuteRunQuery={refresh}\n ref={ref}\n withRunQueryButton\n pluginTypes={queryTypes}\n pluginKindLabel=\"Query Type\"\n value={{\n selection: {\n kind: value.spec.plugin.kind,\n type: value.kind,\n },\n spec: value.spec.plugin.spec,\n }}\n onChange={handlePluginChange}\n />\n </Box>\n );\n});\n\nQueryEditor.displayName = 'QueryEditor';\n"],"names":["produce","Stack","IconButton","Typography","Box","DeleteIcon","ChevronDown","ChevronRight","forwardRef","PluginEditor","useTimeRange","QueryEditorContainer","props","ref","queryTypes","index","query","isCollapsed","onDelete","onChange","onCollapseExpand","spacing","direction","alignItems","borderBottom","borderColor","theme","palette","divider","size","onClick","variant","component","sx","marginLeft","visibility","QueryEditor","value","next","displayName","others","refresh","handlePluginChange","draft","kind","selection","type","spec","plugin","postExecuteRunQuery","withRunQueryButton","pluginTypes","pluginKindLabel"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,OAAO,QAAQ,QAAQ;AAEhC,SAASC,KAAK,EAAEC,UAAU,EAAEC,UAAU,EAAYC,GAAG,QAAQ,gBAAgB;AAC7E,OAAOC,gBAAgB,gCAAgC;AACvD,OAAOC,iBAAiB,8BAA8B;AACtD,OAAOC,kBAAkB,+BAA+B;AACxD,SAASC,UAAU,QAAsB,QAAQ;AACjD,SAASC,YAAY,QAA4C,kBAAkB;AACnF,SAASC,YAAY,QAAQ,gBAAgB;AAe7C;;;;;;;;;;;CAWC,GAED,OAAO,MAAMC,qCAAuBH,WAClC,CAACI,OAAOC;IACN,MAAM,EAAEC,UAAU,EAAEC,KAAK,EAAEC,KAAK,EAAEC,WAAW,EAAEC,QAAQ,EAAEC,QAAQ,EAAEC,gBAAgB,EAAE,GAAGR;IACxF,qBACE,MAACX;QAAkBoB,SAAS;;0BAC1B,MAACpB;gBAAMq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OAAO;gBACLQ,WAAW;oBACTD,MAAMP,MAAMU,IAAI,CAACC,MAAM,CAACJ,IAAI;oBAC5BE,MAAMT,MAAMO,IAAI;gBAClB;gBACAG,MAAMV,MAAMU,IAAI,CAACC,MAAM,CAACD,IAAI;YAC9B;YACA5B,UAAUuB;;;AAIlB;AAEAN,YAAYG,WAAW,GAAG"}
1
+ {"version":3,"sources":["../../../src/components/MultiQueryEditor/QueryEditorContainer.tsx"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { produce } from 'immer';\nimport { QueryDefinition, QueryPluginType } from '@perses-dev/core';\nimport { Stack, IconButton, Typography, BoxProps, Box, CircularProgress } from '@mui/material';\nimport DeleteIcon from 'mdi-material-ui/DeleteOutline';\nimport ChevronDown from 'mdi-material-ui/ChevronDown';\nimport ChevronRight from 'mdi-material-ui/ChevronRight';\nimport { forwardRef, ReactElement } from 'react';\nimport AlertIcon from 'mdi-material-ui/Alert';\nimport { InfoTooltip } from '@perses-dev/components';\nimport { QueryData } from '../../runtime';\nimport { PluginEditor, PluginEditorProps, PluginEditorRef } from '../PluginEditor';\n\n/**\n * Properties for {@link QueryEditorContainer}\n */\ninterface QueryEditorContainerProps {\n queryTypes: QueryPluginType[];\n index: number;\n query: QueryDefinition;\n queryResult?: QueryData;\n filteredQueryPlugins?: string[];\n onChange: (index: number, query: QueryDefinition) => void;\n onCollapseExpand: (index: number) => void;\n isCollapsed?: boolean;\n onDelete?: (index: number) => void;\n}\n\n/**\n * Container for a query editor. This component is responsible for rendering the query editor, and make it collapsible\n * to not take too much space.\n * @param queryTypes the supported query types\n * @param index the index of the query in the list\n * @param query the query definition\n * @param isCollapsed whether the query editor is collapsed or not\n * @param onDelete callback when the query is deleted\n * @param onChange callback when the query is changed\n * @param onCollapseExpand callback when the query is collapsed or expanded\n * @constructor\n */\n\nexport const QueryEditorContainer = forwardRef<PluginEditorRef, QueryEditorContainerProps>(\n (props, ref): ReactElement => {\n const {\n queryTypes,\n index,\n query,\n queryResult,\n filteredQueryPlugins,\n isCollapsed,\n onDelete,\n onChange,\n onCollapseExpand,\n } = props;\n return (\n <Stack key={index} spacing={1}>\n <Stack\n direction=\"row\"\n alignItems=\"center\"\n justifyContent=\"space-between\"\n borderBottom={1}\n borderColor={(theme) => theme.palette.divider}\n >\n <Stack direction=\"row\">\n <IconButton size=\"small\" onClick={() => onCollapseExpand(index)}>\n {isCollapsed ? <ChevronRight /> : <ChevronDown />}\n </IconButton>\n <Typography variant=\"overline\" component=\"h4\">\n Query #{index + 1}\n </Typography>\n </Stack>\n <Stack direction=\"row\" alignItems=\"center\">\n {queryResult?.isFetching && <CircularProgress aria-label=\"loading\" size=\"1.125rem\" />}\n {queryResult?.error && (\n <InfoTooltip description={queryResult.error.message}>\n <Stack\n direction=\"row\"\n alignItems=\"center\"\n sx={{\n color: (theme) => theme.palette.error.main,\n }}\n >\n <IconButton\n aria-label=\"query error\"\n size=\"small\"\n sx={{\n color: (theme) => theme.palette.error.main,\n }}\n >\n <AlertIcon />\n </IconButton>\n <Typography\n sx={{\n maxWidth: 300,\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n '&:hover ::after': { content: '\"Click to copy\"' },\n }}\n >\n {queryResult.error.message}\n </Typography>\n </Stack>\n </InfoTooltip>\n )}\n {onDelete && (\n <IconButton aria-label=\"delete query\" size=\"small\" onClick={() => onDelete && onDelete(index)}>\n <DeleteIcon />\n </IconButton>\n )}\n </Stack>\n </Stack>\n {!isCollapsed && (\n <QueryEditor\n ref={ref}\n queryTypes={queryTypes}\n value={query}\n queryResult={queryResult}\n filteredQueryPlugins={filteredQueryPlugins}\n onChange={(next) => onChange(index, next)}\n />\n )}\n </Stack>\n );\n }\n);\n\nQueryEditorContainer.displayName = 'QueryEditorContainer';\n\n// Props on MUI Box that we don't want people to pass because we're either redefining them or providing them in\n// this component\ntype OmittedMuiProps = 'children' | 'value' | 'onChange';\ninterface QueryEditorProps extends Omit<BoxProps, OmittedMuiProps> {\n queryTypes: QueryPluginType[];\n value: QueryDefinition;\n queryResult?: QueryData;\n filteredQueryPlugins?: string[];\n onChange: (next: QueryDefinition) => void;\n}\n\n/**\n * Editor for a query definition. This component is responsible for rendering the plugin editor for the given query.\n * This will allow user to select a plugin extending from the given supported query types, and then edit the plugin\n * spec for this plugin.\n * @param props\n * @constructor\n */\n\nconst QueryEditor = forwardRef<PluginEditorRef, QueryEditorProps>((props, ref): ReactElement => {\n const { value, onChange, queryTypes, queryResult, filteredQueryPlugins, ...others } = props;\n const handlePluginChange: PluginEditorProps['onChange'] = (next) => {\n onChange(\n produce(value, (draft) => {\n draft.kind = next.selection.type;\n draft.spec.plugin.kind = next.selection.kind;\n draft.spec.plugin.spec = next.spec;\n })\n );\n };\n\n return (\n <Box {...others}>\n <PluginEditor\n ref={ref}\n withRunQueryButton\n pluginTypes={queryTypes}\n pluginKindLabel=\"Query Type\"\n value={{\n selection: {\n kind: value.spec.plugin.kind,\n type: value.kind,\n },\n spec: value.spec.plugin.spec,\n }}\n filteredQueryPlugins={filteredQueryPlugins}\n onQueryRefresh={queryResult?.refetch}\n onChange={handlePluginChange}\n />\n </Box>\n );\n});\n\nQueryEditor.displayName = 'QueryEditor';\n"],"names":["produce","Stack","IconButton","Typography","Box","CircularProgress","DeleteIcon","ChevronDown","ChevronRight","forwardRef","AlertIcon","InfoTooltip","PluginEditor","QueryEditorContainer","props","ref","queryTypes","index","query","queryResult","filteredQueryPlugins","isCollapsed","onDelete","onChange","onCollapseExpand","spacing","direction","alignItems","justifyContent","borderBottom","borderColor","theme","palette","divider","size","onClick","variant","component","isFetching","aria-label","error","description","message","sx","color","main","maxWidth","whiteSpace","overflow","textOverflow","content","QueryEditor","value","next","displayName","others","handlePluginChange","draft","kind","selection","type","spec","plugin","withRunQueryButton","pluginTypes","pluginKindLabel","onQueryRefresh","refetch"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,OAAO,QAAQ,QAAQ;AAEhC,SAASC,KAAK,EAAEC,UAAU,EAAEC,UAAU,EAAYC,GAAG,EAAEC,gBAAgB,QAAQ,gBAAgB;AAC/F,OAAOC,gBAAgB,gCAAgC;AACvD,OAAOC,iBAAiB,8BAA8B;AACtD,OAAOC,kBAAkB,+BAA+B;AACxD,SAASC,UAAU,QAAsB,QAAQ;AACjD,OAAOC,eAAe,wBAAwB;AAC9C,SAASC,WAAW,QAAQ,yBAAyB;AAErD,SAASC,YAAY,QAA4C,kBAAkB;AAiBnF;;;;;;;;;;;CAWC,GAED,OAAO,MAAMC,qCAAuBJ,WAClC,CAACK,OAAOC;IACN,MAAM,EACJC,UAAU,EACVC,KAAK,EACLC,KAAK,EACLC,WAAW,EACXC,oBAAoB,EACpBC,WAAW,EACXC,QAAQ,EACRC,QAAQ,EACRC,gBAAgB,EACjB,GAAGV;IACJ,qBACE,MAACb;QAAkBwB,SAAS;;0BAC1B,MAACxB;gBACCyB,WAAU;gBACVC,YAAW;gBACXC,gBAAe;gBACfC,cAAc;gBACdC,aAAa,CAACC,QAAUA,MAAMC,OAAO,CAACC,OAAO;;kCAE7C,MAAChC;wBAAMyB,WAAU;;0CACf,KAACxB;gCAAWgC,MAAK;gCAAQC,SAAS,IAAMX,iBAAiBP;0CACtDI,4BAAc,KAACb,kCAAkB,KAACD;;0CAErC,MAACJ;gCAAWiC,SAAQ;gCAAWC,WAAU;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YACdA,MAAMC,IAAI,GAAGL,KAAKM,SAAS,CAACC,IAAI;YAChCH,MAAMI,IAAI,CAACC,MAAM,CAACJ,IAAI,GAAGL,KAAKM,SAAS,CAACD,IAAI;YAC5CD,MAAMI,IAAI,CAACC,MAAM,CAACD,IAAI,GAAGR,KAAKQ,IAAI;QACpC;IAEJ;IAEA,qBACE,KAACzD;QAAK,GAAGmD,MAAM;kBACb,cAAA,KAAC3C;YACCG,KAAKA;YACLgD,kBAAkB;YAClBC,aAAahD;YACbiD,iBAAgB;YAChBb,OAAO;gBACLO,WAAW;oBACTD,MAAMN,MAAMS,IAAI,CAACC,MAAM,CAACJ,IAAI;oBAC5BE,MAAMR,MAAMM,IAAI;gBAClB;gBACAG,MAAMT,MAAMS,IAAI,CAACC,MAAM,CAACD,IAAI;YAC9B;YACAzC,sBAAsBA;YACtB8C,gBAAgB/C,aAAagD;YAC7B5C,UAAUiC;;;AAIlB;AAEAL,YAAYG,WAAW,GAAG"}
@@ -1 +1 @@
1
- {"version":3,"file":"PanelSpecEditor.d.ts","sourceRoot":"","sources":["../../../src/components/PanelSpecEditor/PanelSpecEditor.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpG,OAAO,EAAE,OAAO,EAAc,MAAM,iBAAiB,CAAC;AAMtD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACpC,eAAe,EAAE,eAAe,CAAC;IACjC,eAAe,EAAE,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,IAAI,CAAC;IACtD,kBAAkB,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;IAChD,YAAY,EAAE,CAAC,kBAAkB,EAAE,MAAM,KAAK,IAAI,CAAC;CACpD;AAED,eAAO,MAAM,eAAe,kHAgG1B,CAAC"}
1
+ {"version":3,"file":"PanelSpecEditor.d.ts","sourceRoot":"","sources":["../../../src/components/PanelSpecEditor/PanelSpecEditor.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpG,OAAO,EAAE,OAAO,EAAc,MAAM,iBAAiB,CAAC;AAMtD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACpC,eAAe,EAAE,eAAe,CAAC;IACjC,eAAe,EAAE,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,IAAI,CAAC;IACtD,kBAAkB,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;IAChD,YAAY,EAAE,CAAC,kBAAkB,EAAE,MAAM,KAAK,IAAI,CAAC;CACpD;AAED,eAAO,MAAM,eAAe,kHAmG1B,CAAC"}
@@ -14,13 +14,14 @@ import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { ErrorAlert, JSONEditor, LinksEditor } from '@perses-dev/components';
15
15
  import { Controller } from 'react-hook-form';
16
16
  import { forwardRef } from 'react';
17
- import { QueryCountProvider, usePlugin } from '../../runtime';
17
+ import { QueryCountProvider, useDataQueriesContext, usePlugin } from '../../runtime';
18
18
  import { OptionsEditorTabs } from '../OptionsEditorTabs';
19
19
  import { MultiQueryEditor } from '../MultiQueryEditor';
20
20
  export const PanelSpecEditor = /*#__PURE__*/ forwardRef((props, ref)=>{
21
21
  const { control, panelDefinition, onJSONChange, onQueriesChange, onPluginSpecChange } = props;
22
22
  const { kind } = panelDefinition.spec.plugin;
23
23
  const { data: plugin, isLoading, error } = usePlugin('Panel', kind);
24
+ const { queryResults } = useDataQueriesContext();
24
25
  if (error) {
25
26
  return /*#__PURE__*/ _jsx(ErrorAlert, {
26
27
  error: error
@@ -44,6 +45,7 @@ export const PanelSpecEditor = /*#__PURE__*/ forwardRef((props, ref)=>{
44
45
  ref: ref,
45
46
  queryTypes: plugin.supportedQueryTypes ?? [],
46
47
  queries: panelDefinition.spec.queries ?? [],
48
+ queryResults: queryResults,
47
49
  onChange: (queries)=>{
48
50
  field.onChange(queries);
49
51
  onQueriesChange(queries);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/PanelSpecEditor/PanelSpecEditor.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ErrorAlert, JSONEditor, LinksEditor } from '@perses-dev/components';\nimport { PanelDefinition, PanelEditorValues, QueryDefinition, UnknownSpec } from '@perses-dev/core';\nimport { Control, Controller } from 'react-hook-form';\nimport { forwardRef, ReactElement } from 'react';\nimport { QueryCountProvider, usePlugin } from '../../runtime';\nimport { PanelPlugin } from '../../model';\nimport { OptionsEditorTabsProps, OptionsEditorTabs } from '../OptionsEditorTabs';\nimport { MultiQueryEditor } from '../MultiQueryEditor';\nimport { PluginEditorRef } from '../PluginEditor';\n\nexport interface PanelSpecEditorProps {\n control: Control<PanelEditorValues>;\n panelDefinition: PanelDefinition;\n onQueriesChange: (queries: QueryDefinition[]) => void;\n onPluginSpecChange: (spec: UnknownSpec) => void;\n onJSONChange: (panelDefinitionStr: string) => void;\n}\n\nexport const PanelSpecEditor = forwardRef<PluginEditorRef, PanelSpecEditorProps>((props, ref): ReactElement | null => {\n const { control, panelDefinition, onJSONChange, onQueriesChange, onPluginSpecChange } = props;\n const { kind } = panelDefinition.spec.plugin;\n const { data: plugin, isLoading, error } = usePlugin('Panel', kind);\n\n if (error) {\n return <ErrorAlert error={error} />;\n }\n\n if (isLoading) {\n return null;\n }\n\n if (!plugin) {\n throw new Error(`Missing implementation for panel plugin with kind '${kind}'`);\n }\n\n const { panelOptionsEditorComponents, hideQueryEditor } = plugin as PanelPlugin;\n let tabs: OptionsEditorTabsProps['tabs'] = [];\n\n if (!hideQueryEditor) {\n tabs.push({\n label: 'Query',\n content: (\n <Controller\n control={control}\n name=\"panelDefinition.spec.queries\"\n render={({ field }) => (\n <MultiQueryEditor\n ref={ref}\n queryTypes={plugin.supportedQueryTypes ?? []}\n queries={panelDefinition.spec.queries ?? []}\n onChange={(queries) => {\n field.onChange(queries);\n onQueriesChange(queries);\n }}\n />\n )}\n />\n ),\n });\n }\n\n if (panelOptionsEditorComponents) {\n tabs = tabs.concat(\n panelOptionsEditorComponents.map(({ label, content: OptionsEditorComponent }) => ({\n label,\n content: (\n <Controller\n control={control}\n name=\"panelDefinition.spec.plugin.spec\"\n render={({ field }) => (\n <OptionsEditorComponent\n value={panelDefinition.spec.plugin.spec}\n onChange={(spec) => {\n field.onChange(spec);\n onPluginSpecChange(spec);\n }}\n />\n )}\n />\n ),\n }))\n );\n }\n\n // always show json editor and links editor by default\n tabs.push({\n label: 'Links',\n content: <LinksEditor control={control} />,\n });\n tabs.push({\n label: 'JSON',\n content: (\n <Controller\n control={control}\n name=\"panelDefinition\"\n render={({ field }) => (\n <JSONEditor\n maxHeight=\"80vh\"\n value={panelDefinition}\n onChange={(json) => {\n field.onChange(JSON.parse(json));\n onJSONChange(json);\n }}\n />\n )}\n />\n ),\n });\n\n return (\n <QueryCountProvider queryCount={(panelDefinition.spec.queries ?? []).length}>\n <OptionsEditorTabs key={tabs.length} tabs={tabs} />\n </QueryCountProvider>\n );\n});\n\nPanelSpecEditor.displayName = 'PanelSpecEditor';\n"],"names":["ErrorAlert","JSONEditor","LinksEditor","Controller","forwardRef","QueryCountProvider","usePlugin","OptionsEditorTabs","MultiQueryEditor","PanelSpecEditor","props","ref","control","panelDefinition","onJSONChange","onQueriesChange","onPluginSpecChange","kind","spec","plugin","data","isLoading","error","Error","panelOptionsEditorComponents","hideQueryEditor","tabs","push","label","content","name","render","field","queryTypes","supportedQueryTypes","queries","onChange","concat","map","OptionsEditorComponent","value","maxHeight","json","JSON","parse","queryCount","length","displayName"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,UAAU,EAAEC,UAAU,EAAEC,WAAW,QAAQ,yBAAyB;AAE7E,SAAkBC,UAAU,QAAQ,kBAAkB;AACtD,SAASC,UAAU,QAAsB,QAAQ;AACjD,SAASC,kBAAkB,EAAEC,SAAS,QAAQ,gBAAgB;AAE9D,SAAiCC,iBAAiB,QAAQ,uBAAuB;AACjF,SAASC,gBAAgB,QAAQ,sBAAsB;AAWvD,OAAO,MAAMC,gCAAkBL,WAAkD,CAACM,OAAOC;IACvF,MAAM,EAAEC,OAAO,EAAEC,eAAe,EAAEC,YAAY,EAAEC,eAAe,EAAEC,kBAAkB,EAAE,GAAGN;IACxF,MAAM,EAAEO,IAAI,EAAE,GAAGJ,gBAAgBK,IAAI,CAACC,MAAM;IAC5C,MAAM,EAAEC,MAAMD,MAAM,EAAEE,SAAS,EAAEC,KAAK,EAAE,GAAGhB,UAAU,SAASW;IAE9D,IAAIK,OAAO;QACT,qBAAO,KAACtB;YAAWsB,OAAOA;;IAC5B;IAEA,IAAID,WAAW;QACb,OAAO;IACT;IAEA,IAAI,CAACF,QAAQ;QACX,MAAM,IAAII,MAAM,CAAC,mDAAmD,EAAEN,KAAK,CAAC,CAAC;IAC/E;IAEA,MAAM,EAAEO,4BAA4B,EAAEC,eAAe,EAAE,GAAGN;IAC1D,IAAIO,OAAuC,EAAE;IA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,EAAGW,MAAM;kBACzE,cAAA,KAACvC;YAAoCmB,MAAMA;WAAnBA,KAAKoB,MAAM;;AAGzC,GAAG;AAEHrC,gBAAgBsC,WAAW,GAAG"}
1
+ {"version":3,"sources":["../../../src/components/PanelSpecEditor/PanelSpecEditor.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ErrorAlert, JSONEditor, LinksEditor } from '@perses-dev/components';\nimport { PanelDefinition, PanelEditorValues, QueryDefinition, UnknownSpec } from '@perses-dev/core';\nimport { Control, Controller } from 'react-hook-form';\nimport { forwardRef, ReactElement } from 'react';\nimport { QueryCountProvider, useDataQueriesContext, usePlugin } from '../../runtime';\nimport { PanelPlugin } from '../../model';\nimport { OptionsEditorTabsProps, OptionsEditorTabs } from '../OptionsEditorTabs';\nimport { MultiQueryEditor } from '../MultiQueryEditor';\nimport { PluginEditorRef } from '../PluginEditor';\n\nexport interface PanelSpecEditorProps {\n control: Control<PanelEditorValues>;\n panelDefinition: PanelDefinition;\n onQueriesChange: (queries: QueryDefinition[]) => void;\n onPluginSpecChange: (spec: UnknownSpec) => void;\n onJSONChange: (panelDefinitionStr: string) => void;\n}\n\nexport const PanelSpecEditor = forwardRef<PluginEditorRef, PanelSpecEditorProps>((props, ref): ReactElement | null => {\n const { control, panelDefinition, onJSONChange, onQueriesChange, onPluginSpecChange } = props;\n const { kind } = panelDefinition.spec.plugin;\n const { data: plugin, isLoading, error } = usePlugin('Panel', kind);\n\n const { queryResults } = useDataQueriesContext();\n\n if (error) {\n return <ErrorAlert error={error} />;\n }\n\n if (isLoading) {\n return null;\n }\n\n if (!plugin) {\n throw new Error(`Missing implementation for panel plugin with kind '${kind}'`);\n }\n\n const { panelOptionsEditorComponents, hideQueryEditor } = plugin as PanelPlugin;\n let tabs: OptionsEditorTabsProps['tabs'] = [];\n\n if (!hideQueryEditor) {\n tabs.push({\n label: 'Query',\n content: (\n <Controller\n control={control}\n name=\"panelDefinition.spec.queries\"\n render={({ field }) => (\n <MultiQueryEditor\n ref={ref}\n queryTypes={plugin.supportedQueryTypes ?? []}\n queries={panelDefinition.spec.queries ?? []}\n queryResults={queryResults}\n onChange={(queries) => {\n field.onChange(queries);\n onQueriesChange(queries);\n }}\n />\n )}\n />\n ),\n });\n }\n\n if (panelOptionsEditorComponents) {\n tabs = tabs.concat(\n panelOptionsEditorComponents.map(({ label, content: OptionsEditorComponent }) => ({\n label,\n content: (\n <Controller\n control={control}\n name=\"panelDefinition.spec.plugin.spec\"\n render={({ field }) => (\n <OptionsEditorComponent\n value={panelDefinition.spec.plugin.spec}\n onChange={(spec) => {\n field.onChange(spec);\n onPluginSpecChange(spec);\n }}\n />\n )}\n />\n ),\n }))\n );\n }\n\n // always show json editor and links editor by default\n tabs.push({\n label: 'Links',\n content: <LinksEditor control={control} />,\n });\n tabs.push({\n label: 'JSON',\n content: (\n <Controller\n control={control}\n name=\"panelDefinition\"\n render={({ field }) => (\n <JSONEditor\n maxHeight=\"80vh\"\n value={panelDefinition}\n onChange={(json) => {\n field.onChange(JSON.parse(json));\n onJSONChange(json);\n }}\n />\n )}\n />\n ),\n });\n\n return (\n <QueryCountProvider queryCount={(panelDefinition.spec.queries ?? []).length}>\n <OptionsEditorTabs key={tabs.length} tabs={tabs} />\n </QueryCountProvider>\n );\n});\n\nPanelSpecEditor.displayName = 'PanelSpecEditor';\n"],"names":["ErrorAlert","JSONEditor","LinksEditor","Controller","forwardRef","QueryCountProvider","useDataQueriesContext","usePlugin","OptionsEditorTabs","MultiQueryEditor","PanelSpecEditor","props","ref","control","panelDefinition","onJSONChange","onQueriesChange","onPluginSpecChange","kind","spec","plugin","data","isLoading","error","queryResults","Error","panelOptionsEditorComponents","hideQueryEditor","tabs","push","label","content","name","render","field","queryTypes","supportedQueryTypes","queries","onChange","concat","map","OptionsEditorComponent","value","maxHeight","json","JSON","parse","queryCount","length","displayName"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,UAAU,EAAEC,UAAU,EAAEC,WAAW,QAAQ,yBAAyB;AAE7E,SAAkBC,UAAU,QAAQ,kBAAkB;AACtD,SAASC,UAAU,QAAsB,QAAQ;AACjD,SAASC,kBAAkB,EAAEC,qBAAqB,EAAEC,SAAS,QAAQ,gBAAgB;AAErF,SAAiCC,iBAAiB,QAAQ,uBAAuB;AACjF,SAASC,gBAAgB,QAAQ,sBAAsB;AAWvD,OAAO,MAAMC,gCAAkBN,WAAkD,CAACO,OAAOC;IACvF,MAAM,EAAEC,OAAO,EAAEC,eAAe,EAAEC,YAAY,EAAEC,eAAe,EAAEC,kBAAkB,EAAE,GAAGN;IACxF,MAAM,EAAEO,IAAI,EAAE,GAAGJ,gBAAgBK,IAAI,CAACC,MAAM;IAC5C,MAAM,EAAEC,MAAMD,MAAM,EAAEE,SAAS,EAAEC,KAAK,EAAE,GAAGhB,UAAU,SAASW;IAE9D,MAAM,EAAEM,YAAY,EAAE,GAAGlB;IAEzB,IAAIiB,OAAO;QACT,qBAAO,KAACvB;YAAWuB,OAAOA;;IAC5B;IAEA,IAAID,WAAW;QACb,OAAO;IACT;IAEA,IAAI,CAACF,QAAQ;QACX,MAAM,IAAIK,MAAM,CAAC,mDAAmD,EAAEP,KAAK,CAAC,CAAC;IAC/E;IAEA,MAAM,EAAEQ,4BAA4B,EAAEC,eAAe,EAAE,GAAGP;IAC1D,IAAIQ,OAAuC,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OAAO,IAAI,EAAE,AAAD,EAAGW,MAAM;kBACzE,cAAA,KAACxC;YAAoCoB,MAAMA;WAAnBA,KAAKoB,MAAM;;AAGzC,GAAG;AAEHtC,gBAAgBuC,WAAW,GAAG"}
@@ -1 +1 @@
1
- {"version":3,"file":"PluginEditor.d.ts","sourceRoot":"","sources":["../../../src/components/PluginEditor/PluginEditor.tsx"],"names":[],"mappings":";AAoBA,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAmB,MAAM,qBAAqB,CAAC;AAE1F;;;;;;;GAOG;AAEH,eAAO,MAAM,YAAY,4HAwFvB,CAAC"}
1
+ {"version":3,"file":"PluginEditor.d.ts","sourceRoot":"","sources":["../../../src/components/PluginEditor/PluginEditor.tsx"],"names":[],"mappings":";AAoBA,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAmB,MAAM,qBAAqB,CAAC;AAE1F;;;;;;;GAOG;AAEH,eAAO,MAAM,YAAY,4HAyFvB,CAAC"}