@perses-dev/dashboards 0.0.0-snapshot-panel-extra-content-3-17f9c42 → 0.0.0-snapshot-scatterplot-fix-imports-95e1b59
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 +11 -8
- package/dist/cjs/components/AddGroupButton/index.js +10 -8
- package/dist/cjs/components/AddPanelButton/AddPanelButton.js +12 -13
- package/dist/cjs/components/AddPanelButton/index.js +10 -8
- package/dist/cjs/components/Dashboard/Dashboard.js +12 -10
- package/dist/cjs/components/Dashboard/index.js +10 -8
- package/dist/cjs/components/DashboardStickyToolbar/DashboardStickyToolbar.js +53 -22
- package/dist/cjs/components/DashboardStickyToolbar/index.js +10 -8
- package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +82 -103
- package/dist/cjs/components/DashboardToolbar/index.js +10 -8
- package/dist/cjs/components/Datasources/DatasourceEditor.js +236 -0
- package/dist/cjs/components/Datasources/EditDatasourcesButton.js +112 -0
- package/dist/cjs/components/{ToolbarIconButton → Datasources}/index.js +11 -8
- package/dist/cjs/components/DeletePanelDialog/DeletePanelDialog.js +16 -14
- package/dist/cjs/components/DeletePanelDialog/index.js +10 -8
- package/dist/cjs/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +18 -16
- package/dist/cjs/components/DeletePanelGroupDialog/index.js +10 -8
- package/dist/cjs/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js +6 -4
- package/dist/cjs/components/DiscardChangesConfirmationDialog/index.js +10 -8
- package/dist/cjs/components/DownloadButton/DownloadButton.js +13 -12
- package/dist/cjs/components/DownloadButton/index.js +10 -8
- package/dist/cjs/components/EditButton/EditButton.js +9 -7
- package/dist/cjs/components/EditButton/index.js +10 -8
- package/dist/cjs/components/EditJsonButton/EditJsonButton.js +15 -12
- package/dist/cjs/components/EditJsonButton/index.js +10 -8
- package/dist/cjs/components/EditJsonDialog/EditJsonDialog.js +54 -25
- package/dist/cjs/components/EditJsonDialog/index.js +10 -8
- package/dist/cjs/components/EmptyDashboard/EmptyDashboard.js +21 -19
- package/dist/cjs/components/EmptyDashboard/index.js +10 -8
- package/dist/cjs/components/GridLayout/GridContainer.js +6 -4
- package/dist/cjs/components/GridLayout/GridItemContent.js +37 -19
- package/dist/cjs/components/GridLayout/GridLayout.js +21 -19
- package/dist/cjs/components/GridLayout/GridTitle.js +40 -39
- package/dist/cjs/components/GridLayout/index.js +13 -11
- package/dist/cjs/components/Panel/Panel.js +19 -23
- package/dist/cjs/components/Panel/PanelContent.js +11 -8
- package/dist/cjs/components/Panel/PanelHeader.js +35 -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 +237 -144
- package/dist/cjs/components/PanelDrawer/PanelPreview.js +13 -12
- package/dist/cjs/components/PanelDrawer/index.js +11 -8
- package/dist/cjs/components/PanelDrawer/usePanelEditor.js +5 -3
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +18 -16
- package/dist/cjs/components/PanelGroupDialog/PanelGroupEditorForm.js +16 -12
- package/dist/cjs/components/PanelGroupDialog/index.js +10 -8
- package/dist/cjs/components/QuerySummaryTable/QuerySummaryTable.js +48 -46
- package/dist/cjs/components/QuerySummaryTable/index.js +10 -8
- package/dist/cjs/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +26 -24
- package/dist/cjs/components/SaveChangesConfirmationDialog/index.js +10 -8
- package/dist/cjs/components/SaveDashboardButton/SaveDashboardButton.js +14 -14
- package/dist/cjs/components/SaveDashboardButton/index.js +10 -8
- package/dist/cjs/components/Variables/BuiltinVariableAccordions.js +141 -0
- package/dist/cjs/components/Variables/EditVariablesButton.js +19 -17
- package/dist/cjs/components/Variables/TemplateVariable.js +261 -107
- package/dist/cjs/components/Variables/VariableEditor.js +282 -207
- package/dist/cjs/components/Variables/VariableList.js +24 -22
- package/dist/cjs/components/Variables/index.js +14 -11
- package/dist/cjs/components/index.js +30 -29
- package/dist/cjs/constants/grid-layout-config.js +6 -2
- package/dist/cjs/constants/index.js +12 -9
- package/dist/cjs/constants/styles.js +42 -0
- package/dist/cjs/constants/user-interface-text.js +8 -3
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +48 -35
- package/dist/cjs/context/DashboardProvider/common.js +6 -2
- package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +81 -49
- package/dist/cjs/context/DashboardProvider/delete-panel-group-slice.js +4 -2
- package/dist/cjs/context/DashboardProvider/delete-panel-slice.js +8 -6
- package/dist/cjs/context/DashboardProvider/discard-changes-dialog-slice.js +3 -1
- package/dist/cjs/context/DashboardProvider/duplicate-panel-slice.js +4 -2
- 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 +17 -17
- package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +8 -6
- package/dist/cjs/context/DashboardProvider/panel-group-slice.js +16 -8
- 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 +177 -50
- package/dist/cjs/context/TemplateVariableProvider/TemplateVariableProvider.js +150 -39
- package/dist/cjs/context/TemplateVariableProvider/hydrationUtils.js +12 -10
- 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 +15 -7
- package/dist/cjs/context/index.js +13 -11
- package/dist/cjs/context/useDashboard.js +30 -11
- 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 +28 -21
- package/dist/cjs/test/setup-tests.js +2 -2
- package/dist/cjs/test/testDashboard.js +13 -11
- package/dist/cjs/utils/index.js +10 -9
- package/dist/cjs/utils/panelUtils.js +11 -5
- package/dist/cjs/{components/TimeRangeControls → validation}/index.js +10 -8
- package/dist/cjs/{utils/time.js → validation/panel.js} +11 -9
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +32 -18
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +64 -21
- package/dist/cjs/views/ViewDashboard/index.js +10 -8
- package/dist/cjs/views/index.js +10 -8
- package/dist/components/AddGroupButton/AddGroupButton.d.ts +1 -2
- package/dist/components/AddGroupButton/AddGroupButton.d.ts.map +1 -1
- package/dist/components/AddGroupButton/AddGroupButton.js +3 -2
- package/dist/components/AddGroupButton/AddGroupButton.js.map +1 -1
- package/dist/components/AddGroupButton/index.js.map +1 -1
- package/dist/components/AddPanelButton/AddPanelButton.d.ts +1 -2
- package/dist/components/AddPanelButton/AddPanelButton.d.ts.map +1 -1
- package/dist/components/AddPanelButton/AddPanelButton.js +4 -7
- 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 +2 -3
- package/dist/components/Dashboard/Dashboard.d.ts.map +1 -1
- package/dist/components/Dashboard/Dashboard.js +1 -1
- package/dist/components/Dashboard/Dashboard.js.map +1 -1
- package/dist/components/Dashboard/index.js.map +1 -1
- package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.d.ts +1 -2
- package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.d.ts.map +1 -1
- package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js +38 -9
- package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js.map +1 -1
- package/dist/components/DashboardStickyToolbar/index.js.map +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.js +63 -86
- package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
- package/dist/components/DashboardToolbar/index.js.map +1 -1
- package/dist/components/Datasources/DatasourceEditor.d.ts +7 -0
- package/dist/components/Datasources/DatasourceEditor.d.ts.map +1 -0
- package/dist/components/Datasources/DatasourceEditor.js +223 -0
- package/dist/components/Datasources/DatasourceEditor.js.map +1 -0
- package/dist/components/Datasources/EditDatasourcesButton.d.ts +2 -0
- package/dist/components/Datasources/EditDatasourcesButton.d.ts.map +1 -0
- package/dist/components/Datasources/EditDatasourcesButton.js +99 -0
- package/dist/components/Datasources/EditDatasourcesButton.js.map +1 -0
- package/dist/components/Datasources/index.d.ts +3 -0
- package/dist/components/Datasources/index.d.ts.map +1 -0
- package/dist/components/{TimeRangeControls → Datasources}/index.js +2 -1
- package/dist/components/Datasources/index.js.map +1 -0
- package/dist/components/DeletePanelDialog/DeletePanelDialog.d.ts +1 -2
- package/dist/components/DeletePanelDialog/DeletePanelDialog.d.ts.map +1 -1
- package/dist/components/DeletePanelDialog/DeletePanelDialog.js +4 -4
- package/dist/components/DeletePanelDialog/DeletePanelDialog.js.map +1 -1
- package/dist/components/DeletePanelDialog/index.js.map +1 -1
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.d.ts +1 -2
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -1
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +3 -3
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js.map +1 -1
- package/dist/components/DeletePanelGroupDialog/index.js.map +1 -1
- package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.d.ts +1 -2
- package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.d.ts.map +1 -1
- package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js +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.d.ts +1 -2
- package/dist/components/DownloadButton/DownloadButton.d.ts.map +1 -1
- package/dist/components/DownloadButton/DownloadButton.js +3 -4
- package/dist/components/DownloadButton/DownloadButton.js.map +1 -1
- package/dist/components/DownloadButton/index.js.map +1 -1
- package/dist/components/EditButton/EditButton.d.ts +1 -2
- package/dist/components/EditButton/EditButton.d.ts.map +1 -1
- package/dist/components/EditButton/EditButton.js +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.d.ts +4 -2
- package/dist/components/EditJsonButton/EditJsonButton.d.ts.map +1 -1
- package/dist/components/EditJsonButton/EditJsonButton.js +7 -6
- 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 +5 -2
- package/dist/components/EditJsonDialog/EditJsonDialog.d.ts.map +1 -1
- package/dist/components/EditJsonDialog/EditJsonDialog.js +43 -16
- package/dist/components/EditJsonDialog/EditJsonDialog.js.map +1 -1
- package/dist/components/EditJsonDialog/index.js.map +1 -1
- package/dist/components/EmptyDashboard/EmptyDashboard.d.ts +1 -1
- package/dist/components/EmptyDashboard/EmptyDashboard.d.ts.map +1 -1
- package/dist/components/EmptyDashboard/EmptyDashboard.js +3 -3
- package/dist/components/EmptyDashboard/EmptyDashboard.js.map +1 -1
- package/dist/components/EmptyDashboard/index.js.map +1 -1
- package/dist/components/GridLayout/GridContainer.d.ts +1 -1
- package/dist/components/GridLayout/GridContainer.d.ts.map +1 -1
- package/dist/components/GridLayout/GridContainer.js +1 -1
- package/dist/components/GridLayout/GridContainer.js.map +1 -1
- package/dist/components/GridLayout/GridItemContent.d.ts +1 -2
- package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
- package/dist/components/GridLayout/GridItemContent.js +31 -15
- package/dist/components/GridLayout/GridItemContent.js.map +1 -1
- package/dist/components/GridLayout/GridLayout.d.ts +1 -2
- package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
- package/dist/components/GridLayout/GridLayout.js +6 -6
- package/dist/components/GridLayout/GridLayout.js.map +1 -1
- package/dist/components/GridLayout/GridTitle.d.ts +1 -2
- package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
- package/dist/components/GridLayout/GridTitle.js +5 -6
- 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 +2 -2
- package/dist/components/Panel/Panel.d.ts.map +1 -1
- package/dist/components/Panel/Panel.js +7 -13
- package/dist/components/Panel/Panel.js.map +1 -1
- package/dist/components/Panel/PanelContent.d.ts +3 -3
- package/dist/components/Panel/PanelContent.d.ts.map +1 -1
- package/dist/components/Panel/PanelContent.js +4 -3
- package/dist/components/Panel/PanelContent.js.map +1 -1
- package/dist/components/Panel/PanelHeader.d.ts +2 -2
- package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
- package/dist/components/Panel/PanelHeader.js +2 -2
- 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 +1 -2
- 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 +5 -3
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.js +231 -142
- package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.d.ts +1 -2
- package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.js +4 -5
- package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
- package/dist/components/PanelDrawer/index.d.ts +1 -0
- package/dist/components/PanelDrawer/index.d.ts.map +1 -1
- package/dist/components/PanelDrawer/index.js +1 -0
- package/dist/components/PanelDrawer/index.js.map +1 -1
- package/dist/components/PanelDrawer/usePanelEditor.js +2 -2
- package/dist/components/PanelDrawer/usePanelEditor.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts +1 -2
- package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts +1 -2
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js +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.d.ts +1 -2
- package/dist/components/QuerySummaryTable/QuerySummaryTable.d.ts.map +1 -1
- package/dist/components/QuerySummaryTable/QuerySummaryTable.js +8 -8
- package/dist/components/QuerySummaryTable/QuerySummaryTable.js.map +1 -1
- package/dist/components/QuerySummaryTable/index.js.map +1 -1
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.d.ts +1 -2
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.d.ts.map +1 -1
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +8 -8
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +1 -1
- package/dist/components/SaveChangesConfirmationDialog/index.js.map +1 -1
- package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts +1 -2
- package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts.map +1 -1
- package/dist/components/SaveDashboardButton/SaveDashboardButton.js +8 -10
- package/dist/components/SaveDashboardButton/SaveDashboardButton.js.map +1 -1
- package/dist/components/SaveDashboardButton/index.js.map +1 -1
- package/dist/components/Variables/BuiltinVariableAccordions.d.ts +7 -0
- package/dist/components/Variables/BuiltinVariableAccordions.d.ts.map +1 -0
- package/dist/components/Variables/BuiltinVariableAccordions.js +128 -0
- package/dist/components/Variables/BuiltinVariableAccordions.js.map +1 -0
- package/dist/components/Variables/EditVariablesButton.d.ts +1 -2
- package/dist/components/Variables/EditVariablesButton.d.ts.map +1 -1
- package/dist/components/Variables/EditVariablesButton.js +7 -7
- package/dist/components/Variables/EditVariablesButton.js.map +1 -1
- package/dist/components/Variables/TemplateVariable.d.ts +12 -4
- package/dist/components/Variables/TemplateVariable.d.ts.map +1 -1
- package/dist/components/Variables/TemplateVariable.js +244 -100
- package/dist/components/Variables/TemplateVariable.js.map +1 -1
- package/dist/components/Variables/VariableEditor.d.ts +4 -4
- package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditor.js +232 -161
- package/dist/components/Variables/VariableEditor.js.map +1 -1
- package/dist/components/Variables/VariableList.d.ts +2 -3
- package/dist/components/Variables/VariableList.d.ts.map +1 -1
- package/dist/components/Variables/VariableList.js +11 -13
- 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.d.ts +1 -2
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -2
- package/dist/components/index.js.map +1 -1
- package/dist/constants/grid-layout-config.js.map +1 -1
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/constants/index.js +1 -0
- package/dist/constants/index.js.map +1 -1
- package/dist/constants/styles.d.ts +5 -0
- package/dist/constants/styles.d.ts.map +1 -0
- package/dist/{utils/time.js → constants/styles.js} +10 -10
- package/dist/constants/styles.js.map +1 -0
- package/dist/constants/user-interface-text.d.ts +2 -1
- package/dist/constants/user-interface-text.d.ts.map +1 -1
- package/dist/constants/user-interface-text.js +2 -1
- package/dist/constants/user-interface-text.js.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.d.ts +7 -4
- package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.js +16 -9
- package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
- package/dist/context/DashboardProvider/common.d.ts +3 -3
- package/dist/context/DashboardProvider/common.d.ts.map +1 -1
- package/dist/context/DashboardProvider/common.js.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.js +17 -17
- package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
- package/dist/context/DashboardProvider/delete-panel-group-slice.js +1 -1
- package/dist/context/DashboardProvider/delete-panel-group-slice.js.map +1 -1
- package/dist/context/DashboardProvider/delete-panel-slice.js +5 -5
- 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 +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 -2
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.js +11 -13
- 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.d.ts +2 -2
- package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-group-slice.js +4 -4
- 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 +17 -12
- package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
- package/dist/context/DatasourceStoreProvider.js +172 -47
- package/dist/context/DatasourceStoreProvider.js.map +1 -1
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts +15 -8
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts.map +1 -1
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js +115 -23
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js.map +1 -1
- package/dist/context/TemplateVariableProvider/hydrationUtils.d.ts.map +1 -1
- package/dist/context/TemplateVariableProvider/hydrationUtils.js +7 -7
- 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.js +3 -3
- package/dist/context/TemplateVariableProvider/utils.js.map +1 -1
- package/dist/context/index.js.map +1 -1
- package/dist/context/useDashboard.d.ts +3 -3
- package/dist/context/useDashboard.d.ts.map +1 -1
- package/dist/context/useDashboard.js +24 -7
- 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 +9 -4
- 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.d.ts +0 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +0 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/panelUtils.d.ts +1 -1
- package/dist/utils/panelUtils.d.ts.map +1 -1
- package/dist/utils/panelUtils.js +2 -2
- package/dist/utils/panelUtils.js.map +1 -1
- package/dist/validation/index.d.ts +2 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/{components/ToolbarIconButton → validation}/index.js +1 -1
- 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 +4 -3
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.js +19 -7
- package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.d.ts +2 -2
- package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.js +53 -12
- 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
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +0 -183
- package/dist/cjs/components/ToolbarIconButton/ToolbarIconButton.js +0 -38
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts +0 -14
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +0 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js +0 -165
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +0 -1
- package/dist/components/TimeRangeControls/index.d.ts +0 -2
- package/dist/components/TimeRangeControls/index.d.ts.map +0 -1
- package/dist/components/TimeRangeControls/index.js.map +0 -1
- package/dist/components/ToolbarIconButton/ToolbarIconButton.d.ts +0 -6
- package/dist/components/ToolbarIconButton/ToolbarIconButton.d.ts.map +0 -1
- package/dist/components/ToolbarIconButton/ToolbarIconButton.js +0 -32
- package/dist/components/ToolbarIconButton/ToolbarIconButton.js.map +0 -1
- package/dist/components/ToolbarIconButton/index.d.ts +0 -2
- package/dist/components/ToolbarIconButton/index.d.ts.map +0 -1
- package/dist/components/ToolbarIconButton/index.js.map +0 -1
- package/dist/utils/time.d.ts +0 -5
- package/dist/utils/time.d.ts.map +0 -1
- package/dist/utils/time.js.map +0 -1
|
@@ -16,25 +16,34 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
16
16
|
});
|
|
17
17
|
Object.defineProperty(exports, "DatasourceStoreProvider", {
|
|
18
18
|
enumerable: true,
|
|
19
|
-
get: ()
|
|
19
|
+
get: function() {
|
|
20
|
+
return DatasourceStoreProvider;
|
|
21
|
+
}
|
|
20
22
|
});
|
|
21
|
-
const
|
|
23
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
22
24
|
const _react = require("react");
|
|
23
25
|
const _core = require("@perses-dev/core");
|
|
24
|
-
const
|
|
26
|
+
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
25
27
|
function DatasourceStoreProvider(props) {
|
|
26
|
-
const {
|
|
28
|
+
const { projectName, datasourceApi, onCreate, children } = props;
|
|
29
|
+
const [dashboardResource, setDashboardResource] = (0, _react.useState)(props.dashboardResource);
|
|
30
|
+
var _props_savedDatasources;
|
|
31
|
+
const [savedDatasources, setSavedDatasources] = (0, _react.useState)((_props_savedDatasources = props.savedDatasources) !== null && _props_savedDatasources !== void 0 ? _props_savedDatasources : {});
|
|
27
32
|
const project = projectName !== null && projectName !== void 0 ? projectName : dashboardResource === null || dashboardResource === void 0 ? void 0 : dashboardResource.metadata.project;
|
|
28
|
-
const { getPlugin
|
|
33
|
+
const { getPlugin, listPluginMetadata } = (0, _pluginsystem.usePluginRegistry)();
|
|
29
34
|
const findDatasource = (0, _core.useEvent)(async (selector)=>{
|
|
30
35
|
// Try to find it in dashboard spec
|
|
31
36
|
if (dashboardResource) {
|
|
32
|
-
const { datasources
|
|
37
|
+
const { datasources } = dashboardResource.spec;
|
|
33
38
|
const dashboardDatasource = findDashboardDatasource(datasources, selector);
|
|
34
39
|
if (dashboardDatasource !== undefined) {
|
|
35
40
|
return {
|
|
36
|
-
spec: dashboardDatasource,
|
|
37
|
-
proxyUrl:
|
|
41
|
+
spec: dashboardDatasource.spec,
|
|
42
|
+
proxyUrl: buildDatasourceProxyUrl(datasourceApi, {
|
|
43
|
+
project: dashboardResource.metadata.project,
|
|
44
|
+
dashboard: dashboardResource.metadata.name,
|
|
45
|
+
name: dashboardDatasource.name
|
|
46
|
+
})
|
|
38
47
|
};
|
|
39
48
|
}
|
|
40
49
|
}
|
|
@@ -43,8 +52,11 @@ function DatasourceStoreProvider(props) {
|
|
|
43
52
|
const datasource = await datasourceApi.getDatasource(project, selector);
|
|
44
53
|
if (datasource !== undefined) {
|
|
45
54
|
return {
|
|
46
|
-
spec: datasource.
|
|
47
|
-
proxyUrl:
|
|
55
|
+
spec: datasource.spec,
|
|
56
|
+
proxyUrl: buildDatasourceProxyUrl(datasourceApi, {
|
|
57
|
+
project: datasource.metadata.project,
|
|
58
|
+
name: datasource.metadata.name
|
|
59
|
+
})
|
|
48
60
|
};
|
|
49
61
|
}
|
|
50
62
|
}
|
|
@@ -52,23 +64,25 @@ function DatasourceStoreProvider(props) {
|
|
|
52
64
|
const globalDatasource = await datasourceApi.getGlobalDatasource(selector);
|
|
53
65
|
if (globalDatasource !== undefined) {
|
|
54
66
|
return {
|
|
55
|
-
spec: globalDatasource.
|
|
56
|
-
proxyUrl:
|
|
67
|
+
spec: globalDatasource.spec,
|
|
68
|
+
proxyUrl: buildDatasourceProxyUrl(datasourceApi, {
|
|
69
|
+
name: globalDatasource.metadata.name
|
|
70
|
+
})
|
|
57
71
|
};
|
|
58
72
|
}
|
|
59
73
|
throw new Error(`No datasource found for kind '${selector.kind}' and name '${selector.name}'`);
|
|
60
74
|
});
|
|
61
75
|
// Gets a datasource spec for a given selector
|
|
62
76
|
const getDatasource = (0, _react.useCallback)(async (selector)=>{
|
|
63
|
-
const { spec
|
|
77
|
+
const { spec } = await findDatasource(selector);
|
|
64
78
|
return spec;
|
|
65
79
|
}, [
|
|
66
80
|
findDatasource
|
|
67
81
|
]);
|
|
68
82
|
// Given a Datasource selector, finds the spec for it and then uses its corresponding plugin the create a client
|
|
69
83
|
const getDatasourceClient = (0, _react.useCallback)(async function getClient(selector) {
|
|
70
|
-
const { kind
|
|
71
|
-
const [{ spec
|
|
84
|
+
const { kind } = selector;
|
|
85
|
+
const [{ spec, proxyUrl }, plugin] = await Promise.all([
|
|
72
86
|
findDatasource(selector),
|
|
73
87
|
getPlugin('Datasource', kind)
|
|
74
88
|
]);
|
|
@@ -85,53 +99,110 @@ function DatasourceStoreProvider(props) {
|
|
|
85
99
|
getPlugin,
|
|
86
100
|
onCreate
|
|
87
101
|
]);
|
|
88
|
-
const
|
|
102
|
+
const listDatasourceSelectItems = (0, _core.useEvent)(async (datasourcePluginKind)=>{
|
|
89
103
|
const [pluginMetadata, datasources, globalDatasources] = await Promise.all([
|
|
90
104
|
listPluginMetadata('Datasource'),
|
|
91
105
|
project ? datasourceApi.listDatasources(project, datasourcePluginKind) : [],
|
|
92
106
|
datasourceApi.listGlobalDatasources(datasourcePluginKind)
|
|
93
107
|
]);
|
|
94
|
-
// Find the metadata for the plugin type they asked for so we can use it for the name of the default datasource
|
|
108
|
+
// Find the metadata for the plugin type they asked for, so we can use it for the name of the default datasource
|
|
95
109
|
const datasourcePluginMetadata = pluginMetadata.find((metadata)=>metadata.kind === datasourcePluginKind);
|
|
96
110
|
if (datasourcePluginMetadata === undefined) {
|
|
97
111
|
throw new Error(`Could not find a Datasource plugin with kind '${datasourcePluginKind}'`);
|
|
98
112
|
}
|
|
99
|
-
// Get helper for
|
|
100
|
-
const { results
|
|
101
|
-
// Start with dashboard datasources
|
|
113
|
+
// Get helper for computing results properly
|
|
114
|
+
const { results, addItem } = buildDatasourceSelectItemGroups(datasourcePluginMetadata.display.name);
|
|
115
|
+
// Start with dashboard datasources with the highest precedence
|
|
102
116
|
if (dashboardResource === null || dashboardResource === void 0 ? void 0 : dashboardResource.spec.datasources) {
|
|
103
117
|
for(const selectorName in dashboardResource.spec.datasources){
|
|
104
118
|
const spec = dashboardResource.spec.datasources[selectorName];
|
|
105
119
|
if (spec === undefined || spec.plugin.kind !== datasourcePluginKind) continue;
|
|
106
|
-
|
|
120
|
+
const saved = selectorName in savedDatasources;
|
|
121
|
+
addItem({
|
|
122
|
+
spec,
|
|
123
|
+
selectorName,
|
|
124
|
+
selectorGroup: 'dashboard',
|
|
125
|
+
saved
|
|
126
|
+
});
|
|
107
127
|
}
|
|
108
128
|
}
|
|
109
129
|
// Now look at project-level datasources
|
|
110
130
|
for (const datasource of datasources){
|
|
111
|
-
const
|
|
112
|
-
|
|
131
|
+
const selectorName = datasource.metadata.name;
|
|
132
|
+
addItem({
|
|
133
|
+
spec: datasource.spec,
|
|
134
|
+
selectorName,
|
|
135
|
+
selectorGroup: 'project',
|
|
136
|
+
editLink: `/projects/${project}/datasources`
|
|
137
|
+
});
|
|
113
138
|
}
|
|
114
139
|
// And finally global datasources
|
|
115
140
|
for (const globalDatasource of globalDatasources){
|
|
116
|
-
const
|
|
117
|
-
|
|
141
|
+
const selectorName = globalDatasource.metadata.name;
|
|
142
|
+
addItem({
|
|
143
|
+
spec: globalDatasource.spec,
|
|
144
|
+
selectorName,
|
|
145
|
+
selectorGroup: 'global',
|
|
146
|
+
editLink: '/admin/datasources'
|
|
147
|
+
});
|
|
118
148
|
}
|
|
119
149
|
return results;
|
|
120
150
|
});
|
|
151
|
+
const getLocalDatasources = (0, _react.useCallback)(()=>{
|
|
152
|
+
var _dashboardResource_spec_datasources;
|
|
153
|
+
return (_dashboardResource_spec_datasources = dashboardResource === null || dashboardResource === void 0 ? void 0 : dashboardResource.spec.datasources) !== null && _dashboardResource_spec_datasources !== void 0 ? _dashboardResource_spec_datasources : {};
|
|
154
|
+
}, [
|
|
155
|
+
dashboardResource
|
|
156
|
+
]);
|
|
157
|
+
const getSavedDatasources = (0, _react.useCallback)(()=>{
|
|
158
|
+
return savedDatasources;
|
|
159
|
+
}, [
|
|
160
|
+
savedDatasources
|
|
161
|
+
]);
|
|
162
|
+
const setLocalDatasources = (0, _react.useCallback)((datasources)=>{
|
|
163
|
+
if (dashboardResource) {
|
|
164
|
+
setDashboardResource(dashboardResource.kind === 'Dashboard' ? {
|
|
165
|
+
...dashboardResource,
|
|
166
|
+
spec: {
|
|
167
|
+
...dashboardResource.spec,
|
|
168
|
+
datasources: datasources
|
|
169
|
+
}
|
|
170
|
+
} : {
|
|
171
|
+
...dashboardResource,
|
|
172
|
+
spec: {
|
|
173
|
+
...dashboardResource.spec,
|
|
174
|
+
datasources: datasources
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}, [
|
|
179
|
+
dashboardResource
|
|
180
|
+
]);
|
|
121
181
|
const ctxValue = (0, _react.useMemo)(()=>({
|
|
122
182
|
getDatasource,
|
|
123
183
|
getDatasourceClient,
|
|
124
|
-
|
|
184
|
+
getLocalDatasources,
|
|
185
|
+
setLocalDatasources,
|
|
186
|
+
setSavedDatasources,
|
|
187
|
+
getSavedDatasources,
|
|
188
|
+
listDatasourceSelectItems
|
|
125
189
|
}), [
|
|
126
190
|
getDatasource,
|
|
127
191
|
getDatasourceClient,
|
|
128
|
-
|
|
192
|
+
getLocalDatasources,
|
|
193
|
+
setLocalDatasources,
|
|
194
|
+
listDatasourceSelectItems,
|
|
195
|
+
setSavedDatasources,
|
|
196
|
+
getSavedDatasources
|
|
129
197
|
]);
|
|
130
|
-
return /*#__PURE__*/ (0,
|
|
198
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.DatasourceStoreContext.Provider, {
|
|
131
199
|
value: ctxValue,
|
|
132
200
|
children: children
|
|
133
201
|
});
|
|
134
202
|
}
|
|
203
|
+
function buildDatasourceProxyUrl(api, params) {
|
|
204
|
+
return api.buildProxyUrl ? api.buildProxyUrl(params) : '';
|
|
205
|
+
}
|
|
135
206
|
// Helper to find a datasource in the list embedded in a dashboard spec
|
|
136
207
|
function findDashboardDatasource(dashboardDatasources, selector) {
|
|
137
208
|
if (dashboardDatasources === undefined) return undefined;
|
|
@@ -139,42 +210,98 @@ function findDashboardDatasource(dashboardDatasources, selector) {
|
|
|
139
210
|
if (selector.name !== undefined) {
|
|
140
211
|
const named = dashboardDatasources[selector.name];
|
|
141
212
|
if (named === undefined) return undefined;
|
|
142
|
-
return named.plugin.kind === selector.kind ?
|
|
213
|
+
return named.plugin.kind === selector.kind ? {
|
|
214
|
+
name: selector.name,
|
|
215
|
+
spec: named
|
|
216
|
+
} : undefined;
|
|
143
217
|
}
|
|
144
218
|
// If only using a kind, try to find one with that kind that is the default
|
|
145
|
-
|
|
219
|
+
const result = Object.entries(dashboardDatasources).find((entry)=>entry[1].plugin.kind === selector.kind && entry[1].default);
|
|
220
|
+
if (!result) {
|
|
221
|
+
return undefined;
|
|
222
|
+
}
|
|
223
|
+
return {
|
|
224
|
+
name: result[0],
|
|
225
|
+
spec: result[1]
|
|
226
|
+
};
|
|
146
227
|
}
|
|
147
|
-
|
|
148
|
-
|
|
228
|
+
/**
|
|
229
|
+
* Helper for building a list of DatasourceSelectItemGroup results.
|
|
230
|
+
* @param pluginDisplayName
|
|
231
|
+
*/ function buildDatasourceSelectItemGroups(pluginDisplayName) {
|
|
149
232
|
const results = [];
|
|
150
233
|
const usedNames = new Set();
|
|
151
|
-
let
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
234
|
+
let isFirst = true;
|
|
235
|
+
let explicitDefaultAdded = false;
|
|
236
|
+
const groupIndices = {};
|
|
237
|
+
let currentGroupIndex = 1; // 0 is the default group, always there as it contains at least the first item.
|
|
238
|
+
const addItem = ({ spec, selectorName, selectorGroup: group, editLink, saved })=>{
|
|
239
|
+
var _spec_display;
|
|
240
|
+
group = group !== null && group !== void 0 ? group : '';
|
|
241
|
+
// Ensure the default group is always present as soon as an item is added.
|
|
242
|
+
if (isFirst) {
|
|
243
|
+
results.push({
|
|
244
|
+
group: `Default ${pluginDisplayName}`,
|
|
245
|
+
items: []
|
|
161
246
|
});
|
|
162
|
-
defaultAdded = true;
|
|
163
247
|
}
|
|
164
|
-
|
|
165
|
-
if
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
248
|
+
var _groupIndices_group;
|
|
249
|
+
// Create the group if necessary
|
|
250
|
+
let selectItemGroup = results[(_groupIndices_group = groupIndices[group]) !== null && _groupIndices_group !== void 0 ? _groupIndices_group : -1];
|
|
251
|
+
if (!selectItemGroup) {
|
|
252
|
+
groupIndices[group] = currentGroupIndex;
|
|
253
|
+
selectItemGroup = {
|
|
254
|
+
items: [],
|
|
255
|
+
group,
|
|
256
|
+
editLink
|
|
257
|
+
};
|
|
258
|
+
results[currentGroupIndex] = selectItemGroup;
|
|
259
|
+
currentGroupIndex++;
|
|
260
|
+
}
|
|
261
|
+
// Add item to the group
|
|
262
|
+
const isOverridden = usedNames.has(selectorName);
|
|
263
|
+
var _spec_display_name;
|
|
264
|
+
selectItemGroup.items.push({
|
|
265
|
+
name: (_spec_display_name = (_spec_display = spec.display) === null || _spec_display === void 0 ? void 0 : _spec_display.name) !== null && _spec_display_name !== void 0 ? _spec_display_name : selectorName,
|
|
266
|
+
overridden: isOverridden,
|
|
267
|
+
saved,
|
|
169
268
|
selector: {
|
|
170
269
|
kind: spec.plugin.kind,
|
|
171
|
-
name: selectorName
|
|
270
|
+
name: selectorName,
|
|
271
|
+
group
|
|
172
272
|
}
|
|
173
273
|
});
|
|
174
274
|
usedNames.add(selectorName);
|
|
275
|
+
const isExplicitDefault = !isOverridden && spec.default && !explicitDefaultAdded;
|
|
276
|
+
if (results[0] && (isFirst || isExplicitDefault)) {
|
|
277
|
+
// If we haven't added a default yet and this is a default, add default option to the beginning of the results
|
|
278
|
+
results[0].items = [
|
|
279
|
+
{
|
|
280
|
+
name: `Default (${selectorName} from ${group})`,
|
|
281
|
+
selector: {
|
|
282
|
+
kind: spec.plugin.kind
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
];
|
|
286
|
+
// We consider that we added the default datasource only if it has been explicitly set as default.
|
|
287
|
+
// If we add this datasource as default just because it's the first, it still needs to be overridable by
|
|
288
|
+
// another datasource explicitly set as default.
|
|
289
|
+
explicitDefaultAdded = isExplicitDefault;
|
|
290
|
+
}
|
|
291
|
+
// At the end, we make sure the overriding item(s) is well flagged so
|
|
292
|
+
if (isOverridden) {
|
|
293
|
+
for(let i = explicitDefaultAdded ? 1 : 0; i < currentGroupIndex; i++){
|
|
294
|
+
var _results_i;
|
|
295
|
+
var _results_i_items;
|
|
296
|
+
((_results_i_items = (_results_i = results[i]) === null || _results_i === void 0 ? void 0 : _results_i.items) !== null && _results_i_items !== void 0 ? _results_i_items : []).filter((item)=>item.selector.name === selectorName).forEach((item)=>{
|
|
297
|
+
item.overriding = true;
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
isFirst = false;
|
|
175
302
|
};
|
|
176
303
|
return {
|
|
177
304
|
results,
|
|
178
|
-
|
|
305
|
+
addItem
|
|
179
306
|
};
|
|
180
307
|
}
|
|
@@ -21,27 +21,46 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
TemplateVariableProvider: function() {
|
|
25
|
+
return TemplateVariableProvider;
|
|
26
|
+
},
|
|
27
|
+
TemplateVariableProviderWithQueryParams: function() {
|
|
28
|
+
return TemplateVariableProviderWithQueryParams;
|
|
29
|
+
},
|
|
30
|
+
useTemplateExternalVariableDefinitions: function() {
|
|
31
|
+
return useTemplateExternalVariableDefinitions;
|
|
32
|
+
},
|
|
33
|
+
useTemplateVariable: function() {
|
|
34
|
+
return useTemplateVariable;
|
|
35
|
+
},
|
|
36
|
+
useTemplateVariableActions: function() {
|
|
37
|
+
return useTemplateVariableActions;
|
|
38
|
+
},
|
|
39
|
+
useTemplateVariableDefinitions: function() {
|
|
40
|
+
return useTemplateVariableDefinitions;
|
|
41
|
+
},
|
|
42
|
+
useTemplateVariableStore: function() {
|
|
43
|
+
return useTemplateVariableStore;
|
|
44
|
+
},
|
|
45
|
+
useTemplateVariableStoreCtx: function() {
|
|
46
|
+
return useTemplateVariableStoreCtx;
|
|
47
|
+
},
|
|
48
|
+
useTemplateVariableValues: function() {
|
|
49
|
+
return useTemplateVariableValues;
|
|
50
|
+
}
|
|
32
51
|
});
|
|
33
|
-
const
|
|
52
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
34
53
|
const _react = require("react");
|
|
35
54
|
const _zustand = require("zustand");
|
|
36
55
|
const _immer = require("zustand/middleware/immer");
|
|
37
56
|
const _middleware = require("zustand/middleware");
|
|
38
|
-
const _immer1 = /*#__PURE__*/
|
|
39
|
-
const
|
|
57
|
+
const _immer1 = /*#__PURE__*/ _interop_require_default(require("immer"));
|
|
58
|
+
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
40
59
|
const _core = require("@perses-dev/core");
|
|
41
60
|
const _utils = require("./utils");
|
|
42
61
|
const _hydrationUtils = require("./hydrationUtils");
|
|
43
|
-
const
|
|
44
|
-
function
|
|
62
|
+
const _queryparams = require("./query-params");
|
|
63
|
+
function _interop_require_default(obj) {
|
|
45
64
|
return obj && obj.__esModule ? obj : {
|
|
46
65
|
default: obj
|
|
47
66
|
};
|
|
@@ -92,12 +111,12 @@ function useTemplateVariableValues(variableNames) {
|
|
|
92
111
|
function useTemplateVariable(name, source) {
|
|
93
112
|
const store = useTemplateVariableStoreCtx();
|
|
94
113
|
return (0, _zustand.useStore)(store, (s)=>{
|
|
95
|
-
var
|
|
114
|
+
var _s_externalVariableDefinitions_find;
|
|
96
115
|
const state = s.variableState.get({
|
|
97
116
|
name,
|
|
98
117
|
source
|
|
99
118
|
});
|
|
100
|
-
const definitions = source ? (
|
|
119
|
+
const definitions = source ? (_s_externalVariableDefinitions_find = s.externalVariableDefinitions.find((v)=>v.source === source)) === null || _s_externalVariableDefinitions_find === void 0 ? void 0 : _s_externalVariableDefinitions_find.definitions : s.variableDefinitions;
|
|
101
120
|
const definition = (definitions || []).find((v)=>v.spec.name === name);
|
|
102
121
|
return {
|
|
103
122
|
state,
|
|
@@ -130,10 +149,11 @@ function useTemplateVariableStore() {
|
|
|
130
149
|
const store = useTemplateVariableStoreCtx();
|
|
131
150
|
return (0, _zustand.useStore)(store);
|
|
132
151
|
}
|
|
133
|
-
function PluginProvider({ children
|
|
152
|
+
function PluginProvider({ children, builtinVariables }) {
|
|
134
153
|
const originalValues = useTemplateVariableValues();
|
|
135
154
|
const definitions = useTemplateVariableDefinitions();
|
|
136
155
|
const externalDefinitions = useTemplateExternalVariableDefinitions();
|
|
156
|
+
const { absoluteTimeRange } = (0, _pluginsystem.useTimeRange)();
|
|
137
157
|
const values = (0, _react.useMemo)(()=>{
|
|
138
158
|
const contextValues = {};
|
|
139
159
|
// This will loop through all the current variables values
|
|
@@ -146,12 +166,12 @@ function PluginProvider({ children }) {
|
|
|
146
166
|
if (v.value === _core.DEFAULT_ALL_VALUE) {
|
|
147
167
|
const definition = (0, _utils.findVariableDefinitionByName)(name, definitions, externalDefinitions);
|
|
148
168
|
// If the variable is a list variable and has a custom all value, then use that value instead
|
|
149
|
-
if ((definition === null || definition === void 0 ? void 0 : definition.kind) === 'ListVariable' && definition.spec.
|
|
150
|
-
v.value = definition.spec.
|
|
169
|
+
if ((definition === null || definition === void 0 ? void 0 : definition.kind) === 'ListVariable' && definition.spec.customAllValue) {
|
|
170
|
+
v.value = definition.spec.customAllValue;
|
|
151
171
|
} else {
|
|
152
|
-
var
|
|
153
|
-
var
|
|
154
|
-
v.value = (
|
|
172
|
+
var _v_options;
|
|
173
|
+
var _v_options_map;
|
|
174
|
+
v.value = (_v_options_map = (_v_options = v.options) === null || _v_options === void 0 ? void 0 : _v_options.map((o)=>o.value)) !== null && _v_options_map !== void 0 ? _v_options_map : null;
|
|
155
175
|
}
|
|
156
176
|
}
|
|
157
177
|
contextValues[name] = v;
|
|
@@ -162,17 +182,95 @@ function PluginProvider({ children }) {
|
|
|
162
182
|
definitions,
|
|
163
183
|
externalDefinitions
|
|
164
184
|
]);
|
|
165
|
-
|
|
185
|
+
const allBuiltinVariables = (0, _react.useMemo)(()=>{
|
|
186
|
+
const result = [
|
|
187
|
+
{
|
|
188
|
+
kind: 'BuiltinVariable',
|
|
189
|
+
spec: {
|
|
190
|
+
name: '__from',
|
|
191
|
+
value: ()=>absoluteTimeRange.start.valueOf().toString(),
|
|
192
|
+
source: 'Dashboard',
|
|
193
|
+
display: {
|
|
194
|
+
name: '__from',
|
|
195
|
+
description: 'Start time of the current time range in unix millisecond epoch',
|
|
196
|
+
hidden: true
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
kind: 'BuiltinVariable',
|
|
202
|
+
spec: {
|
|
203
|
+
name: '__to',
|
|
204
|
+
value: ()=>absoluteTimeRange.end.valueOf().toString(),
|
|
205
|
+
source: 'Dashboard',
|
|
206
|
+
display: {
|
|
207
|
+
name: '__to',
|
|
208
|
+
description: 'End time of the current time range in unix millisecond epoch',
|
|
209
|
+
hidden: true
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
kind: 'BuiltinVariable',
|
|
215
|
+
spec: {
|
|
216
|
+
name: '__range',
|
|
217
|
+
value: ()=>(0, _core.formatDuration)((0, _core.intervalToPrometheusDuration)(absoluteTimeRange)),
|
|
218
|
+
source: 'Dashboard',
|
|
219
|
+
display: {
|
|
220
|
+
name: '__range',
|
|
221
|
+
description: 'The range for the current dashboard in human readable format',
|
|
222
|
+
hidden: true
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
kind: 'BuiltinVariable',
|
|
228
|
+
spec: {
|
|
229
|
+
name: '__range_s',
|
|
230
|
+
value: ()=>((absoluteTimeRange.end.valueOf() - absoluteTimeRange.start.valueOf()) / 1000).toString(),
|
|
231
|
+
source: 'Dashboard',
|
|
232
|
+
display: {
|
|
233
|
+
name: '__range_s',
|
|
234
|
+
description: 'The range for the current dashboard in second',
|
|
235
|
+
hidden: true
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
kind: 'BuiltinVariable',
|
|
241
|
+
spec: {
|
|
242
|
+
name: '__range_ms',
|
|
243
|
+
value: ()=>(absoluteTimeRange.end.valueOf() - absoluteTimeRange.start.valueOf()).toString(),
|
|
244
|
+
source: 'Dashboard',
|
|
245
|
+
display: {
|
|
246
|
+
name: '__range_ms',
|
|
247
|
+
description: 'The range for the current dashboard in millisecond',
|
|
248
|
+
hidden: true
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
];
|
|
253
|
+
builtinVariables === null || builtinVariables === void 0 ? void 0 : builtinVariables.forEach((def)=>result.push(def));
|
|
254
|
+
return result;
|
|
255
|
+
}, [
|
|
256
|
+
absoluteTimeRange,
|
|
257
|
+
builtinVariables
|
|
258
|
+
]);
|
|
259
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.BuiltinVariableContext.Provider, {
|
|
166
260
|
value: {
|
|
167
|
-
|
|
261
|
+
variables: allBuiltinVariables
|
|
168
262
|
},
|
|
169
|
-
children:
|
|
263
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.TemplateVariableContext.Provider, {
|
|
264
|
+
value: {
|
|
265
|
+
state: values
|
|
266
|
+
},
|
|
267
|
+
children: children
|
|
268
|
+
})
|
|
170
269
|
});
|
|
171
270
|
}
|
|
172
|
-
function createTemplateVariableSrvStore({ initialVariableDefinitions =[]
|
|
173
|
-
const initialParams = (0,
|
|
174
|
-
const store = (0, _zustand.createStore)()((0, _middleware.devtools)((0, _immer.immer)((set, get)=>{
|
|
175
|
-
return {
|
|
271
|
+
function createTemplateVariableSrvStore({ initialVariableDefinitions = [], externalVariableDefinitions = [], queryParams }) {
|
|
272
|
+
const initialParams = (0, _queryparams.getInitalValuesFromQueryParameters)(queryParams ? queryParams[0] : {});
|
|
273
|
+
const store = (0, _zustand.createStore)()((0, _middleware.devtools)((0, _immer.immer)((set, get)=>({
|
|
176
274
|
variableState: (0, _hydrationUtils.hydrateTemplateVariableStates)(initialVariableDefinitions, initialParams, externalVariableDefinitions),
|
|
177
275
|
variableDefinitions: initialVariableDefinitions,
|
|
178
276
|
externalVariableDefinitions: externalVariableDefinitions,
|
|
@@ -227,7 +325,7 @@ function createTemplateVariableSrvStore({ initialVariableDefinitions =[] , exter
|
|
|
227
325
|
if (queryParams) {
|
|
228
326
|
const setQueryParams = queryParams[1];
|
|
229
327
|
setQueryParams({
|
|
230
|
-
[(0,
|
|
328
|
+
[(0, _queryparams.getURLQueryParamName)(name)]: val
|
|
231
329
|
});
|
|
232
330
|
}
|
|
233
331
|
varState.value = val;
|
|
@@ -246,16 +344,16 @@ function createTemplateVariableSrvStore({ initialVariableDefinitions =[] , exter
|
|
|
246
344
|
draft[index] = {
|
|
247
345
|
kind: 'ListVariable',
|
|
248
346
|
spec: (0, _immer1.default)(variable.spec, (specDraft)=>{
|
|
249
|
-
specDraft.
|
|
347
|
+
specDraft.defaultValue = currentVariable.value;
|
|
250
348
|
})
|
|
251
349
|
};
|
|
252
350
|
}
|
|
253
351
|
} else if (variable.kind === 'TextVariable') {
|
|
254
|
-
const
|
|
352
|
+
const currentVariable = variableState.get({
|
|
255
353
|
name
|
|
256
354
|
});
|
|
257
|
-
const currentVariableValue = typeof (
|
|
258
|
-
if ((
|
|
355
|
+
const currentVariableValue = typeof (currentVariable === null || currentVariable === void 0 ? void 0 : currentVariable.value) === 'string' ? currentVariable.value : '';
|
|
356
|
+
if ((currentVariable === null || currentVariable === void 0 ? void 0 : currentVariable.value) !== undefined) {
|
|
259
357
|
draft[index] = {
|
|
260
358
|
kind: 'TextVariable',
|
|
261
359
|
spec: (0, _immer1.default)(variable.spec, (specDraft)=>{
|
|
@@ -274,21 +372,34 @@ function createTemplateVariableSrvStore({ initialVariableDefinitions =[] , exter
|
|
|
274
372
|
getSavedVariablesStatus: ()=>{
|
|
275
373
|
return (0, _utils.checkSavedDefaultVariableStatus)(get().variableDefinitions, get().variableState);
|
|
276
374
|
}
|
|
277
|
-
};
|
|
278
|
-
})));
|
|
375
|
+
}))));
|
|
279
376
|
return store;
|
|
280
377
|
}
|
|
281
|
-
function TemplateVariableProvider({ children
|
|
378
|
+
function TemplateVariableProvider({ children, initialVariableDefinitions = [], externalVariableDefinitions = [], builtinVariables = [] }) {
|
|
379
|
+
const [store] = (0, _react.useState)(createTemplateVariableSrvStore({
|
|
380
|
+
initialVariableDefinitions,
|
|
381
|
+
externalVariableDefinitions
|
|
382
|
+
}));
|
|
383
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(TemplateVariableStoreContext.Provider, {
|
|
384
|
+
value: store,
|
|
385
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(PluginProvider, {
|
|
386
|
+
builtinVariables: builtinVariables,
|
|
387
|
+
children: children
|
|
388
|
+
})
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
function TemplateVariableProviderWithQueryParams({ children, initialVariableDefinitions = [], externalVariableDefinitions = [], builtinVariables = [] }) {
|
|
282
392
|
const allVariableDefs = (0, _utils.mergeVariableDefinitions)(initialVariableDefinitions, externalVariableDefinitions);
|
|
283
|
-
const queryParams = (0,
|
|
393
|
+
const queryParams = (0, _queryparams.useVariableQueryParams)(allVariableDefs);
|
|
284
394
|
const [store] = (0, _react.useState)(createTemplateVariableSrvStore({
|
|
285
395
|
initialVariableDefinitions,
|
|
286
396
|
externalVariableDefinitions,
|
|
287
397
|
queryParams
|
|
288
398
|
}));
|
|
289
|
-
return /*#__PURE__*/ (0,
|
|
399
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(TemplateVariableStoreContext.Provider, {
|
|
290
400
|
value: store,
|
|
291
|
-
children: /*#__PURE__*/ (0,
|
|
401
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(PluginProvider, {
|
|
402
|
+
builtinVariables: builtinVariables,
|
|
292
403
|
children: children
|
|
293
404
|
})
|
|
294
405
|
});
|
|
@@ -16,10 +16,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
16
16
|
});
|
|
17
17
|
Object.defineProperty(exports, "hydrateTemplateVariableStates", {
|
|
18
18
|
enumerable: true,
|
|
19
|
-
get: ()
|
|
19
|
+
get: function() {
|
|
20
|
+
return hydrateTemplateVariableStates;
|
|
21
|
+
}
|
|
20
22
|
});
|
|
21
23
|
const _core = require("@perses-dev/core");
|
|
22
|
-
const
|
|
24
|
+
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
23
25
|
// TODO: move to TemplateVariableProvider/utils.ts
|
|
24
26
|
function hydrateTemplateVariableState(variable, initialValue) {
|
|
25
27
|
const varState = {
|
|
@@ -34,15 +36,15 @@ function hydrateTemplateVariableState(variable, initialValue) {
|
|
|
34
36
|
break;
|
|
35
37
|
case 'ListVariable':
|
|
36
38
|
varState.options = [];
|
|
37
|
-
var
|
|
38
|
-
varState.value = (
|
|
39
|
-
// TODO: smarter fallbacks for
|
|
39
|
+
var _ref;
|
|
40
|
+
varState.value = (_ref = initialValue !== null && initialValue !== void 0 ? initialValue : variable.spec.defaultValue) !== null && _ref !== void 0 ? _ref : null;
|
|
41
|
+
// TODO: smarter fallbacks for defaultValue when allowAllValue is true
|
|
40
42
|
if (varState.options.length > 0 && !varState.value) {
|
|
41
|
-
var
|
|
42
|
-
var
|
|
43
|
-
const firstOptionValue = (
|
|
43
|
+
var _varState_options_;
|
|
44
|
+
var _varState_options__value;
|
|
45
|
+
const firstOptionValue = (_varState_options__value = (_varState_options_ = varState.options[0]) === null || _varState_options_ === void 0 ? void 0 : _varState_options_.value) !== null && _varState_options__value !== void 0 ? _varState_options__value : null;
|
|
44
46
|
if (firstOptionValue !== null) {
|
|
45
|
-
varState.value = variable.spec.
|
|
47
|
+
varState.value = variable.spec.allowMultiple ? [
|
|
46
48
|
firstOptionValue
|
|
47
49
|
] : firstOptionValue;
|
|
48
50
|
}
|
|
@@ -62,7 +64,7 @@ function hydrateTemplateVariableState(variable, initialValue) {
|
|
|
62
64
|
return varState;
|
|
63
65
|
}
|
|
64
66
|
function hydrateTemplateVariableStates(localDefinitions, initialValues, externalDefinitions = []) {
|
|
65
|
-
const state = new
|
|
67
|
+
const state = new _pluginsystem.VariableStoreStateMap();
|
|
66
68
|
// Collect the names used by local definitions
|
|
67
69
|
let overridingNames = {};
|
|
68
70
|
localDefinitions.forEach((v)=>{
|