@perses-dev/plugin-system 0.44.0 → 0.45.0-rc0

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 (122) hide show
  1. package/dist/cjs/components/DatasourceEditorForm/DatasourceEditorForm.js +12 -3
  2. package/dist/cjs/components/{TimeSeriesQueryEditor/TimeSeriesQueryEditor.js → MultiQueryEditor/MultiQueryEditor.js} +35 -37
  3. package/dist/cjs/components/{TimeSeriesQueryEditor/TimeSeriesQueryInput.js → MultiQueryEditor/QueryEditorContainer.js} +22 -10
  4. package/dist/cjs/components/{TimeSeriesQueryEditor → MultiQueryEditor}/index.js +2 -2
  5. package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +12 -46
  6. package/dist/cjs/components/PluginEditor/PluginEditor.js +6 -7
  7. package/dist/cjs/components/PluginEditor/plugin-editor-api.js +43 -31
  8. package/dist/cjs/components/PluginKindSelect/PluginKindSelect.js +25 -5
  9. package/dist/cjs/components/PluginRegistry/PluginRegistry.js +5 -3
  10. package/dist/cjs/components/PluginSpecEditor/PluginSpecEditor.js +1 -1
  11. package/dist/cjs/components/ProjectSelect.js +3 -2
  12. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +192 -0
  13. package/dist/cjs/components/{TraceQueryEditor → TimeRangeControls}/index.js +1 -1
  14. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +16 -4
  15. package/dist/cjs/components/index.js +2 -1
  16. package/dist/cjs/constants/user-interface-text.js +4 -1
  17. package/dist/cjs/runtime/DataQueriesProvider/model.js +6 -2
  18. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +8 -0
  19. package/dist/cjs/runtime/plugin-registry.js +7 -5
  20. package/dist/cjs/validation/resource.js +1 -1
  21. package/dist/cjs/validation/user.js +46 -0
  22. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -1
  23. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +12 -3
  24. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
  25. package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts +16 -0
  26. package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts.map +1 -0
  27. package/dist/components/{TimeSeriesQueryEditor/TimeSeriesQueryEditor.js → MultiQueryEditor/MultiQueryEditor.js} +42 -37
  28. package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -0
  29. package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts +28 -0
  30. package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts.map +1 -0
  31. package/dist/components/{TimeSeriesQueryEditor/TimeSeriesQueryInput.js → MultiQueryEditor/QueryEditorContainer.js} +32 -9
  32. package/dist/components/MultiQueryEditor/QueryEditorContainer.js.map +1 -0
  33. package/dist/components/MultiQueryEditor/index.d.ts +2 -0
  34. package/dist/components/MultiQueryEditor/index.d.ts.map +1 -0
  35. package/dist/components/{TimeSeriesQueryEditor → MultiQueryEditor}/index.js +2 -2
  36. package/dist/components/{TraceQueryEditor → MultiQueryEditor}/index.js.map +1 -1
  37. package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -1
  38. package/dist/components/PanelSpecEditor/PanelSpecEditor.js +13 -47
  39. package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
  40. package/dist/components/PluginEditor/PluginEditor.d.ts.map +1 -1
  41. package/dist/components/PluginEditor/PluginEditor.js +6 -7
  42. package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
  43. package/dist/components/PluginEditor/plugin-editor-api.d.ts +15 -9
  44. package/dist/components/PluginEditor/plugin-editor-api.d.ts.map +1 -1
  45. package/dist/components/PluginEditor/plugin-editor-api.js +43 -31
  46. package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
  47. package/dist/components/PluginKindSelect/PluginKindSelect.d.ts +10 -4
  48. package/dist/components/PluginKindSelect/PluginKindSelect.d.ts.map +1 -1
  49. package/dist/components/PluginKindSelect/PluginKindSelect.js +31 -8
  50. package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
  51. package/dist/components/PluginRegistry/PluginRegistry.js +5 -3
  52. package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
  53. package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts +3 -3
  54. package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts.map +1 -1
  55. package/dist/components/PluginSpecEditor/PluginSpecEditor.js +1 -1
  56. package/dist/components/PluginSpecEditor/PluginSpecEditor.js.map +1 -1
  57. package/dist/components/ProjectSelect.js +3 -2
  58. package/dist/components/ProjectSelect.js.map +1 -1
  59. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts +13 -0
  60. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -0
  61. package/dist/components/TimeRangeControls/TimeRangeControls.js +168 -0
  62. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -0
  63. package/dist/components/TimeRangeControls/index.d.ts +2 -0
  64. package/dist/components/TimeRangeControls/index.d.ts.map +1 -0
  65. package/dist/components/{TraceQueryEditor → TimeRangeControls}/index.js +1 -1
  66. package/dist/components/TimeRangeControls/index.js.map +1 -0
  67. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
  68. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +16 -4
  69. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  70. package/dist/components/index.d.ts +2 -1
  71. package/dist/components/index.d.ts.map +1 -1
  72. package/dist/components/index.js +2 -1
  73. package/dist/components/index.js.map +1 -1
  74. package/dist/constants/user-interface-text.d.ts +2 -0
  75. package/dist/constants/user-interface-text.d.ts.map +1 -1
  76. package/dist/constants/user-interface-text.js +4 -1
  77. package/dist/constants/user-interface-text.js.map +1 -1
  78. package/dist/model/panels.d.ts +7 -2
  79. package/dist/model/panels.d.ts.map +1 -1
  80. package/dist/model/panels.js.map +1 -1
  81. package/dist/model/plugin-base.d.ts +0 -1
  82. package/dist/model/plugin-base.d.ts.map +1 -1
  83. package/dist/model/plugin-base.js.map +1 -1
  84. package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
  85. package/dist/runtime/DataQueriesProvider/model.js +6 -2
  86. package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
  87. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts +4 -0
  88. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts.map +1 -1
  89. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +8 -1
  90. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
  91. package/dist/runtime/plugin-registry.d.ts +5 -5
  92. package/dist/runtime/plugin-registry.d.ts.map +1 -1
  93. package/dist/runtime/plugin-registry.js +7 -5
  94. package/dist/runtime/plugin-registry.js.map +1 -1
  95. package/dist/validation/resource.js +1 -1
  96. package/dist/validation/resource.js.map +1 -1
  97. package/dist/validation/user.d.ts +93 -0
  98. package/dist/validation/user.d.ts.map +1 -0
  99. package/dist/validation/user.js +38 -0
  100. package/dist/validation/user.js.map +1 -0
  101. package/package.json +4 -4
  102. package/dist/cjs/components/TraceQueryEditor/TraceQueryEditor.js +0 -143
  103. package/dist/cjs/components/TraceQueryEditor/TraceQueryInput.js +0 -96
  104. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts +0 -7
  105. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts.map +0 -1
  106. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js.map +0 -1
  107. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts +0 -12
  108. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts.map +0 -1
  109. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js.map +0 -1
  110. package/dist/components/TimeSeriesQueryEditor/index.d.ts +0 -2
  111. package/dist/components/TimeSeriesQueryEditor/index.d.ts.map +0 -1
  112. package/dist/components/TimeSeriesQueryEditor/index.js.map +0 -1
  113. package/dist/components/TraceQueryEditor/TraceQueryEditor.d.ts +0 -8
  114. package/dist/components/TraceQueryEditor/TraceQueryEditor.d.ts.map +0 -1
  115. package/dist/components/TraceQueryEditor/TraceQueryEditor.js +0 -130
  116. package/dist/components/TraceQueryEditor/TraceQueryEditor.js.map +0 -1
  117. package/dist/components/TraceQueryEditor/TraceQueryInput.d.ts +0 -12
  118. package/dist/components/TraceQueryEditor/TraceQueryInput.d.ts.map +0 -1
  119. package/dist/components/TraceQueryEditor/TraceQueryInput.js +0 -83
  120. package/dist/components/TraceQueryEditor/TraceQueryInput.js.map +0 -1
  121. package/dist/components/TraceQueryEditor/index.d.ts +0 -2
  122. package/dist/components/TraceQueryEditor/index.d.ts.map +0 -1
@@ -0,0 +1,192 @@
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
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: all[name]
21
+ });
22
+ }
23
+ _export(exports, {
24
+ DEFAULT_REFRESH_INTERVAL_OPTIONS: function() {
25
+ return DEFAULT_REFRESH_INTERVAL_OPTIONS;
26
+ },
27
+ DEFAULT_TIME_RANGE_OPTIONS: function() {
28
+ return DEFAULT_TIME_RANGE_OPTIONS;
29
+ },
30
+ TimeRangeControls: function() {
31
+ return TimeRangeControls;
32
+ }
33
+ });
34
+ const _jsxruntime = require("react/jsx-runtime");
35
+ const _Refresh = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Refresh"));
36
+ const _material = require("@mui/material");
37
+ const _components = require("@perses-dev/components");
38
+ const _react = require("react");
39
+ const _constants = require("../../constants");
40
+ const _runtime = require("../../runtime");
41
+ function _interop_require_default(obj) {
42
+ return obj && obj.__esModule ? obj : {
43
+ default: obj
44
+ };
45
+ }
46
+ const DEFAULT_TIME_RANGE_OPTIONS = [
47
+ {
48
+ value: {
49
+ pastDuration: '5m'
50
+ },
51
+ display: 'Last 5 minutes'
52
+ },
53
+ {
54
+ value: {
55
+ pastDuration: '15m'
56
+ },
57
+ display: 'Last 15 minutes'
58
+ },
59
+ {
60
+ value: {
61
+ pastDuration: '30m'
62
+ },
63
+ display: 'Last 30 minutes'
64
+ },
65
+ {
66
+ value: {
67
+ pastDuration: '1h'
68
+ },
69
+ display: 'Last 1 hour'
70
+ },
71
+ {
72
+ value: {
73
+ pastDuration: '6h'
74
+ },
75
+ display: 'Last 6 hours'
76
+ },
77
+ {
78
+ value: {
79
+ pastDuration: '12h'
80
+ },
81
+ display: 'Last 12 hours'
82
+ },
83
+ {
84
+ value: {
85
+ pastDuration: '24h'
86
+ },
87
+ display: 'Last 1 day'
88
+ },
89
+ {
90
+ value: {
91
+ pastDuration: '7d'
92
+ },
93
+ display: 'Last 7 days'
94
+ },
95
+ {
96
+ value: {
97
+ pastDuration: '14d'
98
+ },
99
+ display: 'Last 14 days'
100
+ }
101
+ ];
102
+ const DEFAULT_REFRESH_INTERVAL_OPTIONS = [
103
+ {
104
+ value: {
105
+ pastDuration: '0s'
106
+ },
107
+ display: 'Off'
108
+ },
109
+ {
110
+ value: {
111
+ pastDuration: '5s'
112
+ },
113
+ display: '5s'
114
+ },
115
+ {
116
+ value: {
117
+ pastDuration: '10s'
118
+ },
119
+ display: '10s'
120
+ },
121
+ {
122
+ value: {
123
+ pastDuration: '15s'
124
+ },
125
+ display: '15s'
126
+ },
127
+ {
128
+ value: {
129
+ pastDuration: '30s'
130
+ },
131
+ display: '30s'
132
+ },
133
+ {
134
+ value: {
135
+ pastDuration: '60s'
136
+ },
137
+ display: '1m'
138
+ }
139
+ ];
140
+ const DEFAULT_HEIGHT = '34px';
141
+ function TimeRangeControls({ heightPx, showTimeRangeSelector = true, showRefreshButton = true, showRefreshInterval = true, timePresets = DEFAULT_TIME_RANGE_OPTIONS }) {
142
+ const { timeRange, setTimeRange, refresh, refreshInterval, setRefreshInterval } = (0, _runtime.useTimeRange)();
143
+ // Convert height to a string, then use the string for styling
144
+ const height = heightPx === undefined ? DEFAULT_HEIGHT : `${heightPx}px`;
145
+ // add time preset if one does not match duration given in time range
146
+ if ('pastDuration' in timeRange && !timePresets.some((option)=>option.value.pastDuration === timeRange['pastDuration'])) {
147
+ timePresets.push({
148
+ value: {
149
+ pastDuration: timeRange['pastDuration']
150
+ },
151
+ display: `Last ${timeRange['pastDuration']}`
152
+ });
153
+ }
154
+ // set the new refresh interval both in the dashboard context & as query param
155
+ const handleRefreshIntervalChange = (0, _react.useCallback)((duration)=>{
156
+ setRefreshInterval(duration);
157
+ }, [
158
+ setRefreshInterval
159
+ ]);
160
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
161
+ direction: "row",
162
+ spacing: 1,
163
+ children: [
164
+ showTimeRangeSelector && /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.DateTimeRangePicker, {
165
+ timeOptions: timePresets,
166
+ value: timeRange,
167
+ onChange: setTimeRange,
168
+ height: height
169
+ }),
170
+ showRefreshButton && /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.InfoTooltip, {
171
+ description: _constants.TOOLTIP_TEXT.refresh,
172
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ToolbarIconButton, {
173
+ "aria-label": _constants.TOOLTIP_TEXT.refresh,
174
+ onClick: refresh,
175
+ sx: {
176
+ height
177
+ },
178
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Refresh.default, {})
179
+ })
180
+ }),
181
+ showRefreshInterval && /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.InfoTooltip, {
182
+ description: _constants.TOOLTIP_TEXT.refreshInterval,
183
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.RefreshIntervalPicker, {
184
+ timeOptions: DEFAULT_REFRESH_INTERVAL_OPTIONS,
185
+ value: refreshInterval,
186
+ onChange: handleRefreshIntervalChange,
187
+ height: height
188
+ })
189
+ })
190
+ ]
191
+ });
192
+ }
@@ -14,7 +14,7 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
- _export_star(require("./TraceQueryEditor"), exports);
17
+ _export_star(require("./TimeRangeControls"), exports);
18
18
  function _export_star(from, to) {
19
19
  Object.keys(from).forEach(function(k) {
20
20
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
@@ -448,14 +448,26 @@ function VariableEditorForm(props) {
448
448
  name: "listVariableFields.plugin",
449
449
  render: ({ field })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_PluginEditor.PluginEditor, {
450
450
  width: "100%",
451
- pluginType: "Variable",
451
+ pluginTypes: [
452
+ 'Variable'
453
+ ],
452
454
  pluginKindLabel: "Source",
453
455
  isReadonly: action === 'read',
454
- value: state.listVariableFields.plugin,
456
+ value: {
457
+ selection: {
458
+ kind: state.listVariableFields.plugin.kind,
459
+ type: 'Variable'
460
+ },
461
+ spec: state.listVariableFields.plugin.spec
462
+ },
455
463
  onChange: (val)=>{
456
- field.onChange(val);
464
+ field.onChange({
465
+ spec: val.spec,
466
+ kind: val.selection.kind
467
+ });
457
468
  setState((draft)=>{
458
- draft.listVariableFields.plugin = val;
469
+ draft.listVariableFields.plugin.kind = val.selection.kind;
470
+ draft.listVariableFields.plugin.spec = val.spec;
459
471
  });
460
472
  }
461
473
  })
@@ -18,6 +18,7 @@ _export_star(require("./CalculationSelector"), exports);
18
18
  _export_star(require("./DatasourceEditorForm"), exports);
19
19
  _export_star(require("./DatasourceSelect"), exports);
20
20
  _export_star(require("./LegendOptionsEditor"), exports);
21
+ _export_star(require("./MultiQueryEditor"), exports);
21
22
  _export_star(require("./OptionsEditorRadios"), exports);
22
23
  _export_star(require("./OptionsEditorTabs"), exports);
23
24
  _export_star(require("./PanelSpecEditor"), exports);
@@ -25,7 +26,7 @@ _export_star(require("./PluginEditor"), exports);
25
26
  _export_star(require("./PluginKindSelect"), exports);
26
27
  _export_star(require("./PluginRegistry"), exports);
27
28
  _export_star(require("./PluginSpecEditor"), exports);
28
- _export_star(require("./TimeSeriesQueryEditor"), exports);
29
+ _export_star(require("./TimeRangeControls"), exports);
29
30
  _export_star(require("./Variables"), exports);
30
31
  _export_star(require("./ProjectSelect"), exports);
31
32
  function _export_star(from, to) {
@@ -23,5 +23,8 @@ Object.defineProperty(exports, "TOOLTIP_TEXT", {
23
23
  const TOOLTIP_TEXT = {
24
24
  // Variable editor buttons
25
25
  refreshVariableValues: 'Refresh values',
26
- copyVariableValues: 'Copy values to clipboard'
26
+ copyVariableValues: 'Copy values to clipboard',
27
+ // Time range controls buttons
28
+ refresh: 'Refresh',
29
+ refreshInterval: 'Auto refresh interval'
27
30
  };
@@ -43,8 +43,12 @@ function transformQueryResults(results, definitions) {
43
43
  });
44
44
  }
45
45
  function useQueryType() {
46
- const { data: timeSeriesQueryPlugins, isLoading: isTimeSeriesQueryLoading } = (0, _pluginregistry.useListPluginMetadata)('TimeSeriesQuery');
47
- const { data: traceQueryPlugins, isLoading: isTraceQueryPluginLoading } = (0, _pluginregistry.useListPluginMetadata)('TraceQuery');
46
+ const { data: timeSeriesQueryPlugins, isLoading: isTimeSeriesQueryLoading } = (0, _pluginregistry.useListPluginMetadata)([
47
+ 'TimeSeriesQuery'
48
+ ]);
49
+ const { data: traceQueryPlugins, isLoading: isTraceQueryPluginLoading } = (0, _pluginregistry.useListPluginMetadata)([
50
+ 'TraceQuery'
51
+ ]);
48
52
  // For example, `map: {"TimeSeriesQuery":["PrometheusTimeSeriesQuery"],"TraceQuery":["TempoTraceQuery"]}`
49
53
  const queryTypeMap = (0, _react.useMemo)(()=>{
50
54
  const map = {
@@ -27,6 +27,9 @@ _export(exports, {
27
27
  TimeRangeProvider: function() {
28
28
  return TimeRangeProvider;
29
29
  },
30
+ useSuggestedStepMs: function() {
31
+ return useSuggestedStepMs;
32
+ },
30
33
  useTimeRange: function() {
31
34
  return useTimeRange;
32
35
  },
@@ -90,6 +93,11 @@ function useTimeRangeContext() {
90
93
  function useTimeRange() {
91
94
  return useTimeRangeContext();
92
95
  }
96
+ function useSuggestedStepMs(width) {
97
+ const { absoluteTimeRange } = useTimeRange();
98
+ if (width === undefined) return 0;
99
+ return (0, _core.getSuggestedStepMs)(absoluteTimeRange, width);
100
+ }
93
101
  function TimeRangeProvider(props) {
94
102
  const { timeRange, refreshInterval, children, setTimeRange, setRefreshInterval } = props;
95
103
  const [localTimeRange, setLocalTimeRange] = (0, _react.useState)(timeRange);
@@ -55,7 +55,7 @@ function usePlugin(pluginType, kind, options) {
55
55
  // We never want to ask for a plugin when the kind isn't set yet, so disable those queries automatically
56
56
  options = {
57
57
  ...options,
58
- enabled: ((_options_enabled = options === null || options === void 0 ? void 0 : options.enabled) !== null && _options_enabled !== void 0 ? _options_enabled : true) && kind !== ''
58
+ enabled: ((_options_enabled = options === null || options === void 0 ? void 0 : options.enabled) !== null && _options_enabled !== void 0 ? _options_enabled : true) && pluginType !== undefined && kind !== ''
59
59
  };
60
60
  const { getPlugin } = usePluginRegistry();
61
61
  return (0, _reactquery.useQuery)([
@@ -79,19 +79,21 @@ function usePlugins(pluginType, plugins) {
79
79
  })
80
80
  });
81
81
  }
82
- function useListPluginMetadata(pluginType, options) {
82
+ function useListPluginMetadata(pluginTypes, options) {
83
83
  const { listPluginMetadata } = usePluginRegistry();
84
84
  return (0, _reactquery.useQuery)([
85
85
  'listPluginMetadata',
86
- pluginType
87
- ], ()=>listPluginMetadata(pluginType), options);
86
+ pluginTypes
87
+ ], ()=>listPluginMetadata(pluginTypes), options);
88
88
  }
89
89
  function usePluginBuiltinVariableDefinitions() {
90
90
  const { getPlugin, listPluginMetadata } = usePluginRegistry();
91
91
  return (0, _reactquery.useQuery)([
92
92
  'usePluginBuiltinVariableDefinitions'
93
93
  ], async ()=>{
94
- const datasources = await listPluginMetadata('Datasource');
94
+ const datasources = await listPluginMetadata([
95
+ 'Datasource'
96
+ ]);
95
97
  const datasourceKinds = new Set(datasources.map((datasource)=>datasource.kind));
96
98
  const result = [];
97
99
  for (const kind of datasourceKinds){
@@ -21,4 +21,4 @@ Object.defineProperty(exports, "resourceIdValidationSchema", {
21
21
  }
22
22
  });
23
23
  const _zod = require("zod");
24
- const resourceIdValidationSchema = _zod.z.string().nonempty('Required').max(75, 'Must be 75 or fewer characters long').regex(/^[a-zA-Z0-9_.-]+$/, 'Must only contains alphanumerical characters and special characters _ . -');
24
+ const resourceIdValidationSchema = _zod.z.string().min(1, 'Required').max(75, 'Must be 75 or fewer characters long').regex(/^[a-zA-Z0-9_.-]+$/, 'Must only contains alphanumerical characters and special characters _ . -');
@@ -0,0 +1,46 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "userEditorValidationSchema", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return userEditorValidationSchema;
21
+ }
22
+ });
23
+ const _zod = require("zod");
24
+ const _resource = require("./resource");
25
+ const nativeProviderSchema = _zod.z.object({
26
+ password: _zod.z.string().optional()
27
+ });
28
+ const oauthProvidersSchema = _zod.z.object({
29
+ issuer: _zod.z.string().optional(),
30
+ email: _zod.z.string().optional(),
31
+ subject: _zod.z.string().optional()
32
+ });
33
+ // TODO: handle exclusion native / oauth?
34
+ const userSpecSchema = _zod.z.object({
35
+ firstName: _zod.z.string().optional(),
36
+ lastName: _zod.z.string().optional(),
37
+ nativeProvider: nativeProviderSchema.optional(),
38
+ oauthProviders: _zod.z.array(oauthProvidersSchema).optional()
39
+ });
40
+ const userEditorValidationSchema = _zod.z.object({
41
+ kind: _zod.z.literal('User'),
42
+ metadata: _zod.z.object({
43
+ name: _resource.resourceIdValidationSchema
44
+ }),
45
+ spec: userSpecSchema
46
+ });
@@ -1 +1 @@
1
- {"version":3,"file":"DatasourceEditorForm.d.ts","sourceRoot":"","sources":["../../../src/components/DatasourceEditorForm/DatasourceEditorForm.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEhF,OAAO,EAAE,qBAAqB,EAAyB,MAAM,OAAO,CAAC;AA2BrE,UAAU,yBAAyB;IACjC,2BAA2B,EAAE,oBAAoB,CAAC;IAClD,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,KAAK,IAAI,CAAC;IACrD,OAAO,EAAE,qBAAqB,CAAC;IAC/B,QAAQ,CAAC,EAAE,qBAAqB,CAAC;CAClC;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,2CAwOpE"}
1
+ {"version":3,"file":"DatasourceEditorForm.d.ts","sourceRoot":"","sources":["../../../src/components/DatasourceEditorForm/DatasourceEditorForm.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEhF,OAAO,EAAE,qBAAqB,EAAyB,MAAM,OAAO,CAAC;AA2BrE,UAAU,yBAAyB;IACjC,2BAA2B,EAAE,oBAAoB,CAAC;IAClD,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,KAAK,IAAI,CAAC;IACrD,OAAO,EAAE,qBAAqB,CAAC;IAC/B,QAAQ,CAAC,EAAE,qBAAqB,CAAC;CAClC;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,2CA+OpE"}
@@ -314,13 +314,22 @@ export function DatasourceEditorForm(props) {
314
314
  }),
315
315
  /*#__PURE__*/ _jsx(PluginEditor, {
316
316
  width: "100%",
317
- pluginType: "Datasource",
317
+ pluginTypes: [
318
+ 'Datasource'
319
+ ],
318
320
  pluginKindLabel: "Source",
319
- value: state.spec.plugin,
321
+ value: {
322
+ selection: {
323
+ kind: state.spec.plugin.kind,
324
+ type: 'Datasource'
325
+ },
326
+ spec: state.spec.plugin.spec
327
+ },
320
328
  isReadonly: action === 'read',
321
329
  onChange: (v)=>{
322
330
  setState((draft)=>{
323
- draft.spec.plugin = v;
331
+ draft.spec.plugin.kind = v.selection.kind;
332
+ draft.spec.plugin.spec = v.spec;
324
333
  });
325
334
  }
326
335
  })
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/DatasourceEditorForm/DatasourceEditorForm.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 { useImmer } from 'use-immer';\nimport { Action, DatasourceDefinition, DatasourceSpec } from '@perses-dev/core';\nimport { Box, Button, Divider, FormControlLabel, Grid, Stack, Switch, TextField, Typography } from '@mui/material';\nimport { DispatchWithoutAction, useCallback, useState } from 'react';\nimport { DiscardChangesConfirmationDialog } from '@perses-dev/components';\nimport { Controller, FormProvider, SubmitHandler, useForm } from 'react-hook-form';\nimport { zodResolver } from '@hookform/resolvers/zod';\nimport { PluginEditor } from '../PluginEditor';\nimport { getSubmitText, getTitleAction } from '../../utils';\nimport { datasourceEditValidationSchema, DatasourceEditValidationType } from '../../validation';\n\n/**\n * This preprocessing ensures that we always have a defined object for the `display` property\n * @param datasource\n */\nfunction getInitialState(datasourceDefinition: DatasourceDefinition) {\n const patchedDisplay = {\n name: datasourceDefinition.spec.display?.name ?? '',\n description: datasourceDefinition.spec.display?.description ?? '',\n };\n\n return {\n name: datasourceDefinition.name,\n spec: {\n ...datasourceDefinition.spec,\n display: patchedDisplay,\n },\n };\n}\n\ninterface DatasourceEditorFormProps {\n initialDatasourceDefinition: DatasourceDefinition;\n initialAction: Action;\n isDraft: boolean;\n isReadonly?: boolean;\n onSave: (name: string, spec: DatasourceSpec) => void;\n onClose: DispatchWithoutAction;\n onDelete?: DispatchWithoutAction;\n}\n\nexport function DatasourceEditorForm(props: DatasourceEditorFormProps) {\n const { initialDatasourceDefinition, initialAction, isDraft, isReadonly, onSave, onClose, onDelete } = props;\n\n const initialState = getInitialState(initialDatasourceDefinition);\n const [state, setState] = useImmer(initialState);\n const [isDiscardDialogOpened, setDiscardDialogOpened] = useState<boolean>(false);\n const [action, setAction] = useState(initialAction);\n const titleAction = getTitleAction(action, isDraft);\n const submitText = getSubmitText(action, isDraft);\n\n const form = useForm<DatasourceEditValidationType>({\n resolver: zodResolver(datasourceEditValidationSchema),\n mode: 'onBlur',\n defaultValues: {\n name: state.name,\n title: state.spec.display?.name,\n description: state.spec.display?.description,\n default: state.spec.default,\n },\n });\n\n const processForm: SubmitHandler<DatasourceEditValidationType> = () => {\n // reset display attributes to undefined when empty, because we don't want to save empty strings\n onSave(state.name, {\n ...state.spec,\n display: {\n name: state.spec.display?.name === '' ? undefined : state.spec.display?.name,\n description: state.spec.display?.description === '' ? undefined : state.spec.display?.description,\n },\n });\n };\n\n // When user click on cancel, several possibilities:\n // - create action: ask for discard approval\n // - update action: ask for discard approval if changed\n // - read action: don´t ask for discard approval\n const handleCancel = useCallback(() => {\n if (JSON.stringify(initialState) !== JSON.stringify(state)) {\n setDiscardDialogOpened(true);\n } else {\n onClose();\n }\n }, [state, initialState, setDiscardDialogOpened, onClose]);\n\n return (\n <FormProvider {...form}>\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n padding: (theme) => theme.spacing(1, 2),\n borderBottom: (theme) => `1px solid ${theme.palette.divider}`,\n }}\n >\n <Typography variant=\"h2\">{titleAction} Datasource</Typography>\n <Stack direction=\"row\" spacing={1} sx={{ marginLeft: 'auto' }}>\n {action === 'read' ? (\n <>\n <Button disabled={isReadonly} variant=\"contained\" onClick={() => setAction('update')}>\n Edit\n </Button>\n <Button color=\"error\" disabled={isReadonly} variant=\"outlined\" onClick={onDelete}>\n Delete\n </Button>\n <Divider\n orientation=\"vertical\"\n flexItem\n sx={(theme) => ({\n borderColor: theme.palette.grey['500'],\n '&.MuiDivider-root': {\n marginLeft: 2,\n marginRight: 1,\n },\n })}\n />\n <Button color=\"secondary\" variant=\"outlined\" onClick={onClose}>\n Close\n </Button>\n </>\n ) : (\n <>\n <Button variant=\"contained\" disabled={!form.formState.isValid} onClick={form.handleSubmit(processForm)}>\n {submitText}\n </Button>\n <Button color=\"secondary\" variant=\"outlined\" onClick={handleCancel}>\n Cancel\n </Button>\n </>\n )}\n </Stack>\n </Box>\n <Box padding={2} sx={{ overflowY: 'scroll' }}>\n <Grid container spacing={2} mb={2}>\n <Grid item xs={4}>\n <Controller\n name=\"name\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n required\n fullWidth\n name=\"name\"\n label=\"Name\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n disabled: action === 'update' && !isDraft,\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n onChange={(event) => {\n field.onChange(event);\n setState((draft) => {\n draft.name = event.target.value;\n });\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={8}>\n <Controller\n name=\"title\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n name=\"title\"\n label=\"Display Label\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n onChange={(event) => {\n setState((draft) => {\n field.onChange(event);\n if (draft.spec.display) {\n draft.spec.display.name = event.target.value;\n }\n });\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={12}>\n <Controller\n name=\"description\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n name=\"description\"\n label=\"Description\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n onChange={(event) => {\n field.onChange(event);\n setState((draft) => {\n if (draft.spec.display) {\n draft.spec.display.description = event.target.value;\n }\n });\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={6} sx={{ paddingTop: '5px !important' }}>\n <Stack>\n <Controller\n name=\"default\"\n render={({ field }) => (\n <FormControlLabel\n {...field}\n control={\n <Switch\n checked={state.spec.default}\n readOnly={action === 'read'}\n onChange={(event) => {\n if (action === 'read') return; // ReadOnly prop is not blocking user interaction...\n field.onChange(event);\n setState((draft) => {\n draft.spec.default = event.target.checked;\n });\n }}\n />\n }\n label=\"Set as default\"\n />\n )}\n />\n <Typography variant=\"caption\">\n Whether this datasource should be the default {state.spec.plugin.kind} to be used\n </Typography>\n </Stack>\n </Grid>\n </Grid>\n <Divider />\n <Typography py={1} variant=\"h3\">\n Plugin Options\n </Typography>\n <PluginEditor\n width=\"100%\"\n pluginType=\"Datasource\"\n pluginKindLabel=\"Source\"\n value={state.spec.plugin}\n isReadonly={action === 'read'}\n onChange={(v) => {\n setState((draft) => {\n draft.spec.plugin = v;\n });\n }}\n />\n </Box>\n <DiscardChangesConfirmationDialog\n description=\"Are you sure you want to discard your changes? Changes cannot be recovered.\"\n isOpen={isDiscardDialogOpened}\n onCancel={() => setDiscardDialogOpened(false)}\n onDiscardChanges={() => {\n setDiscardDialogOpened(false);\n onClose();\n }}\n />\n </FormProvider>\n );\n}\n"],"names":["useImmer","Box","Button","Divider","FormControlLabel","Grid","Stack","Switch","TextField","Typography","useCallback","useState","DiscardChangesConfirmationDialog","Controller","FormProvider","useForm","zodResolver","PluginEditor","getSubmitText","getTitleAction","datasourceEditValidationSchema","getInitialState","datasourceDefinition","patchedDisplay","name","spec","display","description","DatasourceEditorForm","props","state","initialDatasourceDefinition","initialAction","isDraft","isReadonly","onSave","onClose","onDelete","initialState","setState","isDiscardDialogOpened","setDiscardDialogOpened","action","setAction","titleAction","submitText","form","resolver","mode","defaultValues","title","default","processForm","undefined","handleCancel","JSON","stringify","sx","alignItems","padding","theme","spacing","borderBottom","palette","divider","variant","direction","marginLeft","disabled","onClick","color","orientation","flexItem","borderColor","grey","marginRight","formState","isValid","handleSubmit","overflowY","container","mb","item","xs","render","field","fieldState","required","fullWidth","label","InputLabelProps","shrink","InputProps","readOnly","error","helperText","message","onChange","event","draft","target","value","paddingTop","control","checked","plugin","kind","py","width","pluginType","pluginKindLabel","v","isOpen","onCancel","onDiscardChanges"],"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,QAAQ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AACC,IAAI;gDAAC;;;;;;;;kCAK9E,KAACvG;kCACD,KAACM;wBAAWkG,IAAI;wBAAG1C,SAAQ;kCAAK;;kCAGhC,KAAChD;wBACC2F,OAAM;wBACNC,YAAW;wBACXC,iBAAgB;wBAChBT,OAAOvE,MAAML,IAAI,CAACgF,MAAM;wBACxBvE,YAAYQ,WAAW;wBACvBuD,UAAU,CAACc;4BACTxE,SAAS,CAAC4D;gCACRA,MAAM1E,IAAI,CAACgF,MAAM,GAAGM;4BACtB;wBACF;;;;0BAGJ,KAACnG;gBACCe,aAAY;gBACZqF,QAAQxE;gBACRyE,UAAU,IAAMxE,uBAAuB;gBACvCyE,kBAAkB;oBAChBzE,uBAAuB;oBACvBL;gBACF;;;;AAIR"}
1
+ {"version":3,"sources":["../../../src/components/DatasourceEditorForm/DatasourceEditorForm.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 { useImmer } from 'use-immer';\nimport { Action, DatasourceDefinition, DatasourceSpec } from '@perses-dev/core';\nimport { Box, Button, Divider, FormControlLabel, Grid, Stack, Switch, TextField, Typography } from '@mui/material';\nimport { DispatchWithoutAction, useCallback, useState } from 'react';\nimport { DiscardChangesConfirmationDialog } from '@perses-dev/components';\nimport { Controller, FormProvider, SubmitHandler, useForm } from 'react-hook-form';\nimport { zodResolver } from '@hookform/resolvers/zod';\nimport { PluginEditor } from '../PluginEditor';\nimport { getSubmitText, getTitleAction } from '../../utils';\nimport { datasourceEditValidationSchema, DatasourceEditValidationType } from '../../validation';\n\n/**\n * This preprocessing ensures that we always have a defined object for the `display` property\n * @param datasource\n */\nfunction getInitialState(datasourceDefinition: DatasourceDefinition) {\n const patchedDisplay = {\n name: datasourceDefinition.spec.display?.name ?? '',\n description: datasourceDefinition.spec.display?.description ?? '',\n };\n\n return {\n name: datasourceDefinition.name,\n spec: {\n ...datasourceDefinition.spec,\n display: patchedDisplay,\n },\n };\n}\n\ninterface DatasourceEditorFormProps {\n initialDatasourceDefinition: DatasourceDefinition;\n initialAction: Action;\n isDraft: boolean;\n isReadonly?: boolean;\n onSave: (name: string, spec: DatasourceSpec) => void;\n onClose: DispatchWithoutAction;\n onDelete?: DispatchWithoutAction;\n}\n\nexport function DatasourceEditorForm(props: DatasourceEditorFormProps) {\n const { initialDatasourceDefinition, initialAction, isDraft, isReadonly, onSave, onClose, onDelete } = props;\n\n const initialState = getInitialState(initialDatasourceDefinition);\n const [state, setState] = useImmer(initialState);\n const [isDiscardDialogOpened, setDiscardDialogOpened] = useState<boolean>(false);\n const [action, setAction] = useState(initialAction);\n const titleAction = getTitleAction(action, isDraft);\n const submitText = getSubmitText(action, isDraft);\n\n const form = useForm<DatasourceEditValidationType>({\n resolver: zodResolver(datasourceEditValidationSchema),\n mode: 'onBlur',\n defaultValues: {\n name: state.name,\n title: state.spec.display?.name,\n description: state.spec.display?.description,\n default: state.spec.default,\n },\n });\n\n const processForm: SubmitHandler<DatasourceEditValidationType> = () => {\n // reset display attributes to undefined when empty, because we don't want to save empty strings\n onSave(state.name, {\n ...state.spec,\n display: {\n name: state.spec.display?.name === '' ? undefined : state.spec.display?.name,\n description: state.spec.display?.description === '' ? undefined : state.spec.display?.description,\n },\n });\n };\n\n // When user click on cancel, several possibilities:\n // - create action: ask for discard approval\n // - update action: ask for discard approval if changed\n // - read action: don´t ask for discard approval\n const handleCancel = useCallback(() => {\n if (JSON.stringify(initialState) !== JSON.stringify(state)) {\n setDiscardDialogOpened(true);\n } else {\n onClose();\n }\n }, [state, initialState, setDiscardDialogOpened, onClose]);\n\n return (\n <FormProvider {...form}>\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n padding: (theme) => theme.spacing(1, 2),\n borderBottom: (theme) => `1px solid ${theme.palette.divider}`,\n }}\n >\n <Typography variant=\"h2\">{titleAction} Datasource</Typography>\n <Stack direction=\"row\" spacing={1} sx={{ marginLeft: 'auto' }}>\n {action === 'read' ? (\n <>\n <Button disabled={isReadonly} variant=\"contained\" onClick={() => setAction('update')}>\n Edit\n </Button>\n <Button color=\"error\" disabled={isReadonly} variant=\"outlined\" onClick={onDelete}>\n Delete\n </Button>\n <Divider\n orientation=\"vertical\"\n flexItem\n sx={(theme) => ({\n borderColor: theme.palette.grey['500'],\n '&.MuiDivider-root': {\n marginLeft: 2,\n marginRight: 1,\n },\n })}\n />\n <Button color=\"secondary\" variant=\"outlined\" onClick={onClose}>\n Close\n </Button>\n </>\n ) : (\n <>\n <Button variant=\"contained\" disabled={!form.formState.isValid} onClick={form.handleSubmit(processForm)}>\n {submitText}\n </Button>\n <Button color=\"secondary\" variant=\"outlined\" onClick={handleCancel}>\n Cancel\n </Button>\n </>\n )}\n </Stack>\n </Box>\n <Box padding={2} sx={{ overflowY: 'scroll' }}>\n <Grid container spacing={2} mb={2}>\n <Grid item xs={4}>\n <Controller\n name=\"name\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n required\n fullWidth\n name=\"name\"\n label=\"Name\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n disabled: action === 'update' && !isDraft,\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n onChange={(event) => {\n field.onChange(event);\n setState((draft) => {\n draft.name = event.target.value;\n });\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={8}>\n <Controller\n name=\"title\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n name=\"title\"\n label=\"Display Label\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n onChange={(event) => {\n setState((draft) => {\n field.onChange(event);\n if (draft.spec.display) {\n draft.spec.display.name = event.target.value;\n }\n });\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={12}>\n <Controller\n name=\"description\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n name=\"description\"\n label=\"Description\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n onChange={(event) => {\n field.onChange(event);\n setState((draft) => {\n if (draft.spec.display) {\n draft.spec.display.description = event.target.value;\n }\n });\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={6} sx={{ paddingTop: '5px !important' }}>\n <Stack>\n <Controller\n name=\"default\"\n render={({ field }) => (\n <FormControlLabel\n {...field}\n control={\n <Switch\n checked={state.spec.default}\n readOnly={action === 'read'}\n onChange={(event) => {\n if (action === 'read') return; // ReadOnly prop is not blocking user interaction...\n field.onChange(event);\n setState((draft) => {\n draft.spec.default = event.target.checked;\n });\n }}\n />\n }\n label=\"Set as default\"\n />\n )}\n />\n <Typography variant=\"caption\">\n Whether this datasource should be the default {state.spec.plugin.kind} to be used\n </Typography>\n </Stack>\n </Grid>\n </Grid>\n <Divider />\n <Typography py={1} variant=\"h3\">\n Plugin Options\n </Typography>\n <PluginEditor\n width=\"100%\"\n pluginTypes={['Datasource']}\n pluginKindLabel=\"Source\"\n value={{\n selection: {\n kind: state.spec.plugin.kind,\n type: 'Datasource',\n },\n spec: state.spec.plugin.spec,\n }}\n isReadonly={action === 'read'}\n onChange={(v) => {\n setState((draft) => {\n draft.spec.plugin.kind = v.selection.kind;\n draft.spec.plugin.spec = v.spec;\n });\n }}\n />\n </Box>\n <DiscardChangesConfirmationDialog\n description=\"Are you sure you want to discard your changes? Changes cannot be recovered.\"\n isOpen={isDiscardDialogOpened}\n onCancel={() => setDiscardDialogOpened(false)}\n onDiscardChanges={() => {\n setDiscardDialogOpened(false);\n onClose();\n }}\n />\n </FormProvider>\n );\n}\n"],"names":["useImmer","Box","Button","Divider","FormControlLabel","Grid","Stack","Switch","TextField","Typography","useCallback","useState","DiscardChangesConfirmationDialog","Controller","FormProvider","useForm","zodResolver","PluginEditor","getSubmitText","getTitleAction","datasourceEditValidationSchema","getInitialState","datasourceDefinition","patchedDisplay","name","spec","display","description","DatasourceEditorForm","props","state","initialDatasourceDefinition","initialAction","isDraft","isReadonly","onSave","onClose","onDelete","initialState","setState","isDiscardDialogOpened","setDiscardDialogOpened","action","setAction","titleAction","submitText","form","resolver","mode","defaultValues","title","default","processForm","undefined","handleCancel","JSON","stringify","sx","alignItems","padding","theme","spacing","borderBottom","palette","divider","variant","direction","marginLeft","disabled","onClick","color","orientation","flexItem","borderColor","grey","marginRight","formState","isValid","handleSubmit","overflowY","container","mb","item","xs","render","field","fieldState","required","fullWidth","label","InputLabelProps","shrink","InputProps","readOnly","error","helperText","message","onChange","event","draft","target","value","paddingTop","control","checked","plugin","kind","py","width","pluginTypes","pluginKindLabel","selection","type","v","isOpen","onCancel","onDiscardChanges"],"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,QAAQ,QAAQ,YAAY;AAErC,SAASC,GAAG,EAAEC,MAAM,EAAEC,OAAO,EAAEC,gBAAgB,EAAEC,IAAI,EAAEC,KAAK,EAAEC,MAAM,EAAEC,SAAS,EAAEC,UAAU,QAAQ,gBAAgB;AACnH,SAAgCC,WAAW,EAAEC,QAAQ,QAAQ,QAAQ;AACrE,SAASC,gCAAgC,QAAQ,yBAAyB;AAC1E,SAASC,UAAU,EAAEC,YAAY,EAAiBC,OAAO,QAAQ,kBAAkB;AACnF,SAASC,WAAW,QAAQ,0BAA0B;AACtD,SAASC,YAAY,QA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BACvBuD,UAAU,CAACgB;4BACT1E,SAAS,CAAC4D;gCACRA,MAAM1E,IAAI,CAACgF,MAAM,CAACC,IAAI,GAAGO,EAAEF,SAAS,CAACL,IAAI;gCACzCP,MAAM1E,IAAI,CAACgF,MAAM,CAAChF,IAAI,GAAGwF,EAAExF,IAAI;4BACjC;wBACF;;;;0BAGJ,KAACb;gBACCe,aAAY;gBACZuF,QAAQ1E;gBACR2E,UAAU,IAAM1E,uBAAuB;gBACvC2E,kBAAkB;oBAChB3E,uBAAuB;oBACvBL;gBACF;;;;AAIR"}
@@ -0,0 +1,16 @@
1
+ import { QueryDefinition, QueryPluginType } from '@perses-dev/core';
2
+ export interface MultiQueryEditorProps {
3
+ queryTypes: QueryPluginType[];
4
+ queries?: QueryDefinition[];
5
+ onChange: (queries: QueryDefinition[]) => void;
6
+ }
7
+ /**
8
+ * A component render a list of {@link QueryEditor} for the given query definitions.
9
+ * It allows adding, removing and editing queries.
10
+ * @param queryTypes The list of query types that the underlying editor will propose
11
+ * @param queries The list of query definitions to render
12
+ * @param onChange The callback to call when the queries are modified
13
+ * @constructor
14
+ */
15
+ export declare function MultiQueryEditor({ queryTypes, queries, onChange }: MultiQueryEditorProps): import("react/jsx-runtime").JSX.Element;
16
+ //# sourceMappingURL=MultiQueryEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MultiQueryEditor.d.ts","sourceRoot":"","sources":["../../../src/components/MultiQueryEditor/MultiQueryEditor.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAA6B,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAI/F,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,eAAe,EAAE,CAAC;IAC9B,OAAO,CAAC,EAAE,eAAe,EAAE,CAAC;IAC5B,QAAQ,EAAE,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,IAAI,CAAC;CAChD;AA6BD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,UAAU,EAAE,OAAY,EAAE,QAAQ,EAAE,EAAE,qBAAqB,2CA8E7F"}