@perses-dev/dashboards 0.0.0-snapshot-panel-extra-content-3-17f9c42 → 0.0.0-snapshot-scatter-chart-embed-8efdfab
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 +10 -7
- package/dist/cjs/components/AddGroupButton/index.js +10 -8
- package/dist/cjs/components/AddPanelButton/AddPanelButton.js +10 -11
- package/dist/cjs/components/AddPanelButton/index.js +10 -8
- package/dist/cjs/components/Dashboard/Dashboard.js +11 -9
- 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 +81 -102
- package/dist/cjs/components/DashboardToolbar/index.js +10 -8
- package/dist/cjs/components/Datasources/DatasourceEditor.js +237 -0
- package/dist/cjs/components/Datasources/EditDatasourcesButton.js +106 -0
- package/dist/cjs/components/Datasources/index.js +31 -0
- 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 +15 -11
- package/dist/cjs/components/EditJsonButton/index.js +10 -8
- package/dist/cjs/components/EditJsonDialog/EditJsonDialog.js +46 -24
- 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 -14
- package/dist/cjs/components/GridLayout/GridLayout.js +18 -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 +18 -22
- package/dist/cjs/components/Panel/PanelContent.js +11 -8
- package/dist/cjs/components/Panel/PanelHeader.js +33 -31
- 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 +231 -141
- package/dist/cjs/components/PanelDrawer/PanelPreview.js +11 -9
- package/dist/cjs/components/PanelDrawer/index.js +11 -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 +47 -45
- 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 +8 -8
- package/dist/cjs/components/SaveDashboardButton/index.js +10 -8
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +46 -19
- 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 +17 -15
- package/dist/cjs/components/Variables/TemplateVariable.js +250 -105
- package/dist/cjs/components/Variables/VariableEditor.js +280 -204
- package/dist/cjs/components/Variables/VariableList.js +23 -21
- package/dist/cjs/components/Variables/index.js +14 -11
- package/dist/cjs/components/index.js +32 -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 +9 -2
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +43 -35
- 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 +167 -46
- package/dist/cjs/context/TemplateVariableProvider/TemplateVariableProvider.js +141 -34
- 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 +12 -8
- 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 +30 -16
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +63 -20
- package/dist/cjs/views/ViewDashboard/index.js +10 -8
- package/dist/cjs/views/index.js +10 -8
- package/dist/components/AddGroupButton/AddGroupButton.d.ts.map +1 -1
- package/dist/components/AddGroupButton/AddGroupButton.js +2 -1
- package/dist/components/AddGroupButton/AddGroupButton.js.map +1 -1
- package/dist/components/AddGroupButton/index.js.map +1 -1
- package/dist/components/AddPanelButton/AddPanelButton.js +2 -5
- package/dist/components/AddPanelButton/AddPanelButton.js.map +1 -1
- package/dist/components/AddPanelButton/index.js.map +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.map +1 -1
- package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js +37 -8
- 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.map +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.js +61 -84
- 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 +8 -0
- package/dist/components/Datasources/DatasourceEditor.d.ts.map +1 -0
- package/dist/components/Datasources/DatasourceEditor.js +224 -0
- package/dist/components/Datasources/DatasourceEditor.js.map +1 -0
- package/dist/components/Datasources/EditDatasourcesButton.d.ts +3 -0
- package/dist/components/Datasources/EditDatasourcesButton.d.ts.map +1 -0
- package/dist/components/Datasources/EditDatasourcesButton.js +93 -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/Datasources/index.js +16 -0
- package/dist/components/Datasources/index.js.map +1 -0
- 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.d.ts +4 -1
- package/dist/components/EditJsonButton/EditJsonButton.d.ts.map +1 -1
- package/dist/components/EditJsonButton/EditJsonButton.js +5 -3
- 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 -1
- package/dist/components/EditJsonDialog/EditJsonDialog.d.ts.map +1 -1
- package/dist/components/EditJsonDialog/EditJsonDialog.js +32 -12
- 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.map +1 -1
- package/dist/components/GridLayout/GridItemContent.js +27 -10
- package/dist/components/GridLayout/GridItemContent.js.map +1 -1
- package/dist/components/GridLayout/GridLayout.js +2 -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.map +1 -1
- package/dist/components/Panel/Panel.js +5 -11
- package/dist/components/Panel/Panel.js.map +1 -1
- package/dist/components/Panel/PanelContent.d.ts +2 -1
- package/dist/components/Panel/PanelContent.d.ts.map +1 -1
- package/dist/components/Panel/PanelContent.js +3 -2
- package/dist/components/Panel/PanelContent.js.map +1 -1
- 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 +225 -139
- 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.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.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 +6 -6
- 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.d.ts.map +1 -1
- package/dist/components/SaveDashboardButton/SaveDashboardButton.js +1 -3
- 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 +26 -5
- 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 +5 -5
- package/dist/components/Variables/EditVariablesButton.js.map +1 -1
- package/dist/components/Variables/TemplateVariable.d.ts +10 -1
- package/dist/components/Variables/TemplateVariable.d.ts.map +1 -1
- package/dist/components/Variables/TemplateVariable.js +233 -98
- package/dist/components/Variables/TemplateVariable.js.map +1 -1
- package/dist/components/Variables/VariableEditor.d.ts +2 -1
- package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditor.js +229 -157
- package/dist/components/Variables/VariableEditor.js.map +1 -1
- package/dist/components/Variables/VariableList.d.ts.map +1 -1
- package/dist/components/Variables/VariableList.js +10 -12
- 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 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -0
- 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/constants/styles.js +23 -0
- package/dist/constants/styles.js.map +1 -0
- package/dist/constants/user-interface-text.d.ts +3 -0
- package/dist/constants/user-interface-text.d.ts.map +1 -1
- package/dist/constants/user-interface-text.js +3 -0
- package/dist/constants/user-interface-text.js.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.d.ts +2 -1
- package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.js +8 -6
- 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 -2
- 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 +15 -10
- package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
- package/dist/context/DatasourceStoreProvider.js +161 -42
- package/dist/context/DatasourceStoreProvider.js.map +1 -1
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts +11 -4
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts.map +1 -1
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js +106 -18
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js.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.map +1 -1
- package/dist/context/useDashboard.js +5 -3
- 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 +17 -5
- package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.d.ts +1 -0
- package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.js +52 -11
- 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
|
@@ -16,16 +16,21 @@ 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 , listPluginMetadata } = (0,
|
|
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) {
|
|
@@ -33,8 +38,12 @@ function DatasourceStoreProvider(props) {
|
|
|
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,8 +64,10 @@ 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}'`);
|
|
@@ -85,53 +99,104 @@ 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({
|
|
165
|
+
...dashboardResource,
|
|
166
|
+
spec: {
|
|
167
|
+
...dashboardResource.spec,
|
|
168
|
+
datasources: datasources
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
}, [
|
|
173
|
+
dashboardResource
|
|
174
|
+
]);
|
|
121
175
|
const ctxValue = (0, _react.useMemo)(()=>({
|
|
122
176
|
getDatasource,
|
|
123
177
|
getDatasourceClient,
|
|
124
|
-
|
|
178
|
+
getLocalDatasources,
|
|
179
|
+
setLocalDatasources,
|
|
180
|
+
setSavedDatasources,
|
|
181
|
+
getSavedDatasources,
|
|
182
|
+
listDatasourceSelectItems
|
|
125
183
|
}), [
|
|
126
184
|
getDatasource,
|
|
127
185
|
getDatasourceClient,
|
|
128
|
-
|
|
186
|
+
getLocalDatasources,
|
|
187
|
+
setLocalDatasources,
|
|
188
|
+
listDatasourceSelectItems,
|
|
189
|
+
setSavedDatasources,
|
|
190
|
+
getSavedDatasources
|
|
129
191
|
]);
|
|
130
|
-
return /*#__PURE__*/ (0,
|
|
192
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.DatasourceStoreContext.Provider, {
|
|
131
193
|
value: ctxValue,
|
|
132
194
|
children: children
|
|
133
195
|
});
|
|
134
196
|
}
|
|
197
|
+
function buildDatasourceProxyUrl(api, params) {
|
|
198
|
+
return api.buildProxyUrl ? api.buildProxyUrl(params) : '';
|
|
199
|
+
}
|
|
135
200
|
// Helper to find a datasource in the list embedded in a dashboard spec
|
|
136
201
|
function findDashboardDatasource(dashboardDatasources, selector) {
|
|
137
202
|
if (dashboardDatasources === undefined) return undefined;
|
|
@@ -139,42 +204,98 @@ function findDashboardDatasource(dashboardDatasources, selector) {
|
|
|
139
204
|
if (selector.name !== undefined) {
|
|
140
205
|
const named = dashboardDatasources[selector.name];
|
|
141
206
|
if (named === undefined) return undefined;
|
|
142
|
-
return named.plugin.kind === selector.kind ?
|
|
207
|
+
return named.plugin.kind === selector.kind ? {
|
|
208
|
+
name: selector.name,
|
|
209
|
+
spec: named
|
|
210
|
+
} : undefined;
|
|
143
211
|
}
|
|
144
212
|
// If only using a kind, try to find one with that kind that is the default
|
|
145
|
-
|
|
213
|
+
const result = Object.entries(dashboardDatasources).find((entry)=>entry[1].plugin.kind === selector.kind && entry[1].default);
|
|
214
|
+
if (!result) {
|
|
215
|
+
return undefined;
|
|
216
|
+
}
|
|
217
|
+
return {
|
|
218
|
+
name: result[0],
|
|
219
|
+
spec: result[1]
|
|
220
|
+
};
|
|
146
221
|
}
|
|
147
|
-
|
|
148
|
-
|
|
222
|
+
/**
|
|
223
|
+
* Helper for building a list of DatasourceSelectItemGroup results.
|
|
224
|
+
* @param pluginDisplayName
|
|
225
|
+
*/ function buildDatasourceSelectItemGroups(pluginDisplayName) {
|
|
149
226
|
const results = [];
|
|
150
227
|
const usedNames = new Set();
|
|
151
|
-
let
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
228
|
+
let isFirst = true;
|
|
229
|
+
let explicitDefaultAdded = false;
|
|
230
|
+
const groupIndices = {};
|
|
231
|
+
let currentGroupIndex = 1; // 0 is the default group, always there as it contains at least the first item.
|
|
232
|
+
const addItem = ({ spec , selectorName , selectorGroup: group , editLink , saved })=>{
|
|
233
|
+
var _spec_display;
|
|
234
|
+
group = group !== null && group !== void 0 ? group : '';
|
|
235
|
+
// Ensure the default group is always present as soon as an item is added.
|
|
236
|
+
if (isFirst) {
|
|
237
|
+
results.push({
|
|
238
|
+
group: `Default ${pluginDisplayName}`,
|
|
239
|
+
items: []
|
|
161
240
|
});
|
|
162
|
-
defaultAdded = true;
|
|
163
241
|
}
|
|
164
|
-
|
|
165
|
-
if
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
242
|
+
var _groupIndices_group;
|
|
243
|
+
// Create the group if necessary
|
|
244
|
+
let selectItemGroup = results[(_groupIndices_group = groupIndices[group]) !== null && _groupIndices_group !== void 0 ? _groupIndices_group : -1];
|
|
245
|
+
if (!selectItemGroup) {
|
|
246
|
+
groupIndices[group] = currentGroupIndex;
|
|
247
|
+
selectItemGroup = {
|
|
248
|
+
items: [],
|
|
249
|
+
group,
|
|
250
|
+
editLink
|
|
251
|
+
};
|
|
252
|
+
results[currentGroupIndex] = selectItemGroup;
|
|
253
|
+
currentGroupIndex++;
|
|
254
|
+
}
|
|
255
|
+
// Add item to the group
|
|
256
|
+
const isOverridden = usedNames.has(selectorName);
|
|
257
|
+
var _spec_display_name;
|
|
258
|
+
selectItemGroup.items.push({
|
|
259
|
+
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,
|
|
260
|
+
overridden: isOverridden,
|
|
261
|
+
saved,
|
|
169
262
|
selector: {
|
|
170
263
|
kind: spec.plugin.kind,
|
|
171
|
-
name: selectorName
|
|
264
|
+
name: selectorName,
|
|
265
|
+
group
|
|
172
266
|
}
|
|
173
267
|
});
|
|
174
268
|
usedNames.add(selectorName);
|
|
269
|
+
const isExplicitDefault = !isOverridden && spec.default && !explicitDefaultAdded;
|
|
270
|
+
if (results[0] && (isFirst || isExplicitDefault)) {
|
|
271
|
+
// If we haven't added a default yet and this is a default, add default option to the beginning of the results
|
|
272
|
+
results[0].items = [
|
|
273
|
+
{
|
|
274
|
+
name: `Default (${selectorName} from ${group})`,
|
|
275
|
+
selector: {
|
|
276
|
+
kind: spec.plugin.kind
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
];
|
|
280
|
+
// We consider that we added the default datasource only if it has been explicitly set as default.
|
|
281
|
+
// If we add this datasource as default just because it's the first, it still needs to be overridable by
|
|
282
|
+
// another datasource explicitly set as default.
|
|
283
|
+
explicitDefaultAdded = isExplicitDefault;
|
|
284
|
+
}
|
|
285
|
+
// At the end, we make sure the overriding item(s) is well flagged so
|
|
286
|
+
if (isOverridden) {
|
|
287
|
+
for(let i = explicitDefaultAdded ? 1 : 0; i < currentGroupIndex; i++){
|
|
288
|
+
var _results_i;
|
|
289
|
+
var _results_i_items;
|
|
290
|
+
((_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)=>{
|
|
291
|
+
item.overriding = true;
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
isFirst = false;
|
|
175
296
|
};
|
|
176
297
|
return {
|
|
177
298
|
results,
|
|
178
|
-
|
|
299
|
+
addItem
|
|
179
300
|
};
|
|
180
301
|
}
|
|
@@ -21,27 +21,46 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
-
useTemplateVariableStoreCtx: ()
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
useTemplateVariableStoreCtx: function() {
|
|
25
|
+
return useTemplateVariableStoreCtx;
|
|
26
|
+
},
|
|
27
|
+
useTemplateVariableValues: function() {
|
|
28
|
+
return useTemplateVariableValues;
|
|
29
|
+
},
|
|
30
|
+
useTemplateVariable: function() {
|
|
31
|
+
return useTemplateVariable;
|
|
32
|
+
},
|
|
33
|
+
useTemplateVariableActions: function() {
|
|
34
|
+
return useTemplateVariableActions;
|
|
35
|
+
},
|
|
36
|
+
useTemplateVariableDefinitions: function() {
|
|
37
|
+
return useTemplateVariableDefinitions;
|
|
38
|
+
},
|
|
39
|
+
useTemplateExternalVariableDefinitions: function() {
|
|
40
|
+
return useTemplateExternalVariableDefinitions;
|
|
41
|
+
},
|
|
42
|
+
useTemplateVariableStore: function() {
|
|
43
|
+
return useTemplateVariableStore;
|
|
44
|
+
},
|
|
45
|
+
TemplateVariableProvider: function() {
|
|
46
|
+
return TemplateVariableProvider;
|
|
47
|
+
},
|
|
48
|
+
TemplateVariableProviderWithQueryParams: function() {
|
|
49
|
+
return TemplateVariableProviderWithQueryParams;
|
|
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,15 +182,88 @@ function PluginProvider({ children }) {
|
|
|
162
182
|
definitions,
|
|
163
183
|
externalDefinitions
|
|
164
184
|
]);
|
|
165
|
-
|
|
185
|
+
const allBuiltinVariables = [
|
|
186
|
+
{
|
|
187
|
+
kind: 'BuiltinVariable',
|
|
188
|
+
spec: {
|
|
189
|
+
name: '__from',
|
|
190
|
+
value: ()=>absoluteTimeRange.start.valueOf().toString(),
|
|
191
|
+
source: 'Dashboard',
|
|
192
|
+
display: {
|
|
193
|
+
name: '__from',
|
|
194
|
+
description: 'Start time of the current time range in unix millisecond epoch',
|
|
195
|
+
hidden: true
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
kind: 'BuiltinVariable',
|
|
201
|
+
spec: {
|
|
202
|
+
name: '__to',
|
|
203
|
+
value: ()=>absoluteTimeRange.end.valueOf().toString(),
|
|
204
|
+
source: 'Dashboard',
|
|
205
|
+
display: {
|
|
206
|
+
name: '__to',
|
|
207
|
+
description: 'End time of the current time range in unix millisecond epoch',
|
|
208
|
+
hidden: true
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
kind: 'BuiltinVariable',
|
|
214
|
+
spec: {
|
|
215
|
+
name: '__range',
|
|
216
|
+
value: ()=>(0, _core.formatDuration)((0, _core.intervalToPrometheusDuration)(absoluteTimeRange)),
|
|
217
|
+
source: 'Dashboard',
|
|
218
|
+
display: {
|
|
219
|
+
name: '__range',
|
|
220
|
+
description: 'The range for the current dashboard in human readable format',
|
|
221
|
+
hidden: true
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
kind: 'BuiltinVariable',
|
|
227
|
+
spec: {
|
|
228
|
+
name: '__range_s',
|
|
229
|
+
value: ()=>((absoluteTimeRange.end.valueOf() - absoluteTimeRange.start.valueOf()) / 1000).toString(),
|
|
230
|
+
source: 'Dashboard',
|
|
231
|
+
display: {
|
|
232
|
+
name: '__range_s',
|
|
233
|
+
description: 'The range for the current dashboard in second',
|
|
234
|
+
hidden: true
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
kind: 'BuiltinVariable',
|
|
240
|
+
spec: {
|
|
241
|
+
name: '__range_ms',
|
|
242
|
+
value: ()=>(absoluteTimeRange.end.valueOf() - absoluteTimeRange.start.valueOf()).toString(),
|
|
243
|
+
source: 'Dashboard',
|
|
244
|
+
display: {
|
|
245
|
+
name: '__range_ms',
|
|
246
|
+
description: 'The range for the current dashboard in millisecond',
|
|
247
|
+
hidden: true
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
];
|
|
252
|
+
builtinVariables === null || builtinVariables === void 0 ? void 0 : builtinVariables.forEach((def)=>allBuiltinVariables.push(def));
|
|
253
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.BuiltinVariableContext.Provider, {
|
|
166
254
|
value: {
|
|
167
|
-
|
|
255
|
+
variables: allBuiltinVariables
|
|
168
256
|
},
|
|
169
|
-
children:
|
|
257
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.TemplateVariableContext.Provider, {
|
|
258
|
+
value: {
|
|
259
|
+
state: values
|
|
260
|
+
},
|
|
261
|
+
children: children
|
|
262
|
+
})
|
|
170
263
|
});
|
|
171
264
|
}
|
|
172
265
|
function createTemplateVariableSrvStore({ initialVariableDefinitions =[] , externalVariableDefinitions =[] , queryParams }) {
|
|
173
|
-
const initialParams = (0,
|
|
266
|
+
const initialParams = (0, _queryparams.getInitalValuesFromQueryParameters)(queryParams ? queryParams[0] : {});
|
|
174
267
|
const store = (0, _zustand.createStore)()((0, _middleware.devtools)((0, _immer.immer)((set, get)=>{
|
|
175
268
|
return {
|
|
176
269
|
variableState: (0, _hydrationUtils.hydrateTemplateVariableStates)(initialVariableDefinitions, initialParams, externalVariableDefinitions),
|
|
@@ -227,7 +320,7 @@ function createTemplateVariableSrvStore({ initialVariableDefinitions =[] , exter
|
|
|
227
320
|
if (queryParams) {
|
|
228
321
|
const setQueryParams = queryParams[1];
|
|
229
322
|
setQueryParams({
|
|
230
|
-
[(0,
|
|
323
|
+
[(0, _queryparams.getURLQueryParamName)(name)]: val
|
|
231
324
|
});
|
|
232
325
|
}
|
|
233
326
|
varState.value = val;
|
|
@@ -246,16 +339,16 @@ function createTemplateVariableSrvStore({ initialVariableDefinitions =[] , exter
|
|
|
246
339
|
draft[index] = {
|
|
247
340
|
kind: 'ListVariable',
|
|
248
341
|
spec: (0, _immer1.default)(variable.spec, (specDraft)=>{
|
|
249
|
-
specDraft.
|
|
342
|
+
specDraft.defaultValue = currentVariable.value;
|
|
250
343
|
})
|
|
251
344
|
};
|
|
252
345
|
}
|
|
253
346
|
} else if (variable.kind === 'TextVariable') {
|
|
254
|
-
const
|
|
347
|
+
const currentVariable = variableState.get({
|
|
255
348
|
name
|
|
256
349
|
});
|
|
257
|
-
const currentVariableValue = typeof (
|
|
258
|
-
if ((
|
|
350
|
+
const currentVariableValue = typeof (currentVariable === null || currentVariable === void 0 ? void 0 : currentVariable.value) === 'string' ? currentVariable.value : '';
|
|
351
|
+
if ((currentVariable === null || currentVariable === void 0 ? void 0 : currentVariable.value) !== undefined) {
|
|
259
352
|
draft[index] = {
|
|
260
353
|
kind: 'TextVariable',
|
|
261
354
|
spec: (0, _immer1.default)(variable.spec, (specDraft)=>{
|
|
@@ -278,17 +371,31 @@ function createTemplateVariableSrvStore({ initialVariableDefinitions =[] , exter
|
|
|
278
371
|
})));
|
|
279
372
|
return store;
|
|
280
373
|
}
|
|
281
|
-
function TemplateVariableProvider({ children , initialVariableDefinitions =[] , externalVariableDefinitions =[] }) {
|
|
374
|
+
function TemplateVariableProvider({ children , initialVariableDefinitions =[] , externalVariableDefinitions =[] , builtinVariables =[] }) {
|
|
375
|
+
const [store] = (0, _react.useState)(createTemplateVariableSrvStore({
|
|
376
|
+
initialVariableDefinitions,
|
|
377
|
+
externalVariableDefinitions
|
|
378
|
+
}));
|
|
379
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(TemplateVariableStoreContext.Provider, {
|
|
380
|
+
value: store,
|
|
381
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(PluginProvider, {
|
|
382
|
+
builtinVariables: builtinVariables,
|
|
383
|
+
children: children
|
|
384
|
+
})
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
function TemplateVariableProviderWithQueryParams({ children , initialVariableDefinitions =[] , externalVariableDefinitions =[] , builtinVariables =[] }) {
|
|
282
388
|
const allVariableDefs = (0, _utils.mergeVariableDefinitions)(initialVariableDefinitions, externalVariableDefinitions);
|
|
283
|
-
const queryParams = (0,
|
|
389
|
+
const queryParams = (0, _queryparams.useVariableQueryParams)(allVariableDefs);
|
|
284
390
|
const [store] = (0, _react.useState)(createTemplateVariableSrvStore({
|
|
285
391
|
initialVariableDefinitions,
|
|
286
392
|
externalVariableDefinitions,
|
|
287
393
|
queryParams
|
|
288
394
|
}));
|
|
289
|
-
return /*#__PURE__*/ (0,
|
|
395
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(TemplateVariableStoreContext.Provider, {
|
|
290
396
|
value: store,
|
|
291
|
-
children: /*#__PURE__*/ (0,
|
|
397
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(PluginProvider, {
|
|
398
|
+
builtinVariables: builtinVariables,
|
|
292
399
|
children: children
|
|
293
400
|
})
|
|
294
401
|
});
|
|
@@ -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)=>{
|
|
@@ -14,15 +14,17 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
-
|
|
18
|
-
function
|
|
17
|
+
_export_star(require("./TemplateVariableProvider"), exports);
|
|
18
|
+
function _export_star(from, to) {
|
|
19
19
|
Object.keys(from).forEach(function(k) {
|
|
20
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k))
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
21
|
+
Object.defineProperty(to, k, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function() {
|
|
24
|
+
return from[k];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
26
28
|
});
|
|
27
29
|
return from;
|
|
28
30
|
}
|