@perses-dev/dashboards 0.12.0 → 0.13.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 → Dashboard/Dashboard.js} +2 -2
- package/dist/cjs/components/Dashboard/index.js +28 -0
- package/dist/cjs/components/{DashboardToolbar.js → DashboardToolbar/DashboardToolbar.js} +9 -23
- package/dist/cjs/components/DashboardToolbar/index.js +28 -0
- package/dist/cjs/components/{Panel → DeletePanelDialog}/DeletePanelDialog.js +2 -3
- package/dist/cjs/components/DeletePanelDialog/index.js +28 -0
- package/dist/cjs/components/{PanelGroupDialog → DeletePanelGroupDialog}/DeletePanelGroupDialog.js +0 -0
- package/dist/cjs/components/DeletePanelGroupDialog/index.js +28 -0
- package/dist/cjs/components/GridLayout/GridItemContent.js +11 -1
- package/dist/cjs/components/Panel/Panel.js +30 -89
- package/dist/cjs/components/Panel/Panel.test.js +93 -47
- package/dist/cjs/components/Panel/PanelHeader.js +116 -0
- package/dist/cjs/components/Panel/index.js +0 -1
- package/dist/cjs/components/PanelDrawer/PanelDrawer.test.js +9 -15
- package/dist/cjs/components/PanelDrawer/PanelPreview.js +13 -20
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.test.js +1 -1
- package/dist/cjs/components/PanelGroupDialog/index.js +0 -1
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.test.js +1 -1
- package/dist/cjs/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.js +67 -0
- package/dist/cjs/components/UnsavedChangesConfirmationDialog/index.js +28 -0
- package/dist/cjs/components/Variables/Variable.js +18 -11
- package/dist/cjs/components/index.js +4 -0
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +24 -18
- package/dist/cjs/context/DashboardProvider/common.js +3 -3
- package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +2 -4
- package/dist/cjs/context/DashboardProvider/panel-group-slice.js +47 -52
- package/dist/cjs/context/DashboardProvider/panel-slice.js +2 -13
- package/dist/cjs/context/{TemplateVariableProvider.js → TemplateVariableProvider/TemplateVariableProvider.js} +25 -12
- package/dist/cjs/context/TemplateVariableProvider/index.js +28 -0
- package/dist/cjs/context/TemplateVariableProvider/query-params.js +79 -0
- package/dist/cjs/context/TemplateVariableProvider/query-params.test.js +82 -0
- package/dist/cjs/context/index.js +1 -1
- package/dist/cjs/context/{useDashboardSpec.js → useDashboard.js} +20 -16
- package/dist/cjs/test/plugin-registry.js +14 -54
- package/dist/cjs/test/render.js +6 -1
- package/dist/cjs/utils/component-ids.js +31 -0
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +40 -10
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +1 -1
- package/dist/cjs/views/ViewDashboard/tests/panelGroups.test.js +1 -1
- package/dist/components/{Dashboard.d.ts → Dashboard/Dashboard.d.ts} +0 -0
- package/dist/components/Dashboard/Dashboard.d.ts.map +1 -0
- package/dist/components/{Dashboard.js → Dashboard/Dashboard.js} +2 -2
- package/dist/components/Dashboard/Dashboard.js.map +1 -0
- package/dist/components/Dashboard/index.d.ts +2 -0
- package/dist/components/Dashboard/index.d.ts.map +1 -0
- package/dist/components/Dashboard/index.js +15 -0
- package/dist/components/Dashboard/index.js.map +1 -0
- package/dist/components/{DashboardToolbar.d.ts → DashboardToolbar/DashboardToolbar.d.ts} +2 -0
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -0
- package/dist/components/{DashboardToolbar.js → DashboardToolbar/DashboardToolbar.js} +5 -19
- package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -0
- package/dist/components/DashboardToolbar/index.d.ts +2 -0
- package/dist/components/DashboardToolbar/index.d.ts.map +1 -0
- package/dist/components/DashboardToolbar/index.js +15 -0
- package/dist/components/DashboardToolbar/index.js.map +1 -0
- package/dist/components/DeletePanelDialog/DeletePanelDialog.d.ts +3 -0
- package/dist/components/DeletePanelDialog/DeletePanelDialog.d.ts.map +1 -0
- package/dist/components/{Panel → DeletePanelDialog}/DeletePanelDialog.js +1 -2
- package/dist/components/DeletePanelDialog/DeletePanelDialog.js.map +1 -0
- package/dist/components/DeletePanelDialog/index.d.ts +2 -0
- package/dist/components/DeletePanelDialog/index.d.ts.map +1 -0
- package/dist/components/DeletePanelDialog/index.js +15 -0
- package/dist/components/DeletePanelDialog/index.js.map +1 -0
- package/dist/components/{PanelGroupDialog → DeletePanelGroupDialog}/DeletePanelGroupDialog.d.ts +0 -0
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -0
- package/dist/components/{PanelGroupDialog → DeletePanelGroupDialog}/DeletePanelGroupDialog.js +0 -0
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js.map +1 -0
- package/dist/components/DeletePanelGroupDialog/index.d.ts +2 -0
- package/dist/components/DeletePanelGroupDialog/index.d.ts.map +1 -0
- package/dist/components/DeletePanelGroupDialog/index.js +15 -0
- package/dist/components/DeletePanelGroupDialog/index.js.map +1 -0
- package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
- package/dist/components/GridLayout/GridItemContent.js +12 -2
- package/dist/components/GridLayout/GridItemContent.js.map +1 -1
- package/dist/components/Panel/Panel.d.ts +3 -3
- package/dist/components/Panel/Panel.d.ts.map +1 -1
- package/dist/components/Panel/Panel.js +32 -91
- package/dist/components/Panel/Panel.js.map +1 -1
- package/dist/components/Panel/Panel.test.js +95 -49
- package/dist/components/Panel/Panel.test.js.map +1 -1
- package/dist/components/Panel/PanelHeader.d.ts +16 -0
- package/dist/components/Panel/PanelHeader.d.ts.map +1 -0
- package/dist/components/Panel/PanelHeader.js +105 -0
- package/dist/components/Panel/PanelHeader.js.map +1 -0
- package/dist/components/Panel/index.d.ts +0 -1
- package/dist/components/Panel/index.d.ts.map +1 -1
- package/dist/components/Panel/index.js +0 -1
- package/dist/components/Panel/index.js.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.test.js +10 -16
- package/dist/components/PanelDrawer/PanelDrawer.test.js.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.d.ts +2 -2
- package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.js +13 -20
- package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js.map +1 -1
- package/dist/components/PanelGroupDialog/index.d.ts +0 -1
- package/dist/components/PanelGroupDialog/index.d.ts.map +1 -1
- package/dist/components/PanelGroupDialog/index.js +0 -1
- package/dist/components/PanelGroupDialog/index.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.test.js +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.test.js.map +1 -1
- package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.d.ts +8 -0
- package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.d.ts.map +1 -0
- package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.js +56 -0
- package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.js.map +1 -0
- package/dist/components/UnsavedChangesConfirmationDialog/index.d.ts +2 -0
- package/dist/components/UnsavedChangesConfirmationDialog/index.d.ts.map +1 -0
- package/dist/components/UnsavedChangesConfirmationDialog/index.js +15 -0
- package/dist/components/UnsavedChangesConfirmationDialog/index.js.map +1 -0
- package/dist/components/Variables/Variable.d.ts.map +1 -1
- package/dist/components/Variables/Variable.js +19 -12
- package/dist/components/Variables/Variable.js.map +1 -1
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +4 -0
- package/dist/components/index.js.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.d.ts +4 -4
- package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.js +26 -20
- package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
- package/dist/context/DashboardProvider/common.d.ts +1 -1
- package/dist/context/DashboardProvider/common.d.ts.map +1 -1
- package/dist/context/DashboardProvider/common.js +4 -4
- package/dist/context/DashboardProvider/common.js.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +1 -2
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.js +2 -4
- package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
- package/dist/context/DashboardProvider/index.d.ts +1 -0
- package/dist/context/DashboardProvider/index.d.ts.map +1 -1
- package/dist/context/DashboardProvider/index.js.map +1 -1
- package/dist/context/DashboardProvider/panel-group-slice.d.ts +1 -15
- package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-group-slice.js +38 -49
- package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
- package/dist/context/DashboardProvider/panel-slice.d.ts +0 -9
- package/dist/context/DashboardProvider/panel-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-slice.js +2 -13
- package/dist/context/DashboardProvider/panel-slice.js.map +1 -1
- package/dist/context/{TemplateVariableProvider.d.ts → TemplateVariableProvider/TemplateVariableProvider.d.ts} +0 -0
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts.map +1 -0
- package/dist/context/{TemplateVariableProvider.js → TemplateVariableProvider/TemplateVariableProvider.js} +25 -12
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js.map +1 -0
- package/dist/context/TemplateVariableProvider/index.d.ts +2 -0
- package/dist/context/TemplateVariableProvider/index.d.ts.map +1 -0
- package/dist/context/TemplateVariableProvider/index.js +15 -0
- package/dist/context/TemplateVariableProvider/index.js.map +1 -0
- package/dist/context/TemplateVariableProvider/query-params.d.ts +12 -0
- package/dist/context/TemplateVariableProvider/query-params.d.ts.map +1 -0
- package/dist/context/TemplateVariableProvider/query-params.js +64 -0
- package/dist/context/TemplateVariableProvider/query-params.js.map +1 -0
- package/dist/context/TemplateVariableProvider/query-params.test.d.ts +2 -0
- package/dist/context/TemplateVariableProvider/query-params.test.d.ts.map +1 -0
- package/dist/context/TemplateVariableProvider/query-params.test.js +80 -0
- package/dist/context/TemplateVariableProvider/query-params.test.js.map +1 -0
- package/dist/context/index.d.ts +1 -1
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +1 -1
- package/dist/context/index.js.map +1 -1
- package/dist/context/useDashboard.d.ts +6 -0
- package/dist/context/useDashboard.d.ts.map +1 -0
- package/dist/context/{useDashboardSpec.js → useDashboard.js} +19 -15
- package/dist/context/useDashboard.js.map +1 -0
- package/dist/test/plugin-registry.d.ts +2 -11
- package/dist/test/plugin-registry.d.ts.map +1 -1
- package/dist/test/plugin-registry.js +12 -49
- package/dist/test/plugin-registry.js.map +1 -1
- package/dist/test/render.d.ts.map +1 -1
- package/dist/test/render.js +6 -1
- package/dist/test/render.js.map +1 -1
- package/dist/utils/component-ids.d.ts +8 -0
- package/dist/utils/component-ids.d.ts.map +1 -0
- package/dist/utils/component-ids.js +27 -0
- package/dist/utils/component-ids.js.map +1 -0
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.js +40 -5
- package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.js +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
- package/dist/views/ViewDashboard/tests/panelGroups.test.js +1 -1
- package/dist/views/ViewDashboard/tests/panelGroups.test.js.map +1 -1
- package/package.json +4 -4
- package/dist/components/Dashboard.d.ts.map +0 -1
- package/dist/components/Dashboard.js.map +0 -1
- package/dist/components/DashboardToolbar.d.ts.map +0 -1
- package/dist/components/DashboardToolbar.js.map +0 -1
- package/dist/components/Panel/DeletePanelDialog.d.ts +0 -4
- package/dist/components/Panel/DeletePanelDialog.d.ts.map +0 -1
- package/dist/components/Panel/DeletePanelDialog.js.map +0 -1
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.d.ts.map +0 -1
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.js.map +0 -1
- package/dist/context/TemplateVariableProvider.d.ts.map +0 -1
- package/dist/context/TemplateVariableProvider.js.map +0 -1
- package/dist/context/useDashboardSpec.d.ts +0 -11
- package/dist/context/useDashboardSpec.d.ts.map +0 -1
- package/dist/context/useDashboardSpec.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/PanelGroupDialog/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 './PanelGroupDialog';\
|
|
1
|
+
{"version":3,"sources":["../../../src/components/PanelGroupDialog/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 './PanelGroupDialog';\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,oBAAoB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/TimeRangeControls/TimeRangeControls.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 { generatePath } from 'react-router';\nimport { createMemoryHistory } from 'history';\nimport userEvent from '@testing-library/user-event';\nimport { screen } from '@testing-library/react';\nimport { renderWithContext } from '../../test';\nimport testDashboard from '../../test/testDashboard';\nimport { DashboardProvider, DashboardStoreProps, TimeRangeProvider } from '../../context';\nimport { TimeRangeControls } from './TimeRangeControls';\n\nconst history = createMemoryHistory({\n initialEntries: [generatePath('/dashboards/:id', { id: 'test' })],\n});\n\ndescribe('TimeRangeControls', () => {\n let initialState: DashboardStoreProps;\n const testDefaultTimeRange = { pastDuration: testDashboard.spec.duration };\n\n beforeEach(() => {\n initialState = {\n
|
|
1
|
+
{"version":3,"sources":["../../../src/components/TimeRangeControls/TimeRangeControls.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 { generatePath } from 'react-router';\nimport { createMemoryHistory } from 'history';\nimport userEvent from '@testing-library/user-event';\nimport { screen } from '@testing-library/react';\nimport { renderWithContext } from '../../test';\nimport testDashboard from '../../test/testDashboard';\nimport { DashboardProvider, DashboardStoreProps, TimeRangeProvider } from '../../context';\nimport { TimeRangeControls } from './TimeRangeControls';\n\nconst history = createMemoryHistory({\n initialEntries: [generatePath('/dashboards/:id', { id: 'test' })],\n});\n\ndescribe('TimeRangeControls', () => {\n let initialState: DashboardStoreProps;\n const testDefaultTimeRange = { pastDuration: testDashboard.spec.duration };\n\n beforeEach(() => {\n initialState = {\n dashboardResource: testDashboard,\n };\n });\n\n const renderTimeRangeControls = () => {\n renderWithContext(\n <DashboardProvider initialState={initialState}>\n <TimeRangeProvider timeRange={testDefaultTimeRange}>\n <TimeRangeControls />\n </TimeRangeProvider>\n </DashboardProvider>,\n undefined,\n history\n );\n };\n\n it('should render correct initial relative time shortcut', async () => {\n renderTimeRangeControls();\n expect(screen.getByText('Last 5 minutes')).toBeInTheDocument();\n });\n\n // TODO: fix setTimeRange no-op, test query params\n it('should be able to select the first option', () => {\n renderTimeRangeControls();\n const dateButton = screen.getByRole('button');\n userEvent.click(dateButton);\n const firstOption = screen.getByRole('option', { name: 'Last 5 minutes' });\n userEvent.click(firstOption);\n expect(dateButton).toHaveTextContent(/5 minutes/i);\n });\n\n // TODO: add additional tests for absolute time selection, other inputs, form validation, etc.\n});\n"],"names":["generatePath","createMemoryHistory","userEvent","screen","renderWithContext","testDashboard","DashboardProvider","TimeRangeProvider","TimeRangeControls","history","initialEntries","id","describe","initialState","testDefaultTimeRange","pastDuration","spec","duration","beforeEach","dashboardResource","renderTimeRangeControls","timeRange","undefined","it","expect","getByText","toBeInTheDocument","dateButton","getByRole","click","firstOption","name","toHaveTextContent"],"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,YA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E,IAAM;QACpDH,uBAAuB,EAAE,CAAC;QAC1B,MAAMO,UAAU,GAAGxB,MAAM,CAACyB,SAAS,CAAC,QAAQ,CAAC,AAAC;QAC9C1B,SAAS,CAAC2B,KAAK,CAACF,UAAU,CAAC,CAAC;QAC5B,MAAMG,WAAW,GAAG3B,MAAM,CAACyB,SAAS,CAAC,QAAQ,EAAE;YAAEG,IAAI,EAAE,gBAAgB;SAAE,CAAC,AAAC;QAC3E7B,SAAS,CAAC2B,KAAK,CAACC,WAAW,CAAC,CAAC;QAC7BN,MAAM,CAACG,UAAU,CAAC,CAACK,iBAAiB,cAAc,CAAC;IACrD,CAAC,CAAC,CAAC;AAEH,8FAA8F;AAChG,CAAC,CAAC,CAAC"}
|
package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export interface UnsavedChangesConfirmationDialogProps {
|
|
3
|
+
isOpen: boolean;
|
|
4
|
+
onSave: () => void;
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
}
|
|
7
|
+
export declare const UnsavedChangesConfirmationDialog: ({ isOpen, onSave, onClose, }: UnsavedChangesConfirmationDialogProps) => JSX.Element;
|
|
8
|
+
//# sourceMappingURL=UnsavedChangesConfirmationDialog.d.ts.map
|
package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UnsavedChangesConfirmationDialog.d.ts","sourceRoot":"","sources":["../../../src/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.tsx"],"names":[],"mappings":";AAeA,MAAM,WAAW,qCAAqC;IACpD,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,eAAO,MAAM,gCAAgC,iCAI1C,qCAAqC,gBA0BvC,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
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, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@mui/material';
|
|
15
|
+
import CloseIcon from 'mdi-material-ui/Close';
|
|
16
|
+
export const UnsavedChangesConfirmationDialog = ({ isOpen , onSave , onClose })=>{
|
|
17
|
+
return /*#__PURE__*/ _jsxs(Dialog, {
|
|
18
|
+
open: isOpen,
|
|
19
|
+
children: [
|
|
20
|
+
/*#__PURE__*/ _jsx(DialogTitle, {
|
|
21
|
+
children: "Unsaved Changes"
|
|
22
|
+
}),
|
|
23
|
+
/*#__PURE__*/ _jsx(IconButton, {
|
|
24
|
+
"aria-label": "Close",
|
|
25
|
+
onClick: onClose,
|
|
26
|
+
sx: (theme)=>({
|
|
27
|
+
position: 'absolute',
|
|
28
|
+
top: theme.spacing(0.5),
|
|
29
|
+
right: theme.spacing(0.5)
|
|
30
|
+
}),
|
|
31
|
+
children: /*#__PURE__*/ _jsx(CloseIcon, {})
|
|
32
|
+
}),
|
|
33
|
+
/*#__PURE__*/ _jsx(DialogContent, {
|
|
34
|
+
sx: {
|
|
35
|
+
width: '500px'
|
|
36
|
+
},
|
|
37
|
+
children: "You have unsaved changes in this dashboard. Would you like to save these changes?"
|
|
38
|
+
}),
|
|
39
|
+
/*#__PURE__*/ _jsxs(DialogActions, {
|
|
40
|
+
children: [
|
|
41
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
42
|
+
variant: "contained",
|
|
43
|
+
onClick: onSave,
|
|
44
|
+
children: "Save"
|
|
45
|
+
}),
|
|
46
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
47
|
+
onClick: onClose,
|
|
48
|
+
children: "Cancel"
|
|
49
|
+
})
|
|
50
|
+
]
|
|
51
|
+
})
|
|
52
|
+
]
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=UnsavedChangesConfirmationDialog.js.map
|
package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.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 { IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@mui/material';\nimport CloseIcon from 'mdi-material-ui/Close';\nexport interface UnsavedChangesConfirmationDialogProps {\n isOpen: boolean;\n onSave: () => void;\n onClose: () => void;\n}\n\nexport const UnsavedChangesConfirmationDialog = ({\n isOpen,\n onSave,\n onClose,\n}: UnsavedChangesConfirmationDialogProps) => {\n return (\n <Dialog open={isOpen}>\n <DialogTitle>Unsaved Changes</DialogTitle>\n <IconButton\n aria-label=\"Close\"\n onClick={onClose}\n sx={(theme) => ({\n position: 'absolute',\n top: theme.spacing(0.5),\n right: theme.spacing(0.5),\n })}\n >\n <CloseIcon />\n </IconButton>\n <DialogContent sx={{ width: '500px' }}>\n You have unsaved changes in this dashboard. Would you like to save these changes?\n </DialogContent>\n <DialogActions>\n <Button variant=\"contained\" onClick={onSave}>\n Save\n </Button>\n <Button onClick={onClose}>Cancel</Button>\n </DialogActions>\n </Dialog>\n );\n};\n"],"names":["IconButton","Dialog","DialogTitle","DialogContent","DialogActions","Button","CloseIcon","UnsavedChangesConfirmationDialog","isOpen","onSave","onClose","open","aria-label","onClick","sx","theme","position","top","spacing","right","width","variant"],"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,UAAU,EAAEC,MAAM,EAAEC,WAAW,EAAEC,aAAa,EAAEC,aAAa,EAAEC,MAAM,QAAQ,eAAe,CAAC;AACtG,OAAOC,SAAS,MAAM,uBAAuB,CAAC;AAO9C,OAAO,MAAMC,gCAAgC,GAAG,CAAC,EAC/CC,MAAM,CAAA,EACNC,MAAM,CAAA,EACNC,OAAO,CAAA,EAC+B,GAAK;IAC3C,qBACE,MAACT,MAAM;QAACU,IAAI,EAAEH,MAAM;;0BAClB,KAACN,WAAW;0BAAC,iBAAe;cAAc;0BAC1C,KAACF,UAAU;gBACTY,YAAU,EAAC,OAAO;gBAClBC,OAAO,EAAEH,OAAO;gBAChBI,EAAE,EAAE,CAACC,KAAK,GAAM,CAAA;wBACdC,QAAQ,EAAE,UAAU;wBACpBC,GAAG,EAAEF,KAAK,CAACG,OAAO,CAAC,GAAG,CAAC;wBACvBC,KAAK,EAAEJ,KAAK,CAACG,OAAO,CAAC,GAAG,CAAC;qBAC1B,CAAA,AAAC;0BAEF,cAAA,KAACZ,SAAS,KAAG;cACF;0BACb,KAACH,aAAa;gBAACW,EAAE,EAAE;oBAAEM,KAAK,EAAE,OAAO;iBAAE;0BAAE,mFAEvC;cAAgB;0BAChB,MAAChB,aAAa;;kCACZ,KAACC,MAAM;wBAACgB,OAAO,EAAC,WAAW;wBAACR,OAAO,EAAEJ,MAAM;kCAAE,MAE7C;sBAAS;kCACT,KAACJ,MAAM;wBAACQ,OAAO,EAAEH,OAAO;kCAAE,QAAM;sBAAS;;cAC3B;;MACT,CACT;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/UnsavedChangesConfirmationDialog/index.ts"],"names":[],"mappings":"AAaA,cAAc,oCAAoC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
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 './UnsavedChangesConfirmationDialog';
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/UnsavedChangesConfirmationDialog/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 './UnsavedChangesConfirmationDialog';\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,oCAAoC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Variable.d.ts","sourceRoot":"","sources":["../../../src/components/Variables/Variable.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAE,YAAY,EAAyC,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"Variable.d.ts","sourceRoot":"","sources":["../../../src/components/Variables/Variable.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAE,YAAY,EAAyC,MAAM,kBAAkB,CAAC;AAYvF,aAAK,qBAAqB,GAAG;IAC3B,IAAI,EAAE,YAAY,CAAC;CACpB,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,EAAE,IAAI,EAAE,EAAE,qBAAqB,eAW/D"}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
14
|
import { useEffect, useMemo, useState } from 'react';
|
|
15
15
|
import { Select, FormControl, InputLabel, MenuItem, Box, LinearProgress, TextField } from '@mui/material';
|
|
16
|
-
import { usePlugin, DEFAULT_ALL_VALUE, useTemplateVariableValues, useDatasourceStore } from '@perses-dev/plugin-system';
|
|
16
|
+
import { usePlugin, DEFAULT_ALL_VALUE, useTemplateVariableValues, useDatasourceStore, useTimeRange } from '@perses-dev/plugin-system';
|
|
17
17
|
import { useQuery } from '@tanstack/react-query';
|
|
18
18
|
import { useTemplateVariable, useTemplateVariableActions } from '../../context';
|
|
19
19
|
export function TemplateVariable({ name }) {
|
|
@@ -67,14 +67,17 @@ function ListVariable({ name }) {
|
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
69
|
const variablesValueKey = getVariableValuesKey(variables);
|
|
70
|
+
const { timeRange } = useTimeRange();
|
|
70
71
|
const variablesOptionsQuery = useQuery([
|
|
71
72
|
name,
|
|
72
73
|
definition,
|
|
73
|
-
variablesValueKey
|
|
74
|
+
variablesValueKey,
|
|
75
|
+
timeRange
|
|
74
76
|
], async ()=>{
|
|
75
77
|
const resp = await (variablePlugin === null || variablePlugin === void 0 ? void 0 : variablePlugin.getVariableOptions(spec, {
|
|
76
78
|
datasourceStore,
|
|
77
|
-
variables
|
|
79
|
+
variables,
|
|
80
|
+
timeRange
|
|
78
81
|
}));
|
|
79
82
|
var ref;
|
|
80
83
|
return (ref = resp === null || resp === void 0 ? void 0 : resp.data) !== null && ref !== void 0 ? ref : [];
|
|
@@ -120,22 +123,26 @@ function ListVariable({ name }) {
|
|
|
120
123
|
options,
|
|
121
124
|
allowAllValue
|
|
122
125
|
]);
|
|
123
|
-
|
|
124
|
-
const firstOption = finalOptions === null || finalOptions === void 0 ? void 0 : finalOptions[0];
|
|
125
|
-
const valueIsInOptions = Boolean(finalOptions.find((v)=>{
|
|
126
|
+
const valueIsInOptions = useMemo(()=>Boolean(finalOptions.find((v)=>{
|
|
126
127
|
if (allowMultiple) {
|
|
127
128
|
return value.includes(v.value);
|
|
128
129
|
}
|
|
129
130
|
return value === v.value;
|
|
130
|
-
}))
|
|
131
|
+
})), [
|
|
132
|
+
finalOptions,
|
|
133
|
+
value,
|
|
134
|
+
allowMultiple
|
|
135
|
+
]);
|
|
136
|
+
let selectValue = value;
|
|
137
|
+
if (!valueIsInOptions) {
|
|
138
|
+
selectValue = allowMultiple ? [] : '';
|
|
139
|
+
}
|
|
140
|
+
useEffect(()=>{
|
|
141
|
+
const firstOption = finalOptions === null || finalOptions === void 0 ? void 0 : finalOptions[0];
|
|
131
142
|
// If there is no value but there are options, set the value to the first option.
|
|
132
143
|
if (!value && firstOption) {
|
|
133
144
|
setVariableValue(name, firstOption.value);
|
|
134
145
|
}
|
|
135
|
-
// If there is a value but it's not in the options, select the first value or set to null
|
|
136
|
-
if (value && !valueIsInOptions && !definition.spec.default_value) {
|
|
137
|
-
setVariableValue(name, (firstOption === null || firstOption === void 0 ? void 0 : firstOption.value) || null);
|
|
138
|
-
}
|
|
139
146
|
}, [
|
|
140
147
|
finalOptions,
|
|
141
148
|
setVariableValue,
|
|
@@ -159,7 +166,7 @@ function ListVariable({ name }) {
|
|
|
159
166
|
},
|
|
160
167
|
id: name,
|
|
161
168
|
label: name,
|
|
162
|
-
value:
|
|
169
|
+
value: selectValue,
|
|
163
170
|
onChange: (e)=>{
|
|
164
171
|
// Must be selected
|
|
165
172
|
if (e.target.value === null || e.target.value.length === 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Variables/Variable.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 { useEffect, useMemo, useState } from 'react';\nimport { Select, FormControl, InputLabel, MenuItem, Box, LinearProgress, TextField } from '@mui/material';\nimport { VariableName, ListVariableDefinition, VariableValue } from '@perses-dev/core';\nimport {\n usePlugin,\n DEFAULT_ALL_VALUE,\n useTemplateVariableValues,\n VariableStateMap,\n useDatasourceStore,\n} from '@perses-dev/plugin-system';\nimport { useQuery } from '@tanstack/react-query';\nimport { useTemplateVariable, useTemplateVariableActions } from '../../context';\n\ntype TemplateVariableProps = {\n name: VariableName;\n};\n\nexport function TemplateVariable({ name }: TemplateVariableProps) {\n const ctx = useTemplateVariable(name);\n const kind = ctx.definition?.kind;\n switch (kind) {\n case 'TextVariable':\n return <TextVariable name={name} />;\n case 'ListVariable':\n return <ListVariable name={name} />;\n }\n\n return <div>Unsupported Variable Kind: ${kind}</div>;\n}\n\n/**\n * Returns a serialized string of the current state of variable values.\n */\nfunction getVariableValuesKey(v: VariableStateMap) {\n return Object.values(v)\n .map((v) => JSON.stringify(v.value))\n .join(',');\n}\n\nfunction ListVariable({ name }: TemplateVariableProps) {\n const ctx = useTemplateVariable(name);\n const definition = ctx.definition as ListVariableDefinition;\n const { data: variablePlugin } = usePlugin('Variable', definition.spec.plugin.kind);\n const { setVariableValue, setVariableLoading, setVariableOptions } = useTemplateVariableActions();\n const datasourceStore = useDatasourceStore();\n\n const spec = definition.spec.plugin.spec;\n\n let dependsOnVariables: string[] | undefined;\n if (variablePlugin?.dependsOn) {\n dependsOnVariables = variablePlugin.dependsOn(spec);\n }\n\n const variables = useTemplateVariableValues(dependsOnVariables);\n const allowMultiple = definition?.spec.allow_multiple === true;\n const allowAllValue = definition?.spec.allow_all_value === true;\n const label = definition?.spec.display?.label ?? name;\n\n let waitToLoad = false;\n if (dependsOnVariables) {\n waitToLoad = dependsOnVariables.some((v) => variables[v]?.loading);\n }\n\n const variablesValueKey = getVariableValuesKey(variables);\n\n const variablesOptionsQuery = useQuery(\n [name, definition, variablesValueKey],\n async () => {\n const resp = await variablePlugin?.getVariableOptions(spec, { datasourceStore, variables });\n return resp?.data ?? [];\n },\n { enabled: !!variablePlugin || waitToLoad }\n );\n\n useEffect(() => {\n setVariableLoading(name, variablesOptionsQuery.isFetching);\n if (variablesOptionsQuery.data) {\n setVariableOptions(name, variablesOptionsQuery.data);\n }\n }, [variablesOptionsQuery, name, setVariableLoading, setVariableOptions]);\n\n let value = ctx.state?.value;\n const options = ctx.state?.options;\n const loading = ctx.state?.loading;\n\n // Make sure value is an array if allowMultiple is true\n if (allowMultiple && !Array.isArray(value)) {\n value = typeof value === 'string' ? [value] : [];\n }\n\n const finalOptions = useMemo(() => {\n let computedOptions = options ? [...options] : [];\n\n // Add the all value if it's allowed\n if (allowAllValue) {\n computedOptions = [{ value: DEFAULT_ALL_VALUE, label: 'All' }, ...computedOptions];\n }\n return computedOptions;\n }, [options, allowAllValue]);\n\n useEffect(() => {\n const firstOption = finalOptions?.[0];\n const valueIsInOptions = Boolean(\n finalOptions.find((v) => {\n if (allowMultiple) {\n return (value as string[]).includes(v.value);\n }\n return value === v.value;\n })\n );\n\n // If there is no value but there are options, set the value to the first option.\n if (!value && firstOption) {\n setVariableValue(name, firstOption.value);\n }\n\n // If there is a value but it's not in the options, select the first value or set to null\n if (value && !valueIsInOptions && !definition.spec.default_value) {\n setVariableValue(name, firstOption?.value || null);\n }\n }, [finalOptions, setVariableValue, value, name, allowMultiple]);\n\n return (\n <Box display={'flex'}>\n <FormControl fullWidth>\n <InputLabel id={name}>{label}</InputLabel>\n <Select\n sx={{ minWidth: 100, maxWidth: 250 }}\n id={name}\n label={name}\n value={value ?? ''}\n onChange={(e) => {\n // Must be selected\n if (e.target.value === null || e.target.value.length === 0) {\n if (allowAllValue) {\n setVariableValue(name, DEFAULT_ALL_VALUE);\n }\n return;\n }\n setVariableValue(name, e.target.value as VariableValue);\n }}\n multiple={allowMultiple}\n >\n {loading && (\n <MenuItem value=\"loading\" disabled>\n Loading\n </MenuItem>\n )}\n {finalOptions.map((option) => (\n <MenuItem key={option.value} value={option.value}>\n {option.label}\n </MenuItem>\n ))}\n </Select>\n {loading && <LinearProgress />}\n </FormControl>\n </Box>\n );\n}\n\nfunction TextVariable({ name }: TemplateVariableProps) {\n const { state } = useTemplateVariable(name);\n const [tempValue, setTempValue] = useState(state?.value ?? '');\n const { setVariableValue } = useTemplateVariableActions();\n\n useEffect(() => {\n setTempValue(state?.value ?? '');\n }, [state?.value]);\n\n return (\n <TextField\n value={tempValue}\n onChange={(e) => setTempValue(e.target.value)}\n onBlur={() => setVariableValue(name, tempValue)}\n placeholder={name}\n label={name}\n />\n );\n}\n"],"names":["useEffect","useMemo","useState","Select","FormControl","InputLabel","MenuItem","Box","LinearProgress","TextField","usePlugin","DEFAULT_ALL_VALUE","useTemplateVariableValues","useDatasourceStore","useQuery","useTemplateVariable","useTemplateVariableActions","TemplateVariable","name","ctx","kind","definition","TextVariable","ListVariable","div","getVariableValuesKey","v","Object","values","map","JSON","stringify","value","join","data","variablePlugin","spec","plugin","setVariableValue","setVariableLoading","setVariableOptions","datasourceStore","dependsOnVariables","dependsOn","variables","allowMultiple","allow_multiple","allowAllValue","allow_all_value","label","display","waitToLoad","some","loading","variablesValueKey","variablesOptionsQuery","resp","getVariableOptions","enabled","isFetching","state","options","Array","isArray","finalOptions","computedOptions","firstOption","valueIsInOptions","Boolean","find","includes","default_value","fullWidth","id","sx","minWidth","maxWidth","onChange","e","target","length","multiple","disabled","option","tempValue","setTempValue","onBlur","placeholder"],"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,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO,CAAC;AACrD,SAASC,MAAM,EAAEC,WAAW,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,GAAG,EAAEC,cAAc,EAAEC,SAAS,QAAQ,eAAe,CAAC;AAE1G,SACEC,SAAS,EACTC,iBAAiB,EACjBC,yBAAyB,EAEzBC,kBAAkB,QACb,2BAA2B,CAAC;AACnC,SAASC,QAAQ,QAAQ,uBAAuB,CAAC;AACjD,SAASC,mBAAmB,EAAEC,0BAA0B,QAAQ,eAAe,CAAC;AAMhF,OAAO,SAASC,gBAAgB,CAAC,EAAEC,IAAI,CAAA,EAAyB,EAAE;QAEnDC,GAAc;IAD3B,MAAM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MAAM,CAAC/C,KAAK,CAAC;QAC7CsD,MAAM,EAAE,IAAMhD,gBAAgB,CAACpB,IAAI,EAAEkE,SAAS,CAAC;QAC/CG,WAAW,EAAErE,IAAI;QACjB+B,KAAK,EAAE/B,IAAI;MACX,CACF;AACJ,CAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Variables/Variable.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 { useEffect, useMemo, useState } from 'react';\nimport { Select, FormControl, InputLabel, MenuItem, Box, LinearProgress, TextField } from '@mui/material';\nimport { VariableName, ListVariableDefinition, VariableValue } from '@perses-dev/core';\nimport {\n usePlugin,\n DEFAULT_ALL_VALUE,\n useTemplateVariableValues,\n VariableStateMap,\n useDatasourceStore,\n useTimeRange,\n} from '@perses-dev/plugin-system';\nimport { useQuery } from '@tanstack/react-query';\nimport { useTemplateVariable, useTemplateVariableActions } from '../../context';\n\ntype TemplateVariableProps = {\n name: VariableName;\n};\n\nexport function TemplateVariable({ name }: TemplateVariableProps) {\n const ctx = useTemplateVariable(name);\n const kind = ctx.definition?.kind;\n switch (kind) {\n case 'TextVariable':\n return <TextVariable name={name} />;\n case 'ListVariable':\n return <ListVariable name={name} />;\n }\n\n return <div>Unsupported Variable Kind: ${kind}</div>;\n}\n\n/**\n * Returns a serialized string of the current state of variable values.\n */\nfunction getVariableValuesKey(v: VariableStateMap) {\n return Object.values(v)\n .map((v) => JSON.stringify(v.value))\n .join(',');\n}\n\nfunction ListVariable({ name }: TemplateVariableProps) {\n const ctx = useTemplateVariable(name);\n const definition = ctx.definition as ListVariableDefinition;\n const { data: variablePlugin } = usePlugin('Variable', definition.spec.plugin.kind);\n const { setVariableValue, setVariableLoading, setVariableOptions } = useTemplateVariableActions();\n const datasourceStore = useDatasourceStore();\n\n const spec = definition.spec.plugin.spec;\n\n let dependsOnVariables: string[] | undefined;\n if (variablePlugin?.dependsOn) {\n dependsOnVariables = variablePlugin.dependsOn(spec);\n }\n\n const variables = useTemplateVariableValues(dependsOnVariables);\n const allowMultiple = definition?.spec.allow_multiple === true;\n const allowAllValue = definition?.spec.allow_all_value === true;\n const label = definition?.spec.display?.label ?? name;\n\n let waitToLoad = false;\n if (dependsOnVariables) {\n waitToLoad = dependsOnVariables.some((v) => variables[v]?.loading);\n }\n\n const variablesValueKey = getVariableValuesKey(variables);\n const { timeRange } = useTimeRange();\n\n const variablesOptionsQuery = useQuery(\n [name, definition, variablesValueKey, timeRange],\n async () => {\n const resp = await variablePlugin?.getVariableOptions(spec, { datasourceStore, variables, timeRange });\n return resp?.data ?? [];\n },\n { enabled: !!variablePlugin || waitToLoad }\n );\n\n useEffect(() => {\n setVariableLoading(name, variablesOptionsQuery.isFetching);\n if (variablesOptionsQuery.data) {\n setVariableOptions(name, variablesOptionsQuery.data);\n }\n }, [variablesOptionsQuery, name, setVariableLoading, setVariableOptions]);\n\n let value = ctx.state?.value;\n const options = ctx.state?.options;\n const loading = ctx.state?.loading;\n\n // Make sure value is an array if allowMultiple is true\n if (allowMultiple && !Array.isArray(value)) {\n value = typeof value === 'string' ? [value] : [];\n }\n\n const finalOptions = useMemo(() => {\n let computedOptions = options ? [...options] : [];\n\n // Add the all value if it's allowed\n if (allowAllValue) {\n computedOptions = [{ value: DEFAULT_ALL_VALUE, label: 'All' }, ...computedOptions];\n }\n return computedOptions;\n }, [options, allowAllValue]);\n\n const valueIsInOptions = useMemo(\n () =>\n Boolean(\n finalOptions.find((v) => {\n if (allowMultiple) {\n return (value as string[]).includes(v.value);\n }\n return value === v.value;\n })\n ),\n [finalOptions, value, allowMultiple]\n );\n\n let selectValue = value;\n if (!valueIsInOptions) {\n selectValue = allowMultiple ? [] : '';\n }\n\n useEffect(() => {\n const firstOption = finalOptions?.[0];\n\n // If there is no value but there are options, set the value to the first option.\n if (!value && firstOption) {\n setVariableValue(name, firstOption.value);\n }\n }, [finalOptions, setVariableValue, value, name, allowMultiple]);\n\n return (\n <Box display={'flex'}>\n <FormControl fullWidth>\n <InputLabel id={name}>{label}</InputLabel>\n <Select\n sx={{ minWidth: 100, maxWidth: 250 }}\n id={name}\n label={name}\n value={selectValue}\n onChange={(e) => {\n // Must be selected\n if (e.target.value === null || e.target.value.length === 0) {\n if (allowAllValue) {\n setVariableValue(name, DEFAULT_ALL_VALUE);\n }\n return;\n }\n setVariableValue(name, e.target.value as VariableValue);\n }}\n multiple={allowMultiple}\n >\n {loading && (\n <MenuItem value=\"loading\" disabled>\n Loading\n </MenuItem>\n )}\n {finalOptions.map((option) => (\n <MenuItem key={option.value} value={option.value}>\n {option.label}\n </MenuItem>\n ))}\n </Select>\n {loading && <LinearProgress />}\n </FormControl>\n </Box>\n );\n}\n\nfunction TextVariable({ name }: TemplateVariableProps) {\n const { state } = useTemplateVariable(name);\n const [tempValue, setTempValue] = useState(state?.value ?? '');\n const { setVariableValue } = useTemplateVariableActions();\n\n useEffect(() => {\n setTempValue(state?.value ?? '');\n }, [state?.value]);\n\n return (\n <TextField\n value={tempValue}\n onChange={(e) => setTempValue(e.target.value)}\n onBlur={() => setVariableValue(name, tempValue)}\n placeholder={name}\n label={name}\n />\n );\n}\n"],"names":["useEffect","useMemo","useState","Select","FormControl","InputLabel","MenuItem","Box","LinearProgress","TextField","usePlugin","DEFAULT_ALL_VALUE","useTemplateVariableValues","useDatasourceStore","useTimeRange","useQuery","useTemplateVariable","useTemplateVariableActions","TemplateVariable","name","ctx","kind","definition","TextVariable","ListVariable","div","getVariableValuesKey","v","Object","values","map","JSON","stringify","value","join","data","variablePlugin","spec","plugin","setVariableValue","setVariableLoading","setVariableOptions","datasourceStore","dependsOnVariables","dependsOn","variables","allowMultiple","allow_multiple","allowAllValue","allow_all_value","label","display","waitToLoad","some","loading","variablesValueKey","timeRange","variablesOptionsQuery","resp","getVariableOptions","enabled","isFetching","state","options","Array","isArray","finalOptions","computedOptions","valueIsInOptions","Boolean","find","includes","selectValue","firstOption","fullWidth","id","sx","minWidth","maxWidth","onChange","e","target","length","multiple","disabled","option","tempValue","setTempValue","onBlur","placeholder"],"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,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO,CAAC;AACrD,SAASC,MAAM,EAAEC,WAAW,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,GAAG,EAAEC,cAAc,EAAEC,SAAS,QAAQ,eAAe,CAAC;AAE1G,SACEC,SAAS,EACTC,iBAAiB,EACjBC,yBAAyB,EAEzBC,kBAAkB,EAClBC,YAAY,QACP,2BAA2B,CAAC;AACnC,SAASC,QAAQ,QAAQ,uBAAuB,CAAC;AACjD,SAASC,mBAAmB,EAAEC,0BAA0B,QAAQ,eAAe,CAAC;AAMhF,OAAO,SAASC,gBAAgB,CAAC,EAAEC,IAAI,CAAA,EAAyB,EAAE;QAEnDC,GAAc;IAD3B,MAAMA,GAAG,GAAGJ,mBAAmB,CAACG,IAAI,CAAC,AAAC;IACtC,MAAME,IAAI,GAAGD,CAAAA,GAAc,GAAdA,GAAG,CAACE,UAAU,cAAdF,GAAc,WAAM,GAApBA,KAAAA,CAAoB,GAApBA,GAAc,CAAEC,IAAI,AAAC;IAClC,OAAQA,IAAI;QACV,KAAK,cAAc;YACjB,qBAAO,KAACE,YAAY;gBAACJ,IAAI,EAAEA,IAAI;cAAI,CAAC;QACtC,KAAK,cAAc;YACjB,qBA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DeletePanelGroupDialog';
|
|
2
5
|
export * from './GridLayout';
|
|
3
6
|
export * from './Panel';
|
|
4
7
|
export * from './PanelDrawer';
|
|
5
8
|
export * from './PanelGroupDialog';
|
|
6
9
|
export * from './TimeRangeControls';
|
|
10
|
+
export * from './UnsavedChangesConfirmationDialog';
|
|
7
11
|
export * from './Variables';
|
|
8
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAaA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAaA,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oCAAoC,CAAC;AACnD,cAAc,aAAa,CAAC"}
|
package/dist/components/index.js
CHANGED
|
@@ -11,11 +11,15 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
export * from './Dashboard';
|
|
14
|
+
export * from './DashboardToolbar';
|
|
15
|
+
export * from './DeletePanelDialog';
|
|
16
|
+
export * from './DeletePanelGroupDialog';
|
|
14
17
|
export * from './GridLayout';
|
|
15
18
|
export * from './Panel';
|
|
16
19
|
export * from './PanelDrawer';
|
|
17
20
|
export * from './PanelGroupDialog';
|
|
18
21
|
export * from './TimeRangeControls';
|
|
22
|
+
export * from './UnsavedChangesConfirmationDialog';
|
|
19
23
|
export * from './Variables';
|
|
20
24
|
|
|
21
25
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/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 './Dashboard';\nexport * from './GridLayout';\nexport * from './Panel';\nexport * from './PanelDrawer';\nexport * from './PanelGroupDialog';\nexport * from './TimeRangeControls';\nexport * from './Variables';\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,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/components/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 './Dashboard';\nexport * from './DashboardToolbar';\nexport * from './DeletePanelDialog';\nexport * from './DeletePanelGroupDialog';\nexport * from './GridLayout';\nexport * from './Panel';\nexport * from './PanelDrawer';\nexport * from './PanelGroupDialog';\nexport * from './TimeRangeControls';\nexport * from './UnsavedChangesConfirmationDialog';\nexport * from './Variables';\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,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oCAAoC,CAAC;AACnD,cAAc,aAAa,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { StoreApi } from 'zustand';
|
|
3
|
-
import {
|
|
3
|
+
import { DashboardResource, ProjectMetadata, RelativeTimeRange } from '@perses-dev/core';
|
|
4
4
|
import { PanelGroupEditorSlice } from './panel-group-editor-slice';
|
|
5
5
|
import { PanelGroupSlice } from './panel-group-slice';
|
|
6
6
|
import { PanelEditorSlice } from './panel-editor-slice';
|
|
@@ -11,11 +11,11 @@ export interface DashboardStoreState extends PanelGroupSlice, PanelSlice, PanelG
|
|
|
11
11
|
isEditMode: boolean;
|
|
12
12
|
setEditMode: (isEditMode: boolean) => void;
|
|
13
13
|
defaultTimeRange: RelativeTimeRange;
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
setDashboard: (dashboard: DashboardResource) => void;
|
|
15
|
+
metadata: ProjectMetadata;
|
|
16
16
|
}
|
|
17
17
|
export interface DashboardStoreProps {
|
|
18
|
-
|
|
18
|
+
dashboardResource: DashboardResource;
|
|
19
19
|
isEditMode?: boolean;
|
|
20
20
|
}
|
|
21
21
|
export interface DashboardProviderProps {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DashboardProvider.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/DashboardProvider.tsx"],"names":[],"mappings":";AAcA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAKxC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"DashboardProvider.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/DashboardProvider.tsx"],"names":[],"mappings":";AAcA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAKxC,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACzF,OAAO,EAA+B,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAChG,OAAO,EAAsD,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC1G,OAAO,EAA0B,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAoB,UAAU,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAA+B,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAChG,OAAO,EAA0B,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAEhF,MAAM,WAAW,mBACf,SAAQ,eAAe,EACrB,UAAU,EACV,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB;IAClB,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;IAC3C,gBAAgB,EAAE,iBAAiB,CAAC;IACpC,YAAY,EAAE,CAAC,SAAS,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACrD,QAAQ,EAAE,eAAe,CAAC;CAC3B;AAED,MAAM,WAAW,mBAAmB;IAClC,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,sBAAsB;IACrC,YAAY,EAAE,mBAAmB,CAAC;IAClC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,eAAO,MAAM,gBAAgB,oEAAsE,CAAC;AAEpG,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,CAAC,KAM/E;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,eAU9D"}
|
|
@@ -15,9 +15,9 @@ import { createStore, useStore } from 'zustand';
|
|
|
15
15
|
import { devtools } from 'zustand/middleware';
|
|
16
16
|
import { immer } from 'zustand/middleware/immer';
|
|
17
17
|
import shallow from 'zustand/shallow';
|
|
18
|
-
import { createContext, useContext } from 'react';
|
|
18
|
+
import { createContext, useCallback, useContext, useState } from 'react';
|
|
19
19
|
import { createPanelGroupEditorSlice } from './panel-group-editor-slice';
|
|
20
|
-
import { createPanelGroupSlice } from './panel-group-slice';
|
|
20
|
+
import { convertLayoutsToPanelGroups, createPanelGroupSlice } from './panel-group-slice';
|
|
21
21
|
import { createPanelEditorSlice } from './panel-editor-slice';
|
|
22
22
|
import { createPanelSlice } from './panel-slice';
|
|
23
23
|
import { createDeletePanelGroupSlice } from './delete-panel-group-slice';
|
|
@@ -31,10 +31,20 @@ export function useDashboardStore(selector) {
|
|
|
31
31
|
return useStore(store, selector, shallow);
|
|
32
32
|
}
|
|
33
33
|
export function DashboardProvider(props) {
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
const createDashboardStore = useCallback(initStore, [
|
|
35
|
+
props
|
|
36
|
+
]);
|
|
37
|
+
const [store] = useState(createDashboardStore(props)); // prevent calling createDashboardStore every time it rerenders
|
|
38
|
+
return /*#__PURE__*/ _jsx(DashboardContext.Provider, {
|
|
39
|
+
value: store,
|
|
40
|
+
children: props.children
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function initStore(props) {
|
|
44
|
+
const { initialState: { dashboardResource , isEditMode } , } = props;
|
|
45
|
+
const { spec: { layouts , panels , duration } , metadata , } = dashboardResource;
|
|
46
|
+
const store = createStore()(immer(devtools((...args)=>{
|
|
47
|
+
const [set] = args;
|
|
38
48
|
return {
|
|
39
49
|
...createPanelGroupSlice(layouts)(...args),
|
|
40
50
|
...createPanelSlice(panels)(...args),
|
|
@@ -42,29 +52,25 @@ export function DashboardProvider(props) {
|
|
|
42
52
|
...createDeletePanelGroupSlice(...args),
|
|
43
53
|
...createPanelEditorSlice()(...args),
|
|
44
54
|
...createDeletePanelSlice()(...args),
|
|
55
|
+
metadata,
|
|
45
56
|
defaultTimeRange: {
|
|
46
|
-
pastDuration:
|
|
57
|
+
pastDuration: duration
|
|
47
58
|
},
|
|
48
59
|
isEditMode: !!isEditMode,
|
|
49
60
|
setEditMode: (isEditMode)=>set({
|
|
50
61
|
isEditMode
|
|
51
62
|
}),
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
savePanels();
|
|
60
|
-
savePanelGroups();
|
|
63
|
+
setDashboard: ({ spec: { panels , layouts } })=>{
|
|
64
|
+
set((state)=>{
|
|
65
|
+
const { panelGroups , panelGroupOrder } = convertLayoutsToPanelGroups(layouts);
|
|
66
|
+
state.panels = panels;
|
|
67
|
+
state.panelGroups = panelGroups;
|
|
68
|
+
state.panelGroupOrder = panelGroupOrder;
|
|
69
|
+
});
|
|
61
70
|
}
|
|
62
71
|
};
|
|
63
72
|
})));
|
|
64
|
-
return
|
|
65
|
-
value: dashboardStore,
|
|
66
|
-
children: children
|
|
67
|
-
});
|
|
73
|
+
return store;
|
|
68
74
|
}
|
|
69
75
|
|
|
70
76
|
//# sourceMappingURL=DashboardProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/context/DashboardProvider/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 { devtools } from 'zustand/middleware';\nimport { immer } from 'zustand/middleware/immer';\nimport shallow from 'zustand/shallow';\nimport { createContext, useContext } from 'react';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/context/DashboardProvider/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 { devtools } from 'zustand/middleware';\nimport { immer } from 'zustand/middleware/immer';\nimport shallow from 'zustand/shallow';\nimport { createContext, useCallback, useContext, useState } from 'react';\nimport { DashboardResource, ProjectMetadata, RelativeTimeRange } from '@perses-dev/core';\nimport { createPanelGroupEditorSlice, PanelGroupEditorSlice } from './panel-group-editor-slice';\nimport { convertLayoutsToPanelGroups, createPanelGroupSlice, PanelGroupSlice } from './panel-group-slice';\nimport { createPanelEditorSlice, PanelEditorSlice } from './panel-editor-slice';\nimport { createPanelSlice, PanelSlice } from './panel-slice';\nimport { createDeletePanelGroupSlice, DeletePanelGroupSlice } from './delete-panel-group-slice';\nimport { createDeletePanelSlice, DeletePanelSlice } from './delete-panel-slice';\n\nexport interface DashboardStoreState\n extends PanelGroupSlice,\n PanelSlice,\n PanelGroupEditorSlice,\n DeletePanelGroupSlice,\n PanelEditorSlice,\n DeletePanelSlice {\n isEditMode: boolean;\n setEditMode: (isEditMode: boolean) => void;\n defaultTimeRange: RelativeTimeRange;\n setDashboard: (dashboard: DashboardResource) => void;\n metadata: ProjectMetadata;\n}\n\nexport interface DashboardStoreProps {\n dashboardResource: DashboardResource;\n isEditMode?: boolean;\n}\n\nexport interface DashboardProviderProps {\n initialState: DashboardStoreProps;\n children?: React.ReactNode;\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 createDashboardStore = useCallback(initStore, [props]);\n\n const [store] = useState(createDashboardStore(props)); // prevent calling createDashboardStore every time it rerenders\n\n return (\n <DashboardContext.Provider value={store as StoreApi<DashboardStoreState>}>\n {props.children}\n </DashboardContext.Provider>\n );\n}\n\nfunction initStore(props: DashboardProviderProps) {\n const {\n initialState: { dashboardResource, isEditMode },\n } = props;\n\n const {\n spec: { layouts, panels, duration },\n metadata,\n } = dashboardResource;\n const store = createStore<DashboardStoreState>()(\n immer(\n devtools((...args) => {\n const [set] = args;\n return {\n ...createPanelGroupSlice(layouts)(...args),\n ...createPanelSlice(panels)(...args),\n ...createPanelGroupEditorSlice(...args),\n ...createDeletePanelGroupSlice(...args),\n ...createPanelEditorSlice()(...args),\n ...createDeletePanelSlice()(...args),\n metadata,\n defaultTimeRange: { pastDuration: duration },\n isEditMode: !!isEditMode,\n setEditMode: (isEditMode: boolean) => set({ isEditMode }),\n setDashboard: ({ spec: { panels, layouts } }) => {\n set((state) => {\n const { panelGroups, panelGroupOrder } = convertLayoutsToPanelGroups(layouts);\n state.panels = panels;\n state.panelGroups = panelGroups;\n state.panelGroupOrder = panelGroupOrder;\n });\n },\n };\n })\n )\n );\n\n return store;\n}\n"],"names":["createStore","useStore","devtools","immer","shallow","createContext","useCallback","useContext","useState","createPanelGroupEditorSlice","convertLayoutsToPanelGroups","createPanelGroupSlice","createPanelEditorSlice","createPanelSlice","createDeletePanelGroupSlice","createDeletePanelSlice","DashboardContext","undefined","useDashboardStore","selector","store","Error","DashboardProvider","props","createDashboardStore","initStore","Provider","value","children","initialState","dashboardResource","isEditMode","spec","layouts","panels","duration","metadata","args","set","defaultTimeRange","pastDuration","setEditMode","setDashboard","state","panelGroups","panelGroupOrder"],"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,QAAQ,QAAQ,oBAAoB,CAAC;AAC9C,SAASC,KAAK,QAAQ,0BAA0B,CAAC;AACjD,OAAOC,OAAO,MAAM,iBAAiB,CAAC;AACtC,SAASC,aAAa,EAAEC,WAAW,EAAEC,UAAU,EAAEC,QAAQ,QAAQ,OAAO,CAAC;AAEzE,SAASC,2BAA2B,QAA+B,4BAA4B,CAAC;AAChG,SAASC,2BAA2B,EAAEC,qBAAqB,QAAyB,qBAAqB,CAAC;AAC1G,SAASC,sBAAsB,QAA0B,sBAAsB,CAAC;AAChF,SAASC,gBAAgB,QAAoB,eAAe,CAAC;AAC7D,SAASC,2BAA2B,QAA+B,4B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YACL,GAAG1B,qBAAqB,CAACsB,OAAO,CAAC,IAAII,IAAI,CAAC;YAC1C,GAAGxB,gBAAgB,CAACqB,MAAM,CAAC,IAAIG,IAAI,CAAC;YACpC,GAAG5B,2BAA2B,IAAI4B,IAAI,CAAC;YACvC,GAAGvB,2BAA2B,IAAIuB,IAAI,CAAC;YACvC,GAAGzB,sBAAsB,EAAE,IAAIyB,IAAI,CAAC;YACpC,GAAGtB,sBAAsB,EAAE,IAAIsB,IAAI,CAAC;YACpCD,QAAQ;YACRG,gBAAgB,EAAE;gBAAEC,YAAY,EAAEL,QAAQ;aAAE;YAC5CJ,UAAU,EAAE,CAAC,CAACA,UAAU;YACxBU,WAAW,EAAE,CAACV,UAAmB,GAAKO,GAAG,CAAC;oBAAEP,UAAU;iBAAE,CAAC;YACzDW,YAAY,EAAE,CAAC,EAAEV,IAAI,EAAE,EAAEE,MAAM,CAAA,EAAED,OAAO,CAAA,EAAE,CAAA,EAAE,GAAK;gBAC/CK,GAAG,CAAC,CAACK,KAAK,GAAK;oBACb,MAAM,EAAEC,WAAW,CAAA,EAAEC,eAAe,CAAA,EAAE,GAAGnC,2BAA2B,CAACuB,OAAO,CAAC,AAAC;oBAC9EU,KAAK,CAACT,MAAM,GAAGA,MAAM,CAAC;oBACtBS,KAAK,CAACC,WAAW,GAAGA,WAAW,CAAC;oBAChCD,KAAK,CAACE,eAAe,GAAGA,eAAe,CAAC;gBAC1C,CAAC,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC,CAAC,CACH,CACF,AAAC;IAEF,OAAOzB,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export declare type Middleware = [['zustand/immer', never], ['zustand/devtools', never]];
|
|
5
5
|
declare global {
|
|
6
|
-
var dashboardStoreId: number
|
|
6
|
+
var dashboardStoreId: number;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* Helper function to generate unique IDs for things in the dashboard store that don't have a "natural" ID.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/common.ts"],"names":[],"mappings":"AAaA;;GAEG;AACH,oBAAY,UAAU,GAAG,CAAC,CAAC,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC,CAAC;AAEjF,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/common.ts"],"names":[],"mappings":"AAaA;;GAEG;AACH,oBAAY,UAAU,GAAG,CAAC,CAAC,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC,CAAC;AAEjF,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,gBAAgB,EAAE,MAAM,CAAC;CAC9B;AAMD;;GAEG;AACH,wBAAgB,UAAU,WAEzB"}
|
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
/**
|
|
14
14
|
* The middleware applied to the DashboardStore (can be used as generic argument in StateCreator).
|
|
15
|
-
*/
|
|
15
|
+
*/ if (globalThis.dashboardStoreId === undefined) {
|
|
16
|
+
globalThis.dashboardStoreId = 0;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
16
19
|
* Helper function to generate unique IDs for things in the dashboard store that don't have a "natural" ID.
|
|
17
20
|
*/ export function generateId() {
|
|
18
|
-
if (globalThis.dashboardStoreId === undefined) {
|
|
19
|
-
globalThis.dashboardStoreId = -1;
|
|
20
|
-
}
|
|
21
21
|
return globalThis.dashboardStoreId++;
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/context/DashboardProvider/common.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\n/**\n * The middleware applied to the DashboardStore (can be used as generic argument in StateCreator).\n */\nexport type Middleware = [['zustand/immer', never], ['zustand/devtools', never]];\n\ndeclare global {\n // eslint-disable-next-line no-var\n var dashboardStoreId: number
|
|
1
|
+
{"version":3,"sources":["../../../src/context/DashboardProvider/common.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\n/**\n * The middleware applied to the DashboardStore (can be used as generic argument in StateCreator).\n */\nexport type Middleware = [['zustand/immer', never], ['zustand/devtools', never]];\n\ndeclare global {\n // eslint-disable-next-line no-var\n var dashboardStoreId: number;\n}\n\nif (globalThis.dashboardStoreId === undefined) {\n globalThis.dashboardStoreId = 0;\n}\n\n/**\n * Helper function to generate unique IDs for things in the dashboard store that don't have a \"natural\" ID.\n */\nexport function generateId() {\n return globalThis.dashboardStoreId++;\n}\n"],"names":["globalThis","dashboardStoreId","undefined","generateId"],"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;;CAEC,GACD,AAOA,IAAIA,UAAU,CAACC,gBAAgB,KAAKC,SAAS,EAAE;IAC7CF,UAAU,CAACC,gBAAgB,GAAG,CAAC,CAAC;AAClC,CAAC;AAED;;CAEC,GACD,OAAO,SAASE,UAAU,GAAG;IAC3B,OAAOH,UAAU,CAACC,gBAAgB,EAAE,CAAC;AACvC,CAAC"}
|
|
@@ -7,8 +7,7 @@ export declare function useEditMode(): {
|
|
|
7
7
|
* Returns actions that can be performed on the current dashboard.
|
|
8
8
|
*/
|
|
9
9
|
export declare function useDashboardActions(): {
|
|
10
|
-
|
|
11
|
-
reset: () => void;
|
|
10
|
+
setDashboard: (dashboard: import("@perses-dev/core").DashboardResource) => void;
|
|
12
11
|
openAddPanelGroup: () => void;
|
|
13
12
|
openAddPanel: () => void;
|
|
14
13
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dashboard-provider-api.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/dashboard-provider-api.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3F,wBAAgB,WAAW;;;EAE1B;AAED;;GAEG;AACH,wBAAgB,mBAAmB
|
|
1
|
+
{"version":3,"file":"dashboard-provider-api.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/dashboard-provider-api.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3F,wBAAgB,WAAW;;;EAE1B;AAED;;GAEG;AACH,wBAAgB,mBAAmB;;;;EAUlC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,aAE/B;AAED;;GAEG;AACH,wBAAgB,kBAAkB,yDAYjC;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,YAAY,EAAE,YAAY,sDAMvD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,YAAY;;;;;;2CAapB,oBAAoB,EAAE;EAGhE;AAuBD;;GAEG;AACH,wBAAgB,mBAAmB,sEAElC;AAED;;GAEG;AACH,wBAAgB,yBAAyB;;;;;EASxC;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,sFAa1D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,gBAAgB,EAAE,gBAAgB;;;EAOjE;AAED;;GAEG;AACH,wBAAgB,cAAc,gEAE7B;AAED;;GAEG;AACH,wBAAgB,oBAAoB;;;;EAWnC;AAED,wBAAgB,mBAAmB,iDAElC"}
|
|
@@ -21,13 +21,11 @@ export function useEditMode() {
|
|
|
21
21
|
/**
|
|
22
22
|
* Returns actions that can be performed on the current dashboard.
|
|
23
23
|
*/ export function useDashboardActions() {
|
|
24
|
-
const
|
|
25
|
-
const reset = useDashboardStore((store)=>store.reset);
|
|
24
|
+
const setDashboard = useDashboardStore((store)=>store.setDashboard);
|
|
26
25
|
const openAddPanelGroup = useDashboardStore((store)=>store.openAddPanelGroup);
|
|
27
26
|
const openAddPanel = useDashboardStore((store)=>store.openAddPanel);
|
|
28
27
|
return {
|
|
29
|
-
|
|
30
|
-
reset,
|
|
28
|
+
setDashboard,
|
|
31
29
|
openAddPanelGroup,
|
|
32
30
|
openAddPanel: ()=>openAddPanel(undefined)
|
|
33
31
|
};
|