@perses-dev/dashboards 0.8.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/Dashboard.js +29 -14
- package/dist/cjs/components/DashboardToolbar.js +148 -20
- package/dist/cjs/components/GridLayout/GridItemContent.js +24 -18
- package/dist/cjs/components/GridLayout/GridLayout.js +88 -26
- package/dist/cjs/components/GridLayout/GridTitle.js +69 -31
- package/dist/cjs/components/GridLayout/index.js +18 -19
- package/dist/cjs/components/Panel/Panel.js +145 -55
- package/dist/cjs/components/Panel/Panel.test.js +50 -41
- package/dist/cjs/components/Panel/PanelContent.js +40 -12
- package/dist/cjs/components/Panel/index.js +16 -17
- package/dist/cjs/components/PanelDrawer/PanelDrawer.js +82 -107
- package/dist/cjs/components/PanelDrawer/PanelDrawer.test.js +91 -92
- package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +152 -0
- package/dist/cjs/components/PanelDrawer/PanelSpecEditor.js +40 -0
- package/dist/cjs/components/PanelDrawer/PanelTypeSelect.js +38 -0
- package/dist/cjs/components/PanelDrawer/index.js +28 -0
- package/dist/cjs/components/PanelDrawer/panel-editor-model.js +140 -0
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +120 -31
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.test.js +90 -83
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +120 -38
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.test.js +42 -27
- package/dist/cjs/components/TimeRangeControls/index.js +16 -17
- package/dist/cjs/components/Variables/Variable.js +186 -35
- package/dist/cjs/components/Variables/VariableList.js +100 -13
- package/dist/cjs/components/Variables/index.js +17 -18
- package/dist/cjs/components/index.js +21 -21
- package/dist/cjs/context/DashboardAppSlice.js +43 -31
- package/dist/cjs/context/DashboardProvider.js +88 -58
- package/dist/cjs/context/DatasourceStoreProvider.js +68 -0
- package/dist/cjs/context/LayoutsSlice.js +40 -27
- package/dist/cjs/context/QueryStringProvider.js +69 -15
- package/dist/cjs/context/TemplateVariableProvider.js +128 -136
- package/dist/cjs/context/TimeRangeProvider.js +79 -30
- package/dist/cjs/context/index.js +22 -22
- package/dist/cjs/css/styles.js +43 -39
- package/dist/cjs/index.js +19 -20
- package/dist/cjs/test/dashboard-provider.js +51 -0
- package/dist/cjs/test/index.js +18 -18
- package/dist/cjs/test/plugin-registry.js +52 -25
- package/dist/cjs/test/render.js +25 -22
- package/dist/cjs/test/setup-tests.js +4 -2
- package/dist/cjs/test/testDashboard.js +193 -109
- package/dist/cjs/utils/functions.js +9 -5
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +50 -23
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +62 -31
- package/dist/cjs/views/ViewDashboard/index.js +16 -17
- package/dist/cjs/views/index.js +16 -17
- package/dist/components/Dashboard.js +38 -1
- package/dist/components/Dashboard.js.map +1 -0
- package/dist/components/DashboardToolbar.d.ts.map +1 -1
- package/dist/components/DashboardToolbar.js +154 -1
- package/dist/components/DashboardToolbar.js.map +1 -0
- package/dist/components/GridLayout/GridItemContent.js +35 -1
- package/dist/components/GridLayout/GridItemContent.js.map +1 -0
- package/dist/components/GridLayout/GridLayout.js +99 -1
- package/dist/components/GridLayout/GridLayout.js.map +1 -0
- package/dist/components/GridLayout/GridTitle.js +77 -1
- package/dist/components/GridLayout/GridTitle.js.map +1 -0
- package/dist/components/GridLayout/index.js +16 -1
- package/dist/components/GridLayout/index.js.map +1 -0
- package/dist/components/Panel/Panel.d.ts.map +1 -1
- package/dist/components/Panel/Panel.js +170 -1
- package/dist/components/Panel/Panel.js.map +1 -0
- package/dist/components/Panel/Panel.test.js +71 -1
- package/dist/components/Panel/Panel.test.js.map +1 -0
- package/dist/components/Panel/PanelContent.d.ts +2 -4
- package/dist/components/Panel/PanelContent.d.ts.map +1 -1
- package/dist/components/Panel/PanelContent.js +40 -1
- package/dist/components/Panel/PanelContent.js.map +1 -0
- package/dist/components/Panel/index.js +15 -1
- package/dist/components/Panel/index.js.map +1 -0
- package/dist/components/PanelDrawer/PanelDrawer.d.ts +4 -2
- package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.js +95 -1
- package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -0
- package/dist/components/PanelDrawer/PanelDrawer.test.js +103 -1
- 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 +142 -0
- package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -0
- package/dist/components/PanelDrawer/PanelSpecEditor.d.ts +7 -0
- package/dist/components/PanelDrawer/PanelSpecEditor.d.ts.map +1 -0
- package/dist/components/PanelDrawer/PanelSpecEditor.js +34 -0
- package/dist/components/PanelDrawer/PanelSpecEditor.js.map +1 -0
- package/dist/components/PanelDrawer/PanelTypeSelect.d.ts +8 -0
- package/dist/components/PanelDrawer/PanelTypeSelect.d.ts.map +1 -0
- package/dist/components/PanelDrawer/PanelTypeSelect.js +34 -0
- package/dist/components/PanelDrawer/PanelTypeSelect.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/PanelDrawer/panel-editor-model.d.ts +27 -0
- package/dist/components/PanelDrawer/panel-editor-model.d.ts.map +1 -0
- package/dist/components/PanelDrawer/panel-editor-model.js +133 -0
- package/dist/components/PanelDrawer/panel-editor-model.js.map +1 -0
- package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js +138 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -0
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js +95 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js.map +1 -0
- package/dist/components/TimeRangeControls/TimeRangeControls.js +137 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -0
- package/dist/components/TimeRangeControls/TimeRangeControls.test.js +59 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.test.js.map +1 -0
- package/dist/components/TimeRangeControls/index.js +15 -1
- package/dist/components/TimeRangeControls/index.js.map +1 -0
- package/dist/components/Variables/Variable.d.ts.map +1 -1
- package/dist/components/Variables/Variable.js +202 -1
- package/dist/components/Variables/Variable.js.map +1 -0
- package/dist/components/Variables/VariableList.js +108 -1
- package/dist/components/Variables/VariableList.js.map +1 -0
- package/dist/components/Variables/index.js +16 -1
- package/dist/components/Variables/index.js.map +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +20 -1
- package/dist/components/index.js.map +1 -0
- package/dist/context/DashboardAppSlice.js +45 -1
- package/dist/context/DashboardAppSlice.js.map +1 -0
- package/dist/context/DashboardProvider.d.ts +4 -2
- package/dist/context/DashboardProvider.d.ts.map +1 -1
- package/dist/context/DashboardProvider.js +107 -1
- package/dist/context/DashboardProvider.js.map +1 -0
- package/dist/context/DatasourceStoreProvider.d.ts +16 -0
- package/dist/context/DatasourceStoreProvider.d.ts.map +1 -0
- package/dist/context/DatasourceStoreProvider.js +64 -0
- package/dist/context/DatasourceStoreProvider.js.map +1 -0
- package/dist/context/LayoutsSlice.js +43 -1
- package/dist/context/LayoutsSlice.js.map +1 -0
- package/dist/context/QueryStringProvider.js +40 -1
- package/dist/context/QueryStringProvider.js.map +1 -0
- package/dist/context/TemplateVariableProvider.d.ts +6 -3
- package/dist/context/TemplateVariableProvider.d.ts.map +1 -1
- package/dist/context/TemplateVariableProvider.js +192 -1
- package/dist/context/TemplateVariableProvider.js.map +1 -0
- package/dist/context/TimeRangeProvider.js +72 -1
- package/dist/context/TimeRangeProvider.js.map +1 -0
- package/dist/context/index.d.ts +3 -2
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +21 -1
- package/dist/context/index.js.map +1 -0
- package/dist/css/styles.js +186 -1
- package/dist/css/styles.js.map +1 -0
- package/dist/index.js +17 -1
- 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 +1 -0
- package/dist/test/index.d.ts.map +1 -1
- package/dist/test/index.js +17 -1
- package/dist/test/index.js.map +1 -0
- package/dist/test/plugin-registry.d.ts +2 -3
- package/dist/test/plugin-registry.d.ts.map +1 -1
- package/dist/test/plugin-registry.js +74 -1
- package/dist/test/plugin-registry.js.map +1 -0
- package/dist/test/render.d.ts +1 -2
- package/dist/test/render.d.ts.map +1 -1
- package/dist/test/render.js +34 -1
- package/dist/test/render.js.map +1 -0
- package/dist/test/setup-tests.js +18 -1
- package/dist/test/setup-tests.js.map +1 -0
- package/dist/test/testDashboard.d.ts.map +1 -1
- package/dist/test/testDashboard.js +274 -1
- package/dist/test/testDashboard.js.map +1 -0
- package/dist/utils/functions.js +17 -1
- package/dist/utils/functions.js.map +1 -0
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.js +56 -1
- package/dist/views/ViewDashboard/DashboardApp.js.map +1 -0
- package/dist/views/ViewDashboard/ViewDashboard.d.ts +2 -0
- package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.js +79 -1
- package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -0
- package/dist/views/ViewDashboard/index.js +15 -1
- package/dist/views/ViewDashboard/index.js.map +1 -0
- package/dist/views/index.js +15 -1
- package/dist/views/index.js.map +1 -0
- package/package.json +13 -7
- package/dist/cjs/components/PanelDrawer/PanelOptionsEditor.js +0 -19
- package/dist/components/PanelDrawer/PanelOptionsEditor.d.ts +0 -9
- package/dist/components/PanelDrawer/PanelOptionsEditor.d.ts.map +0 -1
- package/dist/components/PanelDrawer/PanelOptionsEditor.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/context/DashboardProvider.tsx"],"sourcesContent":["// Copyright 2022 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 { createStore, useStore } from 'zustand';\nimport type { StoreApi } from 'zustand';\nimport { immer } from 'zustand/middleware/immer';\nimport shallow from 'zustand/shallow';\nimport { createContext, useContext } from 'react';\nimport produce from 'immer';\nimport { DashboardSpec, GridItemDefinition, LayoutDefinition, PanelDefinition } from '@perses-dev/core';\nimport { DashboardAppSlice, createDashboardAppSlice } from './DashboardAppSlice';\nimport { LayoutsSlice, createLayoutsSlice } from './LayoutsSlice';\n\nexport interface DashboardStoreState extends DashboardAppSlice, LayoutsSlice {\n dashboard: DashboardSpec;\n layouts: LayoutDefinition[];\n panels: Record<string, PanelDefinition>;\n updatePanel: (name: string, panel: PanelDefinition, groupIndex?: number) => void;\n isEditMode: boolean;\n setEditMode: (isEditMode: boolean) => void;\n}\n\nexport interface DashboardStoreProps {\n dashboardSpec: DashboardSpec;\n isEditMode?: boolean;\n}\nexport interface DashboardProviderProps {\n initialState: DashboardStoreProps;\n children?: React.ReactNode;\n}\n\nexport function usePanels() {\n return useDashboardStore(({ panels, updatePanel }) => ({ panels, updatePanel }));\n}\n\nexport function useEditMode() {\n return useDashboardStore(({ isEditMode, setEditMode }) => ({ isEditMode, setEditMode }));\n}\n\nexport function useDashboard() {\n const selectDashboardSpec = (state: DashboardStoreState) => {\n return produce(state.dashboard, (draftState) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n draftState.panels = state.panels as any;\n draftState.layouts = state.layouts;\n });\n };\n const dashboard = useDashboardStore(selectDashboardSpec);\n return { dashboard };\n}\n\nexport const DashboardContext = createContext<StoreApi<DashboardStoreState> | undefined>(undefined);\n\nexport function useDashboardStore<T>(selector: (state: DashboardStoreState) => T) {\n const store = useContext(DashboardContext);\n if (store === undefined) {\n throw new Error('No DashboardContext found. Did you forget a Provider?');\n }\n return useStore(store, selector, shallow);\n}\n\nexport function DashboardProvider(props: DashboardProviderProps) {\n const {\n children,\n initialState: { dashboardSpec, isEditMode },\n } = props;\n\n const { layouts, panels } = dashboardSpec;\n\n const dashboardStore = createStore<DashboardStoreState>()(\n immer((set, get, api) => {\n return {\n ...(createDashboardAppSlice(set, get, api, []) as unknown as DashboardAppSlice),\n ...(createLayoutsSlice(set, get, api, []) as unknown as LayoutsSlice),\n layouts,\n panels,\n dashboard: dashboardSpec,\n updatePanel: (name: string, panel: PanelDefinition, groupIndex = 0) =>\n set((state) => {\n // add new panel to layouts if panels[name] is undefined\n if (state.panels[name] === undefined) {\n // find maximum y so new panel is added to the end of the grid\n let maxY = 0;\n state.layouts[groupIndex]?.spec.items.forEach((layout) => {\n if (layout.y > maxY) {\n maxY = layout.y;\n }\n });\n const panelLayout: GridItemDefinition = {\n x: 0,\n y: maxY + 1,\n width: 12,\n height: 6,\n content: { $ref: `#/spec/panels/${name}` },\n };\n const layouts = state.layouts;\n if (layouts && layouts[groupIndex]) {\n layouts[groupIndex]?.spec.items.push(panelLayout);\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n state.panels[name] = panel as any;\n }),\n isEditMode: !!isEditMode,\n setEditMode: (isEditMode: boolean) => set({ isEditMode }),\n };\n })\n );\n\n return (\n <DashboardContext.Provider value={dashboardStore as StoreApi<DashboardStoreState>}>\n {children}\n </DashboardContext.Provider>\n );\n}\n"],"names":["createStore","useStore","immer","shallow","createContext","useContext","produce","createDashboardAppSlice","createLayoutsSlice","usePanels","useDashboardStore","panels","updatePanel","useEditMode","isEditMode","setEditMode","useDashboard","selectDashboardSpec","state","dashboard","draftState","layouts","DashboardContext","undefined","selector","store","Error","DashboardProvider","props","children","initialState","dashboardSpec","dashboardStore","set","get","api","name","panel","groupIndex","maxY","spec","items","forEach","layout","y","panelLayout","x","width","height","content","$ref","push","Provider","value"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,WAAW,EAAEC,QAAQ,QAAQ,SAAS,CAAC;AAEhD,SAASC,KAAK,QAAQ,0BAA0B,CAAC;AACjD,OAAOC,OAAO,MAAM,iBAAiB,CAAC;AACtC,SAASC,aAAa,EAAEC,UAAU,QAAQ,OAAO,CAAC;AAClD,OAAOC,OAAO,MAAM,OAAO,CAAC;AAE5B,SAA4BC,uBAAuB,QAAQ,qBAAqB,CAAC;AACjF,SAAuBC,kBAAkB,QAAQ,gBAAgB,CAAC;AAoBlE,OAAO,SAASC,SAAS,GAAG;IAC1B,OAAOC,iBAAiB,CAAC,CAAC,EAAEC,MAAM,CAAA,EAAEC,WAAW,CAAA,EAAE,GAAM,CAAA;YAAED,MAAM;YAAEC,WAAW;SAAE,CAAA,AAAC,CAAC,CAAC;AACnF,CAAC;AAED,OAAO,SAASC,WAAW,GAAG;IAC5B,OAAOH,iBAAiB,CAAC,CAAC,EAAEI,UAAU,CAAA,EAAEC,WAAW,CAAA,EAAE,GAAM,CAAA;YAAED,UAAU;YAAEC,WAAW;SAAE,CAAA,AAAC,CAAC,CAAC;AAC3F,CAAC;AAED,OAAO,SAASC,YAAY,GAAG;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AAI,CAACC,KAAK,CAACU,IAAI,CAACN,WAAW,CAAC,CAAC;wBACpD,CAAC;oBACH,CAAC;oBAED,8DAA8D;oBAC9D3B,KAAK,CAACP,MAAM,CAACyB,IAAI,CAAC,GAAGC,KAAK,AAAO,CAAC;gBACpC,CAAC,CAAC,CAAA;aAAA;YACJvB,UAAU,EAAE,CAAC,CAACA,UAAU;YACxBC,WAAW,EAAE,CAACD,UAAmB,GAAKmB,GAAG,CAAC;oBAAEnB,UAAU;iBAAE,CAAC;SAC1D,CAAC;IACJ,CAAC,CAAC,CACH,AAAC;IAEF,qBACE,KAACQ,gBAAgB,CAAC8B,QAAQ;QAACC,KAAK,EAAErB,cAAc;kBAC7CH,QAAQ;MACiB,CAC5B;AACJ,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { DashboardResource, Datasource, DatasourceSelector, GlobalDatasource } from '@perses-dev/core';
|
|
3
|
+
export interface DatasourceStoreProviderProps {
|
|
4
|
+
dashboardResource: DashboardResource;
|
|
5
|
+
datasourceApi: DatasourceApi;
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export interface DatasourceApi {
|
|
9
|
+
getDatasource: (project: string, selector: DatasourceSelector) => Promise<Datasource | undefined>;
|
|
10
|
+
getGlobalDatasource: (selector: DatasourceSelector) => Promise<GlobalDatasource | undefined>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A `DatasourceContext` provider that uses an external API to resolve datasource selectors.
|
|
14
|
+
*/
|
|
15
|
+
export declare function DatasourceStoreProvider(props: DatasourceStoreProviderProps): JSX.Element;
|
|
16
|
+
//# sourceMappingURL=DatasourceStoreProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatasourceStoreProvider.d.ts","sourceRoot":"","sources":["../../src/context/DatasourceStoreProvider.tsx"],"names":[],"mappings":";AAcA,OAAO,EACL,iBAAiB,EAEjB,UAAU,EACV,kBAAkB,EAElB,gBAAgB,EAEjB,MAAM,kBAAkB,CAAC;AAG1B,MAAM,WAAW,4BAA4B;IAC3C,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,aAAa,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAGD,MAAM,WAAW,aAAa;IAC5B,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,kBAAkB,KAAK,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;IAClG,mBAAmB,EAAE,CAAC,QAAQ,EAAE,kBAAkB,KAAK,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAAC;CAC9F;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,4BAA4B,eAmC1E"}
|
|
@@ -0,0 +1,64 @@
|
|
|
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
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { useMemo } from 'react';
|
|
15
|
+
import { useEvent } from '@perses-dev/core';
|
|
16
|
+
import { DatasourceStoreContext } from '@perses-dev/plugin-system';
|
|
17
|
+
/**
|
|
18
|
+
* A `DatasourceContext` provider that uses an external API to resolve datasource selectors.
|
|
19
|
+
*/ export function DatasourceStoreProvider(props) {
|
|
20
|
+
const { dashboardResource , datasourceApi , children } = props;
|
|
21
|
+
const getDatasource = useEvent(async (selector)=>{
|
|
22
|
+
// Try to find it in dashboard spec
|
|
23
|
+
const { datasources } = dashboardResource.spec;
|
|
24
|
+
const dashboardDatasource = findDashboardDatasource(datasources, selector);
|
|
25
|
+
if (dashboardDatasource !== undefined) {
|
|
26
|
+
return dashboardDatasource;
|
|
27
|
+
}
|
|
28
|
+
// Try to find it at the project level as a Datasource resource
|
|
29
|
+
const { project } = dashboardResource.metadata;
|
|
30
|
+
const datasource = await datasourceApi.getDatasource(project, selector);
|
|
31
|
+
if (datasource !== undefined) {
|
|
32
|
+
return datasource.spec;
|
|
33
|
+
}
|
|
34
|
+
// Try to find it at the global level as a GlobalDatasource resource
|
|
35
|
+
const globalDatasource = await datasourceApi.getGlobalDatasource(selector);
|
|
36
|
+
if (globalDatasource !== undefined) {
|
|
37
|
+
return globalDatasource.spec;
|
|
38
|
+
}
|
|
39
|
+
throw new Error(`No datasource found for kind '${selector.kind}' and name '${selector.name}'`);
|
|
40
|
+
});
|
|
41
|
+
const ctxValue = useMemo(()=>({
|
|
42
|
+
getDatasource
|
|
43
|
+
}), [
|
|
44
|
+
getDatasource
|
|
45
|
+
]);
|
|
46
|
+
return /*#__PURE__*/ _jsx(DatasourceStoreContext.Provider, {
|
|
47
|
+
value: ctxValue,
|
|
48
|
+
children: children
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
// Helper to find a datasource in the list embedded in a dashboard spec
|
|
52
|
+
function findDashboardDatasource(dashboardDatasources, selector) {
|
|
53
|
+
if (dashboardDatasources === undefined) return undefined;
|
|
54
|
+
// If using a name in the selector...
|
|
55
|
+
if (selector.name !== undefined) {
|
|
56
|
+
const named = dashboardDatasources[selector.name];
|
|
57
|
+
if (named === undefined) return undefined;
|
|
58
|
+
return named.plugin.kind === selector.kind ? named : undefined;
|
|
59
|
+
}
|
|
60
|
+
// If only using a kind, try to find one with that kind that is the default
|
|
61
|
+
return Object.values(dashboardDatasources).find((ds)=>ds.plugin.kind === selector.kind && ds.default === true);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=DatasourceStoreProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/context/DatasourceStoreProvider.tsx"],"sourcesContent":["// Copyright 2022 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 { useMemo } from 'react';\nimport {\n DashboardResource,\n DashboardSpec,\n Datasource,\n DatasourceSelector,\n DatasourceSpec,\n GlobalDatasource,\n useEvent,\n} from '@perses-dev/core';\nimport { DatasourceStoreContext, DatasourceStore } from '@perses-dev/plugin-system';\n\nexport interface DatasourceStoreProviderProps {\n dashboardResource: DashboardResource;\n datasourceApi: DatasourceApi;\n children?: React.ReactNode;\n}\n\n// The external API for fetching datasource resources\nexport interface DatasourceApi {\n getDatasource: (project: string, selector: DatasourceSelector) => Promise<Datasource | undefined>;\n getGlobalDatasource: (selector: DatasourceSelector) => Promise<GlobalDatasource | undefined>;\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, datasourceApi, children } = props;\n\n const getDatasource = useEvent(async (selector: DatasourceSelector): Promise<DatasourceSpec> => {\n // Try to find it in dashboard spec\n const { datasources } = dashboardResource.spec;\n const dashboardDatasource = findDashboardDatasource(datasources, selector);\n if (dashboardDatasource !== undefined) {\n return dashboardDatasource;\n }\n\n // Try to find it at the project level as a Datasource resource\n const { project } = dashboardResource.metadata;\n const datasource = await datasourceApi.getDatasource(project, selector);\n if (datasource !== undefined) {\n return datasource.spec;\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 globalDatasource.spec;\n }\n\n throw new Error(`No datasource found for kind '${selector.kind}' and name '${selector.name}'`);\n });\n\n const ctxValue: DatasourceStore = useMemo(\n () => ({\n getDatasource,\n }),\n [getDatasource]\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"],"names":["useMemo","useEvent","DatasourceStoreContext","DatasourceStoreProvider","props","dashboardResource","datasourceApi","children","getDatasource","selector","datasources","spec","dashboardDatasource","findDashboardDatasource","undefined","project","metadata","datasource","globalDatasource","getGlobalDatasource","Error","kind","name","ctxValue","Provider","value","dashboardDatasources","named","plugin","Object","values","find","ds","default"],"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,SAASA,OAAO,QAAQ,OAAO,CAAC;AAChC,SAOEC,QAAQ,QACH,kBAAkB,CAAC;AAC1B,SAASC,sBAAsB,QAAyB,2BAA2B,CAAC;AAcpF;;CAEC,GACD,OAAO,SAASC,uBAAuB,CAACC,KAAmC,EAAE;IAC3E,MAAM,EAAEC,iBAA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AAC;AAED,uEAAuE;AACvE,SAASM,uBAAuB,CAACa,oBAAkD,EAAEjB,QAA4B,EAAE;IACjH,IAAIiB,oBAAoB,KAAKZ,SAAS,EAAE,OAAOA,SAAS,CAAC;IAEzD,qCAAqC;IACrC,IAAIL,QAAQ,CAACa,IAAI,KAAKR,SAAS,EAAE;QAC/B,MAAMa,KAAK,GAAGD,oBAAoB,CAACjB,QAAQ,CAACa,IAAI,CAAC,AAAC;QAClD,IAAIK,KAAK,KAAKb,SAAS,EAAE,OAAOA,SAAS,CAAC;QAC1C,OAAOa,KAAK,CAACC,MAAM,CAACP,IAAI,KAAKZ,QAAQ,CAACY,IAAI,GAAGM,KAAK,GAAGb,SAAS,CAAC;IACjE,CAAC;IAED,2EAA2E;IAC3E,OAAOe,MAAM,CAACC,MAAM,CAACJ,oBAAoB,CAAC,CAACK,IAAI,CAAC,CAACC,EAAE,GAAKA,EAAE,CAACJ,MAAM,CAACP,IAAI,KAAKZ,QAAQ,CAACY,IAAI,IAAIW,EAAE,CAACC,OAAO,KAAK,IAAI,CAAC,CAAC;AACnH,CAAC"}
|
|
@@ -1 +1,43 @@
|
|
|
1
|
-
|
|
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
|
+
import { immer } from 'zustand/middleware/immer';
|
|
14
|
+
import { useDashboardStore } from './DashboardProvider';
|
|
15
|
+
export const createLayoutsSlice = immer((set)=>{
|
|
16
|
+
return {
|
|
17
|
+
updateLayout: (layout, index)=>set((state)=>{
|
|
18
|
+
if (index === undefined) {
|
|
19
|
+
state.layouts.unshift(layout);
|
|
20
|
+
} else {
|
|
21
|
+
state.layouts[index] = layout;
|
|
22
|
+
}
|
|
23
|
+
}),
|
|
24
|
+
addItemToLayout: (index, item)=>{
|
|
25
|
+
return set((state)=>{
|
|
26
|
+
const layouts = state.layouts;
|
|
27
|
+
if (layouts && layouts[index]) {
|
|
28
|
+
var ref;
|
|
29
|
+
(ref = layouts[index]) === null || ref === void 0 ? void 0 : ref.spec.items.push(item);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
export function useLayouts() {
|
|
36
|
+
return useDashboardStore(({ layouts , updateLayout , addItemToLayout })=>({
|
|
37
|
+
layouts,
|
|
38
|
+
updateLayout,
|
|
39
|
+
addItemToLayout
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
//# sourceMappingURL=LayoutsSlice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/context/LayoutsSlice.tsx"],"sourcesContent":["// Copyright 2022 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 { LayoutDefinition, GridItemDefinition } from '@perses-dev/core';\nimport { immer } from 'zustand/middleware/immer';\nimport { DashboardStoreState, useDashboardStore } from './DashboardProvider';\n\nexport interface LayoutsSlice {\n updateLayout: (layout: LayoutDefinition, index?: number) => void;\n addItemToLayout: (index: number, item: GridItemDefinition) => void;\n}\n\nexport const createLayoutsSlice = immer<LayoutsSlice>((set) => ({\n updateLayout: (layout: LayoutDefinition, index?: number) =>\n set((state) => {\n if (index === undefined) {\n (state as DashboardStoreState).layouts.unshift(layout);\n } else {\n (state as DashboardStoreState).layouts[index] = layout;\n }\n }),\n addItemToLayout: (index: number, item: GridItemDefinition) =>\n set((state) => {\n const layouts = (state as DashboardStoreState).layouts;\n if (layouts && layouts[index]) {\n layouts[index]?.spec.items.push(item);\n }\n }),\n}));\n\nexport function useLayouts() {\n return useDashboardStore(({ layouts, updateLayout, addItemToLayout }) => ({\n layouts,\n updateLayout,\n addItemToLayout,\n }));\n}\n"],"names":["immer","useDashboardStore","createLayoutsSlice","set","updateLayout","layout","index","state","undefined","layouts","unshift","addItemToLayout","item","spec","items","push","useLayouts"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,KAAK,QAAQ,0BAA0B,CAAC;AACjD,SAA8BC,iBAAiB,QAAQ,qBAAqB,CAAC;AAO7E,OAAO,MAAMC,kBAAkB,GAAGF,KAAK,CAAe,CAACG,GAAG;IAAM,OAAA;QAC9DC,YAAY,EAAE,CAACC,MAAwB,EAAEC,KAAc,GACrDH,GAAG,CAAC,CAACI,KAAK,GAAK;gBACb,IAAID,KAAK,KAAKE,SAAS,EAAE;oBACvB,AAACD,KAAK,CAAyBE,OAAO,CAACC,OAAO,CAACL,MAAM,CAAC,CAAC;gBACzD,OAAO;oBACL,AAACE,KAAK,CAAyBE,OAAO,CAACH,KAAK,CAAC,GAAGD,MAAM,CAAC;gBACzD,CAAC;YACH,CAAC,CAAC;QACJM,eAAe,EAAE,CAACL,KAAa,EAAEM,IAAwB;YACvDT,OAAAA,GAAG,CAAC,CAACI,KAAK,GAAK;gBACb,MAAME,OAAO,GAAG,AAACF,KAAK,CAAyBE,OAAO,AAAC;gBACvD,IAAIA,OAAO,IAAIA,OAAO,CAACH,KAAK,CAAC,EAAE;wBAC7BG,GAAc;oBAAdA,CAAAA,GAAc,GAAdA,OAAO,CAACH,KAAK,CAAC,cAAdG,GAAc,WAAM,GAApBA,KAAAA,CAAoB,GAApBA,GAAc,CAAEI,IAAI,CAACC,KAAK,CAACC,IAAI,CAACH,IAAI,CAAC,CAAC;gBACxC,CAAC;YACH,CAAC,CAAC,CAAA;SAAA;KACL,CAAA;CAAC,CAAC,CAAC;AAEJ,OAAO,SAASI,UAAU,GAAG;IAC3B,OAAOf,iBAAiB,CAAC,CAAC,EAAEQ,OAAO,CAAA,EAAEL,YAAY,CAAA,EAAEO,eAAe,CAAA,EAAE,GAAM,CAAA;YACxEF,OAAO;YACPL,YAAY;YACZO,eAAe;SAChB,CAAA,AAAC,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -1 +1,40 @@
|
|
|
1
|
-
|
|
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
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import React, { useContext, useMemo } from 'react';
|
|
15
|
+
import { QueryStringContext } from '@perses-dev/plugin-system';
|
|
16
|
+
/**
|
|
17
|
+
* Allows apps to provide their own query string implementations
|
|
18
|
+
*/ export function QueryStringProvider(props) {
|
|
19
|
+
const { queryString , setQueryString , children } = props;
|
|
20
|
+
const ctx = useMemo(()=>({
|
|
21
|
+
queryString,
|
|
22
|
+
setQueryString
|
|
23
|
+
}), [
|
|
24
|
+
queryString,
|
|
25
|
+
setQueryString
|
|
26
|
+
]);
|
|
27
|
+
return /*#__PURE__*/ _jsx(QueryStringContext.Provider, {
|
|
28
|
+
value: ctx,
|
|
29
|
+
children: children
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
export function useQueryString() {
|
|
33
|
+
const ctx = useContext(QueryStringContext);
|
|
34
|
+
if (ctx === undefined) {
|
|
35
|
+
throw new Error('No QueryStringContext found. Did you forget a Provider?');
|
|
36
|
+
}
|
|
37
|
+
return ctx;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=QueryStringProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/context/QueryStringProvider.tsx"],"sourcesContent":["// Copyright 2022 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 React, { useContext, useMemo } from 'react';\nimport { QueryString, QueryStringContext } from '@perses-dev/plugin-system';\n\nexport interface QueryStringProviderProps {\n queryString: URLSearchParams;\n setQueryString?: (queryString: URLSearchParams) => void;\n children?: React.ReactNode;\n}\n\n/**\n * Allows apps to provide their own query string implementations\n */\nexport function QueryStringProvider(props: QueryStringProviderProps) {\n const { queryString, setQueryString, children } = props;\n\n const ctx = useMemo(() => ({ queryString, setQueryString }), [queryString, setQueryString]);\n\n return <QueryStringContext.Provider value={ctx}>{children}</QueryStringContext.Provider>;\n}\n\nexport function useQueryString(): QueryString {\n const ctx = useContext(QueryStringContext);\n if (ctx === undefined) {\n throw new Error('No QueryStringContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n"],"names":["React","useContext","useMemo","QueryStringContext","QueryStringProvider","props","queryString","setQueryString","children","ctx","Provider","value","useQueryString","undefined","Error"],"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,OAAOA,KAAK,IAAIC,UAAU,EAAEC,OAAO,QAAQ,OAAO,CAAC;AACnD,SAAsBC,kBAAkB,QAAQ,2BAA2B,CAAC;AAQ5E;;CAEC,GACD,OAAO,SAASC,mBAAmB,CAACC,KAA+B,EAAE;IACnE,MAAM,EAAEC,WAAW,CAAA,EAAEC,cAAc,CAAA,EAAEC,QAAQ,CAAA,EAAE,GAAGH,KAAK,AAAC;IAExD,MAAMI,GAAG,GAAGP,OAAO,CAAC,IAAO,CAAA;YAAEI,WAAW;YAAEC,cAAc;SAAE,CAAA,AAAC,EAAE;QAACD,WAAW;QAAEC,cAAc;KAAC,CAAC,AAAC;IAE5F,qBAAO,KAACJ,kBAAkB,CAACO,QAAQ;QAACC,KAAK,EAAEF,GAAG;kBAAGD,QAAQ;MAA+B,CAAC;AAC3F,CAAC;AAED,OAAO,SAASI,cAAc,GAAgB;IAC5C,MAAMH,GAAG,GAAGR,UAAU,CAACE,kBAAkB,CAAC,AAAC;IAC3C,IAAIM,GAAG,KAAKI,SAAS,EAAE;QACrB,MAAM,IAAIC,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;IACD,OAAOL,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { VariableStateMap, VariableState,
|
|
2
|
+
import { VariableStateMap, VariableState, VariableOption } from '@perses-dev/plugin-system';
|
|
3
|
+
import { VariableName, VariableValue, VariableDefinition } from '@perses-dev/core';
|
|
3
4
|
declare type TemplateVariableStore = {
|
|
4
5
|
variableDefinitions: VariableDefinition[];
|
|
5
6
|
variableState: VariableStateMap;
|
|
6
7
|
setVariableValue: (variableName: VariableName, value: VariableValue) => void;
|
|
7
|
-
|
|
8
|
+
setVariableOptions: (name: VariableName, options: VariableOption[]) => void;
|
|
9
|
+
setVariableLoading: (name: VariableName, loading: boolean) => void;
|
|
8
10
|
};
|
|
9
11
|
export declare function useTemplateVariableValues(variableNames?: string[]): VariableStateMap;
|
|
10
12
|
export declare function useTemplateVariable(name: string): {
|
|
@@ -13,7 +15,8 @@ export declare function useTemplateVariable(name: string): {
|
|
|
13
15
|
};
|
|
14
16
|
export declare function useTemplateVariableActions(): {
|
|
15
17
|
setVariableValue: (variableName: string, value: VariableValue) => void;
|
|
16
|
-
|
|
18
|
+
setVariableLoading: (name: string, loading: boolean) => void;
|
|
19
|
+
setVariableOptions: (name: string, options: VariableOption[]) => void;
|
|
17
20
|
};
|
|
18
21
|
export declare function useTemplateVariableDefinitions(): VariableDefinition[];
|
|
19
22
|
export declare function useTemplateVariableStore(): TemplateVariableStore;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TemplateVariableProvider.d.ts","sourceRoot":"","sources":["../../src/context/TemplateVariableProvider.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"TemplateVariableProvider.d.ts","sourceRoot":"","sources":["../../src/context/TemplateVariableProvider.tsx"],"names":[],"mappings":";AAiBA,OAAO,EAEL,gBAAgB,EAChB,aAAa,EACb,cAAc,EAEf,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEnF,aAAK,qBAAqB,GAAG;IAC3B,mBAAmB,EAAE,kBAAkB,EAAE,CAAC;IAC1C,aAAa,EAAE,gBAAgB,CAAC;IAChC,gBAAgB,EAAE,CAAC,YAAY,EAAE,YAAY,EAAE,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC7E,kBAAkB,EAAE,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,KAAK,IAAI,CAAC;IAC5E,kBAAkB,EAAE,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CACpE,CAAC;AAaF,wBAAgB,yBAAyB,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,oBAqBjE;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM;;;EAU/C;AAED,wBAAgB,0BAA0B;;;;EASzC;AAED,wBAAgB,8BAA8B,yBAG7C;AAED,wBAAgB,wBAAwB,0BAGvC;AA8ED,wBAAgB,wBAAwB,CAAC,EACvC,QAAQ,EACR,0BAA+B,GAChC,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,0BAA0B,CAAC,EAAE,kBAAkB,EAAE,CAAC;CACnD,eAQA"}
|
|
@@ -1 +1,192 @@
|
|
|
1
|
-
|
|
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
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { createContext, useContext, useMemo, useState } from 'react';
|
|
15
|
+
import { createStore, useStore } from 'zustand';
|
|
16
|
+
import { immer } from 'zustand/middleware/immer';
|
|
17
|
+
import { devtools } from 'zustand/middleware';
|
|
18
|
+
import { TemplateVariableContext, DEFAULT_ALL_VALUE as ALL_VALUE } from '@perses-dev/plugin-system';
|
|
19
|
+
const TemplateVariableStoreContext = /*#__PURE__*/ createContext(undefined);
|
|
20
|
+
function useTemplateVariableStoreCtx() {
|
|
21
|
+
const context = useContext(TemplateVariableStoreContext);
|
|
22
|
+
if (!context) {
|
|
23
|
+
throw new Error('TemplateVariableStoreContext not initialized');
|
|
24
|
+
}
|
|
25
|
+
return context;
|
|
26
|
+
}
|
|
27
|
+
export function useTemplateVariableValues(variableNames) {
|
|
28
|
+
const store = useTemplateVariableStoreCtx();
|
|
29
|
+
const state = useStore(store, (s)=>{
|
|
30
|
+
const names = variableNames !== null && variableNames !== void 0 ? variableNames : Object.keys(s.variableState);
|
|
31
|
+
const vars = {};
|
|
32
|
+
names.forEach((name)=>{
|
|
33
|
+
const varState = s.variableState[name];
|
|
34
|
+
if (!varState) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
vars[name] = varState;
|
|
38
|
+
});
|
|
39
|
+
return vars;
|
|
40
|
+
}, (left, right)=>{
|
|
41
|
+
return JSON.stringify(left) === JSON.stringify(right);
|
|
42
|
+
});
|
|
43
|
+
return state;
|
|
44
|
+
}
|
|
45
|
+
export function useTemplateVariable(name) {
|
|
46
|
+
const store = useTemplateVariableStoreCtx();
|
|
47
|
+
return useStore(store, (s)=>{
|
|
48
|
+
const variableState = s.variableState[name];
|
|
49
|
+
const definition = s.variableDefinitions.find((v)=>v.spec.name === name);
|
|
50
|
+
return {
|
|
51
|
+
state: variableState,
|
|
52
|
+
definition
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
export function useTemplateVariableActions() {
|
|
57
|
+
const store = useTemplateVariableStoreCtx();
|
|
58
|
+
return useStore(store, (s)=>{
|
|
59
|
+
return {
|
|
60
|
+
setVariableValue: s.setVariableValue,
|
|
61
|
+
setVariableLoading: s.setVariableLoading,
|
|
62
|
+
setVariableOptions: s.setVariableOptions
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
export function useTemplateVariableDefinitions() {
|
|
67
|
+
const store = useTemplateVariableStoreCtx();
|
|
68
|
+
return useStore(store, (s)=>s.variableDefinitions);
|
|
69
|
+
}
|
|
70
|
+
export function useTemplateVariableStore() {
|
|
71
|
+
const store = useTemplateVariableStoreCtx();
|
|
72
|
+
return useStore(store);
|
|
73
|
+
}
|
|
74
|
+
function PluginProvider({ children }) {
|
|
75
|
+
const originalValues = useTemplateVariableValues();
|
|
76
|
+
const values = useMemo(()=>{
|
|
77
|
+
const contextValues = {};
|
|
78
|
+
// This will loop through all the current variables values
|
|
79
|
+
// and update any variables that have ALL_VALUE as their current value
|
|
80
|
+
// to include all options.
|
|
81
|
+
Object.keys(originalValues).forEach((name)=>{
|
|
82
|
+
const v = {
|
|
83
|
+
...originalValues[name]
|
|
84
|
+
};
|
|
85
|
+
if (v.value === ALL_VALUE) {
|
|
86
|
+
var ref;
|
|
87
|
+
var ref1;
|
|
88
|
+
v.value = (ref1 = (ref = v.options) === null || ref === void 0 ? void 0 : ref.map((o)=>o.value)) !== null && ref1 !== void 0 ? ref1 : null;
|
|
89
|
+
}
|
|
90
|
+
contextValues[name] = v;
|
|
91
|
+
});
|
|
92
|
+
return contextValues;
|
|
93
|
+
}, [
|
|
94
|
+
originalValues
|
|
95
|
+
]);
|
|
96
|
+
return /*#__PURE__*/ _jsx(TemplateVariableContext.Provider, {
|
|
97
|
+
value: {
|
|
98
|
+
state: values
|
|
99
|
+
},
|
|
100
|
+
children: children
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
function createTemplateVariableSrvStore({ initialVariableDefinitions =[] }) {
|
|
104
|
+
const store = createStore()(devtools(immer((set)=>({
|
|
105
|
+
variableState: hydrateTemplateVariableStates(initialVariableDefinitions),
|
|
106
|
+
variableDefinitions: initialVariableDefinitions,
|
|
107
|
+
setVariableOptions (name, options) {
|
|
108
|
+
set((state)=>{
|
|
109
|
+
const varState = state.variableState[name];
|
|
110
|
+
if (!varState) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
varState.options = options;
|
|
114
|
+
});
|
|
115
|
+
},
|
|
116
|
+
setVariableLoading (name, loading) {
|
|
117
|
+
set((state)=>{
|
|
118
|
+
const varState = state.variableState[name];
|
|
119
|
+
if (!varState) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
varState.loading = loading;
|
|
123
|
+
});
|
|
124
|
+
},
|
|
125
|
+
setVariableValue: (name, value)=>set((state)=>{
|
|
126
|
+
let val = value;
|
|
127
|
+
const varState = state.variableState[name];
|
|
128
|
+
if (!varState) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
// Make sure there is only one all value
|
|
132
|
+
if (Array.isArray(val) && val.includes(ALL_VALUE)) {
|
|
133
|
+
if (val.at(-1) === ALL_VALUE) {
|
|
134
|
+
val = ALL_VALUE;
|
|
135
|
+
} else {
|
|
136
|
+
val = val.filter((v)=>v !== ALL_VALUE);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
varState.value = val;
|
|
140
|
+
})
|
|
141
|
+
}))));
|
|
142
|
+
return store;
|
|
143
|
+
}
|
|
144
|
+
export function TemplateVariableProvider({ children , initialVariableDefinitions =[] }) {
|
|
145
|
+
const [store] = useState(createTemplateVariableSrvStore({
|
|
146
|
+
initialVariableDefinitions
|
|
147
|
+
}));
|
|
148
|
+
return /*#__PURE__*/ _jsx(TemplateVariableStoreContext.Provider, {
|
|
149
|
+
value: store,
|
|
150
|
+
children: /*#__PURE__*/ _jsx(PluginProvider, {
|
|
151
|
+
children: children
|
|
152
|
+
})
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
/** Helpers */ function hydrateTemplateVariableState(definition) {
|
|
156
|
+
const v = definition;
|
|
157
|
+
var _default_value;
|
|
158
|
+
const varState = {
|
|
159
|
+
value: (_default_value = v.spec.default_value) !== null && _default_value !== void 0 ? _default_value : null,
|
|
160
|
+
loading: false
|
|
161
|
+
};
|
|
162
|
+
switch(v.kind){
|
|
163
|
+
case 'TextVariable':
|
|
164
|
+
varState.value = v.spec.value;
|
|
165
|
+
break;
|
|
166
|
+
case 'ListVariable':
|
|
167
|
+
varState.options = [];
|
|
168
|
+
if (varState.options.length > 0 && !varState.value) {
|
|
169
|
+
var ref;
|
|
170
|
+
var ref1;
|
|
171
|
+
const firstOptionValue = (ref1 = (ref = varState.options[0]) === null || ref === void 0 ? void 0 : ref.value) !== null && ref1 !== void 0 ? ref1 : null;
|
|
172
|
+
if (firstOptionValue !== null) {
|
|
173
|
+
varState.value = v.spec.allow_multiple ? [
|
|
174
|
+
firstOptionValue
|
|
175
|
+
] : firstOptionValue;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
break;
|
|
179
|
+
default:
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
return varState;
|
|
183
|
+
}
|
|
184
|
+
function hydrateTemplateVariableStates(definitions) {
|
|
185
|
+
const state = {};
|
|
186
|
+
definitions.forEach((v)=>{
|
|
187
|
+
state[v.spec.name] = hydrateTemplateVariableState(v);
|
|
188
|
+
});
|
|
189
|
+
return state;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
//# sourceMappingURL=TemplateVariableProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/context/TemplateVariableProvider.tsx"],"sourcesContent":["// Copyright 2022 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 { createContext, useContext, useMemo, useState } from 'react';\nimport { createStore, useStore } from 'zustand';\nimport { immer } from 'zustand/middleware/immer';\nimport { devtools } from 'zustand/middleware';\nimport {\n TemplateVariableContext,\n VariableStateMap,\n VariableState,\n VariableOption,\n DEFAULT_ALL_VALUE as ALL_VALUE,\n} from '@perses-dev/plugin-system';\nimport { VariableName, VariableValue, VariableDefinition } from '@perses-dev/core';\n\ntype TemplateVariableStore = {\n variableDefinitions: VariableDefinition[];\n variableState: VariableStateMap;\n setVariableValue: (variableName: VariableName, value: VariableValue) => void;\n setVariableOptions: (name: VariableName, options: VariableOption[]) => void;\n setVariableLoading: (name: VariableName, loading: boolean) => void;\n};\n\nconst TemplateVariableStoreContext = createContext<ReturnType<typeof createTemplateVariableSrvStore> | undefined>(\n undefined\n);\nfunction useTemplateVariableStoreCtx() {\n const context = useContext(TemplateVariableStoreContext);\n if (!context) {\n throw new Error('TemplateVariableStoreContext not initialized');\n }\n return context;\n}\n\nexport function useTemplateVariableValues(variableNames?: string[]) {\n const store = useTemplateVariableStoreCtx();\n const state = useStore(\n store,\n (s) => {\n const names = variableNames ?? Object.keys(s.variableState);\n const vars: VariableStateMap = {};\n names.forEach((name) => {\n const varState = s.variableState[name];\n if (!varState) {\n return;\n }\n vars[name] = varState;\n });\n return vars;\n },\n (left, right) => {\n return JSON.stringify(left) === JSON.stringify(right);\n }\n );\n return state;\n}\n\nexport function useTemplateVariable(name: string) {\n const store = useTemplateVariableStoreCtx();\n return useStore(store, (s) => {\n const variableState = s.variableState[name];\n const definition = s.variableDefinitions.find((v) => v.spec.name === name);\n return {\n state: variableState,\n definition,\n };\n });\n}\n\nexport function useTemplateVariableActions() {\n const store = useTemplateVariableStoreCtx();\n return useStore(store, (s) => {\n return {\n setVariableValue: s.setVariableValue,\n setVariableLoading: s.setVariableLoading,\n setVariableOptions: s.setVariableOptions,\n };\n });\n}\n\nexport function useTemplateVariableDefinitions() {\n const store = useTemplateVariableStoreCtx();\n return useStore(store, (s) => s.variableDefinitions);\n}\n\nexport function useTemplateVariableStore() {\n const store = useTemplateVariableStoreCtx();\n return useStore(store);\n}\n\nfunction PluginProvider({ children }: { children: React.ReactNode }) {\n const originalValues = useTemplateVariableValues();\n\n const values = useMemo(() => {\n const contextValues: VariableStateMap = {};\n\n // This will loop through all the current variables values\n // and update any variables that have ALL_VALUE as their current value\n // to include all options.\n Object.keys(originalValues).forEach((name) => {\n const v = { ...originalValues[name] } as VariableState;\n if (v.value === ALL_VALUE) {\n v.value = v.options?.map((o: { value: string }) => o.value) ?? null;\n }\n contextValues[name] = v;\n });\n return contextValues;\n }, [originalValues]);\n\n return <TemplateVariableContext.Provider value={{ state: values }}>{children}</TemplateVariableContext.Provider>;\n}\n\ninterface TemplateVariableSrvArgs {\n initialVariableDefinitions?: VariableDefinition[];\n}\n\nfunction createTemplateVariableSrvStore({ initialVariableDefinitions = [] }: TemplateVariableSrvArgs) {\n const store = createStore<TemplateVariableStore>()(\n devtools(\n immer((set) => ({\n variableState: hydrateTemplateVariableStates(initialVariableDefinitions),\n variableDefinitions: initialVariableDefinitions,\n setVariableOptions(name, options) {\n set((state) => {\n const varState = state.variableState[name];\n if (!varState) {\n return;\n }\n varState.options = options;\n });\n },\n setVariableLoading(name, loading) {\n set((state) => {\n const varState = state.variableState[name];\n if (!varState) {\n return;\n }\n varState.loading = loading;\n });\n },\n\n setVariableValue: (name, value) =>\n set((state) => {\n let val = value;\n const varState = state.variableState[name];\n if (!varState) {\n return;\n }\n\n // Make sure there is only one all value\n if (Array.isArray(val) && val.includes(ALL_VALUE)) {\n if (val.at(-1) === ALL_VALUE) {\n val = ALL_VALUE;\n } else {\n val = val.filter((v) => v !== ALL_VALUE);\n }\n }\n varState.value = val;\n }),\n }))\n )\n );\n\n return store;\n}\n\nexport function TemplateVariableProvider({\n children,\n initialVariableDefinitions = [],\n}: {\n children: React.ReactNode;\n initialVariableDefinitions?: VariableDefinition[];\n}) {\n const [store] = useState(createTemplateVariableSrvStore({ initialVariableDefinitions }));\n\n return (\n <TemplateVariableStoreContext.Provider value={store}>\n <PluginProvider>{children}</PluginProvider>\n </TemplateVariableStoreContext.Provider>\n );\n}\n\n/** Helpers */\n\nfunction hydrateTemplateVariableState(definition: VariableDefinition) {\n const v = definition;\n const varState: VariableState = {\n value: v.spec.default_value ?? null,\n loading: false,\n };\n switch (v.kind) {\n case 'TextVariable':\n varState.value = v.spec.value;\n break;\n case 'ListVariable':\n varState.options = [];\n if (varState.options.length > 0 && !varState.value) {\n const firstOptionValue = varState.options[0]?.value ?? null;\n if (firstOptionValue !== null) {\n varState.value = v.spec.allow_multiple ? [firstOptionValue] : firstOptionValue;\n }\n }\n break;\n default:\n break;\n }\n return varState;\n}\n\nfunction hydrateTemplateVariableStates(definitions: VariableDefinition[]): VariableStateMap {\n const state: VariableStateMap = {};\n definitions.forEach((v) => {\n state[v.spec.name] = hydrateTemplateVariableState(v);\n });\n return state;\n}\n"],"names":["createContext","useContext","useMemo","useState","createStore","useStore","immer","devtools","TemplateVariableContext","DEFAULT_ALL_VALUE","ALL_VALUE","TemplateVariableStoreContext","undefined","useTemplateVariableStoreCtx","context","Error","useTemplateVariableValues","variableNames","store","state","s","names","Object","keys","variableState","vars","forEach","name","varState","left","right","JSON","stringify","useTemplateVariable","definition","variableDefinitions","find","v","spec","useTemplateVariableActions","setVariableValue","setVariableLoading","setVariableOptions","useTemplateVariableDefinitions","useTemplateVariableStore","PluginProvider","children","originalValues","values","contextValues","value","options","map","o","Provider","createTemplateVariableSrvStore","initialVariableDefinitions","set","hydrateTemplateVariableStates","loading","val","Array","isArray","includes","at","filter","TemplateVariableProvider","hydrateTemplateVariableState","default_value","kind","length","firstOptionValue","allow_multiple","definitions"],"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,SA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AA,IAA0B,GAA1BA,CAAAA,GAAmB,GAAnBA,QAAQ,CAACuB,OAAO,CAAC,CAAC,CAAC,cAAnBvB,GAAmB,WAAO,GAA1BA,KAAAA,CAA0B,GAA1BA,GAAmB,CAAEsB,KAAK,cAA1BtB,IAA0B,cAA1BA,IAA0B,GAAI,IAAI,AAAC;gBAC5D,IAAI2C,gBAAgB,KAAK,IAAI,EAAE;oBAC7B3C,QAAQ,CAACsB,KAAK,GAAGb,CAAC,CAACC,IAAI,CAACkC,cAAc,GAAG;wBAACD,gBAAgB;qBAAC,GAAGA,gBAAgB,CAAC;gBACjF,CAAC;YACH,CAAC;YACD,MAAM;QACR;YACE,MAAM;KACT;IACD,OAAO3C,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS8B,6BAA6B,CAACe,WAAiC,EAAoB;IAC1F,MAAMtD,KAAK,GAAqB,EAAE,AAAC;IACnCsD,WAAW,CAAC/C,OAAO,CAAC,CAACW,CAAC,GAAK;QACzBlB,KAAK,CAACkB,CAAC,CAACC,IAAI,CAACX,IAAI,CAAC,GAAGwC,4BAA4B,CAAC9B,CAAC,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IACH,OAAOlB,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1 +1,72 @@
|
|
|
1
|
-
|
|
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
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import React, { useState, useMemo, useCallback } from 'react';
|
|
15
|
+
import { getUnixTime } from 'date-fns';
|
|
16
|
+
import { toAbsoluteTimeRange, isRelativeTimeRange } from '@perses-dev/core';
|
|
17
|
+
import { TimeRangeContext, useQueryString } from '@perses-dev/plugin-system';
|
|
18
|
+
/**
|
|
19
|
+
* Provider implementation that supplies the time range state at runtime.
|
|
20
|
+
*/ export function TimeRangeProvider(props) {
|
|
21
|
+
const { initialTimeRange , children , onTimeRangeChange } = props;
|
|
22
|
+
const { queryString , setQueryString } = useQueryString();
|
|
23
|
+
const defaultTimeRange = isRelativeTimeRange(initialTimeRange) ? toAbsoluteTimeRange(initialTimeRange) : initialTimeRange;
|
|
24
|
+
const [timeRange, setActiveTimeRange] = useState(defaultTimeRange);
|
|
25
|
+
const setTimeRange = useCallback((value)=>{
|
|
26
|
+
if (onTimeRangeChange !== undefined) {
|
|
27
|
+
// optional callback to override default behavior
|
|
28
|
+
onTimeRangeChange(value);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (isRelativeTimeRange(value)) {
|
|
32
|
+
if (setQueryString) {
|
|
33
|
+
queryString.set('start', value.pastDuration);
|
|
34
|
+
// end not required for relative time but may have been set by AbsoluteTimePicker or zoom
|
|
35
|
+
queryString.delete('end');
|
|
36
|
+
setQueryString(queryString);
|
|
37
|
+
} else {
|
|
38
|
+
setActiveTimeRange(toAbsoluteTimeRange(value));
|
|
39
|
+
}
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
// allows app to specify whether query params should be source of truth for active time range
|
|
43
|
+
if (setQueryString) {
|
|
44
|
+
// Absolute URL example) ?start=1663707045000&end=1663713330000
|
|
45
|
+
// currently set from ViewDashboard initial queryString, AbsoluteTimePicker, or LineChart panel onDataZoom
|
|
46
|
+
const startUnixMs = getUnixTime(value.start) * 1000;
|
|
47
|
+
const endUnixMs = getUnixTime(value.end) * 1000;
|
|
48
|
+
queryString.set('start', startUnixMs.toString());
|
|
49
|
+
queryString.set('end', endUnixMs.toString());
|
|
50
|
+
setQueryString(queryString);
|
|
51
|
+
} else {
|
|
52
|
+
setActiveTimeRange(value);
|
|
53
|
+
}
|
|
54
|
+
}, [
|
|
55
|
+
queryString,
|
|
56
|
+
setQueryString,
|
|
57
|
+
onTimeRangeChange
|
|
58
|
+
]);
|
|
59
|
+
const ctx = useMemo(()=>({
|
|
60
|
+
timeRange,
|
|
61
|
+
setTimeRange
|
|
62
|
+
}), [
|
|
63
|
+
timeRange,
|
|
64
|
+
setTimeRange
|
|
65
|
+
]);
|
|
66
|
+
return /*#__PURE__*/ _jsx(TimeRangeContext.Provider, {
|
|
67
|
+
value: ctx,
|
|
68
|
+
children: children
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
//# sourceMappingURL=TimeRangeProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/context/TimeRangeProvider.tsx"],"sourcesContent":["// Copyright 2022 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 React, { useState, useMemo, useCallback } from 'react';\nimport { getUnixTime } from 'date-fns';\nimport { TimeRangeValue, AbsoluteTimeRange, toAbsoluteTimeRange, isRelativeTimeRange } from '@perses-dev/core';\nimport { TimeRange, TimeRangeContext, useQueryString } from '@perses-dev/plugin-system';\n\nexport interface TimeRangeProviderProps {\n initialTimeRange: TimeRangeValue;\n children?: React.ReactNode;\n onTimeRangeChange?: (e: TimeRangeValue) => void;\n}\n\n/**\n * Provider implementation that supplies the time range state at runtime.\n */\nexport function TimeRangeProvider(props: TimeRangeProviderProps) {\n const { initialTimeRange, children, onTimeRangeChange } = props;\n\n const { queryString, setQueryString } = useQueryString();\n\n const defaultTimeRange: AbsoluteTimeRange = isRelativeTimeRange(initialTimeRange)\n ? toAbsoluteTimeRange(initialTimeRange)\n : initialTimeRange;\n\n const [timeRange, setActiveTimeRange] = useState<AbsoluteTimeRange>(defaultTimeRange);\n\n const setTimeRange: TimeRange['setTimeRange'] = useCallback(\n (value: TimeRangeValue) => {\n if (onTimeRangeChange !== undefined) {\n // optional callback to override default behavior\n onTimeRangeChange(value);\n return;\n }\n\n if (isRelativeTimeRange(value)) {\n if (setQueryString) {\n queryString.set('start', value.pastDuration);\n // end not required for relative time but may have been set by AbsoluteTimePicker or zoom\n queryString.delete('end');\n setQueryString(queryString);\n } else {\n setActiveTimeRange(toAbsoluteTimeRange(value));\n }\n return;\n }\n\n // allows app to specify whether query params should be source of truth for active time range\n if (setQueryString) {\n // Absolute URL example) ?start=1663707045000&end=1663713330000\n // currently set from ViewDashboard initial queryString, AbsoluteTimePicker, or LineChart panel onDataZoom\n const startUnixMs = getUnixTime(value.start) * 1000;\n const endUnixMs = getUnixTime(value.end) * 1000;\n queryString.set('start', startUnixMs.toString());\n queryString.set('end', endUnixMs.toString());\n setQueryString(queryString);\n } else {\n setActiveTimeRange(value);\n }\n },\n [queryString, setQueryString, onTimeRangeChange]\n );\n\n const ctx = useMemo(() => ({ timeRange, setTimeRange }), [timeRange, setTimeRange]);\n\n return <TimeRangeContext.Provider value={ctx}>{children}</TimeRangeContext.Provider>;\n}\n"],"names":["React","useState","useMemo","useCallback","getUnixTime","toAbsoluteTimeRange","isRelativeTimeRange","TimeRangeContext","useQueryString","TimeRangeProvider","props","initialTimeRange","children","onTimeRangeChange","queryString","setQueryString","defaultTimeRange","timeRange","setActiveTimeRange","setTimeRange","value","undefined","set","pastDuration","delete","startUnixMs","start","endUnixMs","end","toString","ctx","Provider"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA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WAAW,CAAC,CAAC;YAC9B,OAAO;gBACLI,kBAAkB,CAACb,mBAAmB,CAACe,KAAK,CAAC,CAAC,CAAC;YACjD,CAAC;YACD,OAAO;QACT,CAAC;QAED,6FAA6F;QAC7F,IAAIL,cAAc,EAAE;YAClB,+DAA+D;YAC/D,0GAA0G;YAC1G,MAAMU,WAAW,GAAGrB,WAAW,CAACgB,KAAK,CAACM,KAAK,CAAC,GAAG,IAAI,AAAC;YACpD,MAAMC,SAAS,GAAGvB,WAAW,CAACgB,KAAK,CAACQ,GAAG,CAAC,GAAG,IAAI,AAAC;YAChDd,WAAW,CAACQ,GAAG,CAAC,OAAO,EAAEG,WAAW,CAACI,QAAQ,EAAE,CAAC,CAAC;YACjDf,WAAW,CAACQ,GAAG,CAAC,KAAK,EAAEK,SAAS,CAACE,QAAQ,EAAE,CAAC,CAAC;YAC7Cd,cAAc,CAACD,WAAW,CAAC,CAAC;QAC9B,OAAO;YACLI,kBAAkB,CAACE,KAAK,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC,EACD;QAACN,WAAW;QAAEC,cAAc;QAAEF,iBAAiB;KAAC,CACjD,AAAC;IAEF,MAAMiB,GAAG,GAAG5B,OAAO,CAAC,IAAO,CAAA;YAAEe,SAAS;YAAEE,YAAY;SAAE,CAAA,AAAC,EAAE;QAACF,SAAS;QAAEE,YAAY;KAAC,CAAC,AAAC;IAEpF,qBAAO,KAACZ,gBAAgB,CAACwB,QAAQ;QAACX,KAAK,EAAEU,GAAG;kBAAGlB,QAAQ;MAA6B,CAAC;AACvF,CAAC"}
|
package/dist/context/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export * from './DashboardAppSlice';
|
|
2
|
+
export * from './DashboardProvider';
|
|
3
|
+
export * from './DatasourceStoreProvider';
|
|
2
4
|
export * from './LayoutsSlice';
|
|
5
|
+
export * from './QueryStringProvider';
|
|
3
6
|
export * from './TemplateVariableProvider';
|
|
4
|
-
export * from './DashboardProvider';
|
|
5
7
|
export * from './TimeRangeProvider';
|
|
6
|
-
export * from './QueryStringProvider';
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/context/index.ts"],"names":[],"mappings":"AAaA,cAAc,qBAAqB,CAAC;AACpC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/context/index.ts"],"names":[],"mappings":"AAaA,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC"}
|