@perses-dev/dashboards 0.39.0 → 0.40.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/AddGroupButton/AddGroupButton.js +9 -7
- package/dist/cjs/components/AddGroupButton/index.js +10 -8
- package/dist/cjs/components/AddPanelButton/AddPanelButton.js +9 -7
- package/dist/cjs/components/AddPanelButton/index.js +10 -8
- package/dist/cjs/components/Dashboard/Dashboard.js +11 -9
- package/dist/cjs/components/Dashboard/index.js +10 -8
- package/dist/cjs/components/DashboardStickyToolbar/DashboardStickyToolbar.js +18 -16
- package/dist/cjs/components/DashboardStickyToolbar/index.js +10 -8
- package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +43 -41
- package/dist/cjs/components/DashboardToolbar/index.js +10 -8
- package/dist/cjs/components/DeletePanelDialog/DeletePanelDialog.js +12 -10
- package/dist/cjs/components/DeletePanelDialog/index.js +10 -8
- package/dist/cjs/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +17 -15
- package/dist/cjs/components/DeletePanelGroupDialog/index.js +10 -8
- package/dist/cjs/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js +5 -3
- package/dist/cjs/components/DiscardChangesConfirmationDialog/index.js +10 -8
- package/dist/cjs/components/DownloadButton/DownloadButton.js +12 -10
- package/dist/cjs/components/DownloadButton/index.js +10 -8
- package/dist/cjs/components/EditButton/EditButton.js +8 -6
- package/dist/cjs/components/EditButton/index.js +10 -8
- package/dist/cjs/components/EditJsonButton/EditJsonButton.js +10 -8
- package/dist/cjs/components/EditJsonButton/index.js +10 -8
- package/dist/cjs/components/EditJsonDialog/EditJsonDialog.js +29 -23
- package/dist/cjs/components/EditJsonDialog/index.js +10 -8
- package/dist/cjs/components/EmptyDashboard/EmptyDashboard.js +18 -16
- package/dist/cjs/components/EmptyDashboard/index.js +10 -8
- package/dist/cjs/components/GridLayout/GridContainer.js +5 -3
- package/dist/cjs/components/GridLayout/GridItemContent.js +33 -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 +17 -22
- package/dist/cjs/components/Panel/PanelContent.js +8 -6
- 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 +269 -141
- package/dist/cjs/components/PanelDrawer/PanelPreview.js +11 -9
- package/dist/cjs/components/PanelDrawer/index.js +10 -8
- package/dist/cjs/components/PanelDrawer/usePanelEditor.js +3 -1
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +18 -16
- package/dist/cjs/components/PanelGroupDialog/PanelGroupEditorForm.js +15 -11
- package/dist/cjs/components/PanelGroupDialog/index.js +10 -8
- package/dist/cjs/components/QuerySummaryTable/QuerySummaryTable.js +46 -44
- package/dist/cjs/components/QuerySummaryTable/index.js +10 -8
- package/dist/cjs/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +23 -21
- package/dist/cjs/components/SaveChangesConfirmationDialog/index.js +10 -8
- package/dist/cjs/components/SaveDashboardButton/SaveDashboardButton.js +8 -8
- package/dist/cjs/components/SaveDashboardButton/index.js +10 -8
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +40 -16
- package/dist/cjs/components/TimeRangeControls/index.js +10 -8
- package/dist/cjs/components/ToolbarIconButton/ToolbarIconButton.js +5 -3
- package/dist/cjs/components/ToolbarIconButton/index.js +10 -8
- package/dist/cjs/components/Variables/BuiltinVariableAccordions.js +140 -0
- package/dist/cjs/components/Variables/EditVariablesButton.js +16 -11
- package/dist/cjs/components/Variables/TemplateVariable.js +116 -69
- package/dist/cjs/components/Variables/VariableEditor.js +280 -204
- package/dist/cjs/components/Variables/VariableList.js +19 -15
- package/dist/cjs/components/Variables/index.js +14 -11
- package/dist/cjs/components/index.js +31 -29
- package/dist/cjs/constants/grid-layout-config.js +6 -2
- package/dist/cjs/constants/index.js +11 -9
- package/dist/cjs/constants/user-interface-text.js +6 -2
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +40 -34
- package/dist/cjs/context/DashboardProvider/common.js +6 -2
- package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +70 -38
- package/dist/cjs/context/DashboardProvider/delete-panel-group-slice.js +3 -1
- package/dist/cjs/context/DashboardProvider/delete-panel-slice.js +5 -3
- package/dist/cjs/context/DashboardProvider/discard-changes-dialog-slice.js +3 -1
- package/dist/cjs/context/DashboardProvider/duplicate-panel-slice.js +3 -1
- package/dist/cjs/context/DashboardProvider/edit-json-dialog-slice.js +3 -1
- package/dist/cjs/context/DashboardProvider/index.js +12 -10
- package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +13 -11
- package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +8 -6
- package/dist/cjs/context/DashboardProvider/panel-group-slice.js +15 -7
- package/dist/cjs/context/DashboardProvider/panel-slice.js +3 -1
- package/dist/cjs/context/DashboardProvider/save-changes-dialog-slice.js +3 -1
- package/dist/cjs/context/DatasourceStoreProvider.js +114 -45
- package/dist/cjs/context/TemplateVariableProvider/TemplateVariableProvider.js +125 -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 +8 -6
- package/dist/cjs/index.js +12 -10
- package/dist/cjs/stories/decorators/WithDashboard.js +6 -4
- package/dist/cjs/stories/decorators/WithDatasourceStore.js +6 -4
- package/dist/cjs/stories/decorators/WithTemplateVariables.js +6 -4
- package/dist/cjs/stories/decorators/constants.js +5 -3
- package/dist/cjs/stories/decorators/index.js +13 -11
- package/dist/cjs/test/dashboard-provider.js +8 -4
- package/dist/cjs/test/datasource-provider.js +16 -12
- package/dist/cjs/test/index.js +13 -11
- package/dist/cjs/test/plugin-registry.js +6 -4
- package/dist/cjs/test/render.js +27 -20
- package/dist/cjs/test/setup-tests.js +2 -2
- package/dist/cjs/test/testDashboard.js +13 -11
- package/dist/cjs/utils/index.js +11 -9
- package/dist/cjs/utils/panelUtils.js +9 -3
- package/dist/cjs/utils/time.js +5 -3
- package/dist/cjs/validation/index.js +30 -0
- package/dist/cjs/validation/panel.js +29 -0
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +20 -16
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +63 -19
- package/dist/cjs/views/ViewDashboard/index.js +10 -8
- package/dist/cjs/views/index.js +10 -8
- package/dist/components/AddGroupButton/AddGroupButton.js.map +1 -1
- package/dist/components/AddGroupButton/index.js.map +1 -1
- package/dist/components/AddPanelButton/AddPanelButton.js.map +1 -1
- package/dist/components/AddPanelButton/index.js.map +1 -1
- package/dist/components/Dashboard/Dashboard.js.map +1 -1
- package/dist/components/Dashboard/index.js.map +1 -1
- package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js.map +1 -1
- package/dist/components/DashboardStickyToolbar/index.js.map +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.js +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
- package/dist/components/DashboardToolbar/index.js.map +1 -1
- package/dist/components/DeletePanelDialog/DeletePanelDialog.js.map +1 -1
- package/dist/components/DeletePanelDialog/index.js.map +1 -1
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +2 -2
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js.map +1 -1
- package/dist/components/DeletePanelGroupDialog/index.js.map +1 -1
- package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js.map +1 -1
- package/dist/components/DiscardChangesConfirmationDialog/index.js.map +1 -1
- package/dist/components/DownloadButton/DownloadButton.js.map +1 -1
- package/dist/components/DownloadButton/index.js.map +1 -1
- package/dist/components/EditButton/EditButton.js.map +1 -1
- package/dist/components/EditButton/index.js.map +1 -1
- package/dist/components/EditJsonButton/EditJsonButton.js.map +1 -1
- package/dist/components/EditJsonButton/index.js.map +1 -1
- package/dist/components/EditJsonDialog/EditJsonDialog.d.ts +4 -1
- package/dist/components/EditJsonDialog/EditJsonDialog.d.ts.map +1 -1
- package/dist/components/EditJsonDialog/EditJsonDialog.js +12 -8
- package/dist/components/EditJsonDialog/EditJsonDialog.js.map +1 -1
- package/dist/components/EditJsonDialog/index.js.map +1 -1
- package/dist/components/EmptyDashboard/EmptyDashboard.js.map +1 -1
- package/dist/components/EmptyDashboard/index.js.map +1 -1
- package/dist/components/GridLayout/GridContainer.js.map +1 -1
- package/dist/components/GridLayout/GridItemContent.d.ts.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 +4 -11
- package/dist/components/Panel/Panel.js.map +1 -1
- 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 +223 -138
- package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.js +2 -2
- package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
- package/dist/components/PanelDrawer/index.js.map +1 -1
- package/dist/components/PanelDrawer/usePanelEditor.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js.map +1 -1
- package/dist/components/PanelGroupDialog/index.js.map +1 -1
- package/dist/components/QuerySummaryTable/QuerySummaryTable.js +4 -4
- package/dist/components/QuerySummaryTable/QuerySummaryTable.js.map +1 -1
- package/dist/components/QuerySummaryTable/index.js.map +1 -1
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +4 -4
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +1 -1
- package/dist/components/SaveChangesConfirmationDialog/index.js.map +1 -1
- package/dist/components/SaveDashboardButton/SaveDashboardButton.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 +19 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
- package/dist/components/TimeRangeControls/index.js.map +1 -1
- package/dist/components/ToolbarIconButton/ToolbarIconButton.js.map +1 -1
- package/dist/components/ToolbarIconButton/index.js.map +1 -1
- package/dist/components/Variables/BuiltinVariableAccordions.d.ts +8 -0
- package/dist/components/Variables/BuiltinVariableAccordions.d.ts.map +1 -0
- package/dist/components/Variables/BuiltinVariableAccordions.js +127 -0
- package/dist/components/Variables/BuiltinVariableAccordions.js.map +1 -0
- package/dist/components/Variables/EditVariablesButton.d.ts.map +1 -1
- package/dist/components/Variables/EditVariablesButton.js +3 -0
- 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 +91 -54
- 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.js +6 -6
- package/dist/components/Variables/VariableList.js.map +1 -1
- package/dist/components/Variables/index.d.ts +1 -0
- package/dist/components/Variables/index.d.ts.map +1 -1
- package/dist/components/Variables/index.js +1 -0
- package/dist/components/Variables/index.js.map +1 -1
- package/dist/components/index.js.map +1 -1
- package/dist/constants/grid-layout-config.js.map +1 -1
- package/dist/constants/index.js.map +1 -1
- package/dist/constants/user-interface-text.js.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.js +5 -5
- package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
- package/dist/context/DashboardProvider/common.js.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.js +2 -2
- package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
- package/dist/context/DashboardProvider/delete-panel-group-slice.js.map +1 -1
- package/dist/context/DashboardProvider/delete-panel-slice.js +2 -2
- package/dist/context/DashboardProvider/delete-panel-slice.js.map +1 -1
- package/dist/context/DashboardProvider/discard-changes-dialog-slice.js.map +1 -1
- package/dist/context/DashboardProvider/duplicate-panel-slice.js.map +1 -1
- package/dist/context/DashboardProvider/edit-json-dialog-slice.js.map +1 -1
- package/dist/context/DashboardProvider/index.js.map +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts +2 -1
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.js +7 -7
- package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
- package/dist/context/DashboardProvider/panel-group-editor-slice.js +2 -2
- package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -1
- package/dist/context/DashboardProvider/panel-group-slice.js +3 -3
- package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
- package/dist/context/DashboardProvider/panel-slice.js.map +1 -1
- package/dist/context/DashboardProvider/save-changes-dialog-slice.js.map +1 -1
- package/dist/context/DatasourceStoreProvider.d.ts +14 -10
- package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
- package/dist/context/DatasourceStoreProvider.js +107 -40
- package/dist/context/DatasourceStoreProvider.js.map +1 -1
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts +10 -4
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts.map +1 -1
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js +93 -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.js +1 -1
- package/dist/context/useDashboard.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/stories/decorators/WithDashboard.js.map +1 -1
- package/dist/stories/decorators/WithDatasourceStore.js.map +1 -1
- package/dist/stories/decorators/WithTemplateVariables.js.map +1 -1
- package/dist/stories/decorators/constants.js +2 -2
- package/dist/stories/decorators/constants.js.map +1 -1
- package/dist/stories/decorators/index.js.map +1 -1
- package/dist/test/dashboard-provider.js.map +1 -1
- package/dist/test/datasource-provider.d.ts.map +1 -1
- package/dist/test/datasource-provider.js +5 -7
- package/dist/test/datasource-provider.js.map +1 -1
- package/dist/test/index.js.map +1 -1
- package/dist/test/plugin-registry.js.map +1 -1
- package/dist/test/render.d.ts.map +1 -1
- package/dist/test/render.js +6 -1
- 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 +4 -2
- 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 +49 -7
- 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
|
@@ -27,8 +27,12 @@ import { DatasourceStoreContext, usePluginRegistry } from '@perses-dev/plugin-sy
|
|
|
27
27
|
const dashboardDatasource = findDashboardDatasource(datasources, selector);
|
|
28
28
|
if (dashboardDatasource !== undefined) {
|
|
29
29
|
return {
|
|
30
|
-
spec: dashboardDatasource,
|
|
31
|
-
proxyUrl:
|
|
30
|
+
spec: dashboardDatasource.spec,
|
|
31
|
+
proxyUrl: buildDatasourceProxyUrl(datasourceApi, {
|
|
32
|
+
project: dashboardResource.metadata.project,
|
|
33
|
+
dashboard: dashboardResource.metadata.name,
|
|
34
|
+
name: dashboardDatasource.name
|
|
35
|
+
})
|
|
32
36
|
};
|
|
33
37
|
}
|
|
34
38
|
}
|
|
@@ -37,8 +41,11 @@ import { DatasourceStoreContext, usePluginRegistry } from '@perses-dev/plugin-sy
|
|
|
37
41
|
const datasource = await datasourceApi.getDatasource(project, selector);
|
|
38
42
|
if (datasource !== undefined) {
|
|
39
43
|
return {
|
|
40
|
-
spec: datasource.
|
|
41
|
-
proxyUrl:
|
|
44
|
+
spec: datasource.spec,
|
|
45
|
+
proxyUrl: buildDatasourceProxyUrl(datasourceApi, {
|
|
46
|
+
project: datasource.metadata.project,
|
|
47
|
+
name: datasource.metadata.name
|
|
48
|
+
})
|
|
42
49
|
};
|
|
43
50
|
}
|
|
44
51
|
}
|
|
@@ -46,8 +53,10 @@ import { DatasourceStoreContext, usePluginRegistry } from '@perses-dev/plugin-sy
|
|
|
46
53
|
const globalDatasource = await datasourceApi.getGlobalDatasource(selector);
|
|
47
54
|
if (globalDatasource !== undefined) {
|
|
48
55
|
return {
|
|
49
|
-
spec: globalDatasource.
|
|
50
|
-
proxyUrl:
|
|
56
|
+
spec: globalDatasource.spec,
|
|
57
|
+
proxyUrl: buildDatasourceProxyUrl(datasourceApi, {
|
|
58
|
+
name: globalDatasource.metadata.name
|
|
59
|
+
})
|
|
51
60
|
};
|
|
52
61
|
}
|
|
53
62
|
throw new Error(`No datasource found for kind '${selector.kind}' and name '${selector.name}'`);
|
|
@@ -79,53 +88,56 @@ import { DatasourceStoreContext, usePluginRegistry } from '@perses-dev/plugin-sy
|
|
|
79
88
|
getPlugin,
|
|
80
89
|
onCreate
|
|
81
90
|
]);
|
|
82
|
-
const
|
|
91
|
+
const listDatasourceSelectItems = useEvent(async (datasourcePluginKind)=>{
|
|
83
92
|
const [pluginMetadata, datasources, globalDatasources] = await Promise.all([
|
|
84
93
|
listPluginMetadata('Datasource'),
|
|
85
94
|
project ? datasourceApi.listDatasources(project, datasourcePluginKind) : [],
|
|
86
95
|
datasourceApi.listGlobalDatasources(datasourcePluginKind)
|
|
87
96
|
]);
|
|
88
|
-
// Find the metadata for the plugin type they asked for so we can use it for the name of the default datasource
|
|
97
|
+
// Find the metadata for the plugin type they asked for, so we can use it for the name of the default datasource
|
|
89
98
|
const datasourcePluginMetadata = pluginMetadata.find((metadata)=>metadata.kind === datasourcePluginKind);
|
|
90
99
|
if (datasourcePluginMetadata === undefined) {
|
|
91
100
|
throw new Error(`Could not find a Datasource plugin with kind '${datasourcePluginKind}'`);
|
|
92
101
|
}
|
|
93
|
-
// Get helper for
|
|
94
|
-
const { results ,
|
|
95
|
-
// Start with dashboard datasources
|
|
102
|
+
// Get helper for computing results properly
|
|
103
|
+
const { results , addItem } = buildDatasourceSelectItemGroups(datasourcePluginMetadata.display.name);
|
|
104
|
+
// Start with dashboard datasources with the highest precedence
|
|
96
105
|
if (dashboardResource === null || dashboardResource === void 0 ? void 0 : dashboardResource.spec.datasources) {
|
|
97
106
|
for(const selectorName in dashboardResource.spec.datasources){
|
|
98
107
|
const spec = dashboardResource.spec.datasources[selectorName];
|
|
99
108
|
if (spec === undefined || spec.plugin.kind !== datasourcePluginKind) continue;
|
|
100
|
-
|
|
109
|
+
addItem(spec, selectorName, 'dashboard');
|
|
101
110
|
}
|
|
102
111
|
}
|
|
103
112
|
// Now look at project-level datasources
|
|
104
113
|
for (const datasource of datasources){
|
|
105
|
-
const
|
|
106
|
-
|
|
114
|
+
const selectorName = datasource.metadata.name;
|
|
115
|
+
addItem(datasource.spec, selectorName, 'project', `/projects/${project}/datasources`);
|
|
107
116
|
}
|
|
108
117
|
// And finally global datasources
|
|
109
118
|
for (const globalDatasource of globalDatasources){
|
|
110
|
-
const
|
|
111
|
-
|
|
119
|
+
const selectorName = globalDatasource.metadata.name;
|
|
120
|
+
addItem(globalDatasource.spec, selectorName, 'global', '/admin/datasources');
|
|
112
121
|
}
|
|
113
122
|
return results;
|
|
114
123
|
});
|
|
115
124
|
const ctxValue = useMemo(()=>({
|
|
116
125
|
getDatasource,
|
|
117
126
|
getDatasourceClient,
|
|
118
|
-
|
|
127
|
+
listDatasourceSelectItems
|
|
119
128
|
}), [
|
|
120
129
|
getDatasource,
|
|
121
130
|
getDatasourceClient,
|
|
122
|
-
|
|
131
|
+
listDatasourceSelectItems
|
|
123
132
|
]);
|
|
124
133
|
return /*#__PURE__*/ _jsx(DatasourceStoreContext.Provider, {
|
|
125
134
|
value: ctxValue,
|
|
126
135
|
children: children
|
|
127
136
|
});
|
|
128
137
|
}
|
|
138
|
+
function buildDatasourceProxyUrl(api, params) {
|
|
139
|
+
return api.buildProxyUrl ? api.buildProxyUrl(params) : '';
|
|
140
|
+
}
|
|
129
141
|
// Helper to find a datasource in the list embedded in a dashboard spec
|
|
130
142
|
function findDashboardDatasource(dashboardDatasources, selector) {
|
|
131
143
|
if (dashboardDatasources === undefined) return undefined;
|
|
@@ -133,43 +145,98 @@ function findDashboardDatasource(dashboardDatasources, selector) {
|
|
|
133
145
|
if (selector.name !== undefined) {
|
|
134
146
|
const named = dashboardDatasources[selector.name];
|
|
135
147
|
if (named === undefined) return undefined;
|
|
136
|
-
return named.plugin.kind === selector.kind ?
|
|
148
|
+
return named.plugin.kind === selector.kind ? {
|
|
149
|
+
name: selector.name,
|
|
150
|
+
spec: named
|
|
151
|
+
} : undefined;
|
|
137
152
|
}
|
|
138
153
|
// If only using a kind, try to find one with that kind that is the default
|
|
139
|
-
|
|
154
|
+
const result = Object.entries(dashboardDatasources).find((entry)=>entry[1].plugin.kind === selector.kind && entry[1].default);
|
|
155
|
+
if (!result) {
|
|
156
|
+
return undefined;
|
|
157
|
+
}
|
|
158
|
+
return {
|
|
159
|
+
name: result[0],
|
|
160
|
+
spec: result[1]
|
|
161
|
+
};
|
|
140
162
|
}
|
|
141
|
-
|
|
142
|
-
|
|
163
|
+
/**
|
|
164
|
+
* Helper for building a list of DatasourceSelectItemGroup results.
|
|
165
|
+
* @param pluginDisplayName
|
|
166
|
+
*/ function buildDatasourceSelectItemGroups(pluginDisplayName) {
|
|
143
167
|
const results = [];
|
|
144
168
|
const usedNames = new Set();
|
|
145
|
-
let
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
169
|
+
let isFirst = true;
|
|
170
|
+
let explicitDefaultAdded = false;
|
|
171
|
+
const groupIndices = {};
|
|
172
|
+
let currentGroupIndex = 1; // 0 is the default group, always there as it contains at least the first item.
|
|
173
|
+
const addItem = (spec, selectorName, group, editLink)=>{
|
|
174
|
+
var _spec_display;
|
|
175
|
+
group = group !== null && group !== void 0 ? group : '';
|
|
176
|
+
// Ensure the default group is always present as soon as an item is added.
|
|
177
|
+
if (isFirst) {
|
|
178
|
+
results.push({
|
|
179
|
+
group: `Default ${pluginDisplayName}`,
|
|
180
|
+
items: []
|
|
155
181
|
});
|
|
156
|
-
defaultAdded = true;
|
|
157
182
|
}
|
|
158
|
-
|
|
159
|
-
if
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
183
|
+
var _groupIndices_group;
|
|
184
|
+
// Create the group if necessary
|
|
185
|
+
let selectItemGroup = results[(_groupIndices_group = groupIndices[group]) !== null && _groupIndices_group !== void 0 ? _groupIndices_group : -1];
|
|
186
|
+
if (!selectItemGroup) {
|
|
187
|
+
groupIndices[group] = currentGroupIndex;
|
|
188
|
+
selectItemGroup = {
|
|
189
|
+
items: [],
|
|
190
|
+
group,
|
|
191
|
+
editLink
|
|
192
|
+
};
|
|
193
|
+
results[currentGroupIndex] = selectItemGroup;
|
|
194
|
+
currentGroupIndex++;
|
|
195
|
+
}
|
|
196
|
+
// Add item to the group
|
|
197
|
+
const isOverridden = usedNames.has(selectorName);
|
|
198
|
+
var _spec_display_name;
|
|
199
|
+
selectItemGroup.items.push({
|
|
200
|
+
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,
|
|
201
|
+
overridden: isOverridden,
|
|
163
202
|
selector: {
|
|
164
203
|
kind: spec.plugin.kind,
|
|
165
|
-
name: selectorName
|
|
204
|
+
name: selectorName,
|
|
205
|
+
group
|
|
166
206
|
}
|
|
167
207
|
});
|
|
168
208
|
usedNames.add(selectorName);
|
|
209
|
+
const isExplicitDefault = !isOverridden && spec.default && !explicitDefaultAdded;
|
|
210
|
+
if (results[0] && (isFirst || isExplicitDefault)) {
|
|
211
|
+
// If we haven't added a default yet and this is a default, add default option to the beginning of the results
|
|
212
|
+
results[0].items = [
|
|
213
|
+
{
|
|
214
|
+
name: `Default (${selectorName} from ${group})`,
|
|
215
|
+
selector: {
|
|
216
|
+
kind: spec.plugin.kind
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
];
|
|
220
|
+
// We consider that we added the default datasource only if it has been explicitly set as default.
|
|
221
|
+
// If we add this datasource as default just because it's the first, it still needs to be overridable by
|
|
222
|
+
// another datasource explicitly set as default.
|
|
223
|
+
explicitDefaultAdded = isExplicitDefault;
|
|
224
|
+
}
|
|
225
|
+
// At the end, we make sure the overriding item(s) is well flagged so
|
|
226
|
+
if (isOverridden) {
|
|
227
|
+
for(let i = explicitDefaultAdded ? 1 : 0; i < currentGroupIndex; i++){
|
|
228
|
+
var _results_i;
|
|
229
|
+
var _results_i_items;
|
|
230
|
+
((_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)=>{
|
|
231
|
+
item.overriding = true;
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
isFirst = false;
|
|
169
236
|
};
|
|
170
237
|
return {
|
|
171
238
|
results,
|
|
172
|
-
|
|
239
|
+
addItem
|
|
173
240
|
};
|
|
174
241
|
}
|
|
175
242
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/context/DatasourceStoreProvider.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ReactNode, useCallback, useMemo } from 'react';\nimport {\n DashboardResource,\n DashboardSpec,\n Datasource,\n DatasourceSelector,\n DatasourceSpec,\n GlobalDatasource,\n useEvent,\n} from '@perses-dev/core';\nimport {\n DatasourceStoreContext,\n DatasourceStore,\n usePluginRegistry,\n DatasourceMetadata,\n DatasourceClient,\n} from '@perses-dev/plugin-system';\n\nexport interface DatasourceStoreProviderProps {\n dashboardResource?: DashboardResource;\n projectName?: string;\n datasourceApi: DatasourceApi;\n children?: ReactNode;\n onCreate?: (client: DatasourceClient) => DatasourceClient;\n}\n\n// The external API for fetching datasource resources\nexport interface DatasourceApi {\n getDatasource: (\n project: string,\n selector: DatasourceSelector\n ) => Promise<{ resource: Datasource; proxyUrl: string } | undefined>;\n\n getGlobalDatasource: (\n selector: DatasourceSelector\n ) => Promise<{ resource: GlobalDatasource; proxyUrl: string } | undefined>;\n\n listDatasources: (project: string, pluginKind?: string) => Promise<Datasource[]>;\n\n listGlobalDatasources: (pluginKind?: string) => Promise<GlobalDatasource[]>;\n}\n\n/**\n * A `DatasourceContext` provider that uses an external API to resolve datasource selectors.\n */\nexport function DatasourceStoreProvider(props: DatasourceStoreProviderProps) {\n const { dashboardResource, projectName, datasourceApi, onCreate, children } = props;\n const project = projectName ?? dashboardResource?.metadata.project;\n\n const { getPlugin, listPluginMetadata } = usePluginRegistry();\n\n const findDatasource = useEvent(async (selector: DatasourceSelector) => {\n // Try to find it in dashboard spec\n if (dashboardResource) {\n const { datasources } = dashboardResource.spec;\n const dashboardDatasource = findDashboardDatasource(datasources, selector);\n if (dashboardDatasource !== undefined) {\n return { spec: dashboardDatasource, proxyUrl: undefined };\n }\n }\n\n if (project) {\n // Try to find it at the project level as a Datasource resource\n const datasource = await datasourceApi.getDatasource(project, selector);\n if (datasource !== undefined) {\n return { spec: datasource.resource.spec, proxyUrl: datasource.proxyUrl };\n }\n }\n\n // Try to find it at the global level as a GlobalDatasource resource\n const globalDatasource = await datasourceApi.getGlobalDatasource(selector);\n if (globalDatasource !== undefined) {\n return { spec: globalDatasource.resource.spec, proxyUrl: globalDatasource.proxyUrl };\n }\n\n throw new Error(`No datasource found for kind '${selector.kind}' and name '${selector.name}'`);\n });\n\n // Gets a datasource spec for a given selector\n const getDatasource = useCallback(\n async (selector: DatasourceSelector): Promise<DatasourceSpec> => {\n const { spec } = await findDatasource(selector);\n return spec;\n },\n [findDatasource]\n );\n\n // Given a Datasource selector, finds the spec for it and then uses its corresponding plugin the create a client\n const getDatasourceClient = useCallback(\n async function getClient<Client extends DatasourceClient>(selector: DatasourceSelector): Promise<Client> {\n const { kind } = selector;\n const [{ spec, proxyUrl }, plugin] = await Promise.all([findDatasource(selector), getPlugin('Datasource', kind)]);\n\n // allows extending client\n const client = plugin.createClient(spec.plugin.spec, { proxyUrl }) as Client;\n if (onCreate !== undefined) {\n return onCreate(client) as Client;\n }\n return client;\n },\n [findDatasource, getPlugin, onCreate]\n );\n\n const listDatasourceMetadata = useEvent(async (datasourcePluginKind: string): Promise<DatasourceMetadata[]> => {\n const [pluginMetadata, datasources, globalDatasources] = await Promise.all([\n listPluginMetadata('Datasource'),\n project ? datasourceApi.listDatasources(project, datasourcePluginKind) : [],\n datasourceApi.listGlobalDatasources(datasourcePluginKind),\n ]);\n\n // Find the metadata for the plugin type they asked for so we can use it for the name of the default datasource\n const datasourcePluginMetadata = pluginMetadata.find((metadata) => metadata.kind === datasourcePluginKind);\n if (datasourcePluginMetadata === undefined) {\n throw new Error(`Could not find a Datasource plugin with kind '${datasourcePluginKind}'`);\n }\n\n // Get helper for de-duping results properly\n const { results, addResult } = buildListDatasourceMetadataResults(datasourcePluginMetadata.display.name);\n\n // Start with dashboard datasources that have highest precedence\n if (dashboardResource?.spec.datasources) {\n for (const selectorName in dashboardResource.spec.datasources) {\n const spec = dashboardResource.spec.datasources[selectorName];\n if (spec === undefined || spec.plugin.kind !== datasourcePluginKind) continue;\n addResult(spec, selectorName);\n }\n }\n\n // Now look at project-level datasources\n for (const datasource of datasources) {\n const selectorName = datasource.metadata.name;\n addResult(datasource.spec, selectorName);\n }\n\n // And finally global datasources\n for (const globalDatasource of globalDatasources) {\n const selectorName = globalDatasource.metadata.name;\n addResult(globalDatasource.spec, selectorName);\n }\n\n return results;\n });\n\n const ctxValue: DatasourceStore = useMemo(\n () => ({\n getDatasource,\n getDatasourceClient,\n listDatasourceMetadata,\n }),\n [getDatasource, getDatasourceClient, listDatasourceMetadata]\n );\n\n return <DatasourceStoreContext.Provider value={ctxValue}>{children}</DatasourceStoreContext.Provider>;\n}\n\n// Helper to find a datasource in the list embedded in a dashboard spec\nfunction findDashboardDatasource(dashboardDatasources: DashboardSpec['datasources'], selector: DatasourceSelector) {\n if (dashboardDatasources === undefined) return undefined;\n\n // If using a name in the selector...\n if (selector.name !== undefined) {\n const named = dashboardDatasources[selector.name];\n if (named === undefined) return undefined;\n return named.plugin.kind === selector.kind ? named : undefined;\n }\n\n // If only using a kind, try to find one with that kind that is the default\n return Object.values(dashboardDatasources).find((ds) => ds.plugin.kind === selector.kind && ds.default === true);\n}\n\n// Helper for building a list of DatasourceMetadata results that will take care of de-duping already used selectors\nfunction buildListDatasourceMetadataResults(pluginDisplayName: string) {\n const results: DatasourceMetadata[] = [];\n const usedNames = new Set<string>();\n let defaultAdded = false;\n const addResult = (spec: DatasourceSpec, selectorName: string) => {\n // If we haven't added a default yet and this is a default, add default option to the beginning of the results\n if (spec.default && defaultAdded === false) {\n results.unshift({\n name: `Default ${pluginDisplayName}`,\n selector: {\n kind: spec.plugin.kind,\n },\n });\n defaultAdded = true;\n }\n\n // If we already have a datasource with this selector name, ignore it, otherwise add to end of list\n if (usedNames.has(selectorName)) return;\n\n results.push({\n name: spec.display?.name ?? selectorName,\n selector: {\n kind: spec.plugin.kind,\n name: selectorName,\n },\n });\n usedNames.add(selectorName);\n };\n\n return { results, addResult };\n}\n"],"names":["useCallback","useMemo","useEvent","DatasourceStoreContext","usePluginRegistry","DatasourceStoreProvider","props","dashboardResource","projectName","datasourceApi","onCreate","children","project","metadata","getPlugin","listPluginMetadata","findDatasource","selector","datasources","spec","dashboardDatasource","findDashboardDatasource","undefined","proxyUrl","datasource","getDatasource","resource","globalDatasource","getGlobalDatasource","Error","kind","name","getDatasourceClient","getClient","plugin","Promise","all","client","createClient","listDatasourceMetadata","datasourcePluginKind","pluginMetadata","globalDatasources","listDatasources","listGlobalDatasources","datasourcePluginMetadata","find","results","addResult","buildListDatasourceMetadataResults","display","selectorName","ctxValue","Provider","value","dashboardDatasources","named","Object","values","ds","default","pluginDisplayName","usedNames","Set","defaultAdded","unshift","has","push","add"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAAoBA,WAAW,EAAEC,OAAO,QAAQ,OAAO,CAAC;AACxD,SAOEC,QAAQ,QACH,kBAAkB,CAAC;AAC1B,SACEC,sBAAsB,EAEtBC,iBAAiB,QAGZ,2BAA2B,CAAC;AA0BnC;;CAEC,GACD,OAAO,SAASC,uBAAuB,CAACC,KAAmC,EAAE;IAC3E,MAAM,EAAEC,iBAAiB,CAAA,EAAEC,WAAW,CAAA,EAAEC,aAAa,CAAA,EAAEC,QAAQ,CAAA,EAAEC,QAAQ,CAAA,EAAE,GAAGL,KAAK,AAAC;IACpF,MAAMM,OAAO,GAAGJ,WAAW,aAAXA,WAAW,cAAXA,WAAW,GAA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AE,CAAC;AAChC,CAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/context/DatasourceStoreProvider.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ReactNode, useCallback, useMemo } from 'react';\nimport {\n DashboardResource,\n DashboardSpec,\n ProjectDatasource,\n DatasourceSelector,\n DatasourceSpec,\n GlobalDatasource,\n useEvent,\n} from '@perses-dev/core';\nimport {\n DatasourceStoreContext,\n DatasourceStore,\n DatasourceSelectItemGroup,\n usePluginRegistry,\n DatasourceClient,\n DatasourceSelectItem,\n} from '@perses-dev/plugin-system';\n\nexport interface DatasourceStoreProviderProps {\n dashboardResource?: DashboardResource;\n projectName?: string;\n datasourceApi: DatasourceApi;\n children?: ReactNode;\n onCreate?: (client: DatasourceClient) => DatasourceClient;\n}\n\nexport type BuildDatasourceProxyUrlParams = {\n project?: string;\n dashboard?: string;\n name: string;\n};\n\nexport type BuildDatasourceProxyUrlFunc = (p: BuildDatasourceProxyUrlParams) => string;\n\n/**\n * The external API for fetching datasource resources\n */\nexport interface DatasourceApi {\n buildProxyUrl?: BuildDatasourceProxyUrlFunc;\n\n getDatasource: (project: string, selector: DatasourceSelector) => Promise<ProjectDatasource | undefined>;\n\n getGlobalDatasource: (selector: DatasourceSelector) => Promise<GlobalDatasource | undefined>;\n\n listDatasources: (project: string, pluginKind?: string) => Promise<ProjectDatasource[]>;\n\n listGlobalDatasources: (pluginKind?: string) => Promise<GlobalDatasource[]>;\n}\n\n/**\n * A `DatasourceContext` provider that uses an external API to resolve datasource selectors.\n */\nexport function DatasourceStoreProvider(props: DatasourceStoreProviderProps) {\n const { dashboardResource, projectName, datasourceApi, onCreate, children } = props;\n const project = projectName ?? dashboardResource?.metadata.project;\n\n const { getPlugin, listPluginMetadata } = usePluginRegistry();\n\n const findDatasource = useEvent(async (selector: DatasourceSelector) => {\n // Try to find it in dashboard spec\n if (dashboardResource) {\n const { datasources } = dashboardResource.spec;\n const dashboardDatasource = findDashboardDatasource(datasources, selector);\n if (dashboardDatasource !== undefined) {\n return {\n spec: dashboardDatasource.spec,\n proxyUrl: buildDatasourceProxyUrl(datasourceApi, {\n project: dashboardResource.metadata.project,\n dashboard: dashboardResource.metadata.name,\n name: dashboardDatasource.name,\n }),\n };\n }\n }\n\n if (project) {\n // Try to find it at the project level as a Datasource resource\n const datasource = await datasourceApi.getDatasource(project, selector);\n if (datasource !== undefined) {\n return {\n spec: datasource.spec,\n proxyUrl: buildDatasourceProxyUrl(datasourceApi, {\n project: datasource.metadata.project,\n name: datasource.metadata.name,\n }),\n };\n }\n }\n\n // Try to find it at the global level as a GlobalDatasource resource\n const globalDatasource = await datasourceApi.getGlobalDatasource(selector);\n if (globalDatasource !== undefined) {\n return {\n spec: globalDatasource.spec,\n proxyUrl: buildDatasourceProxyUrl(datasourceApi, {\n name: globalDatasource.metadata.name,\n }),\n };\n }\n\n throw new Error(`No datasource found for kind '${selector.kind}' and name '${selector.name}'`);\n });\n\n // Gets a datasource spec for a given selector\n const getDatasource = useCallback(\n async (selector: DatasourceSelector): Promise<DatasourceSpec> => {\n const { spec } = await findDatasource(selector);\n return spec;\n },\n [findDatasource]\n );\n\n // Given a Datasource selector, finds the spec for it and then uses its corresponding plugin the create a client\n const getDatasourceClient = useCallback(\n async function getClient<Client extends DatasourceClient>(selector: DatasourceSelector): Promise<Client> {\n const { kind } = selector;\n const [{ spec, proxyUrl }, plugin] = await Promise.all([findDatasource(selector), getPlugin('Datasource', kind)]);\n\n // allows extending client\n const client = plugin.createClient(spec.plugin.spec, { proxyUrl }) as Client;\n if (onCreate !== undefined) {\n return onCreate(client) as Client;\n }\n return client;\n },\n [findDatasource, getPlugin, onCreate]\n );\n\n const listDatasourceSelectItems = useEvent(\n async (datasourcePluginKind: string): Promise<DatasourceSelectItemGroup[]> => {\n const [pluginMetadata, datasources, globalDatasources] = await Promise.all([\n listPluginMetadata('Datasource'),\n project ? datasourceApi.listDatasources(project, datasourcePluginKind) : [],\n datasourceApi.listGlobalDatasources(datasourcePluginKind),\n ]);\n\n // Find the metadata for the plugin type they asked for, so we can use it for the name of the default datasource\n const datasourcePluginMetadata = pluginMetadata.find((metadata) => metadata.kind === datasourcePluginKind);\n if (datasourcePluginMetadata === undefined) {\n throw new Error(`Could not find a Datasource plugin with kind '${datasourcePluginKind}'`);\n }\n\n // Get helper for computing results properly\n const { results, addItem } = buildDatasourceSelectItemGroups(datasourcePluginMetadata.display.name);\n\n // Start with dashboard datasources with the highest precedence\n if (dashboardResource?.spec.datasources) {\n for (const selectorName in dashboardResource.spec.datasources) {\n const spec = dashboardResource.spec.datasources[selectorName];\n if (spec === undefined || spec.plugin.kind !== datasourcePluginKind) continue;\n\n addItem(spec, selectorName, 'dashboard');\n }\n }\n\n // Now look at project-level datasources\n for (const datasource of datasources) {\n const selectorName = datasource.metadata.name;\n addItem(datasource.spec, selectorName, 'project', `/projects/${project}/datasources`);\n }\n\n // And finally global datasources\n for (const globalDatasource of globalDatasources) {\n const selectorName = globalDatasource.metadata.name;\n addItem(globalDatasource.spec, selectorName, 'global', '/admin/datasources');\n }\n\n return results;\n }\n );\n\n const ctxValue: DatasourceStore = useMemo(\n () => ({\n getDatasource,\n getDatasourceClient,\n listDatasourceSelectItems,\n }),\n [getDatasource, getDatasourceClient, listDatasourceSelectItems]\n );\n\n return <DatasourceStoreContext.Provider value={ctxValue}>{children}</DatasourceStoreContext.Provider>;\n}\n\nfunction buildDatasourceProxyUrl(api: DatasourceApi, params: BuildDatasourceProxyUrlParams): string {\n return api.buildProxyUrl ? api.buildProxyUrl(params) : '';\n}\n\n// Helper to find a datasource in the list embedded in a dashboard spec\nfunction findDashboardDatasource(\n dashboardDatasources: DashboardSpec['datasources'],\n selector: DatasourceSelector\n): { name: string; spec: DatasourceSpec } | undefined {\n if (dashboardDatasources === undefined) return undefined;\n\n // If using a name in the selector...\n if (selector.name !== undefined) {\n const named = dashboardDatasources[selector.name];\n if (named === undefined) return undefined;\n return named.plugin.kind === selector.kind ? { name: selector.name, spec: named } : undefined;\n }\n\n // If only using a kind, try to find one with that kind that is the default\n const result = Object.entries(dashboardDatasources).find(\n (entry) => entry[1].plugin.kind === selector.kind && entry[1].default\n );\n if (!result) {\n return undefined;\n }\n return { name: result[0], spec: result[1] };\n}\n\ntype AddDatasourceSelectItemFunc = (\n spec: DatasourceSpec,\n selectorName: string,\n selectorGroup?: string,\n editLink?: string\n) => void;\n\n/**\n * Helper for building a list of DatasourceSelectItemGroup results.\n * @param pluginDisplayName\n */\nfunction buildDatasourceSelectItemGroups(pluginDisplayName: string): {\n results: DatasourceSelectItemGroup[];\n addItem: AddDatasourceSelectItemFunc;\n} {\n const results: DatasourceSelectItemGroup[] = [];\n const usedNames = new Set<string>();\n let isFirst = true;\n let explicitDefaultAdded = false;\n const groupIndices: Record<string, number> = {};\n let currentGroupIndex = 1; // 0 is the default group, always there as it contains at least the first item.\n\n const addItem = (spec: DatasourceSpec, selectorName: string, group?: string, editLink?: string) => {\n group = group ?? '';\n\n // Ensure the default group is always present as soon as an item is added.\n if (isFirst) {\n results.push({\n group: `Default ${pluginDisplayName}`,\n items: [],\n });\n }\n\n // Create the group if necessary\n let selectItemGroup = results[groupIndices[group] ?? -1];\n if (!selectItemGroup) {\n groupIndices[group] = currentGroupIndex;\n selectItemGroup = { items: [], group, editLink };\n results[currentGroupIndex] = selectItemGroup;\n currentGroupIndex++;\n }\n\n // Add item to the group\n const isOverridden = usedNames.has(selectorName);\n selectItemGroup.items.push({\n name: spec.display?.name ?? selectorName,\n overridden: isOverridden,\n selector: {\n kind: spec.plugin.kind,\n name: selectorName,\n group,\n },\n });\n usedNames.add(selectorName);\n\n const isExplicitDefault = !isOverridden && spec.default && !explicitDefaultAdded;\n if (results[0] && (isFirst || isExplicitDefault)) {\n // If we haven't added a default yet and this is a default, add default option to the beginning of the results\n results[0].items = [\n {\n name: `Default (${selectorName} from ${group})`,\n selector: {\n kind: spec.plugin.kind,\n },\n },\n ];\n // We consider that we added the default datasource only if it has been explicitly set as default.\n // If we add this datasource as default just because it's the first, it still needs to be overridable by\n // another datasource explicitly set as default.\n explicitDefaultAdded = isExplicitDefault;\n }\n\n // At the end, we make sure the overriding item(s) is well flagged so\n if (isOverridden) {\n for (let i = explicitDefaultAdded ? 1 : 0; i < currentGroupIndex; i++) {\n (results[i]?.items ?? [])\n .filter((item: DatasourceSelectItem) => item.selector.name === selectorName)\n .forEach((item: DatasourceSelectItem) => {\n item.overriding = true;\n });\n }\n }\n\n isFirst = false;\n };\n\n return { results, addItem };\n}\n"],"names":["useCallback","useMemo","useEvent","DatasourceStoreContext","usePluginRegistry","DatasourceStoreProvider","props","dashboardResource","projectName","datasourceApi","onCreate","children","project","metadata","getPlugin","listPluginMetadata","findDatasource","selector","datasources","spec","dashboardDatasource","findDashboardDatasource","undefined","proxyUrl","buildDatasourceProxyUrl","dashboard","name","datasource","getDatasource","globalDatasource","getGlobalDatasource","Error","kind","getDatasourceClient","getClient","plugin","Promise","all","client","createClient","listDatasourceSelectItems","datasourcePluginKind","pluginMetadata","globalDatasources","listDatasources","listGlobalDatasources","datasourcePluginMetadata","find","results","addItem","buildDatasourceSelectItemGroups","display","selectorName","ctxValue","Provider","value","api","params","buildProxyUrl","dashboardDatasources","named","result","Object","entries","entry","default","pluginDisplayName","usedNames","Set","isFirst","explicitDefaultAdded","groupIndices","currentGroupIndex","group","editLink","push","items","selectItemGroup","isOverridden","has","overridden","add","isExplicitDefault","i","filter","item","forEach","overriding"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7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AAK;YACzBjD,MAAMP,CAAAA,qBAAAA,CAAAA,gBAAAA,KAAKgC,qBAALhC,2BAAAA,KAAAA,IAAAA,cAAcO,kBAAdP,gCAAAA,qBAAsBiC;YAC5B4B,YAAYF;YACZ7D,UAAU;gBACRe,MAAMb,KAAKgB,OAAOH;gBAClBN,MAAM0B;gBACNqB;YACF;QACF;QACAN,UAAUc,IAAI7B;QAEd,MAAM8B,oBAAoB,CAACJ,gBAAgB3D,KAAK8C,WAAW,CAACK;QAC5D,IAAItB,OAAO,CAAC,EAAE,IAAKqB,CAAAA,WAAWa,iBAAgB,GAAI;YAChD,8GAA8G;YAC9GlC,OAAO,CAAC,EAAE,CAAC4B,QAAQ;gBACjB;oBACElD,MAAM,CAAC,SAAS,EAAE0B,aAAa,MAAM,EAAEqB,MAAM,CAAC,CAAC;oBAC/CxD,UAAU;wBACRe,MAAMb,KAAKgB,OAAOH;oBACpB;gBACF;aACD;YACD,kGAAkG;YAClG,wGAAwG;YACxG,gDAAgD;YAChDsC,uBAAuBY;QACzB;QAEA,qEAAqE;QACrE,IAAIJ,cAAc;YAChB,IAAK,IAAIK,IAAIb,uBAAuB,IAAI,GAAGa,IAAIX,mBAAmBW,IAAK;oBACpEnC;oBAAAA;gBAAAA,CAAAA,CAAAA,mBAAAA,CAAAA,aAAAA,OAAO,CAACmC,EAAE,cAAVnC,wBAAAA,KAAAA,IAAAA,WAAY4B,mBAAZ5B,8BAAAA,mBAAqB,EAAE,AAAD,EACpBoC,OAAO,CAACC,OAA+BA,KAAKpE,SAASS,SAAS0B,cAC9DkC,QAAQ,CAACD;oBACRA,KAAKE,aAAa;gBACpB;YACJ;QACF;QAEAlB,UAAU;IACZ;IAEA,OAAO;QAAErB;QAASC;IAAQ;AAC5B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
2
|
import { VariableStateMap, VariableState, VariableStoreStateMap, VariableOption } from '@perses-dev/plugin-system';
|
|
3
|
-
import { VariableName, VariableValue, VariableDefinition } from '@perses-dev/core';
|
|
3
|
+
import { VariableName, VariableValue, VariableDefinition, BuiltinVariableDefinition } from '@perses-dev/core';
|
|
4
4
|
declare type TemplateVariableStore = {
|
|
5
5
|
variableDefinitions: VariableDefinition[];
|
|
6
6
|
externalVariableDefinitions: ExternalVariableDefinition[];
|
|
@@ -50,10 +50,15 @@ export declare function useTemplateExternalVariableDefinitions(): ExternalVariab
|
|
|
50
50
|
export declare function useTemplateVariableStore(): TemplateVariableStore;
|
|
51
51
|
export declare type ExternalVariableDefinition = {
|
|
52
52
|
source: string;
|
|
53
|
+
tooltip?: {
|
|
54
|
+
title?: string;
|
|
55
|
+
description?: string;
|
|
56
|
+
};
|
|
57
|
+
editLink?: string;
|
|
53
58
|
definitions: VariableDefinition[];
|
|
54
59
|
};
|
|
55
60
|
export interface TemplateVariableProviderProps {
|
|
56
|
-
children:
|
|
61
|
+
children: ReactNode;
|
|
57
62
|
initialVariableDefinitions?: VariableDefinition[];
|
|
58
63
|
/**
|
|
59
64
|
* The external variables allow you to give to the provider some additional variables, not defined in the dashboard and static.
|
|
@@ -64,7 +69,8 @@ export interface TemplateVariableProviderProps {
|
|
|
64
69
|
* The order of the sources is important as first one will take precedence on the following ones, in case they have same names.
|
|
65
70
|
*/
|
|
66
71
|
externalVariableDefinitions?: ExternalVariableDefinition[];
|
|
72
|
+
builtinVariables?: BuiltinVariableDefinition[];
|
|
67
73
|
}
|
|
68
|
-
export declare function TemplateVariableProvider({ children, initialVariableDefinitions, externalVariableDefinitions, }: TemplateVariableProviderProps): JSX.Element;
|
|
74
|
+
export declare function TemplateVariableProvider({ children, initialVariableDefinitions, externalVariableDefinitions, builtinVariables, }: TemplateVariableProviderProps): JSX.Element;
|
|
69
75
|
export {};
|
|
70
76
|
//# sourceMappingURL=TemplateVariableProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TemplateVariableProvider.d.ts","sourceRoot":"","sources":["../../../src/context/TemplateVariableProvider/TemplateVariableProvider.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"TemplateVariableProvider.d.ts","sourceRoot":"","sources":["../../../src/context/TemplateVariableProvider/TemplateVariableProvider.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAiB,SAAS,EAAiC,MAAM,OAAO,CAAC;AAKhF,OAAO,EAEL,gBAAgB,EAChB,aAAa,EACb,qBAAqB,EACrB,cAAc,EAGf,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAEL,YAAY,EACZ,aAAa,EACb,kBAAkB,EAGlB,yBAAyB,EAC1B,MAAM,kBAAkB,CAAC;AAK1B,aAAK,qBAAqB,GAAG;IAC3B,mBAAmB,EAAE,kBAAkB,EAAE,CAAC;IAC1C,2BAA2B,EAAE,0BAA0B,EAAE,CAAC;IAC1D,aAAa,EAAE,qBAAqB,CAAC;IACrC,gBAAgB,EAAE,CAAC,YAAY,EAAE,YAAY,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9F,kBAAkB,EAAE,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7F,kBAAkB,EAAE,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACpF,sBAAsB,EAAE,CAAC,WAAW,EAAE,kBAAkB,EAAE,KAAK,IAAI,CAAC;IACpE,wBAAwB,EAAE,MAAM,kBAAkB,EAAE,CAAC;IACrD,uBAAuB,EAAE,MAAM;QAAE,uBAAuB,EAAE,OAAO,CAAC;QAAC,qBAAqB,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;CACtG,CAAC;AAKF,wBAAgB,2BAA2B;;;;;;;;EAM1C;AAED,wBAAgB,yBAAyB,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,oBAoCjE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;;;EAWhE;AAED,wBAAgB,0BAA0B;;;;;;;;;;EAYzC;AAED,wBAAgB,8BAA8B,yBAG7C;AAED,wBAAgB,sCAAsC,iCAGrD;AAED,wBAAgB,wBAAwB,0BAGvC;AAyPD,oBAAY,0BAA0B,GAAG;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE;QACR,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,kBAAkB,EAAE,CAAC;CACnC,CAAC;AAEF,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,EAAE,SAAS,CAAC;IACpB,0BAA0B,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAClD;;;;;;;OAOG;IACH,2BAA2B,CAAC,EAAE,0BAA0B,EAAE,CAAC;IAC3D,gBAAgB,CAAC,EAAE,yBAAyB,EAAE,CAAC;CAChD;AAED,wBAAgB,wBAAwB,CAAC,EACvC,QAAQ,EACR,0BAA+B,EAC/B,2BAAgC,EAChC,gBAAqB,GACtB,EAAE,6BAA6B,eAY/B"}
|
|
@@ -16,8 +16,8 @@ import { createStore, useStore } from 'zustand';
|
|
|
16
16
|
import { immer } from 'zustand/middleware/immer';
|
|
17
17
|
import { devtools } from 'zustand/middleware';
|
|
18
18
|
import produce from 'immer';
|
|
19
|
-
import { TemplateVariableContext } from '@perses-dev/plugin-system';
|
|
20
|
-
import { DEFAULT_ALL_VALUE as ALL_VALUE } from '@perses-dev/core';
|
|
19
|
+
import { TemplateVariableContext, BuiltinVariableContext, useTimeRange } from '@perses-dev/plugin-system';
|
|
20
|
+
import { DEFAULT_ALL_VALUE as ALL_VALUE, formatDuration, intervalToPrometheusDuration } from '@perses-dev/core';
|
|
21
21
|
import { checkSavedDefaultVariableStatus, findVariableDefinitionByName, mergeVariableDefinitions } from './utils';
|
|
22
22
|
import { hydrateTemplateVariableStates } from './hydrationUtils';
|
|
23
23
|
import { getInitalValuesFromQueryParameters, getURLQueryParamName, useVariableQueryParams } from './query-params';
|
|
@@ -71,12 +71,12 @@ export function useTemplateVariableValues(variableNames) {
|
|
|
71
71
|
*/ export function useTemplateVariable(name, source) {
|
|
72
72
|
const store = useTemplateVariableStoreCtx();
|
|
73
73
|
return useStore(store, (s)=>{
|
|
74
|
-
var
|
|
74
|
+
var _s_externalVariableDefinitions_find;
|
|
75
75
|
const state = s.variableState.get({
|
|
76
76
|
name,
|
|
77
77
|
source
|
|
78
78
|
});
|
|
79
|
-
const definitions = source ? (
|
|
79
|
+
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;
|
|
80
80
|
const definition = (definitions || []).find((v)=>v.spec.name === name);
|
|
81
81
|
return {
|
|
82
82
|
state,
|
|
@@ -109,10 +109,11 @@ export function useTemplateVariableStore() {
|
|
|
109
109
|
const store = useTemplateVariableStoreCtx();
|
|
110
110
|
return useStore(store);
|
|
111
111
|
}
|
|
112
|
-
function PluginProvider({ children }) {
|
|
112
|
+
function PluginProvider({ children , builtinVariables }) {
|
|
113
113
|
const originalValues = useTemplateVariableValues();
|
|
114
114
|
const definitions = useTemplateVariableDefinitions();
|
|
115
115
|
const externalDefinitions = useTemplateExternalVariableDefinitions();
|
|
116
|
+
const { absoluteTimeRange } = useTimeRange();
|
|
116
117
|
const values = useMemo(()=>{
|
|
117
118
|
const contextValues = {};
|
|
118
119
|
// This will loop through all the current variables values
|
|
@@ -125,12 +126,12 @@ function PluginProvider({ children }) {
|
|
|
125
126
|
if (v.value === ALL_VALUE) {
|
|
126
127
|
const definition = findVariableDefinitionByName(name, definitions, externalDefinitions);
|
|
127
128
|
// If the variable is a list variable and has a custom all value, then use that value instead
|
|
128
|
-
if ((definition === null || definition === void 0 ? void 0 : definition.kind) === 'ListVariable' && definition.spec.
|
|
129
|
-
v.value = definition.spec.
|
|
129
|
+
if ((definition === null || definition === void 0 ? void 0 : definition.kind) === 'ListVariable' && definition.spec.customAllValue) {
|
|
130
|
+
v.value = definition.spec.customAllValue;
|
|
130
131
|
} else {
|
|
131
|
-
var
|
|
132
|
-
var
|
|
133
|
-
v.value = (
|
|
132
|
+
var _v_options;
|
|
133
|
+
var _v_options_map;
|
|
134
|
+
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;
|
|
134
135
|
}
|
|
135
136
|
}
|
|
136
137
|
contextValues[name] = v;
|
|
@@ -141,11 +142,84 @@ function PluginProvider({ children }) {
|
|
|
141
142
|
definitions,
|
|
142
143
|
externalDefinitions
|
|
143
144
|
]);
|
|
144
|
-
|
|
145
|
+
const allBuiltinVariables = [
|
|
146
|
+
{
|
|
147
|
+
kind: 'BuiltinVariable',
|
|
148
|
+
spec: {
|
|
149
|
+
name: '__from',
|
|
150
|
+
value: ()=>absoluteTimeRange.start.valueOf().toString(),
|
|
151
|
+
source: 'Dashboard',
|
|
152
|
+
display: {
|
|
153
|
+
name: '__from',
|
|
154
|
+
description: 'Start time of the current time range in unix millisecond epoch',
|
|
155
|
+
hidden: true
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
kind: 'BuiltinVariable',
|
|
161
|
+
spec: {
|
|
162
|
+
name: '__to',
|
|
163
|
+
value: ()=>absoluteTimeRange.end.valueOf().toString(),
|
|
164
|
+
source: 'Dashboard',
|
|
165
|
+
display: {
|
|
166
|
+
name: '__to',
|
|
167
|
+
description: 'End time of the current time range in unix millisecond epoch',
|
|
168
|
+
hidden: true
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
kind: 'BuiltinVariable',
|
|
174
|
+
spec: {
|
|
175
|
+
name: '__range',
|
|
176
|
+
value: ()=>formatDuration(intervalToPrometheusDuration(absoluteTimeRange)),
|
|
177
|
+
source: 'Dashboard',
|
|
178
|
+
display: {
|
|
179
|
+
name: '__range',
|
|
180
|
+
description: 'The range for the current dashboard in human readable format',
|
|
181
|
+
hidden: true
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
kind: 'BuiltinVariable',
|
|
187
|
+
spec: {
|
|
188
|
+
name: '__range_s',
|
|
189
|
+
value: ()=>((absoluteTimeRange.end.valueOf() - absoluteTimeRange.start.valueOf()) / 1000).toString(),
|
|
190
|
+
source: 'Dashboard',
|
|
191
|
+
display: {
|
|
192
|
+
name: '__range_s',
|
|
193
|
+
description: 'The range for the current dashboard in second',
|
|
194
|
+
hidden: true
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
kind: 'BuiltinVariable',
|
|
200
|
+
spec: {
|
|
201
|
+
name: '__range_ms',
|
|
202
|
+
value: ()=>(absoluteTimeRange.end.valueOf() - absoluteTimeRange.start.valueOf()).toString(),
|
|
203
|
+
source: 'Dashboard',
|
|
204
|
+
display: {
|
|
205
|
+
name: '__range_ms',
|
|
206
|
+
description: 'The range for the current dashboard in millisecond',
|
|
207
|
+
hidden: true
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
];
|
|
212
|
+
builtinVariables === null || builtinVariables === void 0 ? void 0 : builtinVariables.forEach((def)=>allBuiltinVariables.push(def));
|
|
213
|
+
return /*#__PURE__*/ _jsx(BuiltinVariableContext.Provider, {
|
|
145
214
|
value: {
|
|
146
|
-
|
|
215
|
+
variables: allBuiltinVariables
|
|
147
216
|
},
|
|
148
|
-
children:
|
|
217
|
+
children: /*#__PURE__*/ _jsx(TemplateVariableContext.Provider, {
|
|
218
|
+
value: {
|
|
219
|
+
state: values
|
|
220
|
+
},
|
|
221
|
+
children: children
|
|
222
|
+
})
|
|
149
223
|
});
|
|
150
224
|
}
|
|
151
225
|
function createTemplateVariableSrvStore({ initialVariableDefinitions =[] , externalVariableDefinitions =[] , queryParams }) {
|
|
@@ -225,16 +299,16 @@ function createTemplateVariableSrvStore({ initialVariableDefinitions =[] , exter
|
|
|
225
299
|
draft[index] = {
|
|
226
300
|
kind: 'ListVariable',
|
|
227
301
|
spec: produce(variable.spec, (specDraft)=>{
|
|
228
|
-
specDraft.
|
|
302
|
+
specDraft.defaultValue = currentVariable.value;
|
|
229
303
|
})
|
|
230
304
|
};
|
|
231
305
|
}
|
|
232
306
|
} else if (variable.kind === 'TextVariable') {
|
|
233
|
-
const
|
|
307
|
+
const currentVariable = variableState.get({
|
|
234
308
|
name
|
|
235
309
|
});
|
|
236
|
-
const currentVariableValue = typeof (
|
|
237
|
-
if ((
|
|
310
|
+
const currentVariableValue = typeof (currentVariable === null || currentVariable === void 0 ? void 0 : currentVariable.value) === 'string' ? currentVariable.value : '';
|
|
311
|
+
if ((currentVariable === null || currentVariable === void 0 ? void 0 : currentVariable.value) !== undefined) {
|
|
238
312
|
draft[index] = {
|
|
239
313
|
kind: 'TextVariable',
|
|
240
314
|
spec: produce(variable.spec, (specDraft)=>{
|
|
@@ -257,7 +331,7 @@ function createTemplateVariableSrvStore({ initialVariableDefinitions =[] , exter
|
|
|
257
331
|
})));
|
|
258
332
|
return store;
|
|
259
333
|
}
|
|
260
|
-
export function TemplateVariableProvider({ children , initialVariableDefinitions =[] , externalVariableDefinitions =[] }) {
|
|
334
|
+
export function TemplateVariableProvider({ children , initialVariableDefinitions =[] , externalVariableDefinitions =[] , builtinVariables =[] }) {
|
|
261
335
|
const allVariableDefs = mergeVariableDefinitions(initialVariableDefinitions, externalVariableDefinitions);
|
|
262
336
|
const queryParams = useVariableQueryParams(allVariableDefs);
|
|
263
337
|
const [store] = useState(createTemplateVariableSrvStore({
|
|
@@ -268,6 +342,7 @@ export function TemplateVariableProvider({ children , initialVariableDefinitions
|
|
|
268
342
|
return /*#__PURE__*/ _jsx(TemplateVariableStoreContext.Provider, {
|
|
269
343
|
value: store,
|
|
270
344
|
children: /*#__PURE__*/ _jsx(PluginProvider, {
|
|
345
|
+
builtinVariables: builtinVariables,
|
|
271
346
|
children: children
|
|
272
347
|
})
|
|
273
348
|
});
|