@perses-dev/dashboards 0.0.0-snapshot-ts-panel-actions-90e9ef0 → 0.0.0-snapshot-reverse-proxy-75afbd7

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.
Files changed (194) hide show
  1. package/dist/cjs/components/DashboardStickyToolbar/DashboardStickyToolbar.js +0 -2
  2. package/dist/cjs/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +5 -20
  3. package/dist/cjs/components/GridLayout/GridItemContent.js +79 -17
  4. package/dist/cjs/components/GridLayout/GridLayout.js +78 -126
  5. package/dist/cjs/components/GridLayout/Row.js +150 -0
  6. package/dist/cjs/components/GridLayout/index.js +1 -0
  7. package/dist/cjs/components/LeaveDialog/LeaveDialog.js +81 -0
  8. package/dist/cjs/components/LeaveDialog/index.js +30 -0
  9. package/dist/cjs/components/Panel/Panel.js +90 -2
  10. package/dist/cjs/components/Panel/PanelActions.js +37 -11
  11. package/dist/cjs/components/Panel/PanelHeader.js +37 -16
  12. package/dist/cjs/components/Panel/index.js +1 -0
  13. package/dist/cjs/components/PanelDrawer/PanelDrawer.js +58 -21
  14. package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +202 -180
  15. package/dist/cjs/components/PanelDrawer/PanelPreview.js +3 -0
  16. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +9 -21
  17. package/dist/cjs/components/PanelGroupDialog/PanelGroupEditorForm.js +35 -15
  18. package/dist/cjs/components/QueryViewerDialog/QueryViewerDialog.js +121 -0
  19. package/dist/cjs/components/QueryViewerDialog/index.js +30 -0
  20. package/dist/cjs/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +2 -1
  21. package/dist/cjs/components/Variables/ListVariableListBox.js +201 -0
  22. package/dist/cjs/components/Variables/Variable.js +130 -72
  23. package/dist/cjs/components/Variables/VariableEditor.js +22 -15
  24. package/dist/cjs/components/Variables/index.js +1 -0
  25. package/dist/cjs/components/index.js +3 -1
  26. package/dist/cjs/constants/user-interface-text.js +4 -2
  27. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +7 -8
  28. package/dist/cjs/context/DashboardProvider/DashboardProviderWithQueryParams.js +4 -4
  29. package/dist/cjs/context/DashboardProvider/duplicate-panel-slice.js +1 -1
  30. package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +2 -2
  31. package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +6 -2
  32. package/dist/cjs/context/DashboardProvider/panel-group-slice.js +1 -0
  33. package/dist/cjs/context/DashboardProvider/view-panel-slice.js +10 -3
  34. package/dist/cjs/context/PanelEditorProvider/PanelEditorProvider.js +49 -0
  35. package/dist/cjs/context/PanelEditorProvider/index.js +23 -0
  36. package/dist/cjs/context/VariableProvider/VariableProvider.js +1 -1
  37. package/dist/cjs/context/index.js +1 -0
  38. package/dist/cjs/context/useDashboard.js +5 -4
  39. package/dist/cjs/views/ViewDashboard/DashboardApp.js +7 -3
  40. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +9 -8
  41. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.d.ts.map +1 -1
  42. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js +0 -2
  43. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js.map +1 -1
  44. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts +2 -2
  45. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
  46. package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
  47. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -1
  48. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +5 -15
  49. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js.map +1 -1
  50. package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
  51. package/dist/components/GridLayout/GridItemContent.js +39 -18
  52. package/dist/components/GridLayout/GridItemContent.js.map +1 -1
  53. package/dist/components/GridLayout/GridLayout.d.ts +8 -0
  54. package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
  55. package/dist/components/GridLayout/GridLayout.js +72 -126
  56. package/dist/components/GridLayout/GridLayout.js.map +1 -1
  57. package/dist/components/GridLayout/Row.d.ts +17 -0
  58. package/dist/components/GridLayout/Row.d.ts.map +1 -0
  59. package/dist/components/GridLayout/Row.js +142 -0
  60. package/dist/components/GridLayout/Row.js.map +1 -0
  61. package/dist/components/GridLayout/index.d.ts +1 -0
  62. package/dist/components/GridLayout/index.d.ts.map +1 -1
  63. package/dist/components/GridLayout/index.js +1 -0
  64. package/dist/components/GridLayout/index.js.map +1 -1
  65. package/dist/components/LeaveDialog/LeaveDialog.d.ts +13 -0
  66. package/dist/components/LeaveDialog/LeaveDialog.d.ts.map +1 -0
  67. package/dist/components/LeaveDialog/LeaveDialog.js +70 -0
  68. package/dist/components/LeaveDialog/LeaveDialog.js.map +1 -0
  69. package/dist/components/LeaveDialog/index.d.ts +2 -0
  70. package/dist/components/LeaveDialog/index.d.ts.map +1 -0
  71. package/dist/components/LeaveDialog/index.js +15 -0
  72. package/dist/components/LeaveDialog/index.js.map +1 -0
  73. package/dist/components/Panel/HeaderIconButton.d.ts +1 -1
  74. package/dist/components/Panel/Panel.d.ts +6 -0
  75. package/dist/components/Panel/Panel.d.ts.map +1 -1
  76. package/dist/components/Panel/Panel.js +92 -4
  77. package/dist/components/Panel/Panel.js.map +1 -1
  78. package/dist/components/Panel/PanelActions.d.ts +7 -1
  79. package/dist/components/Panel/PanelActions.d.ts.map +1 -1
  80. package/dist/components/Panel/PanelActions.js +37 -11
  81. package/dist/components/Panel/PanelActions.js.map +1 -1
  82. package/dist/components/Panel/PanelHeader.d.ts +8 -1
  83. package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
  84. package/dist/components/Panel/PanelHeader.js +38 -17
  85. package/dist/components/Panel/PanelHeader.js.map +1 -1
  86. package/dist/components/Panel/index.d.ts +1 -0
  87. package/dist/components/Panel/index.d.ts.map +1 -1
  88. package/dist/components/Panel/index.js +1 -0
  89. package/dist/components/Panel/index.js.map +1 -1
  90. package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
  91. package/dist/components/PanelDrawer/PanelDrawer.js +59 -22
  92. package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
  93. package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
  94. package/dist/components/PanelDrawer/PanelEditorForm.js +205 -183
  95. package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
  96. package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -1
  97. package/dist/components/PanelDrawer/PanelPreview.js +4 -1
  98. package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
  99. package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -1
  100. package/dist/components/PanelGroupDialog/PanelGroupDialog.js +8 -15
  101. package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
  102. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts +1 -0
  103. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts.map +1 -1
  104. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js +36 -16
  105. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js.map +1 -1
  106. package/dist/components/QueryViewerDialog/QueryViewerDialog.d.ts +9 -0
  107. package/dist/components/QueryViewerDialog/QueryViewerDialog.d.ts.map +1 -0
  108. package/dist/components/QueryViewerDialog/QueryViewerDialog.js +72 -0
  109. package/dist/components/QueryViewerDialog/QueryViewerDialog.js.map +1 -0
  110. package/dist/components/QueryViewerDialog/index.d.ts +2 -0
  111. package/dist/components/QueryViewerDialog/index.d.ts.map +1 -0
  112. package/dist/components/QueryViewerDialog/index.js +15 -0
  113. package/dist/components/QueryViewerDialog/index.js.map +1 -0
  114. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.d.ts.map +1 -1
  115. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +2 -1
  116. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +1 -1
  117. package/dist/components/Variables/ListVariableListBox.d.ts +16 -0
  118. package/dist/components/Variables/ListVariableListBox.d.ts.map +1 -0
  119. package/dist/components/Variables/ListVariableListBox.js +141 -0
  120. package/dist/components/Variables/ListVariableListBox.js.map +1 -0
  121. package/dist/components/Variables/Variable.d.ts.map +1 -1
  122. package/dist/components/Variables/Variable.js +134 -76
  123. package/dist/components/Variables/Variable.js.map +1 -1
  124. package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
  125. package/dist/components/Variables/VariableEditor.js +24 -17
  126. package/dist/components/Variables/VariableEditor.js.map +1 -1
  127. package/dist/components/Variables/index.d.ts +1 -0
  128. package/dist/components/Variables/index.d.ts.map +1 -1
  129. package/dist/components/Variables/index.js +1 -0
  130. package/dist/components/Variables/index.js.map +1 -1
  131. package/dist/components/index.d.ts +3 -1
  132. package/dist/components/index.d.ts.map +1 -1
  133. package/dist/components/index.js +3 -1
  134. package/dist/components/index.js.map +1 -1
  135. package/dist/constants/user-interface-text.d.ts +2 -0
  136. package/dist/constants/user-interface-text.d.ts.map +1 -1
  137. package/dist/constants/user-interface-text.js +4 -2
  138. package/dist/constants/user-interface-text.js.map +1 -1
  139. package/dist/context/DashboardProvider/DashboardProvider.d.ts +5 -5
  140. package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
  141. package/dist/context/DashboardProvider/DashboardProvider.js +7 -8
  142. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
  143. package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.d.ts.map +1 -1
  144. package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.js +5 -5
  145. package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.js.map +1 -1
  146. package/dist/context/DashboardProvider/common.d.ts +1 -1
  147. package/dist/context/DashboardProvider/common.d.ts.map +1 -1
  148. package/dist/context/DashboardProvider/common.js.map +1 -1
  149. package/dist/context/DashboardProvider/duplicate-panel-slice.js +2 -2
  150. package/dist/context/DashboardProvider/duplicate-panel-slice.js.map +1 -1
  151. package/dist/context/DashboardProvider/panel-editor-slice.d.ts +1 -0
  152. package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
  153. package/dist/context/DashboardProvider/panel-editor-slice.js +3 -3
  154. package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
  155. package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts +1 -0
  156. package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts.map +1 -1
  157. package/dist/context/DashboardProvider/panel-group-editor-slice.js +6 -2
  158. package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -1
  159. package/dist/context/DashboardProvider/panel-group-slice.d.ts +3 -0
  160. package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
  161. package/dist/context/DashboardProvider/panel-group-slice.js +1 -0
  162. package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
  163. package/dist/context/DashboardProvider/view-panel-slice.d.ts +6 -2
  164. package/dist/context/DashboardProvider/view-panel-slice.d.ts.map +1 -1
  165. package/dist/context/DashboardProvider/view-panel-slice.js +10 -3
  166. package/dist/context/DashboardProvider/view-panel-slice.js.map +1 -1
  167. package/dist/context/PanelEditorProvider/PanelEditorProvider.d.ts +13 -0
  168. package/dist/context/PanelEditorProvider/PanelEditorProvider.d.ts.map +1 -0
  169. package/dist/context/PanelEditorProvider/PanelEditorProvider.js +33 -0
  170. package/dist/context/PanelEditorProvider/PanelEditorProvider.js.map +1 -0
  171. package/dist/context/PanelEditorProvider/index.d.ts +3 -0
  172. package/dist/context/PanelEditorProvider/index.d.ts.map +1 -0
  173. package/dist/context/PanelEditorProvider/index.js +16 -0
  174. package/dist/context/PanelEditorProvider/index.js.map +1 -0
  175. package/dist/context/VariableProvider/VariableProvider.js +1 -1
  176. package/dist/context/VariableProvider/VariableProvider.js.map +1 -1
  177. package/dist/context/index.d.ts +1 -0
  178. package/dist/context/index.d.ts.map +1 -1
  179. package/dist/context/index.js +1 -0
  180. package/dist/context/index.js.map +1 -1
  181. package/dist/context/useDashboard.js +5 -4
  182. package/dist/context/useDashboard.js.map +1 -1
  183. package/dist/utils/panelUtils.d.ts +3 -0
  184. package/dist/utils/panelUtils.d.ts.map +1 -1
  185. package/dist/utils/panelUtils.js +3 -0
  186. package/dist/utils/panelUtils.js.map +1 -1
  187. package/dist/views/ViewDashboard/DashboardApp.d.ts +7 -6
  188. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
  189. package/dist/views/ViewDashboard/DashboardApp.js +8 -4
  190. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  191. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
  192. package/dist/views/ViewDashboard/ViewDashboard.js +9 -8
  193. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
  194. package/package.json +8 -8
@@ -2,4 +2,5 @@ export * from './GridContainer';
2
2
  export * from './GridItemContent';
3
3
  export * from './GridLayout';
4
4
  export * from './GridTitle';
5
+ export * from './Row';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/index.ts"],"names":[],"mappings":"AAaA,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/index.ts"],"names":[],"mappings":"AAaA,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC"}
@@ -14,5 +14,6 @@ export * from './GridContainer';
14
14
  export * from './GridItemContent';
15
15
  export * from './GridLayout';
16
16
  export * from './GridTitle';
17
+ export * from './Row';
17
18
 
18
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/GridLayout/index.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\nexport * from './GridContainer';\nexport * from './GridItemContent';\nexport * from './GridLayout';\nexport * from './GridTitle';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,kBAAkB;AAChC,cAAc,oBAAoB;AAClC,cAAc,eAAe;AAC7B,cAAc,cAAc"}
1
+ {"version":3,"sources":["../../../src/components/GridLayout/index.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\nexport * from './GridContainer';\nexport * from './GridItemContent';\nexport * from './GridLayout';\nexport * from './GridTitle';\nexport * from './Row';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,kBAAkB;AAChC,cAAc,oBAAoB;AAClC,cAAc,eAAe;AAC7B,cAAc,cAAc;AAC5B,cAAc,QAAQ"}
@@ -0,0 +1,13 @@
1
+ import { DashboardResource, EphemeralDashboardResource } from '@perses-dev/core';
2
+ import { ReactElement, ReactNode } from 'react';
3
+ import type { BlockerFunction } from '@remix-run/router';
4
+ export interface LeaveDialogProps {
5
+ isBlocked: BlockerFunction | boolean;
6
+ message: string;
7
+ }
8
+ export declare function Prompt({ isBlocked, message }: LeaveDialogProps): ReactElement;
9
+ export declare function LeaveDialog({ original, current, }: {
10
+ original: DashboardResource | EphemeralDashboardResource | undefined;
11
+ current: DashboardResource | EphemeralDashboardResource;
12
+ }): ReactNode;
13
+ //# sourceMappingURL=LeaveDialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LeaveDialog.d.ts","sourceRoot":"","sources":["../../../src/components/LeaveDialog/LeaveDialog.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,SAAS,EAAa,MAAM,OAAO,CAAC;AAG3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAQzD,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,eAAe,GAAG,OAAO,CAAC;IACrC,OAAO,EAAE,MAAM,CAAC;CACjB;AAMD,wBAAgB,MAAM,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,gBAAgB,GAAG,YAAY,CA4B7E;AAKD,wBAAgB,WAAW,CAAC,EAC1B,QAAQ,EACR,OAAO,GACR,EAAE;IACD,QAAQ,EAAE,iBAAiB,GAAG,0BAA0B,GAAG,SAAS,CAAC;IACrE,OAAO,EAAE,iBAAiB,GAAG,0BAA0B,CAAC;CACzD,GAAG,SAAS,CAYZ"}
@@ -0,0 +1,70 @@
1
+ // Copyright 2025 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { useEffect } from 'react';
15
+ import { useBlocker } from 'react-router-dom';
16
+ import { DiscardChangesConfirmationDialog } from '@perses-dev/components';
17
+ const handleRouteChange = (event)=>{
18
+ event.preventDefault();
19
+ event.returnValue = ''; // Required for Chrome
20
+ return ''; // Required for other browsers
21
+ };
22
+ /*
23
+ * Prompt component uses the useBlocker hook to block react-router navigation when there are unsaved changes.
24
+ * It also listens to the beforeunload event to show a browser confirmation dialog when the user tries to close the tab, refresh the page or change url manually.
25
+ */ export function Prompt({ isBlocked, message }) {
26
+ const blocker = useBlocker(isBlocked);
27
+ const isBlockedState = blocker.state === 'blocked';
28
+ const isProceedingState = blocker.state === 'proceeding';
29
+ useEffect(()=>{
30
+ if (isBlocked) {
31
+ window.addEventListener('beforeunload', handleRouteChange);
32
+ } else {
33
+ window.removeEventListener('beforeunload', handleRouteChange);
34
+ }
35
+ return ()=>{
36
+ window.removeEventListener('beforeunload', handleRouteChange);
37
+ };
38
+ }, [
39
+ blocker,
40
+ isBlocked,
41
+ isBlockedState
42
+ ]);
43
+ const handleDiscardChanges = ()=>blocker.proceed?.();
44
+ const handleCancel = ()=>blocker.reset?.();
45
+ return /*#__PURE__*/ _jsx(DiscardChangesConfirmationDialog, {
46
+ description: message,
47
+ isOpen: isBlockedState || isProceedingState,
48
+ onDiscardChanges: handleDiscardChanges,
49
+ onCancel: handleCancel
50
+ });
51
+ }
52
+ /*
53
+ * LeaveDialog prompts the user with a confirmation dialog when they attempt to leave the page with unsaved changes.
54
+ */ export function LeaveDialog({ original, current }) {
55
+ const handleIsBlocked = (ctx)=>{
56
+ if (JSON.stringify(original) !== JSON.stringify(current)) {
57
+ // Only block navigation if the pathname is changing (=> ignore search params changes)
58
+ if (ctx.currentLocation.pathname !== ctx.nextLocation.pathname) {
59
+ return true;
60
+ }
61
+ }
62
+ return false;
63
+ };
64
+ return /*#__PURE__*/ _jsx(Prompt, {
65
+ isBlocked: handleIsBlocked,
66
+ message: "You have unsaved changes, are you sure you want to leave?"
67
+ });
68
+ }
69
+
70
+ //# sourceMappingURL=LeaveDialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/LeaveDialog/LeaveDialog.tsx"],"sourcesContent":["// Copyright 2025 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 { DashboardResource, EphemeralDashboardResource } from '@perses-dev/core';\nimport { ReactElement, ReactNode, useEffect } from 'react';\nimport { useBlocker } from 'react-router-dom';\nimport { DiscardChangesConfirmationDialog } from '@perses-dev/components';\nimport type { BlockerFunction } from '@remix-run/router';\n\nconst handleRouteChange = (event: BeforeUnloadEvent): string => {\n event.preventDefault();\n event.returnValue = ''; // Required for Chrome\n return ''; // Required for other browsers\n};\n\nexport interface LeaveDialogProps {\n isBlocked: BlockerFunction | boolean;\n message: string;\n}\n\n/*\n * Prompt component uses the useBlocker hook to block react-router navigation when there are unsaved changes.\n * It also listens to the beforeunload event to show a browser confirmation dialog when the user tries to close the tab, refresh the page or change url manually.\n */\nexport function Prompt({ isBlocked, message }: LeaveDialogProps): ReactElement {\n const blocker = useBlocker(isBlocked);\n const isBlockedState = blocker.state === 'blocked';\n const isProceedingState = blocker.state === 'proceeding';\n\n useEffect(() => {\n if (isBlocked) {\n window.addEventListener('beforeunload', handleRouteChange);\n } else {\n window.removeEventListener('beforeunload', handleRouteChange);\n }\n\n return (): void => {\n window.removeEventListener('beforeunload', handleRouteChange);\n };\n }, [blocker, isBlocked, isBlockedState]);\n\n const handleDiscardChanges = (): void => blocker.proceed?.();\n const handleCancel = (): void => blocker.reset?.();\n\n return (\n <DiscardChangesConfirmationDialog\n description={message}\n isOpen={isBlockedState || isProceedingState}\n onDiscardChanges={handleDiscardChanges}\n onCancel={handleCancel}\n />\n );\n}\n\n/*\n * LeaveDialog prompts the user with a confirmation dialog when they attempt to leave the page with unsaved changes.\n */\nexport function LeaveDialog({\n original,\n current,\n}: {\n original: DashboardResource | EphemeralDashboardResource | undefined;\n current: DashboardResource | EphemeralDashboardResource;\n}): ReactNode {\n const handleIsBlocked: BlockerFunction = (ctx) => {\n if (JSON.stringify(original) !== JSON.stringify(current)) {\n // Only block navigation if the pathname is changing (=> ignore search params changes)\n if (ctx.currentLocation.pathname !== ctx.nextLocation.pathname) {\n return true;\n }\n }\n return false;\n };\n\n return <Prompt isBlocked={handleIsBlocked} message=\"You have unsaved changes, are you sure you want to leave?\" />;\n}\n"],"names":["useEffect","useBlocker","DiscardChangesConfirmationDialog","handleRouteChange","event","preventDefault","returnValue","Prompt","isBlocked","message","blocker","isBlockedState","state","isProceedingState","window","addEventListener","removeEventListener","handleDiscardChanges","proceed","handleCancel","reset","description","isOpen","onDiscardChanges","onCancel","LeaveDialog","original","current","handleIsBlocked","ctx","JSON","stringify","currentLocation","pathname","nextLocation"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE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og';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/LeaveDialog/index.ts"],"names":[],"mappings":"AAaA,cAAc,eAAe,CAAC"}
@@ -0,0 +1,15 @@
1
+ // Copyright 2025 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ export * from './LeaveDialog';
14
+
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/LeaveDialog/index.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './LeaveDialog';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,gBAAgB"}
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  export declare const HeaderIconButton: import("@emotion/styled").StyledComponent<import("@mui/material").IconButtonOwnProps & Omit<import("@mui/material").ButtonBaseOwnProps, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
3
3
  ref?: ((instance: HTMLButtonElement | null) => void) | import("react").RefObject<HTMLButtonElement> | null | undefined;
4
- }, "className" | "style" | "tabIndex" | "color" | "children" | "classes" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "TouchRippleProps" | "touchRippleRef" | "disableFocusRipple" | "loading" | "loadingIndicator" | "size" | "edge"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
4
+ }, "color" | "children" | "className" | "style" | "classes" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "tabIndex" | "TouchRippleProps" | "touchRippleRef" | "disableFocusRipple" | "loading" | "loadingIndicator" | "size" | "edge"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
5
5
  //# sourceMappingURL=HeaderIconButton.d.ts.map
@@ -9,6 +9,7 @@ export interface PanelProps extends CardProps<'section'> {
9
9
  editHandlers?: PanelHeaderProps['editHandlers'];
10
10
  panelOptions?: PanelOptions;
11
11
  panelGroupItemId?: PanelGroupItemId;
12
+ viewQueriesHandler?: PanelHeaderProps['viewQueriesHandler'];
12
13
  }
13
14
  export type PanelOptions = {
14
15
  /**
@@ -16,6 +17,11 @@ export type PanelOptions = {
16
17
  * This can be useful in embedded mode for example.
17
18
  */
18
19
  hideHeader?: boolean;
20
+ /**
21
+ * Whether to show panel icons always, or only when hovering over the panel.
22
+ * Default: if the dashboard is in editing mode or the panel is in fullscreen mode: 'always', otherwise 'hover'
23
+ */
24
+ showIcons?: 'always' | 'hover';
19
25
  /**
20
26
  * Content to render in right of the panel header. (top right of the panel)
21
27
  * It will only be rendered when the panel is in edit mode.
@@ -1 +1 @@
1
- {"version":3,"file":"Panel.d.ts","sourceRoot":"","sources":["../../../src/components/Panel/Panel.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAqB,SAAS,EAAE,MAAM,eAAe,CAAC;AAE7D,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAE,SAAS,EAA2B,MAAM,OAAO,CAAC;AAE3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,EAAe,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAE9D,MAAM,WAAW,UAAW,SAAQ,SAAS,CAAC,SAAS,CAAC;IACtD,UAAU,EAAE,eAAe,CAAC;IAC5B,YAAY,CAAC,EAAE,gBAAgB,CAAC,cAAc,CAAC,CAAC;IAChD,YAAY,CAAC,EAAE,gBAAgB,CAAC,cAAc,CAAC,CAAC;IAChD,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC;AAED,MAAM,MAAM,YAAY,GAAG;IACzB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,SAAS,CAAC;CAC/C,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B;;OAEG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC;;OAEG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,kDAmGhB,CAAC"}
1
+ {"version":3,"file":"Panel.d.ts","sourceRoot":"","sources":["../../../src/components/Panel/Panel.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAqB,SAAS,EAAE,MAAM,eAAe,CAAC;AAE7D,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAsC,MAAM,OAAO,CAAC;AAEtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,EAAe,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAE9D,MAAM,WAAW,UAAW,SAAQ,SAAS,CAAC,SAAS,CAAC;IACtD,UAAU,EAAE,eAAe,CAAC;IAC5B,YAAY,CAAC,EAAE,gBAAgB,CAAC,cAAc,CAAC,CAAC;IAChD,YAAY,CAAC,EAAE,gBAAgB,CAAC,cAAc,CAAC,CAAC;IAChD,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,kBAAkB,CAAC,EAAE,gBAAgB,CAAC,oBAAoB,CAAC,CAAC;CAC7D;AAED,MAAM,MAAM,YAAY,GAAG;IACzB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,SAAS,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;IAC/B;;;OAGG;IACH,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,SAAS,CAAC;CAC/C,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B;;OAEG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC;;OAEG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,kDAyMhB,CAAC"}
@@ -13,8 +13,8 @@
13
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  import { Card, CardContent } from '@mui/material';
15
15
  import { ErrorAlert, ErrorBoundary, combineSx, useChartsTheme, useId } from '@perses-dev/components';
16
- import { useDataQueriesContext } from '@perses-dev/plugin-system';
17
- import { memo, useMemo, useState } from 'react';
16
+ import { useDataQueriesContext, usePluginRegistry } from '@perses-dev/plugin-system';
17
+ import { memo, useMemo, useState, useEffect } from 'react';
18
18
  import useResizeObserver from 'use-resize-observer';
19
19
  import { PanelContent } from './PanelContent';
20
20
  import { PanelHeader } from './PanelHeader';
@@ -26,7 +26,7 @@ import { PanelHeader } from './PanelHeader';
26
26
  * <PanelContent> // renders loading, error or panel based on the queries' status
27
27
  * <PanelPluginLoader> // loads a panel plugin from the plugin registry and renders the PanelComponent with data from props.queryResults
28
28
  */ export const Panel = /*#__PURE__*/ memo(function Panel(props) {
29
- const { definition, readHandlers, editHandlers, onMouseEnter, onMouseLeave, sx, panelOptions, panelGroupItemId, ...others } = props;
29
+ const { definition, readHandlers, editHandlers, onMouseEnter, onMouseLeave, sx, panelOptions, panelGroupItemId, viewQueriesHandler, ...others } = props;
30
30
  // Make sure we have an ID we can use for aria attributes
31
31
  const generatedPanelId = useId('Panel');
32
32
  const headerId = `${generatedPanelId}-header`;
@@ -46,12 +46,96 @@ import { PanelHeader } from './PanelHeader';
46
46
  ]);
47
47
  const chartsTheme = useChartsTheme();
48
48
  const { queryResults } = useDataQueriesContext();
49
+ const { getPlugin } = usePluginRegistry();
50
+ const panelPropsForActions = useMemo(()=>{
51
+ return {
52
+ spec: definition.spec.plugin.spec,
53
+ queryResults: queryResults.map((query)=>({
54
+ definition: query.definition,
55
+ data: query.data
56
+ })),
57
+ contentDimensions,
58
+ definition
59
+ };
60
+ }, [
61
+ definition,
62
+ contentDimensions,
63
+ queryResults
64
+ ]);
65
+ // Load plugin actions from the plugin
66
+ const [pluginActions, setPluginActions] = useState([]);
67
+ useEffect(()=>{
68
+ let cancelled = false;
69
+ const loadPluginActions = async ()=>{
70
+ const panelPluginKind = definition.spec.plugin.kind;
71
+ const panelProps = panelPropsForActions;
72
+ if (!panelPluginKind || !panelProps) {
73
+ if (!cancelled) {
74
+ setPluginActions([]);
75
+ }
76
+ return;
77
+ }
78
+ try {
79
+ // Add defensive check for getPlugin availability
80
+ if (!getPlugin || typeof getPlugin !== 'function') {
81
+ if (!cancelled) {
82
+ setPluginActions([]);
83
+ }
84
+ return;
85
+ }
86
+ const plugin = await getPlugin('Panel', panelPluginKind);
87
+ if (cancelled) return;
88
+ // More defensive checking for plugin and actions
89
+ if (!plugin || typeof plugin !== 'object' || !plugin.actions || !Array.isArray(plugin.actions) || plugin.actions.length === 0) {
90
+ if (!cancelled) {
91
+ setPluginActions([]);
92
+ }
93
+ return;
94
+ }
95
+ // Render plugin actions in header location
96
+ const headerActions = plugin.actions.filter((action)=>!action.location || action.location === 'header').map((action, index)=>{
97
+ const ActionComponent = action.component;
98
+ try {
99
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
100
+ return /*#__PURE__*/ _jsx(ActionComponent, {
101
+ ...panelProps
102
+ }, `plugin-action-${index}`);
103
+ } catch (error) {
104
+ console.warn(`Failed to render plugin action ${index}:`, error);
105
+ return null;
106
+ }
107
+ }).filter((item)=>Boolean(item));
108
+ if (!cancelled) {
109
+ setPluginActions(headerActions);
110
+ }
111
+ } catch (error) {
112
+ if (!cancelled) {
113
+ console.warn('Failed to load plugin actions:', error);
114
+ setPluginActions([]);
115
+ }
116
+ }
117
+ };
118
+ // Use setTimeout to defer the async operation to the next tick
119
+ const timeoutId = setTimeout(()=>{
120
+ loadPluginActions();
121
+ }, 0);
122
+ return ()=>{
123
+ cancelled = true;
124
+ clearTimeout(timeoutId);
125
+ };
126
+ }, [
127
+ definition.spec.plugin.kind,
128
+ panelPropsForActions,
129
+ getPlugin
130
+ ]);
49
131
  const handleMouseEnter = (e)=>{
50
132
  onMouseEnter?.(e);
51
133
  };
52
134
  const handleMouseLeave = (e)=>{
53
135
  onMouseLeave?.(e);
54
136
  };
137
+ // default value for showIcons: if the dashboard is in editing mode or the panel is in fullscreen mode: 'always', otherwise 'hover'
138
+ const showIcons = panelOptions?.showIcons ?? (editHandlers || readHandlers?.isPanelViewed ? 'always' : 'hover');
55
139
  return /*#__PURE__*/ _jsxs(Card, {
56
140
  component: "section",
57
141
  sx: combineSx({
@@ -82,10 +166,14 @@ import { PanelHeader } from './PanelHeader';
82
166
  queryResults: queryResults,
83
167
  readHandlers: readHandlers,
84
168
  editHandlers: editHandlers,
169
+ viewQueriesHandler: viewQueriesHandler,
85
170
  links: definition.spec.links,
171
+ pluginActions: pluginActions,
172
+ showIcons: showIcons,
86
173
  sx: {
87
174
  paddingX: `${chartsTheme.container.padding.default}px`
88
- }
175
+ },
176
+ dimension: contentDimensions
89
177
  }),
90
178
  /*#__PURE__*/ _jsx(CardContent, {
91
179
  component: "figure",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Panel/Panel.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 { Card, CardContent, CardProps } from '@mui/material';\nimport { ErrorAlert, ErrorBoundary, combineSx, useChartsTheme, useId } from '@perses-dev/components';\nimport { PanelDefinition } from '@perses-dev/core';\nimport { useDataQueriesContext } from '@perses-dev/plugin-system';\nimport { ReactNode, memo, useMemo, useState } from 'react';\nimport useResizeObserver from 'use-resize-observer';\nimport { PanelGroupItemId } from '../../context';\nimport { PanelContent } from './PanelContent';\nimport { PanelHeader, PanelHeaderProps } from './PanelHeader';\n\nexport interface PanelProps extends CardProps<'section'> {\n definition: PanelDefinition;\n readHandlers?: PanelHeaderProps['readHandlers'];\n editHandlers?: PanelHeaderProps['editHandlers'];\n panelOptions?: PanelOptions;\n panelGroupItemId?: PanelGroupItemId;\n}\n\nexport type PanelOptions = {\n /**\n * Allow you to hide the panel header if desired.\n * This can be useful in embedded mode for example.\n */\n hideHeader?: boolean;\n /**\n * Content to render in right of the panel header. (top right of the panel)\n * It will only be rendered when the panel is in edit mode.\n */\n extra?: (props: PanelExtraProps) => ReactNode;\n};\n\nexport type PanelExtraProps = {\n /**\n * The PanelDefinition for the panel.\n */\n panelDefinition?: PanelDefinition;\n /**\n * The PanelGroupItemId for the panel.\n */\n panelGroupItemId?: PanelGroupItemId;\n};\n\n/**\n * Renders a PanelDefinition's content inside of a Card.\n *\n * Internal structure:\n * <Panel> // renders an entire panel, incl. header and action buttons\n * <PanelContent> // renders loading, error or panel based on the queries' status\n * <PanelPluginLoader> // loads a panel plugin from the plugin registry and renders the PanelComponent with data from props.queryResults\n */\nexport const Panel = memo(function Panel(props: PanelProps) {\n const {\n definition,\n readHandlers,\n editHandlers,\n onMouseEnter,\n onMouseLeave,\n sx,\n panelOptions,\n panelGroupItemId,\n ...others\n } = props;\n\n // Make sure we have an ID we can use for aria attributes\n const generatedPanelId = useId('Panel');\n const headerId = `${generatedPanelId}-header`;\n\n const [contentElement, setContentElement] = useState<HTMLElement | null>(null);\n\n const { width, height } = useResizeObserver({ ref: contentElement });\n\n const contentDimensions = useMemo(() => {\n if (width === undefined || height === undefined) return undefined;\n return { width, height };\n }, [width, height]);\n\n const chartsTheme = useChartsTheme();\n\n const { queryResults } = useDataQueriesContext();\n\n const handleMouseEnter: CardProps['onMouseEnter'] = (e) => {\n onMouseEnter?.(e);\n };\n\n const handleMouseLeave: CardProps['onMouseLeave'] = (e) => {\n onMouseLeave?.(e);\n };\n\n return (\n <Card\n component=\"section\"\n sx={combineSx(\n {\n width: '100%',\n height: '100%',\n display: 'flex',\n flexFlow: 'column nowrap',\n ':hover': { '--panel-hover': 'block' },\n },\n sx\n )}\n variant=\"outlined\"\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n aria-labelledby={headerId}\n aria-describedby={headerId}\n data-testid=\"panel\"\n {...others}\n >\n {!panelOptions?.hideHeader && (\n <PanelHeader\n extra={panelOptions?.extra?.({ panelDefinition: definition, panelGroupItemId })}\n id={headerId}\n title={definition.spec.display.name}\n description={definition.spec.display.description}\n queryResults={queryResults}\n readHandlers={readHandlers}\n editHandlers={editHandlers}\n links={definition.spec.links}\n sx={{ paddingX: `${chartsTheme.container.padding.default}px` }}\n />\n )}\n <CardContent\n component=\"figure\"\n sx={{\n position: 'relative',\n overflow: 'hidden',\n flexGrow: 1,\n margin: 0,\n padding: 0,\n // Override MUI default style for last-child\n ':last-child': {\n padding: 0,\n },\n }}\n ref={setContentElement}\n >\n <ErrorBoundary FallbackComponent={ErrorAlert} resetKeys={[definition.spec, queryResults]}>\n <PanelContent\n definition={definition}\n panelPluginKind={definition.spec.plugin.kind}\n spec={definition.spec.plugin.spec}\n contentDimensions={contentDimensions}\n queryResults={queryResults}\n />\n </ErrorBoundary>\n </CardContent>\n </Card>\n );\n});\n"],"names":["Card","CardContent","ErrorAlert","ErrorBoundary","combineSx","useChartsTheme","useId","useDataQueriesContext","memo","useMemo","useState","useResizeObserver","PanelContent","PanelHeader","Panel","props","definition","readHandlers","editHandlers","onMouseEnter","onMouseLeave","sx","panelOptions","panelGroupItemId","others","generatedPanelId","headerId","contentElement","setContentElement","width","height","ref","contentDimensions","undefined","chartsTheme","queryResults","handleMouseEnter","e","handleMouseLeave","component","display","flexFlow","variant","aria-labelledby","aria-describedby","data-testid","hideHeader","extra","panelDefinition","id","title","spec","name","description","links","paddingX","container","padding","default","position","overflow","flexGrow","margin","FallbackComponent","resetKeys","panelPluginKind","plugin","kind"],"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,IAAI,EAAEC,WAAW,QAAmB,gBAAgB;AAC7D,SAASC,UAAU,EAAEC,aAAa,EAAEC,SAAS,EAAEC,cAAc,EAAEC,KAAK,QAAQ,yBAAyB;AAErG,SAASC,qBAAqB,QAAQ,4BAA4B;AAClE,SAAoBC,IAAI,EAAEC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,iBAAiBhC;oBAAYO;gBAAiB;gBAC7E0B,IAAIvB;gBACJwB,OAAOlC,WAAWmC,IAAI,CAACX,OAAO,CAACY,IAAI;gBACnCC,aAAarC,WAAWmC,IAAI,CAACX,OAAO,CAACa,WAAW;gBAChDlB,cAAcA;gBACdlB,cAAcA;gBACdC,cAAcA;gBACdoC,OAAOtC,WAAWmC,IAAI,CAACG,KAAK;gBAC5BjC,IAAI;oBAAEkC,UAAU,GAAGrB,YAAYsB,SAAS,CAACC,OAAO,CAACC,OAAO,CAAC,EAAE,CAAC;gBAAC;;0BAGjE,KAACzD;gBACCsC,WAAU;gBACVlB,IAAI;oBACFsC,UAAU;oBACVC,UAAU;oBACVC,UAAU;oBACVC,QAAQ;oBACRL,SAAS;oBACT,4CAA4C;oBAC5C,eAAe;wBACbA,SAAS;oBACX;gBACF;gBACA1B,KAAKH;0BAEL,cAAA,KAACzB;oBAAc4D,mBAAmB7D;oBAAY8D,WAAW;wBAAChD,WAAWmC,IAAI;wBAAEhB;qBAAa;8BACtF,cAAA,KAACvB;wBACCI,YAAYA;wBACZiD,iBAAiBjD,WAAWmC,IAAI,CAACe,MAAM,CAACC,IAAI;wBAC5ChB,MAAMnC,WAAWmC,IAAI,CAACe,MAAM,CAACf,IAAI;wBACjCnB,mBAAmBA;wBACnBG,cAAcA;;;;;;AAM1B,GAAG"}
1
+ {"version":3,"sources":["../../../src/components/Panel/Panel.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 { Card, CardContent, CardProps } from '@mui/material';\nimport { ErrorAlert, ErrorBoundary, combineSx, useChartsTheme, useId } from '@perses-dev/components';\nimport { PanelDefinition } from '@perses-dev/core';\nimport { useDataQueriesContext, usePluginRegistry } from '@perses-dev/plugin-system';\nimport { ReactNode, memo, useMemo, useState, useEffect } from 'react';\nimport useResizeObserver from 'use-resize-observer';\nimport { PanelGroupItemId } from '../../context';\nimport { PanelContent } from './PanelContent';\nimport { PanelHeader, PanelHeaderProps } from './PanelHeader';\n\nexport interface PanelProps extends CardProps<'section'> {\n definition: PanelDefinition;\n readHandlers?: PanelHeaderProps['readHandlers'];\n editHandlers?: PanelHeaderProps['editHandlers'];\n panelOptions?: PanelOptions;\n panelGroupItemId?: PanelGroupItemId;\n viewQueriesHandler?: PanelHeaderProps['viewQueriesHandler'];\n}\n\nexport type PanelOptions = {\n /**\n * Allow you to hide the panel header if desired.\n * This can be useful in embedded mode for example.\n */\n hideHeader?: boolean;\n /**\n * Whether to show panel icons always, or only when hovering over the panel.\n * Default: if the dashboard is in editing mode or the panel is in fullscreen mode: 'always', otherwise 'hover'\n */\n showIcons?: 'always' | 'hover';\n /**\n * Content to render in right of the panel header. (top right of the panel)\n * It will only be rendered when the panel is in edit mode.\n */\n extra?: (props: PanelExtraProps) => ReactNode;\n};\n\nexport type PanelExtraProps = {\n /**\n * The PanelDefinition for the panel.\n */\n panelDefinition?: PanelDefinition;\n /**\n * The PanelGroupItemId for the panel.\n */\n panelGroupItemId?: PanelGroupItemId;\n};\n\n/**\n * Renders a PanelDefinition's content inside of a Card.\n *\n * Internal structure:\n * <Panel> // renders an entire panel, incl. header and action buttons\n * <PanelContent> // renders loading, error or panel based on the queries' status\n * <PanelPluginLoader> // loads a panel plugin from the plugin registry and renders the PanelComponent with data from props.queryResults\n */\nexport const Panel = memo(function Panel(props: PanelProps) {\n const {\n definition,\n readHandlers,\n editHandlers,\n onMouseEnter,\n onMouseLeave,\n sx,\n panelOptions,\n panelGroupItemId,\n viewQueriesHandler,\n ...others\n } = props;\n\n // Make sure we have an ID we can use for aria attributes\n const generatedPanelId = useId('Panel');\n const headerId = `${generatedPanelId}-header`;\n\n const [contentElement, setContentElement] = useState<HTMLElement | null>(null);\n\n const { width, height } = useResizeObserver({ ref: contentElement });\n\n const contentDimensions = useMemo(() => {\n if (width === undefined || height === undefined) return undefined;\n return { width, height };\n }, [width, height]);\n\n const chartsTheme = useChartsTheme();\n\n const { queryResults } = useDataQueriesContext();\n const { getPlugin } = usePluginRegistry();\n\n const panelPropsForActions = useMemo(() => {\n return {\n spec: definition.spec.plugin.spec,\n queryResults: queryResults.map((query) => ({\n definition: query.definition,\n data: query.data,\n })),\n contentDimensions,\n definition,\n };\n }, [definition, contentDimensions, queryResults]);\n\n // Load plugin actions from the plugin\n const [pluginActions, setPluginActions] = useState<ReactNode[]>([]);\n\n useEffect(() => {\n let cancelled = false;\n\n const loadPluginActions = async (): Promise<void> => {\n const panelPluginKind = definition.spec.plugin.kind;\n const panelProps = panelPropsForActions;\n\n if (!panelPluginKind || !panelProps) {\n if (!cancelled) {\n setPluginActions([]);\n }\n return;\n }\n\n try {\n // Add defensive check for getPlugin availability\n if (!getPlugin || typeof getPlugin !== 'function') {\n if (!cancelled) {\n setPluginActions([]);\n }\n return;\n }\n\n const plugin = await getPlugin('Panel', panelPluginKind);\n\n if (cancelled) return;\n\n // More defensive checking for plugin and actions\n if (\n !plugin ||\n typeof plugin !== 'object' ||\n !plugin.actions ||\n !Array.isArray(plugin.actions) ||\n plugin.actions.length === 0\n ) {\n if (!cancelled) {\n setPluginActions([]);\n }\n return;\n }\n\n // Render plugin actions in header location\n const headerActions = plugin.actions\n .filter((action) => !action.location || action.location === 'header')\n .map((action, index): ReactNode | null => {\n const ActionComponent = action.component;\n try {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return <ActionComponent key={`plugin-action-${index}`} {...(panelProps as any)} />;\n } catch (error) {\n console.warn(`Failed to render plugin action ${index}:`, error);\n return null;\n }\n })\n .filter((item): item is ReactNode => Boolean(item));\n\n if (!cancelled) {\n setPluginActions(headerActions);\n }\n } catch (error) {\n if (!cancelled) {\n console.warn('Failed to load plugin actions:', error);\n setPluginActions([]);\n }\n }\n };\n\n // Use setTimeout to defer the async operation to the next tick\n const timeoutId = setTimeout(() => {\n loadPluginActions();\n }, 0);\n\n return (): void => {\n cancelled = true;\n clearTimeout(timeoutId);\n };\n }, [definition.spec.plugin.kind, panelPropsForActions, getPlugin]);\n\n const handleMouseEnter: CardProps['onMouseEnter'] = (e) => {\n onMouseEnter?.(e);\n };\n\n const handleMouseLeave: CardProps['onMouseLeave'] = (e) => {\n onMouseLeave?.(e);\n };\n\n // default value for showIcons: if the dashboard is in editing mode or the panel is in fullscreen mode: 'always', otherwise 'hover'\n const showIcons = panelOptions?.showIcons ?? (editHandlers || readHandlers?.isPanelViewed ? 'always' : 'hover');\n\n return (\n <Card\n component=\"section\"\n sx={combineSx(\n {\n width: '100%',\n height: '100%',\n display: 'flex',\n flexFlow: 'column nowrap',\n ':hover': { '--panel-hover': 'block' },\n },\n sx\n )}\n variant=\"outlined\"\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n aria-labelledby={headerId}\n aria-describedby={headerId}\n data-testid=\"panel\"\n {...others}\n >\n {!panelOptions?.hideHeader && (\n <PanelHeader\n extra={panelOptions?.extra?.({ panelDefinition: definition, panelGroupItemId })}\n id={headerId}\n title={definition.spec.display.name}\n description={definition.spec.display.description}\n queryResults={queryResults}\n readHandlers={readHandlers}\n editHandlers={editHandlers}\n viewQueriesHandler={viewQueriesHandler}\n links={definition.spec.links}\n pluginActions={pluginActions}\n showIcons={showIcons}\n sx={{ paddingX: `${chartsTheme.container.padding.default}px` }}\n dimension={contentDimensions}\n />\n )}\n <CardContent\n component=\"figure\"\n sx={{\n position: 'relative',\n overflow: 'hidden',\n flexGrow: 1,\n margin: 0,\n padding: 0,\n // Override MUI default style for last-child\n ':last-child': {\n padding: 0,\n },\n }}\n ref={setContentElement}\n >\n <ErrorBoundary FallbackComponent={ErrorAlert} resetKeys={[definition.spec, queryResults]}>\n <PanelContent\n definition={definition}\n panelPluginKind={definition.spec.plugin.kind}\n spec={definition.spec.plugin.spec}\n contentDimensions={contentDimensions}\n queryResults={queryResults}\n />\n </ErrorBoundary>\n </CardContent>\n </Card>\n );\n});\n"],"names":["Card","CardContent","ErrorAlert","ErrorBoundary","combineSx","useChartsTheme","useId","useDataQueriesContext","usePluginRegistry","memo","useMemo","useState","useEffect","useResizeObserver","PanelContent","PanelHeader","Panel","props","definition","readHandlers","editHandlers","onMouseEnter","onMouseLeave","sx","panelOptions","panelGroupItemId","viewQueriesHandler","others","generatedPanelId","headerId","contentElement","setContentElement","width","height","ref","contentDimensions","undefined","chartsTheme","queryResults","getPlugin","panelPropsForActions","spec","plugin","map","query","data","pluginActions","setPluginActions","cancelled","loadPluginActions","panelPluginKind","kind","panelProps","actions","Array","isArray","length","headerActions","filter","action","location","index","ActionComponent","component","error","console","warn","item","Boolean","timeoutId","setTimeout","clearTimeout","handleMouseEnter","e","handleMouseLeave","showIcons","isPanelViewed","display","flexFlow","variant","aria-labelledby","aria-describedby","data-testid","hideHeader","extra","panelDefinition","id","title","name","description","links","paddingX","container","padding","default","dimension","position","overflow","flexGrow","margin","FallbackComponent","resetKeys"],"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,IAAI,EAAEC,WAAW,QAAmB,gBAAgB;AAC7D,SAASC,UAAU,EAAEC,aAAa,EAAEC,SAAS,EAAEC,cAAc,EAAEC,KAAK,QAAQ,yBAAyB;AAErG,SAASC,qBAAqB,EAAEC,iBAAiB,QAAQ,4BAA4B;AACrF,SAAoBC,IAAI,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,SAAS,QAAQ,QAAQ;AACtE,OAAOC,uBAAuB,sBAAsB;AAEpD,SAASC,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VC,QAAQ;oBACRN,SAAS;oBACT,4CAA4C;oBAC5C,eAAe;wBACbA,SAAS;oBACX;gBACF;gBACA3D,KAAKH;0BAEL,cAAA,KAAC5B;oBAAciG,mBAAmBlG;oBAAYmG,WAAW;wBAACnF,WAAWuB,IAAI;wBAAEH;qBAAa;8BACtF,cAAA,KAACxB;wBACCI,YAAYA;wBACZgC,iBAAiBhC,WAAWuB,IAAI,CAACC,MAAM,CAACS,IAAI;wBAC5CV,MAAMvB,WAAWuB,IAAI,CAACC,MAAM,CAACD,IAAI;wBACjCN,mBAAmBA;wBACnBG,cAAcA;;;;;;AAM1B,GAAG"}
@@ -1,6 +1,7 @@
1
- /// <reference types="react" />
1
+ import { ReactNode } from 'react';
2
2
  import { QueryData } from '@perses-dev/plugin-system';
3
3
  import { Link } from '@perses-dev/core';
4
+ import { PanelOptions } from './Panel';
4
5
  export interface PanelActionsProps {
5
6
  title: string;
6
7
  description?: string;
@@ -16,7 +17,12 @@ export interface PanelActionsProps {
16
17
  isPanelViewed?: boolean;
17
18
  onViewPanelClick: () => void;
18
19
  };
20
+ viewQueriesHandler?: {
21
+ onClick: () => void;
22
+ };
19
23
  queryResults: QueryData[];
24
+ pluginActions?: ReactNode[];
25
+ showIcons: PanelOptions['showIcons'];
20
26
  }
21
27
  export declare const PanelActions: React.FC<PanelActionsProps>;
22
28
  //# sourceMappingURL=PanelActions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PanelActions.d.ts","sourceRoot":"","sources":["../../../src/components/Panel/PanelActions.tsx"],"names":[],"mappings":";AAuBA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAGtD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAWxC,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,KAAK,CAAC,EAAE,IAAI,EAAE,C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O,EAAE,MAAM,IAAI,CAAC;KACrB,CAAC;IACF,YAAY,EAAE,SAAS,EAAE,CAAC;IAC1B,aAAa,CAAC,EAAE,SAAS,EAAE,CAAC;IAC5B,SAAS,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC;CACtC;AASD,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA6NpD,CAAC"}
@@ -14,6 +14,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
14
14
  import { Stack, Box, Popover, CircularProgress, styled } from '@mui/material';
15
15
  import { isValidElement, useMemo, useState } from 'react';
16
16
  import { InfoTooltip } from '@perses-dev/components';
17
+ import DatabaseSearch from 'mdi-material-ui/DatabaseSearch';
17
18
  import ArrowCollapseIcon from 'mdi-material-ui/ArrowCollapse';
18
19
  import ArrowExpandIcon from 'mdi-material-ui/ArrowExpand';
19
20
  import PencilIcon from 'mdi-material-ui/PencilOutline';
@@ -32,7 +33,7 @@ const ConditionalBox = styled(Box)({
32
33
  flexGrow: 1,
33
34
  justifyContent: 'flex-end'
34
35
  });
35
- export const PanelActions = ({ editHandlers, readHandlers, extra, title, description, descriptionTooltipId, links, queryResults })=>{
36
+ export const PanelActions = ({ editHandlers, readHandlers, viewQueriesHandler, extra, title, description, descriptionTooltipId, links, queryResults, pluginActions = [], showIcons })=>{
36
37
  const descriptionAction = useMemo(()=>{
37
38
  if (description && description.trim().length > 0) {
38
39
  return /*#__PURE__*/ _jsx(InfoTooltip, {
@@ -67,8 +68,6 @@ export const PanelActions = ({ editHandlers, readHandlers, extra, title, descrip
67
68
  const isFetching = queryResults.some((q)=>q.isFetching);
68
69
  const queryErrors = queryResults.filter((q)=>q.error);
69
70
  if (isFetching && hasData) {
70
- // If the panel has no data, the panel content will show the loading overlay.
71
- // Therefore, show the circular loading indicator only in case the panel doesn't display the loading overlay already.
72
71
  return /*#__PURE__*/ _jsx(CircularProgress, {
73
72
  "aria-label": "loading",
74
73
  size: "1.125rem"
@@ -111,6 +110,23 @@ export const PanelActions = ({ editHandlers, readHandlers, extra, title, descrip
111
110
  readHandlers,
112
111
  title
113
112
  ]);
113
+ const viewQueryAction = useMemo(()=>{
114
+ if (!viewQueriesHandler?.onClick) return null;
115
+ return /*#__PURE__*/ _jsx(InfoTooltip, {
116
+ description: TOOLTIP_TEXT.queryView,
117
+ children: /*#__PURE__*/ _jsx(HeaderIconButton, {
118
+ "aria-label": ARIA_LABEL_TEXT.openQueryView(title),
119
+ size: "small",
120
+ onClick: viewQueriesHandler.onClick,
121
+ children: /*#__PURE__*/ _jsx(DatabaseSearch, {
122
+ fontSize: "inherit"
123
+ })
124
+ })
125
+ });
126
+ }, [
127
+ viewQueriesHandler,
128
+ title
129
+ ]);
114
130
  const editActions = useMemo(()=>{
115
131
  if (editHandlers !== undefined) {
116
132
  // If there are edit handlers, always just show the edit buttons
@@ -190,8 +206,8 @@ export const PanelActions = ({ editHandlers, readHandlers, extra, title, descrip
190
206
  flexGrow: 1
191
207
  }
192
208
  });
193
- // if the panel is in non-editing, non-fullscreen mode, show certain icons only on hover
194
- const OnHover = ({ children })=>editHandlers === undefined && !readHandlers?.isPanelViewed ? /*#__PURE__*/ _jsx(Box, {
209
+ // By default, the panel header shows certain icons only on hover if the panel is in non-editing, non-fullscreen mode
210
+ const OnHover = ({ children })=>showIcons === 'hover' ? /*#__PURE__*/ _jsx(Box, {
195
211
  sx: {
196
212
  display: 'var(--panel-hover, none)'
197
213
  },
@@ -222,8 +238,10 @@ export const PanelActions = ({ editHandlers, readHandlers, extra, title, descrip
222
238
  " ",
223
239
  extraActions,
224
240
  " ",
241
+ viewQueryAction,
225
242
  readActions,
226
243
  " ",
244
+ pluginActions,
227
245
  editActions
228
246
  ]
229
247
  }),
@@ -252,11 +270,16 @@ export const PanelActions = ({ editHandlers, readHandlers, extra, title, descrip
252
270
  /*#__PURE__*/ _jsxs(OnHover, {
253
271
  children: [
254
272
  extraActions,
255
- " ",
256
273
  readActions,
257
- /*#__PURE__*/ _jsx(OverflowMenu, {
274
+ /*#__PURE__*/ _jsxs(OverflowMenu, {
258
275
  title: title,
259
- children: editActions
276
+ children: [
277
+ editActions,
278
+ " ",
279
+ viewQueryAction,
280
+ " ",
281
+ pluginActions
282
+ ]
260
283
  }),
261
284
  moveAction
262
285
  ]
@@ -285,11 +308,14 @@ export const PanelActions = ({ editHandlers, readHandlers, extra, title, descrip
285
308
  /*#__PURE__*/ _jsxs(OnHover, {
286
309
  children: [
287
310
  extraActions,
288
- " ",
311
+ viewQueryAction,
289
312
  readActions,
290
313
  " ",
291
314
  editActions,
292
- " ",
315
+ pluginActions.length <= 1 ? pluginActions : /*#__PURE__*/ _jsx(OverflowMenu, {
316
+ title: title,
317
+ children: pluginActions
318
+ }),
293
319
  moveAction
294
320
  ]
295
321
  })
@@ -303,7 +329,7 @@ const OverflowMenu = ({ children, title })=>{
303
329
  // do not show overflow menu if there is no content (for example, edit actions are hidden)
304
330
  const hasContent = /*#__PURE__*/ isValidElement(children) || Array.isArray(children) && children.some(isValidElement);
305
331
  if (!hasContent) {
306
- return undefined;
332
+ return null;
307
333
  }
308
334
  const handleClick = (event)=>{
309
335
  setAnchorPosition(event.currentTarget.getBoundingClientRect());