@perses-dev/dashboards 0.38.0 → 0.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/AddGroupButton/AddGroupButton.js +9 -7
- package/dist/cjs/components/AddGroupButton/index.js +10 -8
- package/dist/cjs/components/AddPanelButton/AddPanelButton.js +9 -7
- package/dist/cjs/components/AddPanelButton/index.js +10 -8
- package/dist/cjs/components/Dashboard/Dashboard.js +14 -11
- package/dist/cjs/components/Dashboard/index.js +10 -8
- package/dist/cjs/components/DashboardStickyToolbar/DashboardStickyToolbar.js +18 -16
- package/dist/cjs/components/DashboardStickyToolbar/index.js +10 -8
- package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +43 -41
- package/dist/cjs/components/DashboardToolbar/index.js +10 -8
- package/dist/cjs/components/DeletePanelDialog/DeletePanelDialog.js +12 -10
- package/dist/cjs/components/DeletePanelDialog/index.js +10 -8
- package/dist/cjs/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +17 -15
- package/dist/cjs/components/DeletePanelGroupDialog/index.js +10 -8
- package/dist/cjs/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js +5 -3
- package/dist/cjs/components/DiscardChangesConfirmationDialog/index.js +10 -8
- package/dist/cjs/components/DownloadButton/DownloadButton.js +12 -10
- package/dist/cjs/components/DownloadButton/index.js +10 -8
- package/dist/cjs/components/EditButton/EditButton.js +8 -6
- package/dist/cjs/components/EditButton/index.js +10 -8
- package/dist/cjs/components/EditJsonButton/EditJsonButton.js +10 -8
- package/dist/cjs/components/EditJsonButton/index.js +10 -8
- package/dist/cjs/components/EditJsonDialog/EditJsonDialog.js +29 -23
- package/dist/cjs/components/EditJsonDialog/index.js +10 -8
- package/dist/cjs/components/EmptyDashboard/EmptyDashboard.js +18 -16
- package/dist/cjs/components/EmptyDashboard/index.js +10 -8
- package/dist/cjs/components/GridLayout/GridContainer.js +5 -3
- package/dist/cjs/components/GridLayout/GridItemContent.js +33 -12
- package/dist/cjs/components/GridLayout/GridLayout.js +19 -16
- package/dist/cjs/components/GridLayout/GridTitle.js +35 -33
- package/dist/cjs/components/GridLayout/index.js +13 -11
- package/dist/cjs/components/Panel/Panel.js +21 -21
- package/dist/cjs/components/Panel/PanelContent.js +8 -6
- package/dist/cjs/components/Panel/PanelHeader.js +39 -33
- package/dist/cjs/components/Panel/index.js +10 -8
- package/dist/cjs/components/PanelDrawer/PanelDrawer.js +25 -77
- package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +269 -141
- package/dist/cjs/components/PanelDrawer/PanelPreview.js +11 -9
- package/dist/cjs/components/PanelDrawer/index.js +10 -8
- package/dist/cjs/components/PanelDrawer/usePanelEditor.js +3 -1
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +18 -16
- package/dist/cjs/components/PanelGroupDialog/PanelGroupEditorForm.js +15 -11
- package/dist/cjs/components/PanelGroupDialog/index.js +10 -8
- package/dist/cjs/components/QuerySummaryTable/QuerySummaryTable.js +46 -44
- package/dist/cjs/components/QuerySummaryTable/index.js +10 -8
- package/dist/cjs/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +23 -21
- package/dist/cjs/components/SaveChangesConfirmationDialog/index.js +10 -8
- package/dist/cjs/components/SaveDashboardButton/SaveDashboardButton.js +11 -9
- package/dist/cjs/components/SaveDashboardButton/index.js +10 -8
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +40 -16
- package/dist/cjs/components/TimeRangeControls/index.js +10 -8
- package/dist/cjs/components/ToolbarIconButton/ToolbarIconButton.js +5 -3
- package/dist/cjs/components/ToolbarIconButton/index.js +10 -8
- package/dist/cjs/components/Variables/BuiltinVariableAccordions.js +140 -0
- package/dist/cjs/components/Variables/EditVariablesButton.js +18 -11
- package/dist/cjs/components/Variables/TemplateVariable.js +127 -76
- package/dist/cjs/components/Variables/VariableEditor.js +356 -117
- package/dist/cjs/components/Variables/VariableList.js +45 -21
- package/dist/cjs/components/Variables/index.js +14 -11
- package/dist/cjs/components/index.js +31 -29
- package/dist/cjs/constants/grid-layout-config.js +6 -2
- package/dist/cjs/constants/index.js +11 -9
- package/dist/cjs/constants/user-interface-text.js +6 -2
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +40 -34
- package/dist/cjs/context/DashboardProvider/common.js +6 -2
- package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +70 -38
- package/dist/cjs/context/DashboardProvider/delete-panel-group-slice.js +3 -1
- package/dist/cjs/context/DashboardProvider/delete-panel-slice.js +5 -3
- package/dist/cjs/context/DashboardProvider/discard-changes-dialog-slice.js +3 -1
- package/dist/cjs/context/DashboardProvider/duplicate-panel-slice.js +3 -1
- package/dist/cjs/context/DashboardProvider/edit-json-dialog-slice.js +3 -1
- package/dist/cjs/context/DashboardProvider/index.js +12 -10
- package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +13 -11
- package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +8 -6
- package/dist/cjs/context/DashboardProvider/panel-group-slice.js +15 -7
- package/dist/cjs/context/DashboardProvider/panel-slice.js +3 -1
- package/dist/cjs/context/DashboardProvider/save-changes-dialog-slice.js +3 -1
- package/dist/cjs/context/DatasourceStoreProvider.js +114 -45
- package/dist/cjs/context/TemplateVariableProvider/TemplateVariableProvider.js +189 -51
- package/dist/cjs/context/TemplateVariableProvider/hydrationUtils.js +65 -13
- package/dist/cjs/context/TemplateVariableProvider/index.js +10 -8
- package/dist/cjs/context/TemplateVariableProvider/query-params.js +17 -7
- package/dist/cjs/context/TemplateVariableProvider/utils.js +49 -9
- package/dist/cjs/context/index.js +13 -11
- package/dist/cjs/context/useDashboard.js +8 -6
- package/dist/cjs/index.js +12 -10
- package/dist/cjs/stories/decorators/WithDashboard.js +6 -4
- package/dist/cjs/stories/decorators/WithDatasourceStore.js +6 -4
- package/dist/cjs/stories/decorators/WithTemplateVariables.js +6 -4
- package/dist/cjs/stories/decorators/constants.js +5 -3
- package/dist/cjs/stories/decorators/index.js +13 -11
- package/dist/cjs/test/dashboard-provider.js +8 -4
- package/dist/cjs/test/datasource-provider.js +16 -12
- package/dist/cjs/test/index.js +13 -11
- package/dist/cjs/test/plugin-registry.js +6 -4
- package/dist/cjs/test/render.js +27 -20
- package/dist/cjs/test/setup-tests.js +2 -2
- package/dist/cjs/test/testDashboard.js +13 -11
- package/dist/cjs/utils/index.js +11 -9
- package/dist/cjs/utils/panelUtils.js +9 -3
- package/dist/cjs/utils/time.js +5 -3
- package/dist/cjs/validation/index.js +30 -0
- package/dist/cjs/validation/panel.js +29 -0
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +24 -15
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +64 -19
- package/dist/cjs/views/ViewDashboard/index.js +10 -8
- package/dist/cjs/views/index.js +10 -8
- package/dist/components/AddGroupButton/AddGroupButton.js.map +1 -1
- package/dist/components/AddGroupButton/index.js.map +1 -1
- package/dist/components/AddPanelButton/AddPanelButton.js.map +1 -1
- package/dist/components/AddPanelButton/index.js.map +1 -1
- package/dist/components/Dashboard/Dashboard.d.ts +3 -1
- package/dist/components/Dashboard/Dashboard.d.ts.map +1 -1
- package/dist/components/Dashboard/Dashboard.js +3 -2
- package/dist/components/Dashboard/Dashboard.js.map +1 -1
- package/dist/components/Dashboard/index.js.map +1 -1
- package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js.map +1 -1
- package/dist/components/DashboardStickyToolbar/index.js.map +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.js +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
- package/dist/components/DashboardToolbar/index.js.map +1 -1
- package/dist/components/DeletePanelDialog/DeletePanelDialog.js.map +1 -1
- package/dist/components/DeletePanelDialog/index.js.map +1 -1
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +2 -2
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js.map +1 -1
- package/dist/components/DeletePanelGroupDialog/index.js.map +1 -1
- package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js.map +1 -1
- package/dist/components/DiscardChangesConfirmationDialog/index.js.map +1 -1
- package/dist/components/DownloadButton/DownloadButton.js.map +1 -1
- package/dist/components/DownloadButton/index.js.map +1 -1
- package/dist/components/EditButton/EditButton.js.map +1 -1
- package/dist/components/EditButton/index.js.map +1 -1
- package/dist/components/EditJsonButton/EditJsonButton.js.map +1 -1
- package/dist/components/EditJsonButton/index.js.map +1 -1
- package/dist/components/EditJsonDialog/EditJsonDialog.d.ts +4 -1
- package/dist/components/EditJsonDialog/EditJsonDialog.d.ts.map +1 -1
- package/dist/components/EditJsonDialog/EditJsonDialog.js +12 -8
- package/dist/components/EditJsonDialog/EditJsonDialog.js.map +1 -1
- package/dist/components/EditJsonDialog/index.js.map +1 -1
- package/dist/components/EmptyDashboard/EmptyDashboard.js.map +1 -1
- package/dist/components/EmptyDashboard/index.js.map +1 -1
- package/dist/components/GridLayout/GridContainer.js.map +1 -1
- package/dist/components/GridLayout/GridItemContent.d.ts +2 -0
- package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
- package/dist/components/GridLayout/GridItemContent.js +27 -8
- package/dist/components/GridLayout/GridItemContent.js.map +1 -1
- package/dist/components/GridLayout/GridLayout.d.ts +2 -0
- package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
- package/dist/components/GridLayout/GridLayout.js +3 -2
- package/dist/components/GridLayout/GridLayout.js.map +1 -1
- package/dist/components/GridLayout/GridTitle.js.map +1 -1
- package/dist/components/GridLayout/index.js.map +1 -1
- package/dist/components/Panel/Panel.d.ts +20 -0
- package/dist/components/Panel/Panel.d.ts.map +1 -1
- package/dist/components/Panel/Panel.js +8 -10
- package/dist/components/Panel/Panel.js.map +1 -1
- package/dist/components/Panel/PanelContent.js.map +1 -1
- package/dist/components/Panel/PanelHeader.d.ts +2 -1
- package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
- package/dist/components/Panel/PanelHeader.js +7 -3
- package/dist/components/Panel/PanelHeader.js.map +1 -1
- package/dist/components/Panel/index.js.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.js +22 -76
- package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts +4 -1
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.js +223 -138
- package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.js +2 -2
- package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
- package/dist/components/PanelDrawer/index.js.map +1 -1
- package/dist/components/PanelDrawer/usePanelEditor.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js.map +1 -1
- package/dist/components/PanelGroupDialog/index.js.map +1 -1
- package/dist/components/QuerySummaryTable/QuerySummaryTable.js +4 -4
- package/dist/components/QuerySummaryTable/QuerySummaryTable.js.map +1 -1
- package/dist/components/QuerySummaryTable/index.js.map +1 -1
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +4 -4
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +1 -1
- package/dist/components/SaveChangesConfirmationDialog/index.js.map +1 -1
- package/dist/components/SaveDashboardButton/SaveDashboardButton.js +4 -4
- package/dist/components/SaveDashboardButton/SaveDashboardButton.js.map +1 -1
- package/dist/components/SaveDashboardButton/index.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js +19 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
- package/dist/components/TimeRangeControls/index.js.map +1 -1
- package/dist/components/ToolbarIconButton/ToolbarIconButton.js.map +1 -1
- package/dist/components/ToolbarIconButton/index.js.map +1 -1
- package/dist/components/Variables/BuiltinVariableAccordions.d.ts +8 -0
- package/dist/components/Variables/BuiltinVariableAccordions.d.ts.map +1 -0
- package/dist/components/Variables/BuiltinVariableAccordions.js +127 -0
- package/dist/components/Variables/BuiltinVariableAccordions.js.map +1 -0
- package/dist/components/Variables/EditVariablesButton.d.ts.map +1 -1
- package/dist/components/Variables/EditVariablesButton.js +6 -1
- package/dist/components/Variables/EditVariablesButton.js.map +1 -1
- package/dist/components/Variables/TemplateVariable.d.ts +12 -2
- package/dist/components/Variables/TemplateVariable.d.ts.map +1 -1
- package/dist/components/Variables/TemplateVariable.js +102 -61
- package/dist/components/Variables/TemplateVariable.js.map +1 -1
- package/dist/components/Variables/VariableEditor.d.ts +9 -1
- package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditor.js +326 -97
- package/dist/components/Variables/VariableEditor.js.map +1 -1
- package/dist/components/Variables/VariableList.d.ts +5 -0
- package/dist/components/Variables/VariableList.d.ts.map +1 -1
- package/dist/components/Variables/VariableList.js +32 -18
- package/dist/components/Variables/VariableList.js.map +1 -1
- package/dist/components/Variables/index.d.ts +1 -0
- package/dist/components/Variables/index.d.ts.map +1 -1
- package/dist/components/Variables/index.js +1 -0
- package/dist/components/Variables/index.js.map +1 -1
- package/dist/components/index.js.map +1 -1
- package/dist/constants/grid-layout-config.js.map +1 -1
- package/dist/constants/index.js.map +1 -1
- package/dist/constants/user-interface-text.js.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.js +5 -5
- package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
- package/dist/context/DashboardProvider/common.js.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.js +2 -2
- package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
- package/dist/context/DashboardProvider/delete-panel-group-slice.js.map +1 -1
- package/dist/context/DashboardProvider/delete-panel-slice.js +2 -2
- package/dist/context/DashboardProvider/delete-panel-slice.js.map +1 -1
- package/dist/context/DashboardProvider/discard-changes-dialog-slice.js.map +1 -1
- package/dist/context/DashboardProvider/duplicate-panel-slice.js.map +1 -1
- package/dist/context/DashboardProvider/edit-json-dialog-slice.js.map +1 -1
- package/dist/context/DashboardProvider/index.js.map +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts +2 -1
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.js +7 -7
- package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
- package/dist/context/DashboardProvider/panel-group-editor-slice.js +2 -2
- package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -1
- package/dist/context/DashboardProvider/panel-group-slice.js +3 -3
- package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
- package/dist/context/DashboardProvider/panel-slice.js.map +1 -1
- package/dist/context/DashboardProvider/save-changes-dialog-slice.js.map +1 -1
- package/dist/context/DatasourceStoreProvider.d.ts +14 -10
- package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
- package/dist/context/DatasourceStoreProvider.js +107 -40
- package/dist/context/DatasourceStoreProvider.js.map +1 -1
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts +48 -13
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts.map +1 -1
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js +165 -41
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js.map +1 -1
- package/dist/context/TemplateVariableProvider/hydrationUtils.d.ts +9 -2
- package/dist/context/TemplateVariableProvider/hydrationUtils.d.ts.map +1 -1
- package/dist/context/TemplateVariableProvider/hydrationUtils.js +67 -12
- package/dist/context/TemplateVariableProvider/hydrationUtils.js.map +1 -1
- package/dist/context/TemplateVariableProvider/index.js.map +1 -1
- package/dist/context/TemplateVariableProvider/query-params.js.map +1 -1
- package/dist/context/TemplateVariableProvider/utils.d.ts +27 -2
- package/dist/context/TemplateVariableProvider/utils.d.ts.map +1 -1
- package/dist/context/TemplateVariableProvider/utils.js +48 -6
- package/dist/context/TemplateVariableProvider/utils.js.map +1 -1
- package/dist/context/index.js.map +1 -1
- package/dist/context/useDashboard.js +1 -1
- package/dist/context/useDashboard.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/stories/decorators/WithDashboard.js.map +1 -1
- package/dist/stories/decorators/WithDatasourceStore.js.map +1 -1
- package/dist/stories/decorators/WithTemplateVariables.js.map +1 -1
- package/dist/stories/decorators/constants.js +2 -2
- package/dist/stories/decorators/constants.js.map +1 -1
- package/dist/stories/decorators/index.js.map +1 -1
- package/dist/test/dashboard-provider.js.map +1 -1
- package/dist/test/datasource-provider.d.ts.map +1 -1
- package/dist/test/datasource-provider.js +5 -7
- package/dist/test/datasource-provider.js.map +1 -1
- package/dist/test/index.js.map +1 -1
- package/dist/test/plugin-registry.js.map +1 -1
- package/dist/test/render.d.ts.map +1 -1
- package/dist/test/render.js +8 -3
- package/dist/test/render.js.map +1 -1
- package/dist/test/setup-tests.js.map +1 -1
- package/dist/test/testDashboard.js +10 -10
- package/dist/test/testDashboard.js.map +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/panelUtils.js.map +1 -1
- package/dist/utils/time.js.map +1 -1
- package/dist/validation/index.d.ts +2 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +15 -0
- package/dist/validation/index.js.map +1 -0
- package/dist/validation/panel.d.ts +19 -0
- package/dist/validation/panel.d.ts.map +1 -0
- package/dist/validation/panel.js +21 -0
- package/dist/validation/panel.js.map +1 -0
- package/dist/views/ViewDashboard/DashboardApp.d.ts +1 -0
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.js +11 -4
- package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.d.ts +3 -1
- package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.js +51 -8
- package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
- package/dist/views/ViewDashboard/index.js.map +1 -1
- package/dist/views/index.js.map +1 -1
- package/package.json +8 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/context/TemplateVariableProvider/query-params.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 { VariableValue, VariableDefinition } from '@perses-dev/core';\nimport { QueryParamConfig, useQueryParams } from 'use-query-params';\n\nconst variableQueryParameterPrefix = 'var-';\n\nexport function getURLQueryParamName(name: string) {\n return `${variableQueryParameterPrefix}${name}`;\n}\n\nexport function encodeVariableValue(value: VariableValue) {\n if (Array.isArray(value)) {\n return value.join(',');\n }\n return value;\n}\n\nexport function decodeVariableValue(value: string): VariableValue {\n if (!value) {\n return null;\n }\n const values = value.split(',');\n if (values.length === 1) {\n return values[0] as string;\n }\n return values;\n}\n\nconst VariableValueParam: QueryParamConfig<VariableValue> = {\n encode: encodeVariableValue,\n decode: (v) => {\n if (typeof v === 'string') {\n return decodeVariableValue(v);\n }\n return '';\n },\n};\n\nexport function useVariableQueryParams(defs: VariableDefinition[]) {\n const config: Record<string, typeof VariableValueParam> = {};\n defs.forEach((def) => {\n const name = getURLQueryParamName(def.spec.name);\n config[name] = VariableValueParam;\n });\n return useQueryParams(config, { updateType: 'replaceIn' });\n}\n\nexport function getInitalValuesFromQueryParameters(\n queryParamValues: Record<string, VariableValue>\n): Record<string, VariableValue> {\n const values: Record<string, VariableValue> = {};\n Object.keys(queryParamValues).forEach((key) => {\n const value = queryParamValues[key];\n if (!value) {\n return;\n }\n const name = key.replace(variableQueryParameterPrefix, '');\n values[name] = value;\n });\n return values;\n}\n"],"names":["useQueryParams","variableQueryParameterPrefix","getURLQueryParamName","name","encodeVariableValue","value","Array","isArray","join","decodeVariableValue","values","split","length","VariableValueParam","encode","decode","v","useVariableQueryParams","defs","config","forEach","def","spec","updateType","getInitalValuesFromQueryParameters","queryParamValues","Object","keys","key","replace"],"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,SAA2BA,cAAc,QAAQ,
|
|
1
|
+
{"version":3,"sources":["../../../src/context/TemplateVariableProvider/query-params.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 { VariableValue, VariableDefinition } from '@perses-dev/core';\nimport { QueryParamConfig, useQueryParams } from 'use-query-params';\n\nconst variableQueryParameterPrefix = 'var-';\n\nexport function getURLQueryParamName(name: string) {\n return `${variableQueryParameterPrefix}${name}`;\n}\n\nexport function encodeVariableValue(value: VariableValue) {\n if (Array.isArray(value)) {\n return value.join(',');\n }\n return value;\n}\n\nexport function decodeVariableValue(value: string): VariableValue {\n if (!value) {\n return null;\n }\n const values = value.split(',');\n if (values.length === 1) {\n return values[0] as string;\n }\n return values;\n}\n\nconst VariableValueParam: QueryParamConfig<VariableValue> = {\n encode: encodeVariableValue,\n decode: (v) => {\n if (typeof v === 'string') {\n return decodeVariableValue(v);\n }\n return '';\n },\n};\n\nexport function useVariableQueryParams(defs: VariableDefinition[]) {\n const config: Record<string, typeof VariableValueParam> = {};\n defs.forEach((def) => {\n const name = getURLQueryParamName(def.spec.name);\n config[name] = VariableValueParam;\n });\n return useQueryParams(config, { updateType: 'replaceIn' });\n}\n\nexport function getInitalValuesFromQueryParameters(\n queryParamValues: Record<string, VariableValue>\n): Record<string, VariableValue> {\n const values: Record<string, VariableValue> = {};\n Object.keys(queryParamValues).forEach((key) => {\n const value = queryParamValues[key];\n if (!value) {\n return;\n }\n const name = key.replace(variableQueryParameterPrefix, '');\n values[name] = value;\n });\n return values;\n}\n"],"names":["useQueryParams","variableQueryParameterPrefix","getURLQueryParamName","name","encodeVariableValue","value","Array","isArray","join","decodeVariableValue","values","split","length","VariableValueParam","encode","decode","v","useVariableQueryParams","defs","config","forEach","def","spec","updateType","getInitalValuesFromQueryParameters","queryParamValues","Object","keys","key","replace"],"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,SAA2BA,cAAc,QAAQ,mBAAmB;AAEpE,MAAMC,+BAA+B;AAErC,OAAO,SAASC,qBAAqBC,IAAY;IAC/C,OAAO,CAAC,EAAEF,6BAA6B,EAAEE,KAAK,CAAC;AACjD;AAEA,OAAO,SAASC,oBAAoBC,KAAoB;IACtD,IAAIC,MAAMC,QAAQF,QAAQ;QACxB,OAAOA,MAAMG,KAAK;IACpB;IACA,OAAOH;AACT;AAEA,OAAO,SAASI,oBAAoBJ,KAAa;IAC/C,IAAI,CAACA,OAAO;QACV,OAAO;IACT;IACA,MAAMK,SAASL,MAAMM,MAAM;IAC3B,IAAID,OAAOE,WAAW,GAAG;QACvB,OAAOF,MAAM,CAAC,EAAE;IAClB;IACA,OAAOA;AACT;AAEA,MAAMG,qBAAsD;IAC1DC,QAAQV;IACRW,QAAQ,CAACC;QACP,IAAI,OAAOA,MAAM,UAAU;YACzB,OAAOP,oBAAoBO;QAC7B;QACA,OAAO;IACT;AACF;AAEA,OAAO,SAASC,uBAAuBC,IAA0B;IAC/D,MAAMC,SAAoD,CAAC;IAC3DD,KAAKE,QAAQ,CAACC;QACZ,MAAMlB,OAAOD,qBAAqBmB,IAAIC,KAAKnB;QAC3CgB,MAAM,CAAChB,KAAK,GAAGU;IACjB;IACA,OAAOb,eAAemB,QAAQ;QAAEI,YAAY;IAAY;AAC1D;AAEA,OAAO,SAASC,mCACdC,gBAA+C;IAE/C,MAAMf,SAAwC,CAAC;IAC/CgB,OAAOC,KAAKF,kBAAkBL,QAAQ,CAACQ;QACrC,MAAMvB,QAAQoB,gBAAgB,CAACG,IAAI;QACnC,IAAI,CAACvB,OAAO;YACV;QACF;QACA,MAAMF,OAAOyB,IAAIC,QAAQ5B,8BAA8B;QACvDS,MAAM,CAACP,KAAK,GAAGE;IACjB;IACA,OAAOK;AACT"}
|
|
@@ -1,7 +1,32 @@
|
|
|
1
1
|
import { VariableDefinition } from '@perses-dev/core';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { VariableStoreStateMap } from '@perses-dev/plugin-system';
|
|
3
|
+
import { ExternalVariableDefinition } from '@perses-dev/dashboards';
|
|
4
|
+
export declare function checkSavedDefaultVariableStatus(definitions: VariableDefinition[], varState: VariableStoreStateMap): {
|
|
4
5
|
isSavedVariableModified: boolean;
|
|
5
6
|
modifiedVariableNames: string[];
|
|
6
7
|
};
|
|
8
|
+
/**
|
|
9
|
+
* Merge the different kind of variable definition into a list without any duplicates (same name).
|
|
10
|
+
* Respects the order of priority explained in {@link forEachVariableDefinition}
|
|
11
|
+
* @param locals
|
|
12
|
+
* @param externals
|
|
13
|
+
*/
|
|
14
|
+
export declare function mergeVariableDefinitions(locals: VariableDefinition[], externals: ExternalVariableDefinition[]): VariableDefinition[];
|
|
15
|
+
/**
|
|
16
|
+
* Find a definition by its name.
|
|
17
|
+
* Respects the order of priority explained in {@link forEachVariableDefinition}
|
|
18
|
+
* @param name
|
|
19
|
+
* @param localDefinitions
|
|
20
|
+
* @param externalDefinitions
|
|
21
|
+
*/
|
|
22
|
+
export declare function findVariableDefinitionByName(name: string, localDefinitions: VariableDefinition[], externalDefinitions: ExternalVariableDefinition[]): VariableDefinition | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Loop on local and external variable definitions, respecting the order of priority:
|
|
25
|
+
* - local var defs override external var defs of same name
|
|
26
|
+
* - each external var defs override the external var defs coming after.
|
|
27
|
+
* @param locals
|
|
28
|
+
* @param externals
|
|
29
|
+
* @param callbackFn
|
|
30
|
+
*/
|
|
31
|
+
export declare function forEachVariableDefinition(locals: VariableDefinition[], externals: ExternalVariableDefinition[], callbackFn: (varDef: VariableDefinition, name: string, source?: string) => void): void;
|
|
7
32
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/context/TemplateVariableProvider/utils.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/context/TemplateVariableProvider/utils.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAKpE,wBAAgB,+BAA+B,CAAC,WAAW,EAAE,kBAAkB,EAAE,EAAE,QAAQ,EAAE,qBAAqB;;;EAqBjH;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,kBAAkB,EAAE,EAC5B,SAAS,EAAE,0BAA0B,EAAE,GACtC,kBAAkB,EAAE,CAYtB;AAED;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,MAAM,EACZ,gBAAgB,EAAE,kBAAkB,EAAE,EACtC,mBAAmB,EAAE,0BAA0B,EAAE,GAChD,kBAAkB,GAAG,SAAS,CAEhC;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,kBAAkB,EAAE,EAC5B,SAAS,EAAE,0BAA0B,EAAE,EACvC,UAAU,EAAE,CAAC,MAAM,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,QAIhF"}
|
|
@@ -16,17 +16,22 @@
|
|
|
16
16
|
let isSavedVariableModified = false;
|
|
17
17
|
const modifiedVariableNames = [];
|
|
18
18
|
for (const savedVariable of definitions){
|
|
19
|
+
const name = savedVariable.spec.name;
|
|
19
20
|
if (savedVariable.kind === 'ListVariable') {
|
|
20
|
-
const currentVariable = varState
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
const currentVariable = varState.get({
|
|
22
|
+
name
|
|
23
|
+
});
|
|
24
|
+
if ((currentVariable === null || currentVariable === void 0 ? void 0 : currentVariable.value) !== null && (currentVariable === null || currentVariable === void 0 ? void 0 : currentVariable.value) !== savedVariable.spec.defaultValue) {
|
|
25
|
+
modifiedVariableNames.push(name);
|
|
23
26
|
isSavedVariableModified = true;
|
|
24
27
|
}
|
|
25
28
|
} else if (savedVariable.kind === 'TextVariable') {
|
|
26
|
-
const
|
|
27
|
-
|
|
29
|
+
const currentVariable = varState.get({
|
|
30
|
+
name
|
|
31
|
+
});
|
|
32
|
+
const currentVariableValue = typeof (currentVariable === null || currentVariable === void 0 ? void 0 : currentVariable.value) === 'string' ? currentVariable.value : '';
|
|
28
33
|
if (savedVariable.spec.value !== currentVariableValue) {
|
|
29
|
-
modifiedVariableNames.push(
|
|
34
|
+
modifiedVariableNames.push(name);
|
|
30
35
|
isSavedVariableModified = true;
|
|
31
36
|
}
|
|
32
37
|
}
|
|
@@ -36,5 +41,42 @@
|
|
|
36
41
|
modifiedVariableNames
|
|
37
42
|
};
|
|
38
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Merge the different kind of variable definition into a list without any duplicates (same name).
|
|
46
|
+
* Respects the order of priority explained in {@link forEachVariableDefinition}
|
|
47
|
+
* @param locals
|
|
48
|
+
* @param externals
|
|
49
|
+
*/ export function mergeVariableDefinitions(locals, externals) {
|
|
50
|
+
const pushed = {};
|
|
51
|
+
const result = [];
|
|
52
|
+
// Append the value only if it's not already appended
|
|
53
|
+
forEachVariableDefinition(locals, externals, (value, name)=>{
|
|
54
|
+
if (!pushed[name]) {
|
|
55
|
+
result.push(value);
|
|
56
|
+
pushed[name] = true;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Find a definition by its name.
|
|
63
|
+
* Respects the order of priority explained in {@link forEachVariableDefinition}
|
|
64
|
+
* @param name
|
|
65
|
+
* @param localDefinitions
|
|
66
|
+
* @param externalDefinitions
|
|
67
|
+
*/ export function findVariableDefinitionByName(name, localDefinitions, externalDefinitions) {
|
|
68
|
+
return mergeVariableDefinitions(localDefinitions, externalDefinitions).find((d)=>d.spec.name === name);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Loop on local and external variable definitions, respecting the order of priority:
|
|
72
|
+
* - local var defs override external var defs of same name
|
|
73
|
+
* - each external var defs override the external var defs coming after.
|
|
74
|
+
* @param locals
|
|
75
|
+
* @param externals
|
|
76
|
+
* @param callbackFn
|
|
77
|
+
*/ export function forEachVariableDefinition(locals, externals, callbackFn) {
|
|
78
|
+
locals.forEach((v)=>callbackFn(v, v.spec.name));
|
|
79
|
+
externals.forEach((ext)=>ext.definitions.forEach((v)=>callbackFn(v, v.spec.name, ext.source)));
|
|
80
|
+
}
|
|
39
81
|
|
|
40
82
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/context/TemplateVariableProvider/utils.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 { VariableDefinition } from '@perses-dev/core';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/context/TemplateVariableProvider/utils.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 { VariableDefinition } from '@perses-dev/core';\nimport { VariableStoreStateMap } from '@perses-dev/plugin-system';\nimport { ExternalVariableDefinition } from '@perses-dev/dashboards';\n\n/*\n * Check whether saved variable definitions are out of date with current default list values in Zustand store\n */\nexport function checkSavedDefaultVariableStatus(definitions: VariableDefinition[], varState: VariableStoreStateMap) {\n let isSavedVariableModified = false;\n const modifiedVariableNames: string[] = [];\n for (const savedVariable of definitions) {\n const name = savedVariable.spec.name;\n if (savedVariable.kind === 'ListVariable') {\n const currentVariable = varState.get({ name });\n if (currentVariable?.value !== null && currentVariable?.value !== savedVariable.spec.defaultValue) {\n modifiedVariableNames.push(name);\n isSavedVariableModified = true;\n }\n } else if (savedVariable.kind === 'TextVariable') {\n const currentVariable = varState.get({ name });\n const currentVariableValue = typeof currentVariable?.value === 'string' ? currentVariable.value : '';\n if (savedVariable.spec.value !== currentVariableValue) {\n modifiedVariableNames.push(name);\n isSavedVariableModified = true;\n }\n }\n }\n return { isSavedVariableModified, modifiedVariableNames };\n}\n\n/**\n * Merge the different kind of variable definition into a list without any duplicates (same name).\n * Respects the order of priority explained in {@link forEachVariableDefinition}\n * @param locals\n * @param externals\n */\nexport function mergeVariableDefinitions(\n locals: VariableDefinition[],\n externals: ExternalVariableDefinition[]\n): VariableDefinition[] {\n const pushed: Record<string, boolean> = {};\n const result: VariableDefinition[] = [];\n\n // Append the value only if it's not already appended\n forEachVariableDefinition(locals, externals, (value: VariableDefinition, name: string) => {\n if (!pushed[name]) {\n result.push(value);\n pushed[name] = true;\n }\n });\n return result;\n}\n\n/**\n * Find a definition by its name.\n * Respects the order of priority explained in {@link forEachVariableDefinition}\n * @param name\n * @param localDefinitions\n * @param externalDefinitions\n */\nexport function findVariableDefinitionByName(\n name: string,\n localDefinitions: VariableDefinition[],\n externalDefinitions: ExternalVariableDefinition[]\n): VariableDefinition | undefined {\n return mergeVariableDefinitions(localDefinitions, externalDefinitions).find((d) => d.spec.name === name);\n}\n\n/**\n * Loop on local and external variable definitions, respecting the order of priority:\n * - local var defs override external var defs of same name\n * - each external var defs override the external var defs coming after.\n * @param locals\n * @param externals\n * @param callbackFn\n */\nexport function forEachVariableDefinition(\n locals: VariableDefinition[],\n externals: ExternalVariableDefinition[],\n callbackFn: (varDef: VariableDefinition, name: string, source?: string) => void\n) {\n locals.forEach((v) => callbackFn(v, v.spec.name));\n externals.forEach((ext) => ext.definitions.forEach((v) => callbackFn(v, v.spec.name, ext.source)));\n}\n"],"names":["checkSavedDefaultVariableStatus","definitions","varState","isSavedVariableModified","modifiedVariableNames","savedVariable","name","spec","kind","currentVariable","get","value","defaultValue","push","currentVariableValue","mergeVariableDefinitions","locals","externals","pushed","result","forEachVariableDefinition","findVariableDefinitionByName","localDefinitions","externalDefinitions","find","d","callbackFn","forEach","v","ext","source"],"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;AAMjC;;CAEC,GACD,OAAO,SAASA,gCAAgCC,WAAiC,EAAEC,QAA+B;IAChH,IAAIC,0BAA0B;IAC9B,MAAMC,wBAAkC,EAAE;IAC1C,KAAK,MAAMC,iBAAiBJ,YAAa;QACvC,MAAMK,OAAOD,cAAcE,KAAKD;QAChC,IAAID,cAAcG,SAAS,gBAAgB;YACzC,MAAMC,kBAAkBP,SAASQ,IAAI;gBAAEJ;YAAK;YAC5C,IAAIG,CAAAA,4BAAAA,6BAAAA,KAAAA,IAAAA,gBAAiBE,KAAI,MAAM,QAAQF,CAAAA,4BAAAA,6BAAAA,KAAAA,IAAAA,gBAAiBE,KAAI,MAAMN,cAAcE,KAAKK,cAAc;gBACjGR,sBAAsBS,KAAKP;gBAC3BH,0BAA0B;YAC5B;QACF,OAAO,IAAIE,cAAcG,SAAS,gBAAgB;YAChD,MAAMC,kBAAkBP,SAASQ,IAAI;gBAAEJ;YAAK;YAC5C,MAAMQ,uBAAuB,OAAOL,CAAAA,4BAAAA,6BAAAA,KAAAA,IAAAA,gBAAiBE,KAAI,MAAM,WAAWF,gBAAgBE,QAAQ;YAClG,IAAIN,cAAcE,KAAKI,UAAUG,sBAAsB;gBACrDV,sBAAsBS,KAAKP;gBAC3BH,0BAA0B;YAC5B;QACF;IACF;IACA,OAAO;QAAEA;QAAyBC;IAAsB;AAC1D;AAEA;;;;;CAKC,GACD,OAAO,SAASW,yBACdC,MAA4B,EAC5BC,SAAuC;IAEvC,MAAMC,SAAkC,CAAC;IACzC,MAAMC,SAA+B,EAAE;IAEvC,qDAAqD;IACrDC,0BAA0BJ,QAAQC,WAAW,CAACN,OAA2BL;QACvE,IAAI,CAACY,MAAM,CAACZ,KAAK,EAAE;YACjBa,OAAON,KAAKF;YACZO,MAAM,CAACZ,KAAK,GAAG;QACjB;IACF;IACA,OAAOa;AACT;AAEA;;;;;;CAMC,GACD,OAAO,SAASE,6BACdf,IAAY,EACZgB,gBAAsC,EACtCC,mBAAiD;IAEjD,OAAOR,yBAAyBO,kBAAkBC,qBAAqBC,KAAK,CAACC,IAAMA,EAAElB,KAAKD,SAASA;AACrG;AAEA;;;;;;;CAOC,GACD,OAAO,SAASc,0BACdJ,MAA4B,EAC5BC,SAAuC,EACvCS,UAA+E;IAE/EV,OAAOW,QAAQ,CAACC,IAAMF,WAAWE,GAAGA,EAAErB,KAAKD;IAC3CW,UAAUU,QAAQ,CAACE,MAAQA,IAAI5B,YAAY0B,QAAQ,CAACC,IAAMF,WAAWE,GAAGA,EAAErB,KAAKD,MAAMuB,IAAIC;AAC3F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/context/index.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\nexport * from './DashboardProvider';\nexport * from './DatasourceStoreProvider';\nexport * from './TemplateVariableProvider';\nexport * from './useDashboard';\n"],"names":[],"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,cAAc,
|
|
1
|
+
{"version":3,"sources":["../../src/context/index.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\nexport * from './DashboardProvider';\nexport * from './DatasourceStoreProvider';\nexport * from './TemplateVariableProvider';\nexport * from './useDashboard';\n"],"names":[],"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,cAAc,sBAAsB;AACpC,cAAc,4BAA4B;AAC1C,cAAc,6BAA6B;AAC3C,cAAc,iBAAiB"}
|
|
@@ -14,7 +14,7 @@ import { createPanelRef } from '@perses-dev/core';
|
|
|
14
14
|
import { useDashboardStore } from './DashboardProvider';
|
|
15
15
|
import { useTemplateVariableActions, useTemplateVariableDefinitions } from './TemplateVariableProvider';
|
|
16
16
|
export function useDashboard() {
|
|
17
|
-
const { panels , panelGroups , panelGroupOrder , setDashboard: setDashboardResource , metadata , display , duration , refreshInterval
|
|
17
|
+
const { panels , panelGroups , panelGroupOrder , setDashboard: setDashboardResource , metadata , display , duration , refreshInterval } = useDashboardStore(({ panels , panelGroups , panelGroupOrder , setDashboard , metadata , display , duration , refreshInterval })=>({
|
|
18
18
|
panels,
|
|
19
19
|
panelGroups,
|
|
20
20
|
panelGroupOrder,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/context/useDashboard.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 { createPanelRef, DashboardResource, GridDefinition } from '@perses-dev/core';\nimport { PanelGroupDefinition, PanelGroupId, useDashboardStore } from './DashboardProvider';\nimport { useTemplateVariableActions, useTemplateVariableDefinitions } from './TemplateVariableProvider';\n\nexport function useDashboard() {\n const {\n panels,\n panelGroups,\n panelGroupOrder,\n setDashboard: setDashboardResource,\n metadata,\n display,\n duration,\n refreshInterval,\n } = useDashboardStore(\n ({ panels, panelGroups, panelGroupOrder, setDashboard, metadata, display, duration, refreshInterval }) => ({\n panels,\n panelGroups,\n panelGroupOrder,\n setDashboard,\n metadata,\n display,\n duration,\n refreshInterval,\n })\n );\n const { setVariableDefinitions } = useTemplateVariableActions();\n const variables = useTemplateVariableDefinitions();\n const layouts = convertPanelGroupsToLayouts(panelGroups, panelGroupOrder);\n\n const dashboard: DashboardResource = {\n kind: 'Dashboard',\n metadata,\n spec: {\n display,\n panels,\n layouts,\n variables,\n duration,\n refreshInterval,\n },\n };\n\n const setDashboard = (dashboardResource: DashboardResource) => {\n setVariableDefinitions(dashboardResource.spec.variables);\n setDashboardResource(dashboardResource);\n };\n\n return {\n dashboard,\n setDashboard,\n };\n}\n\nfunction convertPanelGroupsToLayouts(\n panelGroups: Record<number, PanelGroupDefinition>,\n panelGroupOrder: PanelGroupId[]\n): GridDefinition[] {\n const layouts: GridDefinition[] = [];\n panelGroupOrder.map((groupOrderId) => {\n const group = panelGroups[groupOrderId];\n if (group === undefined) {\n throw new Error('panel group not found');\n }\n const { title, isCollapsed, itemLayouts, itemPanelKeys } = group;\n let display = undefined;\n if (title) {\n display = {\n title,\n collapse: {\n open: !isCollapsed,\n },\n };\n }\n const layout: GridDefinition = {\n kind: 'Grid',\n spec: {\n display,\n items: itemLayouts.map((layout) => {\n const panelKey = itemPanelKeys[layout.i];\n if (panelKey === undefined) {\n throw new Error(`Missing panel key of layout ${layout.i}`);\n }\n return {\n x: layout.x,\n y: layout.y,\n width: layout.w,\n height: layout.h,\n content: createPanelRef(panelKey),\n };\n }),\n },\n };\n layouts.push(layout);\n });\n\n return layouts;\n}\n"],"names":["createPanelRef","useDashboardStore","useTemplateVariableActions","useTemplateVariableDefinitions","useDashboard","panels","panelGroups","panelGroupOrder","setDashboard","setDashboardResource","metadata","display","duration","refreshInterval","setVariableDefinitions","variables","layouts","convertPanelGroupsToLayouts","dashboard","kind","spec","dashboardResource","map","groupOrderId","group","undefined","Error","title","isCollapsed","itemLayouts","itemPanelKeys","collapse","open","layout","items","panelKey","i","x","y","width","w","height","h","content","push"],"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,SAASA,cAAc,QAA2C,
|
|
1
|
+
{"version":3,"sources":["../../src/context/useDashboard.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 { createPanelRef, DashboardResource, GridDefinition } from '@perses-dev/core';\nimport { PanelGroupDefinition, PanelGroupId, useDashboardStore } from './DashboardProvider';\nimport { useTemplateVariableActions, useTemplateVariableDefinitions } from './TemplateVariableProvider';\n\nexport function useDashboard() {\n const {\n panels,\n panelGroups,\n panelGroupOrder,\n setDashboard: setDashboardResource,\n metadata,\n display,\n duration,\n refreshInterval,\n } = useDashboardStore(\n ({ panels, panelGroups, panelGroupOrder, setDashboard, metadata, display, duration, refreshInterval }) => ({\n panels,\n panelGroups,\n panelGroupOrder,\n setDashboard,\n metadata,\n display,\n duration,\n refreshInterval,\n })\n );\n const { setVariableDefinitions } = useTemplateVariableActions();\n const variables = useTemplateVariableDefinitions();\n const layouts = convertPanelGroupsToLayouts(panelGroups, panelGroupOrder);\n\n const dashboard: DashboardResource = {\n kind: 'Dashboard',\n metadata,\n spec: {\n display,\n panels,\n layouts,\n variables,\n duration,\n refreshInterval,\n },\n };\n\n const setDashboard = (dashboardResource: DashboardResource) => {\n setVariableDefinitions(dashboardResource.spec.variables);\n setDashboardResource(dashboardResource);\n };\n\n return {\n dashboard,\n setDashboard,\n };\n}\n\nfunction convertPanelGroupsToLayouts(\n panelGroups: Record<number, PanelGroupDefinition>,\n panelGroupOrder: PanelGroupId[]\n): GridDefinition[] {\n const layouts: GridDefinition[] = [];\n panelGroupOrder.map((groupOrderId) => {\n const group = panelGroups[groupOrderId];\n if (group === undefined) {\n throw new Error('panel group not found');\n }\n const { title, isCollapsed, itemLayouts, itemPanelKeys } = group;\n let display = undefined;\n if (title) {\n display = {\n title,\n collapse: {\n open: !isCollapsed,\n },\n };\n }\n const layout: GridDefinition = {\n kind: 'Grid',\n spec: {\n display,\n items: itemLayouts.map((layout) => {\n const panelKey = itemPanelKeys[layout.i];\n if (panelKey === undefined) {\n throw new Error(`Missing panel key of layout ${layout.i}`);\n }\n return {\n x: layout.x,\n y: layout.y,\n width: layout.w,\n height: layout.h,\n content: createPanelRef(panelKey),\n };\n }),\n },\n };\n layouts.push(layout);\n });\n\n return layouts;\n}\n"],"names":["createPanelRef","useDashboardStore","useTemplateVariableActions","useTemplateVariableDefinitions","useDashboard","panels","panelGroups","panelGroupOrder","setDashboard","setDashboardResource","metadata","display","duration","refreshInterval","setVariableDefinitions","variables","layouts","convertPanelGroupsToLayouts","dashboard","kind","spec","dashboardResource","map","groupOrderId","group","undefined","Error","title","isCollapsed","itemLayouts","itemPanelKeys","collapse","open","layout","items","panelKey","i","x","y","width","w","height","h","content","push"],"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,SAASA,cAAc,QAA2C,mBAAmB;AACrF,SAA6CC,iBAAiB,QAAQ,sBAAsB;AAC5F,SAASC,0BAA0B,EAAEC,8BAA8B,QAAQ,6BAA6B;AAExG,OAAO,SAASC;IACd,MAAM,EACJC,OAAM,EACNC,YAAW,EACXC,gBAAe,EACfC,cAAcC,qBAAoB,EAClCC,SAAQ,EACRC,QAAO,EACPC,SAAQ,EACRC,gBAAe,EAChB,GAAGZ,kBACF,CAAC,EAAEI,OAAM,EAAEC,YAAW,EAAEC,gBAAe,EAAEC,aAAY,EAAEE,SAAQ,EAAEC,QAAO,EAAEC,SAAQ,EAAEC,gBAAe,EAAE,GAAM,CAAA;YACzGR;YACAC;YACAC;YACAC;YACAE;YACAC;YACAC;YACAC;QACF,CAAA;IAEF,MAAM,EAAEC,uBAAsB,EAAE,GAAGZ;IACnC,MAAMa,YAAYZ;IAClB,MAAMa,UAAUC,4BAA4BX,aAAaC;IAEzD,MAAMW,YAA+B;QACnCC,MAAM;QACNT;QACAU,MAAM;YACJT;YACAN;YACAW;YACAD;YACAH;YACAC;QACF;IACF;IAEA,MAAML,eAAe,CAACa;QACpBP,uBAAuBO,kBAAkBD,KAAKL;QAC9CN,qBAAqBY;IACvB;IAEA,OAAO;QACLH;QACAV;IACF;AACF;AAEA,SAASS,4BACPX,WAAiD,EACjDC,eAA+B;IAE/B,MAAMS,UAA4B,EAAE;IACpCT,gBAAgBe,IAAI,CAACC;QACnB,MAAMC,QAAQlB,WAAW,CAACiB,aAAa;QACvC,IAAIC,UAAUC,WAAW;YACvB,MAAM,IAAIC,MAAM;QAClB;QACA,MAAM,EAAEC,MAAK,EAAEC,YAAW,EAAEC,YAAW,EAAEC,cAAa,EAAE,GAAGN;QAC3D,IAAIb,UAAUc;QACd,IAAIE,OAAO;YACThB,UAAU;gBACRgB;gBACAI,UAAU;oBACRC,MAAM,CAACJ;gBACT;YACF;QACF;QACA,MAAMK,SAAyB;YAC7Bd,MAAM;YACNC,MAAM;gBACJT;gBACAuB,OAAOL,YAAYP,IAAI,CAACW;oBACtB,MAAME,WAAWL,aAAa,CAACG,OAAOG,EAAE;oBACxC,IAAID,aAAaV,WAAW;wBAC1B,MAAM,IAAIC,MAAM,CAAC,4BAA4B,EAAEO,OAAOG,EAAE,CAAC;oBAC3D;oBACA,OAAO;wBACLC,GAAGJ,OAAOI;wBACVC,GAAGL,OAAOK;wBACVC,OAAON,OAAOO;wBACdC,QAAQR,OAAOS;wBACfC,SAAS3C,eAAemC;oBAC1B;gBACF;YACF;QACF;QACAnB,QAAQ4B,KAAKX;IACf;IAEA,OAAOjB;AACT"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.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\nexport * from './components';\nexport * from './context';\nexport * from './views';\n"],"names":[],"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,cAAc,
|
|
1
|
+
{"version":3,"sources":["../src/index.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\nexport * from './components';\nexport * from './context';\nexport * from './views';\n"],"names":[],"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,cAAc,eAAe;AAC7B,cAAc,YAAY;AAC1B,cAAc,UAAU"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/stories/decorators/WithDashboard.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 { StoryFn, StoryContext } from '@storybook/react';\nimport { DashboardProvider, DashboardProviderProps } from '@perses-dev/dashboards';\nimport { EMPTY_DASHBOARD_RESOURCE } from './constants';\n\ndeclare module '@storybook/react' {\n interface Parameters {\n withDashboard?: WithDashboardParameter;\n }\n}\n\nexport type WithDashboardParameter = {\n props: Partial<DashboardProviderProps>;\n};\n\n// Type guard because storybook types parameters as `any`\nfunction isWithDashboardParameter(parameter: unknown | WithDashboardParameter): parameter is WithDashboardParameter {\n return !!parameter && typeof parameter === 'object' && 'props' in parameter;\n}\n\nexport const WithDashboard = (Story: StoryFn, context: StoryContext<unknown>) => {\n const initParameter = context.parameters.withDashboard;\n const parameter = isWithDashboardParameter(initParameter) ? initParameter : undefined;\n const props = parameter?.props;\n\n return (\n <DashboardProvider initialState={{ dashboardResource: EMPTY_DASHBOARD_RESOURCE }} {...props}>\n <Story />\n </DashboardProvider>\n );\n};\n"],"names":["DashboardProvider","EMPTY_DASHBOARD_RESOURCE","isWithDashboardParameter","parameter","WithDashboard","Story","context","initParameter","parameters","withDashboard","undefined","props","initialState","dashboardResource"],"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
|
|
1
|
+
{"version":3,"sources":["../../../src/stories/decorators/WithDashboard.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 { StoryFn, StoryContext } from '@storybook/react';\nimport { DashboardProvider, DashboardProviderProps } from '@perses-dev/dashboards';\nimport { EMPTY_DASHBOARD_RESOURCE } from './constants';\n\ndeclare module '@storybook/react' {\n interface Parameters {\n withDashboard?: WithDashboardParameter;\n }\n}\n\nexport type WithDashboardParameter = {\n props: Partial<DashboardProviderProps>;\n};\n\n// Type guard because storybook types parameters as `any`\nfunction isWithDashboardParameter(parameter: unknown | WithDashboardParameter): parameter is WithDashboardParameter {\n return !!parameter && typeof parameter === 'object' && 'props' in parameter;\n}\n\nexport const WithDashboard = (Story: StoryFn, context: StoryContext<unknown>) => {\n const initParameter = context.parameters.withDashboard;\n const parameter = isWithDashboardParameter(initParameter) ? initParameter : undefined;\n const props = parameter?.props;\n\n return (\n <DashboardProvider initialState={{ dashboardResource: EMPTY_DASHBOARD_RESOURCE }} {...props}>\n <Story />\n </DashboardProvider>\n );\n};\n"],"names":["DashboardProvider","EMPTY_DASHBOARD_RESOURCE","isWithDashboardParameter","parameter","WithDashboard","Story","context","initParameter","parameters","withDashboard","undefined","props","initialState","dashboardResource"],"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,iBAAiB,QAAgC,yBAAyB;AACnF,SAASC,wBAAwB,QAAQ,cAAc;AAYvD,yDAAyD;AACzD,SAASC,yBAAyBC,SAA2C;IAC3E,OAAO,CAAC,CAACA,aAAa,OAAOA,cAAc,YAAY,WAAWA;AACpE;AAEA,OAAO,MAAMC,gBAAgB,CAACC,OAAgBC;IAC5C,MAAMC,gBAAgBD,QAAQE,WAAWC;IACzC,MAAMN,YAAYD,yBAAyBK,iBAAiBA,gBAAgBG;IAC5E,MAAMC,QAAQR,sBAAAA,uBAAAA,KAAAA,IAAAA,UAAWQ;IAEzB,qBACE,KAACX;QAAkBY,cAAc;YAAEC,mBAAmBZ;QAAyB;QAAI,GAAGU,KAAK;kBACzF,cAAA,KAACN;;AAGP,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/stories/decorators/WithDatasourceStore.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 { StoryFn, StoryContext } from '@storybook/react';\nimport { DatasourceStoreProvider, DatasourceStoreProviderProps } from '@perses-dev/dashboards';\nimport { defaultDatasourceProps } from '../../test';\n\ndeclare module '@storybook/react' {\n interface Parameters {\n withDatasourceStore?: WithDatasourceStoreParameter;\n }\n}\n\nexport type WithDatasourceStoreParameter = {\n props: Partial<DatasourceStoreProviderProps>;\n};\n\n// Type guard because storybook types parameters as `any`\nfunction isWithDatasourceStoreParameter(\n parameter: unknown | WithDatasourceStoreParameter\n): parameter is WithDatasourceStoreParameter {\n return !!parameter && typeof parameter === 'object' && 'props' in parameter;\n}\n\nexport const WithDatasourceStore = (Story: StoryFn, context: StoryContext<unknown>) => {\n const initParameter = context.parameters.withDatasourceStore;\n const parameter = isWithDatasourceStoreParameter(initParameter) ? initParameter : undefined;\n const props = parameter?.props;\n\n return (\n <DatasourceStoreProvider {...defaultDatasourceProps} {...props}>\n <Story />\n </DatasourceStoreProvider>\n );\n};\n"],"names":["DatasourceStoreProvider","defaultDatasourceProps","isWithDatasourceStoreParameter","parameter","WithDatasourceStore","Story","context","initParameter","parameters","withDatasourceStore","undefined","props"],"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
|
|
1
|
+
{"version":3,"sources":["../../../src/stories/decorators/WithDatasourceStore.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 { StoryFn, StoryContext } from '@storybook/react';\nimport { DatasourceStoreProvider, DatasourceStoreProviderProps } from '@perses-dev/dashboards';\nimport { defaultDatasourceProps } from '../../test';\n\ndeclare module '@storybook/react' {\n interface Parameters {\n withDatasourceStore?: WithDatasourceStoreParameter;\n }\n}\n\nexport type WithDatasourceStoreParameter = {\n props: Partial<DatasourceStoreProviderProps>;\n};\n\n// Type guard because storybook types parameters as `any`\nfunction isWithDatasourceStoreParameter(\n parameter: unknown | WithDatasourceStoreParameter\n): parameter is WithDatasourceStoreParameter {\n return !!parameter && typeof parameter === 'object' && 'props' in parameter;\n}\n\nexport const WithDatasourceStore = (Story: StoryFn, context: StoryContext<unknown>) => {\n const initParameter = context.parameters.withDatasourceStore;\n const parameter = isWithDatasourceStoreParameter(initParameter) ? initParameter : undefined;\n const props = parameter?.props;\n\n return (\n <DatasourceStoreProvider {...defaultDatasourceProps} {...props}>\n <Story />\n </DatasourceStoreProvider>\n );\n};\n"],"names":["DatasourceStoreProvider","defaultDatasourceProps","isWithDatasourceStoreParameter","parameter","WithDatasourceStore","Story","context","initParameter","parameters","withDatasourceStore","undefined","props"],"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,uBAAuB,QAAsC,yBAAyB;AAC/F,SAASC,sBAAsB,QAAQ,aAAa;AAYpD,yDAAyD;AACzD,SAASC,+BACPC,SAAiD;IAEjD,OAAO,CAAC,CAACA,aAAa,OAAOA,cAAc,YAAY,WAAWA;AACpE;AAEA,OAAO,MAAMC,sBAAsB,CAACC,OAAgBC;IAClD,MAAMC,gBAAgBD,QAAQE,WAAWC;IACzC,MAAMN,YAAYD,+BAA+BK,iBAAiBA,gBAAgBG;IAClF,MAAMC,QAAQR,sBAAAA,uBAAAA,KAAAA,IAAAA,UAAWQ;IAEzB,qBACE,KAACX;QAAyB,GAAGC,sBAAsB;QAAG,GAAGU,KAAK;kBAC5D,cAAA,KAACN;;AAGP,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/stories/decorators/WithTemplateVariables.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 { StoryFn, StoryContext } from '@storybook/react';\nimport { TemplateVariableProvider, TemplateVariableProviderProps } from '@perses-dev/dashboards';\n\ndeclare module '@storybook/react' {\n interface Parameters {\n withTemplateVariables?: WithTemplateVariableParameter;\n }\n}\n\nexport type WithTemplateVariableParameter = {\n props: Partial<TemplateVariableProviderProps>;\n};\n\n// Type guard because storybook types parameters as `any`\nfunction isWithTemplateVariableParameter(\n parameter: unknown | WithTemplateVariableParameter\n): parameter is WithTemplateVariableParameter {\n return !!parameter && typeof parameter === 'object' && 'props' in parameter;\n}\n\nexport const WithTemplateVariables = (Story: StoryFn, context: StoryContext<unknown>) => {\n const initParameter = context.parameters.withTemplateVariables;\n const parameter = isWithTemplateVariableParameter(initParameter) ? initParameter : undefined;\n const props = parameter?.props;\n\n return (\n <TemplateVariableProvider {...props}>\n <Story />\n </TemplateVariableProvider>\n );\n};\n"],"names":["TemplateVariableProvider","isWithTemplateVariableParameter","parameter","WithTemplateVariables","Story","context","initParameter","parameters","withTemplateVariables","undefined","props"],"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
|
|
1
|
+
{"version":3,"sources":["../../../src/stories/decorators/WithTemplateVariables.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 { StoryFn, StoryContext } from '@storybook/react';\nimport { TemplateVariableProvider, TemplateVariableProviderProps } from '@perses-dev/dashboards';\n\ndeclare module '@storybook/react' {\n interface Parameters {\n withTemplateVariables?: WithTemplateVariableParameter;\n }\n}\n\nexport type WithTemplateVariableParameter = {\n props: Partial<TemplateVariableProviderProps>;\n};\n\n// Type guard because storybook types parameters as `any`\nfunction isWithTemplateVariableParameter(\n parameter: unknown | WithTemplateVariableParameter\n): parameter is WithTemplateVariableParameter {\n return !!parameter && typeof parameter === 'object' && 'props' in parameter;\n}\n\nexport const WithTemplateVariables = (Story: StoryFn, context: StoryContext<unknown>) => {\n const initParameter = context.parameters.withTemplateVariables;\n const parameter = isWithTemplateVariableParameter(initParameter) ? initParameter : undefined;\n const props = parameter?.props;\n\n return (\n <TemplateVariableProvider {...props}>\n <Story />\n </TemplateVariableProvider>\n );\n};\n"],"names":["TemplateVariableProvider","isWithTemplateVariableParameter","parameter","WithTemplateVariables","Story","context","initParameter","parameters","withTemplateVariables","undefined","props"],"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,wBAAwB,QAAuC,yBAAyB;AAYjG,yDAAyD;AACzD,SAASC,gCACPC,SAAkD;IAElD,OAAO,CAAC,CAACA,aAAa,OAAOA,cAAc,YAAY,WAAWA;AACpE;AAEA,OAAO,MAAMC,wBAAwB,CAACC,OAAgBC;IACpD,MAAMC,gBAAgBD,QAAQE,WAAWC;IACzC,MAAMN,YAAYD,gCAAgCK,iBAAiBA,gBAAgBG;IACnF,MAAMC,QAAQR,sBAAAA,uBAAAA,KAAAA,IAAAA,UAAWQ;IAEzB,qBACE,KAACV;QAA0B,GAAGU,KAAK;kBACjC,cAAA,KAACN;;AAGP,EAAE"}
|
|
@@ -15,8 +15,8 @@ export const EMPTY_DASHBOARD_RESOURCE = {
|
|
|
15
15
|
metadata: {
|
|
16
16
|
name: 'My Dashboard',
|
|
17
17
|
project: 'Storybook',
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
createdAt: '2021-11-09T00:00:00Z',
|
|
19
|
+
updatedAt: '2021-11-09T00:00:00Z',
|
|
20
20
|
version: 0
|
|
21
21
|
},
|
|
22
22
|
spec: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/stories/decorators/constants.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 { DashboardResource } from '@perses-dev/core';\n\nexport const EMPTY_DASHBOARD_RESOURCE: DashboardResource = {\n kind: 'Dashboard',\n metadata: {\n name: 'My Dashboard',\n project: 'Storybook',\n
|
|
1
|
+
{"version":3,"sources":["../../../src/stories/decorators/constants.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 { DashboardResource } from '@perses-dev/core';\n\nexport const EMPTY_DASHBOARD_RESOURCE: DashboardResource = {\n kind: 'Dashboard',\n metadata: {\n name: 'My Dashboard',\n project: 'Storybook',\n createdAt: '2021-11-09T00:00:00Z',\n updatedAt: '2021-11-09T00:00:00Z',\n version: 0,\n },\n spec: {\n duration: '1h',\n refreshInterval: '0s',\n variables: [],\n layouts: [],\n panels: {},\n },\n};\n"],"names":["EMPTY_DASHBOARD_RESOURCE","kind","metadata","name","project","createdAt","updatedAt","version","spec","duration","refreshInterval","variables","layouts","panels"],"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;AAIjC,OAAO,MAAMA,2BAA8C;IACzDC,MAAM;IACNC,UAAU;QACRC,MAAM;QACNC,SAAS;QACTC,WAAW;QACXC,WAAW;QACXC,SAAS;IACX;IACAC,MAAM;QACJC,UAAU;QACVC,iBAAiB;QACjBC,WAAW,EAAE;QACbC,SAAS,EAAE;QACXC,QAAQ,CAAC;IACX;AACF,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/stories/decorators/index.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\nexport * from './constants';\nexport * from './WithDashboard';\nexport * from './WithDatasourceStore';\nexport * from './WithTemplateVariables';\n"],"names":[],"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,cAAc,
|
|
1
|
+
{"version":3,"sources":["../../../src/stories/decorators/index.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\nexport * from './constants';\nexport * from './WithDashboard';\nexport * from './WithDatasourceStore';\nexport * from './WithTemplateVariables';\n"],"names":[],"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,cAAc,cAAc;AAC5B,cAAc,kBAAkB;AAChC,cAAc,wBAAwB;AACtC,cAAc,0BAA0B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/test/dashboard-provider.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 { DashboardResource } from '@perses-dev/core';\nimport { useContext } from 'react';\nimport { StoreApi } from 'zustand';\nimport { DashboardContext, DashboardStoreState } from '../context';\nimport testDashboard from './testDashboard';\n\n/**\n * Helper to get a test dashboard resource.\n */\nexport function getTestDashboard(): DashboardResource {\n // TODO: Should we be cloning this to create a new object each time?\n return testDashboard;\n}\n\n/**\n * Test helper to create a \"spy\" component that will capture the DashboardProvider's store, allowing you to inspect\n * its state in tests. Be sure to render the DashboardProviderSpy component that's returned in the component test\n * underneath the DashboardProvider.\n */\nexport function createDashboardProviderSpy() {\n const store: { value?: StoreApi<DashboardStoreState> } = {};\n\n // Spy component just captures the store value so it can be inspected in tests\n function DashboardProviderSpy() {\n const ctx = useContext(DashboardContext);\n store.value = ctx;\n return null;\n }\n\n return {\n DashboardProviderSpy,\n store,\n };\n}\n"],"names":["useContext","DashboardContext","testDashboard","getTestDashboard","createDashboardProviderSpy","store","DashboardProviderSpy","ctx","value"],"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,UAAU,QAAQ,
|
|
1
|
+
{"version":3,"sources":["../../src/test/dashboard-provider.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 { DashboardResource } from '@perses-dev/core';\nimport { useContext } from 'react';\nimport { StoreApi } from 'zustand';\nimport { DashboardContext, DashboardStoreState } from '../context';\nimport testDashboard from './testDashboard';\n\n/**\n * Helper to get a test dashboard resource.\n */\nexport function getTestDashboard(): DashboardResource {\n // TODO: Should we be cloning this to create a new object each time?\n return testDashboard;\n}\n\n/**\n * Test helper to create a \"spy\" component that will capture the DashboardProvider's store, allowing you to inspect\n * its state in tests. Be sure to render the DashboardProviderSpy component that's returned in the component test\n * underneath the DashboardProvider.\n */\nexport function createDashboardProviderSpy() {\n const store: { value?: StoreApi<DashboardStoreState> } = {};\n\n // Spy component just captures the store value so it can be inspected in tests\n function DashboardProviderSpy() {\n const ctx = useContext(DashboardContext);\n store.value = ctx;\n return null;\n }\n\n return {\n DashboardProviderSpy,\n store,\n };\n}\n"],"names":["useContext","DashboardContext","testDashboard","getTestDashboard","createDashboardProviderSpy","store","DashboardProviderSpy","ctx","value"],"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,UAAU,QAAQ,QAAQ;AAEnC,SAASC,gBAAgB,QAA6B,aAAa;AACnE,OAAOC,mBAAmB,kBAAkB;AAE5C;;CAEC,GACD,OAAO,SAASC;IACd,oEAAoE;IACpE,OAAOD;AACT;AAEA;;;;CAIC,GACD,OAAO,SAASE;IACd,MAAMC,QAAmD,CAAC;IAE1D,8EAA8E;IAC9E,SAASC;QACP,MAAMC,MAAMP,WAAWC;QACvBI,MAAMG,QAAQD;QACd,OAAO;IACT;IAEA,OAAO;QACLD;QACAD;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datasource-provider.d.ts","sourceRoot":"","sources":["../../src/test/datasource-provider.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;AAG1D,eAAO,MAAM,iBAAiB,6CAA6C,CAAC;AAC5E,eAAO,MAAM,cAAc,EAAE,gBAenB,CAAC;AAKX,eAAO,MAAM,sBAAsB,EAAE,IAAI,CAAC,4BAA4B,EAAE,eAAe,GAAG,mBAAmB,
|
|
1
|
+
{"version":3,"file":"datasource-provider.d.ts","sourceRoot":"","sources":["../../src/test/datasource-provider.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;AAG1D,eAAO,MAAM,iBAAiB,6CAA6C,CAAC;AAC5E,eAAO,MAAM,cAAc,EAAE,gBAenB,CAAC;AAKX,eAAO,MAAM,sBAAsB,EAAE,IAAI,CAAC,4BAA4B,EAAE,eAAe,GAAG,mBAAmB,CAqB5G,CAAC"}
|
|
@@ -16,8 +16,8 @@ export const prometheusDemo = {
|
|
|
16
16
|
kind: 'GlobalDatasource',
|
|
17
17
|
metadata: {
|
|
18
18
|
name: 'PrometheusDemo',
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
createdAt: '0001-01-01T00:00:00Z',
|
|
20
|
+
updatedAt: '0001-01-01T00:00:00Z',
|
|
21
21
|
version: 0
|
|
22
22
|
},
|
|
23
23
|
spec: {
|
|
@@ -25,7 +25,7 @@ export const prometheusDemo = {
|
|
|
25
25
|
plugin: {
|
|
26
26
|
kind: 'PrometheusDatasource',
|
|
27
27
|
spec: {
|
|
28
|
-
|
|
28
|
+
directUrl: prometheusDemoUrl
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -36,15 +36,13 @@ export const prometheusDemo = {
|
|
|
36
36
|
export const defaultDatasourceProps = {
|
|
37
37
|
dashboardResource: getTestDashboard(),
|
|
38
38
|
datasourceApi: {
|
|
39
|
+
buildProxyUrl: ()=>'',
|
|
39
40
|
getDatasource: ()=>{
|
|
40
41
|
return Promise.resolve(undefined);
|
|
41
42
|
},
|
|
42
43
|
getGlobalDatasource: (selector)=>{
|
|
43
44
|
if (selector.kind === 'PrometheusDatasource') {
|
|
44
|
-
return Promise.resolve(
|
|
45
|
-
resource: prometheusDemo,
|
|
46
|
-
proxyUrl: prometheusDemoUrl
|
|
47
|
-
});
|
|
45
|
+
return Promise.resolve(prometheusDemo);
|
|
48
46
|
}
|
|
49
47
|
return Promise.resolve(undefined);
|
|
50
48
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/test/datasource-provider.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 { GlobalDatasource } from '@perses-dev/core';\nimport { DatasourceStoreProviderProps } from '../context';\nimport { getTestDashboard } from './dashboard-provider';\n\nexport const prometheusDemoUrl = 'https://prometheus.demo.do.prometheus.io';\nexport const prometheusDemo: GlobalDatasource = {\n kind: 'GlobalDatasource',\n metadata: {\n name: 'PrometheusDemo',\n
|
|
1
|
+
{"version":3,"sources":["../../src/test/datasource-provider.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 { GlobalDatasource } from '@perses-dev/core';\nimport { DatasourceStoreProviderProps } from '../context';\nimport { getTestDashboard } from './dashboard-provider';\n\nexport const prometheusDemoUrl = 'https://prometheus.demo.do.prometheus.io';\nexport const prometheusDemo: GlobalDatasource = {\n kind: 'GlobalDatasource',\n metadata: {\n name: 'PrometheusDemo',\n createdAt: '0001-01-01T00:00:00Z',\n updatedAt: '0001-01-01T00:00:00Z',\n version: 0,\n },\n spec: {\n default: true,\n plugin: {\n kind: 'PrometheusDatasource',\n spec: { directUrl: prometheusDemoUrl },\n },\n },\n} as const;\n\n// This default currently defines the bare minimum to get a story working in\n// the `Dashboard` storybook with the Prometheus demo api. We'll likely want\n// to expand it to do more in the future.\nexport const defaultDatasourceProps: Pick<DatasourceStoreProviderProps, 'datasourceApi' | 'dashboardResource'> = {\n dashboardResource: getTestDashboard(),\n datasourceApi: {\n buildProxyUrl: () => '',\n getDatasource: () => {\n return Promise.resolve(undefined);\n },\n getGlobalDatasource: (selector) => {\n if (selector.kind === 'PrometheusDatasource') {\n return Promise.resolve(prometheusDemo);\n }\n\n return Promise.resolve(undefined);\n },\n listDatasources: () => {\n return Promise.resolve([]);\n },\n listGlobalDatasources: () => {\n return Promise.resolve([]);\n },\n },\n};\n"],"names":["getTestDashboard","prometheusDemoUrl","prometheusDemo","kind","metadata","name","createdAt","updatedAt","version","spec","default","plugin","directUrl","defaultDatasourceProps","dashboardResource","datasourceApi","buildProxyUrl","getDatasource","Promise","resolve","undefined","getGlobalDatasource","selector","listDatasources","listGlobalDatasources"],"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;AAIjC,SAASA,gBAAgB,QAAQ,uBAAuB;AAExD,OAAO,MAAMC,oBAAoB,2CAA2C;AAC5E,OAAO,MAAMC,iBAAmC;IAC9CC,MAAM;IACNC,UAAU;QACRC,MAAM;QACNC,WAAW;QACXC,WAAW;QACXC,SAAS;IACX;IACAC,MAAM;QACJC,SAAS;QACTC,QAAQ;YACNR,MAAM;YACNM,MAAM;gBAAEG,WAAWX;YAAkB;QACvC;IACF;AACF,EAAW;AAEX,4EAA4E;AAC5E,4EAA4E;AAC5E,yCAAyC;AACzC,OAAO,MAAMY,yBAAoG;IAC/GC,mBAAmBd;IACnBe,eAAe;QACbC,eAAe,IAAM;QACrBC,eAAe;YACb,OAAOC,QAAQC,QAAQC;QACzB;QACAC,qBAAqB,CAACC;YACpB,IAAIA,SAASnB,SAAS,wBAAwB;gBAC5C,OAAOe,QAAQC,QAAQjB;YACzB;YAEA,OAAOgB,QAAQC,QAAQC;QACzB;QACAG,iBAAiB;YACf,OAAOL,QAAQC,QAAQ,EAAE;QAC3B;QACAK,uBAAuB;YACrB,OAAON,QAAQC,QAAQ,EAAE;QAC3B;IACF;AACF,EAAE"}
|
package/dist/test/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/test/index.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\nexport * from './dashboard-provider';\nexport * from './datasource-provider';\nexport * from './plugin-registry';\nexport * from './render';\n"],"names":[],"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,cAAc,
|
|
1
|
+
{"version":3,"sources":["../../src/test/index.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\nexport * from './dashboard-provider';\nexport * from './datasource-provider';\nexport * from './plugin-registry';\nexport * from './render';\n"],"names":[],"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,cAAc,uBAAuB;AACrC,cAAc,wBAAwB;AACtC,cAAc,oBAAoB;AAClC,cAAc,WAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/test/plugin-registry.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 { UnknownSpec } from '@perses-dev/core';\nimport { PanelPlugin, MockPlugin } from '@perses-dev/plugin-system';\n\nconst FakeTimeSeriesChartOptionEditor = () => {\n return <div>TimeSeriesChart options</div>;\n};\n\nconst FakeTimeSeriesPlugin: PanelPlugin<UnknownSpec> = {\n PanelComponent: () => {\n return <div>TimeSeriesChart panel</div>;\n },\n panelOptionsEditorComponents: [\n {\n label: 'Settings',\n content: FakeTimeSeriesChartOptionEditor,\n },\n ],\n createInitialOptions: () => ({}),\n};\n\nconst MOCK_TIME_SERIES_PANEL: MockPlugin = {\n pluginType: 'Panel',\n kind: 'TimeSeriesChart',\n plugin: FakeTimeSeriesPlugin,\n};\n\n// Array of default mock plugins added to the PluginRegistry during test renders\nexport const MOCK_PLUGINS: MockPlugin[] = [MOCK_TIME_SERIES_PANEL];\n"],"names":["FakeTimeSeriesChartOptionEditor","div","FakeTimeSeriesPlugin","PanelComponent","panelOptionsEditorComponents","label","content","createInitialOptions","MOCK_TIME_SERIES_PANEL","pluginType","kind","plugin","MOCK_PLUGINS"],"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
|
|
1
|
+
{"version":3,"sources":["../../src/test/plugin-registry.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 { UnknownSpec } from '@perses-dev/core';\nimport { PanelPlugin, MockPlugin } from '@perses-dev/plugin-system';\n\nconst FakeTimeSeriesChartOptionEditor = () => {\n return <div>TimeSeriesChart options</div>;\n};\n\nconst FakeTimeSeriesPlugin: PanelPlugin<UnknownSpec> = {\n PanelComponent: () => {\n return <div>TimeSeriesChart panel</div>;\n },\n panelOptionsEditorComponents: [\n {\n label: 'Settings',\n content: FakeTimeSeriesChartOptionEditor,\n },\n ],\n createInitialOptions: () => ({}),\n};\n\nconst MOCK_TIME_SERIES_PANEL: MockPlugin = {\n pluginType: 'Panel',\n kind: 'TimeSeriesChart',\n plugin: FakeTimeSeriesPlugin,\n};\n\n// Array of default mock plugins added to the PluginRegistry during test renders\nexport const MOCK_PLUGINS: MockPlugin[] = [MOCK_TIME_SERIES_PANEL];\n"],"names":["FakeTimeSeriesChartOptionEditor","div","FakeTimeSeriesPlugin","PanelComponent","panelOptionsEditorComponents","label","content","createInitialOptions","MOCK_TIME_SERIES_PANEL","pluginType","kind","plugin","MOCK_PLUGINS"],"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;;AAKjC,MAAMA,kCAAkC;IACtC,qBAAO,KAACC;kBAAI;;AACd;AAEA,MAAMC,uBAAiD;IACrDC,gBAAgB;QACd,qBAAO,KAACF;sBAAI;;IACd;IACAG,8BAA8B;QAC5B;YACEC,OAAO;YACPC,SAASN;QACX;KACD;IACDO,sBAAsB,IAAO,CAAA,CAAC,CAAA;AAChC;AAEA,MAAMC,yBAAqC;IACzCC,YAAY;IACZC,MAAM;IACNC,QAAQT;AACV;AAEA,gFAAgF;AAChF,OAAO,MAAMU,eAA6B;IAACJ;CAAuB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/test/render.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAU,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE/D,OAAO,EAAuB,aAAa,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/test/render.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAU,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE/D,OAAO,EAAuB,aAAa,EAAE,MAAM,SAAS,CAAC;AAkC7D;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,KAAK,CAAC,YAAY,EACtB,OAAO,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,EACxC,OAAO,CAAC,EAAE,aAAa,gIAwBxB"}
|
package/dist/test/render.js
CHANGED
|
@@ -18,8 +18,10 @@ import { createMemoryHistory } from 'history';
|
|
|
18
18
|
import { QueryParamProvider } from 'use-query-params';
|
|
19
19
|
import { ReactRouter6Adapter } from 'use-query-params/adapters/react-router-6';
|
|
20
20
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
21
|
-
import {
|
|
21
|
+
import { ChartsProvider, SnackbarProvider, testChartsTheme } from '@perses-dev/components';
|
|
22
22
|
import { mockPluginRegistry, PluginRegistry } from '@perses-dev/plugin-system';
|
|
23
|
+
import { DatasourceStoreProvider } from '../context';
|
|
24
|
+
import { defaultDatasourceProps } from '../test';
|
|
23
25
|
import { MOCK_PLUGINS } from './plugin-registry';
|
|
24
26
|
/*
|
|
25
27
|
* Workaround for React router upgrade type errors.
|
|
@@ -63,11 +65,14 @@ import { MOCK_PLUGINS } from './plugin-registry';
|
|
|
63
65
|
vertical: 'bottom',
|
|
64
66
|
horizontal: 'right'
|
|
65
67
|
},
|
|
66
|
-
children: /*#__PURE__*/ _jsx(
|
|
68
|
+
children: /*#__PURE__*/ _jsx(ChartsProvider, {
|
|
67
69
|
chartsTheme: testChartsTheme,
|
|
68
70
|
children: /*#__PURE__*/ _jsx(PluginRegistry, {
|
|
69
71
|
...mockPluginRegistry(...MOCK_PLUGINS),
|
|
70
|
-
children:
|
|
72
|
+
children: /*#__PURE__*/ _jsx(DatasourceStoreProvider, {
|
|
73
|
+
...defaultDatasourceProps,
|
|
74
|
+
children: ui
|
|
75
|
+
})
|
|
71
76
|
})
|
|
72
77
|
})
|
|
73
78
|
})
|
package/dist/test/render.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/test/render.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 { useLayoutEffect, useState } from 'react';\nimport { render, RenderOptions } from '@testing-library/react';\nimport { Router } from 'react-router-dom';\nimport { createMemoryHistory, MemoryHistory } from 'history';\nimport { QueryParamProvider } from 'use-query-params';\nimport { ReactRouter6Adapter } from 'use-query-params/adapters/react-router-6';\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/test/render.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 { useLayoutEffect, useState } from 'react';\nimport { render, RenderOptions } from '@testing-library/react';\nimport { Router } from 'react-router-dom';\nimport { createMemoryHistory, MemoryHistory } from 'history';\nimport { QueryParamProvider } from 'use-query-params';\nimport { ReactRouter6Adapter } from 'use-query-params/adapters/react-router-6';\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport { ChartsProvider, SnackbarProvider, testChartsTheme } from '@perses-dev/components';\nimport { mockPluginRegistry, PluginRegistry } from '@perses-dev/plugin-system';\nimport { DatasourceStoreProvider } from '../context';\nimport { defaultDatasourceProps } from '../test';\nimport { MOCK_PLUGINS } from './plugin-registry';\n\ninterface CustomRouterProps {\n history: MemoryHistory;\n children: React.ReactNode;\n}\n\n/*\n * Workaround for React router upgrade type errors.\n * More details: https://stackoverflow.com/a/69948457/17575201\n */\nconst CustomRouter: React.FC<CustomRouterProps> = ({ history, children }) => {\n const [state, setState] = useState({\n action: history.action,\n location: history.location,\n });\n\n useLayoutEffect(() => history.listen(setState), [history]);\n\n return (\n <Router location={state.location} navigationType={state.action} navigator={history}>\n {children}\n </Router>\n );\n};\n\n/**\n * Test helper to render a React component with some common app-level providers wrapped around it.\n */\nexport function renderWithContext(\n ui: React.ReactElement,\n options?: Omit<RenderOptions, 'queries'>,\n history?: MemoryHistory\n) {\n // Create a new QueryClient for each test to avoid caching issues\n const queryClient = new QueryClient({ defaultOptions: { queries: { refetchOnWindowFocus: false, retry: false } } });\n\n const customHistory = history ?? createMemoryHistory();\n\n const BaseRender = () => (\n <CustomRouter history={customHistory}>\n <QueryClientProvider client={queryClient}>\n <QueryParamProvider adapter={ReactRouter6Adapter}>\n <SnackbarProvider anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}>\n <ChartsProvider chartsTheme={testChartsTheme}>\n <PluginRegistry {...mockPluginRegistry(...MOCK_PLUGINS)}>\n <DatasourceStoreProvider {...defaultDatasourceProps}>{ui}</DatasourceStoreProvider>\n </PluginRegistry>\n </ChartsProvider>\n </SnackbarProvider>\n </QueryParamProvider>\n </QueryClientProvider>\n </CustomRouter>\n );\n\n return render(<BaseRender />, options);\n}\n"],"names":["useLayoutEffect","useState","render","Router","createMemoryHistory","QueryParamProvider","ReactRouter6Adapter","QueryClient","QueryClientProvider","ChartsProvider","SnackbarProvider","testChartsTheme","mockPluginRegistry","PluginRegistry","DatasourceStoreProvider","defaultDatasourceProps","MOCK_PLUGINS","CustomRouter","history","children","state","setState","action","location","listen","navigationType","navigator","renderWithContext","ui","options","queryClient","defaultOptions","queries","refetchOnWindowFocus","retry","customHistory","BaseRender","client","adapter","anchorOrigin","vertical","horizontal","chartsTheme"],"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,SAASA,eAAe,EAAEC,QAAQ,QAAQ,QAAQ;AAClD,SAASC,MAAM,QAAuB,yBAAyB;AAC/D,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,mBAAmB,QAAuB,UAAU;AAC7D,SAASC,kBAAkB,QAAQ,mBAAmB;AACtD,SAASC,mBAAmB,QAAQ,2CAA2C;AAC/E,SAASC,WAAW,EAAEC,mBAAmB,QAAQ,wBAAwB;AACzE,SAASC,cAAc,EAAEC,gBAAgB,EAAEC,eAAe,QAAQ,yBAAyB;AAC3F,SAASC,kBAAkB,EAAEC,cAAc,QAAQ,4BAA4B;AAC/E,SAASC,uBAAuB,QAAQ,aAAa;AACrD,SAASC,sBAAsB,QAAQ,UAAU;AACjD,SAASC,YAAY,QAAQ,oBAAoB;AAOjD;;;CAGC,GACD,MAAMC,eAA4C,CAAC,EAAEC,QAAO,EAAEC,SAAQ,EAAE;IACtE,MAAM,CAACC,OAAOC,SAAS,GAAGpB,SAAS;QACjCqB,QAAQJ,QAAQI;QAChBC,UAAUL,QAAQK;IACpB;IAEAvB,gBAAgB,IAAMkB,QAAQM,OAAOH,WAAW;QAACH;KAAQ;IAEzD,qBACE,KAACf;QAAOoB,UAAUH,MAAMG;QAAUE,gBAAgBL,MAAME;QAAQI,WAAWR;kBACxEC;;AAGP;AAEA;;CAEC,GACD,OAAO,SAASQ,kBACdC,EAAsB,EACtBC,OAAwC,EACxCX,OAAuB;IAEvB,iEAAiE;IACjE,MAAMY,cAAc,IAAIvB,YAAY;QAAEwB,gBAAgB;YAAEC,SAAS;gBAAEC,sBAAsB;gBAAOC,OAAO;YAAM;QAAE;IAAE;IAEjH,MAAMC,gBAAgBjB,oBAAAA,qBAAAA,UAAWd;IAEjC,MAAMgC,aAAa,kBACjB,KAACnB;YAAaC,SAASiB;sBACrB,cAAA,KAAC3B;gBAAoB6B,QAAQP;0BAC3B,cAAA,KAACzB;oBAAmBiC,SAAShC;8BAC3B,cAAA,KAACI;wBAAiB6B,cAAc;4BAAEC,UAAU;4BAAUC,YAAY;wBAAQ;kCACxE,cAAA,KAAChC;4BAAeiC,aAAa/B;sCAC3B,cAAA,KAACE;gCAAgB,GAAGD,sBAAsBI,aAAa;0CACrD,cAAA,KAACF;oCAAyB,GAAGC,sBAAsB;8CAAGa;;;;;;;;IASpE,OAAO1B,qBAAO,KAACkC,iBAAeP;AAChC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/test/setup-tests.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 { defaultFallbackInView } from 'react-intersection-observer';\n\n// Add testing library assertions\nimport '@testing-library/jest-dom/extend-expect';\n\n// Always mock e-charts during tests since we don't have a proper canvas in jsdom\njest.mock('echarts/core');\n\n// Tell react-intersection-observer that everything should be considered in-view for tests (see package documentation\n// for other options)\ndefaultFallbackInView(true);\n"],"names":["defaultFallbackInView","jest","mock"],"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,SAASA,qBAAqB,QAAQ,
|
|
1
|
+
{"version":3,"sources":["../../src/test/setup-tests.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 { defaultFallbackInView } from 'react-intersection-observer';\n\n// Add testing library assertions\nimport '@testing-library/jest-dom/extend-expect';\n\n// Always mock e-charts during tests since we don't have a proper canvas in jsdom\njest.mock('echarts/core');\n\n// Tell react-intersection-observer that everything should be considered in-view for tests (see package documentation\n// for other options)\ndefaultFallbackInView(true);\n"],"names":["defaultFallbackInView","jest","mock"],"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,SAASA,qBAAqB,QAAQ,8BAA8B;AAEpE,iCAAiC;AACjC,OAAO,0CAA0C;AAEjD,iFAAiF;AACjFC,KAAKC,KAAK;AAEV,qHAAqH;AACrH,qBAAqB;AACrBF,sBAAsB"}
|