@perses-dev/plugin-system 0.43.0-rc2 → 0.44.0-rc0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/CalculationSelector/CalculationSelector.js +1 -1
- package/dist/cjs/components/DatasourceEditorForm/DatasourceEditorForm.js +8 -8
- package/dist/cjs/components/DatasourceSelect.js +11 -9
- package/dist/cjs/components/LegendOptionsEditor/LegendOptionsEditor.js +1 -1
- package/dist/cjs/components/OptionsEditorRadios/OptionsEditorRadios.js +3 -3
- package/dist/cjs/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js +1 -1
- package/dist/cjs/components/OptionsEditorTabs/OptionsEditorTabs.js +3 -3
- package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +49 -11
- package/dist/cjs/components/PluginEditor/PluginEditor.js +2 -3
- package/dist/cjs/components/PluginEditor/plugin-editor-api.js +3 -3
- package/dist/cjs/components/PluginKindSelect/PluginKindSelect.js +2 -2
- package/dist/cjs/components/PluginRegistry/PluginRegistry.js +1 -1
- package/dist/cjs/components/PluginRegistry/plugin-indexes.js +4 -4
- package/dist/cjs/components/PluginSpecEditor/PluginSpecEditor.js +3 -3
- package/dist/cjs/components/ProjectSelect.js +2 -2
- package/dist/cjs/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js +3 -3
- package/dist/cjs/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js +3 -3
- package/dist/cjs/components/TraceQueryEditor/TraceQueryEditor.js +143 -0
- package/dist/cjs/components/TraceQueryEditor/TraceQueryInput.js +96 -0
- package/dist/cjs/components/TraceQueryEditor/index.js +30 -0
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +29 -23
- package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +10 -8
- package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +1 -1
- package/dist/cjs/components/Variables/variable-model.js +12 -13
- package/dist/cjs/context/ProjectStoreProvider.js +5 -5
- package/dist/cjs/model/legend.js +5 -5
- package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +6 -6
- package/dist/cjs/runtime/DataQueriesProvider/model.js +3 -3
- package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +8 -6
- package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.js +3 -3
- package/dist/cjs/runtime/TimeRangeProvider/query-params.js +16 -16
- package/dist/cjs/runtime/builtin-variables.js +5 -5
- package/dist/cjs/runtime/datasources.js +7 -7
- package/dist/cjs/runtime/plugin-registry.js +12 -12
- package/dist/cjs/runtime/template-variables.js +15 -7
- package/dist/cjs/runtime/time-series-queries.js +14 -14
- package/dist/cjs/runtime/trace-queries.js +24 -7
- package/dist/cjs/stories/shared-utils/decorators/WithPluginRegistry.js +3 -1
- package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +1 -1
- package/dist/cjs/test/test-plugins/bert/index.js +2 -2
- package/dist/cjs/test/test-plugins/ernie/index.js +2 -2
- package/dist/cjs/test/test-plugins/index.js +3 -1
- package/dist/cjs/test-utils/mock-plugin-registry.js +4 -4
- package/dist/cjs/utils/action.js +3 -3
- package/dist/cjs/utils/variables.js +4 -4
- package/dist/cjs/validation/role.js +3 -3
- package/dist/cjs/validation/secret.js +3 -3
- package/dist/components/CalculationSelector/CalculationSelector.d.ts +1 -2
- package/dist/components/CalculationSelector/CalculationSelector.d.ts.map +1 -1
- package/dist/components/CalculationSelector/CalculationSelector.js +1 -1
- package/dist/components/CalculationSelector/CalculationSelector.js.map +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +8 -8
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
- package/dist/components/DatasourceSelect.d.ts +3 -4
- package/dist/components/DatasourceSelect.d.ts.map +1 -1
- package/dist/components/DatasourceSelect.js +8 -6
- package/dist/components/DatasourceSelect.js.map +1 -1
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts +1 -2
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts.map +1 -1
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +1 -1
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.d.ts +3 -3
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.d.ts.map +1 -1
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js +3 -3
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js.map +1 -1
- package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.d.ts +1 -1
- package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.d.ts.map +1 -1
- package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js +1 -1
- package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js.map +1 -1
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts +3 -3
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts.map +1 -1
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js +3 -3
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts +1 -2
- package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js +49 -11
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
- package/dist/components/PluginEditor/PluginEditor.d.ts +1 -2
- package/dist/components/PluginEditor/PluginEditor.d.ts.map +1 -1
- package/dist/components/PluginEditor/PluginEditor.js +2 -3
- package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.d.ts +3 -3
- package/dist/components/PluginEditor/plugin-editor-api.d.ts.map +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.js +3 -3
- package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.d.ts +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.d.ts.map +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.js +2 -2
- package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.d.ts +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.d.ts.map +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.js +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
- package/dist/components/PluginRegistry/plugin-indexes.js +1 -1
- package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
- package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts +1 -2
- package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts.map +1 -1
- package/dist/components/PluginSpecEditor/PluginSpecEditor.js +3 -3
- package/dist/components/PluginSpecEditor/PluginSpecEditor.js.map +1 -1
- package/dist/components/ProjectSelect.d.ts +2 -3
- package/dist/components/ProjectSelect.d.ts.map +1 -1
- package/dist/components/ProjectSelect.js +2 -2
- package/dist/components/ProjectSelect.js.map +1 -1
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts +1 -2
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts.map +1 -1
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js +3 -3
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js.map +1 -1
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts +1 -2
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts.map +1 -1
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js +3 -3
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js.map +1 -1
- package/dist/components/TraceQueryEditor/TraceQueryEditor.d.ts +8 -0
- package/dist/components/TraceQueryEditor/TraceQueryEditor.d.ts.map +1 -0
- package/dist/components/TraceQueryEditor/TraceQueryEditor.js +130 -0
- package/dist/components/TraceQueryEditor/TraceQueryEditor.js.map +1 -0
- package/dist/components/TraceQueryEditor/TraceQueryInput.d.ts +12 -0
- package/dist/components/TraceQueryEditor/TraceQueryInput.d.ts.map +1 -0
- package/dist/components/TraceQueryEditor/TraceQueryInput.js +83 -0
- package/dist/components/TraceQueryEditor/TraceQueryInput.js.map +1 -0
- package/dist/components/TraceQueryEditor/index.d.ts +2 -0
- package/dist/components/TraceQueryEditor/index.d.ts.map +1 -0
- package/dist/components/TraceQueryEditor/index.js +15 -0
- package/dist/components/TraceQueryEditor/index.js.map +1 -0
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +26 -22
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts +2 -3
- package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js +4 -4
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
- package/dist/components/Variables/variable-model.d.ts.map +1 -1
- package/dist/components/Variables/variable-model.js +6 -7
- package/dist/components/Variables/variable-model.js.map +1 -1
- package/dist/context/ProjectStoreProvider.d.ts +1 -1
- package/dist/context/ProjectStoreProvider.d.ts.map +1 -1
- package/dist/context/ProjectStoreProvider.js +2 -2
- package/dist/context/ProjectStoreProvider.js.map +1 -1
- package/dist/context/query-params.js.map +1 -1
- package/dist/model/datasource.js +3 -1
- package/dist/model/datasource.js.map +1 -1
- package/dist/model/legend.d.ts +2 -2
- package/dist/model/legend.d.ts.map +1 -1
- package/dist/model/legend.js.map +1 -1
- package/dist/model/panels.d.ts +3 -2
- package/dist/model/panels.d.ts.map +1 -1
- package/dist/model/panels.js.map +1 -1
- package/dist/model/plugin-loading.js.map +1 -1
- package/dist/model/plugins.d.ts +4 -4
- package/dist/model/plugins.d.ts.map +1 -1
- package/dist/model/plugins.js.map +1 -1
- package/dist/model/time-series-queries.d.ts +2 -2
- package/dist/model/time-series-queries.d.ts.map +1 -1
- package/dist/model/time-series-queries.js.map +1 -1
- package/dist/model/trace-queries.d.ts +3 -2
- package/dist/model/trace-queries.d.ts.map +1 -1
- package/dist/model/trace-queries.js.map +1 -1
- package/dist/model/variables.d.ts +2 -2
- package/dist/model/variables.d.ts.map +1 -1
- package/dist/model/variables.js +3 -1
- package/dist/model/variables.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts +1 -1
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts.map +1 -1
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +2 -2
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.d.ts +2 -2
- package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.js +3 -3
- package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.d.ts +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.d.ts.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.js +3 -3
- package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/query-params.d.ts +1 -1
- package/dist/runtime/TimeRangeProvider/query-params.d.ts.map +1 -1
- package/dist/runtime/TimeRangeProvider/query-params.js +4 -4
- package/dist/runtime/TimeRangeProvider/query-params.js.map +1 -1
- package/dist/runtime/builtin-variables.d.ts +1 -1
- package/dist/runtime/builtin-variables.d.ts.map +1 -1
- package/dist/runtime/builtin-variables.js +2 -2
- package/dist/runtime/builtin-variables.js.map +1 -1
- package/dist/runtime/datasources.js +1 -1
- package/dist/runtime/datasources.js.map +1 -1
- package/dist/runtime/plugin-registry.d.ts +2 -2
- package/dist/runtime/plugin-registry.d.ts.map +1 -1
- package/dist/runtime/plugin-registry.js +4 -4
- package/dist/runtime/plugin-registry.js.map +1 -1
- package/dist/runtime/template-variables.d.ts +4 -4
- package/dist/runtime/template-variables.d.ts.map +1 -1
- package/dist/runtime/template-variables.js +10 -2
- package/dist/runtime/template-variables.js.map +1 -1
- package/dist/runtime/time-series-queries.js +7 -7
- package/dist/runtime/time-series-queries.js.map +1 -1
- package/dist/runtime/trace-queries.d.ts +6 -2
- package/dist/runtime/trace-queries.d.ts.map +1 -1
- package/dist/runtime/trace-queries.js +21 -7
- package/dist/runtime/trace-queries.js.map +1 -1
- package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts +2 -3
- package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts.map +1 -1
- package/dist/stories/shared-utils/decorators/WithDataQueries.js.map +1 -1
- package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts +1 -2
- package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts.map +1 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.d.ts +2 -3
- package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.d.ts.map +1 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js.map +1 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts +2 -3
- package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts.map +1 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +1 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js.map +1 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.d.ts +2 -3
- package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.d.ts.map +1 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.js.map +1 -1
- package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts +2 -3
- package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts.map +1 -1
- package/dist/stories/shared-utils/decorators/WithTimeRange.js.map +1 -1
- package/dist/test/render.d.ts +1 -1
- package/dist/test/render.d.ts.map +1 -1
- package/dist/test/render.js.map +1 -1
- package/dist/test/setup-tests.js.map +1 -1
- package/dist/test/test-plugins/bert/index.js +2 -2
- package/dist/test/test-plugins/bert/index.js.map +1 -1
- package/dist/test/test-plugins/ernie/index.js +2 -2
- package/dist/test/test-plugins/ernie/index.js.map +1 -1
- package/dist/test-utils/mock-plugin-registry.d.ts +1 -1
- package/dist/test-utils/mock-plugin-registry.d.ts.map +1 -1
- package/dist/test-utils/mock-plugin-registry.js +1 -1
- package/dist/test-utils/mock-plugin-registry.js.map +1 -1
- package/dist/utils/variables.js.map +1 -1
- package/dist/validation/datasource.d.ts +1 -1
- package/dist/validation/datasource.d.ts.map +1 -1
- package/dist/validation/datasource.js.map +1 -1
- package/dist/validation/resource.js.map +1 -1
- package/dist/validation/role.d.ts +43 -43
- package/dist/validation/role.d.ts.map +1 -1
- package/dist/validation/role.js.map +1 -1
- package/dist/validation/rolebinding.d.ts +10 -10
- package/dist/validation/rolebinding.d.ts.map +1 -1
- package/dist/validation/rolebinding.js.map +1 -1
- package/dist/validation/secret.d.ts +19 -19
- package/dist/validation/secret.d.ts.map +1 -1
- package/dist/validation/secret.js.map +1 -1
- package/dist/validation/variable.d.ts +1 -1
- package/dist/validation/variable.d.ts.map +1 -1
- package/dist/validation/variable.js.map +1 -1
- package/package.json +4 -4
|
@@ -29,7 +29,7 @@ function FallbackPreview() {
|
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
export function VariableEditorForm(props) {
|
|
32
|
-
const { initialVariableDefinition
|
|
32
|
+
const { initialVariableDefinition, initialAction, isDraft, isReadonly, onSave, onClose, onDelete } = props;
|
|
33
33
|
const initialState = getInitialState(initialVariableDefinition);
|
|
34
34
|
const [state, setState] = useImmer(initialState);
|
|
35
35
|
const [isDiscardDialogOpened, setDiscardDialogOpened] = useState(false);
|
|
@@ -77,7 +77,6 @@ export function VariableEditorForm(props) {
|
|
|
77
77
|
state,
|
|
78
78
|
onClose
|
|
79
79
|
]);
|
|
80
|
-
var _state_title, _state_description, _state_listVariableFields_capturingRegexp, _state_listVariableFields_sort, _state_listVariableFields_customAllValue;
|
|
81
80
|
return /*#__PURE__*/ _jsxs(FormProvider, {
|
|
82
81
|
...form,
|
|
83
82
|
children: [
|
|
@@ -171,9 +170,9 @@ export function VariableEditorForm(props) {
|
|
|
171
170
|
xs: 8,
|
|
172
171
|
children: /*#__PURE__*/ _jsx(Controller, {
|
|
173
172
|
name: "name",
|
|
174
|
-
render: ({ field
|
|
173
|
+
render: ({ field, fieldState })=>{
|
|
175
174
|
var _fieldState_error;
|
|
176
|
-
/*#__PURE__*/
|
|
175
|
+
return /*#__PURE__*/ _jsx(TextField, {
|
|
177
176
|
...field,
|
|
178
177
|
required: true,
|
|
179
178
|
fullWidth: true,
|
|
@@ -203,9 +202,10 @@ export function VariableEditorForm(props) {
|
|
|
203
202
|
xs: 4,
|
|
204
203
|
children: /*#__PURE__*/ _jsx(Controller, {
|
|
205
204
|
name: "title",
|
|
206
|
-
render: ({ field
|
|
205
|
+
render: ({ field, fieldState })=>/*#__PURE__*/ {
|
|
207
206
|
var _fieldState_error;
|
|
208
|
-
|
|
207
|
+
var _state_title;
|
|
208
|
+
return _jsx(TextField, {
|
|
209
209
|
...field,
|
|
210
210
|
fullWidth: true,
|
|
211
211
|
label: "Display Label",
|
|
@@ -233,9 +233,10 @@ export function VariableEditorForm(props) {
|
|
|
233
233
|
xs: 8,
|
|
234
234
|
children: /*#__PURE__*/ _jsx(Controller, {
|
|
235
235
|
name: "description",
|
|
236
|
-
render: ({ field
|
|
236
|
+
render: ({ field, fieldState })=>/*#__PURE__*/ {
|
|
237
237
|
var _fieldState_error;
|
|
238
|
-
|
|
238
|
+
var _state_description;
|
|
239
|
+
return _jsx(TextField, {
|
|
239
240
|
...field,
|
|
240
241
|
fullWidth: true,
|
|
241
242
|
label: "Description",
|
|
@@ -263,9 +264,9 @@ export function VariableEditorForm(props) {
|
|
|
263
264
|
xs: 4,
|
|
264
265
|
children: /*#__PURE__*/ _jsx(Controller, {
|
|
265
266
|
name: "kind",
|
|
266
|
-
render: ({ field
|
|
267
|
+
render: ({ field, fieldState })=>{
|
|
267
268
|
var _fieldState_error;
|
|
268
|
-
/*#__PURE__*/
|
|
269
|
+
return /*#__PURE__*/ _jsx(TextField, {
|
|
269
270
|
select: true,
|
|
270
271
|
...field,
|
|
271
272
|
fullWidth: true,
|
|
@@ -315,9 +316,9 @@ export function VariableEditorForm(props) {
|
|
|
315
316
|
}),
|
|
316
317
|
/*#__PURE__*/ _jsx(Controller, {
|
|
317
318
|
name: "textVariableFields.value",
|
|
318
|
-
render: ({ field
|
|
319
|
+
render: ({ field, fieldState })=>{
|
|
319
320
|
var _fieldState_error;
|
|
320
|
-
/*#__PURE__*/
|
|
321
|
+
return /*#__PURE__*/ _jsx(TextField, {
|
|
321
322
|
...field,
|
|
322
323
|
label: "Value",
|
|
323
324
|
InputLabelProps: {
|
|
@@ -340,7 +341,7 @@ export function VariableEditorForm(props) {
|
|
|
340
341
|
}),
|
|
341
342
|
/*#__PURE__*/ _jsx(Controller, {
|
|
342
343
|
name: "textVariableFields.constant",
|
|
343
|
-
render: ({ field
|
|
344
|
+
render: ({ field })=>/*#__PURE__*/ _jsx(FormControlLabel, {
|
|
344
345
|
label: "Constant",
|
|
345
346
|
control: /*#__PURE__*/ _jsx(Switch, {
|
|
346
347
|
...field,
|
|
@@ -394,7 +395,7 @@ export function VariableEditorForm(props) {
|
|
|
394
395
|
}),
|
|
395
396
|
/*#__PURE__*/ _jsx(Controller, {
|
|
396
397
|
name: "listVariableFields.plugin",
|
|
397
|
-
render: ({ field
|
|
398
|
+
render: ({ field })=>/*#__PURE__*/ _jsx(PluginEditor, {
|
|
398
399
|
width: "100%",
|
|
399
400
|
pluginType: "Variable",
|
|
400
401
|
pluginKindLabel: "Source",
|
|
@@ -413,9 +414,10 @@ export function VariableEditorForm(props) {
|
|
|
413
414
|
/*#__PURE__*/ _jsx(Stack, {
|
|
414
415
|
children: /*#__PURE__*/ _jsx(Controller, {
|
|
415
416
|
name: "listVariableFields.capturingRegexp",
|
|
416
|
-
render: ({ field
|
|
417
|
+
render: ({ field, fieldState })=>/*#__PURE__*/ {
|
|
417
418
|
var _fieldState_error;
|
|
418
|
-
|
|
419
|
+
var _state_listVariableFields_capturingRegexp;
|
|
420
|
+
return _jsx(TextField, {
|
|
419
421
|
...field,
|
|
420
422
|
label: "Capturing Regexp Filter",
|
|
421
423
|
InputLabelProps: {
|
|
@@ -445,9 +447,10 @@ export function VariableEditorForm(props) {
|
|
|
445
447
|
/*#__PURE__*/ _jsx(Stack, {
|
|
446
448
|
children: /*#__PURE__*/ _jsx(Controller, {
|
|
447
449
|
name: "listVariableFields.sort",
|
|
448
|
-
render: ({ field
|
|
450
|
+
render: ({ field, fieldState })=>/*#__PURE__*/ {
|
|
449
451
|
var _fieldState_error;
|
|
450
|
-
|
|
452
|
+
var _state_listVariableFields_sort;
|
|
453
|
+
return _jsxs(TextField, {
|
|
451
454
|
select: true,
|
|
452
455
|
...field,
|
|
453
456
|
fullWidth: true,
|
|
@@ -516,7 +519,7 @@ export function VariableEditorForm(props) {
|
|
|
516
519
|
children: [
|
|
517
520
|
/*#__PURE__*/ _jsx(Controller, {
|
|
518
521
|
name: "listVariableFields.allowMultiple",
|
|
519
|
-
render: ({ field
|
|
522
|
+
render: ({ field })=>/*#__PURE__*/ _jsx(FormControlLabel, {
|
|
520
523
|
label: "Allow Multiple Values",
|
|
521
524
|
control: /*#__PURE__*/ _jsx(Switch, {
|
|
522
525
|
...field,
|
|
@@ -543,7 +546,7 @@ export function VariableEditorForm(props) {
|
|
|
543
546
|
children: [
|
|
544
547
|
/*#__PURE__*/ _jsx(Controller, {
|
|
545
548
|
name: "listVariableFields.allowAllValue",
|
|
546
|
-
render: ({ field
|
|
549
|
+
render: ({ field })=>/*#__PURE__*/ _jsx(FormControlLabel, {
|
|
547
550
|
label: "Allow All option",
|
|
548
551
|
control: /*#__PURE__*/ _jsx(Switch, {
|
|
549
552
|
...field,
|
|
@@ -567,9 +570,10 @@ export function VariableEditorForm(props) {
|
|
|
567
570
|
}),
|
|
568
571
|
state.listVariableFields.allowAllValue && /*#__PURE__*/ _jsx(Controller, {
|
|
569
572
|
name: "listVariableFields.customAllValue",
|
|
570
|
-
render: ({ field
|
|
573
|
+
render: ({ field, fieldState })=>/*#__PURE__*/ {
|
|
571
574
|
var _fieldState_error;
|
|
572
|
-
|
|
575
|
+
var _state_listVariableFields_customAllValue;
|
|
576
|
+
return _jsx(TextField, {
|
|
573
577
|
...field,
|
|
574
578
|
fullWidth: true,
|
|
575
579
|
label: "Custom All Value",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/Variables/VariableEditorForm/VariableEditorForm.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 React, { DispatchWithoutAction, useCallback, useMemo, useState } from 'react';\nimport {\n Box,\n Typography,\n Switch,\n TextField,\n Grid,\n FormControlLabel,\n MenuItem,\n Button,\n Stack,\n ClickAwayListener,\n Divider,\n} from '@mui/material';\nimport { VariableDefinition, ListVariableDefinition, Action } from '@perses-dev/core';\nimport { DiscardChangesConfirmationDialog, ErrorBoundary } from '@perses-dev/components';\nimport { Controller, FormProvider, SubmitHandler, useForm } from 'react-hook-form';\nimport { zodResolver } from '@hookform/resolvers/zod';\nimport { useImmer } from 'use-immer';\nimport { getSubmitText, getTitleAction } from '../../../utils';\nimport { VARIABLE_TYPES } from '../variable-model';\nimport { PluginEditor } from '../../PluginEditor';\nimport { variableEditorValidationSchema, VariableEditorValidationType } from '../../../validation';\nimport { VariableListPreview, VariablePreview } from './VariablePreview';\nimport { getVariableDefinitionFromState, getInitialState, VariableEditorState } from './variable-editor-form-model';\n\nfunction FallbackPreview() {\n return <div>Error previewing values</div>;\n}\n\ninterface VariableEditorFormProps {\n initialVariableDefinition: VariableDefinition;\n initialAction: Action;\n isDraft: boolean;\n isReadonly?: boolean;\n onSave: (def: VariableDefinition) => void;\n onClose: () => void;\n onDelete?: DispatchWithoutAction;\n}\n\nexport function VariableEditorForm(props: VariableEditorFormProps) {\n const { initialVariableDefinition, initialAction, isDraft, isReadonly, onSave, onClose, onDelete } = props;\n\n const initialState = getInitialState(initialVariableDefinition);\n const [state, setState] = useImmer(initialState);\n const [isDiscardDialogOpened, setDiscardDialogOpened] = useState<boolean>(false);\n const [previewKey, setPreviewKey] = useState(0);\n const [action, setAction] = useState(initialAction);\n\n const refreshPreview = () => {\n setPreviewKey((prev) => prev + 1);\n };\n\n /** We use the `previewKey` that we increment to know when to explicitly update the\n * spec that will be used for preview. The reason why we do this is to avoid\n * having to re-fetch the values when the user is still editing the spec.\n */\n const previewSpec = useMemo(() => {\n return getVariableDefinitionFromState(state) as ListVariableDefinition;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [previewKey]);\n\n const titleAction = getTitleAction(action, isDraft);\n const submitText = getSubmitText(action, isDraft);\n\n const form = useForm<VariableEditorValidationType>({\n resolver: zodResolver(variableEditorValidationSchema),\n mode: 'onBlur',\n defaultValues: initialState,\n });\n\n const processForm: SubmitHandler<VariableEditorValidationType> = () => {\n // reset display attributes to undefined when empty, because we don't want to save empty strings\n onSave(\n getVariableDefinitionFromState({\n ...state,\n title: state.title === '' ? undefined : state.title,\n description: state.description === '' ? undefined : state.description,\n })\n );\n };\n\n // When user click on cancel, several possibilities:\n // - create action: ask for discard approval\n // - update action: ask for discard approval if changed\n // - read action: don´t ask for discard approval\n const handleCancel = useCallback(() => {\n if (JSON.stringify(initialState) !== JSON.stringify(state)) {\n setDiscardDialogOpened(true);\n } else {\n onClose();\n }\n }, [initialState, state, onClose]);\n\n return (\n <FormProvider {...form}>\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n padding: (theme) => theme.spacing(1, 2),\n borderBottom: (theme) => `1px solid ${theme.palette.divider}`,\n }}\n >\n <Typography variant=\"h2\">{titleAction} Variable</Typography>\n <Stack direction=\"row\" spacing={1} sx={{ marginLeft: 'auto' }}>\n {action === 'read' ? (\n <>\n <Button disabled={isReadonly} variant=\"contained\" onClick={() => setAction('update')}>\n Edit\n </Button>\n <Button color=\"error\" disabled={isReadonly} variant=\"outlined\" onClick={onDelete}>\n Delete\n </Button>\n <Divider\n orientation=\"vertical\"\n flexItem\n sx={(theme) => ({\n borderColor: theme.palette.grey['500'],\n '&.MuiDivider-root': {\n marginLeft: 2,\n marginRight: 1,\n },\n })}\n />\n <Button color=\"secondary\" variant=\"outlined\" onClick={onClose}>\n Close\n </Button>\n </>\n ) : (\n <>\n <Button\n type=\"submit\"\n variant=\"contained\"\n disabled={!form.formState.isValid}\n onClick={form.handleSubmit(processForm)}\n >\n {submitText}\n </Button>\n <Button color=\"secondary\" variant=\"outlined\" onClick={handleCancel}>\n Cancel\n </Button>\n </>\n )}\n </Stack>\n </Box>\n <Box padding={2} sx={{ overflowY: 'scroll' }}>\n <Grid container spacing={2} mb={2}>\n <Grid item xs={8}>\n <Controller\n name=\"name\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n required\n fullWidth\n label=\"Name\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n disabled: action === 'update' && !isDraft,\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={state.name}\n onChange={(event) => {\n field.onChange(event);\n setState((draft) => {\n draft.name = event.target.value;\n });\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={4}>\n <Controller\n name=\"title\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"Display Label\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={state.title ?? ''}\n onChange={(event) => {\n field.onChange(event);\n setState((draft) => {\n draft.title = event.target.value;\n });\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={8}>\n <Controller\n name=\"description\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"Description\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={state.description ?? ''}\n onChange={(event) => {\n field.onChange(event);\n setState((draft) => {\n draft.description = event.target.value;\n });\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={4}>\n <Controller\n name=\"kind\"\n render={({ field, fieldState }) => (\n <TextField\n select\n {...field}\n fullWidth\n label=\"Type\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={state.kind}\n onChange={(event) => {\n field.onChange(event);\n setState((draft) => {\n draft.kind = event.target.value as VariableEditorState['kind'];\n });\n }}\n >\n {VARIABLE_TYPES.map((v) => (\n <MenuItem key={v.kind} value={v.kind}>\n {v.label}\n </MenuItem>\n ))}\n </TextField>\n )}\n />\n </Grid>\n </Grid>\n\n <Divider />\n\n {state.kind === 'TextVariable' && (\n <>\n <Typography py={1} variant=\"subtitle1\">\n Text Options\n </Typography>\n <Stack spacing={2}>\n <Box>\n <VariablePreview values={[state.textVariableFields.value]} />\n </Box>\n <Controller\n name=\"textVariableFields.value\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n label=\"Value\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={state.textVariableFields.value}\n onChange={(event) => {\n field.onChange(event);\n setState((draft) => {\n draft.textVariableFields.value = event.target.value;\n });\n }}\n />\n )}\n />\n <Controller\n name=\"textVariableFields.constant\"\n render={({ field }) => (\n <FormControlLabel\n label=\"Constant\"\n control={\n <Switch\n {...field}\n checked={!!field.value}\n readOnly={action === 'read'}\n value={state.textVariableFields.constant}\n onChange={(event) => {\n if (action === 'read') return; // ReadOnly prop is not blocking user interaction...\n field.onChange(event);\n setState((draft) => {\n draft.textVariableFields.constant = event.target.checked;\n });\n }}\n />\n }\n />\n )}\n />\n </Stack>\n </>\n )}\n\n {state.kind === 'ListVariable' && (\n <>\n <Typography py={1} variant=\"subtitle1\">\n List Options\n </Typography>\n <Stack spacing={2} mb={2}>\n {state.listVariableFields.plugin.kind ? (\n <Box>\n <ErrorBoundary FallbackComponent={FallbackPreview} resetKeys={[previewSpec]}>\n <VariableListPreview definition={previewSpec} onRefresh={refreshPreview} />\n </ErrorBoundary>\n </Box>\n ) : (\n <VariablePreview isLoading={true} />\n )}\n\n <Stack>\n {/** Hack?: Cool technique to refresh the preview to simulate onBlur event */}\n <ClickAwayListener onClickAway={() => refreshPreview()}>\n <Box />\n </ClickAwayListener>\n {/** */}\n <Controller\n name=\"listVariableFields.plugin\"\n render={({ field }) => (\n <PluginEditor\n width=\"100%\"\n pluginType=\"Variable\"\n pluginKindLabel=\"Source\"\n isReadonly={action === 'read'}\n value={state.listVariableFields.plugin}\n onChange={(val) => {\n field.onChange(val);\n setState((draft) => {\n draft.listVariableFields.plugin = val;\n });\n }}\n />\n )}\n />\n </Stack>\n\n <Stack>\n <Controller\n name=\"listVariableFields.capturingRegexp\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n label=\"Capturing Regexp Filter\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n value={state.listVariableFields.capturingRegexp ?? ''}\n onChange={(event) => {\n field.onChange(event);\n setState((draft) => {\n if (event.target.value) {\n // TODO: do a better fix, if empty string => it should skip the filter\n draft.listVariableFields.capturingRegexp = event.target.value;\n } else {\n draft.listVariableFields.capturingRegexp = undefined;\n }\n });\n }}\n helperText={\n fieldState.error?.message\n ? fieldState.error.message\n : 'Optional, if you want to filter on captured result.'\n }\n />\n )}\n />\n </Stack>\n\n <Stack>\n <Controller\n name=\"listVariableFields.sort\"\n render={({ field, fieldState }) => (\n <TextField\n select\n {...field}\n fullWidth\n label=\"Sort\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={state.listVariableFields.sort ?? 'none'}\n onChange={(event) => {\n field.onChange(event);\n setState((draft) => {\n draft.listVariableFields.sort = event.target.value;\n });\n }}\n >\n <MenuItem value=\"none\">None</MenuItem>\n <MenuItem value=\"alphabetical-asc\">Alphabetical, asc</MenuItem>\n <MenuItem value=\"alphabetical-desc\">Alphabetical, desc</MenuItem>\n <MenuItem value=\"numerical-asc\">Numerical, asc</MenuItem>\n <MenuItem value=\"numerical-desc\">Numerical, desc</MenuItem>\n <MenuItem value=\"alphabetical-ci-asc\">Alphabetical, case-insensitive, asc</MenuItem>\n <MenuItem value=\"alphabetical-ci-desc\">Alphabetical, case-insensitive, desc</MenuItem>\n </TextField>\n )}\n />\n </Stack>\n </Stack>\n\n <Divider />\n\n <Typography py={1} variant=\"subtitle1\">\n Dropdown Options\n </Typography>\n <Stack spacing=\"2\">\n <Stack>\n <Controller\n name=\"listVariableFields.allowMultiple\"\n render={({ field }) => (\n <FormControlLabel\n label=\"Allow Multiple Values\"\n control={\n <Switch\n {...field}\n checked={!!field.value}\n readOnly={action === 'read'}\n value={state.listVariableFields.allowMultiple}\n onChange={(event) => {\n if (action === 'read') return; // ReadOnly prop is not blocking user interaction...\n field.onChange(event);\n setState((draft) => {\n draft.listVariableFields.allowMultiple = event.target.checked;\n });\n }}\n />\n }\n />\n )}\n />\n <Typography variant=\"caption\">Enables multiple values to be selected at the same time</Typography>\n </Stack>\n <Stack>\n <Controller\n name=\"listVariableFields.allowAllValue\"\n render={({ field }) => (\n <FormControlLabel\n label=\"Allow All option\"\n control={\n <Switch\n {...field}\n checked={!!field.value}\n readOnly={action === 'read'}\n value={state.listVariableFields.allowAllValue}\n onChange={(event) => {\n if (action === 'read') return; // ReadOnly prop is not blocking user interaction...\n field.onChange(event);\n setState((draft) => {\n draft.listVariableFields.allowAllValue = event.target.checked;\n });\n }}\n />\n }\n />\n )}\n />\n <Typography mb={1} variant=\"caption\">\n Enables an option to include all variable values\n </Typography>\n {state.listVariableFields.allowAllValue && (\n <Controller\n name=\"listVariableFields.customAllValue\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"Custom All Value\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={\n fieldState.error?.message\n ? fieldState.error.message\n : 'When All is selected, this value will be used'\n }\n value={state.listVariableFields.customAllValue ?? ''}\n onChange={(event) => {\n field.onChange(event);\n setState((draft) => {\n if (event.target.value) {\n draft.listVariableFields.customAllValue = event.target.value;\n } else {\n draft.listVariableFields.customAllValue = undefined;\n }\n });\n }}\n />\n )}\n />\n )}\n </Stack>\n </Stack>\n </>\n )}\n </Box>\n <DiscardChangesConfirmationDialog\n description=\"Are you sure you want to discard these changes? Changes cannot be recovered.\"\n isOpen={isDiscardDialogOpened}\n onCancel={() => {\n setDiscardDialogOpened(false);\n }}\n onDiscardChanges={() => {\n setDiscardDialogOpened(false);\n onClose();\n }}\n />\n </FormProvider>\n );\n}\n"],"names":["React","useCallback","useMemo","useState","Box","Typography","Switch","TextField","Grid","FormControlLabel","MenuItem","Button","Stack","ClickAwayListener","Divider","DiscardChangesConfirmationDialog","ErrorBoundary","Controller","FormProvider","useForm","zodResolver","useImmer","getSubmitText","getTitleAction","VARIABLE_TYPES","PluginEditor","variableEditorValidationSchema","VariableListPreview","VariablePreview","getVariableDefinitionFromState","getInitialState","FallbackPreview","div","VariableEditorForm","props","initialVariableDefinition","initialAction","isDraft","isReadonly","onSave","onClose","onDelete","initialState","state","setState","isDiscardDialogOpened","setDiscardDialogOpened","previewKey","setPreviewKey","action","setAction","refreshPreview","prev","previewSpec","titleAction","submitText","form","resolver","mode","defaultValues","processForm","title","undefined","description","handleCancel","JSON","stringify","sx","display","alignItems","padding","theme","spacing","borderBottom","palette","divider","variant","direction","marginLeft","disabled","onClick","color","orientation","flexItem","borderColor","grey","marginRight","type","formState","isValid","handleSubmit","overflowY","container","mb","item","xs","name","render","field","fieldState","required","fullWidth","label","InputLabelProps","shrink","InputProps","readOnly","error","helperText","message","value","onChange","event","draft","target","select","kind","map","v","py","values","textVariableFields","control","checked","constant","listVariableFields","plugin","FallbackComponent","resetKeys","definition","onRefresh","isLoading","onClickAway","width","pluginType","pluginKindLabel","val","capturingRegexp","sort","allowMultiple","allowAllValue","customAllValue","isOpen","onCancel","onDiscardChanges"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,OAAOA,SAAgCC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AACrF,SACEC,GAAG,EACHC,UAAU,EACVC,MAAM,EACNC,SAAS,EACTC,IAAI,EACJC,gBAAgB,EAChBC,QAAQ,EACRC,MAAM,EACNC,KAAK,EACLC,iBAAiB,EACjBC,OAAO,QACF,gBAAgB;AAEvB,SAASC,gCAAgC,EAAEC,aAAa,QAAQ,yBAAyB;AACzF,SAASC,UAAU,EAAEC,YAAY,EAAiBC,OAAO,QAAQ,kBAAkB;AACnF,SAASC,WAAW,QAAQ,0BAA0B;AACtD,SAASC,QAAQ,QAAQ,YAAY;AACrC,SAASC,aAAa,EAAEC,cAAc,QAAQ,iBAAiB;AAC/D,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SAASC,8BAA8B,QAAsC,sBAAsB;AACnG,SAASC,mBAAmB,EAAEC,eAAe,QAAQ,oBAAoB;AACzE,SAASC,8BAA8B,EAAEC,eAAe,QAA6B,+BAA+B;AAEpH,SAASC;IACP,qBAAO,KAACC;kBAAI;;AACd;AAYA,OAAO,SAASC,mBAAmBC,KAA8B;IAC/D,MAAM,EAAEC,0BAAyB,EAAEC,cAAa,EAAEC,QAAO,EAAEC,WAAU,EAAEC,OAAM,EAAEC,QAAO,EAAEC,SAAQ,EAAE,GAAGP;IAErG,MAAMQ,eAAeZ,gBAAgBK;IACrC,MAAM,CAACQ,OAAOC,SAAS,GAAGvB,SAASqB;IACnC,MAAM,CAAC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G,MAAMY,mBAAmBgB,iBAAiB7B,MAAME,OAAOJ;gEACzD,OAAO;oEACLG,MAAMY,mBAAmBgB,iBAAiB/E;gEAC5C;4DACF;wDACF;;;;;;;;;;;;0BAUlB,KAAC/C;gBACCgD,aAAY;gBACZ+E,QAAQjG;gBACRkG,UAAU;oBACRjG,uBAAuB;gBACzB;gBACAkG,kBAAkB;oBAChBlG,uBAAuB;oBACvBN;gBACF;;;;AAIR"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/Variables/VariableEditorForm/VariableEditorForm.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 React, { DispatchWithoutAction, useCallback, useMemo, useState } from 'react';\nimport {\n Box,\n Typography,\n Switch,\n TextField,\n Grid,\n FormControlLabel,\n MenuItem,\n Button,\n Stack,\n ClickAwayListener,\n Divider,\n} from '@mui/material';\nimport { VariableDefinition, ListVariableDefinition, Action } from '@perses-dev/core';\nimport { DiscardChangesConfirmationDialog, ErrorBoundary } from '@perses-dev/components';\nimport { Controller, FormProvider, SubmitHandler, useForm } from 'react-hook-form';\nimport { zodResolver } from '@hookform/resolvers/zod';\nimport { useImmer } from 'use-immer';\nimport { getSubmitText, getTitleAction } from '../../../utils';\nimport { VARIABLE_TYPES } from '../variable-model';\nimport { PluginEditor } from '../../PluginEditor';\nimport { variableEditorValidationSchema, VariableEditorValidationType } from '../../../validation';\nimport { VariableListPreview, VariablePreview } from './VariablePreview';\nimport { getVariableDefinitionFromState, getInitialState, VariableEditorState } from './variable-editor-form-model';\n\nfunction FallbackPreview() {\n return <div>Error previewing values</div>;\n}\n\ninterface VariableEditorFormProps {\n initialVariableDefinition: VariableDefinition;\n initialAction: Action;\n isDraft: boolean;\n isReadonly?: boolean;\n onSave: (def: VariableDefinition) => void;\n onClose: () => void;\n onDelete?: DispatchWithoutAction;\n}\n\nexport function VariableEditorForm(props: VariableEditorFormProps) {\n const { initialVariableDefinition, initialAction, isDraft, isReadonly, onSave, onClose, onDelete } = props;\n\n const initialState = getInitialState(initialVariableDefinition);\n const [state, setState] = useImmer(initialState);\n const [isDiscardDialogOpened, setDiscardDialogOpened] = useState<boolean>(false);\n const [previewKey, setPreviewKey] = useState(0);\n const [action, setAction] = useState(initialAction);\n\n const refreshPreview = () => {\n setPreviewKey((prev) => prev + 1);\n };\n\n /** We use the `previewKey` that we increment to know when to explicitly update the\n * spec that will be used for preview. The reason why we do this is to avoid\n * having to re-fetch the values when the user is still editing the spec.\n */\n const previewSpec = useMemo(() => {\n return getVariableDefinitionFromState(state) as ListVariableDefinition;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [previewKey]);\n\n const titleAction = getTitleAction(action, isDraft);\n const submitText = getSubmitText(action, isDraft);\n\n const form = useForm<VariableEditorValidationType>({\n resolver: zodResolver(variableEditorValidationSchema),\n mode: 'onBlur',\n defaultValues: initialState,\n });\n\n const processForm: SubmitHandler<VariableEditorValidationType> = () => {\n // reset display attributes to undefined when empty, because we don't want to save empty strings\n onSave(\n getVariableDefinitionFromState({\n ...state,\n title: state.title === '' ? undefined : state.title,\n description: state.description === '' ? undefined : state.description,\n })\n );\n };\n\n // When user click on cancel, several possibilities:\n // - create action: ask for discard approval\n // - update action: ask for discard approval if changed\n // - read action: don´t ask for discard approval\n const handleCancel = useCallback(() => {\n if (JSON.stringify(initialState) !== JSON.stringify(state)) {\n setDiscardDialogOpened(true);\n } else {\n onClose();\n }\n }, [initialState, state, onClose]);\n\n return (\n <FormProvider {...form}>\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n padding: (theme) => theme.spacing(1, 2),\n borderBottom: (theme) => `1px solid ${theme.palette.divider}`,\n }}\n >\n <Typography variant=\"h2\">{titleAction} Variable</Typography>\n <Stack direction=\"row\" spacing={1} sx={{ marginLeft: 'auto' }}>\n {action === 'read' ? (\n <>\n <Button disabled={isReadonly} variant=\"contained\" onClick={() => setAction('update')}>\n Edit\n </Button>\n <Button color=\"error\" disabled={isReadonly} variant=\"outlined\" onClick={onDelete}>\n Delete\n </Button>\n <Divider\n orientation=\"vertical\"\n flexItem\n sx={(theme) => ({\n borderColor: theme.palette.grey['500'],\n '&.MuiDivider-root': {\n marginLeft: 2,\n marginRight: 1,\n },\n })}\n />\n <Button color=\"secondary\" variant=\"outlined\" onClick={onClose}>\n Close\n </Button>\n </>\n ) : (\n <>\n <Button\n type=\"submit\"\n variant=\"contained\"\n disabled={!form.formState.isValid}\n onClick={form.handleSubmit(processForm)}\n >\n {submitText}\n </Button>\n <Button color=\"secondary\" variant=\"outlined\" onClick={handleCancel}>\n Cancel\n </Button>\n </>\n )}\n </Stack>\n </Box>\n <Box padding={2} sx={{ overflowY: 'scroll' }}>\n <Grid container spacing={2} mb={2}>\n <Grid item xs={8}>\n <Controller\n name=\"name\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n required\n fullWidth\n label=\"Name\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n disabled: action === 'update' && !isDraft,\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={state.name}\n onChange={(event) => {\n field.onChange(event);\n setState((draft) => {\n draft.name = event.target.value;\n });\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={4}>\n <Controller\n name=\"title\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"Display Label\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={state.title ?? ''}\n onChange={(event) => {\n field.onChange(event);\n setState((draft) => {\n draft.title = event.target.value;\n });\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={8}>\n <Controller\n name=\"description\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"Description\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={state.description ?? ''}\n onChange={(event) => {\n field.onChange(event);\n setState((draft) => {\n draft.description = event.target.value;\n });\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={4}>\n <Controller\n name=\"kind\"\n render={({ field, fieldState }) => (\n <TextField\n select\n {...field}\n fullWidth\n label=\"Type\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={state.kind}\n onChange={(event) => {\n field.onChange(event);\n setState((draft) => {\n draft.kind = event.target.value as VariableEditorState['kind'];\n });\n }}\n >\n {VARIABLE_TYPES.map((v) => (\n <MenuItem key={v.kind} value={v.kind}>\n {v.label}\n </MenuItem>\n ))}\n </TextField>\n )}\n />\n </Grid>\n </Grid>\n\n <Divider />\n\n {state.kind === 'TextVariable' && (\n <>\n <Typography py={1} variant=\"subtitle1\">\n Text Options\n </Typography>\n <Stack spacing={2}>\n <Box>\n <VariablePreview values={[state.textVariableFields.value]} />\n </Box>\n <Controller\n name=\"textVariableFields.value\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n label=\"Value\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={state.textVariableFields.value}\n onChange={(event) => {\n field.onChange(event);\n setState((draft) => {\n draft.textVariableFields.value = event.target.value;\n });\n }}\n />\n )}\n />\n <Controller\n name=\"textVariableFields.constant\"\n render={({ field }) => (\n <FormControlLabel\n label=\"Constant\"\n control={\n <Switch\n {...field}\n checked={!!field.value}\n readOnly={action === 'read'}\n value={state.textVariableFields.constant}\n onChange={(event) => {\n if (action === 'read') return; // ReadOnly prop is not blocking user interaction...\n field.onChange(event);\n setState((draft) => {\n draft.textVariableFields.constant = event.target.checked;\n });\n }}\n />\n }\n />\n )}\n />\n </Stack>\n </>\n )}\n\n {state.kind === 'ListVariable' && (\n <>\n <Typography py={1} variant=\"subtitle1\">\n List Options\n </Typography>\n <Stack spacing={2} mb={2}>\n {state.listVariableFields.plugin.kind ? (\n <Box>\n <ErrorBoundary FallbackComponent={FallbackPreview} resetKeys={[previewSpec]}>\n <VariableListPreview definition={previewSpec} onRefresh={refreshPreview} />\n </ErrorBoundary>\n </Box>\n ) : (\n <VariablePreview isLoading={true} />\n )}\n\n <Stack>\n {/** Hack?: Cool technique to refresh the preview to simulate onBlur event */}\n <ClickAwayListener onClickAway={() => refreshPreview()}>\n <Box />\n </ClickAwayListener>\n {/** */}\n <Controller\n name=\"listVariableFields.plugin\"\n render={({ field }) => (\n <PluginEditor\n width=\"100%\"\n pluginType=\"Variable\"\n pluginKindLabel=\"Source\"\n isReadonly={action === 'read'}\n value={state.listVariableFields.plugin}\n onChange={(val) => {\n field.onChange(val);\n setState((draft) => {\n draft.listVariableFields.plugin = val;\n });\n }}\n />\n )}\n />\n </Stack>\n\n <Stack>\n <Controller\n name=\"listVariableFields.capturingRegexp\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n label=\"Capturing Regexp Filter\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n value={state.listVariableFields.capturingRegexp ?? ''}\n onChange={(event) => {\n field.onChange(event);\n setState((draft) => {\n if (event.target.value) {\n // TODO: do a better fix, if empty string => it should skip the filter\n draft.listVariableFields.capturingRegexp = event.target.value;\n } else {\n draft.listVariableFields.capturingRegexp = undefined;\n }\n });\n }}\n helperText={\n fieldState.error?.message\n ? fieldState.error.message\n : 'Optional, if you want to filter on captured result.'\n }\n />\n )}\n />\n </Stack>\n\n <Stack>\n <Controller\n name=\"listVariableFields.sort\"\n render={({ field, fieldState }) => (\n <TextField\n select\n {...field}\n fullWidth\n label=\"Sort\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={state.listVariableFields.sort ?? 'none'}\n onChange={(event) => {\n field.onChange(event);\n setState((draft) => {\n draft.listVariableFields.sort = event.target.value;\n });\n }}\n >\n <MenuItem value=\"none\">None</MenuItem>\n <MenuItem value=\"alphabetical-asc\">Alphabetical, asc</MenuItem>\n <MenuItem value=\"alphabetical-desc\">Alphabetical, desc</MenuItem>\n <MenuItem value=\"numerical-asc\">Numerical, asc</MenuItem>\n <MenuItem value=\"numerical-desc\">Numerical, desc</MenuItem>\n <MenuItem value=\"alphabetical-ci-asc\">Alphabetical, case-insensitive, asc</MenuItem>\n <MenuItem value=\"alphabetical-ci-desc\">Alphabetical, case-insensitive, desc</MenuItem>\n </TextField>\n )}\n />\n </Stack>\n </Stack>\n\n <Divider />\n\n <Typography py={1} variant=\"subtitle1\">\n Dropdown Options\n </Typography>\n <Stack spacing=\"2\">\n <Stack>\n <Controller\n name=\"listVariableFields.allowMultiple\"\n render={({ field }) => (\n <FormControlLabel\n label=\"Allow Multiple Values\"\n control={\n <Switch\n {...field}\n checked={!!field.value}\n readOnly={action === 'read'}\n value={state.listVariableFields.allowMultiple}\n onChange={(event) => {\n if (action === 'read') return; // ReadOnly prop is not blocking user interaction...\n field.onChange(event);\n setState((draft) => {\n draft.listVariableFields.allowMultiple = event.target.checked;\n });\n }}\n />\n }\n />\n )}\n />\n <Typography variant=\"caption\">Enables multiple values to be selected at the same time</Typography>\n </Stack>\n <Stack>\n <Controller\n name=\"listVariableFields.allowAllValue\"\n render={({ field }) => (\n <FormControlLabel\n label=\"Allow All option\"\n control={\n <Switch\n {...field}\n checked={!!field.value}\n readOnly={action === 'read'}\n value={state.listVariableFields.allowAllValue}\n onChange={(event) => {\n if (action === 'read') return; // ReadOnly prop is not blocking user interaction...\n field.onChange(event);\n setState((draft) => {\n draft.listVariableFields.allowAllValue = event.target.checked;\n });\n }}\n />\n }\n />\n )}\n />\n <Typography mb={1} variant=\"caption\">\n Enables an option to include all variable values\n </Typography>\n {state.listVariableFields.allowAllValue && (\n <Controller\n name=\"listVariableFields.customAllValue\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"Custom All Value\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={\n fieldState.error?.message\n ? fieldState.error.message\n : 'When All is selected, this value will be used'\n }\n value={state.listVariableFields.customAllValue ?? ''}\n onChange={(event) => {\n field.onChange(event);\n setState((draft) => {\n if (event.target.value) {\n draft.listVariableFields.customAllValue = event.target.value;\n } else {\n draft.listVariableFields.customAllValue = undefined;\n }\n });\n }}\n />\n )}\n />\n )}\n </Stack>\n </Stack>\n </>\n )}\n </Box>\n <DiscardChangesConfirmationDialog\n description=\"Are you sure you want to discard these changes? Changes cannot be recovered.\"\n isOpen={isDiscardDialogOpened}\n onCancel={() => {\n setDiscardDialogOpened(false);\n }}\n onDiscardChanges={() => {\n setDiscardDialogOpened(false);\n onClose();\n }}\n />\n </FormProvider>\n );\n}\n"],"names":["React","useCallback","useMemo","useState","Box","Typography","Switch","TextField","Grid","FormControlLabel","MenuItem","Button","Stack","ClickAwayListener","Divider","DiscardChangesConfirmationDialog","ErrorBoundary","Controller","FormProvider","useForm","zodResolver","useImmer","getSubmitText","getTitleAction","VARIABLE_TYPES","PluginEditor","variableEditorValidationSchema","VariableListPreview","VariablePreview","getVariableDefinitionFromState","getInitialState","FallbackPreview","div","VariableEditorForm","props","initialVariableDefinition","initialAction","isDraft","isReadonly","onSave","onClose","onDelete","initialState","state","setState","isDiscardDialogOpened","setDiscardDialogOpened","previewKey","setPreviewKey","action","setAction","refreshPreview","prev","previewSpec","titleAction","submitText","form","resolver","mode","defaultValues","processForm","title","undefined","description","handleCancel","JSON","stringify","sx","display","alignItems","padding","theme","spacing","borderBottom","palette","divider","variant","direction","marginLeft","disabled","onClick","color","orientation","flexItem","borderColor","grey","marginRight","type","formState","isValid","handleSubmit","overflowY","container","mb","item","xs","name","render","field","fieldState","required","fullWidth","label","InputLabelProps","shrink","InputProps","readOnly","error","helperText","message","value","onChange","event","draft","target","select","kind","map","v","py","values","textVariableFields","control","checked","constant","listVariableFields","plugin","FallbackComponent","resetKeys","definition","onRefresh","isLoading","onClickAway","width","pluginType","pluginKindLabel","val","capturingRegexp","sort","allowMultiple","allowAllValue","customAllValue","isOpen","onCancel","onDiscardChanges"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,OAAOA,SAAgCC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AACrF,SACEC,GAAG,EACHC,UAAU,EACVC,MAAM,EACNC,SAAS,EACTC,IAAI,EACJC,gBAAgB,EAChBC,QAAQ,EACRC,MAAM,EACNC,KAAK,EACLC,iBAAiB,EACjBC,OAAO,QACF,gBAAgB;AAEvB,SAASC,gCAAgC,EAAEC,aAAa,QAAQ,yBAAyB;AACzF,SAASC,UAAU,EAAEC,YAAY,EAAiBC,OAAO,QAAQ,kBAAkB;AACnF,SAASC,WAAW,QAAQ,0BAA0B;AACtD,SAASC,QAAQ,QAAQ,YAAY;AACrC,SAASC,aAAa,EAAEC,cAAc,QAAQ,iBAAiB;AAC/D,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SAASC,8BAA8B,QAAsC,sBAAsB;AACnG,SAASC,mBAAm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;;AAIR"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { ListVariableDefinition } from '@perses-dev/core';
|
|
3
2
|
interface VariablePreviewProps {
|
|
4
3
|
values?: string[];
|
|
@@ -6,11 +5,11 @@ interface VariablePreviewProps {
|
|
|
6
5
|
isLoading?: boolean;
|
|
7
6
|
error?: string;
|
|
8
7
|
}
|
|
9
|
-
export declare function VariablePreview(props: VariablePreviewProps): JSX.Element;
|
|
8
|
+
export declare function VariablePreview(props: VariablePreviewProps): import("react/jsx-runtime").JSX.Element;
|
|
10
9
|
interface VariableListPreviewProps {
|
|
11
10
|
definition: ListVariableDefinition;
|
|
12
11
|
onRefresh: () => void;
|
|
13
12
|
}
|
|
14
|
-
export declare function VariableListPreview(props: VariableListPreviewProps): JSX.Element;
|
|
13
|
+
export declare function VariableListPreview(props: VariableListPreviewProps): import("react/jsx-runtime").JSX.Element;
|
|
15
14
|
export {};
|
|
16
15
|
//# sourceMappingURL=VariablePreview.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VariablePreview.d.ts","sourceRoot":"","sources":["../../../../src/components/Variables/VariableEditorForm/VariablePreview.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"VariablePreview.d.ts","sourceRoot":"","sources":["../../../../src/components/Variables/VariableEditorForm/VariablePreview.tsx"],"names":[],"mappings":"AAkBA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAM1D,UAAU,oBAAoB;IAC5B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,2CAqD1D;AAED,UAAU,wBAAwB;IAChC,UAAU,EAAE,sBAAsB,CAAC;IACnC,SAAS,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,2CAalE"}
|
|
@@ -20,9 +20,9 @@ import { TOOLTIP_TEXT } from '../../../constants';
|
|
|
20
20
|
import { useListVariablePluginValues } from '../variable-model';
|
|
21
21
|
const DEFAULT_MAX_PREVIEW_VALUES = 50;
|
|
22
22
|
export function VariablePreview(props) {
|
|
23
|
-
const { values
|
|
23
|
+
const { values, onRefresh, isLoading, error } = props;
|
|
24
24
|
const [maxValues, setMaxValues] = useState(DEFAULT_MAX_PREVIEW_VALUES);
|
|
25
|
-
const { infoSnackbar
|
|
25
|
+
const { infoSnackbar } = useSnackbar();
|
|
26
26
|
const showAll = ()=>{
|
|
27
27
|
setMaxValues(undefined);
|
|
28
28
|
};
|
|
@@ -108,8 +108,8 @@ export function VariablePreview(props) {
|
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
110
|
export function VariableListPreview(props) {
|
|
111
|
-
const { definition
|
|
112
|
-
const { data
|
|
111
|
+
const { definition, onRefresh } = props;
|
|
112
|
+
const { data, isFetching, error } = useListVariablePluginValues(definition);
|
|
113
113
|
const errorMessage = error === null || error === void 0 ? void 0 : error.message;
|
|
114
114
|
return /*#__PURE__*/ _jsx(VariablePreview, {
|
|
115
115
|
values: (data === null || data === void 0 ? void 0 : data.map((val)=>val.value)) || [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/Variables/VariableEditorForm/VariablePreview.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 React, { useState } from 'react';\nimport { Alert, Box, Card, Chip, CircularProgress, IconButton, Stack, Typography } from '@mui/material';\nimport { InfoTooltip, useSnackbar } from '@perses-dev/components';\nimport Refresh from 'mdi-material-ui/Refresh';\nimport Clipboard from 'mdi-material-ui/ClipboardOutline';\nimport { ListVariableDefinition } from '@perses-dev/core';\nimport { TOOLTIP_TEXT } from '../../../constants';\nimport { useListVariablePluginValues } from '../variable-model';\n\nconst DEFAULT_MAX_PREVIEW_VALUES = 50;\n\ninterface VariablePreviewProps {\n values?: string[];\n onRefresh?: () => void;\n isLoading?: boolean;\n error?: string;\n}\n\nexport function VariablePreview(props: VariablePreviewProps) {\n const { values, onRefresh, isLoading, error } = props;\n const [maxValues, setMaxValues] = useState<number | undefined>(DEFAULT_MAX_PREVIEW_VALUES);\n const { infoSnackbar } = useSnackbar();\n const showAll = () => {\n setMaxValues(undefined);\n };\n let notShown = 0;\n\n if (values && values?.length > 0 && maxValues) {\n notShown = values.length - maxValues;\n }\n\n return (\n <Box>\n <Stack direction=\"row\" spacing={1} alignItems=\"center\" mb={1}>\n <Typography variant=\"h4\">Preview Values</Typography>\n {onRefresh && (\n <InfoTooltip description={TOOLTIP_TEXT.refreshVariableValues}>\n <IconButton onClick={onRefresh} size=\"small\">\n <Refresh />\n </IconButton>\n </InfoTooltip>\n )}\n <InfoTooltip description={TOOLTIP_TEXT.copyVariableValues}>\n <IconButton\n onClick={async () => {\n if (values?.length) {\n await navigator.clipboard.writeText(values.map((value) => value).join(', '));\n infoSnackbar('Preview values copied to clipboard!');\n }\n }}\n size=\"small\"\n >\n <Clipboard />\n </IconButton>\n </InfoTooltip>\n </Stack>\n <Card variant=\"outlined\">\n <Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 1, m: 2 }}>\n {error && <Alert severity=\"error\">{error}</Alert>}\n {values?.length === 0 && <Alert severity=\"info\">No results</Alert>}\n {isLoading && (\n <Stack width=\"100%\" sx={{ alignItems: 'center', justifyContent: 'center' }}>\n <CircularProgress />\n </Stack>\n )}\n {values?.slice(0, maxValues).map((val) =>
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/Variables/VariableEditorForm/VariablePreview.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 React, { useState } from 'react';\nimport { Alert, Box, Card, Chip, CircularProgress, IconButton, Stack, Typography } from '@mui/material';\nimport { InfoTooltip, useSnackbar } from '@perses-dev/components';\nimport Refresh from 'mdi-material-ui/Refresh';\nimport Clipboard from 'mdi-material-ui/ClipboardOutline';\nimport { ListVariableDefinition } from '@perses-dev/core';\nimport { TOOLTIP_TEXT } from '../../../constants';\nimport { useListVariablePluginValues } from '../variable-model';\n\nconst DEFAULT_MAX_PREVIEW_VALUES = 50;\n\ninterface VariablePreviewProps {\n values?: string[];\n onRefresh?: () => void;\n isLoading?: boolean;\n error?: string;\n}\n\nexport function VariablePreview(props: VariablePreviewProps) {\n const { values, onRefresh, isLoading, error } = props;\n const [maxValues, setMaxValues] = useState<number | undefined>(DEFAULT_MAX_PREVIEW_VALUES);\n const { infoSnackbar } = useSnackbar();\n const showAll = () => {\n setMaxValues(undefined);\n };\n let notShown = 0;\n\n if (values && values?.length > 0 && maxValues) {\n notShown = values.length - maxValues;\n }\n\n return (\n <Box>\n <Stack direction=\"row\" spacing={1} alignItems=\"center\" mb={1}>\n <Typography variant=\"h4\">Preview Values</Typography>\n {onRefresh && (\n <InfoTooltip description={TOOLTIP_TEXT.refreshVariableValues}>\n <IconButton onClick={onRefresh} size=\"small\">\n <Refresh />\n </IconButton>\n </InfoTooltip>\n )}\n <InfoTooltip description={TOOLTIP_TEXT.copyVariableValues}>\n <IconButton\n onClick={async () => {\n if (values?.length) {\n await navigator.clipboard.writeText(values.map((value) => value).join(', '));\n infoSnackbar('Preview values copied to clipboard!');\n }\n }}\n size=\"small\"\n >\n <Clipboard />\n </IconButton>\n </InfoTooltip>\n </Stack>\n <Card variant=\"outlined\">\n <Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 1, m: 2 }}>\n {error && <Alert severity=\"error\">{error}</Alert>}\n {values?.length === 0 && <Alert severity=\"info\">No results</Alert>}\n {isLoading && (\n <Stack width=\"100%\" sx={{ alignItems: 'center', justifyContent: 'center' }}>\n <CircularProgress />\n </Stack>\n )}\n {values?.slice(0, maxValues).map((val) => <Chip size=\"small\" key={val} label={val} />)}\n {notShown > 0 && <Chip onClick={showAll} variant=\"outlined\" size=\"small\" label={`+${notShown} more`} />}\n </Box>\n </Card>\n </Box>\n );\n}\n\ninterface VariableListPreviewProps {\n definition: ListVariableDefinition;\n onRefresh: () => void;\n}\n\nexport function VariableListPreview(props: VariableListPreviewProps) {\n const { definition, onRefresh } = props;\n const { data, isFetching, error } = useListVariablePluginValues(definition);\n const errorMessage = (error as Error)?.message;\n\n return (\n <VariablePreview\n values={data?.map((val) => val.value) || []}\n onRefresh={onRefresh}\n isLoading={isFetching}\n error={errorMessage}\n />\n );\n}\n"],"names":["React","useState","Alert","Box","Card","Chip","CircularProgress","IconButton","Stack","Typography","InfoTooltip","useSnackbar","Refresh","Clipboard","TOOLTIP_TEXT","useListVariablePluginValues","DEFAULT_MAX_PREVIEW_VALUES","VariablePreview","props","values","onRefresh","isLoading","error","maxValues","setMaxValues","infoSnackbar","showAll","undefined","notShown","length","direction","spacing","alignItems","mb","variant","description","refreshVariableValues","onClick","size","copyVariableValues","navigator","clipboard","writeText","map","value","join","sx","display","flexWrap","gap","m","severity","width","justifyContent","slice","val","label","VariableListPreview","definition","data","isFetching","errorMessage","message"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;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,WAAWA;QACXC,WAAWuC;QACXtC,OAAOuC;;AAGb"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ListVariableSpec, TextVariableSpec, UnknownSpec, VariableDefinition } from '@perses-dev/core';
|
|
2
|
-
export
|
|
2
|
+
export type VariableEditorState = {
|
|
3
3
|
name: string;
|
|
4
4
|
title?: string;
|
|
5
5
|
kind: 'TextVariable' | 'ListVariable' | 'BuiltinVariable';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variable-editor-form-model.d.ts","sourceRoot":"","sources":["../../../../src/components/Variables/VariableEditorForm/variable-editor-form-model.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,gBAAgB,EAEhB,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AAE1B,
|
|
1
|
+
{"version":3,"file":"variable-editor-form-model.d.ts","sourceRoot":"","sources":["../../../../src/components/Variables/VariableEditorForm/variable-editor-form-model.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,gBAAgB,EAEhB,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,cAAc,GAAG,cAAc,GAAG,iBAAiB,CAAC;IAC1D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IAC5E,kBAAkB,EAAE,IAAI,CAAC,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;CAChE,CAAC;AAEF,wBAAgB,eAAe,CAAC,yBAAyB,EAAE,kBAAkB,GAAG,mBAAmB,CAkClG;AAED,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,mBAAmB,GAAG,kBAAkB,CAgC7F"}
|
|
@@ -49,7 +49,7 @@ export function getInitialState(initialVariableDefinition) {
|
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
export function getVariableDefinitionFromState(state) {
|
|
52
|
-
const { name
|
|
52
|
+
const { name, title, kind, description } = state;
|
|
53
53
|
const display = {
|
|
54
54
|
name: title,
|
|
55
55
|
description: description
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/Variables/VariableEditorForm/variable-editor-form-model.ts"],"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 {\n ListVariableSpec,\n TextVariableDefinition,\n TextVariableSpec,\n UnknownSpec,\n VariableDefinition,\n} from '@perses-dev/core';\n\nexport type VariableEditorState = {\n name: string;\n title?: string;\n kind: 'TextVariable' | 'ListVariable' | 'BuiltinVariable';\n description?: string;\n listVariableFields: Omit<ListVariableSpec<UnknownSpec>, 'name' | 'display'>;\n textVariableFields: Omit<TextVariableSpec, 'name' | 'display'>;\n};\n\nexport function getInitialState(initialVariableDefinition: VariableDefinition): VariableEditorState {\n const textVariableFields: Omit<TextVariableSpec, 'name' | 'display'> = {\n value: (initialVariableDefinition as TextVariableDefinition).spec.value ?? '',\n constant: (initialVariableDefinition as TextVariableDefinition).spec.constant ?? false,\n };\n\n const listVariableFields: Omit<ListVariableSpec<UnknownSpec>, 'name' | 'display'> = {\n allowMultiple: false,\n allowAllValue: false,\n customAllValue: undefined,\n capturingRegexp: undefined,\n sort: undefined,\n plugin: {\n kind: '',\n spec: {},\n },\n };\n if (initialVariableDefinition.kind === 'ListVariable') {\n listVariableFields.allowMultiple = initialVariableDefinition.spec.allowMultiple ?? false;\n listVariableFields.allowAllValue = initialVariableDefinition.spec.allowAllValue ?? false;\n listVariableFields.customAllValue = initialVariableDefinition.spec.customAllValue;\n listVariableFields.capturingRegexp = initialVariableDefinition.spec.capturingRegexp;\n listVariableFields.sort = initialVariableDefinition.spec.sort;\n listVariableFields.plugin = initialVariableDefinition.spec.plugin;\n }\n\n return {\n name: initialVariableDefinition.spec.name,\n title: initialVariableDefinition.spec.display?.name ?? '',\n kind: initialVariableDefinition.kind,\n description: initialVariableDefinition.spec.display?.description ?? '',\n listVariableFields,\n textVariableFields,\n };\n}\n\nexport function getVariableDefinitionFromState(state: VariableEditorState): VariableDefinition {\n const { name, title, kind, description } = state;\n\n const display = { name: title, description: description };\n\n if (kind === 'TextVariable') {\n return {\n kind,\n spec: {\n name,\n display,\n ...state.textVariableFields,\n },\n };\n }\n\n if (kind === 'ListVariable') {\n return {\n kind,\n spec: {\n name,\n display,\n allowMultiple: state.listVariableFields.allowMultiple,\n allowAllValue: state.listVariableFields.allowAllValue,\n customAllValue: state.listVariableFields.customAllValue,\n capturingRegexp: state.listVariableFields.capturingRegexp,\n sort: state.listVariableFields.sort,\n plugin: state.listVariableFields.plugin,\n },\n };\n }\n throw new Error(`Unknown variable kind: ${kind}`);\n}\n"],"names":["getInitialState","initialVariableDefinition","textVariableFields","value","spec","constant","listVariableFields","allowMultiple","allowAllValue","customAllValue","undefined","capturingRegexp","sort","plugin","kind","name","title","display","description","getVariableDefinitionFromState","state","Error"],"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;AAmBjC,OAAO,SAASA,gBAAgBC,yBAA6C;QA4BlEA,yCAEMA;QA5BN,uCACG;IAFZ,MAAMC,qBAAiE;QACrEC,OAAO,CAAA,wCAAA,AAACF,0BAAqDG,
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/Variables/VariableEditorForm/variable-editor-form-model.ts"],"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 {\n ListVariableSpec,\n TextVariableDefinition,\n TextVariableSpec,\n UnknownSpec,\n VariableDefinition,\n} from '@perses-dev/core';\n\nexport type VariableEditorState = {\n name: string;\n title?: string;\n kind: 'TextVariable' | 'ListVariable' | 'BuiltinVariable';\n description?: string;\n listVariableFields: Omit<ListVariableSpec<UnknownSpec>, 'name' | 'display'>;\n textVariableFields: Omit<TextVariableSpec, 'name' | 'display'>;\n};\n\nexport function getInitialState(initialVariableDefinition: VariableDefinition): VariableEditorState {\n const textVariableFields: Omit<TextVariableSpec, 'name' | 'display'> = {\n value: (initialVariableDefinition as TextVariableDefinition).spec.value ?? '',\n constant: (initialVariableDefinition as TextVariableDefinition).spec.constant ?? false,\n };\n\n const listVariableFields: Omit<ListVariableSpec<UnknownSpec>, 'name' | 'display'> = {\n allowMultiple: false,\n allowAllValue: false,\n customAllValue: undefined,\n capturingRegexp: undefined,\n sort: undefined,\n plugin: {\n kind: '',\n spec: {},\n },\n };\n if (initialVariableDefinition.kind === 'ListVariable') {\n listVariableFields.allowMultiple = initialVariableDefinition.spec.allowMultiple ?? false;\n listVariableFields.allowAllValue = initialVariableDefinition.spec.allowAllValue ?? false;\n listVariableFields.customAllValue = initialVariableDefinition.spec.customAllValue;\n listVariableFields.capturingRegexp = initialVariableDefinition.spec.capturingRegexp;\n listVariableFields.sort = initialVariableDefinition.spec.sort;\n listVariableFields.plugin = initialVariableDefinition.spec.plugin;\n }\n\n return {\n name: initialVariableDefinition.spec.name,\n title: initialVariableDefinition.spec.display?.name ?? '',\n kind: initialVariableDefinition.kind,\n description: initialVariableDefinition.spec.display?.description ?? '',\n listVariableFields,\n textVariableFields,\n };\n}\n\nexport function getVariableDefinitionFromState(state: VariableEditorState): VariableDefinition {\n const { name, title, kind, description } = state;\n\n const display = { name: title, description: description };\n\n if (kind === 'TextVariable') {\n return {\n kind,\n spec: {\n name,\n display,\n ...state.textVariableFields,\n },\n };\n }\n\n if (kind === 'ListVariable') {\n return {\n kind,\n spec: {\n name,\n display,\n allowMultiple: state.listVariableFields.allowMultiple,\n allowAllValue: state.listVariableFields.allowAllValue,\n customAllValue: state.listVariableFields.customAllValue,\n capturingRegexp: state.listVariableFields.capturingRegexp,\n sort: state.listVariableFields.sort,\n plugin: state.listVariableFields.plugin,\n },\n };\n }\n throw new Error(`Unknown variable kind: ${kind}`);\n}\n"],"names":["getInitialState","initialVariableDefinition","textVariableFields","value","spec","constant","listVariableFields","allowMultiple","allowAllValue","customAllValue","undefined","capturingRegexp","sort","plugin","kind","name","title","display","description","getVariableDefinitionFromState","state","Error"],"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;AAmBjC,OAAO,SAASA,gBAAgBC,yBAA6C;QA4BlEA,yCAEMA;QA5BN,uCACG;IAFZ,MAAMC,qBAAiE;QACrEC,OAAO,CAAA,wCAAA,AAACF,0BAAqDG,IAAI,CAACD,KAAK,cAAhE,mDAAA,wCAAoE;QAC3EE,UAAU,CAAA,2CAAA,AAACJ,0BAAqDG,IAAI,CAACC,QAAQ,cAAnE,sDAAA,2CAAuE;IACnF;IAEA,MAAMC,qBAA8E;QAClFC,eAAe;QACfC,eAAe;QACfC,gB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BAAkB;YAC7B;QACF;IACF;IAEA,IAAIY,SAAS,gBAAgB;QAC3B,OAAO;YACLA;YACAV,MAAM;gBACJW;gBACAE;gBACAV,eAAea,MAAMd,kBAAkB,CAACC,aAAa;gBACrDC,eAAeY,MAAMd,kBAAkB,CAACE,aAAa;gBACrDC,gBAAgBW,MAAMd,kBAAkB,CAACG,cAAc;gBACvDE,iBAAiBS,MAAMd,kBAAkB,CAACK,eAAe;gBACzDC,MAAMQ,MAAMd,kBAAkB,CAACM,IAAI;gBACnCC,QAAQO,MAAMd,kBAAkB,CAACO,MAAM;YACzC;QACF;IACF;IACA,MAAM,IAAIQ,MAAM,CAAC,uBAAuB,EAAEP,KAAK,CAAC;AAClD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variable-model.d.ts","sourceRoot":"","sources":["../../../src/components/Variables/variable-model.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,
|
|
1
|
+
{"version":3,"file":"variable-model.d.ts","sourceRoot":"","sources":["../../../src/components/Variables/variable-model.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAkE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,cAAc,EAAE,EAAE,cAAc,EAAE,MAAM,GAAG,cAAc,EAAE,CAqBnG;AAED,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,sBAAsB,6EAyC7E;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,gBAAgB,UAIvD;AAED,eAAO,MAAM,cAAc;;;;;;EAGjB,CAAC"}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { useQuery } from '@tanstack/react-query';
|
|
14
|
-
import { useDatasourceStore, usePlugin,
|
|
14
|
+
import { useDatasourceStore, usePlugin, useTimeRange, useVariableValues } from '../../runtime';
|
|
15
15
|
export function filterVariableList(data, capturedRegexp) {
|
|
16
16
|
const result = [];
|
|
17
17
|
const filteredSet = new Set();
|
|
@@ -38,10 +38,10 @@ export function filterVariableList(data, capturedRegexp) {
|
|
|
38
38
|
return result;
|
|
39
39
|
}
|
|
40
40
|
export function useListVariablePluginValues(definition) {
|
|
41
|
-
const { data: variablePlugin
|
|
41
|
+
const { data: variablePlugin } = usePlugin('Variable', definition.spec.plugin.kind);
|
|
42
42
|
const datasourceStore = useDatasourceStore();
|
|
43
|
-
const allVariables =
|
|
44
|
-
const { absoluteTimeRange: timeRange
|
|
43
|
+
const allVariables = useVariableValues();
|
|
44
|
+
const { absoluteTimeRange: timeRange, refreshKey } = useTimeRange();
|
|
45
45
|
const variablePluginCtx = {
|
|
46
46
|
timeRange,
|
|
47
47
|
datasourceStore,
|
|
@@ -54,7 +54,7 @@ export function useListVariablePluginValues(definition) {
|
|
|
54
54
|
const dependencies = variablePlugin.dependsOn(spec, variablePluginCtx);
|
|
55
55
|
dependsOnVariables = dependencies.variables;
|
|
56
56
|
}
|
|
57
|
-
const variables =
|
|
57
|
+
const variables = useVariableValues(dependsOnVariables);
|
|
58
58
|
let waitToLoad = false;
|
|
59
59
|
if (dependsOnVariables) {
|
|
60
60
|
waitToLoad = dependsOnVariables.some((v)=>{
|
|
@@ -64,7 +64,6 @@ export function useListVariablePluginValues(definition) {
|
|
|
64
64
|
}
|
|
65
65
|
const variablesValueKey = getVariableValuesKey(variables);
|
|
66
66
|
return useQuery([
|
|
67
|
-
name,
|
|
68
67
|
definition,
|
|
69
68
|
variablesValueKey,
|
|
70
69
|
timeRange,
|
|
@@ -78,7 +77,7 @@ export function useListVariablePluginValues(definition) {
|
|
|
78
77
|
if (resp === undefined) {
|
|
79
78
|
return [];
|
|
80
79
|
}
|
|
81
|
-
if (capturingRegexp
|
|
80
|
+
if (!capturingRegexp) {
|
|
82
81
|
return resp.data;
|
|
83
82
|
}
|
|
84
83
|
return filterVariableList(resp.data, capturingRegexp);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Variables/variable-model.ts"],"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 { ListVariableDefinition } from '@perses-dev/core';\nimport { useQuery } from '@tanstack/react-query';\nimport { VariableOption } from '../../model';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Variables/variable-model.ts"],"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 { ListVariableDefinition } from '@perses-dev/core';\nimport { useQuery } from '@tanstack/react-query';\nimport { VariableOption } from '../../model';\nimport { useDatasourceStore, usePlugin, useTimeRange, useVariableValues, VariableStateMap } from '../../runtime';\n\nexport function filterVariableList(data: VariableOption[], capturedRegexp: RegExp): VariableOption[] {\n const result: VariableOption[] = [];\n const filteredSet = new Set<string>();\n for (const variableValue of data) {\n const matches = variableValue.value.matchAll(capturedRegexp);\n let concat = '';\n for (const match of matches) {\n for (let i = 1; i < match.length; i++) {\n const m = match[i];\n if (m !== undefined) {\n concat = `${concat}${m}`;\n }\n }\n }\n if (concat !== '' && !filteredSet.has(concat)) {\n // like that we are avoiding to have duplicating variable value\n filteredSet.add(concat);\n result.push({ label: variableValue.label, value: concat });\n }\n }\n return result;\n}\n\nexport function useListVariablePluginValues(definition: ListVariableDefinition) {\n const { data: variablePlugin } = usePlugin('Variable', definition.spec.plugin.kind);\n const datasourceStore = useDatasourceStore();\n const allVariables = useVariableValues();\n const { absoluteTimeRange: timeRange, refreshKey } = useTimeRange();\n\n const variablePluginCtx = { timeRange, datasourceStore, variables: allVariables };\n\n const spec = definition.spec.plugin.spec;\n const capturingRegexp =\n definition.spec.capturingRegexp !== undefined ? new RegExp(definition.spec.capturingRegexp, 'g') : undefined;\n\n let dependsOnVariables: string[] | undefined;\n if (variablePlugin?.dependsOn) {\n const dependencies = variablePlugin.dependsOn(spec, variablePluginCtx);\n dependsOnVariables = dependencies.variables;\n }\n\n const variables = useVariableValues(dependsOnVariables);\n\n let waitToLoad = false;\n if (dependsOnVariables) {\n waitToLoad = dependsOnVariables.some((v) => variables[v]?.loading);\n }\n\n const variablesValueKey = getVariableValuesKey(variables);\n\n return useQuery(\n [definition, variablesValueKey, timeRange, refreshKey],\n async () => {\n const resp = await variablePlugin?.getVariableOptions(spec, { datasourceStore, variables, timeRange });\n if (resp === undefined) {\n return [];\n }\n if (!capturingRegexp) {\n return resp.data;\n }\n return filterVariableList(resp.data, capturingRegexp);\n },\n { enabled: !!variablePlugin || waitToLoad }\n );\n}\n\n/**\n * Returns a serialized string of the current state of variable values.\n */\nexport function getVariableValuesKey(v: VariableStateMap) {\n return Object.values(v)\n .map((v) => JSON.stringify(v.value))\n .join(',');\n}\n\nexport const VARIABLE_TYPES = [\n { label: 'List', kind: 'ListVariable' },\n { label: 'Text', kind: 'TextVariable' },\n] as const;\n"],"names":["useQuery","useDatasourceStore","usePlugin","useTimeRange","useVariableValues","filterVariableList","data","capturedRegexp","result","filteredSet","Set","variableValue","matches","value","matchAll","concat","match","i","length","m","undefined","has","add","push","label","useListVariablePluginValues","definition","variablePlugin","spec","plugin","kind","datasourceStore","allVariables","absoluteTimeRange","timeRange","refreshKey","variablePluginCtx","variables","capturingRegexp","RegExp","dependsOnVariables","dependsOn","dependencies","waitToLoad","some","v","loading","variablesValueKey","getVariableValuesKey","resp","getVariableOptions","enabled","Object","values","map","JSON","stringify","join","VARIABLE_TYPES"],"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;AAGjC,SAASA,QAAQ,QAAQ,wBAAwB;AAEjD,SAASC,kBAAkB,EAAEC,SAAS,EAAEC,YAAY,EAAEC,iBAAiB,QAA0B,gBAAgB;AAEjH,OAAO,SAASC,mBAAmBC,IAAsB,EAAEC,cAAsB;IAC/E,MAAMC,SAA2B,EAAE;IACnC,MAAMC,cAAc,IAAIC;IACxB,KAAK,MAAMC,iBAAiBL,KAAM;QAChC,MAAMM,UAAUD,cAAcE,KAAK,CAACC,QAAQ,CAACP;QAC7C,IAAIQ,SAAS;QACb,KAAK,MAAMC,SAASJ,QAAS;YAC3B,IAAK,IAAIK,IAAI,GAAGA,IAAID,MAAME,MAAM,EAAED,IAAK;gBACrC,MAAME,IAAIH,KAAK,CAACC,EAAE;gBAClB,IAAIE,MAAMC,WAAW;oBACnBL,SAAS,CAAC,EAAEA,OAAO,EAAEI,EAAE,CAAC;gBAC1B;YACF;QACF;QACA,IAAIJ,WAAW,MAAM,CAACN,YAAYY,GAAG,CAACN,SAAS;YAC7C,+DAA+D;YAC/DN,YAAYa,GAAG,CAACP;YAChBP,OAAOe,IAAI,CAAC;gBAAEC,OAAOb,cAAca,KAAK;gBAAEX,OAAOE;YAAO;QAC1D;IACF;IACA,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xB,kBAAkBgB;IAAW;AAE9C;AAEA;;CAEC,GACD,OAAO,SAASK,qBAAqBH,CAAmB;IACtD,OAAOO,OAAOC,MAAM,CAACR,GAClBS,GAAG,CAAC,CAACT,IAAMU,KAAKC,SAAS,CAACX,EAAEhC,KAAK,GACjC4C,IAAI,CAAC;AACV;AAEA,OAAO,MAAMC,iBAAiB;IAC5B;QAAElC,OAAO;QAAQM,MAAM;IAAe;IACtC;QAAEN,OAAO;QAAQM,MAAM;IAAe;CACvC,CAAU"}
|
|
@@ -12,5 +12,5 @@ export interface ProjectStoreProviderProps {
|
|
|
12
12
|
export declare const ProjectStoreContext: import("react").Context<ProjectStore | undefined>;
|
|
13
13
|
export declare function useProjectList(): UseQueryResult<ProjectResource[], Error>;
|
|
14
14
|
export declare function useProjectStore(): ProjectStore;
|
|
15
|
-
export declare function ProjectStoreProvider(props: ProjectStoreProviderProps): JSX.Element;
|
|
15
|
+
export declare function ProjectStoreProvider(props: ProjectStoreProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
16
16
|
//# sourceMappingURL=ProjectStoreProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProjectStoreProvider.d.ts","sourceRoot":"","sources":["../../src/context/ProjectStoreProvider.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAY,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,SAAS,EAAsC,MAAM,OAAO,CAAC;AACtE,OAAO,EAAa,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAG9D,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,IAAI,CAAC;IAC/C,OAAO,EAAE,eAAe,CAAC;CAC1B;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,eAAO,MAAM,mBAAmB,mDAAqD,CAAC;AAEtF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