@perses-dev/dashboards 0.16.0 → 0.18.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/DashboardToolbar/DashboardToolbar.js +52 -41
- package/dist/cjs/components/GridLayout/GridContainer.js +2 -2
- package/dist/cjs/components/GridLayout/GridLayout.js +13 -2
- package/dist/cjs/components/GridLayout/GridTitle.js +4 -6
- package/dist/cjs/components/Panel/PanelHeader.js +1 -1
- package/dist/cjs/components/PanelDrawer/PanelDrawer.js +3 -4
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +28 -5
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.test.js +11 -5
- package/dist/cjs/components/Variables/Variable.js +2 -46
- package/dist/cjs/components/Variables/VariableEditor.js +142 -130
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +318 -167
- package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +5 -4
- package/dist/cjs/components/Variables/VariableList.js +13 -8
- package/dist/cjs/components/Variables/variable-model.js +106 -0
- package/dist/cjs/components/Variables/variable-model.test.js +106 -0
- package/dist/cjs/context/TemplateVariableProvider/query-params.js +3 -1
- package/dist/cjs/context/index.js +0 -1
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +2 -1
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +6 -4
- package/dist/cjs/views/ViewDashboard/tests/panelGroups.test.js +4 -2
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts +1 -0
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.js +53 -42
- package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
- package/dist/components/GridLayout/GridContainer.js +2 -2
- package/dist/components/GridLayout/GridContainer.js.map +1 -1
- package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
- package/dist/components/GridLayout/GridLayout.js +13 -2
- package/dist/components/GridLayout/GridLayout.js.map +1 -1
- package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
- package/dist/components/GridLayout/GridTitle.js +4 -6
- package/dist/components/GridLayout/GridTitle.js.map +1 -1
- package/dist/components/Panel/PanelHeader.js +1 -1
- package/dist/components/Panel/PanelHeader.js.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.js +3 -4
- package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js +24 -7
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.test.js +11 -5
- package/dist/components/TimeRangeControls/TimeRangeControls.test.js.map +1 -1
- package/dist/components/Variables/Variable.d.ts.map +1 -1
- package/dist/components/Variables/Variable.js +3 -47
- package/dist/components/Variables/Variable.js.map +1 -1
- package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditor.js +142 -130
- package/dist/components/Variables/VariableEditor.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +315 -169
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +1 -0
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +5 -4
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
- package/dist/components/Variables/VariableList.d.ts +2 -0
- package/dist/components/Variables/VariableList.d.ts.map +1 -1
- package/dist/components/Variables/VariableList.js +13 -8
- package/dist/components/Variables/VariableList.js.map +1 -1
- package/dist/components/Variables/variable-model.d.ts +9 -0
- package/dist/components/Variables/variable-model.d.ts.map +1 -0
- package/dist/components/Variables/variable-model.js +95 -0
- package/dist/components/Variables/variable-model.js.map +1 -0
- package/dist/components/Variables/variable-model.test.d.ts +2 -0
- package/dist/components/Variables/variable-model.test.d.ts.map +1 -0
- package/dist/components/Variables/variable-model.test.js +104 -0
- package/dist/components/Variables/variable-model.test.js.map +1 -0
- package/dist/context/TemplateVariableProvider/query-params.js +3 -1
- package/dist/context/TemplateVariableProvider/query-params.js.map +1 -1
- package/dist/context/index.d.ts +0 -1
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +0 -1
- package/dist/context/index.js.map +1 -1
- 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 +2 -1
- 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 +5 -3
- package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
- package/dist/views/ViewDashboard/tests/panelGroups.test.js +4 -2
- package/dist/views/ViewDashboard/tests/panelGroups.test.js.map +1 -1
- package/package.json +5 -5
- package/dist/cjs/context/TimeRangeProvider/TimeRangeProvider.js +0 -91
- package/dist/cjs/context/TimeRangeProvider/index.js +0 -29
- package/dist/cjs/context/TimeRangeProvider/query-params.js +0 -157
- package/dist/context/TimeRangeProvider/TimeRangeProvider.d.ts +0 -19
- package/dist/context/TimeRangeProvider/TimeRangeProvider.d.ts.map +0 -1
- package/dist/context/TimeRangeProvider/TimeRangeProvider.js +0 -44
- package/dist/context/TimeRangeProvider/TimeRangeProvider.js.map +0 -1
- package/dist/context/TimeRangeProvider/index.d.ts +0 -3
- package/dist/context/TimeRangeProvider/index.d.ts.map +0 -1
- package/dist/context/TimeRangeProvider/index.js +0 -16
- package/dist/context/TimeRangeProvider/index.js.map +0 -1
- package/dist/context/TimeRangeProvider/query-params.d.ts +0 -25
- package/dist/context/TimeRangeProvider/query-params.d.ts.map +0 -1
- package/dist/context/TimeRangeProvider/query-params.js +0 -149
- package/dist/context/TimeRangeProvider/query-params.js.map +0 -1
|
@@ -13,12 +13,13 @@
|
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import { Box } from '@mui/material';
|
|
15
15
|
import { ErrorBoundary, ErrorAlert, combineSx } from '@perses-dev/components';
|
|
16
|
-
import { TimeRangeProvider,
|
|
16
|
+
import { TimeRangeProvider, useInitialTimeRange } from '@perses-dev/plugin-system';
|
|
17
|
+
import { TemplateVariableProvider, DashboardProvider, DatasourceStoreProvider } from '../../context';
|
|
17
18
|
import { DashboardApp } from './DashboardApp';
|
|
18
19
|
/**
|
|
19
20
|
* The View for displaying a Dashboard, along with the UI for selecting variable values.
|
|
20
21
|
*/ export function ViewDashboard(props) {
|
|
21
|
-
const { dashboardResource , datasourceApi , dashboardTitleComponent , initialVariableIsSticky , sx , ...others } = props;
|
|
22
|
+
const { dashboardResource , datasourceApi , dashboardTitleComponent , initialVariableIsSticky , isReadonly , sx , ...others } = props;
|
|
22
23
|
const { spec } = dashboardResource;
|
|
23
24
|
var _duration;
|
|
24
25
|
const dashboardDuration = (_duration = spec.duration) !== null && _duration !== void 0 ? _duration : '1h';
|
|
@@ -49,7 +50,8 @@ import { DashboardApp } from './DashboardApp';
|
|
|
49
50
|
children: /*#__PURE__*/ _jsx(DashboardApp, {
|
|
50
51
|
dashboardResource: dashboardResource,
|
|
51
52
|
dashboardTitleComponent: dashboardTitleComponent,
|
|
52
|
-
initialVariableIsSticky: initialVariableIsSticky
|
|
53
|
+
initialVariableIsSticky: initialVariableIsSticky,
|
|
54
|
+
isReadonly: isReadonly
|
|
53
55
|
})
|
|
54
56
|
})
|
|
55
57
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/views/ViewDashboard/ViewDashboard.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 { Box, BoxProps } from '@mui/material';\nimport { DashboardResource } from '@perses-dev/core';\nimport { ErrorBoundary, ErrorAlert, combineSx } from '@perses-dev/components';\nimport {\n
|
|
1
|
+
{"version":3,"sources":["../../../src/views/ViewDashboard/ViewDashboard.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 { Box, BoxProps } from '@mui/material';\nimport { DashboardResource } from '@perses-dev/core';\nimport { ErrorBoundary, ErrorAlert, combineSx } from '@perses-dev/components';\nimport { TimeRangeProvider, useInitialTimeRange } from '@perses-dev/plugin-system';\nimport {\n TemplateVariableProvider,\n DashboardProvider,\n DatasourceStoreProviderProps,\n DatasourceStoreProvider,\n} from '../../context';\nimport { DashboardApp } from './DashboardApp';\n\nexport interface ViewDashboardProps extends Omit<BoxProps, 'children'> {\n dashboardResource: DashboardResource;\n datasourceApi: DatasourceStoreProviderProps['datasourceApi'];\n dashboardTitleComponent?: JSX.Element;\n initialVariableIsSticky?: boolean;\n isReadonly: boolean;\n}\n\n/**\n * The View for displaying a Dashboard, along with the UI for selecting variable values.\n */\nexport function ViewDashboard(props: ViewDashboardProps) {\n const {\n dashboardResource,\n datasourceApi,\n dashboardTitleComponent,\n initialVariableIsSticky,\n isReadonly,\n sx,\n ...others\n } = props;\n const { spec } = dashboardResource;\n const dashboardDuration = spec.duration ?? '1h';\n const initialTimeRange = useInitialTimeRange(dashboardDuration);\n return (\n <DatasourceStoreProvider dashboardResource={dashboardResource} datasourceApi={datasourceApi}>\n <DashboardProvider initialState={{ dashboardResource }}>\n <TimeRangeProvider initialTimeRange={initialTimeRange} enabledURLParams={true}>\n <TemplateVariableProvider initialVariableDefinitions={spec.variables}>\n <Box\n sx={combineSx(\n {\n display: 'flex',\n width: '100%',\n height: '100%',\n position: 'relative',\n overflow: 'hidden',\n },\n sx\n )}\n {...others}\n >\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <DashboardApp\n dashboardResource={dashboardResource}\n dashboardTitleComponent={dashboardTitleComponent}\n initialVariableIsSticky={initialVariableIsSticky}\n isReadonly={isReadonly}\n />\n </ErrorBoundary>\n </Box>\n </TemplateVariableProvider>\n </TimeRangeProvider>\n </DashboardProvider>\n </DatasourceStoreProvider>\n );\n}\n"],"names":["Box","ErrorBoundary","ErrorAlert","combineSx","TimeRangeProvider","useInitialTimeRange","TemplateVariableProvider","DashboardProvider","DatasourceStoreProvider","DashboardApp","ViewDashboard","props","dashboardResource","datasourceApi","dashboardTitleComponent","initialVariableIsSticky","isReadonly","sx","others","spec","dashboardDuration","duration","initialTimeRange","initialState","enabledURLParams","initialVariableDefinitions","variables","display","width","height","position","overflow","FallbackComponent"],"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,GAAG,QAAkB,eAAe,CAAC;AAE9C,SAASC,aAAa,EAAEC,UAAU,EAAEC,SAAS,QAAQ,wBAAwB,CAAC;AAC9E,SAASC,iBAAiB,EAAEC,mBAAmB,QAA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,KAACO,YAAY;gCACXG,iBAAiB,EAAEA,iBAAiB;gCACpCE,uBAAuB,EAAEA,uBAAuB;gCAChDC,uBAAuB,EAAEA,uBAAuB;gCAChDC,UAAU,EAAEA,UAAU;8BACtB;0BACY;sBACZ;kBACmB;cACT;UACF;MACI,CAC1B;AACJ,CAAC"}
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import { screen } from '@testing-library/react';
|
|
15
15
|
import userEvent from '@testing-library/user-event';
|
|
16
|
-
import {
|
|
16
|
+
import { TimeRangeProvider } from '@perses-dev/plugin-system';
|
|
17
|
+
import { DashboardProvider, TemplateVariableProvider } from '../../../context';
|
|
17
18
|
import { getTestDashboard, renderWithContext } from '../../../test';
|
|
18
19
|
import { DashboardApp } from '../DashboardApp';
|
|
19
20
|
describe('Panel Groups', ()=>{
|
|
@@ -29,7 +30,8 @@ describe('Panel Groups', ()=>{
|
|
|
29
30
|
isEditMode: true
|
|
30
31
|
},
|
|
31
32
|
children: /*#__PURE__*/ _jsx(DashboardApp, {
|
|
32
|
-
dashboardResource: getTestDashboard()
|
|
33
|
+
dashboardResource: getTestDashboard(),
|
|
34
|
+
isReadonly: false
|
|
33
35
|
})
|
|
34
36
|
})
|
|
35
37
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/views/ViewDashboard/tests/panelGroups.test.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 { screen } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { DashboardProvider, TemplateVariableProvider
|
|
1
|
+
{"version":3,"sources":["../../../../src/views/ViewDashboard/tests/panelGroups.test.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 { screen } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { TimeRangeProvider } from '@perses-dev/plugin-system';\nimport { DashboardProvider, TemplateVariableProvider } from '../../../context';\nimport { getTestDashboard, renderWithContext } from '../../../test';\nimport { DashboardApp } from '../DashboardApp';\n\ndescribe('Panel Groups', () => {\n const renderDashboard = () => {\n renderWithContext(\n <TimeRangeProvider initialTimeRange={{ pastDuration: '30m' }}>\n <TemplateVariableProvider>\n <DashboardProvider initialState={{ dashboardResource: getTestDashboard(), isEditMode: true }}>\n <DashboardApp dashboardResource={getTestDashboard()} isReadonly={false} />\n </DashboardProvider>\n </TemplateVariableProvider>\n </TimeRangeProvider>\n );\n };\n it('should delete panel', () => {\n renderDashboard();\n const panelTitle = 'CPU';\n const deletePanelButton = screen.getByLabelText(`delete panel ${panelTitle}`);\n userEvent.click(deletePanelButton);\n screen.getByText('Delete Panel');\n const deleteButton = screen.getByText('Delete');\n userEvent.click(deleteButton);\n\n // The panel should disappear\n const deletedPanel = screen.queryByText(panelTitle);\n expect(deletedPanel).not.toBeInTheDocument();\n });\n\n it('should only delete panel from panel group if panel is not referenced more than once', () => {\n renderDashboard();\n\n const panelTitle = 'Disk I/O Utilization';\n const panels = screen.getAllByText(panelTitle);\n expect(panels).toHaveLength(2);\n\n const deletePanelButton = screen.getAllByLabelText(`delete panel ${panelTitle}`)[0];\n if (deletePanelButton === undefined) throw new Error('Missing delete button');\n\n userEvent.click(deletePanelButton);\n screen.getByText('Delete Panel');\n const deleteButton = screen.getByText('Delete');\n userEvent.click(deleteButton);\n\n // The deleted panel should still be on screen in the other group\n const deletedPanel = screen.queryByText(panelTitle);\n expect(deletedPanel).toBeInTheDocument();\n });\n\n it('should swap panels', () => {\n renderDashboard();\n\n // should move panel down\n const groupTitle1 = 'CPU Stats';\n const moveGroupDownBtn = screen.getByLabelText(`move group ${groupTitle1} down`);\n userEvent.click(moveGroupDownBtn);\n\n // should move panel up\n const groupTitle2 = 'Disk Stats';\n const moveGroupUpBtn = screen.getByLabelText(`move group ${groupTitle2} up`);\n userEvent.click(moveGroupUpBtn);\n\n /* TODO: Figure out how to test this visually without coupling to the store\n const layouts = storeApi.getState().layouts;\n expect(layouts[0]?.title).toBe(undefined);\n expect(layouts[1]?.title).toBe('Disk Stats');\n expect(layouts[2]?.title).toBe('CPU Stats');\n */\n });\n\n it('should delete a panel group', () => {\n renderDashboard();\n const groupTitle = 'CPU Stats';\n const deleteGroupIcon = screen.getByLabelText(`delete group ${groupTitle}`);\n userEvent.click(deleteGroupIcon);\n screen.getByText('Delete Panel Group');\n const deleteButton = screen.getByText('Delete');\n userEvent.click(deleteButton);\n\n // should remove group\n const deletedGroup = screen.queryByText(groupTitle);\n expect(deletedGroup).not.toBeInTheDocument();\n\n // CPU panel should be completely gone since it wasn't in any other group\n let panel = screen.queryByText('CPU');\n expect(panel).not.toBeInTheDocument();\n\n // A DiskIO panel should still be present in the other group that wasn't deleted\n panel = screen.queryByText('Disk I/O Utilization');\n expect(panel).toBeInTheDocument();\n });\n});\n"],"names":["screen","userEvent","TimeRangeProvider","DashboardProvider","TemplateVariableProvider","getTestDashboard","renderWithContext","DashboardApp","describe","renderDashboard","initialTimeRange","pastDuration","initialState","dashboardResource","isEditMode","isReadonly","it","panelTitle","deletePanelButton","getByLabelText","click","getByText","deleteButton","deletedPanel","queryByText","expect","not","toBeInTheDocument","panels","getAllByText","toHaveLength","getAllByLabelText","undefined","Error","groupTitle1","moveGroupDownBtn","groupTitle2","moveGroupUpBtn","groupTitle","deleteGroupIcon","deletedGroup","panel"],"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,MAAM,QAAQ,wBAAwB,CAAC;AAChD,OAAOC,SAAS,MAAM,6BAA6B,CAAC;AACpD,SAASC,iBAAiB,QAAQ,2BAA2B,CAAC;AAC9D,SAASC,iBAAiB,EAAEC,wBAAwB,QAAQ,kBAAkB,CAAC;AAC/E,SAASC,gBAAgB,EAAEC,iBAAiB,QAAQ,eAAe,CAAC;AACpE,SAASC,YAAY,QAAQ,iBAAiB,CAAC;AAE/CC,QAAQ,CAAC,cAAc,EAAE,IAAM;IAC7B,MAAMC,eAAe,GAAG,IAAM;QAC5BH,iBAAiB,eACf,KAACJ,iBAAiB;YAACQ,gBAAgB,EAAE;gBAAEC,YAAY,EAAE,KAAK;aAAE;sBAC1D,cAAA,KAACP,wBAAwB;0BACvB,cAAA,KAACD,iBAAiB;oBAACS,YAAY,EAAE;wBAAEC,iBAAiB,EAAER,gBAAgB,EAAE;wBAAES,UAAU,EAAE,IAAI;qBAAE;8BAC1F,cAAA,KAACP,YAAY;wBAACM,iBAAiB,EAAER,gBAAgB,EAAE;wBAAEU,UAAU,EAAE,KAAK;sBAAI;kBACxD;cACK;UACT,CACrB,CAAC;IACJ,CAAC,AAAC;IACFC,EAAE,CAAC,qBAAqB,EAAE,IAAM;QAC9BP,eAAe,EAAE,CAAC;QAClB,MAAMQ,UAAU,GAAG,KAAK,AAAC;QACzB,MAAMC,iBAAiB,GAAGlB,MAAM,CAACmB,cAAc,CAAC,CAAC,aAAa,EAAEF,UAAU,CAAC,CAAC,CAAC,AAAC;QAC9EhB,S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B,WAAW,CAAC,KAAK,CAAC,AAAC;QACtCC,MAAM,CAACgB,KAAK,CAAC,CAACf,GAAG,CAACC,iBAAiB,EAAE,CAAC;QAEtC,gFAAgF;QAChFc,KAAK,GAAGzC,MAAM,CAACwB,WAAW,CAAC,sBAAsB,CAAC,CAAC;QACnDC,MAAM,CAACgB,KAAK,CAAC,CAACd,iBAAiB,EAAE,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@perses-dev/dashboards",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "The dashboards feature in Perses",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/perses/perses/blob/main/README.md",
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"lint:fix": "eslint --fix src --ext .ts,.tsx"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@perses-dev/components": "^0.
|
|
32
|
-
"@perses-dev/core": "^0.
|
|
33
|
-
"@perses-dev/plugin-system": "^0.
|
|
31
|
+
"@perses-dev/components": "^0.18.0",
|
|
32
|
+
"@perses-dev/core": "^0.18.0",
|
|
33
|
+
"@perses-dev/plugin-system": "^0.18.0",
|
|
34
34
|
"@types/react-grid-layout": "^1.3.2",
|
|
35
35
|
"date-fns": "^2.28.0",
|
|
36
36
|
"immer": "^9.0.15",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"intersection-observer": "^0.12.2"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"@mui/material": "^5.
|
|
49
|
+
"@mui/material": "^5.10.0",
|
|
50
50
|
"@tanstack/react-query": "^4.7.1",
|
|
51
51
|
"react": "^17.0.2 || ^18.0.0",
|
|
52
52
|
"react-dom": "^17.0.2 || ^18.0.0"
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
// Copyright 2022 The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
"use strict";
|
|
14
|
-
Object.defineProperty(exports, "__esModule", {
|
|
15
|
-
value: true
|
|
16
|
-
});
|
|
17
|
-
function _export(target, all) {
|
|
18
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: all[name]
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
_export(exports, {
|
|
24
|
-
TimeRangeProvider: ()=>TimeRangeProvider,
|
|
25
|
-
useDashboardTimeRange: ()=>useDashboardTimeRange
|
|
26
|
-
});
|
|
27
|
-
const _jsxRuntime = require("react/jsx-runtime");
|
|
28
|
-
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
|
29
|
-
const _pluginSystem = require("@perses-dev/plugin-system");
|
|
30
|
-
const _queryParams = require("./query-params");
|
|
31
|
-
function _getRequireWildcardCache(nodeInterop) {
|
|
32
|
-
if (typeof WeakMap !== "function") return null;
|
|
33
|
-
var cacheBabelInterop = new WeakMap();
|
|
34
|
-
var cacheNodeInterop = new WeakMap();
|
|
35
|
-
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
36
|
-
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
37
|
-
})(nodeInterop);
|
|
38
|
-
}
|
|
39
|
-
function _interopRequireWildcard(obj, nodeInterop) {
|
|
40
|
-
if (!nodeInterop && obj && obj.__esModule) {
|
|
41
|
-
return obj;
|
|
42
|
-
}
|
|
43
|
-
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
44
|
-
return {
|
|
45
|
-
default: obj
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
|
49
|
-
if (cache && cache.has(obj)) {
|
|
50
|
-
return cache.get(obj);
|
|
51
|
-
}
|
|
52
|
-
var newObj = {};
|
|
53
|
-
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
54
|
-
for(var key in obj){
|
|
55
|
-
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
56
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
57
|
-
if (desc && (desc.get || desc.set)) {
|
|
58
|
-
Object.defineProperty(newObj, key, desc);
|
|
59
|
-
} else {
|
|
60
|
-
newObj[key] = obj[key];
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
newObj.default = obj;
|
|
65
|
-
if (cache) {
|
|
66
|
-
cache.set(obj, newObj);
|
|
67
|
-
}
|
|
68
|
-
return newObj;
|
|
69
|
-
}
|
|
70
|
-
function TimeRangeProvider(props) {
|
|
71
|
-
const { initialTimeRange , enabledURLParams , children } = props;
|
|
72
|
-
const { timeRange , setTimeRange } = (0, _queryParams.useSetTimeRangeParams)(initialTimeRange, enabledURLParams);
|
|
73
|
-
const ctx = (0, _react.useMemo)(()=>({
|
|
74
|
-
timeRange,
|
|
75
|
-
setTimeRange
|
|
76
|
-
}), [
|
|
77
|
-
timeRange,
|
|
78
|
-
setTimeRange
|
|
79
|
-
]);
|
|
80
|
-
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.TimeRangeContext.Provider, {
|
|
81
|
-
value: ctx,
|
|
82
|
-
children: children
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
function useDashboardTimeRange() {
|
|
86
|
-
const { timeRange , setTimeRange } = (0, _pluginSystem.useTimeRangeContext)();
|
|
87
|
-
return {
|
|
88
|
-
timeRange,
|
|
89
|
-
setTimeRange
|
|
90
|
-
};
|
|
91
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
// Copyright 2022 The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
"use strict";
|
|
14
|
-
Object.defineProperty(exports, "__esModule", {
|
|
15
|
-
value: true
|
|
16
|
-
});
|
|
17
|
-
_exportStar(require("./TimeRangeProvider"), exports);
|
|
18
|
-
_exportStar(require("./query-params"), exports);
|
|
19
|
-
function _exportStar(from, to) {
|
|
20
|
-
Object.keys(from).forEach(function(k) {
|
|
21
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function() {
|
|
24
|
-
return from[k];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
return from;
|
|
29
|
-
}
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
// Copyright 2022 The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
"use strict";
|
|
14
|
-
Object.defineProperty(exports, "__esModule", {
|
|
15
|
-
value: true
|
|
16
|
-
});
|
|
17
|
-
function _export(target, all) {
|
|
18
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: all[name]
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
_export(exports, {
|
|
24
|
-
encodeTimeRangeValue: ()=>encodeTimeRangeValue,
|
|
25
|
-
decodeTimeRangeValue: ()=>decodeTimeRangeValue,
|
|
26
|
-
TimeRangeParam: ()=>TimeRangeParam,
|
|
27
|
-
timeRangeQueryConfig: ()=>timeRangeQueryConfig,
|
|
28
|
-
useInitialTimeRange: ()=>useInitialTimeRange,
|
|
29
|
-
useSetTimeRangeParams: ()=>useSetTimeRangeParams
|
|
30
|
-
});
|
|
31
|
-
const _react = require("react");
|
|
32
|
-
const _useQueryParams = require("use-query-params");
|
|
33
|
-
const _dateFns = require("date-fns");
|
|
34
|
-
const _core = require("@perses-dev/core");
|
|
35
|
-
/* Interprets an encoded string and returns either the string or null/undefined if not available */ function getEncodedValue(input, allowEmptyString) {
|
|
36
|
-
if (input == null) {
|
|
37
|
-
return input;
|
|
38
|
-
}
|
|
39
|
-
// '' or []
|
|
40
|
-
if (input.length === 0 && (!allowEmptyString || allowEmptyString && input !== '')) {
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
const str = input instanceof Array ? input[0] : input;
|
|
44
|
-
if (str == null) {
|
|
45
|
-
return str;
|
|
46
|
-
}
|
|
47
|
-
if (!allowEmptyString && str === '') {
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
return str;
|
|
51
|
-
}
|
|
52
|
-
function encodeTimeRangeValue(timeOptionValue) {
|
|
53
|
-
if (!timeOptionValue) {
|
|
54
|
-
return timeOptionValue;
|
|
55
|
-
}
|
|
56
|
-
if (typeof timeOptionValue === 'string') {
|
|
57
|
-
if ((0, _core.isDurationString)(timeOptionValue)) {
|
|
58
|
-
return timeOptionValue;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return ((0, _dateFns.getUnixTime)(timeOptionValue) * 1000).toString();
|
|
62
|
-
}
|
|
63
|
-
function decodeTimeRangeValue(input) {
|
|
64
|
-
const paramString = getEncodedValue(input);
|
|
65
|
-
if (paramString == null) return paramString;
|
|
66
|
-
return (0, _core.isDurationString)(paramString) ? paramString : new Date(Number(paramString));
|
|
67
|
-
}
|
|
68
|
-
const TimeRangeParam = {
|
|
69
|
-
encode: encodeTimeRangeValue,
|
|
70
|
-
decode: decodeTimeRangeValue,
|
|
71
|
-
equals: (valueA, valueB)=>{
|
|
72
|
-
if (valueA === valueB) return true;
|
|
73
|
-
if (valueA == null || valueB == null) return valueA === valueB;
|
|
74
|
-
return valueA.valueOf() === valueB.valueOf();
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
const timeRangeQueryConfig = {
|
|
78
|
-
start: TimeRangeParam,
|
|
79
|
-
end: TimeRangeParam
|
|
80
|
-
};
|
|
81
|
-
function useInitialTimeRange(dashboardDuration) {
|
|
82
|
-
const [query] = (0, _useQueryParams.useQueryParams)(timeRangeQueryConfig);
|
|
83
|
-
const { start , end } = query;
|
|
84
|
-
return (0, _react.useMemo)(()=>{
|
|
85
|
-
let initialTimeRange = {
|
|
86
|
-
pastDuration: dashboardDuration
|
|
87
|
-
};
|
|
88
|
-
if (!start) {
|
|
89
|
-
return initialTimeRange;
|
|
90
|
-
}
|
|
91
|
-
const startStr = start.toString();
|
|
92
|
-
if ((0, _core.isDurationString)(startStr)) {
|
|
93
|
-
initialTimeRange = {
|
|
94
|
-
pastDuration: startStr
|
|
95
|
-
};
|
|
96
|
-
} else if ((0, _dateFns.isDate)(start) && (0, _dateFns.isDate)(end)) {
|
|
97
|
-
initialTimeRange = {
|
|
98
|
-
start: start,
|
|
99
|
-
end: end
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
return initialTimeRange;
|
|
103
|
-
}, [
|
|
104
|
-
start,
|
|
105
|
-
end,
|
|
106
|
-
dashboardDuration
|
|
107
|
-
]);
|
|
108
|
-
}
|
|
109
|
-
function useSetTimeRangeParams(initialTimeRange, enabledURLParams = true) {
|
|
110
|
-
const [query, setQuery] = (0, _useQueryParams.useQueryParams)(timeRangeQueryConfig);
|
|
111
|
-
// determine whether initial param had previously been populated to fix back btn
|
|
112
|
-
const [paramsLoaded, setParamsLoaded] = (0, _react.useState)(false);
|
|
113
|
-
// optional fallback when app does not want query string as source of truth
|
|
114
|
-
// this occurs when enabledURLParams is set to false on TimeRangeProvider
|
|
115
|
-
const [timeRangeState, setTimeRangeState] = (0, _react.useState)(initialTimeRange);
|
|
116
|
-
const { start } = query;
|
|
117
|
-
(0, _react.useEffect)(()=>{
|
|
118
|
-
// when dashboard loaded with no params, default to dashboard duration
|
|
119
|
-
if (enabledURLParams && !paramsLoaded && !start) {
|
|
120
|
-
if ((0, _core.isRelativeTimeRange)(initialTimeRange)) {
|
|
121
|
-
setQuery({
|
|
122
|
-
start: initialTimeRange.pastDuration,
|
|
123
|
-
end: undefined
|
|
124
|
-
});
|
|
125
|
-
setParamsLoaded(true);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}, [
|
|
129
|
-
initialTimeRange,
|
|
130
|
-
enabledURLParams,
|
|
131
|
-
paramsLoaded,
|
|
132
|
-
start,
|
|
133
|
-
setQuery
|
|
134
|
-
]);
|
|
135
|
-
const setTimeRange = (0, _react.useCallback)((value)=>{
|
|
136
|
-
if ((0, _core.isRelativeTimeRange)(value)) {
|
|
137
|
-
setQuery({
|
|
138
|
-
start: value.pastDuration,
|
|
139
|
-
end: undefined
|
|
140
|
-
});
|
|
141
|
-
} else {
|
|
142
|
-
setQuery(value);
|
|
143
|
-
}
|
|
144
|
-
}, [
|
|
145
|
-
setQuery
|
|
146
|
-
]);
|
|
147
|
-
if (!enabledURLParams) {
|
|
148
|
-
return {
|
|
149
|
-
timeRange: timeRangeState,
|
|
150
|
-
setTimeRange: setTimeRangeState
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
return {
|
|
154
|
-
timeRange: initialTimeRange,
|
|
155
|
-
setTimeRange: setTimeRange
|
|
156
|
-
};
|
|
157
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { TimeRangeValue } from '@perses-dev/core';
|
|
3
|
-
export interface TimeRangeProviderProps {
|
|
4
|
-
initialTimeRange: TimeRangeValue;
|
|
5
|
-
enabledURLParams?: boolean;
|
|
6
|
-
children?: React.ReactNode;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Provider implementation that supplies the time range state at runtime.
|
|
10
|
-
*/
|
|
11
|
-
export declare function TimeRangeProvider(props: TimeRangeProviderProps): JSX.Element;
|
|
12
|
-
/**
|
|
13
|
-
* Internal version of time range hook to get all supported values
|
|
14
|
-
*/
|
|
15
|
-
export declare function useDashboardTimeRange(): {
|
|
16
|
-
timeRange: TimeRangeValue;
|
|
17
|
-
setTimeRange: (value: TimeRangeValue) => void;
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=TimeRangeProvider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TimeRangeProvider.d.ts","sourceRoot":"","sources":["../../../src/context/TimeRangeProvider/TimeRangeProvider.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAkB,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAIlD,MAAM,WAAW,sBAAsB;IACrC,gBAAgB,EAAE,cAAc,CAAC;IACjC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,eAc9D;AAED;;GAEG;AACH,wBAAgB,qBAAqB;;;EAGpC"}
|
|
@@ -1,44 +0,0 @@
|
|
|
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, { useMemo } from 'react';
|
|
15
|
-
import { TimeRangeContext, useTimeRangeContext } from '@perses-dev/plugin-system';
|
|
16
|
-
import { useSetTimeRangeParams } from './query-params';
|
|
17
|
-
/**
|
|
18
|
-
* Provider implementation that supplies the time range state at runtime.
|
|
19
|
-
*/ export function TimeRangeProvider(props) {
|
|
20
|
-
const { initialTimeRange , enabledURLParams , children } = props;
|
|
21
|
-
const { timeRange , setTimeRange } = useSetTimeRangeParams(initialTimeRange, enabledURLParams);
|
|
22
|
-
const ctx = useMemo(()=>({
|
|
23
|
-
timeRange,
|
|
24
|
-
setTimeRange
|
|
25
|
-
}), [
|
|
26
|
-
timeRange,
|
|
27
|
-
setTimeRange
|
|
28
|
-
]);
|
|
29
|
-
return /*#__PURE__*/ _jsx(TimeRangeContext.Provider, {
|
|
30
|
-
value: ctx,
|
|
31
|
-
children: children
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Internal version of time range hook to get all supported values
|
|
36
|
-
*/ export function useDashboardTimeRange() {
|
|
37
|
-
const { timeRange , setTimeRange } = useTimeRangeContext();
|
|
38
|
-
return {
|
|
39
|
-
timeRange,
|
|
40
|
-
setTimeRange
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
//# sourceMappingURL=TimeRangeProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/context/TimeRangeProvider/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, { useMemo } from 'react';\nimport { TimeRangeValue } from '@perses-dev/core';\nimport { TimeRangeContext, useTimeRangeContext } from '@perses-dev/plugin-system';\nimport { useSetTimeRangeParams } from './query-params';\n\nexport interface TimeRangeProviderProps {\n initialTimeRange: TimeRangeValue;\n enabledURLParams?: boolean;\n children?: React.ReactNode;\n}\n\n/**\n * Provider implementation that supplies the time range state at runtime.\n */\nexport function TimeRangeProvider(props: TimeRangeProviderProps) {\n const { initialTimeRange, enabledURLParams, children } = props;\n\n const { timeRange, setTimeRange } = useSetTimeRangeParams(initialTimeRange, enabledURLParams);\n\n const ctx = useMemo(\n () => ({\n timeRange,\n setTimeRange,\n }),\n [timeRange, setTimeRange]\n );\n\n return <TimeRangeContext.Provider value={ctx}>{children}</TimeRangeContext.Provider>;\n}\n\n/**\n * Internal version of time range hook to get all supported values\n */\nexport function useDashboardTimeRange() {\n const { timeRange, setTimeRange } = useTimeRangeContext();\n return { timeRange, setTimeRange };\n}\n"],"names":["React","useMemo","TimeRangeContext","useTimeRangeContext","useSetTimeRangeParams","TimeRangeProvider","props","initialTimeRange","enabledURLParams","children","timeRange","setTimeRange","ctx","Provider","value","useDashboardTimeRange"],"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,OAAO,QAAQ,OAAO,CAAC;AAEvC,SAASC,gBAAgB,EAAEC,mBAAmB,QAAQ,2BAA2B,CAAC;AAClF,SAASC,qBAAqB,QAAQ,gBAAgB,CAAC;AAQvD;;CAEC,GACD,OAAO,SAASC,iBAAiB,CAACC,KAA6B,EAAE;IAC/D,MAAM,EAAEC,gBAAgB,CAAA,EAAEC,gBAAgB,CAAA,EAAEC,QAAQ,CAAA,EAAE,GAAGH,KAAK,AAAC;IAE/D,MAAM,EAAEI,SAAS,CAAA,EAAEC,YAAY,CAAA,EAAE,GAAGP,qBAAqB,CAACG,gBAAgB,EAAEC,gBAAgB,CAAC,AAAC;IAE9F,MAAMI,GAAG,GAAGX,OAAO,CACjB,IAAO,CAAA;YACLS,SAAS;YACTC,YAAY;SACb,CAAA,AAAC,EACF;QAACD,SAAS;QAAEC,YAAY;KAAC,CAC1B,AAAC;IAEF,qBAAO,KAACT,gBAAgB,CAACW,QAAQ;QAACC,KAAK,EAAEF,GAAG;kBAAGH,QAAQ;MAA6B,CAAC;AACvF,CAAC;AAED;;CAEC,GACD,OAAO,SAASM,qBAAqB,GAAG;IACtC,MAAM,EAAEL,SAAS,CAAA,EAAEC,YAAY,CAAA,EAAE,GAAGR,mBAAmB,EAAE,AAAC;IAC1D,OAAO;QAAEO,SAAS;QAAEC,YAAY;KAAE,CAAC;AACrC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/context/TimeRangeProvider/index.ts"],"names":[],"mappings":"AAaA,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
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
|
-
export * from './TimeRangeProvider';
|
|
14
|
-
export * from './query-params';
|
|
15
|
-
|
|
16
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/context/TimeRangeProvider/index.ts"],"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\nexport * from './TimeRangeProvider';\nexport * from './query-params';\n"],"names":[],"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,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { QueryParamConfig } from 'use-query-params';
|
|
2
|
-
import { TimeRangeValue, DurationString } from '@perses-dev/core';
|
|
3
|
-
import { TimeRange } from '@perses-dev/plugin-system';
|
|
4
|
-
export declare type TimeOptionValue = Date | DurationString | null | undefined;
|
|
5
|
-
export declare function encodeTimeRangeValue(timeOptionValue: TimeOptionValue): string | null | undefined;
|
|
6
|
-
export declare function decodeTimeRangeValue(input: string | Array<string | null> | null | undefined): Date | DurationString | null | undefined;
|
|
7
|
-
/**
|
|
8
|
-
* Custom TimeRangeValue param type
|
|
9
|
-
* See: https://github.com/pbeshai/use-query-params/tree/master/packages/serialize-query-params#param-types
|
|
10
|
-
*/
|
|
11
|
-
export declare const TimeRangeParam: QueryParamConfig<TimeOptionValue, TimeOptionValue>;
|
|
12
|
-
export declare const timeRangeQueryConfig: {
|
|
13
|
-
start: QueryParamConfig<TimeOptionValue, TimeOptionValue>;
|
|
14
|
-
end: QueryParamConfig<TimeOptionValue, TimeOptionValue>;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Gets the initial time range taking into account URL params and dashboard JSON duration
|
|
18
|
-
* Sets start query param if it is empty on page load
|
|
19
|
-
*/
|
|
20
|
-
export declare function useInitialTimeRange(dashboardDuration: DurationString): TimeRangeValue;
|
|
21
|
-
/**
|
|
22
|
-
* Returns time range getter and setter, set enabledURLParams to false to disable query string serialization
|
|
23
|
-
*/
|
|
24
|
-
export declare function useSetTimeRangeParams(initialTimeRange: TimeRangeValue, enabledURLParams?: boolean): TimeRange;
|
|
25
|
-
//# sourceMappingURL=query-params.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"query-params.d.ts","sourceRoot":"","sources":["../../../src/context/TimeRangeProvider/query-params.ts"],"names":[],"mappings":"AAcA,OAAO,EAAkB,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpE,OAAO,EACL,cAAc,EAGd,cAAc,EAEf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEtD,oBAAY,eAAe,GAAG,IAAI,GAAG,cAAc,GAAG,IAAI,GAAG,SAAS,CAAC;AA2BvE,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,eAAe,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAWhG;AAGD,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,GACtD,IAAI,GAAG,cAAc,GAAG,IAAI,GAAG,SAAS,CAI1C;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,gBAAgB,CAAC,eAAe,EAAE,eAAe,CAQ7E,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;CAGhC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,iBAAiB,EAAE,cAAc,GAAG,cAAc,CAgBrF;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,gBAAgB,EAAE,cAAc,EAAE,gBAAgB,UAAO,GAAG,SAAS,CAqC1G"}
|