@perses-dev/plugin-system 0.37.2 → 0.39.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.
- package/dist/cjs/components/OptionsEditorRadios/OptionsEditorRadios.js +74 -0
- package/dist/cjs/components/OptionsEditorRadios/index.js +28 -0
- package/dist/cjs/components/{OptionsEditorTabs/TabPanel.js → OptionsEditorTabPanel/OptionsEditorTabPanel.js} +3 -3
- package/dist/cjs/components/OptionsEditorTabPanel/index.js +28 -0
- package/dist/cjs/components/OptionsEditorTabs/OptionsEditorTabs.js +2 -2
- package/dist/cjs/components/PluginEditor/PluginEditor.js +4 -2
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +459 -0
- package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +178 -0
- package/dist/cjs/components/Variables/VariableEditorForm/index.js +29 -0
- package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +102 -0
- package/dist/cjs/components/Variables/index.js +29 -0
- package/dist/cjs/components/Variables/variable-model.js +117 -0
- package/dist/cjs/components/index.js +2 -0
- package/dist/cjs/constants/index.js +28 -0
- package/dist/cjs/constants/user-interface-text.js +25 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +40 -28
- package/dist/cjs/runtime/DataQueriesProvider/model.js +57 -0
- package/dist/cjs/runtime/template-variables.js +62 -0
- package/dist/cjs/test/index.js +1 -0
- package/dist/cjs/test/mock-data.js +55 -0
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.d.ts +16 -0
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.d.ts.map +1 -0
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js +68 -0
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js.map +1 -0
- package/dist/components/OptionsEditorRadios/index.d.ts +2 -0
- package/dist/components/OptionsEditorRadios/index.d.ts.map +1 -0
- package/dist/components/OptionsEditorRadios/index.js +15 -0
- package/dist/components/OptionsEditorRadios/index.js.map +1 -0
- package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.d.ts +9 -0
- package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.d.ts.map +1 -0
- package/dist/components/{OptionsEditorTabs/TabPanel.js → OptionsEditorTabPanel/OptionsEditorTabPanel.js} +2 -2
- package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js.map +1 -0
- package/dist/components/OptionsEditorTabPanel/index.d.ts +2 -0
- package/dist/components/OptionsEditorTabPanel/index.d.ts.map +1 -0
- package/dist/components/OptionsEditorTabPanel/index.js +15 -0
- package/dist/components/OptionsEditorTabPanel/index.js.map +1 -0
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js +2 -2
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -1
- package/dist/components/PluginEditor/PluginEditor.d.ts.map +1 -1
- package/dist/components/PluginEditor/PluginEditor.js +4 -2
- package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.d.ts +1 -0
- package/dist/components/PluginEditor/plugin-editor-api.d.ts.map +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +12 -0
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -0
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +414 -0
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -0
- package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts +16 -0
- package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts.map +1 -0
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js +122 -0
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -0
- package/dist/components/Variables/VariableEditorForm/index.d.ts +3 -0
- package/dist/components/Variables/VariableEditorForm/index.d.ts.map +1 -0
- package/dist/components/Variables/VariableEditorForm/index.js +16 -0
- package/dist/components/Variables/VariableEditorForm/index.js.map +1 -0
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +23 -0
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -0
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +90 -0
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -0
- package/dist/components/Variables/index.d.ts +3 -0
- package/dist/components/Variables/index.d.ts.map +1 -0
- package/dist/components/Variables/index.js +16 -0
- package/dist/components/Variables/index.js.map +1 -0
- package/dist/components/Variables/variable-model.d.ts +17 -0
- package/dist/components/Variables/variable-model.d.ts.map +1 -0
- package/dist/components/Variables/variable-model.js +105 -0
- package/dist/components/Variables/variable-model.js.map +1 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +2 -0
- package/dist/components/index.js.map +1 -1
- package/dist/constants/index.d.ts +2 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/constants/index.js +15 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/constants/user-interface-text.d.ts +5 -0
- package/dist/constants/user-interface-text.d.ts.map +1 -0
- package/dist/constants/user-interface-text.js +19 -0
- package/dist/constants/user-interface-text.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/model/plugin-base.d.ts +1 -0
- package/dist/model/plugin-base.d.ts.map +1 -1
- package/dist/model/plugin-base.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts +5 -5
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts.map +1 -1
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +39 -27
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.d.ts +15 -11
- package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.js +47 -1
- package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
- package/dist/runtime/template-variables.d.ts +61 -2
- package/dist/runtime/template-variables.d.ts.map +1 -1
- package/dist/runtime/template-variables.js +63 -0
- package/dist/runtime/template-variables.js.map +1 -1
- package/dist/test/index.d.ts +1 -0
- package/dist/test/index.d.ts.map +1 -1
- package/dist/test/index.js +1 -0
- package/dist/test/index.js.map +1 -1
- package/dist/test/mock-data.d.ts +3 -0
- package/dist/test/mock-data.d.ts.map +1 -0
- package/dist/test/mock-data.js +49 -0
- package/dist/test/mock-data.js.map +1 -0
- package/package.json +4 -4
- package/dist/components/OptionsEditorTabs/TabPanel.d.ts +0 -9
- package/dist/components/OptionsEditorTabs/TabPanel.d.ts.map +0 -1
- package/dist/components/OptionsEditorTabs/TabPanel.js.map +0 -1
|
@@ -0,0 +1,178 @@
|
|
|
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
|
+
VariablePreview: ()=>VariablePreview,
|
|
25
|
+
VariableListPreview: ()=>VariableListPreview
|
|
26
|
+
});
|
|
27
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
28
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
|
29
|
+
const _material = require("@mui/material");
|
|
30
|
+
const _components = require("@perses-dev/components");
|
|
31
|
+
const _refresh = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/Refresh"));
|
|
32
|
+
const _clipboardOutline = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/ClipboardOutline"));
|
|
33
|
+
const _constants = require("../../../constants");
|
|
34
|
+
const _variableModel = require("../variable-model");
|
|
35
|
+
function _interopRequireDefault(obj) {
|
|
36
|
+
return obj && obj.__esModule ? obj : {
|
|
37
|
+
default: obj
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
41
|
+
if (typeof WeakMap !== "function") return null;
|
|
42
|
+
var cacheBabelInterop = new WeakMap();
|
|
43
|
+
var cacheNodeInterop = new WeakMap();
|
|
44
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
45
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
46
|
+
})(nodeInterop);
|
|
47
|
+
}
|
|
48
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
49
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
50
|
+
return obj;
|
|
51
|
+
}
|
|
52
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
53
|
+
return {
|
|
54
|
+
default: obj
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
58
|
+
if (cache && cache.has(obj)) {
|
|
59
|
+
return cache.get(obj);
|
|
60
|
+
}
|
|
61
|
+
var newObj = {};
|
|
62
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
63
|
+
for(var key in obj){
|
|
64
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
65
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
66
|
+
if (desc && (desc.get || desc.set)) {
|
|
67
|
+
Object.defineProperty(newObj, key, desc);
|
|
68
|
+
} else {
|
|
69
|
+
newObj[key] = obj[key];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
newObj.default = obj;
|
|
74
|
+
if (cache) {
|
|
75
|
+
cache.set(obj, newObj);
|
|
76
|
+
}
|
|
77
|
+
return newObj;
|
|
78
|
+
}
|
|
79
|
+
const DEFAULT_MAX_PREVIEW_VALUES = 50;
|
|
80
|
+
function VariablePreview(props) {
|
|
81
|
+
const { values , onRefresh , isLoading , error } = props;
|
|
82
|
+
const [maxValues, setMaxValues] = (0, _react.useState)(DEFAULT_MAX_PREVIEW_VALUES);
|
|
83
|
+
const { infoSnackbar } = (0, _components.useSnackbar)();
|
|
84
|
+
const showAll = ()=>{
|
|
85
|
+
setMaxValues(undefined);
|
|
86
|
+
};
|
|
87
|
+
let notShown = 0;
|
|
88
|
+
if (values && (values === null || values === void 0 ? void 0 : values.length) > 0 && maxValues) {
|
|
89
|
+
notShown = values.length - maxValues;
|
|
90
|
+
}
|
|
91
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
92
|
+
children: [
|
|
93
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
94
|
+
direction: "row",
|
|
95
|
+
spacing: 1,
|
|
96
|
+
alignItems: "center",
|
|
97
|
+
mb: 1,
|
|
98
|
+
children: [
|
|
99
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
100
|
+
variant: "h4",
|
|
101
|
+
children: "Preview Values"
|
|
102
|
+
}),
|
|
103
|
+
onRefresh && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.InfoTooltip, {
|
|
104
|
+
description: _constants.TOOLTIP_TEXT.refreshVariableValues,
|
|
105
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
106
|
+
onClick: onRefresh,
|
|
107
|
+
size: "small",
|
|
108
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_refresh.default, {})
|
|
109
|
+
})
|
|
110
|
+
}),
|
|
111
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.InfoTooltip, {
|
|
112
|
+
description: _constants.TOOLTIP_TEXT.copyVariableValues,
|
|
113
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
114
|
+
onClick: async ()=>{
|
|
115
|
+
if (values === null || values === void 0 ? void 0 : values.length) {
|
|
116
|
+
await navigator.clipboard.writeText(values.map((value)=>value).join(', '));
|
|
117
|
+
infoSnackbar('Preview values copied to clipboard!');
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
size: "small",
|
|
121
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_clipboardOutline.default, {})
|
|
122
|
+
})
|
|
123
|
+
})
|
|
124
|
+
]
|
|
125
|
+
}),
|
|
126
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Card, {
|
|
127
|
+
variant: "outlined",
|
|
128
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
129
|
+
sx: {
|
|
130
|
+
display: 'flex',
|
|
131
|
+
flexWrap: 'wrap',
|
|
132
|
+
gap: 1,
|
|
133
|
+
m: 2
|
|
134
|
+
},
|
|
135
|
+
children: [
|
|
136
|
+
error && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Alert, {
|
|
137
|
+
severity: "error",
|
|
138
|
+
children: error
|
|
139
|
+
}),
|
|
140
|
+
(values === null || values === void 0 ? void 0 : values.length) === 0 && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Alert, {
|
|
141
|
+
severity: "info",
|
|
142
|
+
children: "No results"
|
|
143
|
+
}),
|
|
144
|
+
isLoading && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Stack, {
|
|
145
|
+
width: "100%",
|
|
146
|
+
sx: {
|
|
147
|
+
alignItems: 'center',
|
|
148
|
+
justifyContent: 'center'
|
|
149
|
+
},
|
|
150
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.CircularProgress, {})
|
|
151
|
+
}),
|
|
152
|
+
values === null || values === void 0 ? void 0 : values.slice(0, maxValues).map((val)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Chip, {
|
|
153
|
+
size: "small",
|
|
154
|
+
label: val
|
|
155
|
+
}, val)),
|
|
156
|
+
notShown > 0 && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Chip, {
|
|
157
|
+
onClick: showAll,
|
|
158
|
+
variant: "outlined",
|
|
159
|
+
size: "small",
|
|
160
|
+
label: `+${notShown} more`
|
|
161
|
+
})
|
|
162
|
+
]
|
|
163
|
+
})
|
|
164
|
+
})
|
|
165
|
+
]
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
function VariableListPreview(props) {
|
|
169
|
+
const { definition , onRefresh } = props;
|
|
170
|
+
const { data , isFetching , error } = (0, _variableModel.useListVariablePluginValues)(definition);
|
|
171
|
+
const errorMessage = error === null || error === void 0 ? void 0 : error.message;
|
|
172
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(VariablePreview, {
|
|
173
|
+
values: (data === null || data === void 0 ? void 0 : data.map((val)=>val.value)) || [],
|
|
174
|
+
onRefresh: onRefresh,
|
|
175
|
+
isLoading: isFetching,
|
|
176
|
+
error: errorMessage
|
|
177
|
+
});
|
|
178
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
_exportStar(require("./VariableEditorForm"), exports);
|
|
18
|
+
_exportStar(require("./VariablePreview"), exports);
|
|
19
|
+
function _exportStar(from, to) {
|
|
20
|
+
Object.keys(from).forEach(function(k) {
|
|
21
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function() {
|
|
24
|
+
return from[k];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
return from;
|
|
29
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
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
|
+
getInitialState: ()=>getInitialState,
|
|
25
|
+
getVariableDefinitionFromState: ()=>getVariableDefinitionFromState
|
|
26
|
+
});
|
|
27
|
+
function getInitialState(initialVariableDefinition) {
|
|
28
|
+
var ref, ref1;
|
|
29
|
+
var _value;
|
|
30
|
+
const textVariableFields = {
|
|
31
|
+
value: (_value = initialVariableDefinition.spec.value) !== null && _value !== void 0 ? _value : ''
|
|
32
|
+
};
|
|
33
|
+
const listVariableFields = {
|
|
34
|
+
allowMultiple: false,
|
|
35
|
+
allowAll: false,
|
|
36
|
+
capturing_regexp: undefined,
|
|
37
|
+
plugin: {
|
|
38
|
+
kind: '',
|
|
39
|
+
spec: {}
|
|
40
|
+
},
|
|
41
|
+
customAllValue: undefined
|
|
42
|
+
};
|
|
43
|
+
if (initialVariableDefinition.kind === 'ListVariable') {
|
|
44
|
+
var _allow_all_value;
|
|
45
|
+
listVariableFields.allowMultiple = (_allow_all_value = initialVariableDefinition.spec.allow_all_value) !== null && _allow_all_value !== void 0 ? _allow_all_value : false;
|
|
46
|
+
var _allow_all_value1;
|
|
47
|
+
listVariableFields.allowAll = (_allow_all_value1 = initialVariableDefinition.spec.allow_all_value) !== null && _allow_all_value1 !== void 0 ? _allow_all_value1 : false;
|
|
48
|
+
listVariableFields.capturing_regexp = initialVariableDefinition.spec.capturing_regexp;
|
|
49
|
+
listVariableFields.plugin = initialVariableDefinition.spec.plugin;
|
|
50
|
+
listVariableFields.customAllValue = initialVariableDefinition.spec.custom_all_value;
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
name: initialVariableDefinition.spec.name,
|
|
54
|
+
title: (ref = initialVariableDefinition.spec.display) === null || ref === void 0 ? void 0 : ref.name,
|
|
55
|
+
kind: initialVariableDefinition.kind,
|
|
56
|
+
description: (ref1 = initialVariableDefinition.spec.display) === null || ref1 === void 0 ? void 0 : ref1.description,
|
|
57
|
+
listVariableFields,
|
|
58
|
+
textVariableFields
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function getVariableDefinitionFromState(state) {
|
|
62
|
+
const { name , title , kind , description } = state;
|
|
63
|
+
let display = title ? {
|
|
64
|
+
name: title
|
|
65
|
+
} : undefined;
|
|
66
|
+
if (description) {
|
|
67
|
+
if (display) {
|
|
68
|
+
display.description = description;
|
|
69
|
+
} else {
|
|
70
|
+
// Name is mandatory if you want to add a description, autofilled by the metadata name if undefined
|
|
71
|
+
display = {
|
|
72
|
+
name: name,
|
|
73
|
+
description: description
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (kind === 'TextVariable') {
|
|
78
|
+
return {
|
|
79
|
+
kind,
|
|
80
|
+
spec: {
|
|
81
|
+
name,
|
|
82
|
+
display,
|
|
83
|
+
...state.textVariableFields
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
if (kind === 'ListVariable') {
|
|
88
|
+
return {
|
|
89
|
+
kind,
|
|
90
|
+
spec: {
|
|
91
|
+
name,
|
|
92
|
+
display,
|
|
93
|
+
allow_multiple: state.listVariableFields.allowMultiple,
|
|
94
|
+
allow_all_value: state.listVariableFields.allowAll,
|
|
95
|
+
capturing_regexp: state.listVariableFields.capturing_regexp,
|
|
96
|
+
plugin: state.listVariableFields.plugin,
|
|
97
|
+
custom_all_value: state.listVariableFields.customAllValue
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
throw new Error(`Unknown variable kind: ${kind}`);
|
|
102
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
_exportStar(require("./variable-model"), exports);
|
|
18
|
+
_exportStar(require("./VariableEditorForm"), exports);
|
|
19
|
+
function _exportStar(from, to) {
|
|
20
|
+
Object.keys(from).forEach(function(k) {
|
|
21
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function() {
|
|
24
|
+
return from[k];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
return from;
|
|
29
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
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 name1 in all)Object.defineProperty(target, name1, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: all[name1]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
filterVariableList: ()=>filterVariableList,
|
|
25
|
+
useListVariablePluginValues: ()=>useListVariablePluginValues,
|
|
26
|
+
getVariableValuesKey: ()=>getVariableValuesKey,
|
|
27
|
+
VARIABLE_TYPES: ()=>VARIABLE_TYPES
|
|
28
|
+
});
|
|
29
|
+
const _reactQuery = require("@tanstack/react-query");
|
|
30
|
+
const _runtime = require("../../runtime");
|
|
31
|
+
function filterVariableList(data, capturedRegexp) {
|
|
32
|
+
const result = [];
|
|
33
|
+
const filteredSet = new Set();
|
|
34
|
+
for (const variableValue of data){
|
|
35
|
+
const matches = variableValue.value.matchAll(capturedRegexp);
|
|
36
|
+
let concat = '';
|
|
37
|
+
for (const match of matches){
|
|
38
|
+
for(let i = 1; i < match.length; i++){
|
|
39
|
+
const m = match[i];
|
|
40
|
+
if (m !== undefined) {
|
|
41
|
+
concat = `${concat}${m}`;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (concat !== '' && !filteredSet.has(concat)) {
|
|
46
|
+
// like that we are avoiding to have duplicating variable value
|
|
47
|
+
filteredSet.add(concat);
|
|
48
|
+
result.push({
|
|
49
|
+
label: variableValue.label,
|
|
50
|
+
value: concat
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
function useListVariablePluginValues(definition) {
|
|
57
|
+
const { data: variablePlugin } = (0, _runtime.usePlugin)('Variable', definition.spec.plugin.kind);
|
|
58
|
+
const datasourceStore = (0, _runtime.useDatasourceStore)();
|
|
59
|
+
const allVariables = (0, _runtime.useTemplateVariableValues)();
|
|
60
|
+
const { absoluteTimeRange: timeRange , refreshKey } = (0, _runtime.useTimeRange)();
|
|
61
|
+
const variablePluginCtx = {
|
|
62
|
+
timeRange,
|
|
63
|
+
datasourceStore,
|
|
64
|
+
variables: allVariables
|
|
65
|
+
};
|
|
66
|
+
const spec = definition.spec.plugin.spec;
|
|
67
|
+
const capturingRegexp = definition.spec.capturing_regexp !== undefined ? new RegExp(definition.spec.capturing_regexp, 'g') : undefined;
|
|
68
|
+
let dependsOnVariables;
|
|
69
|
+
if (variablePlugin === null || variablePlugin === void 0 ? void 0 : variablePlugin.dependsOn) {
|
|
70
|
+
const dependencies = variablePlugin.dependsOn(spec, variablePluginCtx);
|
|
71
|
+
dependsOnVariables = dependencies.variables;
|
|
72
|
+
}
|
|
73
|
+
const variables = (0, _runtime.useTemplateVariableValues)(dependsOnVariables);
|
|
74
|
+
let waitToLoad = false;
|
|
75
|
+
if (dependsOnVariables) {
|
|
76
|
+
waitToLoad = dependsOnVariables.some((v)=>{
|
|
77
|
+
var ref;
|
|
78
|
+
return (ref = variables[v]) === null || ref === void 0 ? void 0 : ref.loading;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
const variablesValueKey = getVariableValuesKey(variables);
|
|
82
|
+
return (0, _reactQuery.useQuery)([
|
|
83
|
+
name,
|
|
84
|
+
definition,
|
|
85
|
+
variablesValueKey,
|
|
86
|
+
timeRange,
|
|
87
|
+
refreshKey
|
|
88
|
+
], async ()=>{
|
|
89
|
+
const resp = await (variablePlugin === null || variablePlugin === void 0 ? void 0 : variablePlugin.getVariableOptions(spec, {
|
|
90
|
+
datasourceStore,
|
|
91
|
+
variables,
|
|
92
|
+
timeRange
|
|
93
|
+
}));
|
|
94
|
+
if (resp === undefined) {
|
|
95
|
+
return [];
|
|
96
|
+
}
|
|
97
|
+
if (capturingRegexp === undefined) {
|
|
98
|
+
return resp.data;
|
|
99
|
+
}
|
|
100
|
+
return filterVariableList(resp.data, capturingRegexp);
|
|
101
|
+
}, {
|
|
102
|
+
enabled: !!variablePlugin || waitToLoad
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function getVariableValuesKey(v) {
|
|
106
|
+
return Object.values(v).map((v)=>JSON.stringify(v.value)).join(',');
|
|
107
|
+
}
|
|
108
|
+
const VARIABLE_TYPES = [
|
|
109
|
+
{
|
|
110
|
+
label: 'List',
|
|
111
|
+
kind: 'ListVariable'
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
label: 'Text',
|
|
115
|
+
kind: 'TextVariable'
|
|
116
|
+
}
|
|
117
|
+
];
|
|
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
17
17
|
_exportStar(require("./CalculationSelector"), exports);
|
|
18
18
|
_exportStar(require("./DatasourceSelect"), exports);
|
|
19
19
|
_exportStar(require("./LegendOptionsEditor"), exports);
|
|
20
|
+
_exportStar(require("./OptionsEditorRadios"), exports);
|
|
20
21
|
_exportStar(require("./OptionsEditorTabs"), exports);
|
|
21
22
|
_exportStar(require("./PanelSpecEditor"), exports);
|
|
22
23
|
_exportStar(require("./PluginEditor"), exports);
|
|
@@ -24,6 +25,7 @@ _exportStar(require("./PluginKindSelect"), exports);
|
|
|
24
25
|
_exportStar(require("./PluginRegistry"), exports);
|
|
25
26
|
_exportStar(require("./PluginSpecEditor"), exports);
|
|
26
27
|
_exportStar(require("./TimeSeriesQueryEditor"), exports);
|
|
28
|
+
_exportStar(require("./Variables"), exports);
|
|
27
29
|
function _exportStar(from, to) {
|
|
28
30
|
Object.keys(from).forEach(function(k) {
|
|
29
31
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
_exportStar(require("./user-interface-text"), exports);
|
|
18
|
+
function _exportStar(from, to) {
|
|
19
|
+
Object.keys(from).forEach(function(k) {
|
|
20
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function() {
|
|
23
|
+
return from[k];
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
return from;
|
|
28
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
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, "TOOLTIP_TEXT", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>TOOLTIP_TEXT
|
|
20
|
+
});
|
|
21
|
+
const TOOLTIP_TEXT = {
|
|
22
|
+
// Variable editor buttons
|
|
23
|
+
refreshVariableValues: 'Refresh values',
|
|
24
|
+
copyVariableValues: 'Copy values to clipboard'
|
|
25
|
+
};
|
package/dist/cjs/index.js
CHANGED
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
17
|
_exportStar(require("./components"), exports);
|
|
18
|
+
_exportStar(require("./constants"), exports);
|
|
18
19
|
_exportStar(require("./model"), exports);
|
|
19
20
|
_exportStar(require("./runtime"), exports);
|
|
20
21
|
_exportStar(require("./test-utils"), exports);
|
|
@@ -21,18 +21,15 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
-
useDataQueries: ()=>useDataQueries,
|
|
25
24
|
DataQueriesContext: ()=>DataQueriesContext,
|
|
26
25
|
useDataQueriesContext: ()=>useDataQueriesContext,
|
|
26
|
+
useDataQueries: ()=>useDataQueries,
|
|
27
27
|
DataQueriesProvider: ()=>DataQueriesProvider
|
|
28
28
|
});
|
|
29
29
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
30
30
|
const _react = require("react");
|
|
31
31
|
const _timeSeriesQueries = require("../time-series-queries");
|
|
32
|
-
|
|
33
|
-
const ctx = useDataQueriesContext();
|
|
34
|
-
return ctx;
|
|
35
|
-
}
|
|
32
|
+
const _model = require("./model");
|
|
36
33
|
const DataQueriesContext = /*#__PURE__*/ (0, _react.createContext)(undefined);
|
|
37
34
|
function useDataQueriesContext() {
|
|
38
35
|
const ctx = (0, _react.useContext)(DataQueriesContext);
|
|
@@ -41,44 +38,59 @@ function useDataQueriesContext() {
|
|
|
41
38
|
}
|
|
42
39
|
return ctx;
|
|
43
40
|
}
|
|
41
|
+
function useDataQueries(queryType) {
|
|
42
|
+
const ctx = useDataQueriesContext();
|
|
43
|
+
// Filter the query results based on the specified query type
|
|
44
|
+
const filteredQueryResults = ctx.queryResults.filter((queryResult)=>queryResult.definition.kind === queryType);
|
|
45
|
+
// Filter the errors based on the specified query type
|
|
46
|
+
const filteredErrors = ctx.errors.filter((errors, index)=>{
|
|
47
|
+
var ref;
|
|
48
|
+
return ((ref = ctx.queryResults[index]) === null || ref === void 0 ? void 0 : ref.definition.kind) === queryType;
|
|
49
|
+
});
|
|
50
|
+
// Create a new context object with the filtered results and errors
|
|
51
|
+
const filteredCtx = {
|
|
52
|
+
queryResults: filteredQueryResults,
|
|
53
|
+
isFetching: filteredQueryResults.some((result)=>result.isFetching),
|
|
54
|
+
isLoading: filteredQueryResults.some((result)=>result.isLoading),
|
|
55
|
+
refetchAll: ctx.refetchAll,
|
|
56
|
+
errors: filteredErrors
|
|
57
|
+
};
|
|
58
|
+
return filteredCtx;
|
|
59
|
+
}
|
|
44
60
|
function DataQueriesProvider(props) {
|
|
45
61
|
const { definitions , options , children } = props;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
kind:
|
|
62
|
+
const getQueryType = (0, _model.useQueryType)();
|
|
63
|
+
const queryDefinitions = definitions.map((definition)=>{
|
|
64
|
+
const type = getQueryType(definition.kind);
|
|
65
|
+
return {
|
|
66
|
+
kind: type,
|
|
51
67
|
spec: {
|
|
52
68
|
plugin: definition
|
|
53
69
|
}
|
|
54
|
-
}));
|
|
55
|
-
const results = (0, _timeSeriesQueries.useTimeSeriesQueries)(timeSeriesQueries, options);
|
|
56
|
-
const data = results.map(({ data , isFetching , isLoading , refetch , error }, i)=>{
|
|
57
|
-
return {
|
|
58
|
-
definition: definitions[i],
|
|
59
|
-
data,
|
|
60
|
-
isFetching,
|
|
61
|
-
isLoading,
|
|
62
|
-
refetch,
|
|
63
|
-
error
|
|
64
70
|
};
|
|
65
71
|
});
|
|
72
|
+
// Filter definitions for time series query and other future query plugins
|
|
73
|
+
const timeSeriesQueries = queryDefinitions.filter((definition)=>definition.kind === 'TimeSeriesQuery');
|
|
74
|
+
const timeSeriesResults = (0, _timeSeriesQueries.useTimeSeriesQueries)(timeSeriesQueries, options);
|
|
66
75
|
const refetchAll = (0, _react.useCallback)(()=>{
|
|
67
|
-
|
|
76
|
+
timeSeriesResults.forEach((result)=>result.refetch());
|
|
68
77
|
}, [
|
|
69
|
-
|
|
78
|
+
timeSeriesResults
|
|
70
79
|
]);
|
|
71
80
|
const ctx = (0, _react.useMemo)(()=>{
|
|
81
|
+
const mergedQueryResults = [
|
|
82
|
+
...(0, _model.transformQueryResults)(timeSeriesResults, timeSeriesQueries)
|
|
83
|
+
];
|
|
72
84
|
return {
|
|
73
|
-
queryResults:
|
|
74
|
-
isFetching:
|
|
75
|
-
isLoading:
|
|
85
|
+
queryResults: mergedQueryResults,
|
|
86
|
+
isFetching: mergedQueryResults.some((result)=>result.isFetching),
|
|
87
|
+
isLoading: mergedQueryResults.some((result)=>result.isLoading),
|
|
76
88
|
refetchAll,
|
|
77
|
-
errors:
|
|
89
|
+
errors: mergedQueryResults.map((result)=>result.error)
|
|
78
90
|
};
|
|
79
91
|
}, [
|
|
80
|
-
|
|
81
|
-
|
|
92
|
+
timeSeriesQueries,
|
|
93
|
+
timeSeriesResults,
|
|
82
94
|
refetchAll
|
|
83
95
|
]);
|
|
84
96
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(DataQueriesContext.Provider, {
|