@perses-dev/plugin-system 0.54.0-beta.9 → 0.54.0-rc.0

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 (51) hide show
  1. package/dist/cjs/components/LinksEditor/LinksEditor.js +162 -0
  2. package/dist/cjs/components/LinksEditor/index.js +30 -0
  3. package/dist/cjs/components/MultiQueryEditor/MultiQueryEditor.js +2 -2
  4. package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +2 -1
  5. package/dist/cjs/components/index.js +1 -0
  6. package/dist/cjs/context/ValidationProvider.js +3 -2
  7. package/dist/cjs/index.js +1 -0
  8. package/dist/cjs/remote/PluginRuntime.js +12 -12
  9. package/dist/cjs/schema/index.js +30 -0
  10. package/dist/cjs/schema/panel.js +42 -0
  11. package/dist/components/LinksEditor/LinksEditor.d.ts +8 -0
  12. package/dist/components/LinksEditor/LinksEditor.d.ts.map +1 -0
  13. package/dist/components/LinksEditor/LinksEditor.js +149 -0
  14. package/dist/components/LinksEditor/LinksEditor.js.map +1 -0
  15. package/dist/components/LinksEditor/index.d.ts +2 -0
  16. package/dist/components/LinksEditor/index.d.ts.map +1 -0
  17. package/dist/components/LinksEditor/index.js +15 -0
  18. package/dist/components/LinksEditor/index.js.map +1 -0
  19. package/dist/components/MultiQueryEditor/MultiQueryEditor.js +2 -2
  20. package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -1
  21. package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts +2 -1
  22. package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -1
  23. package/dist/components/PanelSpecEditor/PanelSpecEditor.js +2 -1
  24. package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
  25. package/dist/components/index.d.ts +1 -0
  26. package/dist/components/index.d.ts.map +1 -1
  27. package/dist/components/index.js +1 -0
  28. package/dist/components/index.js.map +1 -1
  29. package/dist/context/ValidationProvider.d.ts +2 -1
  30. package/dist/context/ValidationProvider.d.ts.map +1 -1
  31. package/dist/context/ValidationProvider.js +2 -1
  32. package/dist/context/ValidationProvider.js.map +1 -1
  33. package/dist/index.d.ts +1 -0
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +1 -0
  36. package/dist/index.js.map +1 -1
  37. package/dist/model/panels.d.ts +9 -1
  38. package/dist/model/panels.d.ts.map +1 -1
  39. package/dist/model/panels.js +3 -1
  40. package/dist/model/panels.js.map +1 -1
  41. package/dist/remote/PluginRuntime.js +12 -12
  42. package/dist/remote/PluginRuntime.js.map +1 -1
  43. package/dist/schema/index.d.ts +2 -0
  44. package/dist/schema/index.d.ts.map +1 -0
  45. package/dist/schema/index.js +15 -0
  46. package/dist/schema/index.js.map +1 -0
  47. package/dist/schema/panel.d.ts +6 -0
  48. package/dist/schema/panel.d.ts.map +1 -0
  49. package/dist/schema/panel.js +26 -0
  50. package/dist/schema/panel.js.map +1 -0
  51. package/package.json +4 -4
@@ -0,0 +1,162 @@
1
+ // Copyright 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, "LinksEditor", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return LinksEditor;
21
+ }
22
+ });
23
+ const _jsxruntime = require("react/jsx-runtime");
24
+ const _react = require("react");
25
+ const _material = require("@mui/material");
26
+ const _reacthookform = require("react-hook-form");
27
+ const _Plus = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Plus"));
28
+ const _Minus = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Minus"));
29
+ const _components = require("@perses-dev/components");
30
+ function _interop_require_default(obj) {
31
+ return obj && obj.__esModule ? obj : {
32
+ default: obj
33
+ };
34
+ }
35
+ function LinksEditor({ control, ...props }) {
36
+ const { fields, append, remove } = (0, _reacthookform.useFieldArray)({
37
+ control: control,
38
+ name: 'panelDefinition.spec.links'
39
+ });
40
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
41
+ ...props,
42
+ gap: 3,
43
+ children: [
44
+ fields && fields.length > 0 ? fields.map((field, index)=>/*#__PURE__*/ (0, _jsxruntime.jsxs)(_react.Fragment, {
45
+ children: [
46
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
47
+ direction: "row",
48
+ gap: 1,
49
+ alignItems: "center",
50
+ children: [
51
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(LinkControl, {
52
+ control: control,
53
+ index: index
54
+ }),
55
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
56
+ style: {
57
+ width: 'fit-content',
58
+ height: 'fit-content'
59
+ },
60
+ onClick: ()=>remove(index),
61
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Minus.default, {})
62
+ })
63
+ ]
64
+ }),
65
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Divider, {})
66
+ ]
67
+ }, field.id)) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
68
+ variant: "subtitle1",
69
+ mb: 2,
70
+ fontStyle: "italic",
71
+ children: "No links defined"
72
+ }),
73
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
74
+ style: {
75
+ width: 'fit-content',
76
+ height: 'fit-content'
77
+ },
78
+ onClick: ()=>append({
79
+ url: '',
80
+ name: '',
81
+ tooltip: '',
82
+ renderVariables: false,
83
+ targetBlank: false
84
+ }),
85
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Plus.default, {})
86
+ })
87
+ ]
88
+ });
89
+ }
90
+ function LinkControl({ control, index }) {
91
+ const defaultLink = {
92
+ url: '',
93
+ name: '',
94
+ tooltip: '',
95
+ renderVariables: false,
96
+ targetBlank: false
97
+ };
98
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
99
+ control: control,
100
+ name: `panelDefinition.spec.links.${index}`,
101
+ render: ({ field, field: { value: link }, fieldState })=>{
102
+ const safeLink = link ?? defaultLink;
103
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.LinkEditorForm, {
104
+ mode: "inline",
105
+ url: {
106
+ value: safeLink.url,
107
+ label: 'URL',
108
+ error: {
109
+ hasError: !!fieldState.error,
110
+ helperText: fieldState.error?.message
111
+ },
112
+ onChange: (url)=>{
113
+ field.onChange({
114
+ ...link,
115
+ url
116
+ });
117
+ }
118
+ },
119
+ newTabOpen: {
120
+ value: !!safeLink.targetBlank,
121
+ onChange: (targetBlank)=>{
122
+ field.onChange({
123
+ ...link,
124
+ targetBlank
125
+ });
126
+ },
127
+ label: 'Open in new tab'
128
+ },
129
+ name: {
130
+ value: safeLink.name ?? '',
131
+ label: 'Name',
132
+ onChange: (name)=>{
133
+ field.onChange({
134
+ ...link,
135
+ name
136
+ });
137
+ }
138
+ },
139
+ renderVariables: {
140
+ value: !!safeLink.renderVariables,
141
+ label: 'Render variables',
142
+ onChange: (renderVariables)=>{
143
+ field.onChange({
144
+ ...link,
145
+ renderVariables
146
+ });
147
+ }
148
+ },
149
+ tooltip: {
150
+ value: safeLink.tooltip ?? '',
151
+ label: 'Tooltip',
152
+ onChange: (tooltip)=>{
153
+ field.onChange({
154
+ ...link,
155
+ tooltip
156
+ });
157
+ }
158
+ }
159
+ });
160
+ }
161
+ });
162
+ }
@@ -0,0 +1,30 @@
1
+ // Copyright 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("./LinksEditor"), 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
+ }
@@ -47,7 +47,7 @@ function useDefaultQueryDefinition(queryTypes, filteredQueryPlugins) {
47
47
  } else {
48
48
  defaultQueryKind = defaultPluginKinds?.[defaultQueryType] ?? queryPlugins?.[0]?.spec.name ?? '';
49
49
  }
50
- const { data: defaultQueryPlugin } = (0, _runtime.usePlugin)(defaultQueryType, defaultQueryKind, {
50
+ const { data: defaultQueryPlugin, isLoading: isPluginLoading } = (0, _runtime.usePlugin)(defaultQueryType, defaultQueryKind, {
51
51
  useErrorBoundary: true,
52
52
  enabled: true
53
53
  });
@@ -62,7 +62,7 @@ function useDefaultQueryDefinition(queryTypes, filteredQueryPlugins) {
62
62
  }
63
63
  }
64
64
  },
65
- isLoading
65
+ isLoading: isLoading || isPluginLoading
66
66
  };
67
67
  }
68
68
  const MultiQueryEditor = /*#__PURE__*/ (0, _react.forwardRef)((props, ref)=>{
@@ -24,6 +24,7 @@ const _jsxruntime = require("react/jsx-runtime");
24
24
  const _components = require("@perses-dev/components");
25
25
  const _reacthookform = require("react-hook-form");
26
26
  const _react = require("react");
27
+ const _LinksEditor = require("../LinksEditor");
27
28
  const _runtime = require("../../runtime");
28
29
  const _OptionsEditorTabs = require("../OptionsEditorTabs");
29
30
  const _MultiQueryEditor = require("../MultiQueryEditor");
@@ -90,7 +91,7 @@ const PanelSpecEditor = /*#__PURE__*/ (0, _react.forwardRef)((props, ref)=>{
90
91
  // always show json editor and links editor by default
91
92
  tabs.push({
92
93
  label: 'Links',
93
- content: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.LinksEditor, {
94
+ content: /*#__PURE__*/ (0, _jsxruntime.jsx)(_LinksEditor.LinksEditor, {
94
95
  control: control
95
96
  })
96
97
  });
@@ -21,6 +21,7 @@ _export_star(require("./DatasourceSelect"), exports);
21
21
  _export_star(require("./HTTPSettingsEditor"), exports);
22
22
  _export_star(require("./ItemSelectionActionsOptionsEditor"), exports);
23
23
  _export_star(require("./LegendOptionsEditor"), exports);
24
+ _export_star(require("./LinksEditor"), exports);
24
25
  _export_star(require("./MultiQueryEditor"), exports);
25
26
  _export_star(require("./OptionsEditorRadios"), exports);
26
27
  _export_star(require("./OptionsEditorTabs"), exports);
@@ -35,6 +35,7 @@ const _jsxruntime = require("react/jsx-runtime");
35
35
  const _react = require("react");
36
36
  const _spec = require("@perses-dev/spec");
37
37
  const _client = require("@perses-dev/client");
38
+ const _schema = require("../schema");
38
39
  const ValidationSchemasContext = /*#__PURE__*/ (0, _react.createContext)(undefined);
39
40
  function useValidationSchemas() {
40
41
  const ctx = (0, _react.useContext)(ValidationSchemasContext);
@@ -45,14 +46,14 @@ function useValidationSchemas() {
45
46
  }
46
47
  function ValidationProvider({ children }) {
47
48
  const [datasourceEditorSchema, setDatasourceEditorSchema] = (0, _react.useState)(_client.datasourceDefinitionSchema);
48
- const [panelEditorSchema, setPanelEditorSchema] = (0, _react.useState)(_spec.panelEditorSchema); // TODO I don't get why this does not compile
49
+ const [panelEditorSchema, setPanelEditorSchema] = (0, _react.useState)(_schema.panelEditorSchema); // TODO I don't get why this does not compile
49
50
  const [variableEditorSchema, setVariableEditorSchema] = (0, _react.useState)(_spec.variableDefinitionSchema);
50
51
  const [annotationEditorSchema, setAnnotationEditorSchema] = (0, _react.useState)(_spec.annotationSpecSchema);
51
52
  function setDatasourceEditorSchemaPlugin(pluginSchema) {
52
53
  setDatasourceEditorSchema((0, _client.buildDatasourceDefinitionSchema)(pluginSchema));
53
54
  }
54
55
  function setPanelEditorSchemaPlugin(pluginSchema) {
55
- setPanelEditorSchema((0, _spec.buildPanelEditorSchema)(pluginSchema));
56
+ setPanelEditorSchema((0, _schema.buildPanelEditorSchema)(pluginSchema));
56
57
  }
57
58
  function setVariableEditorSchemaPlugin(pluginSchema) {
58
59
  setVariableEditorSchema((0, _spec.buildVariableDefinitionSchema)(pluginSchema));
package/dist/cjs/index.js CHANGED
@@ -18,6 +18,7 @@ _export_star(require("./components"), exports);
18
18
  _export_star(require("./constants"), exports);
19
19
  _export_star(require("./model"), exports);
20
20
  _export_star(require("./runtime"), exports);
21
+ _export_star(require("./schema"), exports);
21
22
  _export_star(require("./test-utils"), exports);
22
23
  _export_star(require("./utils"), exports);
23
24
  _export_star(require("./context"), exports);
@@ -148,11 +148,11 @@ const getPluginRuntime = ()=>{
148
148
  }
149
149
  },
150
150
  '@perses-dev/spec': {
151
- version: '0.2.0-beta.2',
151
+ version: '0.2.0-beta.9',
152
152
  lib: ()=>require('@perses-dev/spec'),
153
153
  shareConfig: {
154
154
  singleton: true,
155
- requiredVersion: '^0.2.0-beta.2'
155
+ requiredVersion: '^0.2.0-beta.9'
156
156
  }
157
157
  },
158
158
  '@perses-dev/core': {
@@ -164,43 +164,43 @@ const getPluginRuntime = ()=>{
164
164
  }
165
165
  },
166
166
  '@perses-dev/client': {
167
- version: '0.54.0-beta.1',
167
+ version: '0.54.0-rc.0',
168
168
  lib: ()=>require('@perses-dev/client'),
169
169
  shareConfig: {
170
170
  singleton: true,
171
- requiredVersion: '^0.54.0-beta.1'
171
+ requiredVersion: '^0.54.0-rc.0'
172
172
  }
173
173
  },
174
174
  '@perses-dev/components': {
175
- version: '0.53.1',
175
+ version: '0.54.0-rc.0',
176
176
  lib: ()=>require('@perses-dev/components'),
177
177
  shareConfig: {
178
178
  singleton: true,
179
- requiredVersion: '^0.53.1'
179
+ requiredVersion: '^0.54.0-rc.0'
180
180
  }
181
181
  },
182
182
  '@perses-dev/plugin-system': {
183
- version: '0.53.1',
183
+ version: '0.54.0-rc.0',
184
184
  lib: ()=>require('@perses-dev/plugin-system'),
185
185
  shareConfig: {
186
186
  singleton: true,
187
- requiredVersion: '^0.53.1'
187
+ requiredVersion: '^0.54.0-rc.0'
188
188
  }
189
189
  },
190
190
  '@perses-dev/explore': {
191
- version: '0.53.1',
191
+ version: '0.54.0-rc.0',
192
192
  lib: ()=>require('@perses-dev/explore'),
193
193
  shareConfig: {
194
194
  singleton: true,
195
- requiredVersion: '^0.53.1'
195
+ requiredVersion: '^0.54.0-rc.0'
196
196
  }
197
197
  },
198
198
  '@perses-dev/dashboards': {
199
- version: '0.53.1',
199
+ version: '0.54.0-rc.0',
200
200
  lib: ()=>require('@perses-dev/dashboards'),
201
201
  shareConfig: {
202
202
  singleton: true,
203
- requiredVersion: '^0.53.1'
203
+ requiredVersion: '^0.54.0-rc.0'
204
204
  }
205
205
  },
206
206
  // Below are the shared modules that are used by the plugins, this can be part of the SDK
@@ -0,0 +1,30 @@
1
+ // Copyright 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("./panel"), 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
+ }
@@ -0,0 +1,42 @@
1
+ // Copyright 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: Object.getOwnPropertyDescriptor(all, name).get
21
+ });
22
+ }
23
+ _export(exports, {
24
+ get buildPanelEditorSchema () {
25
+ return buildPanelEditorSchema;
26
+ },
27
+ get panelEditorSchema () {
28
+ return panelEditorSchema;
29
+ }
30
+ });
31
+ const _zod = require("zod");
32
+ const _spec = require("@perses-dev/spec");
33
+ const panelEditorSchema = _zod.z.object({
34
+ groupId: _zod.z.number(),
35
+ panelDefinition: _spec.panelDefinitionSchema
36
+ });
37
+ function buildPanelEditorSchema(pluginSchema) {
38
+ return _zod.z.object({
39
+ groupId: _zod.z.number(),
40
+ panelDefinition: (0, _spec.buildPanelDefinitionSchema)(pluginSchema)
41
+ });
42
+ }
@@ -0,0 +1,8 @@
1
+ import { HTMLAttributes, ReactElement } from 'react';
2
+ import { Control } from 'react-hook-form';
3
+ import { PanelEditorValues } from '../../model';
4
+ export interface LinksEditorProps extends HTMLAttributes<HTMLDivElement> {
5
+ control: Control<PanelEditorValues>;
6
+ }
7
+ export declare function LinksEditor({ control, ...props }: LinksEditorProps): ReactElement;
8
+ //# sourceMappingURL=LinksEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LinksEditor.d.ts","sourceRoot":"","sources":["../../../src/components/LinksEditor/LinksEditor.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAY,cAAc,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE/D,OAAO,EAA6B,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAIrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,WAAW,gBAAiB,SAAQ,cAAc,CAAC,cAAc,CAAC;IACtE,OAAO,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;CACrC;AAED,wBAAgB,WAAW,CAAC,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,EAAE,gBAAgB,GAAG,YAAY,CAiCjF"}
@@ -0,0 +1,149 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // Copyright The Perses Authors
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ import { Fragment } from 'react';
15
+ import { Divider, IconButton, Stack, Typography } from '@mui/material';
16
+ import { Controller, useFieldArray } from 'react-hook-form';
17
+ import PlusIcon from 'mdi-material-ui/Plus';
18
+ import MinusIcon from 'mdi-material-ui/Minus';
19
+ import { LinkEditorForm } from '@perses-dev/components';
20
+ export function LinksEditor({ control, ...props }) {
21
+ const { fields, append, remove } = useFieldArray({
22
+ control: control,
23
+ name: 'panelDefinition.spec.links'
24
+ });
25
+ return /*#__PURE__*/ _jsxs(Stack, {
26
+ ...props,
27
+ gap: 3,
28
+ children: [
29
+ fields && fields.length > 0 ? fields.map((field, index)=>/*#__PURE__*/ _jsxs(Fragment, {
30
+ children: [
31
+ /*#__PURE__*/ _jsxs(Stack, {
32
+ direction: "row",
33
+ gap: 1,
34
+ alignItems: "center",
35
+ children: [
36
+ /*#__PURE__*/ _jsx(LinkControl, {
37
+ control: control,
38
+ index: index
39
+ }),
40
+ /*#__PURE__*/ _jsx(IconButton, {
41
+ style: {
42
+ width: 'fit-content',
43
+ height: 'fit-content'
44
+ },
45
+ onClick: ()=>remove(index),
46
+ children: /*#__PURE__*/ _jsx(MinusIcon, {})
47
+ })
48
+ ]
49
+ }),
50
+ /*#__PURE__*/ _jsx(Divider, {})
51
+ ]
52
+ }, field.id)) : /*#__PURE__*/ _jsx(Typography, {
53
+ variant: "subtitle1",
54
+ mb: 2,
55
+ fontStyle: "italic",
56
+ children: "No links defined"
57
+ }),
58
+ /*#__PURE__*/ _jsx(IconButton, {
59
+ style: {
60
+ width: 'fit-content',
61
+ height: 'fit-content'
62
+ },
63
+ onClick: ()=>append({
64
+ url: '',
65
+ name: '',
66
+ tooltip: '',
67
+ renderVariables: false,
68
+ targetBlank: false
69
+ }),
70
+ children: /*#__PURE__*/ _jsx(PlusIcon, {})
71
+ })
72
+ ]
73
+ });
74
+ }
75
+ function LinkControl({ control, index }) {
76
+ const defaultLink = {
77
+ url: '',
78
+ name: '',
79
+ tooltip: '',
80
+ renderVariables: false,
81
+ targetBlank: false
82
+ };
83
+ return /*#__PURE__*/ _jsx(Controller, {
84
+ control: control,
85
+ name: `panelDefinition.spec.links.${index}`,
86
+ render: ({ field, field: { value: link }, fieldState })=>{
87
+ const safeLink = link ?? defaultLink;
88
+ return /*#__PURE__*/ _jsx(LinkEditorForm, {
89
+ mode: "inline",
90
+ url: {
91
+ value: safeLink.url,
92
+ label: 'URL',
93
+ error: {
94
+ hasError: !!fieldState.error,
95
+ helperText: fieldState.error?.message
96
+ },
97
+ onChange: (url)=>{
98
+ field.onChange({
99
+ ...link,
100
+ url
101
+ });
102
+ }
103
+ },
104
+ newTabOpen: {
105
+ value: !!safeLink.targetBlank,
106
+ onChange: (targetBlank)=>{
107
+ field.onChange({
108
+ ...link,
109
+ targetBlank
110
+ });
111
+ },
112
+ label: 'Open in new tab'
113
+ },
114
+ name: {
115
+ value: safeLink.name ?? '',
116
+ label: 'Name',
117
+ onChange: (name)=>{
118
+ field.onChange({
119
+ ...link,
120
+ name
121
+ });
122
+ }
123
+ },
124
+ renderVariables: {
125
+ value: !!safeLink.renderVariables,
126
+ label: 'Render variables',
127
+ onChange: (renderVariables)=>{
128
+ field.onChange({
129
+ ...link,
130
+ renderVariables
131
+ });
132
+ }
133
+ },
134
+ tooltip: {
135
+ value: safeLink.tooltip ?? '',
136
+ label: 'Tooltip',
137
+ onChange: (tooltip)=>{
138
+ field.onChange({
139
+ ...link,
140
+ tooltip
141
+ });
142
+ }
143
+ }
144
+ });
145
+ }
146
+ });
147
+ }
148
+
149
+ //# sourceMappingURL=LinksEditor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/LinksEditor/LinksEditor.tsx"],"sourcesContent":["// Copyright 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 { Fragment, HTMLAttributes, ReactElement } from 'react';\nimport { Divider, IconButton, Stack, Typography } from '@mui/material';\nimport { Controller, useFieldArray, Control } from 'react-hook-form';\nimport PlusIcon from 'mdi-material-ui/Plus';\nimport MinusIcon from 'mdi-material-ui/Minus';\nimport { LinkEditorForm } from '@perses-dev/components';\nimport { PanelEditorValues } from '../../model';\n\nexport interface LinksEditorProps extends HTMLAttributes<HTMLDivElement> {\n control: Control<PanelEditorValues>;\n}\n\nexport function LinksEditor({ control, ...props }: LinksEditorProps): ReactElement {\n const { fields, append, remove } = useFieldArray({\n control: control,\n name: 'panelDefinition.spec.links',\n });\n\n return (\n <Stack {...props} gap={3}>\n {fields && fields.length > 0 ? (\n fields.map((field, index) => (\n <Fragment key={field.id}>\n <Stack direction=\"row\" gap={1} alignItems=\"center\">\n <LinkControl control={control} index={index} />\n <IconButton style={{ width: 'fit-content', height: 'fit-content' }} onClick={() => remove(index)}>\n <MinusIcon />\n </IconButton>\n </Stack>\n <Divider />\n </Fragment>\n ))\n ) : (\n <Typography variant=\"subtitle1\" mb={2} fontStyle=\"italic\">\n No links defined\n </Typography>\n )}\n <IconButton\n style={{ width: 'fit-content', height: 'fit-content' }}\n onClick={() => append({ url: '', name: '', tooltip: '', renderVariables: false, targetBlank: false })}\n >\n <PlusIcon />\n </IconButton>\n </Stack>\n );\n}\n\nfunction LinkControl({ control, index }: { control: Control<PanelEditorValues>; index: number }): ReactElement {\n const defaultLink = { url: '', name: '', tooltip: '', renderVariables: false, targetBlank: false };\n return (\n <Controller\n control={control}\n name={`panelDefinition.spec.links.${index}`}\n render={({ field, field: { value: link }, fieldState }) => {\n const safeLink = link ?? defaultLink;\n return (\n <LinkEditorForm\n mode=\"inline\"\n url={{\n value: safeLink.url,\n label: 'URL',\n error: { hasError: !!fieldState.error, helperText: fieldState.error?.message },\n onChange: (url) => {\n field.onChange({ ...link, url });\n },\n }}\n newTabOpen={{\n value: !!safeLink.targetBlank,\n onChange: (targetBlank) => {\n field.onChange({ ...link, targetBlank });\n },\n label: 'Open in new tab',\n }}\n name={{\n value: safeLink.name ?? '',\n label: 'Name',\n onChange: (name) => {\n field.onChange({ ...link, name });\n },\n }}\n renderVariables={{\n value: !!safeLink.renderVariables,\n label: 'Render variables',\n onChange: (renderVariables) => {\n field.onChange({ ...link, renderVariables });\n },\n }}\n tooltip={{\n value: safeLink.tooltip ?? '',\n label: 'Tooltip',\n onChange: (tooltip) => {\n field.onChange({ ...link, tooltip });\n },\n }}\n />\n );\n }}\n />\n );\n}\n"],"names":["Fragment","Divider","IconButton","Stack","Typography","Controller","useFieldArray","PlusIcon","MinusIcon","LinkEditorForm","LinksEditor","control","props","fields","append","remove","name","gap","length","map","field","index","direction","alignItems","LinkControl","style","width","height","onClick","id","variant","mb","fontStyle","url","tooltip","renderVariables","targetBlank","defaultLink","render","value","link","fieldState","safeLink","mode","label","error","hasError","helperText","message","onChange","newTabOpen"],"mappings":"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"}
@@ -0,0 +1,2 @@
1
+ export * from './LinksEditor';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/LinksEditor/index.ts"],"names":[],"mappings":"AAaA,cAAc,eAAe,CAAC"}
@@ -0,0 +1,15 @@
1
+ // Copyright 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
+ export * from './LinksEditor';
14
+
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/LinksEditor/index.ts"],"sourcesContent":["// Copyright 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\nexport * from './LinksEditor';\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,gBAAgB"}
@@ -32,7 +32,7 @@ function useDefaultQueryDefinition(queryTypes, filteredQueryPlugins) {
32
32
  } else {
33
33
  defaultQueryKind = defaultPluginKinds?.[defaultQueryType] ?? queryPlugins?.[0]?.spec.name ?? '';
34
34
  }
35
- const { data: defaultQueryPlugin } = usePlugin(defaultQueryType, defaultQueryKind, {
35
+ const { data: defaultQueryPlugin, isLoading: isPluginLoading } = usePlugin(defaultQueryType, defaultQueryKind, {
36
36
  useErrorBoundary: true,
37
37
  enabled: true
38
38
  });
@@ -47,7 +47,7 @@ function useDefaultQueryDefinition(queryTypes, filteredQueryPlugins) {
47
47
  }
48
48
  }
49
49
  },
50
- isLoading
50
+ isLoading: isLoading || isPluginLoading
51
51
  };
52
52
  }
53
53
  /**