@perses-dev/plugin-system 0.0.0-snapshot-scatter-chart-embed-8efdfab → 0.0.0-snapshot-explorer-plugin-c4a7621
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 +83 -163
- package/dist/cjs/components/DatasourceSelect.js +12 -15
- package/dist/cjs/components/HTTPSettingsEditor/HTTPSettingsEditor.js +528 -0
- package/dist/cjs/components/{TimeSeriesQueryEditor → HTTPSettingsEditor}/index.js +2 -2
- package/dist/cjs/components/LegendOptionsEditor/LegendOptionsEditor.js +8 -7
- package/dist/cjs/components/MetricLabelInput/MetricLabelInput.js +41 -0
- package/dist/cjs/{validation/resource.js → components/MetricLabelInput/index.js} +15 -9
- package/dist/cjs/components/{TraceQueryEditor/TraceQueryEditor.js → MultiQueryEditor/MultiQueryEditor.js} +39 -40
- package/dist/cjs/components/{TimeSeriesQueryEditor/TimeSeriesQueryInput.js → MultiQueryEditor/QueryEditorContainer.js} +23 -11
- package/dist/cjs/components/MultiQueryEditor/index.js +30 -0
- 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 +54 -62
- package/dist/cjs/components/PluginEditor/PluginEditor.js +16 -13
- package/dist/cjs/components/PluginEditor/plugin-editor-api.js +44 -33
- package/dist/cjs/components/PluginKindSelect/PluginKindSelect.js +55 -7
- package/dist/cjs/components/PluginRegistry/PluginRegistry.js +9 -10
- package/dist/cjs/components/PluginRegistry/plugin-indexes.js +20 -17
- package/dist/cjs/components/PluginSpecEditor/PluginSpecEditor.js +3 -3
- package/dist/cjs/components/ProjectSelect.js +7 -7
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +131 -0
- package/dist/cjs/components/{TraceQueryEditor → TimeRangeControls}/index.js +1 -1
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +394 -439
- package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +17 -15
- package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +7 -12
- package/dist/cjs/components/Variables/variable-model.js +35 -37
- package/dist/cjs/components/index.js +4 -1
- package/dist/cjs/constants/user-interface-text.js +4 -1
- package/dist/cjs/context/ProjectStoreProvider.js +12 -9
- package/dist/cjs/context/ValidationProvider.js +69 -0
- package/dist/cjs/context/index.js +1 -0
- package/dist/cjs/index.js +1 -1
- package/dist/{components/TimeSeriesQueryEditor/index.js → cjs/model/explore.js} +4 -3
- package/dist/cjs/model/legend.js +5 -5
- package/dist/cjs/remote/PersesPlugin.types.js +16 -0
- package/dist/cjs/remote/PluginLoaderComponent.js +75 -0
- package/dist/cjs/remote/PluginRuntime.js +267 -0
- package/dist/cjs/{validation → remote}/index.js +2 -4
- package/dist/cjs/remote/remotePluginLoader.js +61 -0
- package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +23 -14
- package/dist/cjs/runtime/DataQueriesProvider/model.js +10 -9
- package/dist/cjs/runtime/QueryCountProvider.js +83 -0
- package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +37 -13
- package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.js +3 -3
- package/dist/cjs/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js +100 -0
- package/dist/cjs/runtime/TimeRangeProvider/index.js +2 -1
- package/dist/cjs/runtime/TimeRangeProvider/query-params.js +20 -23
- package/dist/cjs/runtime/UsageMetricsProvider.js +99 -0
- package/dist/cjs/runtime/builtin-variables.js +7 -7
- package/dist/cjs/runtime/datasources.js +30 -21
- package/dist/cjs/runtime/index.js +4 -2
- package/dist/cjs/runtime/plugin-registry.js +48 -36
- package/dist/cjs/runtime/time-series-queries.js +35 -40
- package/dist/cjs/runtime/trace-queries.js +9 -6
- package/dist/cjs/runtime/{template-variables.js → variables.js} +38 -48
- package/dist/cjs/stories/shared-utils/decorators/WithDataQueries.js +1 -1
- package/dist/cjs/stories/shared-utils/decorators/WithPluginRegistry.js +1 -65
- package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js +1 -1
- package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +5 -5
- package/dist/cjs/stories/shared-utils/decorators/{WithPluginSystemTemplateVariables.js → WithPluginSystemVariables.js} +9 -9
- package/dist/cjs/stories/shared-utils/decorators/WithTimeRange.js +1 -1
- package/dist/cjs/stories/shared-utils/decorators/index.js +2 -2
- package/dist/cjs/test/mock-data.js +25 -4
- package/dist/cjs/test/render.js +2 -11
- package/dist/cjs/test/test-plugins/bert/index.js +21 -20
- 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 +13 -13
- package/dist/cjs/utils/action.js +3 -3
- package/dist/cjs/utils/variables.js +24 -24
- package/dist/components/CalculationSelector/CalculationSelector.d.ts +2 -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 +7 -7
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +86 -166
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
- package/dist/components/DatasourceSelect.d.ts +4 -4
- package/dist/components/DatasourceSelect.d.ts.map +1 -1
- package/dist/components/DatasourceSelect.js +9 -12
- package/dist/components/DatasourceSelect.js.map +1 -1
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts +11 -0
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts.map +1 -0
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js +474 -0
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js.map +1 -0
- package/dist/components/HTTPSettingsEditor/index.d.ts +2 -0
- package/dist/components/HTTPSettingsEditor/index.d.ts.map +1 -0
- package/dist/components/HTTPSettingsEditor/index.js +15 -0
- package/dist/components/HTTPSettingsEditor/index.js.map +1 -0
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts +3 -2
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts.map +1 -1
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +10 -9
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
- package/dist/components/MetricLabelInput/MetricLabelInput.d.ts +7 -0
- package/dist/components/MetricLabelInput/MetricLabelInput.d.ts.map +1 -0
- package/dist/components/MetricLabelInput/MetricLabelInput.js +33 -0
- package/dist/components/MetricLabelInput/MetricLabelInput.js.map +1 -0
- package/dist/components/MetricLabelInput/index.d.ts +2 -0
- package/dist/components/MetricLabelInput/index.d.ts.map +1 -0
- package/dist/components/MetricLabelInput/index.js +15 -0
- package/dist/components/MetricLabelInput/index.js.map +1 -0
- package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts +17 -0
- package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts.map +1 -0
- package/dist/components/{TimeSeriesQueryEditor/TimeSeriesQueryEditor.js → MultiQueryEditor/MultiQueryEditor.js} +42 -39
- package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -0
- package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts +29 -0
- package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts.map +1 -0
- package/dist/components/{TimeSeriesQueryEditor/TimeSeriesQueryInput.js → MultiQueryEditor/QueryEditorContainer.js} +33 -10
- package/dist/components/MultiQueryEditor/QueryEditorContainer.js.map +1 -0
- package/dist/components/MultiQueryEditor/index.d.ts +2 -0
- package/dist/components/MultiQueryEditor/index.d.ts.map +1 -0
- package/dist/components/MultiQueryEditor/index.js +15 -0
- package/dist/components/{TraceQueryEditor → MultiQueryEditor}/index.js.map +1 -1
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.d.ts +4 -4
- 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 +2 -2
- 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 +5 -5
- 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 +5 -3
- package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js +56 -64
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
- package/dist/components/PluginEditor/PluginEditor.d.ts +2 -2
- package/dist/components/PluginEditor/PluginEditor.d.ts.map +1 -1
- package/dist/components/PluginEditor/PluginEditor.js +16 -13
- package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.d.ts +16 -10
- package/dist/components/PluginEditor/plugin-editor-api.d.ts.map +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.js +44 -33
- package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.d.ts +11 -5
- package/dist/components/PluginKindSelect/PluginKindSelect.d.ts.map +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.js +61 -10
- package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.d.ts +4 -4
- package/dist/components/PluginRegistry/PluginRegistry.d.ts.map +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.js +9 -10
- package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
- package/dist/components/PluginRegistry/plugin-indexes.d.ts +4 -4
- package/dist/components/PluginRegistry/plugin-indexes.d.ts.map +1 -1
- package/dist/components/PluginRegistry/plugin-indexes.js +17 -14
- package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
- package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts +5 -5
- 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 +3 -3
- package/dist/components/ProjectSelect.d.ts.map +1 -1
- package/dist/components/ProjectSelect.js +7 -7
- package/dist/components/ProjectSelect.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts +14 -0
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -0
- package/dist/components/TimeRangeControls/TimeRangeControls.js +110 -0
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -0
- package/dist/components/TimeRangeControls/index.d.ts +2 -0
- package/dist/components/TimeRangeControls/index.d.ts.map +1 -0
- package/dist/components/{TraceQueryEditor → TimeRangeControls}/index.js +1 -1
- package/dist/components/TimeRangeControls/index.js.map +1 -0
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +4 -3
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +395 -442
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts +3 -3
- package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js +11 -11
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +3 -3
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +7 -12
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
- package/dist/components/Variables/variable-model.d.ts +2 -1
- package/dist/components/Variables/variable-model.d.ts.map +1 -1
- package/dist/components/Variables/variable-model.js +29 -31
- package/dist/components/Variables/variable-model.js.map +1 -1
- package/dist/components/index.d.ts +4 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +4 -1
- package/dist/components/index.js.map +1 -1
- package/dist/constants/user-interface-text.d.ts +2 -0
- package/dist/constants/user-interface-text.d.ts.map +1 -1
- package/dist/constants/user-interface-text.js +4 -1
- package/dist/constants/user-interface-text.js.map +1 -1
- package/dist/context/ProjectStoreProvider.d.ts +4 -4
- package/dist/context/ProjectStoreProvider.d.ts.map +1 -1
- package/dist/context/ProjectStoreProvider.js +9 -6
- package/dist/context/ProjectStoreProvider.js.map +1 -1
- package/dist/context/ValidationProvider.d.ts +19 -0
- package/dist/context/ValidationProvider.d.ts.map +1 -0
- package/dist/context/ValidationProvider.js +52 -0
- package/dist/context/ValidationProvider.js.map +1 -0
- package/dist/context/index.d.ts +1 -0
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +1 -0
- package/dist/context/index.js.map +1 -1
- package/dist/context/query-params.d.ts.map +1 -1
- package/dist/context/query-params.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/model/datasource.js +3 -1
- package/dist/model/datasource.js.map +1 -1
- package/dist/model/explore.d.ts +13 -0
- package/dist/model/explore.d.ts.map +1 -0
- package/dist/{validation/resource.js → model/explore.js} +4 -3
- package/dist/model/explore.js.map +1 -0
- 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 +17 -5
- package/dist/model/panels.d.ts.map +1 -1
- package/dist/model/panels.js.map +1 -1
- package/dist/model/plugin-base.d.ts +0 -1
- package/dist/model/plugin-base.d.ts.map +1 -1
- package/dist/model/plugin-base.js.map +1 -1
- package/dist/model/plugin-loading.js.map +1 -1
- package/dist/model/plugins.d.ts +35 -21
- 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 +4 -3
- 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 +1 -1
- 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/remote/PersesPlugin.types.d.ts +7 -0
- package/dist/remote/PersesPlugin.types.d.ts.map +1 -0
- package/dist/remote/PersesPlugin.types.js +15 -0
- package/dist/remote/PersesPlugin.types.js.map +1 -0
- package/dist/remote/PluginLoaderComponent.d.ts +10 -0
- package/dist/remote/PluginLoaderComponent.d.ts.map +1 -0
- package/dist/remote/PluginLoaderComponent.js +67 -0
- package/dist/remote/PluginLoaderComponent.js.map +1 -0
- package/dist/remote/PluginRuntime.d.ts +11 -0
- package/dist/remote/PluginRuntime.d.ts.map +1 -0
- package/dist/remote/PluginRuntime.js +202 -0
- package/dist/remote/PluginRuntime.js.map +1 -0
- package/dist/remote/index.d.ts +3 -0
- package/dist/remote/index.d.ts.map +1 -0
- package/dist/{validation → remote}/index.js +2 -4
- package/dist/remote/index.js.map +1 -0
- package/dist/remote/remotePluginLoader.d.ts +3 -0
- package/dist/remote/remotePluginLoader.d.ts.map +1 -0
- package/dist/remote/remotePluginLoader.js +53 -0
- package/dist/remote/remotePluginLoader.js.map +1 -0
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts +2 -2
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts.map +1 -1
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +19 -10
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.d.ts +6 -7
- package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.js +10 -9
- package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
- package/dist/runtime/QueryCountProvider.d.ts +9 -0
- package/dist/runtime/QueryCountProvider.d.ts.map +1 -0
- package/dist/{validation/datasource.js → runtime/QueryCountProvider.js} +14 -10
- package/dist/runtime/QueryCountProvider.js.map +1 -0
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts +6 -2
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +30 -9
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.d.ts +2 -2
- 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/TimeRangeSettingsProvider.d.ts +32 -0
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.d.ts.map +1 -0
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js +82 -0
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js.map +1 -0
- package/dist/runtime/TimeRangeProvider/index.d.ts +1 -0
- package/dist/runtime/TimeRangeProvider/index.d.ts.map +1 -1
- package/dist/runtime/TimeRangeProvider/index.js +2 -1
- package/dist/runtime/TimeRangeProvider/index.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 +8 -11
- package/dist/runtime/TimeRangeProvider/query-params.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/refresh-interval.d.ts.map +1 -1
- package/dist/runtime/TimeRangeProvider/refresh-interval.js.map +1 -1
- package/dist/runtime/UsageMetricsProvider.d.ts +25 -0
- package/dist/runtime/UsageMetricsProvider.d.ts.map +1 -0
- package/dist/runtime/UsageMetricsProvider.js +77 -0
- package/dist/runtime/UsageMetricsProvider.js.map +1 -0
- package/dist/runtime/builtin-variables.d.ts +2 -2
- package/dist/runtime/builtin-variables.d.ts.map +1 -1
- package/dist/runtime/builtin-variables.js +4 -4
- package/dist/runtime/builtin-variables.js.map +1 -1
- package/dist/runtime/datasources.d.ts +5 -4
- package/dist/runtime/datasources.d.ts.map +1 -1
- package/dist/runtime/datasources.js +24 -15
- package/dist/runtime/datasources.js.map +1 -1
- package/dist/runtime/index.d.ts +3 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +4 -2
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/plugin-registry.d.ts +11 -11
- package/dist/runtime/plugin-registry.d.ts.map +1 -1
- package/dist/runtime/plugin-registry.js +40 -28
- package/dist/runtime/plugin-registry.js.map +1 -1
- package/dist/runtime/time-series-queries.d.ts +5 -4
- package/dist/runtime/time-series-queries.d.ts.map +1 -1
- package/dist/runtime/time-series-queries.js +28 -33
- package/dist/runtime/time-series-queries.js.map +1 -1
- package/dist/runtime/trace-queries.d.ts +5 -4
- package/dist/runtime/trace-queries.d.ts.map +1 -1
- package/dist/runtime/trace-queries.js +10 -7
- package/dist/runtime/trace-queries.js.map +1 -1
- package/dist/runtime/{template-variables.d.ts → variables.d.ts} +7 -7
- package/dist/runtime/variables.d.ts.map +1 -0
- package/dist/runtime/{template-variables.js → variables.js} +35 -44
- package/dist/runtime/variables.js.map +1 -0
- package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts +3 -3
- package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts.map +1 -1
- package/dist/stories/shared-utils/decorators/WithDataQueries.js +1 -1
- package/dist/stories/shared-utils/decorators/WithDataQueries.js.map +1 -1
- package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts +2 -2
- package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts.map +1 -1
- package/dist/stories/shared-utils/decorators/WithPluginRegistry.js +2 -22
- package/dist/stories/shared-utils/decorators/WithPluginRegistry.js.map +1 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.d.ts +3 -3
- package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.d.ts.map +1 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js +1 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js.map +1 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts +3 -3
- package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts.map +1 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +5 -5
- package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js.map +1 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.d.ts +13 -0
- package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.d.ts.map +1 -0
- package/dist/stories/shared-utils/decorators/{WithPluginSystemTemplateVariables.js → WithPluginSystemVariables.js} +10 -10
- package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.js.map +1 -0
- package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts +3 -3
- package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts.map +1 -1
- package/dist/stories/shared-utils/decorators/WithTimeRange.js +1 -1
- package/dist/stories/shared-utils/decorators/WithTimeRange.js.map +1 -1
- package/dist/stories/shared-utils/decorators/index.d.ts +1 -1
- package/dist/stories/shared-utils/decorators/index.d.ts.map +1 -1
- package/dist/stories/shared-utils/decorators/index.js +2 -2
- package/dist/stories/shared-utils/decorators/index.js.map +1 -1
- package/dist/test/mock-data.d.ts.map +1 -1
- package/dist/test/mock-data.js +25 -4
- package/dist/test/mock-data.js.map +1 -1
- package/dist/test/render.d.ts +4 -4
- package/dist/test/render.d.ts.map +1 -1
- package/dist/test/render.js +2 -11
- package/dist/test/render.js.map +1 -1
- package/dist/test/setup-tests.js.map +1 -1
- package/dist/test/test-plugins/bert/index.d.ts.map +1 -1
- package/dist/test/test-plugins/bert/index.js +21 -20
- 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 +6 -4
- package/dist/test-utils/mock-plugin-registry.d.ts.map +1 -1
- package/dist/test-utils/mock-plugin-registry.js +10 -10
- package/dist/test-utils/mock-plugin-registry.js.map +1 -1
- package/dist/utils/variables.d.ts +4 -4
- package/dist/utils/variables.d.ts.map +1 -1
- package/dist/utils/variables.js +19 -19
- package/dist/utils/variables.js.map +1 -1
- package/package.json +7 -6
- package/dist/cjs/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js +0 -146
- package/dist/cjs/components/TraceQueryEditor/TraceQueryInput.js +0 -96
- package/dist/cjs/validation/datasource.js +0 -30
- package/dist/cjs/validation/role.js +0 -85
- package/dist/cjs/validation/rolebinding.js +0 -55
- package/dist/cjs/validation/secret.js +0 -176
- package/dist/cjs/validation/variable.js +0 -48
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts +0 -8
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts.map +0 -1
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js.map +0 -1
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts +0 -13
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts.map +0 -1
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js.map +0 -1
- package/dist/components/TimeSeriesQueryEditor/index.d.ts +0 -2
- package/dist/components/TimeSeriesQueryEditor/index.d.ts.map +0 -1
- package/dist/components/TimeSeriesQueryEditor/index.js.map +0 -1
- package/dist/components/TraceQueryEditor/TraceQueryEditor.d.ts +0 -9
- package/dist/components/TraceQueryEditor/TraceQueryEditor.d.ts.map +0 -1
- package/dist/components/TraceQueryEditor/TraceQueryEditor.js +0 -130
- package/dist/components/TraceQueryEditor/TraceQueryEditor.js.map +0 -1
- package/dist/components/TraceQueryEditor/TraceQueryInput.d.ts +0 -13
- package/dist/components/TraceQueryEditor/TraceQueryInput.d.ts.map +0 -1
- package/dist/components/TraceQueryEditor/TraceQueryInput.js +0 -83
- package/dist/components/TraceQueryEditor/TraceQueryInput.js.map +0 -1
- package/dist/components/TraceQueryEditor/index.d.ts +0 -2
- package/dist/components/TraceQueryEditor/index.d.ts.map +0 -1
- package/dist/runtime/template-variables.d.ts.map +0 -1
- package/dist/runtime/template-variables.js.map +0 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.d.ts +0 -13
- package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.d.ts.map +0 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.js.map +0 -1
- package/dist/validation/datasource.d.ts +0 -19
- package/dist/validation/datasource.d.ts.map +0 -1
- package/dist/validation/datasource.js.map +0 -1
- package/dist/validation/index.d.ts +0 -5
- package/dist/validation/index.d.ts.map +0 -1
- package/dist/validation/index.js.map +0 -1
- package/dist/validation/resource.d.ts +0 -3
- package/dist/validation/resource.d.ts.map +0 -1
- package/dist/validation/resource.js.map +0 -1
- package/dist/validation/role.d.ts +0 -228
- package/dist/validation/role.d.ts.map +0 -1
- package/dist/validation/role.js +0 -66
- package/dist/validation/role.js.map +0 -1
- package/dist/validation/rolebinding.d.ts +0 -137
- package/dist/validation/rolebinding.d.ts.map +0 -1
- package/dist/validation/rolebinding.js +0 -47
- package/dist/validation/rolebinding.js.map +0 -1
- package/dist/validation/secret.d.ts +0 -964
- package/dist/validation/secret.d.ts.map +0 -1
- package/dist/validation/secret.js +0 -157
- package/dist/validation/secret.js.map +0 -1
- package/dist/validation/variable.d.ts +0 -96
- package/dist/validation/variable.d.ts.map +0 -1
- package/dist/validation/variable.js +0 -40
- package/dist/validation/variable.js.map +0 -1
|
@@ -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,iB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S,CAACqE;oEACRA,MAAMY,mBAAmBe,gBAAgB5B,MAAME,OAAOS;gEACxD;4DACF;;;;0DAMV,KAACtH;gDAAWwF,IAAI;gDAAGjB,SAAQ;0DAAU;;4CAGpCjC,MAAMkF,mBAAmBe,+BACxB,KAAC3H;gDACC+E,MAAK;gDACLC,QAAQ,CAAC,EAAEC,MAAK,EAAEC,WAAU,EAAE;wDAWxBA;kEAVJ,OAAA,KAAC5F;wDACE,GAAG2F,KAAK;wDACTG,SAAS;wDACTC,OAAM;wDACNC,iBAAiB;4DAAEC,QAAQvD,WAAW,SAAS,OAAOa;wDAAU;wDAChE2C,YAAY;4DACVC,UAAUzD,WAAW;wDACvB;wDACA0D,OAAO,CAAC,CAACR,WAAWQ;wDACpBC,YACET,CAAAA,CAAAA,oBAAAA,WAAWQ,mBAAXR,+BAAAA,KAAAA,IAAAA,kBAAkBU,OAAM,IACpBV,WAAWQ,MAAME,UACjB;wDAENC,OAAOnE,CAAAA,2CAAAA,MAAMkF,mBAAmBgB,4BAAzBlG,sDAAAA,2CAA2C;wDAClDoE,UAAU,CAACC;4DACTd,MAAMa,SAASC;4DACfpE,SAAS,CAACqE;gEACR,IAAID,MAAME,OAAOJ,OAAO;oEACtBG,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, ReactElement, useState } from 'react';\nimport {\n Box,\n Typography,\n Switch,\n TextField,\n Grid,\n FormControlLabel,\n MenuItem,\n Stack,\n ClickAwayListener,\n Divider,\n} from '@mui/material';\nimport { VariableDefinition, ListVariableDefinition, Action } from '@perses-dev/core';\nimport { DiscardChangesConfirmationDialog, ErrorAlert, ErrorBoundary, FormActions } from '@perses-dev/components';\nimport { Control, Controller, FormProvider, SubmitHandler, useForm, useFormContext, useWatch } from 'react-hook-form';\nimport { zodResolver } from '@hookform/resolvers/zod';\nimport { getSubmitText, getTitleAction } from '../../../utils';\nimport { VARIABLE_TYPES } from '../variable-model';\nimport { PluginEditor } from '../../PluginEditor';\nimport { useValidationSchemas } from '../../../context';\nimport { VariableListPreview, VariablePreview } from './VariablePreview';\n\nfunction FallbackPreview(): ReactElement {\n return <div>Error previewing values</div>;\n}\n\ninterface KindVariableEditorFormProps {\n action: Action;\n control: Control<VariableDefinition>;\n}\n\nfunction TextVariableEditorForm({ action, control }: KindVariableEditorFormProps): ReactElement {\n return (\n <>\n <Typography py={1} variant=\"subtitle1\">\n Text Options\n </Typography>\n <Stack spacing={2}>\n <Controller\n control={control}\n name=\"spec.value\"\n render={({ field, fieldState }) => (\n <>\n <Box>\n <VariablePreview values={[field.value]} />\n </Box>\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={field.value ?? ''}\n onChange={(event) => {\n field.onChange(event);\n }}\n />\n </>\n )}\n />\n <Controller\n control={control}\n name=\"spec.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={field.value ?? false}\n onChange={(event) => {\n if (action === 'read') return; // ReadOnly prop is not blocking user interaction...\n field.onChange(event);\n }}\n />\n }\n />\n )}\n />\n </Stack>\n </>\n );\n}\n\nfunction ListVariableEditorForm({ action, control }: KindVariableEditorFormProps): ReactElement {\n const form = useFormContext<VariableDefinition>();\n /** We use `previewSpec` 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, setPreviewSpec] = useState<ListVariableDefinition>(form.getValues() as ListVariableDefinition);\n const refreshPreview = (): void => {\n setPreviewSpec(form.getValues() as ListVariableDefinition);\n };\n\n const kind = useWatch<VariableDefinition, 'spec.plugin.kind'>({ control: control, name: 'spec.plugin.kind' });\n const _allowAllValue = useWatch<VariableDefinition, 'spec.allowAllValue'>({\n control: control,\n name: 'spec.allowAllValue',\n });\n\n // When variable kind is selected we need to provide default values\n // TODO: check if react-hook-form has a better way to do this\n const values = form.getValues() as ListVariableDefinition;\n if (values.spec.allowAllValue === undefined) {\n form.setValue('spec.allowAllValue', false);\n }\n\n if (values.spec.allowMultiple === undefined) {\n form.setValue('spec.allowMultiple', false);\n }\n\n return (\n <>\n <Typography py={1} variant=\"subtitle1\">\n List Options\n </Typography>\n <Stack spacing={2} mb={2}>\n {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 <ErrorBoundary FallbackComponent={ErrorAlert}>\n <Controller\n control={control}\n name=\"spec.plugin\"\n render={({ field }) => (\n <PluginEditor\n width=\"100%\"\n pluginTypes={['Variable']}\n pluginKindLabel=\"Source\"\n value={{\n selection: {\n type: 'Variable',\n kind: field.value?.kind ?? 'StaticListVariable',\n },\n spec: field.value?.spec ?? { values: [] },\n }}\n isReadonly={action === 'read'}\n onChange={(v) => {\n field.onChange({ kind: v.selection.kind, spec: v.spec });\n }}\n />\n )}\n />\n </ErrorBoundary>\n </Stack>\n\n <Stack>\n <Controller\n control={control}\n name=\"spec.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={field.value ?? ''}\n onChange={(event) => {\n if (event.target.value === '') {\n field.onChange(undefined);\n } else {\n field.onChange(event);\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 control={control}\n name=\"spec.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={field.value ?? 'none'}\n onChange={(event) => {\n field.onChange(event);\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 control={control}\n name=\"spec.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={field.value ?? false}\n onChange={(event) => {\n if (action === 'read') return; // ReadOnly prop is not blocking user interaction...\n field.onChange(event);\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 control={control}\n name=\"spec.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={field.value ?? false}\n onChange={(event) => {\n if (action === 'read') return; // ReadOnly prop is not blocking user interaction...\n field.onChange(event);\n }}\n />\n }\n />\n )}\n />\n <Typography mb={1} variant=\"caption\">\n Enables an option to include all variable values\n </Typography>\n {_allowAllValue && (\n <Controller\n control={control}\n name=\"spec.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={field.value ?? ''}\n onChange={(event) => {\n if (event.target.value === '') {\n field.onChange(undefined);\n } else {\n field.onChange(event);\n }\n }}\n />\n )}\n />\n )}\n </Stack>\n </Stack>\n </>\n );\n}\n\ninterface VariableEditorFormProps {\n initialVariableDefinition: VariableDefinition;\n action: Action;\n isDraft: boolean;\n isReadonly?: boolean;\n onActionChange?: (action: Action) => void;\n onSave: (def: VariableDefinition) => void;\n onClose: () => void;\n onDelete?: DispatchWithoutAction;\n}\n\nexport function VariableEditorForm({\n initialVariableDefinition,\n action,\n isDraft,\n isReadonly,\n onActionChange,\n onSave,\n onClose,\n onDelete,\n}: VariableEditorFormProps): ReactElement {\n const [isDiscardDialogOpened, setDiscardDialogOpened] = useState<boolean>(false);\n const titleAction = getTitleAction(action, isDraft);\n const submitText = getSubmitText(action, isDraft);\n\n const { variableEditorSchema } = useValidationSchemas();\n const form = useForm<VariableDefinition>({\n resolver: zodResolver(variableEditorSchema),\n mode: 'onBlur',\n defaultValues: initialVariableDefinition,\n });\n\n const kind = useWatch({ control: form.control, name: 'kind' });\n\n function clearFormData(data: VariableDefinition): VariableDefinition {\n const result = { ...data };\n if (\n result.spec.display?.name === undefined &&\n result.spec.display?.description === undefined &&\n result.spec.display?.hidden === undefined\n ) {\n delete result.spec.display;\n }\n return result;\n }\n\n const processForm: SubmitHandler<VariableDefinition> = (data: VariableDefinition) => {\n // reset display attributes to undefined when empty, because we don't want to save empty strings\n onSave(clearFormData(data));\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 function handleCancel(): void {\n if (JSON.stringify(initialVariableDefinition) !== JSON.stringify(clearFormData(form.getValues()))) {\n setDiscardDialogOpened(true);\n } else {\n onClose();\n }\n }\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 <FormActions\n action={action}\n submitText={submitText}\n isReadonly={isReadonly}\n isValid={form.formState.isValid}\n onActionChange={onActionChange}\n onSubmit={form.handleSubmit(processForm)}\n onDelete={onDelete}\n onCancel={handleCancel}\n />\n </Box>\n <Box padding={2} sx={{ overflowY: 'scroll' }}>\n <Grid container spacing={2} mb={2}>\n <Grid item xs={8}>\n <Controller\n control={form.control}\n name=\"spec.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={field.value ?? ''}\n onChange={(event) => {\n field.onChange(event);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={4}>\n <Controller\n control={form.control}\n name=\"spec.display.name\"\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={field.value ?? ''}\n onChange={(event) => {\n field.onChange(event);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={8}>\n <Controller\n control={form.control}\n name=\"spec.display.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={field.value ?? ''}\n onChange={(event) => {\n field.onChange(event);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={4}>\n <Controller\n control={form.control}\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={field.value ?? 'TextVariable'}\n onChange={(event) => {\n field.onChange(event);\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 {kind === 'TextVariable' && (\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <TextVariableEditorForm action={action} control={form.control} />\n </ErrorBoundary>\n )}\n {kind === 'ListVariable' && (\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <ListVariableEditorForm action={action} control={form.control} />\n </ErrorBoundary>\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","useState","Box","Typography","Switch","TextField","Grid","FormControlLabel","MenuItem","Stack","ClickAwayListener","Divider","DiscardChangesConfirmationDialog","ErrorAlert","ErrorBoundary","FormActions","Controller","FormProvider","useForm","useFormContext","useWatch","zodResolver","getSubmitText","getTitleAction","VARIABLE_TYPES","PluginEditor","useValidationSchemas","VariableListPreview","VariablePreview","FallbackPreview","div","TextVariableEditorForm","action","control","py","variant","spacing","name","render","field","fieldState","values","value","label","InputLabelProps","shrink","undefined","InputProps","readOnly","error","helperText","message","onChange","event","checked","ListVariableEditorForm","form","previewSpec","setPreviewSpec","getValues","refreshPreview","kind","_allowAllValue","spec","allowAllValue","setValue","allowMultiple","mb","FallbackComponent","resetKeys","definition","onRefresh","isLoading","onClickAway","width","pluginTypes","pluginKindLabel","selection","type","isReadonly","v","target","select","fullWidth","VariableEditorForm","initialVariableDefinition","isDraft","onActionChange","onSave","onClose","onDelete","isDiscardDialogOpened","setDiscardDialogOpened","titleAction","submitText","variableEditorSchema","resolver","mode","defaultValues","clearFormData","data","result","display","description","hidden","processForm","handleCancel","JSON","stringify","sx","alignItems","padding","theme","borderBottom","palette","divider","isValid","formState","onSubmit","handleSubmit","onCancel","overflowY","container","item","xs","required","disabled","map","isOpen","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,S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KAAK;mDADKqC,EAAEnB,IAAI;;;;;;kCAUjC,KAAClD;oBAEAkD,SAAS,gCACR,KAAC/C;wBAAcsD,mBAAmBvD;kCAChC,cAAA,KAACkB;4BAAuBC,QAAQA;4BAAQC,SAASuB,KAAKvB,OAAO;;;oBAGhE4B,SAAS,gCACR,KAAC/C;wBAAcsD,mBAAmBvD;kCAChC,cAAA,KAAC0C;4BAAuBvB,QAAQA;4BAAQC,SAASuB,KAAKvB,OAAO;;;;;0BAInE,KAACrB;gBACC2F,aAAY;gBACZyB,QAAQrC;gBACR6B,UAAU;oBACR5B,uBAAuB;gBACzB;gBACAqC,kBAAkB;oBAChBrC,uBAAuB;oBACvBH;gBACF;;;;AAIR"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
2
|
import { ListVariableDefinition } from '@perses-dev/core';
|
|
3
3
|
interface VariablePreviewProps {
|
|
4
4
|
values?: string[];
|
|
@@ -6,11 +6,11 @@ interface VariablePreviewProps {
|
|
|
6
6
|
isLoading?: boolean;
|
|
7
7
|
error?: string;
|
|
8
8
|
}
|
|
9
|
-
export declare function VariablePreview(props: VariablePreviewProps):
|
|
9
|
+
export declare function VariablePreview(props: VariablePreviewProps): ReactElement;
|
|
10
10
|
interface VariableListPreviewProps {
|
|
11
11
|
definition: ListVariableDefinition;
|
|
12
12
|
onRefresh: () => void;
|
|
13
13
|
}
|
|
14
|
-
export declare function VariableListPreview(props: VariableListPreviewProps):
|
|
14
|
+
export declare function VariableListPreview(props: VariableListPreviewProps): ReactElement;
|
|
15
15
|
export {};
|
|
16
16
|
//# 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":"AAaA,OAAc,EAAE,YAAY,EAAY,MAAM,OAAO,CAAC;AAKtD,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,GAAG,YAAY,CAqDzE;AAED,UAAU,wBAAwB;IAChC,UAAU,EAAE,sBAAsB,CAAC;IACnC,SAAS,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,GAAG,YAAY,CAajF"}
|
|
@@ -20,14 +20,14 @@ 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
|
};
|
|
29
29
|
let notShown = 0;
|
|
30
|
-
if (values &&
|
|
30
|
+
if (values && values?.length > 0 && maxValues) {
|
|
31
31
|
notShown = values.length - maxValues;
|
|
32
32
|
}
|
|
33
33
|
return /*#__PURE__*/ _jsxs(Box, {
|
|
@@ -54,7 +54,7 @@ export function VariablePreview(props) {
|
|
|
54
54
|
description: TOOLTIP_TEXT.copyVariableValues,
|
|
55
55
|
children: /*#__PURE__*/ _jsx(IconButton, {
|
|
56
56
|
onClick: async ()=>{
|
|
57
|
-
if (values
|
|
57
|
+
if (values?.length) {
|
|
58
58
|
await navigator.clipboard.writeText(values.map((value)=>value).join(', '));
|
|
59
59
|
infoSnackbar('Preview values copied to clipboard!');
|
|
60
60
|
}
|
|
@@ -79,7 +79,7 @@ export function VariablePreview(props) {
|
|
|
79
79
|
severity: "error",
|
|
80
80
|
children: error
|
|
81
81
|
}),
|
|
82
|
-
|
|
82
|
+
values?.length === 0 && /*#__PURE__*/ _jsx(Alert, {
|
|
83
83
|
severity: "info",
|
|
84
84
|
children: "No results"
|
|
85
85
|
}),
|
|
@@ -91,10 +91,10 @@ export function VariablePreview(props) {
|
|
|
91
91
|
},
|
|
92
92
|
children: /*#__PURE__*/ _jsx(CircularProgress, {})
|
|
93
93
|
}),
|
|
94
|
-
values
|
|
94
|
+
values?.slice(0, maxValues).map((val, index)=>/*#__PURE__*/ _jsx(Chip, {
|
|
95
95
|
size: "small",
|
|
96
96
|
label: val
|
|
97
|
-
},
|
|
97
|
+
}, index)),
|
|
98
98
|
notShown > 0 && /*#__PURE__*/ _jsx(Chip, {
|
|
99
99
|
onClick: showAll,
|
|
100
100
|
variant: "outlined",
|
|
@@ -108,11 +108,11 @@ export function VariablePreview(props) {
|
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
110
|
export function VariableListPreview(props) {
|
|
111
|
-
const { definition
|
|
112
|
-
const { data
|
|
113
|
-
const errorMessage = error
|
|
111
|
+
const { definition, onRefresh } = props;
|
|
112
|
+
const { data, isFetching, error } = useListVariablePluginValues(definition);
|
|
113
|
+
const errorMessage = error?.message;
|
|
114
114
|
return /*#__PURE__*/ _jsx(VariablePreview, {
|
|
115
|
-
values:
|
|
115
|
+
values: data?.map((val)=>val.value) || [],
|
|
116
116
|
onRefresh: onRefresh,
|
|
117
117
|
isLoading: isFetching,
|
|
118
118
|
error: errorMessage
|
|
@@ -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, { ReactElement, 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): ReactElement {\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 = (): void => {\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, index) => <Chip size=\"small\" key={index} 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): ReactElement {\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","index","label","VariableListPreview","definition","data","isFetching","errorMessage","message"],"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,SAAuBC,QAAQ,QAAQ,QAAQ;AACtD,SAASC,KAAK,EAAEC,GAAG,EAAEC,IAAI,EAAEC,IAAI,EAAEC,gBAAgB,EAAEC,UAAU,EAAEC,KAAK,EAAEC,UAAU,QAAQ,gBAAgB;AACxG,SAASC,WAAW,EAAEC,WAAW,QAAQ,yBAAyB;AAClE,OAAOC,aAAa,0BAA0B;AAC9C,OAAOC,eAAe,mCAAmC;AAEzD,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SAASC,2BAA2B,QAAQ,oBAAoB;AAEhE,MAAMC,6BAA6B;AASnC,OAAO,SAASC,gBAAgBC,KAA2B;IACzD,MAAM,EAAEC,MAAM,EAAEC,SAAS,EAAEC,SAAS,EAAEC,KAAK,EAAE,GAAGJ;IAChD,MAAM,CAACK,WAAWC,aAAa,GAAGvB,SAA6Be;IAC/D,MAAM,EAAES,YAAY,EAAE,GAAGd;IACzB,MAAMe,UAAU;QACdF,aAAaG;IACf;IACA,IAAIC,WAAW;IAEf,IAAIT,UAAUA,QAAQU,SAAS,KAAKN,WAAW;QAC7CK,WAAWT,OAAOU,MAAM,GAAGN;IAC7B;IAEA,qBACE,MAACpB;;0BACC,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AAM,EAAE0C,IAAI,EAAEC,UAAU,EAAEvC,KAAK,EAAE,GAAGP,4BAA4B4C;IAChE,MAAMG,eAAgBxC,OAAiByC;IAEvC,qBACE,KAAC9C;QACCE,QAAQyC,MAAMjB,IAAI,CAACY,MAAQA,IAAIX,KAAK,KAAK,EAAE;QAC3CxB,WAAWA;QACXC,WAAWwC;QACXvC,OAAOwC;;AAGb"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ListVariableSpec, TextVariableSpec,
|
|
2
|
-
export
|
|
1
|
+
import { ListVariableSpec, TextVariableSpec, VariableDefinition } from '@perses-dev/core';
|
|
2
|
+
export type VariableEditorState = {
|
|
3
3
|
name: string;
|
|
4
4
|
title?: string;
|
|
5
5
|
kind: 'TextVariable' | 'ListVariable' | 'BuiltinVariable';
|
|
6
6
|
description?: string;
|
|
7
|
-
listVariableFields: Omit<ListVariableSpec
|
|
7
|
+
listVariableFields: Omit<ListVariableSpec, 'name' | 'display'>;
|
|
8
8
|
textVariableFields: Omit<TextVariableSpec, 'name' | 'display'>;
|
|
9
9
|
};
|
|
10
10
|
export declare function getInitialState(initialVariableDefinition: VariableDefinition): VariableEditorState;
|
|
@@ -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,
|
|
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,EAAE,gBAAgB,EAA0B,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAElH,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,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IAC/D,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"}
|
|
@@ -11,11 +11,9 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
export function getInitialState(initialVariableDefinition) {
|
|
14
|
-
var _initialVariableDefinition_spec_display, _initialVariableDefinition_spec_display1;
|
|
15
|
-
var _initialVariableDefinition_spec_value, _initialVariableDefinition_spec_constant;
|
|
16
14
|
const textVariableFields = {
|
|
17
|
-
value:
|
|
18
|
-
constant:
|
|
15
|
+
value: initialVariableDefinition.spec.value ?? '',
|
|
16
|
+
constant: initialVariableDefinition.spec.constant ?? false
|
|
19
17
|
};
|
|
20
18
|
const listVariableFields = {
|
|
21
19
|
allowMultiple: false,
|
|
@@ -29,27 +27,24 @@ export function getInitialState(initialVariableDefinition) {
|
|
|
29
27
|
}
|
|
30
28
|
};
|
|
31
29
|
if (initialVariableDefinition.kind === 'ListVariable') {
|
|
32
|
-
|
|
33
|
-
listVariableFields.
|
|
34
|
-
var _initialVariableDefinition_spec_allowAllValue;
|
|
35
|
-
listVariableFields.allowAllValue = (_initialVariableDefinition_spec_allowAllValue = initialVariableDefinition.spec.allowAllValue) !== null && _initialVariableDefinition_spec_allowAllValue !== void 0 ? _initialVariableDefinition_spec_allowAllValue : false;
|
|
30
|
+
listVariableFields.allowMultiple = initialVariableDefinition.spec.allowMultiple ?? false;
|
|
31
|
+
listVariableFields.allowAllValue = initialVariableDefinition.spec.allowAllValue ?? false;
|
|
36
32
|
listVariableFields.customAllValue = initialVariableDefinition.spec.customAllValue;
|
|
37
33
|
listVariableFields.capturingRegexp = initialVariableDefinition.spec.capturingRegexp;
|
|
38
34
|
listVariableFields.sort = initialVariableDefinition.spec.sort;
|
|
39
35
|
listVariableFields.plugin = initialVariableDefinition.spec.plugin;
|
|
40
36
|
}
|
|
41
|
-
var _initialVariableDefinition_spec_display_name, _initialVariableDefinition_spec_display_description;
|
|
42
37
|
return {
|
|
43
38
|
name: initialVariableDefinition.spec.name,
|
|
44
|
-
title:
|
|
39
|
+
title: initialVariableDefinition.spec.display?.name ?? '',
|
|
45
40
|
kind: initialVariableDefinition.kind,
|
|
46
|
-
description:
|
|
41
|
+
description: initialVariableDefinition.spec.display?.description ?? '',
|
|
47
42
|
listVariableFields,
|
|
48
43
|
textVariableFields
|
|
49
44
|
};
|
|
50
45
|
}
|
|
51
46
|
export function getVariableDefinitionFromState(state) {
|
|
52
|
-
const { name
|
|
47
|
+
const { name, title, kind, description } = state;
|
|
53
48
|
const display = {
|
|
54
49
|
name: title,
|
|
55
50
|
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 {
|
|
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 { ListVariableSpec, TextVariableDefinition, TextVariableSpec, VariableDefinition } 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, '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, '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;AAajC,OAAO,SAASA,gBAAgBC,yBAA6C;IAC3E,MAAMC,qBAAiE;QACrEC,OAAO,AAACF,0BAAqDG,IAAI,CAACD,KAAK,IAAI;QAC3EE,UAAU,AAACJ,0BAAqDG,IAAI,CAACC,QAAQ,IAAI;IACnF;IAEA,MAAMC,qBAAiE;QACrEC,eAAe;QACfC,eAAe;QACfC,gBAAgBC;QAChBC,iBAAiBD;QACjBE,MAAMF;QACNG,QAAQ;YACNC,MAAM;YACNV,MAAM,CAAC;QACT;IACF;IACA,IAAIH,0BAA0Ba,IAAI,KAAK,gBAAgB;QACrDR,mBAAmBC,aAAa,GAAGN,0BAA0BG,IAAI,CAACG,aAAa,IAAI;QACnFD,mBAAmBE,aAAa,GAAGP,0BAA0BG,IAAI,CAACI,aAAa,IAAI;QACnFF,mBAAmBG,cAAc,GAAGR,0BAA0BG,IAAI,CAACK,cAAc;QACjFH,mBAAmBK,eAAe,GAAGV,0BAA0BG,IAAI,CAACO,eAAe;QACnFL,mBAAmBM,IAAI,GAAGX,0BAA0BG,IAAI,CAACQ,IAAI;QAC7DN,mBAAmBO,MAAM,GAAGZ,0BAA0BG,IAAI,CAACS,MAAM;IACnE;IAEA,OAAO;QACLE,MAAMd,0BAA0BG,IAAI,CAACW,IAAI;QACzCC,OAAOf,0BAA0BG,IAAI,CAACa,OAAO,EAAEF,QAAQ;QACvDD,MAAMb,0BAA0Ba,IAAI;QACpCI,aAAajB,0BAA0BG,IAAI,CAACa,OAAO,EAAEC,eAAe;QACpEZ;QACAJ;IACF;AACF;AAEA,OAAO,SAASiB,+BAA+BC,KAA0B;IACvE,MAAM,EAAEL,IAAI,EAAEC,KAAK,EAAEF,IAAI,EAAEI,WAAW,EAAE,GAAGE;IAE3C,MAAMH,UAAU;QAAEF,MAAMC;QAAOE,aAAaA;IAAY;IAExD,IAAIJ,SAAS,gBAAgB;QAC3B,OAAO;YACLA;YACAV,MAAM;gBACJW;gBACAE;gBACA,GAAGG,MAAMlB,kBAAkB;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,8 +1,9 @@
|
|
|
1
1
|
import { ListVariableDefinition } from '@perses-dev/core';
|
|
2
|
+
import { UseQueryResult } from '@tanstack/react-query';
|
|
2
3
|
import { VariableOption } from '../../model';
|
|
3
4
|
import { VariableStateMap } from '../../runtime';
|
|
4
5
|
export declare function filterVariableList(data: VariableOption[], capturedRegexp: RegExp): VariableOption[];
|
|
5
|
-
export declare function useListVariablePluginValues(definition: ListVariableDefinition):
|
|
6
|
+
export declare function useListVariablePluginValues(definition: ListVariableDefinition): UseQueryResult<VariableOption[]>;
|
|
6
7
|
/**
|
|
7
8
|
* Returns a serialized string of the current state of variable values.
|
|
8
9
|
*/
|
|
@@ -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;
|
|
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;AAC1D,OAAO,EAAY,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAqE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEpH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,cAAc,EAAE,EAAE,cAAc,EAAE,MAAM,GAAG,cAAc,EAAE,CAqBnG;AAED,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,sBAAsB,GAAG,cAAc,CAAC,cAAc,EAAE,CAAC,CAyChH;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,gBAAgB,GAAG,MAAM,CAIhE;AAED,eAAO,MAAM,cAAc;;;;;;EAGjB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2024 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
|
|
@@ -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, useAllVariableValues } 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 = useAllVariableValues();
|
|
44
|
+
const { absoluteTimeRange: timeRange, refreshKey } = useTimeRange();
|
|
45
45
|
const variablePluginCtx = {
|
|
46
46
|
timeRange,
|
|
47
47
|
datasourceStore,
|
|
@@ -50,39 +50,37 @@ export function useListVariablePluginValues(definition) {
|
|
|
50
50
|
const spec = definition.spec.plugin.spec;
|
|
51
51
|
const capturingRegexp = definition.spec.capturingRegexp !== undefined ? new RegExp(definition.spec.capturingRegexp, 'g') : undefined;
|
|
52
52
|
let dependsOnVariables;
|
|
53
|
-
if (variablePlugin
|
|
53
|
+
if (variablePlugin?.dependsOn) {
|
|
54
54
|
const dependencies = variablePlugin.dependsOn(spec, variablePluginCtx);
|
|
55
55
|
dependsOnVariables = dependencies.variables;
|
|
56
56
|
}
|
|
57
|
-
const variables =
|
|
57
|
+
const variables = useAllVariableValues(dependsOnVariables);
|
|
58
58
|
let waitToLoad = false;
|
|
59
59
|
if (dependsOnVariables) {
|
|
60
|
-
waitToLoad = dependsOnVariables.some((v)=>
|
|
61
|
-
var _variables_v;
|
|
62
|
-
return (_variables_v = variables[v]) === null || _variables_v === void 0 ? void 0 : _variables_v.loading;
|
|
63
|
-
});
|
|
60
|
+
waitToLoad = dependsOnVariables.some((v)=>variables[v]?.loading);
|
|
64
61
|
}
|
|
65
62
|
const variablesValueKey = getVariableValuesKey(variables);
|
|
66
|
-
return useQuery(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
63
|
+
return useQuery({
|
|
64
|
+
queryKey: [
|
|
65
|
+
definition,
|
|
66
|
+
variablesValueKey,
|
|
67
|
+
timeRange,
|
|
68
|
+
refreshKey
|
|
69
|
+
],
|
|
70
|
+
queryFn: async ()=>{
|
|
71
|
+
const resp = await variablePlugin?.getVariableOptions(spec, {
|
|
72
|
+
datasourceStore,
|
|
73
|
+
variables,
|
|
74
|
+
timeRange
|
|
75
|
+
});
|
|
76
|
+
if (resp === undefined) {
|
|
77
|
+
return [];
|
|
78
|
+
}
|
|
79
|
+
if (!capturingRegexp) {
|
|
80
|
+
return resp.data;
|
|
81
|
+
}
|
|
82
|
+
return filterVariableList(resp.data, capturingRegexp);
|
|
83
|
+
},
|
|
86
84
|
enabled: !!variablePlugin || waitToLoad
|
|
87
85
|
});
|
|
88
86
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Variables/variable-model.ts"],"sourcesContent":["// Copyright
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Variables/variable-model.ts"],"sourcesContent":["// Copyright 2024 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, UseQueryResult } from '@tanstack/react-query';\nimport { VariableOption } from '../../model';\nimport { useDatasourceStore, usePlugin, useTimeRange, useAllVariableValues, 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): UseQueryResult<VariableOption[]> {\n const { data: variablePlugin } = usePlugin('Variable', definition.spec.plugin.kind);\n const datasourceStore = useDatasourceStore();\n const allVariables = useAllVariableValues();\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 = useAllVariableValues(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 queryKey: [definition, variablesValueKey, timeRange, refreshKey],\n queryFn: 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): string {\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","useAllVariableValues","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","queryKey","queryFn","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,QAAwB,wBAAwB;AAEjE,SAASC,kBAAkB,EAAEC,SAAS,EAAEC,YAAY,EAAEC,oBAAoB,QAA0B,gBAAgB;AAEpH,OAAO,SAASC,mBAAmBC,IAAsB,EAAEC,cAAsB;IAC/E,MAAMC,SAA2B,EAAE;IACnC,MAAMC,cAAc,IAAIC;IACxB,KAAK,MAAMC,iBAAiBL,KAAM;QAChC,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,IAAMR,SAAS,CAACQ,EAAE,EAAEC;IAC5D;IAEA,MAAMC,oBAAoBC,qBAAqBX;IAE/C,OAAOrC,SAAS;QACdiD,UAAU;YAACvB;YAAYqB;YAAmBb;YAAWC;SAAW;QAChEe,SAAS;YACP,MAAMC,OAAO,MAAMxB,gBAAgByB,mBAAmBxB,MAAM;gBAAEG;gBAAiBM;gBAAWH;YAAU;YACpG,IAAIiB,SAAS/B,WAAW;gBACtB,OAAO,EAAE;YACX;YACA,IAAI,CAACkB,iBAAiB;gBACpB,OAAOa,KAAK7C,IAAI;YAClB;YACA,OAAOD,mBAAmB8C,KAAK7C,IAAI,EAAEgC;QACvC;QACAe,SAAS,CAAC,CAAC1B,kBAAkBgB;IAC/B;AACF;AAEA;;CAEC,GACD,OAAO,SAASK,qBAAqBH,CAAmB;IACtD,OAAOS,OAAOC,MAAM,CAACV,GAClBW,GAAG,CAAC,CAACX,IAAMY,KAAKC,SAAS,CAACb,EAAEhC,KAAK,GACjC8C,IAAI,CAAC;AACV;AAEA,OAAO,MAAMC,iBAAiB;IAC5B;QAAEpC,OAAO;QAAQM,MAAM;IAAe;IACtC;QAAEN,OAAO;QAAQM,MAAM;IAAe;CACvC,CAAU"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export * from './CalculationSelector';
|
|
2
2
|
export * from './DatasourceEditorForm';
|
|
3
3
|
export * from './DatasourceSelect';
|
|
4
|
+
export * from './HTTPSettingsEditor';
|
|
4
5
|
export * from './LegendOptionsEditor';
|
|
6
|
+
export * from './MultiQueryEditor';
|
|
5
7
|
export * from './OptionsEditorRadios';
|
|
6
8
|
export * from './OptionsEditorTabs';
|
|
7
9
|
export * from './PanelSpecEditor';
|
|
@@ -9,7 +11,8 @@ export * from './PluginEditor';
|
|
|
9
11
|
export * from './PluginKindSelect';
|
|
10
12
|
export * from './PluginRegistry';
|
|
11
13
|
export * from './PluginSpecEditor';
|
|
12
|
-
export * from './
|
|
14
|
+
export * from './TimeRangeControls';
|
|
13
15
|
export * from './Variables';
|
|
14
16
|
export * from './ProjectSelect';
|
|
17
|
+
export * from './MetricLabelInput';
|
|
15
18
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAaA,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAaA,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC"}
|