@perses-dev/dashboards 0.52.0-beta.4 → 0.52.0-rc.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/GridLayout/GridItemContent.js +137 -17
- package/dist/cjs/components/GridLayout/GridLayout.js +78 -126
- package/dist/cjs/components/GridLayout/Row.js +150 -0
- package/dist/cjs/components/GridLayout/index.js +1 -0
- package/dist/cjs/components/LeaveDialog/LeaveDialog.js +44 -0
- package/dist/cjs/components/LeaveDialog/index.js +30 -0
- package/dist/cjs/components/Panel/Panel.js +7 -2
- package/dist/cjs/components/Panel/PanelActions.js +25 -5
- package/dist/cjs/components/Panel/PanelHeader.js +33 -15
- package/dist/cjs/components/PanelDrawer/PanelDrawer.js +58 -21
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +3 -0
- package/dist/cjs/components/PanelGroupDialog/PanelGroupEditorForm.js +35 -15
- package/dist/cjs/components/index.js +1 -0
- package/dist/cjs/constants/user-interface-text.js +4 -2
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +7 -8
- package/dist/cjs/context/DashboardProvider/DashboardProviderWithQueryParams.js +3 -3
- package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +1 -0
- package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +6 -2
- package/dist/cjs/context/DashboardProvider/panel-group-slice.js +1 -0
- package/dist/cjs/context/DashboardProvider/view-panel-slice.js +10 -3
- package/dist/cjs/context/VariableProvider/VariableProvider.js +1 -1
- package/dist/cjs/context/useDashboard.js +5 -4
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +7 -3
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +9 -8
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts +2 -2
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
- package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
- package/dist/components/GridLayout/GridItemContent.js +99 -20
- package/dist/components/GridLayout/GridItemContent.js.map +1 -1
- package/dist/components/GridLayout/GridLayout.d.ts +8 -0
- package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
- package/dist/components/GridLayout/GridLayout.js +72 -126
- package/dist/components/GridLayout/GridLayout.js.map +1 -1
- package/dist/components/GridLayout/Row.d.ts +17 -0
- package/dist/components/GridLayout/Row.d.ts.map +1 -0
- package/dist/components/GridLayout/Row.js +142 -0
- package/dist/components/GridLayout/Row.js.map +1 -0
- package/dist/components/GridLayout/index.d.ts +1 -0
- package/dist/components/GridLayout/index.d.ts.map +1 -1
- package/dist/components/GridLayout/index.js +1 -0
- package/dist/components/GridLayout/index.js.map +1 -1
- package/dist/components/LeaveDialog/LeaveDialog.d.ts +7 -0
- package/dist/components/LeaveDialog/LeaveDialog.d.ts.map +1 -0
- package/dist/components/LeaveDialog/LeaveDialog.js +36 -0
- package/dist/components/LeaveDialog/LeaveDialog.js.map +1 -0
- package/dist/components/LeaveDialog/index.d.ts +2 -0
- package/dist/components/LeaveDialog/index.d.ts.map +1 -0
- package/dist/components/LeaveDialog/index.js +15 -0
- package/dist/components/LeaveDialog/index.js.map +1 -0
- package/dist/components/Panel/Panel.d.ts +6 -0
- package/dist/components/Panel/Panel.d.ts.map +1 -1
- package/dist/components/Panel/Panel.js +7 -2
- package/dist/components/Panel/Panel.js.map +1 -1
- package/dist/components/Panel/PanelActions.d.ts +5 -0
- package/dist/components/Panel/PanelActions.d.ts.map +1 -1
- package/dist/components/Panel/PanelActions.js +25 -5
- package/dist/components/Panel/PanelActions.js.map +1 -1
- package/dist/components/Panel/PanelHeader.d.ts +7 -1
- package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
- package/dist/components/Panel/PanelHeader.js +34 -16
- package/dist/components/Panel/PanelHeader.js.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.js +59 -22
- package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js +3 -0
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts +1 -0
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js +36 -16
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.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/constants/user-interface-text.d.ts +2 -0
- package/dist/constants/user-interface-text.d.ts.map +1 -1
- package/dist/constants/user-interface-text.js +4 -2
- package/dist/constants/user-interface-text.js.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.d.ts +5 -5
- package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.js +7 -8
- package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
- package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.js +4 -4
- package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.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.map +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts +1 -0
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.js +1 -0
- package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
- package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts +1 -0
- package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-group-editor-slice.js +6 -2
- package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -1
- package/dist/context/DashboardProvider/panel-group-slice.d.ts +3 -0
- package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-group-slice.js +1 -0
- package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
- package/dist/context/DashboardProvider/view-panel-slice.d.ts +6 -2
- package/dist/context/DashboardProvider/view-panel-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/view-panel-slice.js +10 -3
- package/dist/context/DashboardProvider/view-panel-slice.js.map +1 -1
- package/dist/context/VariableProvider/VariableProvider.js +1 -1
- package/dist/context/VariableProvider/VariableProvider.js.map +1 -1
- package/dist/context/useDashboard.js +5 -4
- package/dist/context/useDashboard.js.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.d.ts +7 -6
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.js +8 -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 +9 -8
- package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/context/DashboardProvider/panel-group-editor-slice.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { StateCreator } from 'zustand';\nimport { PanelGroupId } from '@perses-dev/core';\nimport { Middleware } from './common';\nimport { PanelGroupSlice, addPanelGroup, createEmptyPanelGroup } 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: (): void => {\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 = createEmptyPanelGroup();\n newGroup.title = next.title;\n newGroup.isCollapsed = next.isCollapsed;\n set((draft) => {\n addPanelGroup(draft, newGroup);\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): void => {\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":["addPanelGroup","createEmptyPanelGroup","createPanelGroupEditorSlice","set","get","panelGroupEditor","undefined","openAddPanelGroup","editor","mode","initialValues","title","isCollapsed","applyChanges","next","newGroup","draft","close","openEditPanelGroup","panelGroupId","existingGroup","panelGroups","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;AAKjC,SAA0BA,aAAa,EAAEC,qBAAqB,QAAQ,sBAAsB;
|
|
1
|
+
{"version":3,"sources":["../../../src/context/DashboardProvider/panel-group-editor-slice.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { StateCreator } from 'zustand';\nimport { PanelGroupId } from '@perses-dev/core';\nimport { Middleware } from './common';\nimport { PanelGroupSlice, addPanelGroup, createEmptyPanelGroup } 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 repeatVariable: string | undefined;\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: (): void => {\n // Create the editor state\n const editor: PanelGroupEditor = {\n mode: 'Add',\n initialValues: {\n title: '',\n isCollapsed: false,\n repeatVariable: '',\n },\n applyChanges(next) {\n const newGroup = createEmptyPanelGroup();\n newGroup.title = next.title;\n newGroup.isCollapsed = next.isCollapsed;\n newGroup.repeatVariable = next.repeatVariable;\n set((draft) => {\n addPanelGroup(draft, newGroup);\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): void => {\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 repeatVariable: existingGroup.repeatVariable ?? '',\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 group.repeatVariable = next.repeatVariable;\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":["addPanelGroup","createEmptyPanelGroup","createPanelGroupEditorSlice","set","get","panelGroupEditor","undefined","openAddPanelGroup","editor","mode","initialValues","title","isCollapsed","repeatVariable","applyChanges","next","newGroup","draft","close","openEditPanelGroup","panelGroupId","existingGroup","panelGroups","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;AAKjC,SAA0BA,aAAa,EAAEC,qBAAqB,QAAQ,sBAAsB;AAmC5F,OAAO,MAAMC,8BAMT,CAACC,KAAKC,MAAS,CAAA;QACjBC,kBAAkBC;QAElBC,mBAAmB;YACjB,0BAA0B;YAC1B,MAAMC,SAA2B;gBAC/BC,MAAM;gBACNC,eAAe;oBACbC,OAAO;oBACPC,aAAa;oBACbC,gBAAgB;gBAClB;gBACAC,cAAaC,IAAI;oBACf,MAAMC,WAAWf;oBACjBe,SAASL,KAAK,GAAGI,KAAKJ,KAAK;oBAC3BK,SAASJ,WAAW,GAAGG,KAAKH,WAAW;oBACvCI,SAASH,cAAc,GAAGE,KAAKF,cAAc;oBAC7CV,IAAI,CAACc;wBACHjB,cAAciB,OAAOD;oBACvB;gBACF;gBACAE;oBACEf,IAAI,CAACc;wBACHA,MAAMZ,gBAAgB,GAAGC;oBAC3B;gBACF;YACF;YAEA,kBAAkB;YAClBH,IAAI,CAACc;gBACHA,MAAMZ,gBAAgB,GAAGG;YAC3B;QACF;QAEAW,oBAAoB,CAACC;YACnB,MAAMC,gBAAgBjB,MAAMkB,WAAW,CAACF,aAAa;YACrD,IAAIC,kBAAkBf,WAAW;gBAC/B,MAAM,IAAIiB,MAAM,CAAC,oBAAoB,EAAEH,aAAa,eAAe,CAAC;YACtE;YAEA,0BAA0B;YAC1B,MAAMZ,SAA2B;gBAC/BC,MAAM;gBACNC,eAAe;oBACbC,OAAOU,cAAcV,KAAK,IAAI;oBAC9BC,aAAaS,cAAcT,WAAW;oBACtCC,gBAAgBQ,cAAcR,cAAc,IAAI;gBAClD;gBACAC,cAAaC,IAAI;oBACfZ,IAAI,CAACc;wBACH,MAAMO,QAAQP,MAAMK,WAAW,CAACF,aAAa;wBAC7C,IAAII,UAAUlB,WAAW;4BACvB,MAAM,IAAIiB,MAAM,CAAC,oBAAoB,EAAEH,aAAa,eAAe,CAAC;wBACtE;wBACAI,MAAMb,KAAK,GAAGI,KAAKJ,KAAK;wBACxBa,MAAMZ,WAAW,GAAGG,KAAKH,WAAW;wBACpCY,MAAMX,cAAc,GAAGE,KAAKF,cAAc;oBAC5C;gBACF;gBACAK;oBACEf,IAAI,CAACc;wBACHA,MAAMZ,gBAAgB,GAAGC;oBAC3B;gBACF;YACF;YAEA,kBAAkB;YAClBH,IAAI,CAACc;gBACHA,MAAMZ,gBAAgB,GAAGG;YAC3B;QACF;IACF,CAAA,EAAG"}
|
|
@@ -28,6 +28,8 @@ export interface PanelGroupDefinition {
|
|
|
28
28
|
id: PanelGroupId;
|
|
29
29
|
isCollapsed: boolean;
|
|
30
30
|
title?: string;
|
|
31
|
+
repeatedOriginId?: PanelGroupId;
|
|
32
|
+
repeatVariable?: string;
|
|
31
33
|
itemLayouts: PanelGroupItemLayout[];
|
|
32
34
|
itemPanelKeys: Record<PanelGroupItemLayoutId, string>;
|
|
33
35
|
}
|
|
@@ -41,6 +43,7 @@ export type PanelGroupItemLayoutId = string;
|
|
|
41
43
|
export interface PanelGroupItemId {
|
|
42
44
|
panelGroupId: PanelGroupId;
|
|
43
45
|
panelGroupItemLayoutId: PanelGroupItemLayoutId;
|
|
46
|
+
repeatVariable?: [string, string];
|
|
44
47
|
}
|
|
45
48
|
export declare function isPanelGroupItemIdEqual(a?: PanelGroupItemId, b?: PanelGroupItemId): boolean;
|
|
46
49
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"panel-group-slice.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/panel-group-slice.ts"],"names":[],"mappings":"AAaA,OAAO,EAAsB,gBAAgB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEtF,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAc,UAAU,EAAE,MAAM,UAAU,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC,YAAY,EAAE,oBAAoB,CAAC,CAAC;IAExD;;OAEG;IACH,eAAe,EAAE,YAAY,EAAE,CAAC;IAEhC;;OAEG;IACH,eAAe,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAE1D;;OAEG;IACH,uBAAuB,EAAE,CAAC,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,oBAAoB,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC;CACjH;AAED,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,YAAY,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,oBAAoB,EAAE,CAAC;IACpC,aAAa,EAAE,MAAM,CAAC,sBAAsB,EAAE,MAAM,CAAC,CAAC;CACvD;AAED,MAAM,WAAW,oBAAqB,SAAQ,MAAM;IAClD,CAAC,EAAE,sBAAsB,CAAC;CAC3B;AAED,MAAM,MAAM,sBAAsB,GAAG,MAAM,CAAC;AAE5C;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,YAAY,EAAE,YAAY,CAAC;IAC3B,sBAAsB,EAAE,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"panel-group-slice.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/panel-group-slice.ts"],"names":[],"mappings":"AAaA,OAAO,EAAsB,gBAAgB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEtF,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAc,UAAU,EAAE,MAAM,UAAU,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC,YAAY,EAAE,oBAAoB,CAAC,CAAC;IAExD;;OAEG;IACH,eAAe,EAAE,YAAY,EAAE,CAAC;IAEhC;;OAEG;IACH,eAAe,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAE1D;;OAEG;IACH,uBAAuB,EAAE,CAAC,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,oBAAoB,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC;CACjH;AAED,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,YAAY,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,YAAY,CAAC;IAChC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,oBAAoB,EAAE,CAAC;IACpC,aAAa,EAAE,MAAM,CAAC,sBAAsB,EAAE,MAAM,CAAC,CAAC;CACvD;AAED,MAAM,WAAW,oBAAqB,SAAQ,MAAM;IAClD,CAAC,EAAE,sBAAsB,CAAC;CAC3B;AAED,MAAM,MAAM,sBAAsB,GAAG,MAAM,CAAC;AAE5C;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,YAAY,EAAE,YAAY,CAAC;IAC3B,sBAAsB,EAAE,sBAAsB,CAAC;IAC/C,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC;AAKD,wBAAgB,uBAAuB,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,CAAC,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAE3F;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,gBAAgB,EAAE,GAC1B,YAAY,CAAC,eAAe,EAAE,UAAU,EAAE,EAAE,EAAE,eAAe,CAAC,CAkChE;AAED,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,gBAAgB,EAAE,GAC1B,IAAI,CAAC,eAAe,EAAE,aAAa,GAAG,iBAAiB,CAAC,CAqC1D;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,oBAAoB,CAQ5D;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,aAAa,CAAC,eAAe,CAAC,EAAE,QAAQ,EAAE,oBAAoB,GAAG,IAAI,CAGzG"}
|
|
@@ -77,6 +77,7 @@ export function convertLayoutsToPanelGroups(layouts) {
|
|
|
77
77
|
panelGroups[panelGroupId] = {
|
|
78
78
|
id: panelGroupId,
|
|
79
79
|
isCollapsed: layout.spec.display?.collapse?.open === false,
|
|
80
|
+
repeatVariable: layout.spec.repeatVariable,
|
|
80
81
|
title: layout.spec.display?.title,
|
|
81
82
|
itemLayouts,
|
|
82
83
|
itemPanelKeys
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/context/DashboardProvider/panel-group-slice.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { getPanelKeyFromRef, LayoutDefinition, PanelGroupId } from '@perses-dev/core';\n\nimport { Layout } from 'react-grid-layout';\nimport { StateCreator } from 'zustand';\nimport { WritableDraft } from 'immer';\nimport { generateId, Middleware } from './common';\n\n/**\n * Slice with the state of Panel Groups, as well as any actions that modify only Panel Group state.\n */\nexport interface PanelGroupSlice {\n /**\n * Panel groups indexed by their ID.\n */\n panelGroups: Record<PanelGroupId, PanelGroupDefinition>;\n\n /**\n * An array of panel group IDs, representing their order in the dashboard.\n */\n panelGroupOrder: PanelGroupId[];\n\n /**\n * Rearrange the order of panel groups by swapping the positions\n */\n swapPanelGroups: (xIndex: number, yIndex: number) => void;\n\n /**\n * Update the item layouts for a panel group when, for example, a panel is moved or resized.\n */\n updatePanelGroupLayouts: (panelGroupId: PanelGroupId, itemLayouts: PanelGroupDefinition['itemLayouts']) => void;\n}\n\nexport interface PanelGroupDefinition {\n id: PanelGroupId;\n isCollapsed: boolean;\n title?: string;\n itemLayouts: PanelGroupItemLayout[];\n itemPanelKeys: Record<PanelGroupItemLayoutId, string>;\n}\n\nexport interface PanelGroupItemLayout extends Layout {\n i: PanelGroupItemLayoutId;\n}\n\nexport type PanelGroupItemLayoutId = string;\n\n/**\n * Uniquely identifies an item in a PanelGroup.\n */\nexport interface PanelGroupItemId {\n panelGroupId: PanelGroupId;\n panelGroupItemLayoutId: PanelGroupItemLayoutId;\n}\n\n/*\n * Check if two PanelGroupItemId are equal\n */\nexport function isPanelGroupItemIdEqual(a?: PanelGroupItemId, b?: PanelGroupItemId): boolean {\n return a?.panelGroupId === b?.panelGroupId && a?.panelGroupItemLayoutId === b?.panelGroupItemLayoutId;\n}\n\n/**\n * Curried function for creating a PanelGroupSlice.\n */\nexport function createPanelGroupSlice(\n layouts: LayoutDefinition[]\n): StateCreator<PanelGroupSlice, Middleware, [], PanelGroupSlice> {\n const { panelGroups, panelGroupOrder } = convertLayoutsToPanelGroups(layouts);\n\n // Return the state creator function for Zustand\n return (set) => ({\n panelGroups,\n panelGroupOrder,\n\n swapPanelGroups(x, y): void {\n set((state) => {\n if (x < 0 || x >= state.panelGroupOrder.length || y < 0 || y >= state.panelGroupOrder.length) {\n throw new Error('index out of bound');\n }\n const xPanelGroup = state.panelGroupOrder[x];\n const yPanelGroup = state.panelGroupOrder[y];\n\n if (xPanelGroup === undefined || yPanelGroup === undefined) {\n throw new Error('panel group is undefined');\n }\n // assign yPanelGroup to layouts[x] and assign xGroup to layouts[y], swapping two panel groups\n [state.panelGroupOrder[x], state.panelGroupOrder[y]] = [yPanelGroup, xPanelGroup];\n });\n },\n\n updatePanelGroupLayouts(panelGroupId, itemLayouts): void {\n set((state) => {\n const group = state.panelGroups[panelGroupId];\n if (group === undefined) {\n throw new Error(`Cannot find panel group ${panelGroupId}`);\n }\n group.itemLayouts = itemLayouts;\n });\n },\n });\n}\n\nexport function convertLayoutsToPanelGroups(\n layouts: LayoutDefinition[]\n): Pick<PanelGroupSlice, 'panelGroups' | 'panelGroupOrder'> {\n // Convert the initial layouts from the JSON\n const panelGroups: PanelGroupSlice['panelGroups'] = {};\n const panelGroupIdOrder: PanelGroupSlice['panelGroupOrder'] = [];\n for (const layout of layouts) {\n const itemLayouts: PanelGroupDefinition['itemLayouts'] = [];\n const itemPanelKeys: PanelGroupDefinition['itemPanelKeys'] = {};\n\n // Split layout information from panel keys to make it easier to update just layouts on move/resize of panels\n for (const item of layout.spec.items) {\n const panelGroupLayoutId = generateId().toString();\n itemLayouts.push({\n i: panelGroupLayoutId,\n w: item.width,\n h: item.height,\n x: item.x,\n y: item.y,\n });\n itemPanelKeys[panelGroupLayoutId] = getPanelKeyFromRef(item.content);\n }\n\n // Create the panel group and keep track of the ID order\n const panelGroupId = generateId();\n panelGroups[panelGroupId] = {\n id: panelGroupId,\n isCollapsed: layout.spec.display?.collapse?.open === false,\n title: layout.spec.display?.title,\n itemLayouts,\n itemPanelKeys,\n };\n panelGroupIdOrder.push(panelGroupId);\n }\n return {\n panelGroups,\n panelGroupOrder: panelGroupIdOrder,\n };\n}\n\n/**\n * Private helper function for creating an empty panel group.\n */\nexport function createEmptyPanelGroup(): PanelGroupDefinition {\n return {\n id: generateId(),\n title: undefined,\n isCollapsed: false,\n itemLayouts: [],\n itemPanelKeys: {},\n };\n}\n\n/**\n * Private helper function that modifies panel group state to add a new panel\n */\nexport function addPanelGroup(draft: WritableDraft<PanelGroupSlice>, newGroup: PanelGroupDefinition): void {\n draft.panelGroups[newGroup.id] = newGroup;\n draft.panelGroupOrder.unshift(newGroup.id);\n}\n"],"names":["getPanelKeyFromRef","generateId","isPanelGroupItemIdEqual","a","b","panelGroupId","panelGroupItemLayoutId","createPanelGroupSlice","layouts","panelGroups","panelGroupOrder","convertLayoutsToPanelGroups","set","swapPanelGroups","x","y","state","length","Error","xPanelGroup","yPanelGroup","undefined","updatePanelGroupLayouts","itemLayouts","group","panelGroupIdOrder","layout","itemPanelKeys","item","spec","items","panelGroupLayoutId","toString","push","i","w","width","h","height","content","id","isCollapsed","display","collapse","open","title","createEmptyPanelGroup","addPanelGroup","draft","newGroup","unshift"],"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,SAASA,kBAAkB,QAAwC,mBAAmB;AAKtF,SAASC,UAAU,QAAoB,WAAW;
|
|
1
|
+
{"version":3,"sources":["../../../src/context/DashboardProvider/panel-group-slice.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { getPanelKeyFromRef, LayoutDefinition, PanelGroupId } from '@perses-dev/core';\n\nimport { Layout } from 'react-grid-layout';\nimport { StateCreator } from 'zustand';\nimport { WritableDraft } from 'immer';\nimport { generateId, Middleware } from './common';\n\n/**\n * Slice with the state of Panel Groups, as well as any actions that modify only Panel Group state.\n */\nexport interface PanelGroupSlice {\n /**\n * Panel groups indexed by their ID.\n */\n panelGroups: Record<PanelGroupId, PanelGroupDefinition>;\n\n /**\n * An array of panel group IDs, representing their order in the dashboard.\n */\n panelGroupOrder: PanelGroupId[];\n\n /**\n * Rearrange the order of panel groups by swapping the positions\n */\n swapPanelGroups: (xIndex: number, yIndex: number) => void;\n\n /**\n * Update the item layouts for a panel group when, for example, a panel is moved or resized.\n */\n updatePanelGroupLayouts: (panelGroupId: PanelGroupId, itemLayouts: PanelGroupDefinition['itemLayouts']) => void;\n}\n\nexport interface PanelGroupDefinition {\n id: PanelGroupId;\n isCollapsed: boolean;\n title?: string;\n repeatedOriginId?: PanelGroupId; // ID of the original panel group from which this repeated group is derived\n repeatVariable?: string; // Optional, used for repeated panel groups\n itemLayouts: PanelGroupItemLayout[];\n itemPanelKeys: Record<PanelGroupItemLayoutId, string>;\n}\n\nexport interface PanelGroupItemLayout extends Layout {\n i: PanelGroupItemLayoutId;\n}\n\nexport type PanelGroupItemLayoutId = string;\n\n/**\n * Uniquely identifies an item in a PanelGroup.\n */\nexport interface PanelGroupItemId {\n panelGroupId: PanelGroupId;\n panelGroupItemLayoutId: PanelGroupItemLayoutId;\n repeatVariable?: [string, string]; // Optional, used for repeated panel groups. Variable name and value.\n}\n\n/*\n * Check if two PanelGroupItemId are equal\n */\nexport function isPanelGroupItemIdEqual(a?: PanelGroupItemId, b?: PanelGroupItemId): boolean {\n return a?.panelGroupId === b?.panelGroupId && a?.panelGroupItemLayoutId === b?.panelGroupItemLayoutId;\n}\n\n/**\n * Curried function for creating a PanelGroupSlice.\n */\nexport function createPanelGroupSlice(\n layouts: LayoutDefinition[]\n): StateCreator<PanelGroupSlice, Middleware, [], PanelGroupSlice> {\n const { panelGroups, panelGroupOrder } = convertLayoutsToPanelGroups(layouts);\n\n // Return the state creator function for Zustand\n return (set) => ({\n panelGroups,\n panelGroupOrder,\n\n swapPanelGroups(x, y): void {\n set((state) => {\n if (x < 0 || x >= state.panelGroupOrder.length || y < 0 || y >= state.panelGroupOrder.length) {\n throw new Error('index out of bound');\n }\n const xPanelGroup = state.panelGroupOrder[x];\n const yPanelGroup = state.panelGroupOrder[y];\n\n if (xPanelGroup === undefined || yPanelGroup === undefined) {\n throw new Error('panel group is undefined');\n }\n // assign yPanelGroup to layouts[x] and assign xGroup to layouts[y], swapping two panel groups\n [state.panelGroupOrder[x], state.panelGroupOrder[y]] = [yPanelGroup, xPanelGroup];\n });\n },\n\n updatePanelGroupLayouts(panelGroupId, itemLayouts): void {\n set((state) => {\n const group = state.panelGroups[panelGroupId];\n if (group === undefined) {\n throw new Error(`Cannot find panel group ${panelGroupId}`);\n }\n group.itemLayouts = itemLayouts;\n });\n },\n });\n}\n\nexport function convertLayoutsToPanelGroups(\n layouts: LayoutDefinition[]\n): Pick<PanelGroupSlice, 'panelGroups' | 'panelGroupOrder'> {\n // Convert the initial layouts from the JSON\n const panelGroups: PanelGroupSlice['panelGroups'] = {};\n const panelGroupIdOrder: PanelGroupSlice['panelGroupOrder'] = [];\n for (const layout of layouts) {\n const itemLayouts: PanelGroupDefinition['itemLayouts'] = [];\n const itemPanelKeys: PanelGroupDefinition['itemPanelKeys'] = {};\n\n // Split layout information from panel keys to make it easier to update just layouts on move/resize of panels\n for (const item of layout.spec.items) {\n const panelGroupLayoutId = generateId().toString();\n itemLayouts.push({\n i: panelGroupLayoutId,\n w: item.width,\n h: item.height,\n x: item.x,\n y: item.y,\n });\n itemPanelKeys[panelGroupLayoutId] = getPanelKeyFromRef(item.content);\n }\n\n // Create the panel group and keep track of the ID order\n const panelGroupId = generateId();\n panelGroups[panelGroupId] = {\n id: panelGroupId,\n isCollapsed: layout.spec.display?.collapse?.open === false,\n repeatVariable: layout.spec.repeatVariable,\n title: layout.spec.display?.title,\n itemLayouts,\n itemPanelKeys,\n };\n panelGroupIdOrder.push(panelGroupId);\n }\n return {\n panelGroups,\n panelGroupOrder: panelGroupIdOrder,\n };\n}\n\n/**\n * Private helper function for creating an empty panel group.\n */\nexport function createEmptyPanelGroup(): PanelGroupDefinition {\n return {\n id: generateId(),\n title: undefined,\n isCollapsed: false,\n itemLayouts: [],\n itemPanelKeys: {},\n };\n}\n\n/**\n * Private helper function that modifies panel group state to add a new panel\n */\nexport function addPanelGroup(draft: WritableDraft<PanelGroupSlice>, newGroup: PanelGroupDefinition): void {\n draft.panelGroups[newGroup.id] = newGroup;\n draft.panelGroupOrder.unshift(newGroup.id);\n}\n"],"names":["getPanelKeyFromRef","generateId","isPanelGroupItemIdEqual","a","b","panelGroupId","panelGroupItemLayoutId","createPanelGroupSlice","layouts","panelGroups","panelGroupOrder","convertLayoutsToPanelGroups","set","swapPanelGroups","x","y","state","length","Error","xPanelGroup","yPanelGroup","undefined","updatePanelGroupLayouts","itemLayouts","group","panelGroupIdOrder","layout","itemPanelKeys","item","spec","items","panelGroupLayoutId","toString","push","i","w","width","h","height","content","id","isCollapsed","display","collapse","open","repeatVariable","title","createEmptyPanelGroup","addPanelGroup","draft","newGroup","unshift"],"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,SAASA,kBAAkB,QAAwC,mBAAmB;AAKtF,SAASC,UAAU,QAAoB,WAAW;AAoDlD;;CAEC,GACD,OAAO,SAASC,wBAAwBC,CAAoB,EAAEC,CAAoB;IAChF,OAAOD,GAAGE,iBAAiBD,G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IAAI,CAACC,KAAK,CAAE;YACpC,MAAMC,qBAAqB9B,aAAa+B,QAAQ;YAChDT,YAAYU,IAAI,CAAC;gBACfC,GAAGH;gBACHI,GAAGP,KAAKQ,KAAK;gBACbC,GAAGT,KAAKU,MAAM;gBACdxB,GAAGc,KAAKd,CAAC;gBACTC,GAAGa,KAAKb,CAAC;YACX;YACAY,aAAa,CAACI,mBAAmB,GAAG/B,mBAAmB4B,KAAKW,OAAO;QACrE;QAEA,wDAAwD;QACxD,MAAMlC,eAAeJ;QACrBQ,WAAW,CAACJ,aAAa,GAAG;YAC1BmC,IAAInC;YACJoC,aAAaf,OAAOG,IAAI,CAACa,OAAO,EAAEC,UAAUC,SAAS;YACrDC,gBAAgBnB,OAAOG,IAAI,CAACgB,cAAc;YAC1CC,OAAOpB,OAAOG,IAAI,CAACa,OAAO,EAAEI;YAC5BvB;YACAI;QACF;QACAF,kBAAkBQ,IAAI,CAAC5B;IACzB;IACA,OAAO;QACLI;QACAC,iBAAiBe;IACnB;AACF;AAEA;;CAEC,GACD,OAAO,SAASsB;IACd,OAAO;QACLP,IAAIvC;QACJ6C,OAAOzB;QACPoB,aAAa;QACblB,aAAa,EAAE;QACfI,eAAe,CAAC;IAClB;AACF;AAEA;;CAEC,GACD,OAAO,SAASqB,cAAcC,KAAqC,EAAEC,QAA8B;IACjGD,MAAMxC,WAAW,CAACyC,SAASV,EAAE,CAAC,GAAGU;IACjCD,MAAMvC,eAAe,CAACyC,OAAO,CAACD,SAASV,EAAE;AAC3C"}
|
|
@@ -2,6 +2,10 @@ import { StateCreator } from 'zustand';
|
|
|
2
2
|
import { PanelGroupItemId } from '@perses-dev/dashboards';
|
|
3
3
|
import { Middleware } from './common';
|
|
4
4
|
import { PanelGroupSlice } from './panel-group-slice';
|
|
5
|
+
export interface VirtualPanelRef {
|
|
6
|
+
ref: string;
|
|
7
|
+
repeatVariable?: [string, string];
|
|
8
|
+
}
|
|
5
9
|
/**
|
|
6
10
|
* Slice that handles viewing Panels in max size ("full screen").
|
|
7
11
|
*/
|
|
@@ -12,10 +16,10 @@ export interface ViewPanelSlice {
|
|
|
12
16
|
}
|
|
13
17
|
export interface ViewPanelState {
|
|
14
18
|
panelGroupItemId?: PanelGroupItemId;
|
|
15
|
-
panelRef?:
|
|
19
|
+
panelRef?: VirtualPanelRef;
|
|
16
20
|
}
|
|
17
21
|
/**
|
|
18
22
|
* Curried function for viewing panel in max size ("full screen").
|
|
19
23
|
*/
|
|
20
|
-
export declare function createViewPanelSlice(viewPanelRef?:
|
|
24
|
+
export declare function createViewPanelSlice(viewPanelRef?: VirtualPanelRef, setViewPanelRef?: (ref: VirtualPanelRef | undefined) => void): StateCreator<ViewPanelSlice & PanelGroupSlice, Middleware, [], ViewPanelSlice>;
|
|
21
25
|
//# sourceMappingURL=view-panel-slice.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view-panel-slice.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/view-panel-slice.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAwB,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAEhF,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"view-panel-slice.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/view-panel-slice.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAwB,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAEhF,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAKtD,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,cAAc,CAAC;IAC1B,YAAY,EAAE,MAAM,gBAAgB,GAAG,SAAS,CAAC;IACjD,YAAY,EAAE,CAAC,gBAAgB,CAAC,EAAE,gBAAgB,KAAK,IAAI,CAAC;CAC7D;AAED,MAAM,WAAW,cAAc;IAE7B,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,QAAQ,CAAC,EAAE,eAAe,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,YAAY,CAAC,EAAE,eAAe,EAC9B,eAAe,CAAC,EAAE,CAAC,GAAG,EAAE,eAAe,GAAG,SAAS,KAAK,IAAI,GAC3D,YAAY,CAAC,cAAc,GAAG,eAAe,EAAE,UAAU,EAAE,EAAE,EAAE,cAAc,CAAC,CAwBhF"}
|
|
@@ -47,12 +47,13 @@ function getViewPanelGroupId(panelGroups, panelGroupItemId, panelRef) {
|
|
|
47
47
|
// Find the PanelGroupItemId of a Panel from a PanelRef
|
|
48
48
|
function findPanelGroupItemIdOfPanelRef(panelGroups, panelRef) {
|
|
49
49
|
for (const panelGroup of Object.values(panelGroups)){
|
|
50
|
-
const itemPanel = Object.entries(panelGroup.itemPanelKeys ?? []).find(([_, value])=>value === panelRef);
|
|
50
|
+
const itemPanel = Object.entries(panelGroup.itemPanelKeys ?? []).find(([_, value])=>value === panelRef.ref);
|
|
51
51
|
if (itemPanel) {
|
|
52
52
|
const [key] = itemPanel;
|
|
53
53
|
return {
|
|
54
54
|
panelGroupId: panelGroup.id,
|
|
55
|
-
panelGroupItemLayoutId: key
|
|
55
|
+
panelGroupItemLayoutId: key,
|
|
56
|
+
repeatVariable: panelRef.repeatVariable
|
|
56
57
|
};
|
|
57
58
|
}
|
|
58
59
|
}
|
|
@@ -65,7 +66,13 @@ function findPanelRefOfPanelGroupItemId(panelGroups, panelGroupItemId) {
|
|
|
65
66
|
}
|
|
66
67
|
const panelGroup = panelGroups[panelGroupItemId.panelGroupId];
|
|
67
68
|
if (panelGroup) {
|
|
68
|
-
|
|
69
|
+
const panelRef = panelGroup.itemPanelKeys[panelGroupItemId.panelGroupItemLayoutId];
|
|
70
|
+
if (panelRef) {
|
|
71
|
+
return {
|
|
72
|
+
ref: panelRef,
|
|
73
|
+
repeatVariable: panelGroupItemId.repeatVariable
|
|
74
|
+
};
|
|
75
|
+
}
|
|
69
76
|
}
|
|
70
77
|
return undefined;
|
|
71
78
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/context/DashboardProvider/view-panel-slice.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { StateCreator } from 'zustand';\nimport { PanelGroupDefinition, PanelGroupItemId } from '@perses-dev/dashboards';\nimport { PanelGroupId } from '@perses-dev/core';\nimport { Middleware } from './common';\nimport { PanelGroupSlice } from './panel-group-slice';\n\n/**\n * Slice that handles viewing Panels in max size (\"full screen\").\n */\nexport interface ViewPanelSlice {\n viewPanel: ViewPanelState;\n getViewPanel: () => PanelGroupItemId | undefined;\n setViewPanel: (panelGroupItemId?: PanelGroupItemId) => void;\n}\n\nexport interface ViewPanelState {\n // Do not use directly, use `getViewPanel()` instead for getting the current viewed PanelGroupItemId!\n panelGroupItemId?: PanelGroupItemId;\n panelRef?:
|
|
1
|
+
{"version":3,"sources":["../../../src/context/DashboardProvider/view-panel-slice.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { StateCreator } from 'zustand';\nimport { PanelGroupDefinition, PanelGroupItemId } from '@perses-dev/dashboards';\nimport { PanelGroupId } from '@perses-dev/core';\nimport { Middleware } from './common';\nimport { PanelGroupSlice } from './panel-group-slice';\n\n/*\n * A reference to a Panel that can be repeated in a PanelGroup.\n */\nexport interface VirtualPanelRef {\n ref: string;\n repeatVariable?: [string, string];\n}\n\n/**\n * Slice that handles viewing Panels in max size (\"full screen\").\n */\nexport interface ViewPanelSlice {\n viewPanel: ViewPanelState;\n getViewPanel: () => PanelGroupItemId | undefined;\n setViewPanel: (panelGroupItemId?: PanelGroupItemId) => void;\n}\n\nexport interface ViewPanelState {\n // Do not use directly, use `getViewPanel()` instead for getting the current viewed PanelGroupItemId!\n panelGroupItemId?: PanelGroupItemId;\n panelRef?: VirtualPanelRef;\n}\n\n/**\n * Curried function for viewing panel in max size (\"full screen\").\n */\nexport function createViewPanelSlice(\n viewPanelRef?: VirtualPanelRef,\n setViewPanelRef?: (ref: VirtualPanelRef | undefined) => void\n): StateCreator<ViewPanelSlice & PanelGroupSlice, Middleware, [], ViewPanelSlice> {\n return (set, get) => ({\n viewPanel: {\n panelGroupItemId: undefined,\n panelRef: viewPanelRef,\n },\n\n getViewPanel(): PanelGroupItemId | undefined {\n return getViewPanelGroupId(get().panelGroups, get().viewPanel.panelGroupItemId, get().viewPanel.panelRef);\n },\n\n setViewPanel(panelGroupItemId?: PanelGroupItemId): void {\n set((state) => {\n state.viewPanel = {\n panelRef: undefined,\n panelGroupItemId: panelGroupItemId,\n };\n const panelRef = findPanelRefOfPanelGroupItemId(get().panelGroups, panelGroupItemId);\n if (setViewPanelRef) {\n setViewPanelRef(panelRef);\n }\n });\n },\n });\n}\n\nfunction getViewPanelGroupId(\n panelGroups: Record<PanelGroupId, PanelGroupDefinition>,\n panelGroupItemId?: PanelGroupItemId,\n panelRef?: VirtualPanelRef\n): PanelGroupItemId | undefined {\n if (panelGroupItemId) {\n return panelGroupItemId;\n }\n\n if (panelRef) {\n return findPanelGroupItemIdOfPanelRef(panelGroups, panelRef);\n }\n\n return undefined;\n}\n\n// Find the PanelGroupItemId of a Panel from a PanelRef\nfunction findPanelGroupItemIdOfPanelRef(\n panelGroups: Record<PanelGroupId, PanelGroupDefinition>,\n panelRef: VirtualPanelRef\n): PanelGroupItemId | undefined {\n for (const panelGroup of Object.values(panelGroups)) {\n const itemPanel = Object.entries(panelGroup.itemPanelKeys ?? []).find(([_, value]) => value === panelRef.ref);\n if (itemPanel) {\n const [key] = itemPanel;\n return {\n panelGroupId: panelGroup.id,\n panelGroupItemLayoutId: key,\n repeatVariable: panelRef.repeatVariable,\n };\n }\n }\n return undefined;\n}\n\n// Find the PanelRef from a PanelGroupItemId\nfunction findPanelRefOfPanelGroupItemId(\n panelGroups: Record<PanelGroupId, PanelGroupDefinition>,\n panelGroupItemId?: PanelGroupItemId\n): VirtualPanelRef | undefined {\n if (!panelGroupItemId) {\n return undefined;\n }\n const panelGroup = panelGroups[panelGroupItemId.panelGroupId];\n if (panelGroup) {\n const panelRef = panelGroup.itemPanelKeys[panelGroupItemId.panelGroupItemLayoutId];\n if (panelRef) {\n return { ref: panelRef, repeatVariable: panelGroupItemId.repeatVariable };\n }\n }\n return undefined;\n}\n"],"names":["createViewPanelSlice","viewPanelRef","setViewPanelRef","set","get","viewPanel","panelGroupItemId","undefined","panelRef","getViewPanel","getViewPanelGroupId","panelGroups","setViewPanel","state","findPanelRefOfPanelGroupItemId","findPanelGroupItemIdOfPanelRef","panelGroup","Object","values","itemPanel","entries","itemPanelKeys","find","_","value","ref","key","panelGroupId","id","panelGroupItemLayoutId","repeatVariable"],"mappings":"AAAA,oCAA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c;YACzC;QACF;IACF;IACA,OAAOvB;AACT;AAEA,4CAA4C;AAC5C,SAASO,+BACPH,WAAuD,EACvDL,gBAAmC;IAEnC,IAAI,CAACA,kBAAkB;QACrB,OAAOC;IACT;IACA,MAAMS,aAAaL,WAAW,CAACL,iBAAiBqB,YAAY,CAAC;IAC7D,IAAIX,YAAY;QACd,MAAMR,WAAWQ,WAAWK,aAAa,CAACf,iBAAiBuB,sBAAsB,CAAC;QAClF,IAAIrB,UAAU;YACZ,OAAO;gBAAEiB,KAAKjB;gBAAUsB,gBAAgBxB,iBAAiBwB,cAAc;YAAC;QAC1E;IACF;IACA,OAAOvB;AACT"}
|
|
@@ -330,7 +330,7 @@ function createVariableDefinitionStore({ initialVariableDefinitions = [], extern
|
|
|
330
330
|
return checkSavedDefaultVariableStatus(get().variableDefinitions, get().variableState);
|
|
331
331
|
}
|
|
332
332
|
}))));
|
|
333
|
-
return store;
|
|
333
|
+
return store;
|
|
334
334
|
}
|
|
335
335
|
// TODO: merge the different providers related to Variables under a single one (and keep "VariableProvider" as a name)
|
|
336
336
|
export function VariableProvider({ children, initialVariableDefinitions = [], externalVariableDefinitions = [], builtinVariableDefinitions = [] }) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/context/VariableProvider/VariableProvider.tsx"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { createContext, ReactElement, ReactNode, useContext, useMemo, useState } from 'react';\nimport { createStore, StoreApi, useStore } from 'zustand';\nimport { useStoreWithEqualityFn } from 'zustand/traditional';\nimport { immer } from 'zustand/middleware/immer';\nimport { devtools } from 'zustand/middleware';\nimport { shallow } from 'zustand/shallow';\nimport { produce } from 'immer';\nimport {\n VariableContext,\n VariableStateMap,\n VariableState,\n VariableStoreStateMap,\n VariableOption,\n BuiltinVariableContext,\n useTimeRange,\n} from '@perses-dev/plugin-system';\nimport {\n DEFAULT_ALL_VALUE as ALL_VALUE,\n VariableName,\n VariableValue,\n VariableDefinition,\n formatDuration,\n intervalToPrometheusDuration,\n BuiltinVariableDefinition,\n TextVariableDefinition,\n ListVariableDefinition,\n} from '@perses-dev/core';\nimport { checkSavedDefaultVariableStatus, findVariableDefinitionByName, mergeVariableDefinitions } from './utils';\nimport { hydrateVariableDefinitionStates as hydrateVariableDefinitionStates } from './hydrationUtils';\nimport { getInitalValuesFromQueryParameters, getURLQueryParamName, useVariableQueryParams } from './query-params';\n\n/**\n * This store is used to manipulate and read the definition of the variables and their state.\n * - being local or external variables.\n * - being text or list variables.\n * - being of any state (value, options, loading, error, ...) check {@VariableState}\n * Go and read each property documentation for more details.\n */\ntype VariableDefinitionStore = {\n /**\n * List of local variables definitions.\n * This is typically the variable definition that can be modified through the setVariableDefinition setter.\n *\n * In Perses App ecosystem, this is typically the dashboard scope variables, that's why we call them local.\n * Note that depending on the form, we can reuse this store to modify higher scope variables. For example,\n * when we modify the variable of a project, we'll set this field with project scope variables. To be able to modify\n * them.\n */\n variableDefinitions: VariableDefinition[];\n /**\n * List of external variable definitions.\n * This is static variable definitions that won´t be modified under this context.\n * You'll have to set one list of external variable definition by scope. See {@link ExternalVariableDefinition} for\n * more details.\n *\n * In Perses App ecosystem, this is typically the project or global scope variables.\n * Note that depending on the form, we can reuse this store to modify higher scope variables. For example,\n * when we modify the variable of a project, we'll set this field with global scope variables. Which means we\n * won't be able to modify them from this form.\n */\n externalVariableDefinitions: ExternalVariableDefinition[];\n /**\n * Additionally to definitions, we need to associate to each variable a state. That's what this map is meant for.\n * This can be heavily modified under this context, using the different setters available.\n * Note that the state of local AND external variables can be modified.\n */\n variableState: VariableStoreStateMap;\n /**\n * Allow to modify the `value` property of a variable in the state map.\n * @param variableName identify the variable\n * @param value new value\n * @param source identify the variable source if this is an external variable. See {@link ExternalVariableDefinition}\n */\n setVariableValue: (variableName: VariableName, value: VariableValue, source?: string) => void;\n /**\n * Allow to modify the `options` property of a variable in the state map.\n * @param variableName identify the variable\n * @param options new value\n * @param source identify the variable source if this is an external variable. See {@link ExternalVariableDefinition}\n */\n setVariableOptions: (name: VariableName, options: VariableOption[], source?: string) => void;\n /**\n * Allow to modify the `loading` property of a variable in the state map.\n * @param variableName identify the variable\n * @param laoding new value\n * @param source identify the variable source if this is an external variable. See {@link ExternalVariableDefinition}\n */\n setVariableLoading: (name: VariableName, loading: boolean, source?: string) => void;\n setVariableDefinitions: (definitions: VariableDefinition[]) => void;\n setVariableDefaultValues: () => VariableDefinition[];\n getSavedVariablesStatus: () => { isSavedVariableModified: boolean; modifiedVariableNames: string[] };\n};\n\n/**\n * Context object for {@link VariableDefinitionStore}.\n */\nconst VariableDefinitionStoreContext = createContext<StoreApi<VariableDefinitionStore> | undefined>(undefined);\nexport function useVariableDefinitionStoreCtx(): StoreApi<VariableDefinitionStore> {\n const context = useContext(VariableDefinitionStoreContext);\n if (!context) {\n throw new Error('VariableStoreContext not initialized');\n }\n return context;\n}\n\nexport function useVariableDefinitionStates(variableNames?: string[]): VariableStateMap {\n const store = useVariableDefinitionStoreCtx();\n return useStoreWithEqualityFn(\n store,\n (s) => {\n const varStates: VariableStateMap = {};\n\n // Collect values of local variables, from the variable state\n const names = variableNames ?? s.variableDefinitions.map((value) => value.spec.name);\n names.forEach((name) => {\n const varState = s.variableState.get({ name });\n if (!varState || varState.overridden) {\n return;\n }\n varStates[name] = varState;\n });\n\n // Collect values of external variables, from the variable state\n s.externalVariableDefinitions.forEach((d) => {\n const source = d.source;\n d.definitions.forEach((value) => {\n const name = value.spec.name;\n const varState = s.variableState.get({ name, source });\n if (!varState || varState.overridden) {\n return;\n }\n varStates[name] = varState;\n });\n });\n\n return varStates;\n },\n (left, right) => {\n return JSON.stringify(left) === JSON.stringify(right);\n }\n );\n}\n\n/**\n * Get the state and definition of a variable from the variables context.\n * @param name name of the variable\n * @param source if given, it searches in the external variables\n */\nexport function useVariableDefinitionAndState(\n name: string,\n source?: string\n): {\n definition: TextVariableDefinition | ListVariableDefinition | undefined;\n state: VariableState | undefined;\n} {\n const store = useVariableDefinitionStoreCtx();\n return useStore(store, (s) => {\n const state = s.variableState.get({ name, source });\n const definitions = source\n ? s.externalVariableDefinitions.find((v) => v.source === source)?.definitions\n : s.variableDefinitions;\n const definition = (definitions || []).find((v) => v.spec.name === name);\n\n return { state, definition };\n });\n}\n\nexport function useVariableDefinitionActions(): {\n setVariableLoading: (name: VariableName, loading: boolean, source?: string) => void;\n getSavedVariablesStatus: () => { isSavedVariableModified: boolean; modifiedVariableNames: string[] };\n setVariableDefaultValues: () => VariableDefinition[];\n setVariableValue: (variableName: VariableName, value: VariableValue, source?: string) => void;\n setVariableOptions: (name: VariableName, options: VariableOption[], source?: string) => void;\n setVariableDefinitions: (definitions: VariableDefinition[]) => void;\n} {\n const store = useVariableDefinitionStoreCtx();\n return useStoreWithEqualityFn(\n store,\n (s) => {\n return {\n setVariableValue: s.setVariableValue,\n setVariableLoading: s.setVariableLoading,\n setVariableOptions: s.setVariableOptions,\n setVariableDefinitions: s.setVariableDefinitions,\n setVariableDefaultValues: s.setVariableDefaultValues,\n getSavedVariablesStatus: s.getSavedVariablesStatus,\n };\n },\n shallow\n );\n}\n\nexport function useVariableDefinitions(): VariableDefinition[] {\n const store = useVariableDefinitionStoreCtx();\n return useStore(store, (s) => s.variableDefinitions);\n}\n\nexport function useExternalVariableDefinitions(): ExternalVariableDefinition[] {\n const store = useVariableDefinitionStoreCtx();\n return useStore(store, (s) => s.externalVariableDefinitions);\n}\n\ninterface PluginProviderProps {\n children: ReactNode;\n builtinVariables?: BuiltinVariableDefinition[];\n}\n\nfunction PluginProvider({ children, builtinVariables }: PluginProviderProps): ReactElement {\n const originalValues = useVariableDefinitionStates();\n const definitions = useVariableDefinitions();\n const externalDefinitions = useExternalVariableDefinitions();\n const { absoluteTimeRange } = useTimeRange();\n\n const values = useMemo(() => {\n const contextValues: VariableStateMap = {};\n\n // This will loop through all the current variables values\n // and update any variables that have ALL_VALUE as their current value\n // to include all options.\n Object.keys(originalValues).forEach((name) => {\n const v = { ...originalValues[name] } as VariableState;\n\n if (v.value === ALL_VALUE) {\n const definition = findVariableDefinitionByName(name, definitions, externalDefinitions);\n // If the variable is a list variable and has a custom all value, then use that value instead\n if (definition?.kind === 'ListVariable' && definition.spec.customAllValue) {\n v.value = definition.spec.customAllValue;\n } else {\n v.value = v.options?.map((o: { value: string }) => o.value) ?? null;\n }\n }\n contextValues[name] = v;\n });\n return contextValues;\n }, [originalValues, definitions, externalDefinitions]);\n\n const allBuiltinVariables: BuiltinVariableDefinition[] = useMemo(() => {\n const result: BuiltinVariableDefinition[] = [\n {\n kind: 'BuiltinVariable',\n spec: {\n name: '__from',\n value: () => absoluteTimeRange.start.valueOf().toString(),\n source: 'Dashboard',\n display: {\n name: '__from',\n description: 'Start time of the current time range in unix millisecond epoch',\n hidden: true,\n },\n },\n },\n {\n kind: 'BuiltinVariable',\n spec: {\n name: '__to',\n value: () => absoluteTimeRange.end.valueOf().toString(),\n source: 'Dashboard',\n display: {\n name: '__to',\n description: 'End time of the current time range in unix millisecond epoch',\n hidden: true,\n },\n },\n },\n {\n kind: 'BuiltinVariable',\n spec: {\n name: '__range',\n value: () => formatDuration(intervalToPrometheusDuration(absoluteTimeRange)),\n source: 'Dashboard',\n display: {\n name: '__range',\n description: 'The range for the current dashboard in human readable format',\n hidden: true,\n },\n },\n },\n {\n kind: 'BuiltinVariable',\n spec: {\n name: '__range_s',\n value: () => ((absoluteTimeRange.end.valueOf() - absoluteTimeRange.start.valueOf()) / 1000).toString(),\n source: 'Dashboard',\n display: {\n name: '__range_s',\n description: 'The range for the current dashboard in second',\n hidden: true,\n },\n },\n },\n {\n kind: 'BuiltinVariable',\n spec: {\n name: '__range_ms',\n value: () => (absoluteTimeRange.end.valueOf() - absoluteTimeRange.start.valueOf()).toString(),\n source: 'Dashboard',\n display: {\n name: '__range_ms',\n description: 'The range for the current dashboard in millisecond',\n hidden: true,\n },\n },\n },\n ];\n builtinVariables?.forEach((def) => result.push(def));\n return result;\n }, [absoluteTimeRange, builtinVariables]);\n\n return (\n <BuiltinVariableContext.Provider value={{ variables: allBuiltinVariables }}>\n <VariableContext.Provider value={{ state: values }}>{children}</VariableContext.Provider>\n </BuiltinVariableContext.Provider>\n );\n}\n\ninterface VariableDefinitionStoreArgs {\n initialVariableDefinitions?: VariableDefinition[];\n externalVariableDefinitions?: ExternalVariableDefinition[];\n queryParams?: ReturnType<typeof useVariableQueryParams>;\n}\n\nfunction createVariableDefinitionStore({\n initialVariableDefinitions = [],\n externalVariableDefinitions = [],\n queryParams,\n}: VariableDefinitionStoreArgs): StoreApi<VariableDefinitionStore> {\n const initialParams = getInitalValuesFromQueryParameters(queryParams ? queryParams[0] : {});\n const store = createStore<VariableDefinitionStore>()(\n devtools(\n immer((set, get) => ({\n variableState: hydrateVariableDefinitionStates(\n initialVariableDefinitions,\n initialParams,\n externalVariableDefinitions\n ),\n variableDefinitions: initialVariableDefinitions,\n externalVariableDefinitions: externalVariableDefinitions,\n setVariableDefinitions(definitions: VariableDefinition[]): void {\n set(\n (state) => {\n state.variableDefinitions = definitions;\n state.variableState = hydrateVariableDefinitionStates(\n definitions,\n initialParams,\n externalVariableDefinitions\n );\n },\n false,\n '[Variables] setVariableDefinitions' // Used for action name in Redux devtools\n );\n },\n setVariableOptions(name, options, source?: string): void {\n set(\n (state) => {\n const varState = state.variableState.get({ name, source });\n if (!varState) {\n return;\n }\n varState.options = options;\n },\n false,\n '[Variables] setVariableOptions'\n );\n },\n setVariableLoading(name, loading, source?: string): void {\n set(\n (state) => {\n const varState = state.variableState.get({ name, source });\n if (!varState) {\n return;\n }\n varState.loading = loading;\n },\n false,\n '[Variables] setVariableLoading'\n );\n },\n setVariableValue: (name, value, source?: string): void =>\n set(\n (state) => {\n let val = value;\n const varState = state.variableState.get({ name, source });\n if (!varState) {\n return;\n }\n\n // Make sure there is only one all value\n if (Array.isArray(val) && val.includes(ALL_VALUE)) {\n if (val.at(-1) === ALL_VALUE) {\n val = ALL_VALUE;\n } else {\n val = val.filter((v) => v !== ALL_VALUE);\n }\n }\n if (queryParams) {\n const setQueryParams = queryParams[1];\n setQueryParams({ [getURLQueryParamName(name)]: val });\n }\n varState.value = val;\n },\n false,\n '[Variables] setVariableValue'\n ),\n setVariableDefaultValues: (): VariableDefinition[] => {\n const variableDefinitions = get().variableDefinitions;\n const variableState = get().variableState;\n const updatedVariables = produce(variableDefinitions, (draft) => {\n draft.forEach((variable, index) => {\n const name = variable.spec.name;\n if (variable.kind === 'ListVariable') {\n const currentVariable = variableState.get({ name });\n if (currentVariable?.value !== undefined) {\n draft[index] = {\n kind: 'ListVariable',\n spec: produce(variable.spec, (specDraft) => {\n specDraft.defaultValue = currentVariable.value;\n }),\n };\n }\n } else if (variable.kind === 'TextVariable') {\n const currentVariable = variableState.get({ name });\n const currentVariableValue = typeof currentVariable?.value === 'string' ? currentVariable.value : '';\n if (currentVariable?.value !== undefined) {\n draft[index] = {\n kind: 'TextVariable',\n spec: produce(variable.spec, (specDraft) => {\n specDraft.value = currentVariableValue;\n }),\n };\n }\n }\n });\n });\n set(\n (state) => {\n state.variableDefinitions = updatedVariables;\n },\n false,\n '[Variables] setVariableDefaultValues'\n );\n return updatedVariables;\n },\n getSavedVariablesStatus: (): {\n modifiedVariableNames: string[];\n isSavedVariableModified: boolean;\n } => {\n return checkSavedDefaultVariableStatus(get().variableDefinitions, get().variableState);\n },\n }))\n )\n );\n\n return store as unknown as StoreApi<VariableDefinitionStore>; // TODO: @Gladorme check if we can avoid this cast\n}\n\n/**\n * The external variables allow you to give to the provider some additional variables, not defined in the dashboard and static.\n * It means that you won´t be able to update them from the dashboard itself, but you will see them appear and will be able\n * to modify their runtime value as any other variable.\n * If one of the external variable has the same name as a local one, it will be marked as overridden.\n * You can define one list of variable definition by source and as many source as you want.\n * The order of the sources is important as first one will take precedence on the following ones, in case they have same names.\n */\nexport type ExternalVariableDefinition = {\n source: string;\n tooltip?: {\n title?: string;\n description?: string;\n };\n editLink?: string;\n definitions: VariableDefinition[];\n};\n\nexport interface VariableProviderProps {\n children: ReactNode;\n initialVariableDefinitions?: VariableDefinition[];\n externalVariableDefinitions?: ExternalVariableDefinition[];\n builtinVariableDefinitions?: BuiltinVariableDefinition[];\n}\n\n// TODO: merge the different providers related to Variables under a single one (and keep \"VariableProvider\" as a name)\nexport function VariableProvider({\n children,\n initialVariableDefinitions = [],\n externalVariableDefinitions = [],\n builtinVariableDefinitions = [],\n}: VariableProviderProps): ReactElement {\n const [store] = useState(() =>\n createVariableDefinitionStore({ initialVariableDefinitions, externalVariableDefinitions })\n );\n\n return (\n <VariableDefinitionStoreContext.Provider value={store}>\n <PluginProvider builtinVariables={builtinVariableDefinitions}>{children}</PluginProvider>\n </VariableDefinitionStoreContext.Provider>\n );\n}\n\nexport function VariableProviderWithQueryParams({\n children,\n initialVariableDefinitions = [],\n externalVariableDefinitions = [],\n builtinVariableDefinitions: builtinVariables = [],\n}: VariableProviderProps): ReactElement {\n const allVariableDefs = mergeVariableDefinitions(initialVariableDefinitions, externalVariableDefinitions);\n const queryParams = useVariableQueryParams(allVariableDefs);\n const [store] = useState(() =>\n createVariableDefinitionStore({ initialVariableDefinitions, externalVariableDefinitions, queryParams })\n );\n\n return (\n <VariableDefinitionStoreContext.Provider value={store}>\n <PluginProvider builtinVariables={builtinVariables}>{children}</PluginProvider>\n </VariableDefinitionStoreContext.Provider>\n );\n}\n"],"names":["createContext","useContext","useMemo","useState","createStore","useStore","useStoreWithEqualityFn","immer","devtools","shallow","produce","VariableContext","BuiltinVariableContext","useTimeRange","DEFAULT_ALL_VALUE","ALL_VALUE","formatDuration","intervalToPrometheusDuration","checkSavedDefaultVariableStatus","findVariableDefinitionByName","mergeVariableDefinitions","hydrateVariableDefinitionStates","getInitalValuesFromQueryParameters","getURLQueryParamName","useVariableQueryParams","VariableDefinitionStoreContext","undefined","useVariableDefinitionStoreCtx","context","Error","useVariableDefinitionStates","variableNames","store","s","varStates","names","variableDefinitions","map","value","spec","name","forEach","varState","variableState","get","overridden","externalVariableDefinitions","d","source","definitions","left","right","JSON","stringify","useVariableDefinitionAndState","state","find","v","definition","useVariableDefinitionActions","setVariableValue","setVariableLoading","setVariableOptions","setVariableDefinitions","setVariableDefaultValues","getSavedVariablesStatus","useVariableDefinitions","useExternalVariableDefinitions","PluginProvider","children","builtinVariables","originalValues","externalDefinitions","absoluteTimeRange","values","contextValues","Object","keys","kind","customAllValue","options","o","allBuiltinVariables","result","start","valueOf","toString","display","description","hidden","end","def","push","Provider","variables","createVariableDefinitionStore","initialVariableDefinitions","queryParams","initialParams","set","loading","val","Array","isArray","includes","at","filter","setQueryParams","updatedVariables","draft","variable","index","currentVariable","specDraft","defaultValue","currentVariableValue","VariableProvider","builtinVariableDefinitions","VariableProviderWithQueryParams","allVariableDefs"],"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,SAASA,aAAa,EAA2BC,UAAU,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AAC9F,SAASC,WAAW,EAAYC,QAAQ,QAAQ,UAAU;AAC1D,SAASC,sBAAsB,QAAQ,sBAAsB;AAC7D,SAASC,KAAK,QAAQ,2BAA2B;AACjD,SAASC,QAAQ,QAAQ,qBAAqB;AAC9C,SAASC,OAAO,QAAQ,kBAAkB;AAC1C,SAASC,OAAO,QAAQ,QAAQ;AAChC,SACEC,eAAe,EAKfC,sBAAsB,EACtBC,YAAY,QACP,4BAA4B;AAC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AAClH;AA2BA,sHAAsH;AACtH,OAAO,SAASoF,iBAAiB,EAC/B/C,QAAQ,EACR2B,6BAA6B,EAAE,EAC/BlD,8BAA8B,EAAE,EAChCuE,6BAA6B,EAAE,EACT;IACtB,MAAM,CAACrF,MAAM,GAAG7B,SAAS,IACvB4F,8BAA8B;YAAEC;YAA4BlD;QAA4B;IAG1F,qBACE,KAACrB,+BAA+BoE,QAAQ;QAACvD,OAAON;kBAC9C,cAAA,KAACoC;YAAeE,kBAAkB+C;sBAA6BhD;;;AAGrE;AAEA,OAAO,SAASiD,gCAAgC,EAC9CjD,QAAQ,EACR2B,6BAA6B,EAAE,EAC/BlD,8BAA8B,EAAE,EAChCuE,4BAA4B/C,mBAAmB,EAAE,EAC3B;IACtB,MAAMiD,kBAAkBnG,yBAAyB4E,4BAA4BlD;IAC7E,MAAMmD,cAAczE,uBAAuB+F;IAC3C,MAAM,CAACvF,MAAM,GAAG7B,SAAS,IACvB4F,8BAA8B;YAAEC;YAA4BlD;YAA6BmD;QAAY;IAGvG,qBACE,KAACxE,+BAA+BoE,QAAQ;QAACvD,OAAON;kBAC9C,cAAA,KAACoC;YAAeE,kBAAkBA;sBAAmBD;;;AAG3D"}
|
|
1
|
+
{"version":3,"sources":["../../../src/context/VariableProvider/VariableProvider.tsx"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { createContext, ReactElement, ReactNode, useContext, useMemo, useState } from 'react';\nimport { createStore, StoreApi, useStore } from 'zustand';\nimport { useStoreWithEqualityFn } from 'zustand/traditional';\nimport { immer } from 'zustand/middleware/immer';\nimport { devtools } from 'zustand/middleware';\nimport { shallow } from 'zustand/shallow';\nimport { produce } from 'immer';\nimport {\n VariableContext,\n VariableStateMap,\n VariableState,\n VariableStoreStateMap,\n VariableOption,\n BuiltinVariableContext,\n useTimeRange,\n} from '@perses-dev/plugin-system';\nimport {\n DEFAULT_ALL_VALUE as ALL_VALUE,\n VariableName,\n VariableValue,\n VariableDefinition,\n formatDuration,\n intervalToPrometheusDuration,\n BuiltinVariableDefinition,\n TextVariableDefinition,\n ListVariableDefinition,\n} from '@perses-dev/core';\nimport { checkSavedDefaultVariableStatus, findVariableDefinitionByName, mergeVariableDefinitions } from './utils';\nimport { hydrateVariableDefinitionStates as hydrateVariableDefinitionStates } from './hydrationUtils';\nimport { getInitalValuesFromQueryParameters, getURLQueryParamName, useVariableQueryParams } from './query-params';\n\n/**\n * This store is used to manipulate and read the definition of the variables and their state.\n * - being local or external variables.\n * - being text or list variables.\n * - being of any state (value, options, loading, error, ...) check {@VariableState}\n * Go and read each property documentation for more details.\n */\ntype VariableDefinitionStore = {\n /**\n * List of local variables definitions.\n * This is typically the variable definition that can be modified through the setVariableDefinition setter.\n *\n * In Perses App ecosystem, this is typically the dashboard scope variables, that's why we call them local.\n * Note that depending on the form, we can reuse this store to modify higher scope variables. For example,\n * when we modify the variable of a project, we'll set this field with project scope variables. To be able to modify\n * them.\n */\n variableDefinitions: VariableDefinition[];\n /**\n * List of external variable definitions.\n * This is static variable definitions that won´t be modified under this context.\n * You'll have to set one list of external variable definition by scope. See {@link ExternalVariableDefinition} for\n * more details.\n *\n * In Perses App ecosystem, this is typically the project or global scope variables.\n * Note that depending on the form, we can reuse this store to modify higher scope variables. For example,\n * when we modify the variable of a project, we'll set this field with global scope variables. Which means we\n * won't be able to modify them from this form.\n */\n externalVariableDefinitions: ExternalVariableDefinition[];\n /**\n * Additionally to definitions, we need to associate to each variable a state. That's what this map is meant for.\n * This can be heavily modified under this context, using the different setters available.\n * Note that the state of local AND external variables can be modified.\n */\n variableState: VariableStoreStateMap;\n /**\n * Allow to modify the `value` property of a variable in the state map.\n * @param variableName identify the variable\n * @param value new value\n * @param source identify the variable source if this is an external variable. See {@link ExternalVariableDefinition}\n */\n setVariableValue: (variableName: VariableName, value: VariableValue, source?: string) => void;\n /**\n * Allow to modify the `options` property of a variable in the state map.\n * @param variableName identify the variable\n * @param options new value\n * @param source identify the variable source if this is an external variable. See {@link ExternalVariableDefinition}\n */\n setVariableOptions: (name: VariableName, options: VariableOption[], source?: string) => void;\n /**\n * Allow to modify the `loading` property of a variable in the state map.\n * @param variableName identify the variable\n * @param laoding new value\n * @param source identify the variable source if this is an external variable. See {@link ExternalVariableDefinition}\n */\n setVariableLoading: (name: VariableName, loading: boolean, source?: string) => void;\n setVariableDefinitions: (definitions: VariableDefinition[]) => void;\n setVariableDefaultValues: () => VariableDefinition[];\n getSavedVariablesStatus: () => { isSavedVariableModified: boolean; modifiedVariableNames: string[] };\n};\n\n/**\n * Context object for {@link VariableDefinitionStore}.\n */\nconst VariableDefinitionStoreContext = createContext<StoreApi<VariableDefinitionStore> | undefined>(undefined);\nexport function useVariableDefinitionStoreCtx(): StoreApi<VariableDefinitionStore> {\n const context = useContext(VariableDefinitionStoreContext);\n if (!context) {\n throw new Error('VariableStoreContext not initialized');\n }\n return context;\n}\n\nexport function useVariableDefinitionStates(variableNames?: string[]): VariableStateMap {\n const store = useVariableDefinitionStoreCtx();\n return useStoreWithEqualityFn(\n store,\n (s) => {\n const varStates: VariableStateMap = {};\n\n // Collect values of local variables, from the variable state\n const names = variableNames ?? s.variableDefinitions.map((value) => value.spec.name);\n names.forEach((name) => {\n const varState = s.variableState.get({ name });\n if (!varState || varState.overridden) {\n return;\n }\n varStates[name] = varState;\n });\n\n // Collect values of external variables, from the variable state\n s.externalVariableDefinitions.forEach((d) => {\n const source = d.source;\n d.definitions.forEach((value) => {\n const name = value.spec.name;\n const varState = s.variableState.get({ name, source });\n if (!varState || varState.overridden) {\n return;\n }\n varStates[name] = varState;\n });\n });\n\n return varStates;\n },\n (left, right) => {\n return JSON.stringify(left) === JSON.stringify(right);\n }\n );\n}\n\n/**\n * Get the state and definition of a variable from the variables context.\n * @param name name of the variable\n * @param source if given, it searches in the external variables\n */\nexport function useVariableDefinitionAndState(\n name: string,\n source?: string\n): {\n definition: TextVariableDefinition | ListVariableDefinition | undefined;\n state: VariableState | undefined;\n} {\n const store = useVariableDefinitionStoreCtx();\n return useStore(store, (s) => {\n const state = s.variableState.get({ name, source });\n const definitions = source\n ? s.externalVariableDefinitions.find((v) => v.source === source)?.definitions\n : s.variableDefinitions;\n const definition = (definitions || []).find((v) => v.spec.name === name);\n\n return { state, definition };\n });\n}\n\nexport function useVariableDefinitionActions(): {\n setVariableLoading: (name: VariableName, loading: boolean, source?: string) => void;\n getSavedVariablesStatus: () => { isSavedVariableModified: boolean; modifiedVariableNames: string[] };\n setVariableDefaultValues: () => VariableDefinition[];\n setVariableValue: (variableName: VariableName, value: VariableValue, source?: string) => void;\n setVariableOptions: (name: VariableName, options: VariableOption[], source?: string) => void;\n setVariableDefinitions: (definitions: VariableDefinition[]) => void;\n} {\n const store = useVariableDefinitionStoreCtx();\n return useStoreWithEqualityFn(\n store,\n (s) => {\n return {\n setVariableValue: s.setVariableValue,\n setVariableLoading: s.setVariableLoading,\n setVariableOptions: s.setVariableOptions,\n setVariableDefinitions: s.setVariableDefinitions,\n setVariableDefaultValues: s.setVariableDefaultValues,\n getSavedVariablesStatus: s.getSavedVariablesStatus,\n };\n },\n shallow\n );\n}\n\nexport function useVariableDefinitions(): VariableDefinition[] {\n const store = useVariableDefinitionStoreCtx();\n return useStore(store, (s) => s.variableDefinitions);\n}\n\nexport function useExternalVariableDefinitions(): ExternalVariableDefinition[] {\n const store = useVariableDefinitionStoreCtx();\n return useStore(store, (s) => s.externalVariableDefinitions);\n}\n\ninterface PluginProviderProps {\n children: ReactNode;\n builtinVariables?: BuiltinVariableDefinition[];\n}\n\nfunction PluginProvider({ children, builtinVariables }: PluginProviderProps): ReactElement {\n const originalValues = useVariableDefinitionStates();\n const definitions = useVariableDefinitions();\n const externalDefinitions = useExternalVariableDefinitions();\n const { absoluteTimeRange } = useTimeRange();\n\n const values = useMemo(() => {\n const contextValues: VariableStateMap = {};\n\n // This will loop through all the current variables values\n // and update any variables that have ALL_VALUE as their current value\n // to include all options.\n Object.keys(originalValues).forEach((name) => {\n const v = { ...originalValues[name] } as VariableState;\n\n if (v.value === ALL_VALUE) {\n const definition = findVariableDefinitionByName(name, definitions, externalDefinitions);\n // If the variable is a list variable and has a custom all value, then use that value instead\n if (definition?.kind === 'ListVariable' && definition.spec.customAllValue) {\n v.value = definition.spec.customAllValue;\n } else {\n v.value = v.options?.map((o: { value: string }) => o.value) ?? null;\n }\n }\n contextValues[name] = v;\n });\n return contextValues;\n }, [originalValues, definitions, externalDefinitions]);\n\n const allBuiltinVariables: BuiltinVariableDefinition[] = useMemo(() => {\n const result: BuiltinVariableDefinition[] = [\n {\n kind: 'BuiltinVariable',\n spec: {\n name: '__from',\n value: () => absoluteTimeRange.start.valueOf().toString(),\n source: 'Dashboard',\n display: {\n name: '__from',\n description: 'Start time of the current time range in unix millisecond epoch',\n hidden: true,\n },\n },\n },\n {\n kind: 'BuiltinVariable',\n spec: {\n name: '__to',\n value: () => absoluteTimeRange.end.valueOf().toString(),\n source: 'Dashboard',\n display: {\n name: '__to',\n description: 'End time of the current time range in unix millisecond epoch',\n hidden: true,\n },\n },\n },\n {\n kind: 'BuiltinVariable',\n spec: {\n name: '__range',\n value: () => formatDuration(intervalToPrometheusDuration(absoluteTimeRange)),\n source: 'Dashboard',\n display: {\n name: '__range',\n description: 'The range for the current dashboard in human readable format',\n hidden: true,\n },\n },\n },\n {\n kind: 'BuiltinVariable',\n spec: {\n name: '__range_s',\n value: () => ((absoluteTimeRange.end.valueOf() - absoluteTimeRange.start.valueOf()) / 1000).toString(),\n source: 'Dashboard',\n display: {\n name: '__range_s',\n description: 'The range for the current dashboard in second',\n hidden: true,\n },\n },\n },\n {\n kind: 'BuiltinVariable',\n spec: {\n name: '__range_ms',\n value: () => (absoluteTimeRange.end.valueOf() - absoluteTimeRange.start.valueOf()).toString(),\n source: 'Dashboard',\n display: {\n name: '__range_ms',\n description: 'The range for the current dashboard in millisecond',\n hidden: true,\n },\n },\n },\n ];\n builtinVariables?.forEach((def) => result.push(def));\n return result;\n }, [absoluteTimeRange, builtinVariables]);\n\n return (\n <BuiltinVariableContext.Provider value={{ variables: allBuiltinVariables }}>\n <VariableContext.Provider value={{ state: values }}>{children}</VariableContext.Provider>\n </BuiltinVariableContext.Provider>\n );\n}\n\ninterface VariableDefinitionStoreArgs {\n initialVariableDefinitions?: VariableDefinition[];\n externalVariableDefinitions?: ExternalVariableDefinition[];\n queryParams?: ReturnType<typeof useVariableQueryParams>;\n}\n\nfunction createVariableDefinitionStore({\n initialVariableDefinitions = [],\n externalVariableDefinitions = [],\n queryParams,\n}: VariableDefinitionStoreArgs): StoreApi<VariableDefinitionStore> {\n const initialParams = getInitalValuesFromQueryParameters(queryParams ? queryParams[0] : {});\n const store = createStore<VariableDefinitionStore>()(\n devtools(\n immer((set, get) => ({\n variableState: hydrateVariableDefinitionStates(\n initialVariableDefinitions,\n initialParams,\n externalVariableDefinitions\n ),\n variableDefinitions: initialVariableDefinitions,\n externalVariableDefinitions: externalVariableDefinitions,\n setVariableDefinitions(definitions: VariableDefinition[]): void {\n set(\n (state) => {\n state.variableDefinitions = definitions;\n state.variableState = hydrateVariableDefinitionStates(\n definitions,\n initialParams,\n externalVariableDefinitions\n );\n },\n false,\n '[Variables] setVariableDefinitions' // Used for action name in Redux devtools\n );\n },\n setVariableOptions(name, options, source?: string): void {\n set(\n (state) => {\n const varState = state.variableState.get({ name, source });\n if (!varState) {\n return;\n }\n varState.options = options;\n },\n false,\n '[Variables] setVariableOptions'\n );\n },\n setVariableLoading(name, loading, source?: string): void {\n set(\n (state) => {\n const varState = state.variableState.get({ name, source });\n if (!varState) {\n return;\n }\n varState.loading = loading;\n },\n false,\n '[Variables] setVariableLoading'\n );\n },\n setVariableValue: (name, value, source?: string): void =>\n set(\n (state) => {\n let val = value;\n const varState = state.variableState.get({ name, source });\n if (!varState) {\n return;\n }\n\n // Make sure there is only one all value\n if (Array.isArray(val) && val.includes(ALL_VALUE)) {\n if (val.at(-1) === ALL_VALUE) {\n val = ALL_VALUE;\n } else {\n val = val.filter((v) => v !== ALL_VALUE);\n }\n }\n if (queryParams) {\n const setQueryParams = queryParams[1];\n setQueryParams({ [getURLQueryParamName(name)]: val });\n }\n varState.value = val;\n },\n false,\n '[Variables] setVariableValue'\n ),\n setVariableDefaultValues: (): VariableDefinition[] => {\n const variableDefinitions = get().variableDefinitions;\n const variableState = get().variableState;\n const updatedVariables = produce(variableDefinitions, (draft) => {\n draft.forEach((variable, index) => {\n const name = variable.spec.name;\n if (variable.kind === 'ListVariable') {\n const currentVariable = variableState.get({ name });\n if (currentVariable?.value !== undefined) {\n draft[index] = {\n kind: 'ListVariable',\n spec: produce(variable.spec, (specDraft) => {\n specDraft.defaultValue = currentVariable.value;\n }),\n };\n }\n } else if (variable.kind === 'TextVariable') {\n const currentVariable = variableState.get({ name });\n const currentVariableValue = typeof currentVariable?.value === 'string' ? currentVariable.value : '';\n if (currentVariable?.value !== undefined) {\n draft[index] = {\n kind: 'TextVariable',\n spec: produce(variable.spec, (specDraft) => {\n specDraft.value = currentVariableValue;\n }),\n };\n }\n }\n });\n });\n set(\n (state) => {\n state.variableDefinitions = updatedVariables;\n },\n false,\n '[Variables] setVariableDefaultValues'\n );\n return updatedVariables;\n },\n getSavedVariablesStatus: (): {\n modifiedVariableNames: string[];\n isSavedVariableModified: boolean;\n } => {\n return checkSavedDefaultVariableStatus(get().variableDefinitions, get().variableState);\n },\n }))\n )\n );\n\n return store as StoreApi<VariableDefinitionStore>;\n}\n\n/**\n * The external variables allow you to give to the provider some additional variables, not defined in the dashboard and static.\n * It means that you won´t be able to update them from the dashboard itself, but you will see them appear and will be able\n * to modify their runtime value as any other variable.\n * If one of the external variable has the same name as a local one, it will be marked as overridden.\n * You can define one list of variable definition by source and as many source as you want.\n * The order of the sources is important as first one will take precedence on the following ones, in case they have same names.\n */\nexport type ExternalVariableDefinition = {\n source: string;\n tooltip?: {\n title?: string;\n description?: string;\n };\n editLink?: string;\n definitions: VariableDefinition[];\n};\n\nexport interface VariableProviderProps {\n children: ReactNode;\n initialVariableDefinitions?: VariableDefinition[];\n externalVariableDefinitions?: ExternalVariableDefinition[];\n builtinVariableDefinitions?: BuiltinVariableDefinition[];\n}\n\n// TODO: merge the different providers related to Variables under a single one (and keep \"VariableProvider\" as a name)\nexport function VariableProvider({\n children,\n initialVariableDefinitions = [],\n externalVariableDefinitions = [],\n builtinVariableDefinitions = [],\n}: VariableProviderProps): ReactElement {\n const [store] = useState(() =>\n createVariableDefinitionStore({ initialVariableDefinitions, externalVariableDefinitions })\n );\n\n return (\n <VariableDefinitionStoreContext.Provider value={store}>\n <PluginProvider builtinVariables={builtinVariableDefinitions}>{children}</PluginProvider>\n </VariableDefinitionStoreContext.Provider>\n );\n}\n\nexport function VariableProviderWithQueryParams({\n children,\n initialVariableDefinitions = [],\n externalVariableDefinitions = [],\n builtinVariableDefinitions: builtinVariables = [],\n}: VariableProviderProps): ReactElement {\n const allVariableDefs = mergeVariableDefinitions(initialVariableDefinitions, externalVariableDefinitions);\n const queryParams = useVariableQueryParams(allVariableDefs);\n const [store] = useState(() =>\n createVariableDefinitionStore({ initialVariableDefinitions, externalVariableDefinitions, queryParams })\n );\n\n return (\n <VariableDefinitionStoreContext.Provider value={store}>\n <PluginProvider builtinVariables={builtinVariables}>{children}</PluginProvider>\n </VariableDefinitionStoreContext.Provider>\n );\n}\n"],"names":["createContext","useContext","useMemo","useState","createStore","useStore","useStoreWithEqualityFn","immer","devtools","shallow","produce","VariableContext","BuiltinVariableContext","useTimeRange","DEFAULT_ALL_VALUE","ALL_VALUE","formatDuration","intervalToPrometheusDuration","checkSavedDefaultVariableStatus","findVariableDefinitionByName","mergeVariableDefinitions","hydrateVariableDefinitionStates","getInitalValuesFromQueryParameters","getURLQueryParamName","useVariableQueryParams","VariableDefinitionStoreContext","undefined","useVariableDefinitionStoreCtx","context","Error","useVariableDefinitionStates","variableNames","store","s","varStates","names","variableDefinitions","map","value","spec","name","forEach","varState","variableState","get","overridden","externalVariableDefinitions","d","source","definitions","left","right","JSON","stringify","useVariableDefinitionAndState","state","find","v","definition","useVariableDefinitionActions","setVariableValue","setVariableLoading","setVariableOptions","setVariableDefinitions","setVariableDefaultValues","getSavedVariablesStatus","useVariableDefinitions","useExternalVariableDefinitions","PluginProvider","children","builtinVariables","originalValues","externalDefinitions","absoluteTimeRange","values","contextValues","Object","keys","kind","customAllValue","options","o","allBuiltinVariables","result","start","valueOf","toString","display","description","hidden","end","def","push","Provider","variables","createVariableDefinitionStore","initialVariableDefinitions","queryParams","initialParams","set","loading","val","Array","isArray","includes","at","filter","setQueryParams","updatedVariables","draft","variable","index","currentVariable","specDraft","defaultValue","currentVariableValue","VariableProvider","builtinVariableDefinitions","VariableProviderWithQueryParams","allVariableDefs"],"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,SAASA,aAAa,EAA2BC,UAAU,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AAC9F,SAASC,WAAW,EAAYC,QAAQ,QAAQ,UAAU;AAC1D,SAASC,sBAAsB,QAAQ,sBAAsB;AAC7D,SAASC,KAAK,QAAQ,2BAA2B;AACjD,SAASC,QAAQ,QAAQ,qBAAqB;AAC9C,SAASC,OAAO,QAAQ,kBAAkB;AAC1C,SAASC,OAAO,QAAQ,QAAQ;AAChC,SACEC,eAAe,EAKfC,sBAAsB,EACtBC,YAAY,QACP,4BAA4B;AACnC,SACEC,qBAAqBC,SAAS,EAI9BC,cAAc,EAC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QAAQ,EACR2B,6BAA6B,EAAE,EAC/BlD,8BAA8B,EAAE,EAChCuE,6BAA6B,EAAE,EACT;IACtB,MAAM,CAACrF,MAAM,GAAG7B,SAAS,IACvB4F,8BAA8B;YAAEC;YAA4BlD;QAA4B;IAG1F,qBACE,KAACrB,+BAA+BoE,QAAQ;QAACvD,OAAON;kBAC9C,cAAA,KAACoC;YAAeE,kBAAkB+C;sBAA6BhD;;;AAGrE;AAEA,OAAO,SAASiD,gCAAgC,EAC9CjD,QAAQ,EACR2B,6BAA6B,EAAE,EAC/BlD,8BAA8B,EAAE,EAChCuE,4BAA4B/C,mBAAmB,EAAE,EAC3B;IACtB,MAAMiD,kBAAkBnG,yBAAyB4E,4BAA4BlD;IAC7E,MAAMmD,cAAczE,uBAAuB+F;IAC3C,MAAM,CAACvF,MAAM,GAAG7B,SAAS,IACvB4F,8BAA8B;YAAEC;YAA4BlD;YAA6BmD;QAAY;IAGvG,qBACE,KAACxE,+BAA+BoE,QAAQ;QAACvD,OAAON;kBAC9C,cAAA,KAACoC;YAAeE,kBAAkBA;sBAAmBD;;;AAG3D"}
|
|
@@ -72,11 +72,11 @@ function convertPanelGroupsToLayouts(panelGroups, panelGroupOrder) {
|
|
|
72
72
|
if (group === undefined) {
|
|
73
73
|
throw new Error('panel group not found');
|
|
74
74
|
}
|
|
75
|
-
const { title, isCollapsed, itemLayouts, itemPanelKeys } = group;
|
|
75
|
+
const { title, isCollapsed, repeatVariable, itemLayouts, itemPanelKeys } = group;
|
|
76
76
|
let display = undefined;
|
|
77
|
-
if (title) {
|
|
77
|
+
if (title || isCollapsed !== undefined) {
|
|
78
78
|
display = {
|
|
79
|
-
title,
|
|
79
|
+
title: title ?? '',
|
|
80
80
|
collapse: {
|
|
81
81
|
open: !isCollapsed
|
|
82
82
|
}
|
|
@@ -98,7 +98,8 @@ function convertPanelGroupsToLayouts(panelGroups, panelGroupOrder) {
|
|
|
98
98
|
height: layout.h,
|
|
99
99
|
content: createPanelRef(panelKey)
|
|
100
100
|
};
|
|
101
|
-
})
|
|
101
|
+
}),
|
|
102
|
+
repeatVariable: repeatVariable
|
|
102
103
|
}
|
|
103
104
|
};
|
|
104
105
|
layouts.push(layout);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/context/useDashboard.tsx"],"sourcesContent":["// Copyright 2024 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 {\n createPanelRef,\n DashboardResource,\n EphemeralDashboardResource,\n GridDefinition,\n PanelGroupId,\n} from '@perses-dev/core';\nimport { PanelGroupDefinition, useDashboardStore } from './DashboardProvider';\nimport { useVariableDefinitionActions, useVariableDefinitions } from './VariableProvider';\n\nexport function useDashboard(): {\n dashboard: DashboardResource | EphemeralDashboardResource;\n setDashboard: (dashboardResource: DashboardResource | EphemeralDashboardResource) => void;\n} {\n const {\n panels,\n panelGroups,\n panelGroupOrder,\n setDashboard: setDashboardResource,\n kind,\n metadata,\n display,\n duration,\n refreshInterval,\n datasources,\n ttl,\n } = useDashboardStore(\n ({\n panels,\n panelGroups,\n panelGroupOrder,\n setDashboard,\n kind,\n metadata,\n display,\n duration,\n refreshInterval,\n datasources,\n ttl,\n }) => ({\n panels,\n panelGroups,\n panelGroupOrder,\n setDashboard,\n kind,\n metadata,\n display,\n duration,\n refreshInterval,\n datasources,\n ttl,\n })\n );\n const { setVariableDefinitions } = useVariableDefinitionActions();\n const variables = useVariableDefinitions();\n const layouts = convertPanelGroupsToLayouts(panelGroups, panelGroupOrder);\n\n const dashboard =\n kind === 'Dashboard'\n ? ({\n kind,\n metadata,\n spec: {\n display,\n panels,\n layouts,\n variables,\n duration,\n refreshInterval,\n datasources,\n },\n } as DashboardResource)\n : ({\n kind,\n metadata,\n spec: {\n display,\n panels,\n layouts,\n variables,\n duration,\n refreshInterval,\n datasources,\n ttl,\n },\n } as EphemeralDashboardResource);\n\n const setDashboard = (dashboardResource: DashboardResource | EphemeralDashboardResource): void => {\n setVariableDefinitions(dashboardResource.spec.variables);\n setDashboardResource(dashboardResource);\n };\n\n return {\n dashboard,\n setDashboard,\n };\n}\n\nfunction convertPanelGroupsToLayouts(\n panelGroups: Record<number, PanelGroupDefinition>,\n panelGroupOrder: PanelGroupId[]\n): GridDefinition[] {\n const layouts: GridDefinition[] = [];\n panelGroupOrder.map((groupOrderId) => {\n const group = panelGroups[groupOrderId];\n if (group === undefined) {\n throw new Error('panel group not found');\n }\n const { title, isCollapsed, itemLayouts, itemPanelKeys } = group;\n let display = undefined;\n if (title) {\n display = {\n title,\n collapse: {\n open: !isCollapsed,\n },\n };\n }\n const layout: GridDefinition = {\n kind: 'Grid',\n spec: {\n display,\n items: itemLayouts.map((layout) => {\n const panelKey = itemPanelKeys[layout.i];\n if (panelKey === undefined) {\n throw new Error(`Missing panel key of layout ${layout.i}`);\n }\n return {\n x: layout.x,\n y: layout.y,\n width: layout.w,\n height: layout.h,\n content: createPanelRef(panelKey),\n };\n }),\n },\n };\n layouts.push(layout);\n });\n\n return layouts;\n}\n"],"names":["createPanelRef","useDashboardStore","useVariableDefinitionActions","useVariableDefinitions","useDashboard","panels","panelGroups","panelGroupOrder","setDashboard","setDashboardResource","kind","metadata","display","duration","refreshInterval","datasources","ttl","setVariableDefinitions","variables","layouts","convertPanelGroupsToLayouts","dashboard","spec","dashboardResource","map","groupOrderId","group","undefined","Error","title","isCollapsed","itemLayouts","itemPanelKeys","collapse","open","layout","items","panelKey","i","x","y","width","w","height","h","content","push"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AAC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AAM,IAAIC,MAAM;QAClB;QACA,MAAM,EAAEC,KAAK,EAAEC,WAAW,EAAEC,WAAW,EAAEC,aAAa,EAAE,
|
|
1
|
+
{"version":3,"sources":["../../src/context/useDashboard.tsx"],"sourcesContent":["// Copyright 2024 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 {\n createPanelRef,\n DashboardResource,\n EphemeralDashboardResource,\n GridDefinition,\n PanelGroupId,\n} from '@perses-dev/core';\nimport { PanelGroupDefinition, useDashboardStore } from './DashboardProvider';\nimport { useVariableDefinitionActions, useVariableDefinitions } from './VariableProvider';\n\nexport function useDashboard(): {\n dashboard: DashboardResource | EphemeralDashboardResource;\n setDashboard: (dashboardResource: DashboardResource | EphemeralDashboardResource) => void;\n} {\n const {\n panels,\n panelGroups,\n panelGroupOrder,\n setDashboard: setDashboardResource,\n kind,\n metadata,\n display,\n duration,\n refreshInterval,\n datasources,\n ttl,\n } = useDashboardStore(\n ({\n panels,\n panelGroups,\n panelGroupOrder,\n setDashboard,\n kind,\n metadata,\n display,\n duration,\n refreshInterval,\n datasources,\n ttl,\n }) => ({\n panels,\n panelGroups,\n panelGroupOrder,\n setDashboard,\n kind,\n metadata,\n display,\n duration,\n refreshInterval,\n datasources,\n ttl,\n })\n );\n const { setVariableDefinitions } = useVariableDefinitionActions();\n const variables = useVariableDefinitions();\n const layouts = convertPanelGroupsToLayouts(panelGroups, panelGroupOrder);\n\n const dashboard =\n kind === 'Dashboard'\n ? ({\n kind,\n metadata,\n spec: {\n display,\n panels,\n layouts,\n variables,\n duration,\n refreshInterval,\n datasources,\n },\n } as DashboardResource)\n : ({\n kind,\n metadata,\n spec: {\n display,\n panels,\n layouts,\n variables,\n duration,\n refreshInterval,\n datasources,\n ttl,\n },\n } as EphemeralDashboardResource);\n\n const setDashboard = (dashboardResource: DashboardResource | EphemeralDashboardResource): void => {\n setVariableDefinitions(dashboardResource.spec.variables);\n setDashboardResource(dashboardResource);\n };\n\n return {\n dashboard,\n setDashboard,\n };\n}\n\nfunction convertPanelGroupsToLayouts(\n panelGroups: Record<number, PanelGroupDefinition>,\n panelGroupOrder: PanelGroupId[]\n): GridDefinition[] {\n const layouts: GridDefinition[] = [];\n panelGroupOrder.map((groupOrderId) => {\n const group = panelGroups[groupOrderId];\n if (group === undefined) {\n throw new Error('panel group not found');\n }\n const { title, isCollapsed, repeatVariable, itemLayouts, itemPanelKeys } = group;\n let display = undefined;\n if (title || isCollapsed !== undefined) {\n display = {\n title: title ?? '',\n collapse: {\n open: !isCollapsed,\n },\n };\n }\n const layout: GridDefinition = {\n kind: 'Grid',\n spec: {\n display,\n items: itemLayouts.map((layout) => {\n const panelKey = itemPanelKeys[layout.i];\n if (panelKey === undefined) {\n throw new Error(`Missing panel key of layout ${layout.i}`);\n }\n return {\n x: layout.x,\n y: layout.y,\n width: layout.w,\n height: layout.h,\n content: createPanelRef(panelKey),\n };\n }),\n repeatVariable: repeatVariable,\n },\n };\n layouts.push(layout);\n });\n\n return layouts;\n}\n"],"names":["createPanelRef","useDashboardStore","useVariableDefinitionActions","useVariableDefinitions","useDashboard","panels","panelGroups","panelGroupOrder","setDashboard","setDashboardResource","kind","metadata","display","duration","refreshInterval","datasources","ttl","setVariableDefinitions","variables","layouts","convertPanelGroupsToLayouts","dashboard","spec","dashboardResource","map","groupOrderId","group","undefined","Error","title","isCollapsed","repeatVariable","itemLayouts","itemPanelKeys","collapse","open","layout","items","panelKey","i","x","y","width","w","height","h","content","push"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAA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vB,MAAM,IAAIC,MAAM;QAClB;QACA,MAAM,EAAEC,KAAK,EAAEC,WAAW,EAAEC,cAAc,EAAEC,WAAW,EAAEC,aAAa,EAAE,GAAGP;QAC3E,IAAId,UAAUe;QACd,IAAIE,SAASC,gBAAgBH,WAAW;YACtCf,UAAU;gBACRiB,OAAOA,SAAS;gBAChBK,UAAU;oBACRC,MAAM,CAACL;gBACT;YACF;QACF;QACA,MAAMM,SAAyB;YAC7B1B,MAAM;YACNY,MAAM;gBACJV;gBACAyB,OAAOL,YAAYR,GAAG,CAAC,CAACY;oBACtB,MAAME,WAAWL,aAAa,CAACG,OAAOG,CAAC,CAAC;oBACxC,IAAID,aAAaX,WAAW;wBAC1B,MAAM,IAAIC,MAAM,CAAC,4BAA4B,EAAEQ,OAAOG,CAAC,EAAE;oBAC3D;oBACA,OAAO;wBACLC,GAAGJ,OAAOI,CAAC;wBACXC,GAAGL,OAAOK,CAAC;wBACXC,OAAON,OAAOO,CAAC;wBACfC,QAAQR,OAAOS,CAAC;wBAChBC,SAAS9C,eAAesC;oBAC1B;gBACF;gBACAP,gBAAgBA;YAClB;QACF;QACAZ,QAAQ4B,IAAI,CAACX;IACf;IAEA,OAAOjB;AACT"}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
1
|
+
import { ReactElement, ReactNode } from 'react';
|
|
2
2
|
import { DashboardResource, EphemeralDashboardResource } from '@perses-dev/core';
|
|
3
3
|
import { EmptyDashboardProps } from '../../components';
|
|
4
4
|
import { OnSaveDashboard } from '../../context';
|
|
5
5
|
export interface DashboardAppProps {
|
|
6
|
-
emptyDashboardProps?: Partial<EmptyDashboardProps>;
|
|
7
6
|
dashboardResource: DashboardResource | EphemeralDashboardResource;
|
|
8
|
-
|
|
9
|
-
onSave?: OnSaveDashboard;
|
|
10
|
-
onDiscard?: (entity: DashboardResource) => void;
|
|
11
|
-
initialVariableIsSticky?: boolean;
|
|
7
|
+
emptyDashboardProps?: Partial<EmptyDashboardProps>;
|
|
12
8
|
isReadonly: boolean;
|
|
13
9
|
isVariableEnabled: boolean;
|
|
14
10
|
isDatasourceEnabled: boolean;
|
|
15
11
|
isCreating?: boolean;
|
|
12
|
+
isInitialVariableSticky?: boolean;
|
|
13
|
+
isLeavingConfirmDialogEnabled?: boolean;
|
|
14
|
+
dashboardTitleComponent?: ReactNode;
|
|
15
|
+
onSave?: OnSaveDashboard;
|
|
16
|
+
onDiscard?: (entity: DashboardResource) => void;
|
|
16
17
|
}
|
|
17
18
|
export declare const DashboardApp: (props: DashboardAppProps) => ReactElement;
|
|
18
19
|
//# sourceMappingURL=DashboardApp.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DashboardApp.d.ts","sourceRoot":"","sources":["../../../src/views/ViewDashboard/DashboardApp.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAY,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"DashboardApp.d.ts","sourceRoot":"","sources":["../../../src/views/ViewDashboard/DashboardApp.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAG1D,OAAO,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAEjF,OAAO,EAQL,mBAAmB,EAIpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAkE,MAAM,eAAe,CAAC;AAEhH,MAAM,WAAW,iBAAiB;IAChC,iBAAiB,EAAE,iBAAiB,GAAG,0BAA0B,CAAC;IAClE,mBAAmB,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACnD,UAAU,EAAE,OAAO,CAAC;IACpB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAElC,6BAA6B,CAAC,EAAE,OAAO,CAAC;IACxC,uBAAuB,CAAC,EAAE,SAAS,CAAC;IACpC,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,CAAC;CACjD;AAED,eAAO,MAAM,YAAY,UAAW,iBAAiB,KAAG,YA0GvD,CAAC"}
|
|
@@ -15,10 +15,10 @@ import { useState } from 'react';
|
|
|
15
15
|
import { Box } from '@mui/material';
|
|
16
16
|
import { ChartsProvider, ErrorAlert, ErrorBoundary, useChartsTheme } from '@perses-dev/components';
|
|
17
17
|
import { useDatasourceStore } from '@perses-dev/plugin-system';
|
|
18
|
-
import { PanelDrawer, Dashboard, PanelGroupDialog, DeletePanelGroupDialog, DashboardDiscardChangesConfirmationDialog, DashboardToolbar, DeletePanelDialog, EditJsonDialog, SaveChangesConfirmationDialog } from '../../components';
|
|
18
|
+
import { PanelDrawer, Dashboard, PanelGroupDialog, DeletePanelGroupDialog, DashboardDiscardChangesConfirmationDialog, DashboardToolbar, DeletePanelDialog, EditJsonDialog, SaveChangesConfirmationDialog, LeaveDialog } from '../../components';
|
|
19
19
|
import { useDashboard, useDiscardChangesConfirmationDialog, useEditMode } from '../../context';
|
|
20
20
|
export const DashboardApp = (props)=>{
|
|
21
|
-
const { dashboardResource,
|
|
21
|
+
const { dashboardResource, emptyDashboardProps, isReadonly, isVariableEnabled, isDatasourceEnabled, isCreating, isInitialVariableSticky, isLeavingConfirmDialogEnabled, dashboardTitleComponent, onSave, onDiscard } = props;
|
|
22
22
|
const chartsTheme = useChartsTheme();
|
|
23
23
|
const { isEditMode, setEditMode } = useEditMode();
|
|
24
24
|
const { dashboard, setDashboard } = useDashboard();
|
|
@@ -68,7 +68,7 @@ export const DashboardApp = (props)=>{
|
|
|
68
68
|
/*#__PURE__*/ _jsx(DashboardToolbar, {
|
|
69
69
|
dashboardName: dashboardResource.metadata.name,
|
|
70
70
|
dashboardTitleComponent: dashboardTitleComponent,
|
|
71
|
-
initialVariableIsSticky:
|
|
71
|
+
initialVariableIsSticky: isInitialVariableSticky,
|
|
72
72
|
onSave: onSave,
|
|
73
73
|
isReadonly: isReadonly,
|
|
74
74
|
isVariableEnabled: isVariableEnabled,
|
|
@@ -106,7 +106,11 @@ export const DashboardApp = (props)=>{
|
|
|
106
106
|
isReadonly: !isEditMode,
|
|
107
107
|
disableMetadataEdition: !isCreating
|
|
108
108
|
}),
|
|
109
|
-
/*#__PURE__*/ _jsx(SaveChangesConfirmationDialog, {})
|
|
109
|
+
/*#__PURE__*/ _jsx(SaveChangesConfirmationDialog, {}),
|
|
110
|
+
isLeavingConfirmDialogEnabled && isEditMode && /*#__PURE__*/ _jsx(LeaveDialog, {
|
|
111
|
+
original: originalDashboard,
|
|
112
|
+
current: dashboard
|
|
113
|
+
})
|
|
110
114
|
]
|
|
111
115
|
})
|
|
112
116
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/views/ViewDashboard/DashboardApp.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ReactElement, useState } from 'react';\nimport { Box } from '@mui/material';\nimport { ChartsProvider, ErrorAlert, ErrorBoundary, useChartsTheme } from '@perses-dev/components';\nimport { DashboardResource, EphemeralDashboardResource } from '@perses-dev/core';\nimport { useDatasourceStore } from '@perses-dev/plugin-system';\nimport {\n PanelDrawer,\n Dashboard,\n PanelGroupDialog,\n DeletePanelGroupDialog,\n DashboardDiscardChangesConfirmationDialog,\n DashboardToolbar,\n DeletePanelDialog,\n EmptyDashboardProps,\n EditJsonDialog,\n SaveChangesConfirmationDialog,\n} from '../../components';\nimport { OnSaveDashboard, useDashboard, useDiscardChangesConfirmationDialog, useEditMode } from '../../context';\n\nexport interface DashboardAppProps {\n emptyDashboardProps?: Partial<EmptyDashboardProps>;\n
|
|
1
|
+
{"version":3,"sources":["../../../src/views/ViewDashboard/DashboardApp.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ReactElement, ReactNode, useState } from 'react';\nimport { Box } from '@mui/material';\nimport { ChartsProvider, ErrorAlert, ErrorBoundary, useChartsTheme } from '@perses-dev/components';\nimport { DashboardResource, EphemeralDashboardResource } from '@perses-dev/core';\nimport { useDatasourceStore } from '@perses-dev/plugin-system';\nimport {\n PanelDrawer,\n Dashboard,\n PanelGroupDialog,\n DeletePanelGroupDialog,\n DashboardDiscardChangesConfirmationDialog,\n DashboardToolbar,\n DeletePanelDialog,\n EmptyDashboardProps,\n EditJsonDialog,\n SaveChangesConfirmationDialog,\n LeaveDialog,\n} from '../../components';\nimport { OnSaveDashboard, useDashboard, useDiscardChangesConfirmationDialog, useEditMode } from '../../context';\n\nexport interface DashboardAppProps {\n dashboardResource: DashboardResource | EphemeralDashboardResource;\n emptyDashboardProps?: Partial<EmptyDashboardProps>;\n isReadonly: boolean;\n isVariableEnabled: boolean;\n isDatasourceEnabled: boolean;\n isCreating?: boolean;\n isInitialVariableSticky?: boolean;\n // If true, browser confirmation dialog will be shown when navigating away with unsaved changes (closing tab, ...).\n isLeavingConfirmDialogEnabled?: boolean;\n dashboardTitleComponent?: ReactNode;\n onSave?: OnSaveDashboard;\n onDiscard?: (entity: DashboardResource) => void;\n}\n\nexport const DashboardApp = (props: DashboardAppProps): ReactElement => {\n const {\n dashboardResource,\n emptyDashboardProps,\n isReadonly,\n isVariableEnabled,\n isDatasourceEnabled,\n isCreating,\n isInitialVariableSticky,\n isLeavingConfirmDialogEnabled,\n dashboardTitleComponent,\n onSave,\n onDiscard,\n } = props;\n\n const chartsTheme = useChartsTheme();\n\n const { isEditMode, setEditMode } = useEditMode();\n const { dashboard, setDashboard } = useDashboard();\n const [originalDashboard, setOriginalDashboard] = useState<\n DashboardResource | EphemeralDashboardResource | undefined\n >(undefined);\n const { setSavedDatasources } = useDatasourceStore();\n\n const { openDiscardChangesConfirmationDialog, closeDiscardChangesConfirmationDialog } =\n useDiscardChangesConfirmationDialog();\n\n const handleDiscardChanges = (): void => {\n // Reset to the original spec and exit edit mode\n if (originalDashboard) {\n setDashboard(originalDashboard);\n }\n setEditMode(false);\n closeDiscardChangesConfirmationDialog();\n if (onDiscard) {\n onDiscard(dashboard as unknown as DashboardResource);\n }\n };\n\n const onEditButtonClick = (): void => {\n setEditMode(true);\n setOriginalDashboard(dashboard);\n setSavedDatasources(dashboard.spec.datasources ?? {});\n };\n\n const onCancelButtonClick = (): void => {\n // check if dashboard has been modified\n if (JSON.stringify(dashboard) === JSON.stringify(originalDashboard)) {\n setEditMode(false);\n } else {\n openDiscardChangesConfirmationDialog({\n onDiscardChanges: () => {\n handleDiscardChanges();\n },\n onCancel: () => {\n closeDiscardChangesConfirmationDialog();\n },\n });\n }\n };\n\n return (\n <Box\n sx={{\n flexGrow: 1,\n overflowX: 'hidden',\n overflowY: 'auto',\n display: 'flex',\n flexDirection: 'column',\n }}\n >\n <DashboardToolbar\n dashboardName={dashboardResource.metadata.name}\n dashboardTitleComponent={dashboardTitleComponent}\n initialVariableIsSticky={isInitialVariableSticky}\n onSave={onSave}\n isReadonly={isReadonly}\n isVariableEnabled={isVariableEnabled}\n isDatasourceEnabled={isDatasourceEnabled}\n onEditButtonClick={onEditButtonClick}\n onCancelButtonClick={onCancelButtonClick}\n />\n <Box sx={{ paddingTop: 2, paddingX: 2, height: '100%' }}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <Dashboard\n emptyDashboardProps={{\n onEditButtonClick,\n ...emptyDashboardProps,\n }}\n />\n </ErrorBoundary>\n <ChartsProvider chartsTheme={chartsTheme} enablePinning={false} enableSyncGrouping={false}>\n <PanelDrawer />\n </ChartsProvider>\n <PanelGroupDialog />\n <DeletePanelGroupDialog />\n <DeletePanelDialog />\n <DashboardDiscardChangesConfirmationDialog />\n <EditJsonDialog isReadonly={!isEditMode} disableMetadataEdition={!isCreating} />\n <SaveChangesConfirmationDialog />\n {isLeavingConfirmDialogEnabled && isEditMode && (\n <LeaveDialog original={originalDashboard} current={dashboard} />\n )}\n </Box>\n </Box>\n );\n};\n"],"names":["useState","Box","ChartsProvider","ErrorAlert","ErrorBoundary","useChartsTheme","useDatasourceStore","PanelDrawer","Dashboard","PanelGroupDialog","DeletePanelGroupDialog","DashboardDiscardChangesConfirmationDialog","DashboardToolbar","DeletePanelDialog","EditJsonDialog","SaveChangesConfirmationDialog","LeaveDialog","useDashboard","useDiscardChangesConfirmationDialog","useEditMode","DashboardApp","props","dashboardResource","emptyDashboardProps","isReadonly","isVariableEnabled","isDatasourceEnabled","isCreating","isInitialVariableSticky","isLeavingConfirmDialogEnabled","dashboardTitleComponent","onSave","onDiscard","chartsTheme","isEditMode","setEditMode","dashboard","setDashboard","originalDashboard","setOriginalDashboard","undefined","setSavedDatasources","openDiscardChangesConfirmationDialog","closeDiscardChangesConfirmationDialog","handleDiscardChanges","onEditButtonClick","spec","datasources","onCancelButtonClick","JSON","stringify","onDiscardChanges","onCancel","sx","flexGrow","overflowX","overflowY","display","flexDirection","dashboardName","metadata","name","initialVariableIsSticky","paddingTop","paddingX","height","FallbackComponent","enablePinning","enableSyncGrouping","disableMetadataEdition","original","current"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEA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I,qBAAqBH;QACrBK,oBAAoBL,UAAUU,IAAI,CAACC,WAAW,IAAI,CAAC;IACrD;IAEA,MAAMC,sBAAsB;QAC1B,uCAAuC;QACvC,IAAIC,KAAKC,SAAS,CAACd,eAAea,KAAKC,SAAS,CAACZ,oBAAoB;YACnEH,YAAY;QACd,OAAO;YACLO,qCAAqC;gBACnCS,kBAAkB;oBAChBP;gBACF;gBACAQ,UAAU;oBACRT;gBACF;YACF;QACF;IACF;IAEA,qBACE,MAAC1C;QACCoD,IAAI;YACFC,UAAU;YACVC,WAAW;YACXC,WAAW;YACXC,SAAS;YACTC,eAAe;QACjB;;0BAEA,KAAC9C;gBACC+C,eAAerC,kBAAkBsC,QAAQ,CAACC,IAAI;gBAC9C/B,yBAAyBA;gBACzBgC,yBAAyBlC;gBACzBG,QAAQA;gBACRP,YAAYA;gBACZC,mBAAmBA;gBACnBC,qBAAqBA;gBACrBmB,mBAAmBA;gBACnBG,qBAAqBA;;0BAEvB,MAAC/C;gBAAIoD,IAAI;oBAAEU,YAAY;oBAAGC,UAAU;oBAAGC,QAAQ;gBAAO;;kCACpD,KAAC7D;wBAAc8D,mBAAmB/D;kCAChC,cAAA,KAACK;4BACCe,qBAAqB;gCACnBsB;gCACA,GAAGtB,mBAAmB;4BACxB;;;kCAGJ,KAACrB;wBAAe+B,aAAaA;wBAAakC,eAAe;wBAAOC,oBAAoB;kCAClF,cAAA,KAAC7D;;kCAEH,KAACE;kCACD,KAACC;kCACD,KAACG;kCACD,KAACF;kCACD,KAACG;wBAAeU,YAAY,CAACU;wBAAYmC,wBAAwB,CAAC1C;;kCAClE,KAACZ;oBACAc,iCAAiCK,4BAChC,KAAClB;wBAAYsD,UAAUhC;wBAAmBiC,SAASnC;;;;;;AAK7D,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViewDashboard.d.ts","sourceRoot":"","sources":["../../../src/views/ViewDashboard/ViewDashboard.tsx"],"names":[],"mappings":"AAaA,OAAO,EA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