@perses-dev/plugin-system 0.53.0-beta.1 → 0.53.0-beta.3

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 (78) hide show
  1. package/dist/cjs/components/MultiQueryEditor/MultiQueryEditor.js +8 -3
  2. package/dist/cjs/components/MultiQueryEditor/QueryEditorContainer.js +74 -29
  3. package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +10 -1
  4. package/dist/cjs/components/PluginEditor/PluginEditor.js +11 -45
  5. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +27 -10
  6. package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +1 -1
  7. package/dist/cjs/components/Variables/variable-model.js +3 -3
  8. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +70 -33
  9. package/dist/cjs/runtime/TimeRangeProvider/{TimeRangeProviderWithQueryParams.js → TimeRangeProviders.js} +23 -5
  10. package/dist/cjs/runtime/TimeRangeProvider/index.js +1 -1
  11. package/dist/cjs/runtime/log-queries.js +2 -1
  12. package/dist/cjs/runtime/profile-queries.js +2 -1
  13. package/dist/cjs/runtime/time-series-queries.js +10 -16
  14. package/dist/cjs/runtime/trace-queries.js +3 -2
  15. package/dist/cjs/test/utils.js +4 -4
  16. package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts +3 -0
  17. package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts.map +1 -1
  18. package/dist/components/MultiQueryEditor/MultiQueryEditor.js +8 -3
  19. package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -1
  20. package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts +3 -0
  21. package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts.map +1 -1
  22. package/dist/components/MultiQueryEditor/QueryEditorContainer.js +75 -30
  23. package/dist/components/MultiQueryEditor/QueryEditorContainer.js.map +1 -1
  24. package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts +1 -0
  25. package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -1
  26. package/dist/components/PanelSpecEditor/PanelSpecEditor.js +11 -2
  27. package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
  28. package/dist/components/PluginEditor/PluginEditor.d.ts +3 -3
  29. package/dist/components/PluginEditor/PluginEditor.d.ts.map +1 -1
  30. package/dist/components/PluginEditor/PluginEditor.js +12 -46
  31. package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
  32. package/dist/components/PluginEditor/plugin-editor-api.d.ts +1 -1
  33. package/dist/components/PluginEditor/plugin-editor-api.d.ts.map +1 -1
  34. package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
  35. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
  36. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +28 -11
  37. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  38. package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts.map +1 -1
  39. package/dist/components/Variables/VariableEditorForm/VariablePreview.js +1 -1
  40. package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
  41. package/dist/components/Variables/variable-model.js +3 -3
  42. package/dist/components/Variables/variable-model.js.map +1 -1
  43. package/dist/model/plugin-base.d.ts +1 -6
  44. package/dist/model/plugin-base.d.ts.map +1 -1
  45. package/dist/model/plugin-base.js.map +1 -1
  46. package/dist/model/time-series-queries.d.ts +0 -1
  47. package/dist/model/time-series-queries.d.ts.map +1 -1
  48. package/dist/model/time-series-queries.js.map +1 -1
  49. package/dist/runtime/DataQueriesProvider/model.d.ts +1 -1
  50. package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
  51. package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
  52. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts +2 -3
  53. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts.map +1 -1
  54. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +70 -33
  55. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
  56. package/dist/runtime/TimeRangeProvider/TimeRangeProviders.d.ts +10 -0
  57. package/dist/runtime/TimeRangeProvider/TimeRangeProviders.d.ts.map +1 -0
  58. package/dist/runtime/TimeRangeProvider/{TimeRangeProviderWithQueryParams.js → TimeRangeProviders.js} +13 -3
  59. package/dist/runtime/TimeRangeProvider/TimeRangeProviders.js.map +1 -0
  60. package/dist/runtime/TimeRangeProvider/index.d.ts +1 -1
  61. package/dist/runtime/TimeRangeProvider/index.d.ts.map +1 -1
  62. package/dist/runtime/TimeRangeProvider/index.js +1 -1
  63. package/dist/runtime/TimeRangeProvider/index.js.map +1 -1
  64. package/dist/runtime/log-queries.js +2 -1
  65. package/dist/runtime/log-queries.js.map +1 -1
  66. package/dist/runtime/profile-queries.js +2 -1
  67. package/dist/runtime/profile-queries.js.map +1 -1
  68. package/dist/runtime/time-series-queries.d.ts.map +1 -1
  69. package/dist/runtime/time-series-queries.js +10 -16
  70. package/dist/runtime/time-series-queries.js.map +1 -1
  71. package/dist/runtime/trace-queries.js +3 -2
  72. package/dist/runtime/trace-queries.js.map +1 -1
  73. package/dist/test/utils.js +5 -5
  74. package/dist/test/utils.js.map +1 -1
  75. package/package.json +4 -4
  76. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.d.ts +0 -9
  77. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.d.ts.map +0 -1
  78. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.js.map +0 -1
@@ -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() {
@@ -65,14 +65,15 @@ function useTraceQueries(definitions) {
65
65
  });
66
66
  }
67
67
  function getQueryOptions({ plugin, definition, context }) {
68
- const { datasourceStore, variableState, absoluteTimeRange } = context;
68
+ const { variableState, absoluteTimeRange } = context;
69
69
  const dependencies = plugin?.dependsOn ? plugin.dependsOn(definition.spec.plugin.spec, context) : {};
70
70
  const variableDependencies = dependencies?.variables;
71
71
  const filteredVariabledState = (0, _utils.filterVariableStateMap)(variableState, variableDependencies);
72
72
  const variablesValueKey = (0, _utils.getVariableValuesKey)(filteredVariabledState);
73
73
  const queryKey = [
74
+ 'query',
75
+ TRACE_QUERY_KEY,
74
76
  definition,
75
- datasourceStore,
76
77
  absoluteTimeRange,
77
78
  variablesValueKey
78
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 ?? {
@@ -1,11 +1,14 @@
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[];
6
7
  filteredQueryPlugins?: string[];
7
8
  queries?: QueryDefinition[];
9
+ queryResults?: QueryData[];
8
10
  onChange: (queries: QueryDefinition[]) => void;
11
+ onQueryRun: (index: number, query: QueryDefinition) => void;
9
12
  }
10
13
  /**
11
14
  * A component render a list of {@link QueryEditorContainer} for the given query definitions.
@@ -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,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,OAAO,CAAC,EAAE,eAAe,EAAE,CAAC;IAC5B,QAAQ,EAAE,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,IAAI,CAAC;CAChD;AA4CD;;;;;;;GAOG;AAEH,eAAO,MAAM,gBAAgB,mHAoF3B,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;IAC/C,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;CAC7D;AA4CD;;;;;;;GAOG;AAEH,eAAO,MAAM,gBAAgB,mHA0F3B,CAAC"}
@@ -58,7 +58,7 @@ function useDefaultQueryDefinition(queryTypes, filteredQueryPlugins) {
58
58
  * @param onChange The callback to call when the queries are modified
59
59
  * @constructor
60
60
  */ export const MultiQueryEditor = /*#__PURE__*/ forwardRef((props, ref)=>{
61
- const { queryTypes, queries = [], filteredQueryPlugins, onChange } = props;
61
+ const { queryTypes, queries = [], queryResults, filteredQueryPlugins, onChange, onQueryRun } = props;
62
62
  const { defaultInitialQueryDefinition, isLoading } = useDefaultQueryDefinition(queryTypes, filteredQueryPlugins);
63
63
  // State for which queries are collapsed
64
64
  const [queriesCollapsed, setQueriesCollapsed] = useState(queries.map(()=>false));
@@ -74,6 +74,9 @@ function useDefaultQueryDefinition(queryTypes, filteredQueryPlugins) {
74
74
  }
75
75
  }));
76
76
  };
77
+ const handleQueryRun = (index, queryDef)=>{
78
+ onQueryRun(index, queryDef);
79
+ };
77
80
  const handleQueryAdd = ()=>{
78
81
  onChange(produce(queries, (draft)=>{
79
82
  if (draft) {
@@ -124,11 +127,13 @@ function useDefaultQueryDefinition(queryTypes, filteredQueryPlugins) {
124
127
  queryTypes: queryTypes,
125
128
  index: i,
126
129
  query: query,
130
+ queryResult: queryResults?.[i],
131
+ filteredQueryPlugins: filteredQueryPlugins,
127
132
  isCollapsed: !!queriesCollapsed[i],
128
133
  onChange: handleQueryChange,
134
+ onQueryRun: handleQueryRun,
129
135
  onDelete: queries.length > 1 ? handleQueryDelete : undefined,
130
- onCollapseExpand: handleQueryCollapseExpand,
131
- filteredQueryPlugins: filteredQueryPlugins
136
+ onCollapseExpand: handleQueryCollapseExpand
132
137
  }, i))
133
138
  }),
134
139
  /*#__PURE__*/ _jsx(Button, {
@@ -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 filteredQueryPlugins?: string[];\n queries?: QueryDefinition[];\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 = [], 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 isCollapsed={!!queriesCollapsed[i]}\n onChange={handleQueryChange}\n onDelete={queries.length > 1 ? handleQueryDelete : undefined}\n onCollapseExpand={handleQueryCollapseExpand}\n filteredQueryPlugins={filteredQueryPlugins}\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","onChange","queriesCollapsed","setQueriesCollapsed","map","handleQueryChange","index","queryDef","draft","handleQueryAdd","push","handleQueryDelete","splice","handleQueryCollapseExpand","queryDefinitions","spacing","query","isCollapsed","onDelete","undefined","onCollapseExpand","variant","startIcon","sx","marginTop","onClick","displayName"],"mappings":"AAAA,oCAAo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AA8B,GAC/B,EAAE;IAER,qBACE;;0BACE,KAACxB;gBAAM8C,SAAS;0BACbD,iBAAiBV,GAAG,CAAC,CAACY,OAAwB9B,kBAC7C,KAACZ;wBACCyB,KAAKA;wBACLvB,YAAYA;wBAEZ8B,OAAOpB;wBACP8B,OAAOA;wBACPC,aAAa,CAAC,CAACf,gBAAgB,CAAChB,EAAE;wBAClCe,UAAUI;wBACVa,UAAUlB,QAAQhB,MAAM,GAAG,IAAI2B,oBAAoBQ;wBACnDC,kBAAkBP;wBAClBpC,sBAAsBA;uBAPjBS;;0BAWX,KAAClB;gBAAOqD,SAAQ;gBAAYC,yBAAW,KAACpD;gBAAYqD,IAAI;oBAAEC,WAAW;gBAAE;gBAAGC,SAAShB;0BAAgB;;;;AAKzG,GAAG;AAEHZ,iBAAiB6B,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 onQueryRun: (index: number, query: 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, onQueryRun } = 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 handleQueryRun = (index: number, queryDef: QueryDefinition): void => {\n onQueryRun(index, queryDef);\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 onQueryRun={handleQueryRun}\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","onQueryRun","queriesCollapsed","setQueriesCollapsed","map","handleQueryChange","index","queryDef","draft","handleQueryRun","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;AAW9D,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,CA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B,CAACD;YACnBA,iBAAiBS,IAAI,CAAC;YACtB,OAAO;mBAAIT;aAAiB;QAC9B;IACF;IAEA,MAAMU,oBAAoB,CAACN;QACzBN,SACEnC,QAAQiC,SAAS,CAACU;YAChBA,MAAMK,MAAM,CAACP,OAAO;QACtB;QAEFH,oBAAoB,CAACD;YACnBA,iBAAiBW,MAAM,CAACP,OAAO;YAC/B,OAAO;mBAAIJ;aAAiB;QAC9B;IACF;IAEA,MAAMY,4BAA4B,CAACR;QACjCH,oBAAoB,CAACD;YACnBA,gBAAgB,CAACI,MAAM,GAAG,CAACJ,gBAAgB,CAACI,MAAM;YAClD,OAAO;mBAAIJ;aAAiB;QAC9B;IACF;IAEA,2CAA2C;IAC3C,MAAMa,mBAAsCjB,QAAQhB,MAAM,GACtDgB,UACA,CAACnB,YACC;QAACY;KAA8B,GAC/B,EAAE;IAER,qBACE;;0BACE,KAACxB;gBAAMiD,SAAS;0BACbD,iBAAiBX,GAAG,CAAC,CAACa,OAAwBjC,kBAC7C,KAACZ;wBACCyB,KAAKA;wBACLvB,YAAYA;wBAEZgC,OAAOtB;wBACPiC,OAAOA;wBACPC,aAAanB,cAAc,CAACf,EAAE;wBAC9BT,sBAAsBA;wBACtB4C,aAAa,CAAC,CAACjB,gBAAgB,CAAClB,EAAE;wBAClCgB,UAAUK;wBACVJ,YAAYQ;wBACZW,UAAUtB,QAAQhB,MAAM,GAAG,IAAI8B,oBAAoBS;wBACnDC,kBAAkBR;uBATb9B;;0BAaX,KAAClB;gBAAOyD,SAAQ;gBAAYC,yBAAW,KAACxD;gBAAYyD,IAAI;oBAAEC,WAAW;gBAAE;gBAAGC,SAASjB;0BAAgB;;;;AAKzG,GAAG;AAEHf,iBAAiBiC,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,8 +9,10 @@ interface QueryEditorContainerProps {
8
9
  queryTypes: QueryPluginType[];
9
10
  index: number;
10
11
  query: QueryDefinition;
12
+ queryResult?: QueryData;
11
13
  filteredQueryPlugins?: string[];
12
14
  onChange: (index: number, query: QueryDefinition) => void;
15
+ onQueryRun: (index: number, query: QueryDefinition) => void;
13
16
  onCollapseExpand: (index: number) => void;
14
17
  isCollapsed?: boolean;
15
18
  onDelete?: (index: number) => void;
@@ -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,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,uHAiChC,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,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;IAC5D,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,uHAqFhC,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,47 +32,92 @@ 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, filteredQueryPlugins, index, query, isCollapsed, onDelete, onChange, onCollapseExpand } = props;
35
+ const { queryTypes, index, query, queryResult, filteredQueryPlugins, isCollapsed, onDelete, onChange, onQueryRun, 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
  }),
69
114
  !isCollapsed && /*#__PURE__*/ _jsx(QueryEditor, {
70
- filteredQueryPlugins: filteredQueryPlugins,
71
115
  ref: ref,
72
116
  queryTypes: queryTypes,
73
117
  value: query,
74
- onChange: (next)=>onChange(index, next)
118
+ filteredQueryPlugins: filteredQueryPlugins,
119
+ onChange: (next)=>onChange(index, next),
120
+ onQueryRun: ()=>onQueryRun(index, query)
75
121
  })
76
122
  ]
77
123
  }, index);
@@ -84,8 +130,7 @@ QueryEditorContainer.displayName = 'QueryEditorContainer';
84
130
  * @param props
85
131
  * @constructor
86
132
  */ const QueryEditor = /*#__PURE__*/ forwardRef((props, ref)=>{
87
- const { value, onChange, queryTypes, filteredQueryPlugins, ...others } = props;
88
- const { refresh } = useTimeRange();
133
+ const { queryTypes, value, filteredQueryPlugins, onChange, onQueryRun, ...others } = props;
89
134
  const handlePluginChange = (next)=>{
90
135
  onChange(produce(value, (draft)=>{
91
136
  draft.kind = next.selection.type;
@@ -96,9 +141,7 @@ QueryEditorContainer.displayName = 'QueryEditorContainer';
96
141
  return /*#__PURE__*/ _jsx(Box, {
97
142
  ...others,
98
143
  children: /*#__PURE__*/ _jsx(PluginEditor, {
99
- postExecuteRunQuery: refresh,
100
144
  ref: ref,
101
- withRunQueryButton: true,
102
145
  pluginTypes: queryTypes,
103
146
  pluginKindLabel: "Query Type",
104
147
  value: {
@@ -108,8 +151,10 @@ QueryEditorContainer.displayName = 'QueryEditorContainer';
108
151
  },
109
152
  spec: value.spec.plugin.spec
110
153
  },
111
- onChange: handlePluginChange,
112
- filteredQueryPlugins: filteredQueryPlugins
154
+ filteredQueryPlugins: filteredQueryPlugins,
155
+ withRunQueryButton: true,
156
+ onRunQuery: onQueryRun,
157
+ onChange: handlePluginChange
113
158
  })
114
159
  });
115
160
  });
@@ -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 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 { queryTypes, filteredQueryPlugins, 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\n filteredQueryPlugins={filteredQueryPlugins}\n ref={ref}\n queryTypes={queryTypes}\n value={query}\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 filteredQueryPlugins?: string[];\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, filteredQueryPlugins, ...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 filteredQueryPlugins={filteredQueryPlugins}\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","filteredQueryPlugins","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;AAgB7C;;;;;;;;;;;CAWC,GAED,OAAO,MAAMC,qCAAuBH,WAClC,CAACI,OAAOC;IACN,MAAM,EAAEC,UAAU,EAAEC,oBAAoB,EAAEC,KAAK,EAAEC,KAAK,EAAEC,WAAW,EAAEC,QAAQ,EAAEC,QAAQ,EAAEC,gBAAgB,EAAE,GAAGT;IAC9G,qBACE,MAACX;QAAkBqB,SAAS;;0BAC1B,MAACrB;gBAAMsB,WAAU;gBAAMC,YAAW;gBAASC,cAAc;gBAAGC,aAAa,CAACC,QAAUA,MAAMC,OAAO,CAACC,OAAO;;kCACvG,KAAC3B;wBAAW4B,MAAK;wBAAQC,SAAS,IAAMV,iBAAiBL;kCACtDE,4BAAc,KAACX,kCAAkB,KAACD;;kCAErC,MAACH;wBAAW6B,SAAQ;wBAAWC,WAAU;;4BAAK;4BACpCjB,QAAQ;;;kCAElB,KAACd;wBACC4B,MAAK;wBACL,2GAA2G;wBAC3GI,IAAI;4BAAEC,YAAY;4BAAQC,YAAY,GAAGjB,WAAW,YAAY,UAAU;wBAAC;wBAC3EY,SAAS,IAAMZ,YAAYA,SAASH;kCAEpC,cAAA,KAACX;;;;YAGJ,CAACa,6BACA,KAACmB;gBACCtB,sBAAsBA;gBACtBF,KAAKA;gBACLC,YAAYA;gBACZwB,OAAOrB;gBACPG,UAAU,CAACmB,OAASnB,SAASJ,OAAOuB;;;OAvB9BvB;AA4BhB,GACA;AAEFL,qBAAqB6B,WAAW,GAAG;AAYnC;;;;;;CAMC,GAED,MAAMH,4BAAc7B,WAA8C,CAACI,OAAOC;IACxE,MAAM,EAAEyB,KAAK,EAAElB,QAAQ,EAAEN,UAAU,EAAEC,oBAAoB,EAAE,GAAG0B,QAAQ,GAAG7B;IACzE,MAAM,EAAE8B,OAAO,EAAE,GAAGhC;IACpB,MAAMiC,qBAAoD,CAACJ;QACzDnB,SACEpB,QAAQsC,OAAO,CAACM;YACdA,MAAMC,IAAI,GAAGN,KAAKO,SAAS,CAACC,IAAI;YAChCH,MAAMI,IAAI,CAACC,MAAM,CAACJ,IAAI,GAAGN,KAAKO,SAAS,CAACD,IAAI;YAC5CD,MAAMI,IAAI,CAACC,MAAM,CAACD,IAAI,GAAGT,KAAKS,IAAI;QACpC;IAEJ;IAEA,qBACE,KAAC5C;QAAK,GAAGqC,MAAM;kBACb,cAAA,KAAChC;YACCyC,qBAAqBR;YACrB7B,KAAKA;YACLsC,kBAAkB;YAClBC,aAAatC;YACbuC,iBAAgB;YAChBf,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;YACV5B,sBAAsBA;;;AAI9B;AAEAsB,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 onQueryRun: (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 onQueryRun,\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 filteredQueryPlugins={filteredQueryPlugins}\n onChange={(next) => onChange(index, next)}\n onQueryRun={() => onQueryRun(index, query)}\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 filteredQueryPlugins?: string[];\n onChange: (next: QueryDefinition) => void;\n onQueryRun: () => 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 { queryTypes, value, filteredQueryPlugins, onChange, onQueryRun, ...others } = props;\n\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 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 withRunQueryButton\n onRunQuery={onQueryRun}\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","onQueryRun","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","pluginTypes","pluginKindLabel","withRunQueryButton","onRunQuery"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AAC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AAK,GAAGoD,MAAM;kBACb,cAAA,KAAC5C;YACCG,KAAKA;YACLiD,aAAahD;YACbiD,iBAAgB;YAChBZ,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;YACA1C,sBAAsBA;YACtB8C,kBAAkB;YAClBC,YAAY3C;YACZD,UAAUkC;;;AAIlB;AAEAL,YAAYG,WAAW,GAAG"}
@@ -6,6 +6,7 @@ export interface PanelSpecEditorProps {
6
6
  control: Control<PanelEditorValues>;
7
7
  panelDefinition: PanelDefinition;
8
8
  onQueriesChange: (queries: QueryDefinition[]) => void;
9
+ onQueryRun: (index: number, query: QueryDefinition) => void;
9
10
  onPluginSpecChange: (spec: UnknownSpec) => void;
10
11
  onJSONChange: (panelDefinitionStr: string) => void;
11
12
  }
@@ -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,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;IAC5D,kBAAkB,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;IAChD,YAAY,EAAE,CAAC,kBAAkB,EAAE,MAAM,KAAK,IAAI,CAAC;CACpD;AAED,eAAO,MAAM,eAAe,kHA0G1B,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
- const { control, panelDefinition, onJSONChange, onQueriesChange, onPluginSpecChange } = props;
21
+ const { control, panelDefinition, onQueriesChange, onQueryRun, onPluginSpecChange, onJSONChange } = 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,9 +45,17 @@ 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);
52
+ },
53
+ onQueryRun: (index, query)=>{
54
+ onQueryRun(index, query);
55
+ // If spec has not changed, refetch to update the data
56
+ if (JSON.stringify(panelDefinition.spec.queries?.[index]) === JSON.stringify(query)) {
57
+ queryResults[index]?.refetch?.();
58
+ }
50
59
  }
51
60
  })
52
61
  })
@@ -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,MAA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OAAO;QACPC,uBACE,KAAC1B;YACCS,SAASA;YACTkB,MAAK;YACLC,QAAQ,CAAC,EAAEC,KAAK,EAAE,iBAChB,KAAC/B;oBACCwC,WAAU;oBACVD,OAAO3B;oBACPuB,UAAU,CAACM;wBACTV,MAAMI,QAAQ,CAACO,KAAKC,KAAK,CAACF;wBAC1B5B,aAAa4B;oBACf;;;IAKV;IAEA,qBACE,KAACrC;QAAmBwC,YAAY,AAAChC,CAAAA,gBAAgBK,IAAI,CAACiB,OAAO,IAAI,EAAE,AAAD,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 onQueryRun: (index: number, query: 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, onQueriesChange, onQueryRun, onPluginSpecChange, onJSONChange } = 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 onQueryRun={(index, query) => {\n onQueryRun(index, query);\n // If spec has not changed, refetch to update the data\n if (JSON.stringify(panelDefinition.spec.queries?.[index]) === JSON.stringify(query)) {\n queryResults[index]?.refetch?.();\n }\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","onQueriesChange","onQueryRun","onPluginSpecChange","onJSONChange","kind","spec","plugin","data","isLoading","error","queryResults","Error","panelOptionsEditorComponents","hideQueryEditor","tabs","push","label","content","name","render","field","queryTypes","supportedQueryTypes","queries","onChange","index","query","JSON","stringify","refetch","concat","map","OptionsEditorComponent","value","maxHeight","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;AAYvD,OAAO,MAAMC,gCAAkBN,WAAkD,CAACO,OAAOC;IACvF,MAAM,EAAEC,OAAO,EAA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lB,6BAA6BmB,GAAG,CAAC,CAAC,EAAEf,KAAK,EAAEC,SAASe,sBAAsB,EAAE,GAAM,CAAA;gBAChFhB;gBACAC,uBACE,KAAC7B;oBACCU,SAASA;oBACToB,MAAK;oBACLC,QAAQ,CAAC,EAAEC,KAAK,EAAE,iBAChB,KAACY;4BACCC,OAAOlC,gBAAgBM,IAAI,CAACC,MAAM,CAACD,IAAI;4BACvCmB,UAAU,CAACnB;gCACTe,MAAMI,QAAQ,CAACnB;gCACfH,mBAAmBG;4BACrB;;;YAKV,CAAA;IAEJ;IAEA,sDAAsD;IACtDS,KAAKC,IAAI,CAAC;QACRC,OAAO;QACPC,uBAAS,KAAC9B;YAAYW,SAASA;;IACjC;IACAgB,KAAKC,IAAI,CAAC;QACRC,OAAO;QACPC,uBACE,KAAC7B;YACCU,SAASA;YACToB,MAAK;YACLC,QAAQ,CAAC,EAAEC,KAAK,EAAE,iBAChB,KAAClC;oBACCgD,WAAU;oBACVD,OAAOlC;oBACPyB,UAAU,CAACW;wBACTf,MAAMI,QAAQ,CAACG,KAAKS,KAAK,CAACD;wBAC1BhC,aAAagC;oBACf;;;IAKV;IAEA,qBACE,KAAC7C;QAAmB+C,YAAY,AAACtC,CAAAA,gBAAgBM,IAAI,CAACkB,OAAO,IAAI,EAAE,AAAD,EAAGe,MAAM;kBACzE,cAAA,KAAC7C;YAAoCqB,MAAMA;WAAnBA,KAAKwB,MAAM;;AAGzC,GAAG;AAEH3C,gBAAgB4C,WAAW,GAAG"}
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
2
- import { PluginEditorProps, PluginEditorRef } from './plugin-editor-api';
1
+ import { ReactElement } from 'react';
2
+ import { PluginEditorProps } from './plugin-editor-api';
3
3
  /**
4
4
  * A combination `PluginKindSelect` and `PluginSpecEditor` component. This is meant for editing the `plugin` property
5
5
  * that's common in our JSON specs where a user selects a plugin `kind` and then edits the `spec` via that plugin's
@@ -8,5 +8,5 @@ import { PluginEditorProps, PluginEditorRef } from './plugin-editor-api';
8
8
  * previous plugin's spec state. If you just want this behavior, but in a different UI layout from this, try the
9
9
  * `usePluginEditor` hook that powers this component.
10
10
  */
11
- export declare const PluginEditor: import("react").ForwardRefExoticComponent<Omit<PluginEditorProps, "ref"> & import("react").RefAttributes<PluginEditorRef>>;
11
+ export declare function PluginEditor(props: PluginEditorProps): ReactElement;
12
12
  //# sourceMappingURL=PluginEditor.d.ts.map
@@ -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,4HA0FvB,CAAC"}
1
+ {"version":3,"file":"PluginEditor.d.ts","sourceRoot":"","sources":["../../../src/components/PluginEditor/PluginEditor.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,YAAY,EAAe,MAAM,OAAO,CAAC;AAIlD,OAAO,EAAE,iBAAiB,EAAmB,MAAM,qBAAqB,CAAC;AAEzE;;;;;;;GAOG;AAEH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,YAAY,CAwEnE"}