@perses-dev/dashboards 0.0.0-snapshot-time-range-height-80d08fc
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/LICENSE +201 -0
- package/dist/cjs/components/Dashboard/Dashboard.js +37 -0
- package/dist/cjs/components/Dashboard/index.js +28 -0
- package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +176 -0
- package/dist/cjs/components/DashboardToolbar/index.js +28 -0
- package/dist/cjs/components/DeletePanelDialog/DeletePanelDialog.js +92 -0
- package/dist/cjs/components/DeletePanelDialog/index.js +28 -0
- package/dist/cjs/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +88 -0
- package/dist/cjs/components/DeletePanelGroupDialog/index.js +28 -0
- package/dist/cjs/components/DownloadButton/DownloadButton.js +109 -0
- package/dist/cjs/components/DownloadButton/index.js +28 -0
- package/dist/cjs/components/GridLayout/GridContainer.js +219 -0
- package/dist/cjs/components/GridLayout/GridItemContent.js +41 -0
- package/dist/cjs/components/GridLayout/GridLayout.js +104 -0
- package/dist/cjs/components/GridLayout/GridTitle.js +100 -0
- package/dist/cjs/components/GridLayout/index.js +29 -0
- package/dist/cjs/components/Panel/Panel.js +123 -0
- package/dist/cjs/components/Panel/Panel.test.js +129 -0
- package/dist/cjs/components/Panel/PanelContent.js +44 -0
- package/dist/cjs/components/Panel/PanelHeader.js +120 -0
- package/dist/cjs/components/Panel/index.js +28 -0
- package/dist/cjs/components/PanelDrawer/PanelDrawer.js +98 -0
- package/dist/cjs/components/PanelDrawer/PanelDrawer.test.js +131 -0
- package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +202 -0
- package/dist/cjs/components/PanelDrawer/PanelPreview.js +47 -0
- package/dist/cjs/components/PanelDrawer/index.js +28 -0
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +101 -0
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.test.js +87 -0
- package/dist/cjs/components/PanelGroupDialog/PanelGroupEditorForm.js +92 -0
- package/dist/cjs/components/PanelGroupDialog/index.js +28 -0
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +136 -0
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.test.js +95 -0
- package/dist/cjs/components/TimeRangeControls/index.js +28 -0
- package/dist/cjs/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.js +67 -0
- package/dist/cjs/components/UnsavedChangesConfirmationDialog/index.js +28 -0
- package/dist/cjs/components/Variables/Variable.js +194 -0
- package/dist/cjs/components/Variables/VariableEditor.js +276 -0
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +459 -0
- package/dist/cjs/components/Variables/VariableEditorForm/index.js +28 -0
- package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +89 -0
- package/dist/cjs/components/Variables/VariableList.js +150 -0
- package/dist/cjs/components/Variables/index.js +30 -0
- package/dist/cjs/components/Variables/variable-model.js +117 -0
- package/dist/cjs/components/Variables/variable-model.test.js +106 -0
- package/dist/cjs/components/index.js +39 -0
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +95 -0
- package/dist/cjs/context/DashboardProvider/common.js +28 -0
- package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +191 -0
- package/dist/cjs/context/DashboardProvider/delete-panel-group-slice.js +70 -0
- package/dist/cjs/context/DashboardProvider/delete-panel-slice.js +85 -0
- package/dist/cjs/context/DashboardProvider/index.js +29 -0
- package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +205 -0
- package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +85 -0
- package/dist/cjs/context/DashboardProvider/panel-group-slice.js +113 -0
- package/dist/cjs/context/DashboardProvider/panel-slice.js +25 -0
- package/dist/cjs/context/DatasourceStoreProvider.js +170 -0
- package/dist/cjs/context/TemplateVariableProvider/TemplateVariableProvider.js +228 -0
- package/dist/cjs/context/TemplateVariableProvider/index.js +28 -0
- package/dist/cjs/context/TemplateVariableProvider/query-params.js +81 -0
- package/dist/cjs/context/TemplateVariableProvider/query-params.test.js +82 -0
- package/dist/cjs/context/index.js +31 -0
- package/dist/cjs/context/useDashboard.js +94 -0
- package/dist/cjs/index.js +30 -0
- package/dist/cjs/test/dashboard-provider.js +51 -0
- package/dist/cjs/test/index.js +30 -0
- package/dist/cjs/test/plugin-registry.js +42 -0
- package/dist/cjs/test/render.js +62 -0
- package/dist/cjs/test/setup-tests.js +23 -0
- package/dist/cjs/test/testDashboard.js +293 -0
- package/dist/cjs/utils/functions.js +23 -0
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +96 -0
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +68 -0
- package/dist/cjs/views/ViewDashboard/index.js +28 -0
- package/dist/cjs/views/ViewDashboard/tests/panelGroups.test.js +110 -0
- package/dist/cjs/views/index.js +28 -0
- package/dist/components/Dashboard/Dashboard.d.ts +8 -0
- package/dist/components/Dashboard/Dashboard.d.ts.map +1 -0
- package/dist/components/Dashboard/Dashboard.js +33 -0
- package/dist/components/Dashboard/Dashboard.js.map +1 -0
- package/dist/components/Dashboard/index.d.ts +2 -0
- package/dist/components/Dashboard/index.d.ts.map +1 -0
- package/dist/components/Dashboard/index.js +15 -0
- package/dist/components/Dashboard/index.js.map +1 -0
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts +11 -0
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -0
- package/dist/components/DashboardToolbar/DashboardToolbar.js +165 -0
- package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -0
- package/dist/components/DashboardToolbar/index.d.ts +2 -0
- package/dist/components/DashboardToolbar/index.d.ts.map +1 -0
- package/dist/components/DashboardToolbar/index.js +15 -0
- package/dist/components/DashboardToolbar/index.js.map +1 -0
- package/dist/components/DeletePanelDialog/DeletePanelDialog.d.ts +3 -0
- package/dist/components/DeletePanelDialog/DeletePanelDialog.d.ts.map +1 -0
- package/dist/components/DeletePanelDialog/DeletePanelDialog.js +81 -0
- package/dist/components/DeletePanelDialog/DeletePanelDialog.js.map +1 -0
- package/dist/components/DeletePanelDialog/index.d.ts +2 -0
- package/dist/components/DeletePanelDialog/index.d.ts.map +1 -0
- package/dist/components/DeletePanelDialog/index.js +15 -0
- package/dist/components/DeletePanelDialog/index.js.map +1 -0
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.d.ts +3 -0
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -0
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +77 -0
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js.map +1 -0
- package/dist/components/DeletePanelGroupDialog/index.d.ts +2 -0
- package/dist/components/DeletePanelGroupDialog/index.d.ts.map +1 -0
- package/dist/components/DeletePanelGroupDialog/index.js +15 -0
- package/dist/components/DeletePanelGroupDialog/index.js.map +1 -0
- package/dist/components/DownloadButton/DownloadButton.d.ts +3 -0
- package/dist/components/DownloadButton/DownloadButton.d.ts.map +1 -0
- package/dist/components/DownloadButton/DownloadButton.js +60 -0
- package/dist/components/DownloadButton/DownloadButton.js.map +1 -0
- package/dist/components/DownloadButton/index.d.ts +2 -0
- package/dist/components/DownloadButton/index.d.ts.map +1 -0
- package/dist/components/DownloadButton/index.js +15 -0
- package/dist/components/DownloadButton/index.js.map +1 -0
- package/dist/components/GridLayout/GridContainer.d.ts +6 -0
- package/dist/components/GridLayout/GridContainer.d.ts.map +1 -0
- package/dist/components/GridLayout/GridContainer.js +213 -0
- package/dist/components/GridLayout/GridContainer.js.map +1 -0
- package/dist/components/GridLayout/GridItemContent.d.ts +10 -0
- package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -0
- package/dist/components/GridLayout/GridItemContent.js +37 -0
- package/dist/components/GridLayout/GridItemContent.js.map +1 -0
- package/dist/components/GridLayout/GridLayout.d.ts +10 -0
- package/dist/components/GridLayout/GridLayout.d.ts.map +1 -0
- package/dist/components/GridLayout/GridLayout.js +100 -0
- package/dist/components/GridLayout/GridLayout.js.map +1 -0
- package/dist/components/GridLayout/GridTitle.d.ts +16 -0
- package/dist/components/GridLayout/GridTitle.d.ts.map +1 -0
- package/dist/components/GridLayout/GridTitle.js +92 -0
- package/dist/components/GridLayout/GridTitle.js.map +1 -0
- package/dist/components/GridLayout/index.d.ts +3 -0
- package/dist/components/GridLayout/index.d.ts.map +1 -0
- package/dist/components/GridLayout/index.js +16 -0
- package/dist/components/GridLayout/index.js.map +1 -0
- package/dist/components/Panel/Panel.d.ts +13 -0
- package/dist/components/Panel/Panel.d.ts.map +1 -0
- package/dist/components/Panel/Panel.js +114 -0
- package/dist/components/Panel/Panel.js.map +1 -0
- package/dist/components/Panel/Panel.test.d.ts +2 -0
- package/dist/components/Panel/Panel.test.d.ts.map +1 -0
- package/dist/components/Panel/Panel.test.js +122 -0
- package/dist/components/Panel/Panel.test.js.map +1 -0
- package/dist/components/Panel/PanelContent.d.ts +12 -0
- package/dist/components/Panel/PanelContent.d.ts.map +1 -0
- package/dist/components/Panel/PanelContent.js +41 -0
- package/dist/components/Panel/PanelContent.js.map +1 -0
- package/dist/components/Panel/PanelHeader.d.ts +16 -0
- package/dist/components/Panel/PanelHeader.d.ts.map +1 -0
- package/dist/components/Panel/PanelHeader.js +109 -0
- package/dist/components/Panel/PanelHeader.js.map +1 -0
- package/dist/components/Panel/index.d.ts +2 -0
- package/dist/components/Panel/index.d.ts.map +1 -0
- package/dist/components/Panel/index.js +15 -0
- package/dist/components/Panel/index.js.map +1 -0
- package/dist/components/PanelDrawer/PanelDrawer.d.ts +6 -0
- package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -0
- package/dist/components/PanelDrawer/PanelDrawer.js +94 -0
- package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -0
- package/dist/components/PanelDrawer/PanelDrawer.test.d.ts +2 -0
- package/dist/components/PanelDrawer/PanelDrawer.test.d.ts.map +1 -0
- package/dist/components/PanelDrawer/PanelDrawer.test.js +124 -0
- package/dist/components/PanelDrawer/PanelDrawer.test.js.map +1 -0
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts +12 -0
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -0
- package/dist/components/PanelDrawer/PanelEditorForm.js +192 -0
- package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -0
- package/dist/components/PanelDrawer/PanelPreview.d.ts +4 -0
- package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -0
- package/dist/components/PanelDrawer/PanelPreview.js +41 -0
- package/dist/components/PanelDrawer/PanelPreview.js.map +1 -0
- package/dist/components/PanelDrawer/index.d.ts +2 -0
- package/dist/components/PanelDrawer/index.d.ts.map +1 -0
- package/dist/components/PanelDrawer/index.js +15 -0
- package/dist/components/PanelDrawer/index.js.map +1 -0
- package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts +6 -0
- package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -0
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js +92 -0
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -0
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.d.ts +2 -0
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.d.ts.map +1 -0
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js +80 -0
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js.map +1 -0
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts +12 -0
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts.map +1 -0
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js +82 -0
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js.map +1 -0
- package/dist/components/PanelGroupDialog/index.d.ts +2 -0
- package/dist/components/PanelGroupDialog/index.d.ts.map +1 -0
- package/dist/components/PanelGroupDialog/index.js +15 -0
- package/dist/components/PanelGroupDialog/index.js.map +1 -0
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts +9 -0
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -0
- package/dist/components/TimeRangeControls/TimeRangeControls.js +119 -0
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -0
- package/dist/components/TimeRangeControls/TimeRangeControls.test.d.ts +2 -0
- package/dist/components/TimeRangeControls/TimeRangeControls.test.d.ts.map +1 -0
- package/dist/components/TimeRangeControls/TimeRangeControls.test.js +88 -0
- package/dist/components/TimeRangeControls/TimeRangeControls.test.js.map +1 -0
- package/dist/components/TimeRangeControls/index.d.ts +2 -0
- package/dist/components/TimeRangeControls/index.d.ts.map +1 -0
- package/dist/components/TimeRangeControls/index.js +15 -0
- package/dist/components/TimeRangeControls/index.js.map +1 -0
- package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.d.ts +8 -0
- package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.d.ts.map +1 -0
- package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.js +56 -0
- package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.js.map +1 -0
- package/dist/components/UnsavedChangesConfirmationDialog/index.d.ts +2 -0
- package/dist/components/UnsavedChangesConfirmationDialog/index.d.ts.map +1 -0
- package/dist/components/UnsavedChangesConfirmationDialog/index.js +15 -0
- package/dist/components/UnsavedChangesConfirmationDialog/index.js.map +1 -0
- package/dist/components/Variables/Variable.d.ts +8 -0
- package/dist/components/Variables/Variable.d.ts.map +1 -0
- package/dist/components/Variables/Variable.js +188 -0
- package/dist/components/Variables/Variable.js.map +1 -0
- package/dist/components/Variables/VariableEditor.d.ts +8 -0
- package/dist/components/Variables/VariableEditor.d.ts.map +1 -0
- package/dist/components/Variables/VariableEditor.js +265 -0
- package/dist/components/Variables/VariableEditor.js.map +1 -0
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +8 -0
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -0
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +409 -0
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -0
- package/dist/components/Variables/VariableEditorForm/index.d.ts +2 -0
- package/dist/components/Variables/VariableEditorForm/index.d.ts.map +1 -0
- package/dist/components/Variables/VariableEditorForm/index.js +15 -0
- package/dist/components/Variables/VariableEditorForm/index.js.map +1 -0
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +22 -0
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -0
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +77 -0
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -0
- package/dist/components/Variables/VariableList.d.ts +9 -0
- package/dist/components/Variables/VariableList.d.ts.map +1 -0
- package/dist/components/Variables/VariableList.js +100 -0
- package/dist/components/Variables/VariableList.js.map +1 -0
- package/dist/components/Variables/index.d.ts +4 -0
- package/dist/components/Variables/index.d.ts.map +1 -0
- package/dist/components/Variables/index.js +17 -0
- package/dist/components/Variables/index.js.map +1 -0
- package/dist/components/Variables/variable-model.d.ts +16 -0
- package/dist/components/Variables/variable-model.d.ts.map +1 -0
- package/dist/components/Variables/variable-model.js +105 -0
- package/dist/components/Variables/variable-model.js.map +1 -0
- package/dist/components/Variables/variable-model.test.d.ts +2 -0
- package/dist/components/Variables/variable-model.test.d.ts.map +1 -0
- package/dist/components/Variables/variable-model.test.js +104 -0
- package/dist/components/Variables/variable-model.test.js.map +1 -0
- package/dist/components/index.d.ts +13 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +26 -0
- package/dist/components/index.js.map +1 -0
- package/dist/context/DashboardProvider/DashboardProvider.d.ts +28 -0
- package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -0
- package/dist/context/DashboardProvider/DashboardProvider.js +77 -0
- package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -0
- package/dist/context/DashboardProvider/common.d.ts +12 -0
- package/dist/context/DashboardProvider/common.d.ts.map +1 -0
- package/dist/context/DashboardProvider/common.js +24 -0
- package/dist/context/DashboardProvider/common.js.map +1 -0
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +74 -0
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -0
- package/dist/context/DashboardProvider/dashboard-provider-api.js +190 -0
- package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -0
- package/dist/context/DashboardProvider/delete-panel-group-slice.d.ts +23 -0
- package/dist/context/DashboardProvider/delete-panel-group-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/delete-panel-group-slice.js +64 -0
- package/dist/context/DashboardProvider/delete-panel-group-slice.js.map +1 -0
- package/dist/context/DashboardProvider/delete-panel-slice.d.ts +36 -0
- package/dist/context/DashboardProvider/delete-panel-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/delete-panel-slice.js +81 -0
- package/dist/context/DashboardProvider/delete-panel-slice.js.map +1 -0
- package/dist/context/DashboardProvider/index.d.ts +7 -0
- package/dist/context/DashboardProvider/index.d.ts.map +1 -0
- package/dist/context/DashboardProvider/index.js +16 -0
- package/dist/context/DashboardProvider/index.js.map +1 -0
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts +56 -0
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/panel-editor-slice.js +201 -0
- package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -0
- package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts +33 -0
- package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/panel-group-editor-slice.js +79 -0
- package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -0
- package/dist/context/DashboardProvider/panel-group-slice.d.ts +59 -0
- package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/panel-group-slice.js +105 -0
- package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -0
- package/dist/context/DashboardProvider/panel-slice.d.ts +14 -0
- package/dist/context/DashboardProvider/panel-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/panel-slice.js +21 -0
- package/dist/context/DashboardProvider/panel-slice.js.map +1 -0
- package/dist/context/DatasourceStoreProvider.d.ts +24 -0
- package/dist/context/DatasourceStoreProvider.d.ts.map +1 -0
- package/dist/context/DatasourceStoreProvider.js +166 -0
- package/dist/context/DatasourceStoreProvider.js.map +1 -0
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts +30 -0
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts.map +1 -0
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js +212 -0
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js.map +1 -0
- package/dist/context/TemplateVariableProvider/index.d.ts +2 -0
- package/dist/context/TemplateVariableProvider/index.d.ts.map +1 -0
- package/dist/context/TemplateVariableProvider/index.js +15 -0
- package/dist/context/TemplateVariableProvider/index.js.map +1 -0
- package/dist/context/TemplateVariableProvider/query-params.d.ts +12 -0
- package/dist/context/TemplateVariableProvider/query-params.d.ts.map +1 -0
- package/dist/context/TemplateVariableProvider/query-params.js +66 -0
- package/dist/context/TemplateVariableProvider/query-params.js.map +1 -0
- package/dist/context/TemplateVariableProvider/query-params.test.d.ts +2 -0
- package/dist/context/TemplateVariableProvider/query-params.test.d.ts.map +1 -0
- package/dist/context/TemplateVariableProvider/query-params.test.js +80 -0
- package/dist/context/TemplateVariableProvider/query-params.test.js.map +1 -0
- package/dist/context/index.d.ts +5 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js +18 -0
- package/dist/context/index.js.map +1 -0
- package/dist/context/useDashboard.d.ts +6 -0
- package/dist/context/useDashboard.d.ts.map +1 -0
- package/dist/context/useDashboard.js +88 -0
- package/dist/context/useDashboard.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/test/dashboard-provider.d.ts +19 -0
- package/dist/test/dashboard-provider.d.ts.map +1 -0
- package/dist/test/dashboard-provider.js +40 -0
- package/dist/test/dashboard-provider.js.map +1 -0
- package/dist/test/index.d.ts +4 -0
- package/dist/test/index.d.ts.map +1 -0
- package/dist/test/index.js +17 -0
- package/dist/test/index.js.map +1 -0
- package/dist/test/plugin-registry.d.ts +3 -0
- package/dist/test/plugin-registry.d.ts.map +1 -0
- package/dist/test/plugin-registry.js +37 -0
- package/dist/test/plugin-registry.js.map +1 -0
- package/dist/test/render.d.ts +8 -0
- package/dist/test/render.d.ts.map +1 -0
- package/dist/test/render.js +58 -0
- package/dist/test/render.js.map +1 -0
- package/dist/test/setup-tests.d.ts +2 -0
- package/dist/test/setup-tests.d.ts.map +1 -0
- package/dist/test/setup-tests.js +22 -0
- package/dist/test/setup-tests.js.map +1 -0
- package/dist/test/testDashboard.d.ts +4 -0
- package/dist/test/testDashboard.d.ts.map +1 -0
- package/dist/test/testDashboard.js +287 -0
- package/dist/test/testDashboard.js.map +1 -0
- package/dist/utils/functions.d.ts +2 -0
- package/dist/utils/functions.d.ts.map +1 -0
- package/dist/utils/functions.js +17 -0
- package/dist/utils/functions.js.map +1 -0
- package/dist/views/ViewDashboard/DashboardApp.d.ts +10 -0
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -0
- package/dist/views/ViewDashboard/DashboardApp.js +90 -0
- package/dist/views/ViewDashboard/DashboardApp.js.map +1 -0
- package/dist/views/ViewDashboard/ViewDashboard.d.ts +16 -0
- package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -0
- package/dist/views/ViewDashboard/ViewDashboard.js +64 -0
- package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -0
- package/dist/views/ViewDashboard/index.d.ts +2 -0
- package/dist/views/ViewDashboard/index.d.ts.map +1 -0
- package/dist/views/ViewDashboard/index.js +15 -0
- package/dist/views/ViewDashboard/index.js.map +1 -0
- package/dist/views/ViewDashboard/tests/panelGroups.test.d.ts +2 -0
- package/dist/views/ViewDashboard/tests/panelGroups.test.d.ts.map +1 -0
- package/dist/views/ViewDashboard/tests/panelGroups.test.js +103 -0
- package/dist/views/ViewDashboard/tests/panelGroups.test.js.map +1 -0
- package/dist/views/index.d.ts +2 -0
- package/dist/views/index.d.ts.map +1 -0
- package/dist/views/index.js +15 -0
- package/dist/views/index.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
function _export(target, all) {
|
|
18
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: all[name]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
createPanelGroupSlice: ()=>createPanelGroupSlice,
|
|
25
|
+
convertLayoutsToPanelGroups: ()=>convertLayoutsToPanelGroups,
|
|
26
|
+
createEmptyPanelGroup: ()=>createEmptyPanelGroup,
|
|
27
|
+
addPanelGroup: ()=>addPanelGroup
|
|
28
|
+
});
|
|
29
|
+
const _core = require("@perses-dev/core");
|
|
30
|
+
const _common = require("./common");
|
|
31
|
+
function createPanelGroupSlice(layouts) {
|
|
32
|
+
const { panelGroups , panelGroupOrder } = convertLayoutsToPanelGroups(layouts);
|
|
33
|
+
// Return the state creator function for Zustand
|
|
34
|
+
return (set)=>({
|
|
35
|
+
panelGroups,
|
|
36
|
+
panelGroupOrder,
|
|
37
|
+
swapPanelGroups (x, y) {
|
|
38
|
+
set((state)=>{
|
|
39
|
+
if (x < 0 || x >= state.panelGroupOrder.length || y < 0 || y >= state.panelGroupOrder.length) {
|
|
40
|
+
throw new Error('index out of bound');
|
|
41
|
+
}
|
|
42
|
+
const xPanelGroup = state.panelGroupOrder[x];
|
|
43
|
+
const yPanelGroup = state.panelGroupOrder[y];
|
|
44
|
+
if (xPanelGroup === undefined || yPanelGroup === undefined) {
|
|
45
|
+
throw new Error('panel group is undefined');
|
|
46
|
+
}
|
|
47
|
+
// assign yPanelGroup to layouts[x] and assign xGroup to layouts[y], swapping two panel groups
|
|
48
|
+
[state.panelGroupOrder[x], state.panelGroupOrder[y]] = [
|
|
49
|
+
yPanelGroup,
|
|
50
|
+
xPanelGroup
|
|
51
|
+
];
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
updatePanelGroupLayouts (panelGroupId, itemLayouts) {
|
|
55
|
+
set((state)=>{
|
|
56
|
+
const group = state.panelGroups[panelGroupId];
|
|
57
|
+
if (group === undefined) {
|
|
58
|
+
throw new Error(`Cannot find panel group ${panelGroupId}`);
|
|
59
|
+
}
|
|
60
|
+
group.itemLayouts = itemLayouts;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function convertLayoutsToPanelGroups(layouts) {
|
|
66
|
+
// Convert the initial layouts from the JSON
|
|
67
|
+
const panelGroups = {};
|
|
68
|
+
const panelGroupIdOrder = [];
|
|
69
|
+
for (const layout of layouts){
|
|
70
|
+
var ref, ref1, ref2;
|
|
71
|
+
const itemLayouts = [];
|
|
72
|
+
const itemPanelKeys = {};
|
|
73
|
+
// Split layout information from panel keys to make it easier to update just layouts on move/resize of panels
|
|
74
|
+
for (const item of layout.spec.items){
|
|
75
|
+
const panelGroupLayoutId = (0, _common.generateId)().toString();
|
|
76
|
+
itemLayouts.push({
|
|
77
|
+
i: panelGroupLayoutId,
|
|
78
|
+
w: item.width,
|
|
79
|
+
h: item.height,
|
|
80
|
+
x: item.x,
|
|
81
|
+
y: item.y
|
|
82
|
+
});
|
|
83
|
+
itemPanelKeys[panelGroupLayoutId] = (0, _core.getPanelKeyFromRef)(item.content);
|
|
84
|
+
}
|
|
85
|
+
// Create the panel group and keep track of the ID order
|
|
86
|
+
const panelGroupId = (0, _common.generateId)();
|
|
87
|
+
panelGroups[panelGroupId] = {
|
|
88
|
+
id: panelGroupId,
|
|
89
|
+
isCollapsed: ((ref = layout.spec.display) === null || ref === void 0 ? void 0 : (ref1 = ref.collapse) === null || ref1 === void 0 ? void 0 : ref1.open) === false,
|
|
90
|
+
title: (ref2 = layout.spec.display) === null || ref2 === void 0 ? void 0 : ref2.title,
|
|
91
|
+
itemLayouts,
|
|
92
|
+
itemPanelKeys
|
|
93
|
+
};
|
|
94
|
+
panelGroupIdOrder.push(panelGroupId);
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
panelGroups,
|
|
98
|
+
panelGroupOrder: panelGroupIdOrder
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function createEmptyPanelGroup() {
|
|
102
|
+
return {
|
|
103
|
+
id: (0, _common.generateId)(),
|
|
104
|
+
title: undefined,
|
|
105
|
+
isCollapsed: false,
|
|
106
|
+
itemLayouts: [],
|
|
107
|
+
itemPanelKeys: {}
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
function addPanelGroup(draft, newGroup) {
|
|
111
|
+
draft.panelGroups[newGroup.id] = newGroup;
|
|
112
|
+
draft.panelGroupOrder.unshift(newGroup.id);
|
|
113
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "createPanelSlice", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>createPanelSlice
|
|
20
|
+
});
|
|
21
|
+
function createPanelSlice(panels) {
|
|
22
|
+
return ()=>({
|
|
23
|
+
panels
|
|
24
|
+
});
|
|
25
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "DatasourceStoreProvider", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>DatasourceStoreProvider
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _react = require("react");
|
|
23
|
+
const _core = require("@perses-dev/core");
|
|
24
|
+
const _pluginSystem = require("@perses-dev/plugin-system");
|
|
25
|
+
function DatasourceStoreProvider(props) {
|
|
26
|
+
const { dashboardResource , datasourceApi , children } = props;
|
|
27
|
+
const { project } = dashboardResource.metadata;
|
|
28
|
+
const { getPlugin , listPluginMetadata } = (0, _pluginSystem.usePluginRegistry)();
|
|
29
|
+
const findDatasource = (0, _core.useEvent)(async (selector)=>{
|
|
30
|
+
// Try to find it in dashboard spec
|
|
31
|
+
const { datasources } = dashboardResource.spec;
|
|
32
|
+
const dashboardDatasource = findDashboardDatasource(datasources, selector);
|
|
33
|
+
if (dashboardDatasource !== undefined) {
|
|
34
|
+
return {
|
|
35
|
+
spec: dashboardDatasource,
|
|
36
|
+
proxyUrl: undefined
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
// Try to find it at the project level as a Datasource resource
|
|
40
|
+
const datasource = await datasourceApi.getDatasource(project, selector);
|
|
41
|
+
if (datasource !== undefined) {
|
|
42
|
+
return {
|
|
43
|
+
spec: datasource.resource.spec,
|
|
44
|
+
proxyUrl: datasource.proxyUrl
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
// Try to find it at the global level as a GlobalDatasource resource
|
|
48
|
+
const globalDatasource = await datasourceApi.getGlobalDatasource(selector);
|
|
49
|
+
if (globalDatasource !== undefined) {
|
|
50
|
+
return {
|
|
51
|
+
spec: globalDatasource.resource.spec,
|
|
52
|
+
proxyUrl: globalDatasource.proxyUrl
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
throw new Error(`No datasource found for kind '${selector.kind}' and name '${selector.name}'`);
|
|
56
|
+
});
|
|
57
|
+
// Gets a datasource spec for a given selector
|
|
58
|
+
const getDatasource = (0, _react.useCallback)(async (selector)=>{
|
|
59
|
+
const { spec } = await findDatasource(selector);
|
|
60
|
+
return spec;
|
|
61
|
+
}, [
|
|
62
|
+
findDatasource
|
|
63
|
+
]);
|
|
64
|
+
// Given a Datasource selector, finds the spec for it and then uses its corresponding plugin the create a client
|
|
65
|
+
const getDatasourceClient = (0, _react.useCallback)(async function getClient(selector) {
|
|
66
|
+
const { kind } = selector;
|
|
67
|
+
const [{ spec , proxyUrl }, plugin] = await Promise.all([
|
|
68
|
+
findDatasource(selector),
|
|
69
|
+
getPlugin('Datasource', kind)
|
|
70
|
+
]);
|
|
71
|
+
return plugin.createClient(spec.plugin.spec, {
|
|
72
|
+
proxyUrl
|
|
73
|
+
});
|
|
74
|
+
}, [
|
|
75
|
+
findDatasource,
|
|
76
|
+
getPlugin
|
|
77
|
+
]);
|
|
78
|
+
const listDatasourceMetadata = (0, _core.useEvent)(async (datasourcePluginKind)=>{
|
|
79
|
+
const [pluginMetadata, datasources, globalDatasources] = await Promise.all([
|
|
80
|
+
listPluginMetadata('Datasource'),
|
|
81
|
+
datasourceApi.listDatasources(project, datasourcePluginKind),
|
|
82
|
+
datasourceApi.listGlobalDatasources(datasourcePluginKind)
|
|
83
|
+
]);
|
|
84
|
+
// Find the metadata for the plugin type they asked for so we can use it for the name of the default datasource
|
|
85
|
+
const datasourcePluginMetadata = pluginMetadata.find((metadata)=>metadata.kind === datasourcePluginKind);
|
|
86
|
+
if (datasourcePluginMetadata === undefined) {
|
|
87
|
+
throw new Error(`Could not find a Datasource plugin with kind '${datasourcePluginKind}'`);
|
|
88
|
+
}
|
|
89
|
+
// Get helper for de-duping results properly
|
|
90
|
+
const { results , addResult } = buildListDatasourceMetadataResults(datasourcePluginMetadata.display.name);
|
|
91
|
+
// Start with dashboard datasources that have highest precedence
|
|
92
|
+
if (dashboardResource.spec.datasources !== undefined) {
|
|
93
|
+
for(const selectorName in dashboardResource.spec.datasources){
|
|
94
|
+
const spec = dashboardResource.spec.datasources[selectorName];
|
|
95
|
+
if (spec === undefined || spec.plugin.kind !== datasourcePluginKind) continue;
|
|
96
|
+
addResult(spec, selectorName);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// Now look at project-level datasources
|
|
100
|
+
for (const datasource of datasources){
|
|
101
|
+
const selectorName1 = datasource.metadata.name;
|
|
102
|
+
addResult(datasource.spec, selectorName1);
|
|
103
|
+
}
|
|
104
|
+
// And finally global datasources
|
|
105
|
+
for (const globalDatasource of globalDatasources){
|
|
106
|
+
const selectorName2 = globalDatasource.metadata.name;
|
|
107
|
+
addResult(globalDatasource.spec, selectorName2);
|
|
108
|
+
}
|
|
109
|
+
return results;
|
|
110
|
+
});
|
|
111
|
+
const ctxValue = (0, _react.useMemo)(()=>({
|
|
112
|
+
getDatasource,
|
|
113
|
+
getDatasourceClient,
|
|
114
|
+
listDatasourceMetadata
|
|
115
|
+
}), [
|
|
116
|
+
getDatasource,
|
|
117
|
+
getDatasourceClient,
|
|
118
|
+
listDatasourceMetadata
|
|
119
|
+
]);
|
|
120
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.DatasourceStoreContext.Provider, {
|
|
121
|
+
value: ctxValue,
|
|
122
|
+
children: children
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
// Helper to find a datasource in the list embedded in a dashboard spec
|
|
126
|
+
function findDashboardDatasource(dashboardDatasources, selector) {
|
|
127
|
+
if (dashboardDatasources === undefined) return undefined;
|
|
128
|
+
// If using a name in the selector...
|
|
129
|
+
if (selector.name !== undefined) {
|
|
130
|
+
const named = dashboardDatasources[selector.name];
|
|
131
|
+
if (named === undefined) return undefined;
|
|
132
|
+
return named.plugin.kind === selector.kind ? named : undefined;
|
|
133
|
+
}
|
|
134
|
+
// If only using a kind, try to find one with that kind that is the default
|
|
135
|
+
return Object.values(dashboardDatasources).find((ds)=>ds.plugin.kind === selector.kind && ds.default === true);
|
|
136
|
+
}
|
|
137
|
+
// Helper for building a list of DatasourceMetadata results that will take care of de-duping already used selectors
|
|
138
|
+
function buildListDatasourceMetadataResults(pluginDisplayName) {
|
|
139
|
+
const results = [];
|
|
140
|
+
const usedNames = new Set();
|
|
141
|
+
let defaultAdded = false;
|
|
142
|
+
const addResult = (spec, selectorName)=>{
|
|
143
|
+
var ref;
|
|
144
|
+
// If we haven't added a default yet and this is a default, add default option to the beginning of the results
|
|
145
|
+
if (spec.default && defaultAdded === false) {
|
|
146
|
+
results.unshift({
|
|
147
|
+
name: `Default ${pluginDisplayName}`,
|
|
148
|
+
selector: {
|
|
149
|
+
kind: spec.plugin.kind
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
defaultAdded = true;
|
|
153
|
+
}
|
|
154
|
+
// If we already have a datasource with this selector name, ignore it, otherwise add to end of list
|
|
155
|
+
if (usedNames.has(selectorName)) return;
|
|
156
|
+
var ref1;
|
|
157
|
+
results.push({
|
|
158
|
+
name: (ref1 = (ref = spec.display) === null || ref === void 0 ? void 0 : ref.name) !== null && ref1 !== void 0 ? ref1 : selectorName,
|
|
159
|
+
selector: {
|
|
160
|
+
kind: spec.plugin.kind,
|
|
161
|
+
name: selectorName
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
usedNames.add(selectorName);
|
|
165
|
+
};
|
|
166
|
+
return {
|
|
167
|
+
results,
|
|
168
|
+
addResult
|
|
169
|
+
};
|
|
170
|
+
}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
function _export(target, all) {
|
|
18
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: all[name]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
useTemplateVariableValues: ()=>useTemplateVariableValues,
|
|
25
|
+
useTemplateVariable: ()=>useTemplateVariable,
|
|
26
|
+
useTemplateVariableActions: ()=>useTemplateVariableActions,
|
|
27
|
+
useTemplateVariableDefinitions: ()=>useTemplateVariableDefinitions,
|
|
28
|
+
useTemplateVariableStore: ()=>useTemplateVariableStore,
|
|
29
|
+
TemplateVariableProvider: ()=>TemplateVariableProvider
|
|
30
|
+
});
|
|
31
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
32
|
+
const _react = require("react");
|
|
33
|
+
const _zustand = require("zustand");
|
|
34
|
+
const _immer = require("zustand/middleware/immer");
|
|
35
|
+
const _middleware = require("zustand/middleware");
|
|
36
|
+
const _pluginSystem = require("@perses-dev/plugin-system");
|
|
37
|
+
const _queryParams = require("./query-params");
|
|
38
|
+
const TemplateVariableStoreContext = /*#__PURE__*/ (0, _react.createContext)(undefined);
|
|
39
|
+
function useTemplateVariableStoreCtx() {
|
|
40
|
+
const context = (0, _react.useContext)(TemplateVariableStoreContext);
|
|
41
|
+
if (!context) {
|
|
42
|
+
throw new Error('TemplateVariableStoreContext not initialized');
|
|
43
|
+
}
|
|
44
|
+
return context;
|
|
45
|
+
}
|
|
46
|
+
function useTemplateVariableValues(variableNames) {
|
|
47
|
+
const store = useTemplateVariableStoreCtx();
|
|
48
|
+
const state = (0, _zustand.useStore)(store, (s)=>{
|
|
49
|
+
const names = variableNames !== null && variableNames !== void 0 ? variableNames : Object.keys(s.variableState);
|
|
50
|
+
const vars = {};
|
|
51
|
+
names.forEach((name)=>{
|
|
52
|
+
const varState = s.variableState[name];
|
|
53
|
+
if (!varState) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
vars[name] = varState;
|
|
57
|
+
});
|
|
58
|
+
return vars;
|
|
59
|
+
}, (left, right)=>{
|
|
60
|
+
return JSON.stringify(left) === JSON.stringify(right);
|
|
61
|
+
});
|
|
62
|
+
return state;
|
|
63
|
+
}
|
|
64
|
+
function useTemplateVariable(name) {
|
|
65
|
+
const store = useTemplateVariableStoreCtx();
|
|
66
|
+
return (0, _zustand.useStore)(store, (s)=>{
|
|
67
|
+
const variableState = s.variableState[name];
|
|
68
|
+
const definition = s.variableDefinitions.find((v)=>v.spec.name === name);
|
|
69
|
+
return {
|
|
70
|
+
state: variableState,
|
|
71
|
+
definition
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function useTemplateVariableActions() {
|
|
76
|
+
const store = useTemplateVariableStoreCtx();
|
|
77
|
+
return (0, _zustand.useStore)(store, (s)=>{
|
|
78
|
+
return {
|
|
79
|
+
setVariableValue: s.setVariableValue,
|
|
80
|
+
setVariableLoading: s.setVariableLoading,
|
|
81
|
+
setVariableOptions: s.setVariableOptions,
|
|
82
|
+
setVariableDefinitions: s.setVariableDefinitions
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function useTemplateVariableDefinitions() {
|
|
87
|
+
const store = useTemplateVariableStoreCtx();
|
|
88
|
+
return (0, _zustand.useStore)(store, (s)=>s.variableDefinitions);
|
|
89
|
+
}
|
|
90
|
+
function useTemplateVariableStore() {
|
|
91
|
+
const store = useTemplateVariableStoreCtx();
|
|
92
|
+
return (0, _zustand.useStore)(store);
|
|
93
|
+
}
|
|
94
|
+
function PluginProvider({ children }) {
|
|
95
|
+
const originalValues = useTemplateVariableValues();
|
|
96
|
+
const values = (0, _react.useMemo)(()=>{
|
|
97
|
+
const contextValues = {};
|
|
98
|
+
// This will loop through all the current variables values
|
|
99
|
+
// and update any variables that have ALL_VALUE as their current value
|
|
100
|
+
// to include all options.
|
|
101
|
+
Object.keys(originalValues).forEach((name)=>{
|
|
102
|
+
const v = {
|
|
103
|
+
...originalValues[name]
|
|
104
|
+
};
|
|
105
|
+
if (v.value === _pluginSystem.DEFAULT_ALL_VALUE) {
|
|
106
|
+
var ref;
|
|
107
|
+
var ref1;
|
|
108
|
+
v.value = (ref1 = (ref = v.options) === null || ref === void 0 ? void 0 : ref.map((o)=>o.value)) !== null && ref1 !== void 0 ? ref1 : null;
|
|
109
|
+
}
|
|
110
|
+
contextValues[name] = v;
|
|
111
|
+
});
|
|
112
|
+
return contextValues;
|
|
113
|
+
}, [
|
|
114
|
+
originalValues
|
|
115
|
+
]);
|
|
116
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.TemplateVariableContext.Provider, {
|
|
117
|
+
value: {
|
|
118
|
+
state: values
|
|
119
|
+
},
|
|
120
|
+
children: children
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
function createTemplateVariableSrvStore({ initialVariableDefinitions =[] , queryParams }) {
|
|
124
|
+
const initialParams = (0, _queryParams.getInitalValuesFromQueryParameters)(queryParams ? queryParams[0] : {});
|
|
125
|
+
const store = (0, _zustand.createStore)()((0, _middleware.devtools)((0, _immer.immer)((set)=>({
|
|
126
|
+
variableState: hydrateTemplateVariableStates(initialVariableDefinitions, initialParams),
|
|
127
|
+
variableDefinitions: initialVariableDefinitions,
|
|
128
|
+
setVariableDefinitions (definitions) {
|
|
129
|
+
set((state)=>{
|
|
130
|
+
state.variableDefinitions = definitions;
|
|
131
|
+
state.variableState = hydrateTemplateVariableStates(definitions, initialParams);
|
|
132
|
+
});
|
|
133
|
+
},
|
|
134
|
+
setVariableOptions (name, options) {
|
|
135
|
+
set((state)=>{
|
|
136
|
+
const varState = state.variableState[name];
|
|
137
|
+
if (!varState) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
varState.options = options;
|
|
141
|
+
});
|
|
142
|
+
},
|
|
143
|
+
setVariableLoading (name, loading) {
|
|
144
|
+
set((state)=>{
|
|
145
|
+
const varState = state.variableState[name];
|
|
146
|
+
if (!varState) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
varState.loading = loading;
|
|
150
|
+
});
|
|
151
|
+
},
|
|
152
|
+
setVariableValue: (name, value)=>set((state)=>{
|
|
153
|
+
let val = value;
|
|
154
|
+
const varState = state.variableState[name];
|
|
155
|
+
if (!varState) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
// Make sure there is only one all value
|
|
159
|
+
if (Array.isArray(val) && val.includes(_pluginSystem.DEFAULT_ALL_VALUE)) {
|
|
160
|
+
if (val.at(-1) === _pluginSystem.DEFAULT_ALL_VALUE) {
|
|
161
|
+
val = _pluginSystem.DEFAULT_ALL_VALUE;
|
|
162
|
+
} else {
|
|
163
|
+
val = val.filter((v)=>v !== _pluginSystem.DEFAULT_ALL_VALUE);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (queryParams) {
|
|
167
|
+
const setQueryParams = queryParams[1];
|
|
168
|
+
setQueryParams({
|
|
169
|
+
[(0, _queryParams.getURLQueryParamName)(name)]: val
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
varState.value = val;
|
|
173
|
+
})
|
|
174
|
+
}))));
|
|
175
|
+
return store;
|
|
176
|
+
}
|
|
177
|
+
function TemplateVariableProvider({ children , initialVariableDefinitions =[] }) {
|
|
178
|
+
const queryParams = (0, _queryParams.useVariableQueryParams)(initialVariableDefinitions);
|
|
179
|
+
const [store] = (0, _react.useState)(createTemplateVariableSrvStore({
|
|
180
|
+
initialVariableDefinitions,
|
|
181
|
+
queryParams
|
|
182
|
+
}));
|
|
183
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(TemplateVariableStoreContext.Provider, {
|
|
184
|
+
value: store,
|
|
185
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(PluginProvider, {
|
|
186
|
+
children: children
|
|
187
|
+
})
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
/** Helpers */ function hydrateTemplateVariableState(definition, initialValue) {
|
|
191
|
+
const v = definition;
|
|
192
|
+
var ref;
|
|
193
|
+
const varState = {
|
|
194
|
+
value: (ref = initialValue !== null && initialValue !== void 0 ? initialValue : v.spec.default_value) !== null && ref !== void 0 ? ref : null,
|
|
195
|
+
loading: false
|
|
196
|
+
};
|
|
197
|
+
switch(v.kind){
|
|
198
|
+
case 'TextVariable':
|
|
199
|
+
varState.value = initialValue !== null && initialValue !== void 0 ? initialValue : v.spec.value;
|
|
200
|
+
break;
|
|
201
|
+
case 'ListVariable':
|
|
202
|
+
varState.options = [];
|
|
203
|
+
if (varState.options.length > 0 && !varState.value) {
|
|
204
|
+
var ref1;
|
|
205
|
+
var ref2;
|
|
206
|
+
const firstOptionValue = (ref2 = (ref1 = varState.options[0]) === null || ref1 === void 0 ? void 0 : ref1.value) !== null && ref2 !== void 0 ? ref2 : null;
|
|
207
|
+
if (firstOptionValue !== null) {
|
|
208
|
+
varState.value = v.spec.allow_multiple ? [
|
|
209
|
+
firstOptionValue
|
|
210
|
+
] : firstOptionValue;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
break;
|
|
214
|
+
default:
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
return varState;
|
|
218
|
+
}
|
|
219
|
+
function hydrateTemplateVariableStates(definitions, initialValues) {
|
|
220
|
+
const state = {};
|
|
221
|
+
definitions.forEach((v)=>{
|
|
222
|
+
const name = v.spec.name;
|
|
223
|
+
const param = initialValues[name];
|
|
224
|
+
const initialValue = param ? param : null;
|
|
225
|
+
state[name] = hydrateTemplateVariableState(v, initialValue);
|
|
226
|
+
});
|
|
227
|
+
return state;
|
|
228
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
_exportStar(require("./TemplateVariableProvider"), exports);
|
|
18
|
+
function _exportStar(from, to) {
|
|
19
|
+
Object.keys(from).forEach(function(k) {
|
|
20
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function() {
|
|
23
|
+
return from[k];
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
return from;
|
|
28
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
function _export(target, all) {
|
|
18
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: all[name]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
getURLQueryParamName: ()=>getURLQueryParamName,
|
|
25
|
+
encodeVariableValue: ()=>encodeVariableValue,
|
|
26
|
+
decodeVariableValue: ()=>decodeVariableValue,
|
|
27
|
+
useVariableQueryParams: ()=>useVariableQueryParams,
|
|
28
|
+
getInitalValuesFromQueryParameters: ()=>getInitalValuesFromQueryParameters
|
|
29
|
+
});
|
|
30
|
+
const _useQueryParams = require("use-query-params");
|
|
31
|
+
const variableQueryParameterPrefix = 'var-';
|
|
32
|
+
function getURLQueryParamName(name) {
|
|
33
|
+
return `${variableQueryParameterPrefix}${name}`;
|
|
34
|
+
}
|
|
35
|
+
function encodeVariableValue(value) {
|
|
36
|
+
if (Array.isArray(value)) {
|
|
37
|
+
return value.join(',');
|
|
38
|
+
}
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
function decodeVariableValue(value) {
|
|
42
|
+
if (!value) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
const values = value.split(',');
|
|
46
|
+
if (values.length === 1) {
|
|
47
|
+
return values[0];
|
|
48
|
+
}
|
|
49
|
+
return values;
|
|
50
|
+
}
|
|
51
|
+
const VariableValueParam = {
|
|
52
|
+
encode: encodeVariableValue,
|
|
53
|
+
decode: (v)=>{
|
|
54
|
+
if (typeof v === 'string') {
|
|
55
|
+
return decodeVariableValue(v);
|
|
56
|
+
}
|
|
57
|
+
return '';
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
function useVariableQueryParams(defs) {
|
|
61
|
+
const config = {};
|
|
62
|
+
defs.forEach((def)=>{
|
|
63
|
+
const name = getURLQueryParamName(def.spec.name);
|
|
64
|
+
config[name] = VariableValueParam;
|
|
65
|
+
});
|
|
66
|
+
return (0, _useQueryParams.useQueryParams)(config, {
|
|
67
|
+
updateType: 'replaceIn'
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
function getInitalValuesFromQueryParameters(queryParamValues) {
|
|
71
|
+
const values = {};
|
|
72
|
+
Object.keys(queryParamValues).forEach((key)=>{
|
|
73
|
+
const value = queryParamValues[key];
|
|
74
|
+
if (!value) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const name = key.replace(variableQueryParameterPrefix, '');
|
|
78
|
+
values[name] = value;
|
|
79
|
+
});
|
|
80
|
+
return values;
|
|
81
|
+
}
|