@perses-dev/plugin-system 0.0.0-snapshot-ts-panel-actions-76080ec → 0.0.0-snapshot-reverse-proxy-75afbd7

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 (190) hide show
  1. package/dist/cjs/components/DatasourceEditorForm/DatasourceEditorForm.js +1 -0
  2. package/dist/cjs/components/{DatasourceSelect.js → DatasourceSelect/DatasourceSelect.js} +4 -3
  3. package/dist/cjs/components/DatasourceSelect/index.js +30 -0
  4. package/dist/cjs/components/LegendOptionsEditor/LegendOptionsEditor.js +117 -90
  5. package/dist/cjs/components/MultiQueryEditor/MultiQueryEditor.js +5 -2
  6. package/dist/cjs/components/MultiQueryEditor/QueryEditorContainer.js +14 -4
  7. package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +7 -5
  8. package/dist/cjs/components/PluginEditor/PluginEditor.js +57 -17
  9. package/dist/cjs/components/PluginKindSelect/PluginKindSelect.js +6 -3
  10. package/dist/cjs/components/PluginSpecEditor/PluginSpecEditor.js +13 -9
  11. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +62 -120
  12. package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +42 -33
  13. package/dist/cjs/components/Variables/VariableEditorForm/index.js +1 -0
  14. package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +47 -0
  15. package/dist/cjs/components/Variables/variable-model.js +3 -3
  16. package/dist/cjs/components/index.js +0 -1
  17. package/dist/cjs/context/index.js +0 -1
  18. package/dist/cjs/model/legend.js +13 -0
  19. package/dist/cjs/model/log-queries.js +16 -0
  20. package/dist/cjs/remote/PluginRuntime.js +3 -2
  21. package/dist/cjs/remote/remotePluginLoader.js +19 -4
  22. package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +10 -2
  23. package/dist/cjs/runtime/DataQueriesProvider/model.js +17 -4
  24. package/dist/cjs/runtime/RouterProvider.js +114 -0
  25. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +6 -1
  26. package/dist/cjs/runtime/UsageMetricsProvider.js +4 -3
  27. package/dist/cjs/runtime/index.js +1 -0
  28. package/dist/cjs/runtime/log-queries.js +68 -0
  29. package/dist/cjs/runtime/time-series-queries.js +4 -4
  30. package/dist/cjs/runtime/variables.js +15 -0
  31. package/dist/cjs/test/mock-data.js +182 -0
  32. package/dist/cjs/test/utils.js +17 -8
  33. package/dist/cjs/utils/variables.js +109 -14
  34. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -1
  35. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +1 -0
  36. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
  37. package/dist/components/{DatasourceSelect.d.ts → DatasourceSelect/DatasourceSelect.d.ts} +1 -1
  38. package/dist/components/DatasourceSelect/DatasourceSelect.d.ts.map +1 -0
  39. package/dist/components/{DatasourceSelect.js → DatasourceSelect/DatasourceSelect.js} +4 -3
  40. package/dist/components/DatasourceSelect/DatasourceSelect.js.map +1 -0
  41. package/dist/components/DatasourceSelect/index.d.ts +2 -0
  42. package/dist/components/DatasourceSelect/index.d.ts.map +1 -0
  43. package/dist/components/DatasourceSelect/index.js +15 -0
  44. package/dist/components/DatasourceSelect/index.js.map +1 -0
  45. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts +2 -1
  46. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts.map +1 -1
  47. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +120 -93
  48. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
  49. package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts +3 -2
  50. package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts.map +1 -1
  51. package/dist/components/MultiQueryEditor/MultiQueryEditor.js +6 -3
  52. package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -1
  53. package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts +3 -2
  54. package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts.map +1 -1
  55. package/dist/components/MultiQueryEditor/QueryEditorContainer.js +14 -4
  56. package/dist/components/MultiQueryEditor/QueryEditorContainer.js.map +1 -1
  57. package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts +3 -2
  58. package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -1
  59. package/dist/components/PanelSpecEditor/PanelSpecEditor.js +7 -5
  60. package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
  61. package/dist/components/PluginEditor/PluginEditor.d.ts +3 -3
  62. package/dist/components/PluginEditor/PluginEditor.d.ts.map +1 -1
  63. package/dist/components/PluginEditor/PluginEditor.js +57 -17
  64. package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
  65. package/dist/components/PluginEditor/plugin-editor-api.d.ts +5 -0
  66. package/dist/components/PluginEditor/plugin-editor-api.d.ts.map +1 -1
  67. package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
  68. package/dist/components/PluginKindSelect/PluginKindSelect.d.ts.map +1 -1
  69. package/dist/components/PluginKindSelect/PluginKindSelect.js +7 -4
  70. package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
  71. package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts.map +1 -1
  72. package/dist/components/PluginSpecEditor/PluginSpecEditor.js +13 -9
  73. package/dist/components/PluginSpecEditor/PluginSpecEditor.js.map +1 -1
  74. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
  75. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
  76. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +63 -80
  77. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  78. package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts +2 -2
  79. package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts.map +1 -1
  80. package/dist/components/Variables/VariableEditorForm/VariablePreview.js +43 -34
  81. package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
  82. package/dist/components/Variables/VariableEditorForm/index.d.ts +1 -0
  83. package/dist/components/Variables/VariableEditorForm/index.d.ts.map +1 -1
  84. package/dist/components/Variables/VariableEditorForm/index.js +1 -0
  85. package/dist/components/Variables/VariableEditorForm/index.js.map +1 -1
  86. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +6 -0
  87. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -1
  88. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +44 -0
  89. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
  90. package/dist/components/Variables/variable-model.js +3 -3
  91. package/dist/components/Variables/variable-model.js.map +1 -1
  92. package/dist/components/index.d.ts +0 -1
  93. package/dist/components/index.d.ts.map +1 -1
  94. package/dist/components/index.js +0 -1
  95. package/dist/components/index.js.map +1 -1
  96. package/dist/context/index.d.ts +0 -1
  97. package/dist/context/index.d.ts.map +1 -1
  98. package/dist/context/index.js +0 -1
  99. package/dist/context/index.js.map +1 -1
  100. package/dist/model/legend.d.ts +3 -1
  101. package/dist/model/legend.d.ts.map +1 -1
  102. package/dist/model/legend.js +10 -0
  103. package/dist/model/legend.js.map +1 -1
  104. package/dist/model/log-queries.d.ts +24 -0
  105. package/dist/model/log-queries.d.ts.map +1 -0
  106. package/dist/model/log-queries.js +15 -0
  107. package/dist/model/log-queries.js.map +1 -0
  108. package/dist/model/plugin-base.d.ts +6 -1
  109. package/dist/model/plugin-base.d.ts.map +1 -1
  110. package/dist/model/plugin-base.js.map +1 -1
  111. package/dist/model/plugins.d.ts +2 -0
  112. package/dist/model/plugins.d.ts.map +1 -1
  113. package/dist/model/plugins.js.map +1 -1
  114. package/dist/model/time-series-queries.d.ts +1 -1
  115. package/dist/model/time-series-queries.d.ts.map +1 -1
  116. package/dist/model/time-series-queries.js.map +1 -1
  117. package/dist/model/variables.d.ts +1 -1
  118. package/dist/model/variables.d.ts.map +1 -1
  119. package/dist/model/variables.js.map +1 -1
  120. package/dist/remote/PluginRuntime.d.ts +2 -2
  121. package/dist/remote/PluginRuntime.d.ts.map +1 -1
  122. package/dist/remote/PluginRuntime.js +4 -3
  123. package/dist/remote/PluginRuntime.js.map +1 -1
  124. package/dist/remote/remotePluginLoader.d.ts +18 -1
  125. package/dist/remote/remotePluginLoader.d.ts.map +1 -1
  126. package/dist/remote/remotePluginLoader.js +22 -4
  127. package/dist/remote/remotePluginLoader.js.map +1 -1
  128. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts.map +1 -1
  129. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +10 -2
  130. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
  131. package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
  132. package/dist/runtime/DataQueriesProvider/model.js +17 -4
  133. package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
  134. package/dist/runtime/RouterProvider.d.ts +32 -0
  135. package/dist/runtime/RouterProvider.d.ts.map +1 -0
  136. package/dist/runtime/RouterProvider.js +59 -0
  137. package/dist/runtime/RouterProvider.js.map +1 -0
  138. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts.map +1 -1
  139. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +6 -1
  140. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
  141. package/dist/runtime/TimeRangeProvider/query-params.d.ts.map +1 -1
  142. package/dist/runtime/TimeRangeProvider/query-params.js.map +1 -1
  143. package/dist/runtime/UsageMetricsProvider.d.ts +3 -1
  144. package/dist/runtime/UsageMetricsProvider.d.ts.map +1 -1
  145. package/dist/runtime/UsageMetricsProvider.js +4 -3
  146. package/dist/runtime/UsageMetricsProvider.js.map +1 -1
  147. package/dist/runtime/index.d.ts +1 -0
  148. package/dist/runtime/index.d.ts.map +1 -1
  149. package/dist/runtime/index.js +1 -0
  150. package/dist/runtime/index.js.map +1 -1
  151. package/dist/runtime/log-queries.d.ts +7 -0
  152. package/dist/runtime/log-queries.d.ts.map +1 -0
  153. package/dist/runtime/log-queries.js +52 -0
  154. package/dist/runtime/log-queries.js.map +1 -0
  155. package/dist/runtime/time-series-queries.d.ts.map +1 -1
  156. package/dist/runtime/time-series-queries.js +4 -4
  157. package/dist/runtime/time-series-queries.js.map +1 -1
  158. package/dist/runtime/variables.d.ts +1 -0
  159. package/dist/runtime/variables.d.ts.map +1 -1
  160. package/dist/runtime/variables.js +13 -0
  161. package/dist/runtime/variables.js.map +1 -1
  162. package/dist/test/mock-data.d.ts +136 -1
  163. package/dist/test/mock-data.d.ts.map +1 -1
  164. package/dist/test/mock-data.js +156 -0
  165. package/dist/test/mock-data.js.map +1 -1
  166. package/dist/test/utils.d.ts.map +1 -1
  167. package/dist/test/utils.js +17 -8
  168. package/dist/test/utils.js.map +1 -1
  169. package/dist/utils/variables.d.ts +24 -2
  170. package/dist/utils/variables.d.ts.map +1 -1
  171. package/dist/utils/variables.js +102 -14
  172. package/dist/utils/variables.js.map +1 -1
  173. package/package.json +7 -7
  174. package/dist/cjs/components/ProjectSelect.js +0 -96
  175. package/dist/cjs/context/ProjectStoreProvider.js +0 -81
  176. package/dist/cjs/context/query-params.js +0 -49
  177. package/dist/components/DatasourceSelect.d.ts.map +0 -1
  178. package/dist/components/DatasourceSelect.js.map +0 -1
  179. package/dist/components/ProjectSelect.d.ts +0 -15
  180. package/dist/components/ProjectSelect.d.ts.map +0 -1
  181. package/dist/components/ProjectSelect.js +0 -91
  182. package/dist/components/ProjectSelect.js.map +0 -1
  183. package/dist/context/ProjectStoreProvider.d.ts +0 -16
  184. package/dist/context/ProjectStoreProvider.d.ts.map +0 -1
  185. package/dist/context/ProjectStoreProvider.js +0 -59
  186. package/dist/context/ProjectStoreProvider.js.map +0 -1
  187. package/dist/context/query-params.d.ts +0 -5
  188. package/dist/context/query-params.d.ts.map +0 -1
  189. package/dist/context/query-params.js +0 -41
  190. package/dist/context/query-params.js.map +0 -1
@@ -238,6 +238,7 @@ function DatasourceEditorForm(props) {
238
238
  'Datasource'
239
239
  ],
240
240
  pluginKindLabel: "Source",
241
+ withRunQueryButton: false,
241
242
  value: {
242
243
  selection: {
243
244
  type: 'Datasource',
@@ -47,8 +47,8 @@ const _jsxruntime = require("react/jsx-runtime");
47
47
  const _react = require("react");
48
48
  const _OpenInNew = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/OpenInNew"));
49
49
  const _material = require("@mui/material");
50
- const _runtime = require("../runtime");
51
- const _utils = require("../utils");
50
+ const _runtime = require("../../runtime");
51
+ const _utils = require("../../utils");
52
52
  function _interop_require_default(obj) {
53
53
  return obj && obj.__esModule ? obj : {
54
54
  default: obj
@@ -61,7 +61,7 @@ const emptyDatasourceOption = {
61
61
  value: ''
62
62
  };
63
63
  function DatasourceSelect(props) {
64
- const { datasourcePluginKind, value, project, onChange, ...others } = props;
64
+ const { datasourcePluginKind, value, project, readOnly, onChange, ...others } = props;
65
65
  const { data, isLoading } = (0, _runtime.useListDatasourceSelectItems)(datasourcePluginKind, project);
66
66
  const variables = (0, _runtime.useVariableValues)();
67
67
  const defaultValue = (0, _react.useMemo)(()=>{
@@ -132,6 +132,7 @@ function DatasourceSelect(props) {
132
132
  // eslint-disable-next-line @typescript-eslint/no-empty-function
133
133
  const fakeActionEvent = ()=>{};
134
134
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Autocomplete, {
135
+ readOnly: readOnly,
135
136
  options: options,
136
137
  renderInput: (params)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
137
138
  ...params,
@@ -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
+ _export_star(require("./DatasourceSelect"), exports);
18
+ function _export_star(from, to) {
19
+ Object.keys(from).forEach(function(k) {
20
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
21
+ Object.defineProperty(to, k, {
22
+ enumerable: true,
23
+ get: function() {
24
+ return from[k];
25
+ }
26
+ });
27
+ }
28
+ });
29
+ return from;
30
+ }
@@ -24,6 +24,7 @@ const _jsxruntime = require("react/jsx-runtime");
24
24
  const _material = require("@mui/material");
25
25
  const _core = require("@perses-dev/core");
26
26
  const _components = require("@perses-dev/components");
27
+ const _react = require("react");
27
28
  const _model = require("../../model");
28
29
  const POSITION_OPTIONS = Object.entries(_model.LEGEND_POSITIONS_CONFIG).map(([id, config])=>{
29
30
  return {
@@ -31,25 +32,13 @@ const POSITION_OPTIONS = Object.entries(_model.LEGEND_POSITIONS_CONFIG).map(([id
31
32
  ...config
32
33
  };
33
34
  });
34
- const MODE_OPTIONS = Object.entries(_model.LEGEND_MODE_CONFIG).map(([id, config])=>{
35
- return {
36
- id: id,
37
- ...config
38
- };
39
- });
40
35
  const SIZE_OPTIONS = Object.entries(_model.LEGEND_SIZE_CONFIG).map(([id, config])=>{
41
36
  return {
42
37
  id: id,
43
38
  ...config
44
39
  };
45
40
  });
46
- const VALUE_OPTIONS = Object.entries(_model.LEGEND_VALUE_CONFIG).map(([id, config])=>{
47
- return {
48
- id: id,
49
- ...config
50
- };
51
- });
52
- function LegendOptionsEditor({ value, onChange, showValuesEditor = true }) {
41
+ function LegendOptionsEditor({ value, onChange, showValuesEditor = true, calculation = 'aggregation' }) {
53
42
  const handleLegendShowChange = (_, checked)=>{
54
43
  // legend is hidden when legend obj is undefined
55
44
  const legendValue = checked === true ? {
@@ -63,13 +52,6 @@ function LegendOptionsEditor({ value, onChange, showValuesEditor = true }) {
63
52
  position: newValue.id
64
53
  });
65
54
  };
66
- const handleLegendModeChange = (_, newValue)=>{
67
- onChange({
68
- ...value,
69
- position: currentPosition,
70
- mode: newValue.id
71
- });
72
- };
73
55
  const handleLegendSizeChange = (_, newValue)=>{
74
56
  onChange({
75
57
  ...value,
@@ -90,20 +72,51 @@ function LegendOptionsEditor({ value, onChange, showValuesEditor = true }) {
90
72
  const currentPosition = (0, _core.getLegendPosition)(value?.position);
91
73
  const legendPositionConfig = _model.LEGEND_POSITIONS_CONFIG[currentPosition];
92
74
  const currentMode = (0, _core.getLegendMode)(value?.mode);
93
- const legendModeConfig = _model.LEGEND_MODE_CONFIG[currentMode];
94
75
  const currentSize = (0, _core.getLegendSize)(value?.size);
95
76
  const legendSizeConfig = _model.LEGEND_SIZE_CONFIG[currentSize];
96
- const currentValues = value?.values || [];
97
- const legendValuesConfig = currentValues.reduce((result, item)=>{
98
- const config = _model.LEGEND_VALUE_CONFIG[item];
99
- if (config) {
100
- result.push({
101
- ...config,
102
- id: item
77
+ const legendValuesConfig = (0, _react.useMemo)(()=>{
78
+ const currentValues = value?.values;
79
+ if (!currentValues?.length) return [];
80
+ if (calculation === 'aggregation') {
81
+ return currentValues.reduce((result, item)=>{
82
+ const config = _model.LEGEND_VALUE_CONFIG[item];
83
+ if (config) {
84
+ result.push({
85
+ ...config,
86
+ id: item
87
+ });
88
+ }
89
+ return result;
90
+ }, []);
91
+ }
92
+ return currentValues.map((id)=>{
93
+ const { label, description } = _model.comparisonLegends[id];
94
+ return {
95
+ id,
96
+ label,
97
+ description
98
+ };
99
+ });
100
+ }, [
101
+ calculation,
102
+ value?.values
103
+ ]);
104
+ const valueOptions = (0, _react.useMemo)(()=>{
105
+ if (calculation === 'aggregation') {
106
+ return Object.entries(_model.LEGEND_VALUE_CONFIG || {}).map(([id, config])=>{
107
+ return {
108
+ id: id,
109
+ ...config
110
+ };
103
111
  });
104
112
  }
105
- return result;
106
- }, []);
113
+ return Object.entries(_model.comparisonLegends).map(([id, config])=>({
114
+ id: id,
115
+ ...config
116
+ }));
117
+ }, [
118
+ calculation
119
+ ]);
107
120
  return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.OptionsEditorGroup, {
108
121
  title: "Legend",
109
122
  children: [
@@ -116,69 +129,83 @@ function LegendOptionsEditor({ value, onChange, showValuesEditor = true }) {
116
129
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorControl, {
117
130
  label: "Show",
118
131
  control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Switch, {
119
- checked: value !== undefined,
132
+ checked: !!value,
120
133
  onChange: handleLegendShowChange
121
134
  })
122
135
  }),
123
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorControl, {
124
- label: "Position",
125
- control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.SettingsAutocomplete, {
126
- value: {
127
- ...legendPositionConfig,
128
- id: currentPosition
129
- },
130
- options: POSITION_OPTIONS,
131
- onChange: handleLegendPositionChange,
132
- disabled: value === undefined,
133
- disableClearable: true
134
- })
135
- }),
136
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorControl, {
137
- label: "Mode",
138
- control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.SettingsAutocomplete, {
139
- value: {
140
- ...legendModeConfig,
141
- id: currentMode
142
- },
143
- options: MODE_OPTIONS,
144
- onChange: handleLegendModeChange,
145
- disabled: value === undefined,
146
- disableClearable: true
147
- })
148
- }),
149
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorControl, {
150
- label: "Size",
151
- control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.SettingsAutocomplete, {
152
- value: {
153
- ...legendSizeConfig,
154
- id: currentSize
155
- },
156
- options: SIZE_OPTIONS,
157
- onChange: handleLegendSizeChange,
158
- // TODO: enable sizes for list mode when we normalize the layout of
159
- // lists to more closely match tables.
160
- disabled: value === undefined || currentMode !== 'table',
161
- disableClearable: true
162
- })
163
- }),
164
- showValuesEditor && /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorControl, {
165
- label: "Values",
166
- control: // For some reason, the inferred option type doesn't always seem to work
167
- // quite right when `multiple` is true. Explicitly setting the generics
168
- // to work around this.
169
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.SettingsAutocomplete, {
170
- multiple: true,
171
- disableCloseOnSelect: true,
172
- disableClearable: true,
173
- value: legendValuesConfig,
174
- options: VALUE_OPTIONS,
175
- onChange: handleLegendValueChange,
176
- disabled: value === undefined || currentMode !== 'table',
177
- limitTags: 1,
178
- ChipProps: {
179
- size: 'small'
180
- }
181
- })
136
+ value && /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
137
+ children: [
138
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorControl, {
139
+ label: "Position",
140
+ control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.SettingsAutocomplete, {
141
+ value: {
142
+ ...legendPositionConfig,
143
+ id: currentPosition
144
+ },
145
+ options: POSITION_OPTIONS,
146
+ onChange: handleLegendPositionChange,
147
+ disableClearable: true
148
+ })
149
+ }),
150
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorControl, {
151
+ label: "Mode",
152
+ control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.ToggleButtonGroup, {
153
+ color: "primary",
154
+ exclusive: true,
155
+ value: currentMode,
156
+ "aria-label": "Mode",
157
+ onChange: (__, newValue)=>{
158
+ onChange({
159
+ ...value,
160
+ position: currentPosition,
161
+ mode: newValue
162
+ });
163
+ },
164
+ children: Object.entries(_model.LEGEND_MODE_CONFIG).map(([modeId, config])=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.ToggleButton, {
165
+ value: modeId,
166
+ selected: currentMode === modeId,
167
+ "aria-label": `display ${modeId} mode`,
168
+ children: config.label
169
+ }, modeId))
170
+ })
171
+ }),
172
+ currentMode === 'table' && /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
173
+ children: [
174
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorControl, {
175
+ label: "Size",
176
+ control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.SettingsAutocomplete, {
177
+ value: {
178
+ ...legendSizeConfig,
179
+ id: currentSize
180
+ },
181
+ options: SIZE_OPTIONS,
182
+ onChange: handleLegendSizeChange,
183
+ // TODO: enable sizes for list mode when we normalize the layout of
184
+ // lists to more closely match tables.
185
+ disableClearable: true
186
+ })
187
+ }),
188
+ showValuesEditor && /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorControl, {
189
+ label: "Values",
190
+ control: // For some reason, the inferred option type doesn't always seem to work
191
+ // quite right when `multiple` is true. Explicitly setting the generics
192
+ // to work around this.
193
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.SettingsAutocomplete, {
194
+ multiple: true,
195
+ disableCloseOnSelect: true,
196
+ disableClearable: true,
197
+ value: legendValuesConfig,
198
+ options: valueOptions,
199
+ onChange: handleLegendValueChange,
200
+ limitTags: 1,
201
+ ChipProps: {
202
+ size: 'small'
203
+ }
204
+ })
205
+ })
206
+ ]
207
+ })
208
+ ]
182
209
  })
183
210
  ]
184
211
  });
@@ -60,7 +60,8 @@ function useDefaultQueryDefinition(queryTypes) {
60
60
  isLoading
61
61
  };
62
62
  }
63
- function MultiQueryEditor({ queryTypes, queries = [], onChange }) {
63
+ const MultiQueryEditor = /*#__PURE__*/ (0, _react.forwardRef)((props, ref)=>{
64
+ const { queryTypes, queries = [], onChange } = props;
64
65
  const { defaultInitialQueryDefinition, isLoading } = useDefaultQueryDefinition(queryTypes);
65
66
  // State for which queries are collapsed
66
67
  const [queriesCollapsed, setQueriesCollapsed] = (0, _react.useState)(queries.map(()=>false));
@@ -122,6 +123,7 @@ function MultiQueryEditor({ queryTypes, queries = [], onChange }) {
122
123
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
123
124
  spacing: 1,
124
125
  children: queryDefinitions.map((query, i)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_QueryEditorContainer.QueryEditorContainer, {
126
+ ref: ref,
125
127
  queryTypes: queryTypes,
126
128
  index: i,
127
129
  query: query,
@@ -142,4 +144,5 @@ function MultiQueryEditor({ queryTypes, queries = [], onChange }) {
142
144
  })
143
145
  ]
144
146
  });
145
- }
147
+ });
148
+ MultiQueryEditor.displayName = 'MultiQueryEditor';
@@ -26,13 +26,16 @@ const _material = require("@mui/material");
26
26
  const _DeleteOutline = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/DeleteOutline"));
27
27
  const _ChevronDown = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/ChevronDown"));
28
28
  const _ChevronRight = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/ChevronRight"));
29
+ const _react = require("react");
29
30
  const _PluginEditor = require("../PluginEditor");
31
+ const _runtime = require("../../runtime");
30
32
  function _interop_require_default(obj) {
31
33
  return obj && obj.__esModule ? obj : {
32
34
  default: obj
33
35
  };
34
36
  }
35
- const QueryEditorContainer = ({ queryTypes, index, query, isCollapsed, onDelete, onChange, onCollapseExpand })=>{
37
+ const QueryEditorContainer = /*#__PURE__*/ (0, _react.forwardRef)((props, ref)=>{
38
+ const { queryTypes, index, query, isCollapsed, onDelete, onChange, onCollapseExpand } = props;
36
39
  return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
37
40
  spacing: 1,
38
41
  children: [
@@ -68,21 +71,24 @@ const QueryEditorContainer = ({ queryTypes, index, query, isCollapsed, onDelete,
68
71
  ]
69
72
  }),
70
73
  !isCollapsed && /*#__PURE__*/ (0, _jsxruntime.jsx)(QueryEditor, {
74
+ ref: ref,
71
75
  queryTypes: queryTypes,
72
76
  value: query,
73
77
  onChange: (next)=>onChange(index, next)
74
78
  })
75
79
  ]
76
80
  }, index);
77
- };
81
+ });
82
+ QueryEditorContainer.displayName = 'QueryEditorContainer';
78
83
  /**
79
84
  * Editor for a query definition. This component is responsible for rendering the plugin editor for the given query.
80
85
  * This will allow user to select a plugin extending from the given supported query types, and then edit the plugin
81
86
  * spec for this plugin.
82
87
  * @param props
83
88
  * @constructor
84
- */ function QueryEditor(props) {
89
+ */ const QueryEditor = /*#__PURE__*/ (0, _react.forwardRef)((props, ref)=>{
85
90
  const { value, onChange, queryTypes, ...others } = props;
91
+ const { refresh } = (0, _runtime.useTimeRange)();
86
92
  const handlePluginChange = (next)=>{
87
93
  onChange((0, _immer.produce)(value, (draft)=>{
88
94
  draft.kind = next.selection.type;
@@ -93,6 +99,9 @@ const QueryEditorContainer = ({ queryTypes, index, query, isCollapsed, onDelete,
93
99
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
94
100
  ...others,
95
101
  children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_PluginEditor.PluginEditor, {
102
+ postExecuteRunQuery: refresh,
103
+ ref: ref,
104
+ withRunQueryButton: true,
96
105
  pluginTypes: queryTypes,
97
106
  pluginKindLabel: "Query Type",
98
107
  value: {
@@ -105,4 +114,5 @@ const QueryEditorContainer = ({ queryTypes, index, query, isCollapsed, onDelete,
105
114
  onChange: handlePluginChange
106
115
  })
107
116
  });
108
- }
117
+ });
118
+ QueryEditor.displayName = 'QueryEditor';
@@ -23,10 +23,11 @@ Object.defineProperty(exports, "PanelSpecEditor", {
23
23
  const _jsxruntime = require("react/jsx-runtime");
24
24
  const _components = require("@perses-dev/components");
25
25
  const _reacthookform = require("react-hook-form");
26
+ const _react = require("react");
26
27
  const _runtime = require("../../runtime");
27
28
  const _OptionsEditorTabs = require("../OptionsEditorTabs");
28
29
  const _MultiQueryEditor = require("../MultiQueryEditor");
29
- function PanelSpecEditor(props) {
30
+ const PanelSpecEditor = /*#__PURE__*/ (0, _react.forwardRef)((props, ref)=>{
30
31
  const { control, panelDefinition, onJSONChange, onQueriesChange, onPluginSpecChange } = props;
31
32
  const { kind } = panelDefinition.spec.plugin;
32
33
  const { data: plugin, isLoading, error } = (0, _runtime.usePlugin)('Panel', kind);
@@ -35,11 +36,10 @@ function PanelSpecEditor(props) {
35
36
  error: error
36
37
  });
37
38
  }
38
- // TODO: Proper loading indicator
39
39
  if (isLoading) {
40
40
  return null;
41
41
  }
42
- if (plugin === undefined) {
42
+ if (!plugin) {
43
43
  throw new Error(`Missing implementation for panel plugin with kind '${kind}'`);
44
44
  }
45
45
  const { panelOptionsEditorComponents, hideQueryEditor } = plugin;
@@ -51,6 +51,7 @@ function PanelSpecEditor(props) {
51
51
  control: control,
52
52
  name: "panelDefinition.spec.queries",
53
53
  render: ({ field })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_MultiQueryEditor.MultiQueryEditor, {
54
+ ref: ref,
54
55
  queryTypes: plugin.supportedQueryTypes ?? [],
55
56
  queries: panelDefinition.spec.queries ?? [],
56
57
  onChange: (queries)=>{
@@ -61,7 +62,7 @@ function PanelSpecEditor(props) {
61
62
  })
62
63
  });
63
64
  }
64
- if (panelOptionsEditorComponents !== undefined) {
65
+ if (panelOptionsEditorComponents) {
65
66
  tabs = tabs.concat(panelOptionsEditorComponents.map(({ label, content: OptionsEditorComponent })=>({
66
67
  label,
67
68
  content: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
@@ -105,4 +106,5 @@ function PanelSpecEditor(props) {
105
106
  tabs: tabs
106
107
  }, tabs.length)
107
108
  });
108
- }
109
+ });
110
+ PanelSpecEditor.displayName = 'PanelSpecEditor';
@@ -24,6 +24,7 @@ const _jsxruntime = require("react/jsx-runtime");
24
24
  const _material = require("@mui/material");
25
25
  const _Reload = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Reload"));
26
26
  const _components = require("@perses-dev/components");
27
+ const _react = require("react");
27
28
  const _PluginKindSelect = require("../PluginKindSelect");
28
29
  const _PluginSpecEditor = require("../PluginSpecEditor");
29
30
  const _plugineditorapi = require("./plugin-editor-api");
@@ -32,23 +33,63 @@ function _interop_require_default(obj) {
32
33
  default: obj
33
34
  };
34
35
  }
35
- function PluginEditor(props) {
36
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
37
- const { value, pluginTypes, pluginKindLabel, onChange: _, isReadonly, ...others } = props;
36
+ const PluginEditor = /*#__PURE__*/ (0, _react.forwardRef)((props, ref)=>{
37
+ const { value, withRunQueryButton = true, pluginTypes, pluginKindLabel, onChange: _, isReadonly, postExecuteRunQuery: refresh, ...others } = props;
38
38
  const { pendingSelection, isLoading, error, onSelectionChange, onSpecChange } = (0, _plugineditorapi.usePluginEditor)(props);
39
+ /*
40
+ We could technically merge the watchedQuery, watchedOtherSpecs into a single watched-object,
41
+ because at the end of the day, they are all specs.
42
+ However, let's have them separated to keep the code simple and readable.
43
+ Reason: Only Query string field is common between all of them. Other specs may be different
44
+ Example: Legend, and MinSteps
45
+ */ const [watchedQuery, setWatchQuery] = (0, _react.useState)(value.spec['query']);
46
+ const [watchedOtherSpecs, setWatchOtherSpecs] = (0, _react.useState)(value.spec);
47
+ const runQueryHandler = (0, _react.useCallback)(()=>{
48
+ onSpecChange({
49
+ ...value.spec,
50
+ ...watchedOtherSpecs,
51
+ query: watchedQuery
52
+ });
53
+ refresh?.();
54
+ }, [
55
+ value.spec,
56
+ onSpecChange,
57
+ watchedQuery,
58
+ watchedOtherSpecs,
59
+ refresh
60
+ ]);
61
+ const queryHandlerSettings = (0, _react.useMemo)(()=>{
62
+ return withRunQueryButton ? {
63
+ runWithOnBlur: false,
64
+ watchQueryChanges: (query)=>{
65
+ setWatchQuery(query);
66
+ },
67
+ setWatchOtherSpecs: (otherSpecs)=>{
68
+ setWatchOtherSpecs(otherSpecs);
69
+ }
70
+ } : undefined;
71
+ }, [
72
+ withRunQueryButton
73
+ ]);
74
+ (0, _react.useImperativeHandle)(ref, ()=>({
75
+ flushChanges: runQueryHandler
76
+ }));
39
77
  return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
40
78
  ...others,
41
79
  children: [
42
80
  /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
43
81
  sx: {
44
82
  display: 'flex',
45
- flexDirection: 'row'
83
+ flexDirection: 'row',
84
+ alignItems: 'center',
85
+ justifyContent: 'space-between',
86
+ gap: 1,
87
+ mb: 1
46
88
  },
47
89
  children: [
48
90
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_PluginKindSelect.PluginKindSelect, {
49
91
  fullWidth: false,
50
92
  sx: {
51
- mb: 2,
52
93
  minWidth: 120
53
94
  },
54
95
  margin: "dense",
@@ -56,23 +97,20 @@ function PluginEditor(props) {
56
97
  pluginTypes: pluginTypes,
57
98
  disabled: isLoading,
58
99
  value: pendingSelection ? pendingSelection : value.selection,
59
- InputProps: {
60
- readOnly: isReadonly
100
+ slotProps: {
101
+ input: {
102
+ readOnly: isReadonly
103
+ }
61
104
  },
62
105
  error: !!error,
63
106
  helperText: error?.message,
64
107
  onChange: onSelectionChange
65
108
  }),
66
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
109
+ withRunQueryButton && !isLoading && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
110
+ "data-testid": "run_query_button",
67
111
  variant: "contained",
68
- sx: {
69
- marginTop: 1.5,
70
- marginBottom: 1.5,
71
- paddingTop: 0.5,
72
- marginLeft: 'auto'
73
- },
74
112
  startIcon: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Reload.default, {}),
75
- onClick: ()=>onSpecChange(value.spec),
113
+ onClick: runQueryHandler,
76
114
  children: "Run Query"
77
115
  })
78
116
  ]
@@ -83,9 +121,11 @@ function PluginEditor(props) {
83
121
  pluginSelection: value.selection,
84
122
  value: value.spec,
85
123
  onChange: onSpecChange,
86
- isReadonly: isReadonly
124
+ isReadonly: isReadonly,
125
+ queryHandlerSettings: queryHandlerSettings
87
126
  })
88
127
  })
89
128
  ]
90
129
  });
91
- }
130
+ });
131
+ PluginEditor.displayName = 'PluginEditor';
@@ -27,6 +27,9 @@ const _runtime = require("../../runtime");
27
27
  const PluginKindSelect = /*#__PURE__*/ (0, _react.forwardRef)((props, ref)=>{
28
28
  const { pluginTypes, value: propValue, onChange, ...others } = props;
29
29
  const { data, isLoading } = (0, _runtime.useListPluginMetadata)(pluginTypes);
30
+ const sortedData = (0, _react.useMemo)(()=>data?.sort((a, b)=>a.spec.display.name.localeCompare(b.spec.display.name)), [
31
+ data
32
+ ]);
30
33
  // Pass an empty value while options are still loading so MUI doesn't complain about us using an "out of range" value
31
34
  const value = !propValue || isLoading ? '' : selectionToOptionValue(propValue);
32
35
  const handleChange = (event)=>{
@@ -37,9 +40,9 @@ const PluginKindSelect = /*#__PURE__*/ (0, _react.forwardRef)((props, ref)=>{
37
40
  return '';
38
41
  }
39
42
  const selectedValue = optionValueToSelection(selected);
40
- return data?.find((v)=>v.kind === selectedValue.type && v.spec.name === selectedValue.kind)?.spec.display.name;
43
+ return sortedData?.find((v)=>v.kind === selectedValue.type && v.spec.name === selectedValue.kind)?.spec.display.name;
41
44
  }, [
42
- data
45
+ sortedData
43
46
  ]);
44
47
  // TODO: Does this need a loading indicator of some kind?
45
48
  return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.TextField, {
@@ -58,7 +61,7 @@ const PluginKindSelect = /*#__PURE__*/ (0, _react.forwardRef)((props, ref)=>{
58
61
  value: "",
59
62
  children: "Loading..."
60
63
  }),
61
- data?.map((metadata)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
64
+ sortedData?.map((metadata)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
62
65
  "data-testid": "option",
63
66
  value: selectionToOptionValue({
64
67
  type: metadata.kind,
@@ -22,6 +22,7 @@ Object.defineProperty(exports, "PluginSpecEditor", {
22
22
  });
23
23
  const _jsxruntime = require("react/jsx-runtime");
24
24
  const _components = require("@perses-dev/components");
25
+ const _material = require("@mui/material");
25
26
  const _runtime = require("../../runtime");
26
27
  function PluginSpecEditor(props) {
27
28
  const { pluginSelection: { type: pluginType, kind: pluginKind }, ...others } = props;
@@ -31,21 +32,24 @@ function PluginSpecEditor(props) {
31
32
  error: error
32
33
  });
33
34
  }
34
- // TODO: Proper loading indicator
35
35
  if (isLoading) {
36
- return null;
36
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
37
+ width: "100%",
38
+ sx: {
39
+ alignItems: 'center',
40
+ justifyContent: 'center'
41
+ },
42
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.CircularProgress, {})
43
+ });
37
44
  }
38
- if (plugin === undefined) {
45
+ if (!plugin) {
39
46
  throw new Error(`Missing implementation for ${pluginType} plugin with kind '${pluginKind}'`);
40
47
  }
41
48
  if (pluginType === 'Panel') {
42
49
  throw new Error('This editor should not be used for panel type. Please use Panel Spec Editor instead.');
43
50
  }
44
51
  const { OptionsEditorComponent } = plugin;
45
- if (OptionsEditorComponent !== undefined) {
46
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(OptionsEditorComponent, {
47
- ...others
48
- });
49
- }
50
- return null;
52
+ return OptionsEditorComponent ? /*#__PURE__*/ (0, _jsxruntime.jsx)(OptionsEditorComponent, {
53
+ ...others
54
+ }) : null;
51
55
  }