@perses-dev/plugin-system 0.52.0-rc.1 → 0.52.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/DatasourceSelect.js +2 -1
- package/dist/cjs/components/LegendOptionsEditor/LegendOptionsEditor.js +73 -73
- package/dist/cjs/components/PluginEditor/PluginEditor.js +9 -10
- package/dist/cjs/components/PluginKindSelect/PluginKindSelect.js +6 -3
- package/dist/cjs/context/query-params.js +5 -5
- package/dist/cjs/runtime/TimeRangeProvider/query-params.js +27 -27
- package/dist/components/DatasourceSelect.d.ts.map +1 -1
- package/dist/components/DatasourceSelect.js +2 -1
- package/dist/components/DatasourceSelect.js.map +1 -1
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts.map +1 -1
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +75 -75
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
- package/dist/components/PluginEditor/PluginEditor.d.ts.map +1 -1
- package/dist/components/PluginEditor/PluginEditor.js +9 -10
- package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.d.ts.map +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.js +7 -4
- package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
- package/dist/context/query-params.js +5 -5
- package/dist/context/query-params.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/query-params.d.ts +12 -7
- package/dist/runtime/TimeRangeProvider/query-params.d.ts.map +1 -1
- package/dist/runtime/TimeRangeProvider/query-params.js +23 -20
- package/dist/runtime/TimeRangeProvider/query-params.js.map +1 -1
- package/package.json +5 -5
|
@@ -61,7 +61,7 @@ const emptyDatasourceOption = {
|
|
|
61
61
|
value: ''
|
|
62
62
|
};
|
|
63
63
|
function DatasourceSelect(props) {
|
|
64
|
-
const { datasourcePluginKind, value, project, onChange, ...others } = props;
|
|
64
|
+
const { datasourcePluginKind, value, project, readOnly, onChange, ...others } = props;
|
|
65
65
|
const { data, isLoading } = (0, _runtime.useListDatasourceSelectItems)(datasourcePluginKind, project);
|
|
66
66
|
const variables = (0, _runtime.useVariableValues)();
|
|
67
67
|
const defaultValue = (0, _react.useMemo)(()=>{
|
|
@@ -132,6 +132,7 @@ function DatasourceSelect(props) {
|
|
|
132
132
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
133
133
|
const fakeActionEvent = ()=>{};
|
|
134
134
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Autocomplete, {
|
|
135
|
+
readOnly: readOnly,
|
|
135
136
|
options: options,
|
|
136
137
|
renderInput: (params)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
137
138
|
...params,
|
|
@@ -32,12 +32,6 @@ const POSITION_OPTIONS = Object.entries(_model.LEGEND_POSITIONS_CONFIG).map(([id
|
|
|
32
32
|
...config
|
|
33
33
|
};
|
|
34
34
|
});
|
|
35
|
-
const MODE_OPTIONS = Object.entries(_model.LEGEND_MODE_CONFIG).map(([id, config])=>{
|
|
36
|
-
return {
|
|
37
|
-
id: id,
|
|
38
|
-
...config
|
|
39
|
-
};
|
|
40
|
-
});
|
|
41
35
|
const SIZE_OPTIONS = Object.entries(_model.LEGEND_SIZE_CONFIG).map(([id, config])=>{
|
|
42
36
|
return {
|
|
43
37
|
id: id,
|
|
@@ -58,13 +52,6 @@ function LegendOptionsEditor({ value, onChange, showValuesEditor = true, calcula
|
|
|
58
52
|
position: newValue.id
|
|
59
53
|
});
|
|
60
54
|
};
|
|
61
|
-
const handleLegendModeChange = (_, newValue)=>{
|
|
62
|
-
onChange({
|
|
63
|
-
...value,
|
|
64
|
-
position: currentPosition,
|
|
65
|
-
mode: newValue.id
|
|
66
|
-
});
|
|
67
|
-
};
|
|
68
55
|
const handleLegendSizeChange = (_, newValue)=>{
|
|
69
56
|
onChange({
|
|
70
57
|
...value,
|
|
@@ -85,7 +72,6 @@ function LegendOptionsEditor({ value, onChange, showValuesEditor = true, calcula
|
|
|
85
72
|
const currentPosition = (0, _core.getLegendPosition)(value?.position);
|
|
86
73
|
const legendPositionConfig = _model.LEGEND_POSITIONS_CONFIG[currentPosition];
|
|
87
74
|
const currentMode = (0, _core.getLegendMode)(value?.mode);
|
|
88
|
-
const legendModeConfig = _model.LEGEND_MODE_CONFIG[currentMode];
|
|
89
75
|
const currentSize = (0, _core.getLegendSize)(value?.size);
|
|
90
76
|
const legendSizeConfig = _model.LEGEND_SIZE_CONFIG[currentSize];
|
|
91
77
|
const legendValuesConfig = (0, _react.useMemo)(()=>{
|
|
@@ -147,65 +133,79 @@ function LegendOptionsEditor({ value, onChange, showValuesEditor = true, calcula
|
|
|
147
133
|
onChange: handleLegendShowChange
|
|
148
134
|
})
|
|
149
135
|
}),
|
|
150
|
-
/*#__PURE__*/ (0, _jsxruntime.
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
136
|
+
value && /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
137
|
+
children: [
|
|
138
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorControl, {
|
|
139
|
+
label: "Position",
|
|
140
|
+
control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.SettingsAutocomplete, {
|
|
141
|
+
value: {
|
|
142
|
+
...legendPositionConfig,
|
|
143
|
+
id: currentPosition
|
|
144
|
+
},
|
|
145
|
+
options: POSITION_OPTIONS,
|
|
146
|
+
onChange: handleLegendPositionChange,
|
|
147
|
+
disableClearable: true
|
|
148
|
+
})
|
|
149
|
+
}),
|
|
150
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorControl, {
|
|
151
|
+
label: "Mode",
|
|
152
|
+
control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.ToggleButtonGroup, {
|
|
153
|
+
color: "primary",
|
|
154
|
+
exclusive: true,
|
|
155
|
+
value: currentMode,
|
|
156
|
+
"aria-label": "Mode",
|
|
157
|
+
onChange: (__, newValue)=>{
|
|
158
|
+
onChange({
|
|
159
|
+
...value,
|
|
160
|
+
position: currentPosition,
|
|
161
|
+
mode: newValue
|
|
162
|
+
});
|
|
163
|
+
},
|
|
164
|
+
children: Object.entries(_model.LEGEND_MODE_CONFIG).map(([modeId, config])=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.ToggleButton, {
|
|
165
|
+
value: modeId,
|
|
166
|
+
selected: currentMode === modeId,
|
|
167
|
+
"aria-label": `display ${modeId} mode`,
|
|
168
|
+
children: config.label
|
|
169
|
+
}, modeId))
|
|
170
|
+
})
|
|
171
|
+
}),
|
|
172
|
+
currentMode === 'table' && /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
173
|
+
children: [
|
|
174
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorControl, {
|
|
175
|
+
label: "Size",
|
|
176
|
+
control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.SettingsAutocomplete, {
|
|
177
|
+
value: {
|
|
178
|
+
...legendSizeConfig,
|
|
179
|
+
id: currentSize
|
|
180
|
+
},
|
|
181
|
+
options: SIZE_OPTIONS,
|
|
182
|
+
onChange: handleLegendSizeChange,
|
|
183
|
+
// TODO: enable sizes for list mode when we normalize the layout of
|
|
184
|
+
// lists to more closely match tables.
|
|
185
|
+
disableClearable: true
|
|
186
|
+
})
|
|
187
|
+
}),
|
|
188
|
+
showValuesEditor && /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorControl, {
|
|
189
|
+
label: "Values",
|
|
190
|
+
control: // For some reason, the inferred option type doesn't always seem to work
|
|
191
|
+
// quite right when `multiple` is true. Explicitly setting the generics
|
|
192
|
+
// to work around this.
|
|
193
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.SettingsAutocomplete, {
|
|
194
|
+
multiple: true,
|
|
195
|
+
disableCloseOnSelect: true,
|
|
196
|
+
disableClearable: true,
|
|
197
|
+
value: legendValuesConfig,
|
|
198
|
+
options: valueOptions,
|
|
199
|
+
onChange: handleLegendValueChange,
|
|
200
|
+
limitTags: 1,
|
|
201
|
+
ChipProps: {
|
|
202
|
+
size: 'small'
|
|
203
|
+
}
|
|
204
|
+
})
|
|
205
|
+
})
|
|
206
|
+
]
|
|
207
|
+
})
|
|
208
|
+
]
|
|
209
209
|
})
|
|
210
210
|
]
|
|
211
211
|
});
|
|
@@ -80,13 +80,16 @@ const PluginEditor = /*#__PURE__*/ (0, _react.forwardRef)((props, ref)=>{
|
|
|
80
80
|
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
81
81
|
sx: {
|
|
82
82
|
display: 'flex',
|
|
83
|
-
flexDirection: 'row'
|
|
83
|
+
flexDirection: 'row',
|
|
84
|
+
alignItems: 'center',
|
|
85
|
+
justifyContent: 'space-between',
|
|
86
|
+
gap: 1,
|
|
87
|
+
mb: 1
|
|
84
88
|
},
|
|
85
89
|
children: [
|
|
86
90
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_PluginKindSelect.PluginKindSelect, {
|
|
87
91
|
fullWidth: false,
|
|
88
92
|
sx: {
|
|
89
|
-
mb: 2,
|
|
90
93
|
minWidth: 120
|
|
91
94
|
},
|
|
92
95
|
margin: "dense",
|
|
@@ -94,8 +97,10 @@ const PluginEditor = /*#__PURE__*/ (0, _react.forwardRef)((props, ref)=>{
|
|
|
94
97
|
pluginTypes: pluginTypes,
|
|
95
98
|
disabled: isLoading,
|
|
96
99
|
value: pendingSelection ? pendingSelection : value.selection,
|
|
97
|
-
|
|
98
|
-
|
|
100
|
+
slotProps: {
|
|
101
|
+
input: {
|
|
102
|
+
readOnly: isReadonly
|
|
103
|
+
}
|
|
99
104
|
},
|
|
100
105
|
error: !!error,
|
|
101
106
|
helperText: error?.message,
|
|
@@ -104,12 +109,6 @@ const PluginEditor = /*#__PURE__*/ (0, _react.forwardRef)((props, ref)=>{
|
|
|
104
109
|
withRunQueryButton && !isLoading && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
|
|
105
110
|
"data-testid": "run_query_button",
|
|
106
111
|
variant: "contained",
|
|
107
|
-
sx: {
|
|
108
|
-
marginTop: 1.5,
|
|
109
|
-
marginBottom: 1.5,
|
|
110
|
-
paddingTop: 0.5,
|
|
111
|
-
marginLeft: 'auto'
|
|
112
|
-
},
|
|
113
112
|
startIcon: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Reload.default, {}),
|
|
114
113
|
onClick: runQueryHandler,
|
|
115
114
|
children: "Run Query"
|
|
@@ -27,6 +27,9 @@ const _runtime = require("../../runtime");
|
|
|
27
27
|
const PluginKindSelect = /*#__PURE__*/ (0, _react.forwardRef)((props, ref)=>{
|
|
28
28
|
const { pluginTypes, value: propValue, onChange, ...others } = props;
|
|
29
29
|
const { data, isLoading } = (0, _runtime.useListPluginMetadata)(pluginTypes);
|
|
30
|
+
const sortedData = (0, _react.useMemo)(()=>data?.sort((a, b)=>a.spec.display.name.localeCompare(b.spec.display.name)), [
|
|
31
|
+
data
|
|
32
|
+
]);
|
|
30
33
|
// Pass an empty value while options are still loading so MUI doesn't complain about us using an "out of range" value
|
|
31
34
|
const value = !propValue || isLoading ? '' : selectionToOptionValue(propValue);
|
|
32
35
|
const handleChange = (event)=>{
|
|
@@ -37,9 +40,9 @@ const PluginKindSelect = /*#__PURE__*/ (0, _react.forwardRef)((props, ref)=>{
|
|
|
37
40
|
return '';
|
|
38
41
|
}
|
|
39
42
|
const selectedValue = optionValueToSelection(selected);
|
|
40
|
-
return
|
|
43
|
+
return sortedData?.find((v)=>v.kind === selectedValue.type && v.spec.name === selectedValue.kind)?.spec.display.name;
|
|
41
44
|
}, [
|
|
42
|
-
|
|
45
|
+
sortedData
|
|
43
46
|
]);
|
|
44
47
|
// TODO: Does this need a loading indicator of some kind?
|
|
45
48
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.TextField, {
|
|
@@ -58,7 +61,7 @@ const PluginKindSelect = /*#__PURE__*/ (0, _react.forwardRef)((props, ref)=>{
|
|
|
58
61
|
value: "",
|
|
59
62
|
children: "Loading..."
|
|
60
63
|
}),
|
|
61
|
-
|
|
64
|
+
sortedData?.map((metadata)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
62
65
|
"data-testid": "option",
|
|
63
66
|
value: selectionToOptionValue({
|
|
64
67
|
type: metadata.kind,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2025 The Perses Authors
|
|
2
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
3
|
// you may not use this file except in compliance with the License.
|
|
4
4
|
// You may obtain a copy of the License at
|
|
@@ -21,12 +21,12 @@ Object.defineProperty(exports, "useSetProjectParams", {
|
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
23
|
const _react = require("react");
|
|
24
|
-
const
|
|
24
|
+
const _usequeryparams = require("use-query-params");
|
|
25
25
|
function useSetProjectParams(enabledURLParams = true) {
|
|
26
|
-
const [query, setQuery] = (0,
|
|
27
|
-
project:
|
|
26
|
+
const [query, setQuery] = (0, _usequeryparams.useQueryParams)({
|
|
27
|
+
project: ''
|
|
28
28
|
}, {
|
|
29
|
-
|
|
29
|
+
updateType: 'replaceIn'
|
|
30
30
|
});
|
|
31
31
|
const [projectState, setProjectState] = (0, _react.useState)('none');
|
|
32
32
|
const setProject = (0, _react.useCallback)((project)=>{
|
|
@@ -21,20 +21,20 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
+
TimeRangeParam: function() {
|
|
25
|
+
return TimeRangeParam;
|
|
26
|
+
},
|
|
24
27
|
decodeTimeRangeValue: function() {
|
|
25
28
|
return decodeTimeRangeValue;
|
|
26
29
|
},
|
|
27
30
|
encodeTimeRangeValue: function() {
|
|
28
31
|
return encodeTimeRangeValue;
|
|
29
32
|
},
|
|
30
|
-
|
|
31
|
-
return
|
|
32
|
-
},
|
|
33
|
-
parseAsTimeRange: function() {
|
|
34
|
-
return parseAsTimeRange;
|
|
33
|
+
refreshIntervalQueryConfig: function() {
|
|
34
|
+
return refreshIntervalQueryConfig;
|
|
35
35
|
},
|
|
36
|
-
|
|
37
|
-
return
|
|
36
|
+
timeRangeQueryConfig: function() {
|
|
37
|
+
return timeRangeQueryConfig;
|
|
38
38
|
},
|
|
39
39
|
useInitialRefreshInterval: function() {
|
|
40
40
|
return useInitialRefreshInterval;
|
|
@@ -50,9 +50,9 @@ _export(exports, {
|
|
|
50
50
|
}
|
|
51
51
|
});
|
|
52
52
|
const _react = require("react");
|
|
53
|
+
const _usequeryparams = require("use-query-params");
|
|
53
54
|
const _datefns = require("date-fns");
|
|
54
55
|
const _core = require("@perses-dev/core");
|
|
55
|
-
const _nuqs = require("nuqs");
|
|
56
56
|
/* Interprets an encoded string and returns either the string or null/undefined if not available */ function getEncodedValue(input, allowEmptyString) {
|
|
57
57
|
// '' or []
|
|
58
58
|
if (!input || input.length === 0 && (!allowEmptyString || allowEmptyString && input !== '')) {
|
|
@@ -69,7 +69,7 @@ const _nuqs = require("nuqs");
|
|
|
69
69
|
}
|
|
70
70
|
function encodeTimeRangeValue(timeOptionValue) {
|
|
71
71
|
if (!timeOptionValue) {
|
|
72
|
-
return
|
|
72
|
+
return timeOptionValue;
|
|
73
73
|
}
|
|
74
74
|
if (typeof timeOptionValue === 'string') {
|
|
75
75
|
if ((0, _core.isDurationString)(timeOptionValue)) {
|
|
@@ -83,25 +83,25 @@ function decodeTimeRangeValue(input) {
|
|
|
83
83
|
if (!paramString) return null;
|
|
84
84
|
return (0, _core.isDurationString)(paramString) ? paramString : new Date(Number(paramString));
|
|
85
85
|
}
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
const TimeRangeParam = {
|
|
87
|
+
encode: encodeTimeRangeValue,
|
|
88
|
+
decode: decodeTimeRangeValue,
|
|
89
|
+
equals: (valueA, valueB)=>{
|
|
90
90
|
if (valueA === valueB) return true;
|
|
91
91
|
if (!valueA || !valueB) return valueA === valueB;
|
|
92
92
|
return valueA.valueOf() === valueB.valueOf();
|
|
93
93
|
}
|
|
94
|
-
});
|
|
95
|
-
const parseAsTimeRange = {
|
|
96
|
-
start: parseAsTimeRangeValue,
|
|
97
|
-
end: parseAsTimeRangeValue
|
|
98
94
|
};
|
|
99
|
-
const
|
|
100
|
-
|
|
95
|
+
const timeRangeQueryConfig = {
|
|
96
|
+
start: TimeRangeParam,
|
|
97
|
+
end: TimeRangeParam
|
|
98
|
+
};
|
|
99
|
+
const refreshIntervalQueryConfig = {
|
|
100
|
+
refresh: TimeRangeParam
|
|
101
101
|
};
|
|
102
102
|
function useInitialTimeRange(dashboardDuration) {
|
|
103
|
-
const [query] = (0,
|
|
104
|
-
|
|
103
|
+
const [query] = (0, _usequeryparams.useQueryParams)(timeRangeQueryConfig, {
|
|
104
|
+
updateType: 'replaceIn'
|
|
105
105
|
});
|
|
106
106
|
const { start, end } = query;
|
|
107
107
|
return (0, _react.useMemo)(()=>{
|
|
@@ -130,8 +130,8 @@ function useInitialTimeRange(dashboardDuration) {
|
|
|
130
130
|
]);
|
|
131
131
|
}
|
|
132
132
|
function useTimeRangeParams(initialTimeRange) {
|
|
133
|
-
const [query, setQuery] = (0,
|
|
134
|
-
|
|
133
|
+
const [query, setQuery] = (0, _usequeryparams.useQueryParams)(timeRangeQueryConfig, {
|
|
134
|
+
updateType: 'replaceIn'
|
|
135
135
|
});
|
|
136
136
|
// determine whether initial param had previously been populated to fix back btn
|
|
137
137
|
const [paramsLoaded, setParamsLoaded] = (0, _react.useState)(false);
|
|
@@ -171,8 +171,8 @@ function useTimeRangeParams(initialTimeRange) {
|
|
|
171
171
|
};
|
|
172
172
|
}
|
|
173
173
|
function useInitialRefreshInterval(dashboardDuration) {
|
|
174
|
-
const [query] = (0,
|
|
175
|
-
|
|
174
|
+
const [query] = (0, _usequeryparams.useQueryParams)(refreshIntervalQueryConfig, {
|
|
175
|
+
updateType: 'replaceIn'
|
|
176
176
|
});
|
|
177
177
|
const { refresh } = query;
|
|
178
178
|
return (0, _react.useMemo)(()=>{
|
|
@@ -191,8 +191,8 @@ function useInitialRefreshInterval(dashboardDuration) {
|
|
|
191
191
|
]);
|
|
192
192
|
}
|
|
193
193
|
function useSetRefreshIntervalParams(initialRefreshInterval) {
|
|
194
|
-
const [query, setQuery] = (0,
|
|
195
|
-
|
|
194
|
+
const [query, setQuery] = (0, _usequeryparams.useQueryParams)(refreshIntervalQueryConfig, {
|
|
195
|
+
updateType: 'replaceIn'
|
|
196
196
|
});
|
|
197
197
|
// determine whether initial param had previously been populated to fix back btn
|
|
198
198
|
const [paramsLoaded, setParamsLoaded] = (0, _react.useState)(false);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatasourceSelect.d.ts","sourceRoot":"","sources":["../../src/components/DatasourceSelect.tsx"],"names":[],"mappings":"AAcA,OAAO,EAML,mBAAmB,EACnB,eAAe,EAGhB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,YAAY,EAAW,MAAM,OAAO,CAAC;AAC9C,OAAO,EAEL,yBAAyB,EACzB,4BAA4B,EAG5B,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAOpB,KAAK,eAAe,GAAG,UAAU,GAAG,OAAO,GAAG,UAAU,CAAC;AAWzD,MAAM,MAAM,qBAAqB,CAAC,CAAC,GAAG,kBAAkB,IAAI,CAAC,GAAG,YAAY,CAAC;AAE7E,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CAAC,mBAAmB,GAAG,eAAe,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC;IACjH,KAAK,EAAE,qBAAqB,CAAC;IAC7B,QAAQ,EAAE,CAAC,IAAI,EAAE,qBAAqB,KAAK,IAAI,CAAC;IAChD,oBAAoB,EAAE,MAAM,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,YAAY,
|
|
1
|
+
{"version":3,"file":"DatasourceSelect.d.ts","sourceRoot":"","sources":["../../src/components/DatasourceSelect.tsx"],"names":[],"mappings":"AAcA,OAAO,EAML,mBAAmB,EACnB,eAAe,EAGhB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,YAAY,EAAW,MAAM,OAAO,CAAC;AAC9C,OAAO,EAEL,yBAAyB,EACzB,4BAA4B,EAG5B,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAOpB,KAAK,eAAe,GAAG,UAAU,GAAG,OAAO,GAAG,UAAU,CAAC;AAWzD,MAAM,MAAM,qBAAqB,CAAC,CAAC,GAAG,kBAAkB,IAAI,CAAC,GAAG,YAAY,CAAC;AAE7E,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CAAC,mBAAmB,GAAG,eAAe,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC;IACjH,KAAK,EAAE,qBAAqB,CAAC;IAC7B,QAAQ,EAAE,CAAC,IAAI,EAAE,qBAAqB,KAAK,IAAI,CAAC;IAChD,oBAAoB,EAAE,MAAM,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,YAAY,CAkH3E;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,YAAY,CAahH;AAKD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,4BAA4B,GAAG,YAAY,GAAG,MAAM,CAKnG;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,qBAAqB,CAehF;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,qBAAqB,GAAG,SAAS,GAAG,KAAK,IAAI,YAAY,CAEpG;AAED,eAAO,MAAM,+BAA+B,UACnC,qBAAqB,GAAG,SAAS,aAC7B,gBAAgB,8BACC,yBAAyB,EAAE,GAAG,SAAS,KAClE,kBAAkB,GAAG,SA4BvB,CAAC;AAEF,eAAO,MAAM,kCAAkC,UACtC,qBAAqB,wBACN,MAAM,KAC3B,kBAQF,CAAC"}
|
|
@@ -27,7 +27,7 @@ const emptyDatasourceOption = {
|
|
|
27
27
|
* Displays a MUI input for selecting a Datasource of a particular kind. Note: The 'value' and `onChange` handler for
|
|
28
28
|
* the input deal with a `DatasourceSelector`.
|
|
29
29
|
*/ export function DatasourceSelect(props) {
|
|
30
|
-
const { datasourcePluginKind, value, project, onChange, ...others } = props;
|
|
30
|
+
const { datasourcePluginKind, value, project, readOnly, onChange, ...others } = props;
|
|
31
31
|
const { data, isLoading } = useListDatasourceSelectItems(datasourcePluginKind, project);
|
|
32
32
|
const variables = useVariableValues();
|
|
33
33
|
const defaultValue = useMemo(()=>{
|
|
@@ -98,6 +98,7 @@ const emptyDatasourceOption = {
|
|
|
98
98
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
99
99
|
const fakeActionEvent = ()=>{};
|
|
100
100
|
return /*#__PURE__*/ _jsx(Autocomplete, {
|
|
101
|
+
readOnly: readOnly,
|
|
101
102
|
options: options,
|
|
102
103
|
renderInput: (params)=>/*#__PURE__*/ _jsx(TextField, {
|
|
103
104
|
...params,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/DatasourceSelect.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 OpenInNewIcon from 'mdi-material-ui/OpenInNew';\nimport {\n Stack,\n ListItemText,\n Chip,\n IconButton,\n Box,\n OutlinedSelectProps,\n BaseSelectProps,\n Autocomplete,\n TextField,\n} from '@mui/material';\nimport { DatasourceSelector, VariableName } from '@perses-dev/core';\nimport { ReactElement, useMemo } from 'react';\nimport {\n DatasourceSelectItem,\n DatasourceSelectItemGroup,\n DatasourceSelectItemSelector,\n useListDatasourceSelectItems,\n useVariableValues,\n VariableStateMap,\n} from '../runtime';\nimport { parseVariables } from '../utils';\n\nconst DATASOURCE_VARIABLE_VALUE_PREFIX = '__DATASOURCE_VARIABLE_VALUE__';\nconst VARIABLE_IDENTIFIER = '$';\n// Props on MUI Select that we don't want people to pass because we're either redefining them or providing them in\n// this component\ntype OmittedMuiProps = 'children' | 'value' | 'onChange';\n\ntype DataSourceOption = {\n groupEditLink?: string;\n groupLabel?: string;\n value: string;\n} & Omit<DatasourceSelectItem, 'selector'> &\n Omit<DatasourceSelectItem['selector'], 'kind'>;\n\nconst emptyDatasourceOption: DataSourceOption = { name: '', value: '' };\n\nexport type DatasourceSelectValue<T = DatasourceSelector> = T | VariableName;\n\nexport interface DatasourceSelectProps extends Omit<OutlinedSelectProps & BaseSelectProps<string>, OmittedMuiProps> {\n value: DatasourceSelectValue;\n onChange: (next: DatasourceSelectValue) => void;\n datasourcePluginKind: string;\n project?: string;\n}\n\n/**\n * Displays a MUI input for selecting a Datasource of a particular kind. Note: The 'value' and `onChange` handler for\n * the input deal with a `DatasourceSelector`.\n */\nexport function DatasourceSelect(props: DatasourceSelectProps): ReactElement {\n const { datasourcePluginKind, value, project, onChange, ...others } = props;\n const { data, isLoading } = useListDatasourceSelectItems(datasourcePluginKind, project);\n const variables = useVariableValues();\n\n const defaultValue = useMemo<VariableName | DatasourceSelectItemSelector>(() => {\n if (isVariableDatasource(value)) {\n return value;\n }\n\n const group = (data ?? [])\n .flatMap((itemGroup) => itemGroup.items)\n .find((item) => {\n return value.kind === item.selector.kind && value.name === item.selector.name && !item.overridden;\n })?.selector.group;\n return { ...value, group };\n }, [value, data]);\n\n const options = useMemo<DataSourceOption[]>(() => {\n const datasourceOptions = (data || []).flatMap<DataSourceOption>((itemGroup) =>\n itemGroup.items.map<DataSourceOption>((item) => ({\n groupLabel: itemGroup.group,\n groupEditLink: itemGroup.editLink,\n name: item.name,\n overriding: item.overriding,\n overridden: item.overridden,\n saved: item.saved ?? true,\n group: item.selector.group,\n value: selectorToOptionValue(item.selector),\n }))\n );\n\n const datasourceOptionsMap = new Map(datasourceOptions.map((option) => [option.name, option]));\n\n const variableOptions = Object.entries(variables).flatMap<DataSourceOption>(([name, variable]) => {\n if (Array.isArray(variable.value)) return [];\n\n const associatedDatasource = datasourceOptionsMap.get(variable.value ?? '');\n if (!associatedDatasource) return [];\n\n return {\n groupLabel: 'Variables',\n name: `${VARIABLE_IDENTIFIER}${name}`,\n saved: true,\n value: `${DATASOURCE_VARIABLE_VALUE_PREFIX}${VARIABLE_IDENTIFIER}${name}`,\n };\n });\n\n return [...datasourceOptions, ...variableOptions];\n }, [data, variables]);\n\n // While loading available values, just use an empty datasource option so MUI select doesn't warn about values out of range\n const optionValue = isLoading\n ? emptyDatasourceOption\n : options.find((option) => option.value === selectorToOptionValue(defaultValue));\n\n // When the user makes a selection, convert the string option value back to a DatasourceSelector\n const handleChange = (selectedOption: DataSourceOption | null): void => {\n if (selectedOption) {\n const next = optionValueToSelector(selectedOption?.value || '');\n onChange(next);\n } else {\n onChange({ kind: datasourcePluginKind });\n }\n };\n\n // We use a fake action event when we click on the action of the chip (hijack the \"delete\" feature).\n // This is because the href link action is on the `deleteIcon` property already, but the `onDelete` property\n // controls its visibility.\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n const fakeActionEvent = (): void => {};\n\n return (\n <Autocomplete<DataSourceOption>\n options={options}\n renderInput={(params) => <TextField {...params} label={others.label} placeholder=\"\" />}\n groupBy={(option) => option.groupLabel || 'No group'}\n getOptionLabel={(option) => {\n return option.name;\n }}\n onChange={(_, v) => handleChange(v)}\n value={optionValue}\n renderOption={(props, option) => {\n return (\n <li {...props} key={option.value}>\n <Stack direction=\"row\" alignItems=\"center\" justifyContent=\"space-between\" width=\"100%\">\n <ListItemText>\n <DatasourceName name={option.name} overridden={option.overridden} overriding={option.overriding} />\n </ListItemText>\n {!option.saved && <ListItemText>Save the dashboard to enable this datasource</ListItemText>}\n <ListItemText style={{ textAlign: 'right' }}>\n {option.groupLabel && option.groupLabel.length > 0 && (\n <Chip\n disabled={false}\n label={option.groupLabel}\n size=\"small\"\n onDelete={option.groupEditLink ? fakeActionEvent : undefined}\n deleteIcon={\n option.groupEditLink ? (\n <IconButton href={option.groupEditLink} target=\"_blank\">\n <OpenInNewIcon fontSize=\"small\" />\n </IconButton>\n ) : undefined\n }\n />\n )}\n </ListItemText>\n </Stack>\n </li>\n );\n }}\n />\n );\n}\n\nexport function DatasourceName(props: { name: string; overridden?: boolean; overriding?: boolean }): ReactElement {\n const { name, overridden, overriding } = props;\n return (\n <>\n {`${name} `}\n {!overridden && overriding && (\n <Box display=\"inline\" fontWeight=\"normal\" color={(theme) => theme.palette.primary.main}>\n (overriding)\n </Box>\n )}\n {overridden && '(overridden)'}\n </>\n );\n}\n\n// Delimiter used to stringify/parse option values\nconst OPTION_VALUE_DELIMITER = '_____';\n\n/**\n * Given a DatasourceSelectItemSelector,\n * returns a string value like `{kind}_____{group}_____{name}` that can be used as a Select input value.\n * @param selector\n */\nexport function selectorToOptionValue(selector: DatasourceSelectItemSelector | VariableName): string {\n if (isVariableDatasource(selector)) {\n return `${DATASOURCE_VARIABLE_VALUE_PREFIX}${selector}`;\n }\n return [selector.kind, selector.group ?? '', selector.name ?? ''].join(OPTION_VALUE_DELIMITER);\n}\n\n/**\n * Given an option value name like `{kind}_____{group}_____{name}`,\n * returns a DatasourceSelector to be used by the query data model.\n * @param optionValue\n */\nexport function optionValueToSelector(optionValue: string): DatasourceSelectValue {\n if (optionValue.startsWith(DATASOURCE_VARIABLE_VALUE_PREFIX)) {\n return optionValue.split(DATASOURCE_VARIABLE_VALUE_PREFIX)[1]!;\n }\n\n const words = optionValue.split(OPTION_VALUE_DELIMITER);\n const kind = words[0];\n const name = words[2];\n if (kind === undefined || name === undefined) {\n throw new Error('Invalid optionValue string');\n }\n return {\n kind,\n name: name === '' ? undefined : name,\n };\n}\n\nexport function isVariableDatasource(value: DatasourceSelectValue | undefined): value is VariableName {\n return typeof value === 'string' && value.startsWith(VARIABLE_IDENTIFIER);\n}\n\nexport const datasourceSelectValueToSelector = (\n value: DatasourceSelectValue | undefined,\n variables: VariableStateMap,\n datasourceSelectItemGroups: DatasourceSelectItemGroup[] | undefined\n): DatasourceSelector | undefined => {\n if (!isVariableDatasource(value)) {\n return value;\n }\n\n const [variableName] = parseVariables(value);\n const variable = variables[variableName ?? ''];\n\n // If the variable is not defined or if its value is an array, we cannot determine a selector and return undefined\n if (!variable || Array.isArray(variable.value)) {\n return undefined;\n }\n\n const associatedDatasource = (datasourceSelectItemGroups || [])\n .flatMap((itemGroup) => itemGroup.items)\n .find((datasource) => datasource.name === variable.value);\n\n // If the variable value is not a datasource, we cannot determine a selector and return undefined\n if (associatedDatasource === undefined) {\n return undefined;\n }\n\n const datasourceSelector: DatasourceSelector = {\n kind: associatedDatasource.selector.kind,\n name: associatedDatasource.selector.name,\n };\n\n return datasourceSelector;\n};\n\nexport const useDatasourceSelectValueToSelector = (\n value: DatasourceSelectValue,\n datasourcePluginKind: string\n): DatasourceSelector => {\n const { data } = useListDatasourceSelectItems(datasourcePluginKind);\n const variables = useVariableValues();\n if (!isVariableDatasource(value)) {\n return value;\n }\n\n return datasourceSelectValueToSelector(value, variables, data) ?? { kind: datasourcePluginKind };\n};\n"],"names":["OpenInNewIcon","Stack","ListItemText","Chip","IconButton","Box","Autocomplete","TextField","useMemo","useListDatasourceSelectItems","useVariableValues","parseVariables","DATASOURCE_VARIABLE_VALUE_PREFIX","VARIABLE_IDENTIFIER","emptyDatasourceOption","name","value","DatasourceSelect","props","datasourcePluginKind","project","onChange","others","data","isLoading","variables","defaultValue","isVariableDatasource","group","flatMap","itemGroup","items","find","item","kind","selector","overridden","options","datasourceOptions","map","groupLabel","groupEditLink","editLink","overriding","saved","selectorToOptionValue","datasourceOptionsMap","Map","option","variableOptions","Object","entries","variable","Array","isArray","associatedDatasource","get","optionValue","handleChange","selectedOption","next","optionValueToSelector","fakeActionEvent","renderInput","params","label","placeholder","groupBy","getOptionLabel","_","v","renderOption","li","key","direction","alignItems","justifyContent","width","DatasourceName","style","textAlign","length","disabled","size","onDelete","undefined","deleteIcon","href","target","fontSize","display","fontWeight","color","theme","palette","primary","main","OPTION_VALUE_DELIMITER","join","startsWith","split","words","Error","datasourceSelectValueToSelector","datasourceSelectItemGroups","variableName","datasource","datasourceSelector","useDatasourceSelectValueToSelector"],"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,OAAOA,mBAAmB,4BAA4B;AACtD,SACEC,KAAK,EACLC,YAAY,EACZC,IAAI,EACJC,UAAU,EACVC,GAAG,EAGHC,YAAY,EACZC,SAAS,QACJ,gBAAgB;AAEvB,SAAuBC,OAAO,QAAQ,QAAQ;AAC9C,SAIEC,4BAA4B,EAC5BC,iBAAiB,QAEZ,aAAa;AACpB,SAASC,cAAc,QAAQ,WAAW;AAE1C,MAAMC,mCAAmC;AACzC,MAAMC,sBAAsB;AAY5B,MAAMC,wBAA0C;IAAEC,MAAM;IAAIC,OAAO;AAAG;AAWtE;;;CAGC,GACD,OAAO,SAASC,iBAAiBC,KAA4B;IAC3D,MAAM,EAAEC,oBAAoB,EAAEH,KAAK,EAAEI,OAAO,EAAEC,QAAQ,EAAE,GAAGC,QAAQ,GAAGJ;IACtE,MAAM,EAAEK,IAAI,EAAEC,SAAS,EAAE,GAAGf,6BAA6BU,sBAAsBC;IAC/E,MAAMK,YAAYf;IAElB,MAAMgB,eAAelB,QAAqD;QACxE,IAAImB,qBAAqBX,QAAQ;YAC/B,OAAOA;QACT;QAEA,MAAMY,QAAQ,AAACL,CAAAA,QAAQ,EAAE,AAAD,EACrBM,OAAO,CAAC,CAACC,YAAcA,UAAUC,KAAK,EACtCC,IAAI,CAAC,CAACC;YACL,OAAOjB,MAAMkB,IAAI,KAAKD,KAAKE,QAAQ,CAACD,IAAI,IAAIlB,MAAMD,IAAI,KAAKkB,KAAKE,QAAQ,CAACpB,IAAI,IAAI,CA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UAAU,CAACtF;AACvD;AAEA,OAAO,MAAM0F,kCAAkC,CAC7CvF,OACAS,WACA+E;IAEA,IAAI,CAAC7E,qBAAqBX,QAAQ;QAChC,OAAOA;IACT;IAEA,MAAM,CAACyF,aAAa,GAAG9F,eAAeK;IACtC,MAAMoC,WAAW3B,SAAS,CAACgF,gBAAgB,GAAG;IAE9C,kHAAkH;IAClH,IAAI,CAACrD,YAAYC,MAAMC,OAAO,CAACF,SAASpC,KAAK,GAAG;QAC9C,OAAOqE;IACT;IAEA,MAAM9B,uBAAuB,AAACiD,CAAAA,8BAA8B,EAAE,AAAD,EAC1D3E,OAAO,CAAC,CAACC,YAAcA,UAAUC,KAAK,EACtCC,IAAI,CAAC,CAAC0E,aAAeA,WAAW3F,IAAI,KAAKqC,SAASpC,KAAK;IAE1D,iGAAiG;IACjG,IAAIuC,yBAAyB8B,WAAW;QACtC,OAAOA;IACT;IAEA,MAAMsB,qBAAyC;QAC7CzE,MAAMqB,qBAAqBpB,QAAQ,CAACD,IAAI;QACxCnB,MAAMwC,qBAAqBpB,QAAQ,CAACpB,IAAI;IAC1C;IAEA,OAAO4F;AACT,EAAE;AAEF,OAAO,MAAMC,qCAAqC,CAChD5F,OACAG;IAEA,MAAM,EAAEI,IAAI,EAAE,GAAGd,6BAA6BU;IAC9C,MAAMM,YAAYf;IAClB,IAAI,CAACiB,qBAAqBX,QAAQ;QAChC,OAAOA;IACT;IAEA,OAAOuF,gCAAgCvF,OAAOS,WAAWF,SAAS;QAAEW,MAAMf;IAAqB;AACjG,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../../src/components/DatasourceSelect.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 OpenInNewIcon from 'mdi-material-ui/OpenInNew';\nimport {\n Stack,\n ListItemText,\n Chip,\n IconButton,\n Box,\n OutlinedSelectProps,\n BaseSelectProps,\n Autocomplete,\n TextField,\n} from '@mui/material';\nimport { DatasourceSelector, VariableName } from '@perses-dev/core';\nimport { ReactElement, useMemo } from 'react';\nimport {\n DatasourceSelectItem,\n DatasourceSelectItemGroup,\n DatasourceSelectItemSelector,\n useListDatasourceSelectItems,\n useVariableValues,\n VariableStateMap,\n} from '../runtime';\nimport { parseVariables } from '../utils';\n\nconst DATASOURCE_VARIABLE_VALUE_PREFIX = '__DATASOURCE_VARIABLE_VALUE__';\nconst VARIABLE_IDENTIFIER = '$';\n// Props on MUI Select that we don't want people to pass because we're either redefining them or providing them in\n// this component\ntype OmittedMuiProps = 'children' | 'value' | 'onChange';\n\ntype DataSourceOption = {\n groupEditLink?: string;\n groupLabel?: string;\n value: string;\n} & Omit<DatasourceSelectItem, 'selector'> &\n Omit<DatasourceSelectItem['selector'], 'kind'>;\n\nconst emptyDatasourceOption: DataSourceOption = { name: '', value: '' };\n\nexport type DatasourceSelectValue<T = DatasourceSelector> = T | VariableName;\n\nexport interface DatasourceSelectProps extends Omit<OutlinedSelectProps & BaseSelectProps<string>, OmittedMuiProps> {\n value: DatasourceSelectValue;\n onChange: (next: DatasourceSelectValue) => void;\n datasourcePluginKind: string;\n project?: string;\n}\n\n/**\n * Displays a MUI input for selecting a Datasource of a particular kind. Note: The 'value' and `onChange` handler for\n * the input deal with a `DatasourceSelector`.\n */\nexport function DatasourceSelect(props: DatasourceSelectProps): ReactElement {\n const { datasourcePluginKind, value, project, readOnly, onChange, ...others } = props;\n const { data, isLoading } = useListDatasourceSelectItems(datasourcePluginKind, project);\n const variables = useVariableValues();\n\n const defaultValue = useMemo<VariableName | DatasourceSelectItemSelector>(() => {\n if (isVariableDatasource(value)) {\n return value;\n }\n\n const group = (data ?? [])\n .flatMap((itemGroup) => itemGroup.items)\n .find((item) => {\n return value.kind === item.selector.kind && value.name === item.selector.name && !item.overridden;\n })?.selector.group;\n return { ...value, group };\n }, [value, data]);\n\n const options = useMemo<DataSourceOption[]>(() => {\n const datasourceOptions = (data || []).flatMap<DataSourceOption>((itemGroup) =>\n itemGroup.items.map<DataSourceOption>((item) => ({\n groupLabel: itemGroup.group,\n groupEditLink: itemGroup.editLink,\n name: item.name,\n overriding: item.overriding,\n overridden: item.overridden,\n saved: item.saved ?? true,\n group: item.selector.group,\n value: selectorToOptionValue(item.selector),\n }))\n );\n\n const datasourceOptionsMap = new Map(datasourceOptions.map((option) => [option.name, option]));\n\n const variableOptions = Object.entries(variables).flatMap<DataSourceOption>(([name, variable]) => {\n if (Array.isArray(variable.value)) return [];\n\n const associatedDatasource = datasourceOptionsMap.get(variable.value ?? '');\n if (!associatedDatasource) return [];\n\n return {\n groupLabel: 'Variables',\n name: `${VARIABLE_IDENTIFIER}${name}`,\n saved: true,\n value: `${DATASOURCE_VARIABLE_VALUE_PREFIX}${VARIABLE_IDENTIFIER}${name}`,\n };\n });\n\n return [...datasourceOptions, ...variableOptions];\n }, [data, variables]);\n\n // While loading available values, just use an empty datasource option so MUI select doesn't warn about values out of range\n const optionValue = isLoading\n ? emptyDatasourceOption\n : options.find((option) => option.value === selectorToOptionValue(defaultValue));\n\n // When the user makes a selection, convert the string option value back to a DatasourceSelector\n const handleChange = (selectedOption: DataSourceOption | null): void => {\n if (selectedOption) {\n const next = optionValueToSelector(selectedOption?.value || '');\n onChange(next);\n } else {\n onChange({ kind: datasourcePluginKind });\n }\n };\n\n // We use a fake action event when we click on the action of the chip (hijack the \"delete\" feature).\n // This is because the href link action is on the `deleteIcon` property already, but the `onDelete` property\n // controls its visibility.\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n const fakeActionEvent = (): void => {};\n\n return (\n <Autocomplete<DataSourceOption>\n readOnly={readOnly}\n options={options}\n renderInput={(params) => <TextField {...params} label={others.label} placeholder=\"\" />}\n groupBy={(option) => option.groupLabel || 'No group'}\n getOptionLabel={(option) => {\n return option.name;\n }}\n onChange={(_, v) => handleChange(v)}\n value={optionValue}\n renderOption={(props, option) => {\n return (\n <li {...props} key={option.value}>\n <Stack direction=\"row\" alignItems=\"center\" justifyContent=\"space-between\" width=\"100%\">\n <ListItemText>\n <DatasourceName name={option.name} overridden={option.overridden} overriding={option.overriding} />\n </ListItemText>\n {!option.saved && <ListItemText>Save the dashboard to enable this datasource</ListItemText>}\n <ListItemText style={{ textAlign: 'right' }}>\n {option.groupLabel && option.groupLabel.length > 0 && (\n <Chip\n disabled={false}\n label={option.groupLabel}\n size=\"small\"\n onDelete={option.groupEditLink ? fakeActionEvent : undefined}\n deleteIcon={\n option.groupEditLink ? (\n <IconButton href={option.groupEditLink} target=\"_blank\">\n <OpenInNewIcon fontSize=\"small\" />\n </IconButton>\n ) : undefined\n }\n />\n )}\n </ListItemText>\n </Stack>\n </li>\n );\n }}\n />\n );\n}\n\nexport function DatasourceName(props: { name: string; overridden?: boolean; overriding?: boolean }): ReactElement {\n const { name, overridden, overriding } = props;\n return (\n <>\n {`${name} `}\n {!overridden && overriding && (\n <Box display=\"inline\" fontWeight=\"normal\" color={(theme) => theme.palette.primary.main}>\n (overriding)\n </Box>\n )}\n {overridden && '(overridden)'}\n </>\n );\n}\n\n// Delimiter used to stringify/parse option values\nconst OPTION_VALUE_DELIMITER = '_____';\n\n/**\n * Given a DatasourceSelectItemSelector,\n * returns a string value like `{kind}_____{group}_____{name}` that can be used as a Select input value.\n * @param selector\n */\nexport function selectorToOptionValue(selector: DatasourceSelectItemSelector | VariableName): string {\n if (isVariableDatasource(selector)) {\n return `${DATASOURCE_VARIABLE_VALUE_PREFIX}${selector}`;\n }\n return [selector.kind, selector.group ?? '', selector.name ?? ''].join(OPTION_VALUE_DELIMITER);\n}\n\n/**\n * Given an option value name like `{kind}_____{group}_____{name}`,\n * returns a DatasourceSelector to be used by the query data model.\n * @param optionValue\n */\nexport function optionValueToSelector(optionValue: string): DatasourceSelectValue {\n if (optionValue.startsWith(DATASOURCE_VARIABLE_VALUE_PREFIX)) {\n return optionValue.split(DATASOURCE_VARIABLE_VALUE_PREFIX)[1]!;\n }\n\n const words = optionValue.split(OPTION_VALUE_DELIMITER);\n const kind = words[0];\n const name = words[2];\n if (kind === undefined || name === undefined) {\n throw new Error('Invalid optionValue string');\n }\n return {\n kind,\n name: name === '' ? undefined : name,\n };\n}\n\nexport function isVariableDatasource(value: DatasourceSelectValue | undefined): value is VariableName {\n return typeof value === 'string' && value.startsWith(VARIABLE_IDENTIFIER);\n}\n\nexport const datasourceSelectValueToSelector = (\n value: DatasourceSelectValue | undefined,\n variables: VariableStateMap,\n datasourceSelectItemGroups: DatasourceSelectItemGroup[] | undefined\n): DatasourceSelector | undefined => {\n if (!isVariableDatasource(value)) {\n return value;\n }\n\n const [variableName] = parseVariables(value);\n const variable = variables[variableName ?? ''];\n\n // If the variable is not defined or if its value is an array, we cannot determine a selector and return undefined\n if (!variable || Array.isArray(variable.value)) {\n return undefined;\n }\n\n const associatedDatasource = (datasourceSelectItemGroups || [])\n .flatMap((itemGroup) => itemGroup.items)\n .find((datasource) => datasource.name === variable.value);\n\n // If the variable value is not a datasource, we cannot determine a selector and return undefined\n if (associatedDatasource === undefined) {\n return undefined;\n }\n\n const datasourceSelector: DatasourceSelector = {\n kind: associatedDatasource.selector.kind,\n name: associatedDatasource.selector.name,\n };\n\n return datasourceSelector;\n};\n\nexport const useDatasourceSelectValueToSelector = (\n value: DatasourceSelectValue,\n datasourcePluginKind: string\n): DatasourceSelector => {\n const { data } = useListDatasourceSelectItems(datasourcePluginKind);\n const variables = useVariableValues();\n if (!isVariableDatasource(value)) {\n return value;\n }\n\n return datasourceSelectValueToSelector(value, variables, data) ?? { kind: datasourcePluginKind };\n};\n"],"names":["OpenInNewIcon","Stack","ListItemText","Chip","IconButton","Box","Autocomplete","TextField","useMemo","useListDatasourceSelectItems","useVariableValues","parseVariables","DATASOURCE_VARIABLE_VALUE_PREFIX","VARIABLE_IDENTIFIER","emptyDatasourceOption","name","value","DatasourceSelect","props","datasourcePluginKind","project","readOnly","onChange","others","data","isLoading","variables","defaultValue","isVariableDatasource","group","flatMap","itemGroup","items","find","item","kind","selector","overridden","options","datasourceOptions","map","groupLabel","groupEditLink","editLink","overriding","saved","selectorToOptionValue","datasourceOptionsMap","Map","option","variableOptions","Object","entries","variable","Array","isArray","associatedDatasource","get","optionValue","handleChange","selectedOption","next","optionValueToSelector","fakeActionEvent","renderInput","params","label","placeholder","groupBy","getOptionLabel","_","v","renderOption","li","key","direction","alignItems","justifyContent","width","DatasourceName","style","textAlign","length","disabled","size","onDelete","undefined","deleteIcon","href","target","fontSize","display","fontWeight","color","theme","palette","primary","main","OPTION_VALUE_DELIMITER","join","startsWith","split","words","Error","datasourceSelectValueToSelector","datasourceSelectItemGroups","variableName","datasource","datasourceSelector","useDatasourceSelectValueToSelector"],"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,OAAOA,mBAAmB,4BAA4B;AACtD,SACEC,KAAK,EACLC,YAAY,EACZC,IAAI,EACJC,UAAU,EACVC,GAAG,EAGHC,YAAY,EACZC,SAAS,QACJ,gBAAgB;AAEvB,SAAuBC,OAAO,QAAQ,QAAQ;AAC9C,SAIEC,4BAA4B,EAC5BC,iBAAiB,QAEZ,aAAa;AACpB,SAASC,cAAc,QAAQ,WAAW;AAE1C,MAAMC,mCAAmC;AACzC,MAAMC,sBAAsB;AAY5B,MAAMC,wBAA0C;IAAEC,MAAM;IAAIC,OAAO;AAAG;AAWtE;;;CAGC,GACD,OAAO,SAASC,iBAAiBC,KAA4B;IAC3D,MAAM,EAAEC,oBAAoB,EAAEH,KAAK,E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O,MAAMC,qCAAqC,CAChD7F,OACAG;IAEA,MAAM,EAAEK,IAAI,EAAE,GAAGf,6BAA6BU;IAC9C,MAAMO,YAAYhB;IAClB,IAAI,CAACkB,qBAAqBZ,QAAQ;QAChC,OAAOA;IACT;IAEA,OAAOwF,gCAAgCxF,OAAOU,WAAWF,SAAS;QAAEW,MAAMhB;IAAqB;AACjG,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LegendOptionsEditor.d.ts","sourceRoot":"","sources":["../../../src/components/LegendOptionsEditor/LegendOptionsEditor.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,YAAY,EAAW,MAAM,OAAO,CAAC;AAC9C,OAAO,EAGL,iBAAiB,EAQlB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"LegendOptionsEditor.d.ts","sourceRoot":"","sources":["../../../src/components/LegendOptionsEditor/LegendOptionsEditor.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,YAAY,EAAW,MAAM,OAAO,CAAC;AAC9C,OAAO,EAGL,iBAAiB,EAQlB,MAAM,aAAa,CAAC;AAsBrB,MAAM,WAAW,wBAAwB;IACvC,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC/C,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,WAAW,CAAC,EAAE,aAAa,GAAG,YAAY,CAAC;CAC5C;AAED,wBAAgB,mBAAmB,CAAC,EAClC,KAAK,EACL,QAAQ,EACR,gBAAuB,EACvB,WAA2B,GAC5B,EAAE,wBAAwB,GAAG,YAAY,CAgLzC"}
|