@perses-dev/dashboards 0.10.0 → 0.12.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 +4 -5
- package/dist/cjs/components/DashboardToolbar.js +18 -5
- package/dist/cjs/components/GridLayout/GridItemContent.js +3 -11
- package/dist/cjs/components/GridLayout/GridLayout.js +20 -20
- package/dist/cjs/components/GridLayout/GridTitle.js +9 -11
- package/dist/cjs/components/Panel/DeletePanelDialog.js +12 -10
- package/dist/cjs/components/Panel/Panel.js +12 -22
- package/dist/cjs/components/Panel/Panel.test.js +5 -3
- package/dist/cjs/components/Panel/index.js +1 -0
- package/dist/cjs/components/PanelDrawer/PanelDrawer.js +1 -1
- package/dist/cjs/components/PanelDrawer/PanelDrawer.test.js +13 -5
- package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +21 -15
- package/dist/cjs/components/PanelDrawer/PanelPreview.js +9 -3
- package/dist/cjs/components/PanelGroupDialog/DeletePanelGroupDialog.js +13 -11
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +70 -111
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.test.js +22 -16
- package/dist/cjs/components/PanelGroupDialog/PanelGroupEditorForm.js +92 -0
- package/dist/cjs/components/PanelGroupDialog/index.js +29 -0
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +8 -11
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.test.js +20 -13
- package/dist/cjs/components/Variables/Variable.js +1 -0
- package/dist/cjs/components/Variables/VariableEditor.js +40 -6
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +9 -5
- package/dist/cjs/components/Variables/VariableList.js +0 -1
- package/dist/cjs/components/index.js +1 -0
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +26 -8
- package/dist/cjs/context/DashboardProvider/common.js +10 -0
- package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +122 -29
- package/dist/cjs/context/DashboardProvider/delete-panel-group-slice.js +70 -0
- package/dist/cjs/context/DashboardProvider/delete-panel-slice.js +85 -0
- package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +182 -0
- package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +89 -0
- package/dist/cjs/context/DashboardProvider/panel-group-slice.js +83 -18
- package/dist/cjs/context/DashboardProvider/panel-slice.js +36 -0
- package/dist/cjs/context/TimeRangeProvider.js +20 -44
- package/dist/cjs/context/index.js +1 -1
- package/dist/cjs/context/useDashboardSpec.js +90 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/test/render.js +25 -5
- package/dist/cjs/test/setup-tests.js +4 -1
- package/dist/cjs/test/testDashboard.js +11 -10
- package/dist/cjs/utils/index.js +28 -0
- package/dist/cjs/utils/time-range-params.js +151 -0
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +2 -5
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +5 -22
- package/dist/cjs/views/ViewDashboard/tests/panelGroups.test.js +42 -93
- package/dist/components/Dashboard.js +5 -6
- package/dist/components/Dashboard.js.map +1 -1
- package/dist/components/DashboardToolbar.d.ts.map +1 -1
- package/dist/components/DashboardToolbar.js +20 -7
- package/dist/components/DashboardToolbar.js.map +1 -1
- package/dist/components/GridLayout/GridItemContent.d.ts +2 -4
- package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
- package/dist/components/GridLayout/GridItemContent.js +4 -12
- package/dist/components/GridLayout/GridItemContent.js.map +1 -1
- package/dist/components/GridLayout/GridLayout.d.ts +2 -3
- package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
- package/dist/components/GridLayout/GridLayout.js +22 -22
- package/dist/components/GridLayout/GridLayout.js.map +1 -1
- package/dist/components/GridLayout/GridTitle.d.ts +2 -1
- package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
- package/dist/components/GridLayout/GridTitle.js +10 -12
- package/dist/components/GridLayout/GridTitle.js.map +1 -1
- package/dist/components/Panel/DeletePanelDialog.d.ts +0 -1
- package/dist/components/Panel/DeletePanelDialog.d.ts.map +1 -1
- package/dist/components/Panel/DeletePanelDialog.js +13 -11
- package/dist/components/Panel/DeletePanelDialog.js.map +1 -1
- package/dist/components/Panel/Panel.d.ts +2 -2
- package/dist/components/Panel/Panel.d.ts.map +1 -1
- package/dist/components/Panel/Panel.js +12 -22
- package/dist/components/Panel/Panel.js.map +1 -1
- package/dist/components/Panel/Panel.test.d.ts +1 -1
- package/dist/components/Panel/Panel.test.d.ts.map +1 -1
- package/dist/components/Panel/Panel.test.js +5 -3
- package/dist/components/Panel/Panel.test.js.map +1 -1
- package/dist/components/Panel/index.d.ts +1 -0
- package/dist/components/Panel/index.d.ts.map +1 -1
- package/dist/components/Panel/index.js +1 -0
- package/dist/components/Panel/index.js.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.js +2 -2
- package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.test.js +13 -5
- package/dist/components/PanelDrawer/PanelDrawer.test.js.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.js +22 -16
- package/dist/components/PanelDrawer/PanelEditorForm.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 +9 -3
- package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.d.ts +1 -2
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -1
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.js +13 -11
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts +4 -2
- package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js +73 -112
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js +21 -15
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts +12 -0
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts.map +1 -0
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js +82 -0
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js.map +1 -0
- package/dist/components/PanelGroupDialog/index.d.ts +3 -0
- package/dist/components/PanelGroupDialog/index.d.ts.map +1 -0
- package/dist/components/PanelGroupDialog/index.js +16 -0
- package/dist/components/PanelGroupDialog/index.js.map +1 -0
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js +11 -14
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.test.js +21 -14
- package/dist/components/TimeRangeControls/TimeRangeControls.test.js.map +1 -1
- package/dist/components/Variables/Variable.js +1 -0
- 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 +40 -6
- 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 +9 -5
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
- package/dist/components/Variables/VariableList.js +0 -1
- package/dist/components/Variables/VariableList.js.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -0
- package/dist/components/index.js.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.d.ts +10 -5
- package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.js +26 -8
- package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
- package/dist/context/DashboardProvider/common.d.ts +7 -0
- package/dist/context/DashboardProvider/common.d.ts.map +1 -1
- package/dist/context/DashboardProvider/common.js +8 -1
- package/dist/context/DashboardProvider/common.js.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +65 -22
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.js +133 -26
- package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
- package/dist/context/DashboardProvider/delete-panel-group-slice.d.ts +23 -0
- package/dist/context/DashboardProvider/delete-panel-group-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/delete-panel-group-slice.js +64 -0
- package/dist/context/DashboardProvider/delete-panel-group-slice.js.map +1 -0
- package/dist/context/DashboardProvider/delete-panel-slice.d.ts +36 -0
- package/dist/context/DashboardProvider/delete-panel-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/delete-panel-slice.js +81 -0
- package/dist/context/DashboardProvider/delete-panel-slice.js.map +1 -0
- package/dist/context/DashboardProvider/index.d.ts +3 -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-editor-slice.d.ts +56 -0
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/panel-editor-slice.js +178 -0
- package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -0
- package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts +33 -0
- package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/panel-group-editor-slice.js +83 -0
- package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -0
- package/dist/context/DashboardProvider/panel-group-slice.d.ts +60 -11
- package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-group-slice.js +85 -18
- package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
- package/dist/context/DashboardProvider/panel-slice.d.ts +23 -0
- package/dist/context/DashboardProvider/panel-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/panel-slice.js +32 -0
- package/dist/context/DashboardProvider/panel-slice.js.map +1 -0
- package/dist/context/TimeRangeProvider.d.ts +9 -2
- package/dist/context/TimeRangeProvider.d.ts.map +1 -1
- package/dist/context/TimeRangeProvider.js +15 -43
- package/dist/context/TimeRangeProvider.js.map +1 -1
- 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/useDashboardSpec.d.ts +11 -0
- package/dist/context/useDashboardSpec.d.ts.map +1 -0
- package/dist/context/useDashboardSpec.js +84 -0
- package/dist/context/useDashboardSpec.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/test/render.d.ts +2 -1
- package/dist/test/render.d.ts.map +1 -1
- package/dist/test/render.js +25 -5
- package/dist/test/render.js.map +1 -1
- package/dist/test/setup-tests.d.ts.map +1 -1
- package/dist/test/setup-tests.js +4 -0
- package/dist/test/setup-tests.js.map +1 -1
- package/dist/test/testDashboard.d.ts.map +1 -1
- package/dist/test/testDashboard.js +11 -10
- package/dist/test/testDashboard.js.map +1 -1
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +15 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/time-range-params.d.ts +25 -0
- package/dist/utils/time-range-params.d.ts.map +1 -0
- package/dist/utils/time-range-params.js +143 -0
- package/dist/utils/time-range-params.js.map +1 -0
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.js +1 -4
- package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.js +5 -22
- package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
- package/dist/views/ViewDashboard/tests/panelGroups.test.js +45 -96
- package/dist/views/ViewDashboard/tests/panelGroups.test.js.map +1 -1
- package/package.json +5 -4
- package/dist/cjs/context/DashboardProvider/layout-slice.js +0 -200
- package/dist/cjs/context/DashboardProvider/panel-editing-slice.js +0 -156
- package/dist/cjs/context/QueryStringProvider.js +0 -89
- package/dist/context/DashboardProvider/layout-slice.d.ts +0 -57
- package/dist/context/DashboardProvider/layout-slice.d.ts.map +0 -1
- package/dist/context/DashboardProvider/layout-slice.js +0 -196
- package/dist/context/DashboardProvider/layout-slice.js.map +0 -1
- package/dist/context/DashboardProvider/panel-editing-slice.d.ts +0 -70
- package/dist/context/DashboardProvider/panel-editing-slice.d.ts.map +0 -1
- package/dist/context/DashboardProvider/panel-editing-slice.js +0 -152
- package/dist/context/DashboardProvider/panel-editing-slice.js.map +0 -1
- package/dist/context/QueryStringProvider.d.ts +0 -13
- package/dist/context/QueryStringProvider.d.ts.map +0 -1
- package/dist/context/QueryStringProvider.js +0 -40
- package/dist/context/QueryStringProvider.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/context/DashboardProvider/delete-panel-group-slice.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\nimport { StateCreator } from 'zustand';\nimport { Middleware } from './common';\nimport { PanelGroupId, PanelGroupSlice } from './panel-group-slice';\nimport { PanelSlice } from './panel-slice';\n\n/**\n * Slice that handles the visual editor state and related actions for deleting a Panel Group.\n */\nexport interface DeletePanelGroupSlice {\n deletePanelGroupDialog?: DeletePanelGroupDialogState;\n\n /**\n * Delete panel group and all the panels within the group\n */\n deletePanelGroup: (panelGroupId: PanelGroupId) => void;\n\n openDeletePanelGroupDialog: (panelGroupId: PanelGroupId) => void;\n closeDeletePanelGroupDialog: () => void;\n}\n\nexport interface DeletePanelGroupDialogState {\n panelGroupId: PanelGroupId;\n panelGroupName?: string;\n}\n\nexport const createDeletePanelGroupSlice: StateCreator<\n // Actions in here need to modify both Panels and Panel Groups state\n DeletePanelGroupSlice & PanelGroupSlice & PanelSlice,\n Middleware,\n [],\n DeletePanelGroupSlice\n> = (set, get) => ({\n deletePanelGroup(panelGroupId) {\n const { panelGroups, panelGroupOrder } = get();\n const group = panelGroups[panelGroupId];\n const idIndex = panelGroupOrder.findIndex((id) => id === panelGroupId);\n if (group === undefined || idIndex === -1) {\n throw new Error(`Panel group ${panelGroupId} not found`);\n }\n\n // Get the panel keys for all the panel items in the group we're going to delete\n const panelKeys = Object.values(group.itemPanelKeys);\n\n set((draft) => {\n // Delete the panel group which also deletes all its items\n delete draft.panelGroups[panelGroupId];\n draft.panelGroupOrder.splice(idIndex, 1);\n\n // Get all remaining panel keys in use\n const usedPanelKeys = getUsedPanelKeys(draft.panelGroups);\n\n // For the panel keys of the items that were just deleted, see if they're still used and if not, also delete the\n // panel definition\n for (const panelKey of panelKeys) {\n if (usedPanelKeys.has(panelKey)) continue;\n\n delete draft.panels[panelKey];\n }\n });\n },\n\n openDeletePanelGroupDialog: (panelGroupId) => {\n const panelGroup = get().panelGroups[panelGroupId];\n if (panelGroup === undefined) {\n throw new Error(`Panel group with Id ${panelGroupId} not found`);\n }\n set((state) => {\n state.deletePanelGroupDialog = { panelGroupId, panelGroupName: panelGroup.title };\n });\n },\n\n closeDeletePanelGroupDialog: () =>\n set((state) => {\n state.deletePanelGroupDialog = undefined;\n }),\n});\n\n// Helper to get the panel keys of all groups, returning a set to eliminate duplicates\nfunction getUsedPanelKeys(panelGroups: PanelGroupSlice['panelGroups']): Set<string> {\n const usedPanelKeys = new Set<string>();\n for (const group of Object.values(panelGroups)) {\n for (const panelKey of Object.values(group.itemPanelKeys)) {\n usedPanelKeys.add(panelKey);\n }\n }\n return usedPanelKeys;\n}\n"],"names":["createDeletePanelGroupSlice","set","get","deletePanelGroup","panelGroupId","panelGroups","panelGroupOrder","group","idIndex","findIndex","id","undefined","Error","panelKeys","Object","values","itemPanelKeys","draft","splice","usedPanelKeys","getUsedPanelKeys","panelKey","has","panels","openDeletePanelGroupDialog","panelGroup","state","deletePanelGroupDialog","panelGroupName","title","closeDeletePanelGroupDialog","Set","add"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AA2BjC,OAAO,MAAMA,2BAA2B,GAMpC,CAACC,GAAG,EAAEC,GAAG,GAAM,CAAA;QACjBC,gBAAgB,EAACC,YAAY,EAAE;YAC7B,MAAM,EAAEC,WAAW,CAAA,EAAEC,eAAe,CAAA,EAAE,GAAGJ,GAAG,EAAE,AAAC;YAC/C,MAAMK,KAAK,GAAGF,WAAW,CAACD,YAAY,CAAC,AAAC;YACxC,MAAMI,OAAO,GAAGF,eAAe,CAACG,SAAS,CAAC,CAACC,EAAE,GAAKA,EAAE,KAAKN,YAAY,CAAC,AAAC;YACvE,IAAIG,KAAK,KAAKI,SAAS,IAAIH,OAAO,KAAK,CAAC,CAAC,EAAE;gBACzC,MAAM,IAAII,KAAK,CAAC,CAAC,YAAY,EAA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C,CAAC;KACL,CAAA,AAAC,CAAC;AAEH,sFAAsF;AACtF,SAASS,gBAAgB,CAACf,WAA2C,EAAe;IAClF,MAAMc,aAAa,GAAG,IAAIY,GAAG,EAAU,AAAC;IACxC,KAAK,MAAMxB,KAAK,IAAIO,MAAM,CAACC,MAAM,CAACV,WAAW,CAAC,CAAE;QAC9C,KAAK,MAAMgB,QAAQ,IAAIP,MAAM,CAACC,MAAM,CAACR,KAAK,CAACS,aAAa,CAAC,CAAE;YACzDG,aAAa,CAACa,GAAG,CAACX,QAAQ,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;IACD,OAAOF,aAAa,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { StateCreator } from 'zustand';
|
|
2
|
+
import { Middleware } from './common';
|
|
3
|
+
import { PanelGroupSlice, PanelGroupItemId } from './panel-group-slice';
|
|
4
|
+
import { PanelSlice } from './panel-slice';
|
|
5
|
+
/**
|
|
6
|
+
* Slice that handles the visual editor state and actions for deleting Panels.
|
|
7
|
+
*/
|
|
8
|
+
export interface DeletePanelSlice {
|
|
9
|
+
/**
|
|
10
|
+
* Delete panels
|
|
11
|
+
*/
|
|
12
|
+
deletePanel: (panelGroupItemId: PanelGroupItemId) => void;
|
|
13
|
+
/**
|
|
14
|
+
* State for the delete panel dialog when it's open, otherwise undefined when it's closed.
|
|
15
|
+
*/
|
|
16
|
+
deletePanelDialog?: DeletePanelDialogState;
|
|
17
|
+
/**
|
|
18
|
+
* Open delete panel dialog
|
|
19
|
+
*/
|
|
20
|
+
openDeletePanelDialog: (panelGroupItemId: PanelGroupItemId) => void;
|
|
21
|
+
/**
|
|
22
|
+
* Close delete panel dialog
|
|
23
|
+
*/
|
|
24
|
+
closeDeletePanelDialog: () => void;
|
|
25
|
+
}
|
|
26
|
+
export interface DeletePanelDialogState {
|
|
27
|
+
panelGroupItemId: PanelGroupItemId;
|
|
28
|
+
panelName: string;
|
|
29
|
+
panelGroupName: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Curried function for creating the PanelDeleteSlice.
|
|
33
|
+
*/
|
|
34
|
+
export declare function createDeletePanelSlice(): StateCreator<DeletePanelSlice & PanelSlice & PanelGroupSlice, Middleware, [
|
|
35
|
+
], DeletePanelSlice>;
|
|
36
|
+
//# sourceMappingURL=delete-panel-slice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-panel-slice.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/delete-panel-slice.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,WAAW,EAAE,CAAC,gBAAgB,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAE1D;;OAEG;IACH,iBAAiB,CAAC,EAAE,sBAAsB,CAAC;IAE3C;;OAEG;IACH,qBAAqB,EAAE,CAAC,gBAAgB,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAEpE;;OAEG;IACH,sBAAsB,EAAE,MAAM,IAAI,CAAC;CACpC;AAED,MAAM,WAAW,sBAAsB;IACrC,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,YAAY,CAEpD,gBAAgB,GAAG,UAAU,GAAG,eAAe,EAC/C,UAAU,EACV;CAAE,EACF,gBAAgB,CACjB,CA6DA"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
/**
|
|
14
|
+
* Curried function for creating the PanelDeleteSlice.
|
|
15
|
+
*/ export function createDeletePanelSlice() {
|
|
16
|
+
// Return the state creator function for Zustand that uses the panels provided as intitial state
|
|
17
|
+
return (set, get)=>({
|
|
18
|
+
deletePanel (panelGroupItemId) {
|
|
19
|
+
set((draft)=>{
|
|
20
|
+
const { panelGroupId , panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;
|
|
21
|
+
const existingGroup = draft.panelGroups[panelGroupId];
|
|
22
|
+
if (existingGroup === undefined) {
|
|
23
|
+
throw new Error(`Missing panel group ${panelGroupId}`);
|
|
24
|
+
}
|
|
25
|
+
const existingLayoutIdx = existingGroup.itemLayouts.findIndex((layout)=>layout.i === panelGroupLayoutId);
|
|
26
|
+
const existingPanelKey = existingGroup.itemPanelKeys[panelGroupLayoutId];
|
|
27
|
+
if (existingLayoutIdx === -1 || existingPanelKey === undefined) {
|
|
28
|
+
throw new Error(`Missing panel group item ${panelGroupLayoutId}`);
|
|
29
|
+
}
|
|
30
|
+
// remove panel from panel group
|
|
31
|
+
existingGroup.itemLayouts.splice(existingLayoutIdx, 1);
|
|
32
|
+
delete existingGroup.itemPanelKeys[panelGroupLayoutId];
|
|
33
|
+
// See if panel key is still used and if not, delete it
|
|
34
|
+
if (isPanelKeyStillUsed(draft.panelGroups, existingPanelKey) === false) {
|
|
35
|
+
delete draft.panels[existingPanelKey];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
openDeletePanelDialog (panelGroupItemId) {
|
|
40
|
+
const { panelGroupId , panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;
|
|
41
|
+
const { panels , panelGroups } = get();
|
|
42
|
+
const panelGroup = panelGroups[panelGroupId];
|
|
43
|
+
if (panelGroup === undefined) {
|
|
44
|
+
throw new Error(`Panel group not found ${panelGroupId}`);
|
|
45
|
+
}
|
|
46
|
+
const panelKey = panelGroup.itemPanelKeys[panelGroupLayoutId];
|
|
47
|
+
if (panelKey === undefined) {
|
|
48
|
+
throw new Error(`Could not find Panel Group item ${panelGroupLayoutId}`);
|
|
49
|
+
}
|
|
50
|
+
const panel = panels[panelKey];
|
|
51
|
+
if (panel === undefined) {
|
|
52
|
+
throw new Error(`Could not find panel ${panelKey}`);
|
|
53
|
+
}
|
|
54
|
+
set((state)=>{
|
|
55
|
+
var _title;
|
|
56
|
+
state.deletePanelDialog = {
|
|
57
|
+
panelGroupItemId: panelGroupItemId,
|
|
58
|
+
panelName: panel.spec.display.name,
|
|
59
|
+
panelGroupName: (_title = panelGroup.title) !== null && _title !== void 0 ? _title : ''
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
closeDeletePanelDialog () {
|
|
64
|
+
set((state)=>{
|
|
65
|
+
state.deletePanelDialog = undefined;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
// Helper function to determine if a panel key is still being used somewhere in Panel Groups
|
|
71
|
+
function isPanelKeyStillUsed(panelGroups, panelKey) {
|
|
72
|
+
for (const group of Object.values(panelGroups)){
|
|
73
|
+
const found = Object.values(group.itemPanelKeys).find((key)=>key === panelKey);
|
|
74
|
+
if (found !== undefined) {
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
//# sourceMappingURL=delete-panel-slice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/context/DashboardProvider/delete-panel-slice.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\nimport { StateCreator } from 'zustand';\nimport { Middleware } from './common';\nimport { PanelGroupSlice, PanelGroupItemId } from './panel-group-slice';\nimport { PanelSlice } from './panel-slice';\n\n/**\n * Slice that handles the visual editor state and actions for deleting Panels.\n */\nexport interface DeletePanelSlice {\n /**\n * Delete panels\n */\n deletePanel: (panelGroupItemId: PanelGroupItemId) => void;\n\n /**\n * State for the delete panel dialog when it's open, otherwise undefined when it's closed.\n */\n deletePanelDialog?: DeletePanelDialogState;\n\n /**\n * Open delete panel dialog\n */\n openDeletePanelDialog: (panelGroupItemId: PanelGroupItemId) => void;\n\n /**\n * Close delete panel dialog\n */\n closeDeletePanelDialog: () => void;\n}\n\nexport interface DeletePanelDialogState {\n panelGroupItemId: PanelGroupItemId;\n panelName: string;\n panelGroupName: string;\n}\n\n/**\n * Curried function for creating the PanelDeleteSlice.\n */\nexport function createDeletePanelSlice(): StateCreator<\n // Actions in here need to modify both Panels and Panel Groups state\n DeletePanelSlice & PanelSlice & PanelGroupSlice,\n Middleware,\n [],\n DeletePanelSlice\n> {\n // Return the state creator function for Zustand that uses the panels provided as intitial state\n return (set, get) => ({\n deletePanel(panelGroupItemId: PanelGroupItemId) {\n set((draft) => {\n const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;\n const existingGroup = draft.panelGroups[panelGroupId];\n if (existingGroup === undefined) {\n throw new Error(`Missing panel group ${panelGroupId}`);\n }\n const existingLayoutIdx = existingGroup.itemLayouts.findIndex((layout) => layout.i === panelGroupLayoutId);\n const existingPanelKey = existingGroup.itemPanelKeys[panelGroupLayoutId];\n if (existingLayoutIdx === -1 || existingPanelKey === undefined) {\n throw new Error(`Missing panel group item ${panelGroupLayoutId}`);\n }\n\n // remove panel from panel group\n existingGroup.itemLayouts.splice(existingLayoutIdx, 1);\n delete existingGroup.itemPanelKeys[panelGroupLayoutId];\n\n // See if panel key is still used and if not, delete it\n if (isPanelKeyStillUsed(draft.panelGroups, existingPanelKey) === false) {\n delete draft.panels[existingPanelKey];\n }\n });\n },\n\n openDeletePanelDialog(panelGroupItemId: PanelGroupItemId) {\n const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;\n\n const { panels, panelGroups } = get();\n const panelGroup = panelGroups[panelGroupId];\n if (panelGroup === undefined) {\n throw new Error(`Panel group not found ${panelGroupId}`);\n }\n\n const panelKey = panelGroup.itemPanelKeys[panelGroupLayoutId];\n if (panelKey === undefined) {\n throw new Error(`Could not find Panel Group item ${panelGroupLayoutId}`);\n }\n\n const panel = panels[panelKey];\n if (panel === undefined) {\n throw new Error(`Could not find panel ${panelKey}`);\n }\n\n set((state) => {\n state.deletePanelDialog = {\n panelGroupItemId: panelGroupItemId,\n panelName: panel.spec.display.name,\n panelGroupName: panelGroup.title ?? '',\n };\n });\n },\n\n closeDeletePanelDialog() {\n set((state) => {\n state.deletePanelDialog = undefined;\n });\n },\n });\n}\n\n// Helper function to determine if a panel key is still being used somewhere in Panel Groups\nfunction isPanelKeyStillUsed(panelGroups: PanelGroupSlice['panelGroups'], panelKey: string) {\n for (const group of Object.values(panelGroups)) {\n const found = Object.values(group.itemPanelKeys).find((key) => key === panelKey);\n if (found !== undefined) {\n return true;\n }\n }\n return false;\n}\n"],"names":["createDeletePanelSlice","set","get","deletePanel","panelGroupItemId","draft","panelGroupId","panelGroupItemLayoutId","panelGroupLayoutId","existingGroup","panelGroups","undefined","Error","existingLayoutIdx","itemLayouts","findIndex","layout","i","existingPanelKey","itemPanelKeys","splice","isPanelKeyStillUsed","panels","openDeletePanelDialog","panelGroup","panelKey","panel","state","deletePanelDialog","panelName","spec","display","name","panelGroupName","title","closeDeletePanelDialog","group","Object","values","found","find","key"],"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;AAsCjC;;CAEC,GACD,OAAO,SAASA,sBAAsB,GAMpC;IACA,gGAAgG;IAChG,OAAO,CAACC,GAAG,EAAEC,GAAG,GAAM,CAAA;YACpBC,WAAW,EAACC,gBAAkC,EAAE;gBAC9CH,GAAG,CAAC,CAACI,KAAK,GAAK;oBACb,MAAM,EAAEC,YAAY,CAAA,EAAEC,sBAAsB,EAAEC,kBAAkB,CAAA,EAAE,GAAGJ,gBAAgB,AAAC;oBACtF,MAAMK,aAAa,GAAGJ,KAAK,CAACK,WAAW,CAACJ,YAAY,CAAC,AAAC;oBACtD,IAAIG,aAAa,KAAKE,SAAS,EAAE;wBAC/B,MAAM,IAAIC,KAAK,CAAC,CAAC,oBAAoB,EAAEN,YAAY,CAAC,CAAC,CAAC,CAAC;oBACzD,CAAC;oBACD,MAAMO,iBAAiB,GAAGJ,aAAa,CAACK,WAAW,CAACC,SAAS,CAAC,CAACC,MAAM,GAAKA,MAAM,CAACC,CAAC,KAAKT,kBAAkB,CAAC,AAAC;oBAC3G,MAAMU,gBAAgB,GAAGT,aAAa,CAACU,aAAa,CAACX,kBAAkB,CAAC,AAAC;oBACzE,IAAIK,iBAAiB,KAAK,CAAC,CAAC,IAAIK,gBAAgB,KAAKP,SAAS,EAAE;wBAC9D,MAAM,IAAIC,KAAK,CAAC,CAAC,yBAAyB,EAAEJ,kBAAkB,CAAC,CAAC,CAAC,CA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EDxB,GAAG,CAAC,CAAC0B,KAAK,GAAK;wBAIKH,MAAgB;oBAHlCG,KAAK,CAACC,iBAAiB,GAAG;wBACxBxB,gBAAgB,EAAEA,gBAAgB;wBAClCyB,SAAS,EAAEH,KAAK,CAACI,IAAI,CAACC,OAAO,CAACC,IAAI;wBAClCC,cAAc,EAAET,CAAAA,MAAgB,GAAhBA,UAAU,CAACU,KAAK,cAAhBV,MAAgB,cAAhBA,MAAgB,GAAI,EAAE;qBACvC,CAAC;gBACJ,CAAC,CAAC,CAAC;YACL,CAAC;YAEDW,sBAAsB,IAAG;gBACvBlC,GAAG,CAAC,CAAC0B,KAAK,GAAK;oBACbA,KAAK,CAACC,iBAAiB,GAAGjB,SAAS,CAAC;gBACtC,CAAC,CAAC,CAAC;YACL,CAAC;SACF,CAAA,AAAC,CAAC;AACL,CAAC;AAED,4FAA4F;AAC5F,SAASU,mBAAmB,CAACX,WAA2C,EAAEe,QAAgB,EAAE;IAC1F,KAAK,MAAMW,KAAK,IAAIC,MAAM,CAACC,MAAM,CAAC5B,WAAW,CAAC,CAAE;QAC9C,MAAM6B,KAAK,GAAGF,MAAM,CAACC,MAAM,CAACF,KAAK,CAACjB,aAAa,CAAC,CAACqB,IAAI,CAAC,CAACC,GAAG,GAAKA,GAAG,KAAKhB,QAAQ,CAAC,AAAC;QACjF,IAAIc,KAAK,KAAK5B,SAAS,EAAE;YACvB,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
export * from './dashboard-provider-api';
|
|
2
2
|
export * from './DashboardProvider';
|
|
3
|
+
export type { PanelGroupId, PanelGroupDefinition, PanelGroupItemId, PanelGroupItemLayoutId as PanelGroupLayoutId, } from './panel-group-slice';
|
|
4
|
+
export type { PanelGroupEditor, PanelGroupEditorValues } from './panel-group-editor-slice';
|
|
5
|
+
export type { DeletePanelDialogState } from './delete-panel-slice';
|
|
3
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/index.ts"],"names":[],"mappings":"AAaA,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/index.ts"],"names":[],"mappings":"AAaA,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,YAAY,EACV,YAAY,EACZ,oBAAoB,EACpB,gBAAgB,EAChB,sBAAsB,IAAI,kBAAkB,GAC7C,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAC3F,YAAY,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/context/DashboardProvider/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-provider-api';\nexport * from './DashboardProvider';\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,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/context/DashboardProvider/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-provider-api';\nexport * from './DashboardProvider';\nexport type {\n PanelGroupId,\n PanelGroupDefinition,\n PanelGroupItemId,\n PanelGroupItemLayoutId as PanelGroupLayoutId,\n} from './panel-group-slice';\nexport type { PanelGroupEditor, PanelGroupEditorValues } from './panel-group-editor-slice';\nexport type { DeletePanelDialogState } from './delete-panel-slice';\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,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { UnknownSpec } from '@perses-dev/core';
|
|
2
|
+
import { StateCreator } from 'zustand';
|
|
3
|
+
import { Middleware } from './common';
|
|
4
|
+
import { PanelGroupSlice, PanelGroupItemId, PanelGroupId } from './panel-group-slice';
|
|
5
|
+
import { PanelSlice } from './panel-slice';
|
|
6
|
+
/**
|
|
7
|
+
* Slice that handles the visual editor state and actions for adding or editing Panels.
|
|
8
|
+
*/
|
|
9
|
+
export interface PanelEditorSlice {
|
|
10
|
+
/**
|
|
11
|
+
* State for the panel editor when its open, otherwise undefined when it's closed.
|
|
12
|
+
*/
|
|
13
|
+
panelEditor?: PanelEditorState;
|
|
14
|
+
/**
|
|
15
|
+
* Opens the editor for editing an existing panel by providing its layout coordinates.
|
|
16
|
+
*/
|
|
17
|
+
openEditPanel: (panelGroupItemId: PanelGroupItemId) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Opens the editor for adding a new Panel to a panel group.
|
|
20
|
+
*/
|
|
21
|
+
openAddPanel: (panelGroupId?: PanelGroupId) => void;
|
|
22
|
+
}
|
|
23
|
+
export interface PanelEditorState {
|
|
24
|
+
/**
|
|
25
|
+
* Whether we're adding a new panel, or editing an existing panel.
|
|
26
|
+
*/
|
|
27
|
+
mode: 'Add' | 'Edit';
|
|
28
|
+
/**
|
|
29
|
+
* Initial values for the things that can be edited about a panel.
|
|
30
|
+
*/
|
|
31
|
+
initialValues: PanelEditorValues;
|
|
32
|
+
/**
|
|
33
|
+
* Applies changes, but doesn't close the editor.
|
|
34
|
+
*/
|
|
35
|
+
applyChanges: (next: PanelEditorValues) => void;
|
|
36
|
+
/**
|
|
37
|
+
* Close the editor.
|
|
38
|
+
*/
|
|
39
|
+
close: () => void;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Panel values that can be edited in the panel editor.
|
|
43
|
+
*/
|
|
44
|
+
export interface PanelEditorValues {
|
|
45
|
+
name: string;
|
|
46
|
+
description: string;
|
|
47
|
+
groupId: PanelGroupId;
|
|
48
|
+
kind: string;
|
|
49
|
+
spec: UnknownSpec;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Curried function for creating the PanelEditorSlice.
|
|
53
|
+
*/
|
|
54
|
+
export declare function createPanelEditorSlice(): StateCreator<PanelEditorSlice & PanelSlice & PanelGroupSlice, Middleware, [
|
|
55
|
+
], PanelEditorSlice>;
|
|
56
|
+
//# sourceMappingURL=panel-editor-slice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"panel-editor-slice.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/panel-editor-slice.ts"],"names":[],"mappings":"AAaA,OAAO,EAAmB,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAAc,UAAU,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,YAAY,EAGb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAE/B;;OAEG;IACH,aAAa,EAAE,CAAC,gBAAgB,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAE5D;;OAEG;IACH,YAAY,EAAE,CAAC,YAAY,CAAC,EAAE,YAAY,KAAK,IAAI,CAAC;CACrD;AAED,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,IAAI,EAAE,KAAK,GAAG,MAAM,CAAC;IAErB;;OAEG;IACH,aAAa,EAAE,iBAAiB,CAAC;IAEjC;;OAEG;IACH,YAAY,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAEhD;;OAEG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,YAAY,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,WAAW,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,YAAY,CAEpD,gBAAgB,GAAG,UAAU,GAAG,eAAe,EAC/C,UAAU,EACV;CAAE,EACF,gBAAgB,CACjB,CA+IA"}
|
|
@@ -0,0 +1,178 @@
|
|
|
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 { removeWhiteSpacesAndSpecialCharacters } from '../../utils/functions';
|
|
14
|
+
import { generateId } from './common';
|
|
15
|
+
/**
|
|
16
|
+
* Curried function for creating the PanelEditorSlice.
|
|
17
|
+
*/ export function createPanelEditorSlice() {
|
|
18
|
+
// Return the state creator function for Zustand that uses the panels provided as intitial state
|
|
19
|
+
return (set, get)=>{
|
|
20
|
+
return {
|
|
21
|
+
panelEditor: undefined,
|
|
22
|
+
openEditPanel (panelGroupItemId) {
|
|
23
|
+
var ref;
|
|
24
|
+
const { panels , panelGroups } = get();
|
|
25
|
+
// Figure out the panel key at that location
|
|
26
|
+
const { panelGroupId , panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;
|
|
27
|
+
const panelKey = (ref = panelGroups[panelGroupId]) === null || ref === void 0 ? void 0 : ref.itemPanelKeys[panelGroupLayoutId];
|
|
28
|
+
if (panelKey === undefined) {
|
|
29
|
+
throw new Error(`Could not find Panel Group item ${panelGroupItemId}`);
|
|
30
|
+
}
|
|
31
|
+
// Find the panel to edit
|
|
32
|
+
const panelToEdit = panels[panelKey];
|
|
33
|
+
if (panelToEdit === undefined) {
|
|
34
|
+
throw new Error(`Cannot find Panel with key '${panelKey}'`);
|
|
35
|
+
}
|
|
36
|
+
var _description;
|
|
37
|
+
const editorState = {
|
|
38
|
+
mode: 'Edit',
|
|
39
|
+
initialValues: {
|
|
40
|
+
name: panelToEdit.spec.display.name,
|
|
41
|
+
description: (_description = panelToEdit.spec.display.description) !== null && _description !== void 0 ? _description : '',
|
|
42
|
+
groupId: panelGroupItemId.panelGroupId,
|
|
43
|
+
kind: panelToEdit.spec.plugin.kind,
|
|
44
|
+
spec: panelToEdit.spec.plugin.spec
|
|
45
|
+
},
|
|
46
|
+
applyChanges: (next)=>{
|
|
47
|
+
const panelDefinititon = createPanelDefinitionFromEditorValues(next);
|
|
48
|
+
set((draft)=>{
|
|
49
|
+
draft.panels[panelKey] = panelDefinititon;
|
|
50
|
+
// If the panel didn't change groups, nothing else to do
|
|
51
|
+
if (next.groupId === panelGroupId) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
// Move panel to the new group
|
|
55
|
+
const existingGroup = draft.panelGroups[panelGroupId];
|
|
56
|
+
if (existingGroup === undefined) {
|
|
57
|
+
throw new Error(`Missing panel group ${panelGroupId}`);
|
|
58
|
+
}
|
|
59
|
+
const existingLayoutIdx = existingGroup.itemLayouts.findIndex((layout)=>layout.i === panelGroupLayoutId);
|
|
60
|
+
const existingLayout = existingGroup.itemLayouts[existingLayoutIdx];
|
|
61
|
+
const existingPanelKey = existingGroup.itemPanelKeys[panelGroupLayoutId];
|
|
62
|
+
if (existingLayoutIdx === -1 || existingLayout === undefined || existingPanelKey === undefined) {
|
|
63
|
+
throw new Error(`Missing panel group item ${panelGroupLayoutId}`);
|
|
64
|
+
}
|
|
65
|
+
// Remove item from the old group
|
|
66
|
+
existingGroup.itemLayouts.splice(existingLayoutIdx, 1);
|
|
67
|
+
delete existingGroup.itemPanelKeys[panelGroupLayoutId];
|
|
68
|
+
// Add item to the end of the new group
|
|
69
|
+
const newGroup = draft.panelGroups[next.groupId];
|
|
70
|
+
if (newGroup === undefined) {
|
|
71
|
+
throw new Error(`Could not find new group ${next.groupId}`);
|
|
72
|
+
}
|
|
73
|
+
newGroup.itemLayouts.push({
|
|
74
|
+
i: existingLayout.i,
|
|
75
|
+
x: 0,
|
|
76
|
+
y: getYForNewRow(newGroup),
|
|
77
|
+
w: existingLayout.w,
|
|
78
|
+
h: existingLayout.h
|
|
79
|
+
});
|
|
80
|
+
newGroup.itemPanelKeys[existingLayout.i] = existingPanelKey;
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
close: ()=>{
|
|
84
|
+
set((state)=>{
|
|
85
|
+
state.panelEditor = undefined;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
// Open the editor with the new state
|
|
90
|
+
set((state)=>{
|
|
91
|
+
state.panelEditor = editorState;
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
openAddPanel (panelGroupId) {
|
|
95
|
+
// If a panel group isn't supplied, add to the first group
|
|
96
|
+
if (panelGroupId === undefined) {
|
|
97
|
+
const firstGroupId = get().panelGroupOrder[0];
|
|
98
|
+
if (firstGroupId === undefined) {
|
|
99
|
+
throw new Error('No panel groups to add a panel to');
|
|
100
|
+
}
|
|
101
|
+
panelGroupId = firstGroupId;
|
|
102
|
+
}
|
|
103
|
+
const editorState = {
|
|
104
|
+
mode: 'Add',
|
|
105
|
+
initialValues: {
|
|
106
|
+
name: '',
|
|
107
|
+
description: '',
|
|
108
|
+
groupId: panelGroupId,
|
|
109
|
+
// TODO: If we knew what plugins were available (and how to create the initial spec), we might be able to
|
|
110
|
+
// set a smarter default here?
|
|
111
|
+
kind: '',
|
|
112
|
+
spec: {}
|
|
113
|
+
},
|
|
114
|
+
applyChanges: (next)=>{
|
|
115
|
+
const panelDef = createPanelDefinitionFromEditorValues(next);
|
|
116
|
+
const panelKey = removeWhiteSpacesAndSpecialCharacters(next.name);
|
|
117
|
+
set((draft)=>{
|
|
118
|
+
// Add a panel
|
|
119
|
+
draft.panels[panelKey] = panelDef;
|
|
120
|
+
// Also add a panel group item referencing the panel
|
|
121
|
+
const group = draft.panelGroups[next.groupId];
|
|
122
|
+
if (group === undefined) {
|
|
123
|
+
throw new Error(`Missing panel group ${next.groupId}`);
|
|
124
|
+
}
|
|
125
|
+
const layout = {
|
|
126
|
+
i: generateId().toString(),
|
|
127
|
+
x: 0,
|
|
128
|
+
y: getYForNewRow(group),
|
|
129
|
+
w: 12,
|
|
130
|
+
h: 6
|
|
131
|
+
};
|
|
132
|
+
group.itemLayouts.push(layout);
|
|
133
|
+
group.itemPanelKeys[layout.i] = panelKey;
|
|
134
|
+
});
|
|
135
|
+
},
|
|
136
|
+
close: ()=>{
|
|
137
|
+
set((state)=>{
|
|
138
|
+
state.panelEditor = undefined;
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
// Open the editor with the new state
|
|
143
|
+
set((state)=>{
|
|
144
|
+
state.panelEditor = editorState;
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
// Helper to create PanelDefinitions when saving
|
|
151
|
+
function createPanelDefinitionFromEditorValues(editorValues) {
|
|
152
|
+
return {
|
|
153
|
+
kind: 'Panel',
|
|
154
|
+
spec: {
|
|
155
|
+
display: {
|
|
156
|
+
name: editorValues.name,
|
|
157
|
+
description: editorValues.description !== '' ? editorValues.description : undefined
|
|
158
|
+
},
|
|
159
|
+
plugin: {
|
|
160
|
+
kind: editorValues.kind,
|
|
161
|
+
spec: editorValues.spec
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
// Given a PanelGroup, will find the Y coordinate for adding a new row to the grid, taking into account the items present
|
|
167
|
+
function getYForNewRow(group) {
|
|
168
|
+
let newRowY = 0;
|
|
169
|
+
for (const layout of group.itemLayouts){
|
|
170
|
+
const itemMaxY = layout.y + layout.h;
|
|
171
|
+
if (itemMaxY > newRowY) {
|
|
172
|
+
newRowY = itemMaxY;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return newRowY;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
//# sourceMappingURL=panel-editor-slice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/context/DashboardProvider/panel-editor-slice.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\nimport { PanelDefinition, UnknownSpec } from '@perses-dev/core';\nimport { StateCreator } from 'zustand';\nimport { removeWhiteSpacesAndSpecialCharacters } from '../../utils/functions';\nimport { generateId, Middleware } from './common';\nimport {\n PanelGroupSlice,\n PanelGroupItemId,\n PanelGroupId,\n PanelGroupDefinition,\n PanelGroupItemLayout,\n} from './panel-group-slice';\nimport { PanelSlice } from './panel-slice';\n\n/**\n * Slice that handles the visual editor state and actions for adding or editing Panels.\n */\nexport interface PanelEditorSlice {\n /**\n * State for the panel editor when its open, otherwise undefined when it's closed.\n */\n panelEditor?: PanelEditorState;\n\n /**\n * Opens the editor for editing an existing panel by providing its layout coordinates.\n */\n openEditPanel: (panelGroupItemId: PanelGroupItemId) => void;\n\n /**\n * Opens the editor for adding a new Panel to a panel group.\n */\n openAddPanel: (panelGroupId?: PanelGroupId) => void;\n}\n\nexport interface PanelEditorState {\n /**\n * Whether we're adding a new panel, or editing an existing panel.\n */\n mode: 'Add' | 'Edit';\n\n /**\n * Initial values for the things that can be edited about a panel.\n */\n initialValues: PanelEditorValues;\n\n /**\n * Applies changes, but doesn't close the editor.\n */\n applyChanges: (next: PanelEditorValues) => void;\n\n /**\n * Close the editor.\n */\n close: () => void;\n}\n\n/**\n * Panel values that can be edited in the panel editor.\n */\nexport interface PanelEditorValues {\n name: string;\n description: string;\n groupId: PanelGroupId;\n kind: string;\n spec: UnknownSpec;\n}\n\n/**\n * Curried function for creating the PanelEditorSlice.\n */\nexport function createPanelEditorSlice(): StateCreator<\n // Actions in here need to modify both Panels and Panel Groups state\n PanelEditorSlice & PanelSlice & PanelGroupSlice,\n Middleware,\n [],\n PanelEditorSlice\n> {\n // Return the state creator function for Zustand that uses the panels provided as intitial state\n return (set, get) => ({\n panelEditor: undefined,\n\n openEditPanel(panelGroupItemId) {\n const { panels, panelGroups } = get();\n\n // Figure out the panel key at that location\n const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;\n const panelKey = panelGroups[panelGroupId]?.itemPanelKeys[panelGroupLayoutId];\n if (panelKey === undefined) {\n throw new Error(`Could not find Panel Group item ${panelGroupItemId}`);\n }\n\n // Find the panel to edit\n const panelToEdit = panels[panelKey];\n if (panelToEdit === undefined) {\n throw new Error(`Cannot find Panel with key '${panelKey}'`);\n }\n\n const editorState: PanelEditorState = {\n mode: 'Edit',\n initialValues: {\n name: panelToEdit.spec.display.name,\n description: panelToEdit.spec.display.description ?? '',\n groupId: panelGroupItemId.panelGroupId,\n kind: panelToEdit.spec.plugin.kind,\n spec: panelToEdit.spec.plugin.spec,\n },\n applyChanges: (next) => {\n const panelDefinititon = createPanelDefinitionFromEditorValues(next);\n set((draft) => {\n draft.panels[panelKey] = panelDefinititon;\n\n // If the panel didn't change groups, nothing else to do\n if (next.groupId === panelGroupId) {\n return;\n }\n\n // Move panel to the new group\n const existingGroup = draft.panelGroups[panelGroupId];\n if (existingGroup === undefined) {\n throw new Error(`Missing panel group ${panelGroupId}`);\n }\n\n const existingLayoutIdx = existingGroup.itemLayouts.findIndex((layout) => layout.i === panelGroupLayoutId);\n const existingLayout = existingGroup.itemLayouts[existingLayoutIdx];\n const existingPanelKey = existingGroup.itemPanelKeys[panelGroupLayoutId];\n if (existingLayoutIdx === -1 || existingLayout === undefined || existingPanelKey === undefined) {\n throw new Error(`Missing panel group item ${panelGroupLayoutId}`);\n }\n\n // Remove item from the old group\n existingGroup.itemLayouts.splice(existingLayoutIdx, 1);\n delete existingGroup.itemPanelKeys[panelGroupLayoutId];\n\n // Add item to the end of the new group\n const newGroup = draft.panelGroups[next.groupId];\n if (newGroup === undefined) {\n throw new Error(`Could not find new group ${next.groupId}`);\n }\n\n newGroup.itemLayouts.push({\n i: existingLayout.i,\n x: 0,\n y: getYForNewRow(newGroup),\n w: existingLayout.w,\n h: existingLayout.h,\n });\n newGroup.itemPanelKeys[existingLayout.i] = existingPanelKey;\n });\n },\n close: () => {\n set((state) => {\n state.panelEditor = undefined;\n });\n },\n };\n\n // Open the editor with the new state\n set((state) => {\n state.panelEditor = editorState;\n });\n },\n\n openAddPanel(panelGroupId) {\n // If a panel group isn't supplied, add to the first group\n if (panelGroupId === undefined) {\n const firstGroupId = get().panelGroupOrder[0];\n if (firstGroupId === undefined) {\n throw new Error('No panel groups to add a panel to');\n }\n panelGroupId = firstGroupId;\n }\n\n const editorState: PanelEditorState = {\n mode: 'Add',\n initialValues: {\n name: '',\n description: '',\n groupId: panelGroupId,\n // TODO: If we knew what plugins were available (and how to create the initial spec), we might be able to\n // set a smarter default here?\n kind: '',\n spec: {},\n },\n applyChanges: (next) => {\n const panelDef = createPanelDefinitionFromEditorValues(next);\n const panelKey = removeWhiteSpacesAndSpecialCharacters(next.name);\n set((draft) => {\n // Add a panel\n draft.panels[panelKey] = panelDef;\n\n // Also add a panel group item referencing the panel\n const group = draft.panelGroups[next.groupId];\n if (group === undefined) {\n throw new Error(`Missing panel group ${next.groupId}`);\n }\n const layout: PanelGroupItemLayout = {\n i: generateId().toString(),\n x: 0,\n y: getYForNewRow(group),\n w: 12,\n h: 6,\n };\n group.itemLayouts.push(layout);\n group.itemPanelKeys[layout.i] = panelKey;\n });\n },\n close: () => {\n set((state) => {\n state.panelEditor = undefined;\n });\n },\n };\n\n // Open the editor with the new state\n set((state) => {\n state.panelEditor = editorState;\n });\n },\n });\n}\n\n// Helper to create PanelDefinitions when saving\nfunction createPanelDefinitionFromEditorValues(editorValues: PanelEditorValues): PanelDefinition {\n return {\n kind: 'Panel',\n spec: {\n display: {\n name: editorValues.name,\n description: editorValues.description !== '' ? editorValues.description : undefined,\n },\n plugin: {\n kind: editorValues.kind,\n spec: editorValues.spec,\n },\n },\n };\n}\n\n// Given a PanelGroup, will find the Y coordinate for adding a new row to the grid, taking into account the items present\nfunction getYForNewRow(group: PanelGroupDefinition) {\n let newRowY = 0;\n for (const layout of group.itemLayouts) {\n const itemMaxY = layout.y + layout.h;\n if (itemMaxY > newRowY) {\n newRowY = itemMaxY;\n }\n }\n return newRowY;\n}\n"],"names":["removeWhiteSpacesAndSpecialCharacters","generateId","createPanelEditorSlice","set","get","panelEditor","undefined","openEditPanel","panelGroupItemId","panelGroups","panels","panelGroupId","panelGroupItemLayoutId","panelGroupLayoutId","panelKey","itemPanelKeys","Error","panelToEdit","editorState","mode","initialValues","name","spec","display","description","groupId","kind","plugin","applyChanges","next","panelDefinititon","createPanelDefinitionFromEditorValues","draft","existingGroup","existingLayoutIdx","itemLayouts","findIndex","layout","i","existingLayout","existingPanelKey","splice","newGroup","push","x","y","getYForNewRow","w","h","close","state","openAddPanel","firstGroupId","panelGroupOrder","panelDef","group","toString","editorValues","newRowY","itemMaxY"],"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;AAIjC,SAASA,qCAAqC,QAAQ,uBAAuB,CAAC;AAC9E,SAASC,UAAU,QAAoB,UAAU,CAAC;AA+DlD;;CAEC,GACD,OAAO,SAASC,sBAAsB,GAMpC;IACA,gGAAgG;IAChG,OAAO,CAACC,GAAG,EAAEC,GAAG;QAAM,OAAA;YACpBC,WAAW,EAAEC,SAAS;YAEtBC,aAAa,EAACC,gBAAgB,EAAE;oBAKbC,GAAyB;gBAJ1C,MAAM,EAAEC,MAAM,CAAA,EAAED,WAAW,CAAA,EAAE,GAAGL,GAAG,EAAE,AAAC;gBAEtC,4CAA4C;gBAC5C,MAA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AC,CAAC+C,KAAK,GAAK;oBACbA,KAAK,CAAC7C,WAAW,GAAGa,WAAW,CAAC;gBAClC,CAAC,CAAC,CAAC;YACL,CAAC;SACF,CAAA;KAAC,CAAC;AACL,CAAC;AAED,gDAAgD;AAChD,SAASa,qCAAqC,CAAC0B,YAA+B,EAAmB;IAC/F,OAAO;QACL/B,IAAI,EAAE,OAAO;QACbJ,IAAI,EAAE;YACJC,OAAO,EAAE;gBACPF,IAAI,EAAEoC,YAAY,CAACpC,IAAI;gBACvBG,WAAW,EAAEiC,YAAY,CAACjC,WAAW,KAAK,EAAE,GAAGiC,YAAY,CAACjC,WAAW,GAAGlB,SAAS;aACpF;YACDqB,MAAM,EAAE;gBACND,IAAI,EAAE+B,YAAY,CAAC/B,IAAI;gBACvBJ,IAAI,EAAEmC,YAAY,CAACnC,IAAI;aACxB;SACF;KACF,CAAC;AACJ,CAAC;AAED,yHAAyH;AACzH,SAASwB,aAAa,CAACS,KAA2B,EAAE;IAClD,IAAIG,OAAO,GAAG,CAAC,AAAC;IAChB,KAAK,MAAMrB,MAAM,IAAIkB,KAAK,CAACpB,WAAW,CAAE;QACtC,MAAMwB,QAAQ,GAAGtB,MAAM,CAACQ,CAAC,GAAGR,MAAM,CAACW,CAAC,AAAC;QACrC,IAAIW,QAAQ,GAAGD,OAAO,EAAE;YACtBA,OAAO,GAAGC,QAAQ,CAAC;QACrB,CAAC;IACH,CAAC;IACD,OAAOD,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { StateCreator } from 'zustand';
|
|
2
|
+
import { Middleware } from './common';
|
|
3
|
+
import { PanelGroupSlice, PanelGroupId } from './panel-group-slice';
|
|
4
|
+
export interface PanelGroupEditor {
|
|
5
|
+
mode: 'Add' | 'Edit';
|
|
6
|
+
initialValues: PanelGroupEditorValues;
|
|
7
|
+
applyChanges: (next: PanelGroupEditorValues) => void;
|
|
8
|
+
close: () => void;
|
|
9
|
+
}
|
|
10
|
+
export interface PanelGroupEditorValues {
|
|
11
|
+
title: string;
|
|
12
|
+
isCollapsed: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Slice that handles the visual editor state and related actions for adding or editing Panel Groups.
|
|
16
|
+
*/
|
|
17
|
+
export interface PanelGroupEditorSlice {
|
|
18
|
+
/**
|
|
19
|
+
* State that's present when the panel group editor is open.
|
|
20
|
+
*/
|
|
21
|
+
panelGroupEditor?: PanelGroupEditor;
|
|
22
|
+
/**
|
|
23
|
+
* Opens the panel group editor to add a new panel group.
|
|
24
|
+
*/
|
|
25
|
+
openAddPanelGroup: () => void;
|
|
26
|
+
/**
|
|
27
|
+
* Opens the panel group editor to edit an existing panel group.
|
|
28
|
+
*/
|
|
29
|
+
openEditPanelGroup: (panelGroupId: PanelGroupId) => void;
|
|
30
|
+
}
|
|
31
|
+
export declare const createPanelGroupEditorSlice: StateCreator<PanelGroupEditorSlice & PanelGroupSlice, Middleware, [
|
|
32
|
+
], PanelGroupEditorSlice>;
|
|
33
|
+
//# sourceMappingURL=panel-group-editor-slice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"panel-group-editor-slice.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/panel-group-editor-slice.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAc,UAAU,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,eAAe,EAAwB,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAE1F,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,KAAK,GAAG,MAAM,CAAC;IACrB,aAAa,EAAE,sBAAsB,CAAC;IACtC,YAAY,EAAE,CAAC,IAAI,EAAE,sBAAsB,KAAK,IAAI,CAAC;IACrD,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,OAAO,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IAEpC;;OAEG;IACH,iBAAiB,EAAE,MAAM,IAAI,CAAC;IAE9B;;OAEG;IACH,kBAAkB,EAAE,CAAC,YAAY,EAAE,YAAY,KAAK,IAAI,CAAC;CAC1D;AAED,eAAO,MAAM,2BAA2B,EAAE,YAAY,CAEpD,qBAAqB,GAAG,eAAe,EACvC,UAAU,EACV;CAAE,EACF,qBAAqB,CAwErB,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
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 { generateId } from './common';
|
|
14
|
+
export const createPanelGroupEditorSlice = (set, get)=>({
|
|
15
|
+
panelGroupEditor: undefined,
|
|
16
|
+
openAddPanelGroup: ()=>{
|
|
17
|
+
// Create the editor state
|
|
18
|
+
const editor = {
|
|
19
|
+
mode: 'Add',
|
|
20
|
+
initialValues: {
|
|
21
|
+
title: '',
|
|
22
|
+
isCollapsed: false
|
|
23
|
+
},
|
|
24
|
+
applyChanges (next) {
|
|
25
|
+
const newGroup = {
|
|
26
|
+
id: generateId(),
|
|
27
|
+
itemLayouts: [],
|
|
28
|
+
itemPanelKeys: {},
|
|
29
|
+
...next
|
|
30
|
+
};
|
|
31
|
+
set((draft)=>{
|
|
32
|
+
draft.panelGroups[newGroup.id] = newGroup;
|
|
33
|
+
draft.panelGroupOrder.unshift(newGroup.id);
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
close () {
|
|
37
|
+
set((draft)=>{
|
|
38
|
+
draft.panelGroupEditor = undefined;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
// Open the editor
|
|
43
|
+
set((draft)=>{
|
|
44
|
+
draft.panelGroupEditor = editor;
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
openEditPanelGroup: (panelGroupId)=>{
|
|
48
|
+
const existingGroup = get().panelGroups[panelGroupId];
|
|
49
|
+
if (existingGroup === undefined) {
|
|
50
|
+
throw new Error(`Panel group with Id ${panelGroupId} does not exist`);
|
|
51
|
+
}
|
|
52
|
+
var _title;
|
|
53
|
+
// Create the editor state
|
|
54
|
+
const editor = {
|
|
55
|
+
mode: 'Edit',
|
|
56
|
+
initialValues: {
|
|
57
|
+
title: (_title = existingGroup.title) !== null && _title !== void 0 ? _title : '',
|
|
58
|
+
isCollapsed: existingGroup.isCollapsed
|
|
59
|
+
},
|
|
60
|
+
applyChanges (next) {
|
|
61
|
+
set((draft)=>{
|
|
62
|
+
const group = draft.panelGroups[panelGroupId];
|
|
63
|
+
if (group === undefined) {
|
|
64
|
+
throw new Error(`Panel group with Id ${panelGroupId} does not exist`);
|
|
65
|
+
}
|
|
66
|
+
group.title = next.title;
|
|
67
|
+
group.isCollapsed = next.isCollapsed;
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
close () {
|
|
71
|
+
set((draft)=>{
|
|
72
|
+
draft.panelGroupEditor = undefined;
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
// Open the editor
|
|
77
|
+
set((draft)=>{
|
|
78
|
+
draft.panelGroupEditor = editor;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
//# sourceMappingURL=panel-group-editor-slice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/context/DashboardProvider/panel-group-editor-slice.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\nimport { StateCreator } from 'zustand';\nimport { generateId, Middleware } from './common';\nimport { PanelGroupSlice, PanelGroupDefinition, PanelGroupId } from './panel-group-slice';\n\nexport interface PanelGroupEditor {\n mode: 'Add' | 'Edit';\n initialValues: PanelGroupEditorValues;\n applyChanges: (next: PanelGroupEditorValues) => void;\n close: () => void;\n}\n\nexport interface PanelGroupEditorValues {\n title: string;\n isCollapsed: boolean;\n}\n\n/**\n * Slice that handles the visual editor state and related actions for adding or editing Panel Groups.\n */\nexport interface PanelGroupEditorSlice {\n /**\n * State that's present when the panel group editor is open.\n */\n panelGroupEditor?: PanelGroupEditor;\n\n /**\n * Opens the panel group editor to add a new panel group.\n */\n openAddPanelGroup: () => void;\n\n /**\n * Opens the panel group editor to edit an existing panel group.\n */\n openEditPanelGroup: (panelGroupId: PanelGroupId) => void;\n}\n\nexport const createPanelGroupEditorSlice: StateCreator<\n // Actions in here need to modify Panel Group state\n PanelGroupEditorSlice & PanelGroupSlice,\n Middleware,\n [],\n PanelGroupEditorSlice\n> = (set, get) => ({\n panelGroupEditor: undefined,\n\n openAddPanelGroup: () => {\n // Create the editor state\n const editor: PanelGroupEditor = {\n mode: 'Add',\n initialValues: {\n title: '',\n isCollapsed: false,\n },\n applyChanges(next) {\n const newGroup: PanelGroupDefinition = {\n id: generateId(),\n itemLayouts: [],\n itemPanelKeys: {},\n ...next,\n };\n set((draft) => {\n draft.panelGroups[newGroup.id] = newGroup;\n draft.panelGroupOrder.unshift(newGroup.id);\n });\n },\n close() {\n set((draft) => {\n draft.panelGroupEditor = undefined;\n });\n },\n };\n\n // Open the editor\n set((draft) => {\n draft.panelGroupEditor = editor;\n });\n },\n\n openEditPanelGroup: (panelGroupId) => {\n const existingGroup = get().panelGroups[panelGroupId];\n if (existingGroup === undefined) {\n throw new Error(`Panel group with Id ${panelGroupId} does not exist`);\n }\n\n // Create the editor state\n const editor: PanelGroupEditor = {\n mode: 'Edit',\n initialValues: {\n title: existingGroup.title ?? '',\n isCollapsed: existingGroup.isCollapsed,\n },\n applyChanges(next) {\n set((draft) => {\n const group = draft.panelGroups[panelGroupId];\n if (group === undefined) {\n throw new Error(`Panel group with Id ${panelGroupId} does not exist`);\n }\n group.title = next.title;\n group.isCollapsed = next.isCollapsed;\n });\n },\n close() {\n set((draft) => {\n draft.panelGroupEditor = undefined;\n });\n },\n };\n\n // Open the editor\n set((draft) => {\n draft.panelGroupEditor = editor;\n });\n },\n});\n"],"names":["generateId","createPanelGroupEditorSlice","set","get","panelGroupEditor","undefined","openAddPanelGroup","editor","mode","initialValues","title","isCollapsed","applyChanges","next","newGroup","id","itemLayouts","itemPanelKeys","draft","panelGroups","panelGroupOrder","unshift","close","openEditPanelGroup","panelGroupId","existingGroup","Error","group"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,UAAU,QAAoB,UAAU,CAAC;AAmClD,OAAO,MAAMC,2BAA2B,GAMpC,CAACC,GAAG,EAAEC,GAAG,GAAM,CAAA;QACjBC,gBAAgB,EAAEC,SAAS;QAE3BC,iBAAiB,EAAE,IAAM;YACvB,0BAA0B;YAC1B,MAAMC,MAAM,G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