@perses-dev/dashboards 0.0.0-snapshot-ts-panel-actions-76080ec → 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 +7 -2
  10. package/dist/cjs/components/Panel/PanelActions.js +37 -14
  11. package/dist/cjs/components/Panel/PanelHeader.js +35 -15
  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 +7 -2
  77. package/dist/components/Panel/Panel.js.map +1 -1
  78. package/dist/components/Panel/PanelActions.d.ts +5 -0
  79. package/dist/components/Panel/PanelActions.d.ts.map +1 -1
  80. package/dist/components/Panel/PanelActions.js +37 -14
  81. package/dist/components/Panel/PanelActions.js.map +1 -1
  82. package/dist/components/Panel/PanelHeader.d.ts +7 -1
  83. package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
  84. package/dist/components/Panel/PanelHeader.js +36 -16
  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
@@ -11,16 +11,27 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
- import { CardHeader, Stack, Typography } from '@mui/material';
14
+ import { CardHeader, Stack, Typography, Tooltip } from '@mui/material';
15
15
  import { combineSx } from '@perses-dev/components';
16
16
  import { useReplaceVariablesInString } from '@perses-dev/plugin-system';
17
+ import { useEffect, useRef, useState } from 'react';
17
18
  import { HEADER_ACTIONS_CONTAINER_NAME } from '../../constants';
18
19
  import { PanelActions } from './PanelActions';
19
- export function PanelHeader({ id, title: rawTitle, description: rawDescription, links, queryResults, readHandlers, editHandlers, sx, extra, pluginActions, ...rest }) {
20
+ export function PanelHeader({ id, title: rawTitle, description: rawDescription, links, queryResults, readHandlers, editHandlers, sx, extra, pluginActions, showIcons, viewQueriesHandler, dimension, ...rest }) {
20
21
  const titleElementId = `${id}-title`;
21
22
  const descriptionTooltipId = `${id}-description`;
22
23
  const title = useReplaceVariablesInString(rawTitle);
23
24
  const description = useReplaceVariablesInString(rawDescription);
25
+ const textRef = useRef(null);
26
+ const [isEllipsisActive, setIsEllipsisActive] = useState(false);
27
+ useEffect(()=>{
28
+ if (textRef.current && dimension?.width) {
29
+ setIsEllipsisActive(textRef.current.scrollWidth > textRef.current.clientWidth);
30
+ }
31
+ }, [
32
+ title,
33
+ dimension?.width
34
+ ]);
24
35
  return /*#__PURE__*/ _jsx(CardHeader, {
25
36
  id: id,
26
37
  component: "header",
@@ -29,20 +40,27 @@ export function PanelHeader({ id, title: rawTitle, description: rawDescription,
29
40
  disableTypography: true,
30
41
  title: /*#__PURE__*/ _jsxs(Stack, {
31
42
  direction: "row",
43
+ alignItems: "center",
44
+ height: "var(--panel-header-height, 30px)",
32
45
  children: [
33
- /*#__PURE__*/ _jsx(Typography, {
34
- id: titleElementId,
35
- variant: "subtitle1",
36
- sx: {
37
- // `minHeight` guarantees that the header has the correct height
38
- // when there is no title (i.e. in the preview)
39
- lineHeight: '24px',
40
- minHeight: '26px',
41
- whiteSpace: 'nowrap',
42
- overflow: 'hidden',
43
- textOverflow: 'ellipsis'
44
- },
45
- children: title
46
+ /*#__PURE__*/ _jsx(Tooltip, {
47
+ title: title,
48
+ disableHoverListener: !isEllipsisActive,
49
+ children: /*#__PURE__*/ _jsx(Typography, {
50
+ id: titleElementId,
51
+ variant: "subtitle1",
52
+ ref: textRef,
53
+ sx: {
54
+ // `minHeight` guarantees that the header has the correct height
55
+ // when there is no title (i.e. in the preview)
56
+ lineHeight: '24px',
57
+ minHeight: '26px',
58
+ whiteSpace: 'nowrap',
59
+ overflow: 'hidden',
60
+ textOverflow: 'ellipsis'
61
+ },
62
+ children: title
63
+ })
46
64
  }),
47
65
  /*#__PURE__*/ _jsx(PanelActions, {
48
66
  title: title,
@@ -51,9 +69,11 @@ export function PanelHeader({ id, title: rawTitle, description: rawDescription,
51
69
  links: links,
52
70
  readHandlers: readHandlers,
53
71
  editHandlers: editHandlers,
72
+ viewQueriesHandler: viewQueriesHandler,
54
73
  extra: extra,
55
74
  queryResults: queryResults,
56
- pluginActions: pluginActions
75
+ pluginActions: pluginActions,
76
+ showIcons: showIcons
57
77
  })
58
78
  ]
59
79
  }),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Panel/PanelHeader.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 { CardHeader, CardHeaderProps, Stack, Typography } from '@mui/material';\nimport { combineSx } from '@perses-dev/components';\nimport { Link } from '@perses-dev/core';\nimport { QueryData, useReplaceVariablesInString } from '@perses-dev/plugin-system';\nimport { ReactElement, ReactNode } from 'react';\nimport { HEADER_ACTIONS_CONTAINER_NAME } from '../../constants';\nimport { PanelActions, PanelActionsProps } from './PanelActions';\n\ntype OmittedProps = 'children' | 'action' | 'title' | 'disableTypography';\n\nexport interface PanelHeaderProps extends Omit<CardHeaderProps, OmittedProps> {\n id: string;\n title: string;\n description?: string;\n links?: Link[];\n extra?: ReactNode;\n queryResults: QueryData[];\n readHandlers?: PanelActionsProps['readHandlers'];\n editHandlers?: PanelActionsProps['editHandlers'];\n pluginActions?: ReactNode[]; // Add pluginActions prop\n}\n\nexport function PanelHeader({\n id,\n title: rawTitle,\n description: rawDescription,\n links,\n queryResults,\n readHandlers,\n editHandlers,\n sx,\n extra,\n pluginActions,\n ...rest\n}: PanelHeaderProps): ReactElement {\n const titleElementId = `${id}-title`;\n const descriptionTooltipId = `${id}-description`;\n\n const title = useReplaceVariablesInString(rawTitle) as string;\n const description = useReplaceVariablesInString(rawDescription);\n\n return (\n <CardHeader\n id={id}\n component=\"header\"\n aria-labelledby={titleElementId}\n aria-describedby={descriptionTooltipId}\n disableTypography\n title={\n <Stack direction=\"row\">\n <Typography\n id={titleElementId}\n variant=\"subtitle1\"\n sx={{\n // `minHeight` guarantees that the header has the correct height\n // when there is no title (i.e. in the preview)\n lineHeight: '24px',\n minHeight: '26px',\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n }}\n >\n {title}\n </Typography>\n <PanelActions\n title={title}\n description={description}\n descriptionTooltipId={descriptionTooltipId}\n links={links}\n readHandlers={readHandlers}\n editHandlers={editHandlers}\n extra={extra}\n queryResults={queryResults}\n pluginActions={pluginActions}\n />\n </Stack>\n }\n sx={combineSx(\n (theme) => ({\n containerType: 'inline-size',\n containerName: HEADER_ACTIONS_CONTAINER_NAME,\n padding: theme.spacing(1),\n borderBottom: `solid 1px ${theme.palette.divider}`,\n '.MuiCardHeader-content': {\n overflow: 'hidden',\n },\n }),\n sx\n )}\n {...rest}\n />\n );\n}\n"],"names":["CardHeader","Stack","Typography","combineSx","useReplaceVariablesInString","HEADER_ACTIONS_CONTAINER_NAME","PanelActions","PanelHeader","id","title","rawTitle","description","rawDescription","links","queryResults","readHandlers","editHandlers","sx","extra","pluginActions","rest","titleElementId","descriptionTooltipId","component","aria-labelledby","aria-describedby","disableTypography","direction","variant","lineHeight","minHeight","whiteSpace","overflow","textOverflow","theme","containerType","containerName","padding","spacing","borderBottom","palette","divider"],"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,UAAU,EAAmBC,KAAK,EAAEC,UAAU,QAAQ,gBAAgB;AAC/E,SAASC,SAAS,QAAQ,yBAAyB;AAEnD,SAAoBC,2BAA2B,QAAQ,4BAA4B;AAEnF,SAASC,6BAA6B,QAAQ,kBAAkB;AAChE,SAASC,YAAY,QAA2B,iBAAiB;AAgBjE,OAAO,SAASC,YAAY,EAC1BC,EAAE,EACFC,OAAOC,QAAQ,EACfC,aAAaC,cAAc,EAC3BC,KAAK,EACLC,YAAY,EACZC,YAAY,EACZC,YAAY,EACZC,EAAE,EACFC,KAAK,EACLC,aAAa,EACb,GAAGC,MACc;IACjB,MAAMC,iBAAiB,GAAGb,GAAG,MAAM,CAAC;IACpC,MAAMc,uBAAuB,GAAGd,GAAG,YAAY,CAAC;IAEhD,MAAMC,QAAQL,4BAA4BM;IAC1C,MAAMC,cAAcP,4BAA4BQ;IAEhD,qBACE,KAACZ;QACCQ,IAAIA;QACJe,WAAU;QACVC,mBAAiBH;QACjBI,oBAAkBH;QAClBI,iBAAiB;QACjBjB,qBACE,MAACR;YAAM0B,WAAU;;8BACf,KAACzB;oBACCM,IAAIa;oBACJO,SAAQ;oBACRX,IAAI;wBACF,gEAAgE;wBAChE,+CAA+C;wBAC/CY,YAAY;wBACZC,WAAW;wBACXC,YAAY;wBACZC,UAAU;wBACVC,cAAc;oBAChB;8BAECxB;;8BAEH,KAACH;oBACCG,OAAOA;oBACPE,aAAaA;oBACbW,sBAAsBA;oBACtBT,OAAOA;oBACPE,cAAcA;oBACdC,cAAcA;oBACdE,OAAOA;oBACPJ,cAAcA;oBACdK,eAAeA;;;;QAIrBF,IAAId,UACF,CAAC+B,QAAW,CAAA;gBACVC,eAAe;gBACfC,eAAe/B;gBACfgC,SAASH,MAAMI,OAAO,CAAC;gBACvBC,cAAc,CAAC,UAAU,EAAEL,MAAMM,OAAO,CAACC,OAAO,EAAE;gBAClD,0BAA0B;oBACxBT,UAAU;gBACZ;YACF,CAAA,GACAf;QAED,GAAGG,IAAI;;AAGd"}
1
+ {"version":3,"sources":["../../../src/components/Panel/PanelHeader.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 { CardHeader, CardHeaderProps, Stack, Typography, Tooltip } from '@mui/material';\nimport { combineSx } from '@perses-dev/components';\nimport { Link } from '@perses-dev/core';\nimport { QueryData, useReplaceVariablesInString } from '@perses-dev/plugin-system';\nimport { ReactElement, ReactNode, useEffect, useRef, useState } from 'react';\nimport { HEADER_ACTIONS_CONTAINER_NAME } from '../../constants';\nimport { PanelActions, PanelActionsProps } from './PanelActions';\nimport { PanelOptions } from './Panel';\n\ntype OmittedProps = 'children' | 'action' | 'title' | 'disableTypography';\n\nexport interface PanelHeaderProps extends Omit<CardHeaderProps, OmittedProps> {\n id: string;\n title: string;\n description?: string;\n links?: Link[];\n extra?: ReactNode;\n queryResults: QueryData[];\n viewQueriesHandler?: PanelActionsProps['viewQueriesHandler'];\n readHandlers?: PanelActionsProps['readHandlers'];\n editHandlers?: PanelActionsProps['editHandlers'];\n pluginActions?: ReactNode[]; // Add pluginActions prop\n showIcons: PanelOptions['showIcons'];\n dimension?: { width: number };\n}\n\nexport function PanelHeader({\n id,\n title: rawTitle,\n description: rawDescription,\n links,\n queryResults,\n readHandlers,\n editHandlers,\n sx,\n extra,\n pluginActions,\n showIcons,\n viewQueriesHandler,\n dimension,\n ...rest\n}: PanelHeaderProps): ReactElement {\n const titleElementId = `${id}-title`;\n const descriptionTooltipId = `${id}-description`;\n\n const title = useReplaceVariablesInString(rawTitle) as string;\n const description = useReplaceVariablesInString(rawDescription);\n\n const textRef = useRef<HTMLDivElement>(null);\n const [isEllipsisActive, setIsEllipsisActive] = useState(false);\n\n useEffect(() => {\n if (textRef.current && dimension?.width) {\n setIsEllipsisActive(textRef.current.scrollWidth > textRef.current.clientWidth);\n }\n }, [title, dimension?.width]);\n\n return (\n <CardHeader\n id={id}\n component=\"header\"\n aria-labelledby={titleElementId}\n aria-describedby={descriptionTooltipId}\n disableTypography\n title={\n <Stack direction=\"row\" alignItems=\"center\" height=\"var(--panel-header-height, 30px)\">\n <Tooltip title={title} disableHoverListener={!isEllipsisActive}>\n <Typography\n id={titleElementId}\n variant=\"subtitle1\"\n ref={textRef}\n sx={{\n // `minHeight` guarantees that the header has the correct height\n // when there is no title (i.e. in the preview)\n lineHeight: '24px',\n minHeight: '26px',\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n }}\n >\n {title}\n </Typography>\n </Tooltip>\n <PanelActions\n title={title}\n description={description}\n descriptionTooltipId={descriptionTooltipId}\n links={links}\n readHandlers={readHandlers}\n editHandlers={editHandlers}\n viewQueriesHandler={viewQueriesHandler}\n extra={extra}\n queryResults={queryResults}\n pluginActions={pluginActions}\n showIcons={showIcons}\n />\n </Stack>\n }\n sx={combineSx(\n (theme) => ({\n containerType: 'inline-size',\n containerName: HEADER_ACTIONS_CONTAINER_NAME,\n padding: theme.spacing(1),\n borderBottom: `solid 1px ${theme.palette.divider}`,\n '.MuiCardHeader-content': {\n overflow: 'hidden',\n },\n }),\n sx\n )}\n {...rest}\n />\n );\n}\n"],"names":["CardHeader","Stack","Typography","Tooltip","combineSx","useReplaceVariablesInString","useEffect","useRef","useState","HEADER_ACTIONS_CONTAINER_NAME","PanelActions","PanelHeader","id","title","rawTitle","description","rawDescription","links","queryResults","readHandlers","editHandlers","sx","extra","pluginActions","showIcons","viewQueriesHandler","dimension","rest","titleElementId","descriptionTooltipId","textRef","isEllipsisActive","setIsEllipsisActive","current","width","scrollWidth","clientWidth","component","aria-labelledby","aria-describedby","disableTypography","direction","alignItems","height","disableHoverListener","variant","ref","lineHeight","minHeight","whiteSpace","overflow","textOverflow","theme","containerType","containerName","padding","spacing","borderBottom","palette","divider"],"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,UAAU,EAAmBC,KAAK,EAAEC,UAAU,EAAEC,OAAO,QAAQ,gBAAgB;AACxF,SAASC,SAAS,QAAQ,yBAAyB;AAEnD,SAAoBC,2BAA2B,QAAQ,4BAA4B;AACnF,SAAkCC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAC7E,SAASC,6BAA6B,QAAQ,kBAAkB;AAChE,SAASC,YAAY,QAA2B,iBAAiB;AAoBjE,OAAO,SAASC,YAAY,EAC1BC,EAAE,EACFC,OAAOC,QAAQ,EACfC,aAAaC,cAAc,EAC3BC,KAAK,EACLC,YAAY,EACZC,YAAY,EACZC,YAAY,EACZC,EAAE,EACFC,KAAK,EACLC,aAAa,EACbC,SAAS,EACTC,kBAAkB,EAClBC,SAAS,EACT,GAAGC,MACc;IACjB,MAAMC,iBAAiB,GAAGhB,GAAG,MAAM,CAAC;IACpC,MAAMiB,uBAAuB,GAAGjB,GAAG,YAAY,CAAC;IAEhD,MAAMC,QAAQR,4BAA4BS;IAC1C,MAAMC,cAAcV,4BAA4BW;IAEhD,MAAMc,UAAUvB,OAAuB;IACvC,MAAM,CAACwB,kBAAkBC,oBAAoB,GAAGxB,SAAS;IAEzDF,UAAU;QACR,IAAIwB,QAAQG,OAAO,IAAIP,WAAWQ,OAAO;YACvCF,oBAAoBF,QAAQG,OAAO,CAACE,WAAW,GAAGL,QAAQG,OAAO,CAACG,WAAW;QAC/E;IACF,GAAG;QAACvB;QAAOa,WAAWQ;KAAM;IAE5B,qBACE,KAAClC;QACCY,IAAIA;QACJyB,WAAU;QACVC,mBAAiBV;QACjBW,oBAAkBV;QAClBW,iBAAiB;QACjB3B,qBACE,MAACZ;YAAMwC,WAAU;YAAMC,YAAW;YAASC,QAAO;;8BAChD,KAACxC;oBAAQU,OAAOA;oBAAO+B,sBAAsB,CAACb;8BAC5C,cAAA,KAAC7B;wBACCU,IAAIgB;wBACJiB,SAAQ;wBACRC,KAAKhB;wBACLT,IAAI;4BACF,gEAAgE;4BAChE,+CAA+C;4BAC/C0B,YAAY;4BACZC,WAAW;4BACXC,YAAY;4BACZC,UAAU;4BACVC,cAAc;wBAChB;kCAECtC;;;8BAGL,KAACH;oBACCG,OAAOA;oBACPE,aAAaA;oBACbc,sBAAsBA;oBACtBZ,OAAOA;oBACPE,cAAcA;oBACdC,cAAcA;oBACdK,oBAAoBA;oBACpBH,OAAOA;oBACPJ,cAAcA;oBACdK,eAAeA;oBACfC,WAAWA;;;;QAIjBH,IAAIjB,UACF,CAACgD,QAAW,CAAA;gBACVC,eAAe;gBACfC,eAAe7C;gBACf8C,SAASH,MAAMI,OAAO,CAAC;gBACvBC,cAAc,CAAC,UAAU,EAAEL,MAAMM,OAAO,CAACC,OAAO,EAAE;gBAClD,0BAA0B;oBACxBT,UAAU;gBACZ;YACF,CAAA,GACA7B;QAED,GAAGM,IAAI;;AAGd"}
@@ -1,3 +1,4 @@
1
+ export * from './HeaderIconButton';
1
2
  export * from './Panel';
2
3
  export * from './PanelPluginLoader';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Panel/index.ts"],"names":[],"mappings":"AAaA,cAAc,SAAS,CAAC;AACxB,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Panel/index.ts"],"names":[],"mappings":"AAaA,cAAc,oBAAoB,CAAC;AACnC,cAAc,SAAS,CAAC;AACxB,cAAc,qBAAqB,CAAC"}
@@ -10,6 +10,7 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
+ export * from './HeaderIconButton';
13
14
  export * from './Panel';
14
15
  export * from './PanelPluginLoader';
15
16
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Panel/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 './Panel';\nexport * from './PanelPluginLoader';\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,UAAU;AACxB,cAAc,sBAAsB"}
1
+ {"version":3,"sources":["../../../src/components/Panel/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 './HeaderIconButton';\nexport * from './Panel';\nexport * from './PanelPluginLoader';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,qBAAqB;AACnC,cAAc,UAAU;AACxB,cAAc,sBAAsB"}
@@ -1 +1 @@
1
- {"version":3,"file":"PanelDrawer.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/PanelDrawer.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,YAAY,EAAY,MAAM,OAAO,CAAC;AAM/C;;GAEG;AACH,eAAO,MAAM,WAAW,QAAO,YAiD9B,CAAC"}
1
+ {"version":3,"file":"PanelDrawer.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/PanelDrawer.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,YAAY,EAA6C,MAAM,OAAO,CAAC;AAOhF;;GAEG;AACH,eAAO,MAAM,WAAW,QAAO,YAsE9B,CAAC"}
@@ -11,8 +11,9 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
- import { useState } from 'react';
14
+ import { useState, useMemo, useCallback } from 'react';
15
15
  import { Drawer, ErrorAlert, ErrorBoundary } from '@perses-dev/components';
16
+ import { useVariableValues, VariableContext } from '@perses-dev/plugin-system';
16
17
  import { usePanelEditor } from '../../context';
17
18
  import { PanelEditorForm } from './PanelEditorForm';
18
19
  /**
@@ -22,44 +23,80 @@ import { PanelEditorForm } from './PanelEditorForm';
22
23
  // When the user clicks close, start closing but don't call the store yet to keep values stable during animtation
23
24
  const [isClosing, setIsClosing] = useState(false);
24
25
  // Drawer is open if we have a model and we're not transitioning out
25
- const isOpen = panelEditor !== undefined && isClosing === false;
26
- function handleSave(values) {
26
+ const isOpen = panelEditor !== undefined && !isClosing;
27
+ const handleSave = useCallback((values)=>{
27
28
  // This shouldn't happen since we don't render the submit button until we have a model, but check to make TS happy
28
29
  if (panelEditor === undefined || values === undefined) {
29
30
  throw new Error('Cannot apply changes');
30
31
  }
31
32
  panelEditor.applyChanges(values);
32
33
  setIsClosing(true);
33
- }
34
+ }, [
35
+ panelEditor
36
+ ]);
34
37
  const handleClose = ()=>{
35
38
  setIsClosing(true);
36
39
  };
37
40
  // Don't call closeDrawer on the store until the Drawer has completely transitioned out and reset close state
38
- const handleExited = ()=>{
41
+ const handleExited = useCallback(()=>{
39
42
  panelEditor?.close();
40
43
  setIsClosing(false);
41
- };
44
+ }, [
45
+ panelEditor
46
+ ]);
42
47
  // Disables closing on click out. This is a quick-win solution to avoid losing draft changes.
43
48
  // -> TODO find a way to enable closing by clicking-out in edit view, with a discard confirmation modal popping up
44
49
  const handleClickOut = ()=>{
45
50
  /* do nothing */ };
46
- return /*#__PURE__*/ _jsx(Drawer, {
47
- isOpen: isOpen,
48
- onClose: handleClickOut,
49
- SlideProps: {
50
- onExited: handleExited
51
- },
52
- "data-testid": "panel-editor",
53
- children: panelEditor && /*#__PURE__*/ _jsx(ErrorBoundary, {
54
- FallbackComponent: ErrorAlert,
55
- children: /*#__PURE__*/ _jsx(PanelEditorForm, {
56
- initialAction: panelEditor.mode,
57
- initialValues: panelEditor.initialValues,
58
- onSave: handleSave,
59
- onClose: handleClose
51
+ const drawer = useMemo(()=>{
52
+ return /*#__PURE__*/ _jsx(Drawer, {
53
+ isOpen: isOpen,
54
+ onClose: handleClickOut,
55
+ SlideProps: {
56
+ onExited: handleExited
57
+ },
58
+ "data-testid": "panel-editor",
59
+ children: panelEditor && /*#__PURE__*/ _jsx(ErrorBoundary, {
60
+ FallbackComponent: ErrorAlert,
61
+ children: /*#__PURE__*/ _jsx(PanelEditorForm, {
62
+ initialAction: panelEditor.mode,
63
+ initialValues: panelEditor.initialValues,
64
+ onSave: handleSave,
65
+ onClose: handleClose
66
+ })
60
67
  })
61
- })
62
- });
68
+ });
69
+ }, [
70
+ handleExited,
71
+ handleSave,
72
+ isOpen,
73
+ panelEditor
74
+ ]);
75
+ // If the panel editor is using a repeat variable, we need to wrap the drawer in a VariableContext.Provider
76
+ if (panelEditor?.panelGroupItemId?.repeatVariable) {
77
+ return /*#__PURE__*/ _jsx(RepeatVariableWrapper, {
78
+ repeatVariable: panelEditor.panelGroupItemId.repeatVariable,
79
+ children: drawer
80
+ });
81
+ }
82
+ return drawer;
63
83
  };
84
+ // Wraps the drawer in a VariableContext.Provider to provide the repeat variable value
85
+ // This is necessary for previewing panels that use repeat variables and query editor
86
+ function RepeatVariableWrapper({ repeatVariable, children }) {
87
+ const variables = useVariableValues();
88
+ return /*#__PURE__*/ _jsx(VariableContext.Provider, {
89
+ value: {
90
+ state: {
91
+ ...variables,
92
+ [repeatVariable[0]]: {
93
+ value: repeatVariable[1],
94
+ loading: false
95
+ }
96
+ }
97
+ },
98
+ children: children
99
+ });
100
+ }
64
101
 
65
102
  //# sourceMappingURL=PanelDrawer.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/PanelDrawer/PanelDrawer.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-empty-function */\n// 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 { Drawer, ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport { PanelEditorValues } from '@perses-dev/core';\nimport { usePanelEditor } from '../../context';\nimport { PanelEditorForm } from './PanelEditorForm';\n\n/**\n * The Add/Edit panel drawer for editing a panel's options.\n */\nexport const PanelDrawer = (): ReactElement => {\n const panelEditor = usePanelEditor();\n\n // When the user clicks close, start closing but don't call the store yet to keep values stable during animtation\n const [isClosing, setIsClosing] = useState(false);\n\n // Drawer is open if we have a model and we're not transitioning out\n const isOpen = panelEditor !== undefined && isClosing === false;\n\n function handleSave(values: PanelEditorValues): void {\n // This shouldn't happen since we don't render the submit button until we have a model, but check to make TS happy\n if (panelEditor === undefined || values === undefined) {\n throw new Error('Cannot apply changes');\n }\n panelEditor.applyChanges(values);\n setIsClosing(true);\n }\n\n const handleClose = (): void => {\n setIsClosing(true);\n };\n\n // Don't call closeDrawer on the store until the Drawer has completely transitioned out and reset close state\n const handleExited = (): void => {\n panelEditor?.close();\n setIsClosing(false);\n };\n\n // Disables closing on click out. This is a quick-win solution to avoid losing draft changes.\n // -> TODO find a way to enable closing by clicking-out in edit view, with a discard confirmation modal popping up\n const handleClickOut = (): void => {\n /* do nothing */\n };\n\n return (\n <Drawer isOpen={isOpen} onClose={handleClickOut} SlideProps={{ onExited: handleExited }} data-testid=\"panel-editor\">\n {/* When the drawer is opened, we should have panel editor state (this also ensures the form state gets reset between opens) */}\n {panelEditor && (\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <PanelEditorForm\n initialAction={panelEditor.mode}\n initialValues={panelEditor.initialValues}\n onSave={handleSave}\n onClose={handleClose}\n />\n </ErrorBoundary>\n )}\n </Drawer>\n );\n};\n"],"names":["useState","Drawer","ErrorAlert","ErrorBoundary","usePanelEditor","PanelEditorForm","PanelDrawer","panelEditor","isClosing","setIsClosing","isOpen","undefined","handleSave","values","Error","applyChanges","handleClose","handleExited","close","handleClickOut","onClose","SlideProps","onExited","data-testid","FallbackComponent","initialAction","mode","initialValues","onSave"],"mappings":"AAAA,uDAAuD,GACvD,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAAuBA,QAAQ,QAAQ,QAAQ;AAC/C,SAASC,MAAM,EAAEC,UAAU,EAAEC,aAAa,QAAQ,yBAAyB;AAE3E,SAASC,cAAc,QAAQ,gBAAgB;AAC/C,SAASC,eAAe,QAAQ,oBAAoB;AAEpD;;CAEC,GACD,OAAO,MAAMC,cAAc;IACzB,MAAMC,cAAcH;IAEpB,iHAAiH;IACjH,MAAM,CAACI,WAAWC,aAAa,GAAGT,SAAS;IAE3C,oEAAoE;IACpE,MAAMU,SAASH,gBAAgBI,aAAaH,cAAc;IAE1D,SAASI,WAAWC,MAAyB;QAC3C,kHAAkH;QAClH,IAAIN,gBAAgBI,aAAaE,WAAWF,WAAW;YACrD,MAAM,IAAIG,MAAM;QAClB;QACAP,YAAYQ,YAAY,CAACF;QACzBJ,aAAa;IACf;IAEA,MAAMO,cAAc;QAClBP,aAAa;IACf;IAEA,6GAA6G;IAC7G,MAAMQ,eAAe;QACnBV,aAAaW;QACbT,aAAa;IACf;IAEA,6FAA6F;IAC7F,kHAAkH;IAClH,MAAMU,iBAAiB;IACrB,cAAc,GAChB;IAEA,qBACE,KAAClB;QAAOS,QAAQA;QAAQU,SAASD;QAAgBE,YAAY;YAAEC,UAAUL;QAAa;QAAGM,eAAY;kBAElGhB,6BACC,KAACJ;YAAcqB,mBAAmBtB;sBAChC,cAAA,KAACG;gBACCoB,eAAelB,YAAYmB,IAAI;gBAC/BC,eAAepB,YAAYoB,aAAa;gBACxCC,QAAQhB;gBACRQ,SAASJ;;;;AAMrB,EAAE"}
1
+ {"version":3,"sources":["../../../src/components/PanelDrawer/PanelDrawer.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-empty-function */\n// 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, useMemo, ReactNode, useCallback } from 'react';\nimport { Drawer, ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport { PanelEditorValues } from '@perses-dev/core';\nimport { useVariableValues, VariableContext } from '@perses-dev/plugin-system';\nimport { usePanelEditor } from '../../context';\nimport { PanelEditorForm } from './PanelEditorForm';\n\n/**\n * The Add/Edit panel drawer for editing a panel's options.\n */\nexport const PanelDrawer = (): ReactElement => {\n const panelEditor = usePanelEditor();\n\n // When the user clicks close, start closing but don't call the store yet to keep values stable during animtation\n const [isClosing, setIsClosing] = useState(false);\n\n // Drawer is open if we have a model and we're not transitioning out\n const isOpen = panelEditor !== undefined && !isClosing;\n\n const handleSave = useCallback(\n (values: PanelEditorValues) => {\n // This shouldn't happen since we don't render the submit button until we have a model, but check to make TS happy\n if (panelEditor === undefined || values === undefined) {\n throw new Error('Cannot apply changes');\n }\n panelEditor.applyChanges(values);\n setIsClosing(true);\n },\n [panelEditor]\n );\n\n const handleClose = (): void => {\n setIsClosing(true);\n };\n\n // Don't call closeDrawer on the store until the Drawer has completely transitioned out and reset close state\n const handleExited = useCallback(() => {\n panelEditor?.close();\n setIsClosing(false);\n }, [panelEditor]);\n\n // Disables closing on click out. This is a quick-win solution to avoid losing draft changes.\n // -> TODO find a way to enable closing by clicking-out in edit view, with a discard confirmation modal popping up\n const handleClickOut = (): void => {\n /* do nothing */\n };\n\n const drawer = useMemo(() => {\n return (\n <Drawer\n isOpen={isOpen}\n onClose={handleClickOut}\n SlideProps={{ onExited: handleExited }}\n data-testid=\"panel-editor\"\n >\n {/* When the drawer is opened, we should have panel editor state (this also ensures the form state gets reset between opens) */}\n {panelEditor && (\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <PanelEditorForm\n initialAction={panelEditor.mode}\n initialValues={panelEditor.initialValues}\n onSave={handleSave}\n onClose={handleClose}\n />\n </ErrorBoundary>\n )}\n </Drawer>\n );\n }, [handleExited, handleSave, isOpen, panelEditor]);\n\n // If the panel editor is using a repeat variable, we need to wrap the drawer in a VariableContext.Provider\n if (panelEditor?.panelGroupItemId?.repeatVariable) {\n return (\n <RepeatVariableWrapper repeatVariable={panelEditor.panelGroupItemId.repeatVariable}>\n {drawer}\n </RepeatVariableWrapper>\n );\n }\n\n return drawer;\n};\n\n// Wraps the drawer in a VariableContext.Provider to provide the repeat variable value\n// This is necessary for previewing panels that use repeat variables and query editor\nfunction RepeatVariableWrapper({\n repeatVariable,\n children,\n}: {\n repeatVariable: [string, string];\n children: ReactNode;\n}): ReactElement {\n const variables = useVariableValues();\n\n return (\n <VariableContext.Provider\n value={{ state: { ...variables, [repeatVariable[0]]: { value: repeatVariable[1], loading: false } } }}\n >\n {children}\n </VariableContext.Provider>\n );\n}\n"],"names":["useState","useMemo","useCallback","Drawer","ErrorAlert","ErrorBoundary","useVariableValues","VariableContext","usePanelEditor","PanelEditorForm","PanelDrawer","panelEditor","isClosing","setIsClosing","isOpen","undefined","handleSave","values","Error","applyChanges","handleClose","handleExited","close","handleClickOut","drawer","onClose","SlideProps","onExited","data-testid","FallbackComponent","initialAction","mode","initialValues","onSave","panelGroupItemId","repeatVariable","RepeatVariableWrapper","children","variables","Provider","value","state","loading"],"mappings":"AAAA,uDAAuD,GACvD,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAAuBA,QAAQ,EAAEC,OAAO,EAAaC,WAAW,QAAQ,QAAQ;AAChF,SAASC,MAAM,EAAEC,UAAU,EAAEC,aAAa,QAAQ,yBAAyB;AAE3E,SAASC,iBAAiB,EAAEC,eAAe,QAAQ,4BAA4B;AAC/E,SAASC,cAAc,QAAQ,gBAAgB;AAC/C,SAASC,eAAe,QAAQ,oBAAoB;AAEpD;;CAEC,GACD,OAAO,MAAMC,cAAc;IACzB,MAAMC,cAAcH;IAEpB,iHAAiH;IACjH,MAAM,CAACI,WAAWC,aAAa,GAAGb,SAAS;IAE3C,oEAAoE;IACpE,MAAMc,SAASH,gBAAgBI,aAAa,CAACH;IAE7C,MAAMI,aAAad,YACjB,CAACe;QACC,kHAAkH;QAClH,IAAIN,gBAAgBI,aAAaE,WAAWF,WAAW;YACrD,MAAM,IAAIG,MAAM;QAClB;QACAP,YAAYQ,YAAY,CAACF;QACzBJ,aAAa;IACf,GACA;QAACF;KAAY;IAGf,MAAMS,cAAc;QAClBP,aAAa;IACf;IAEA,6GAA6G;IAC7G,MAAMQ,eAAenB,YAAY;QAC/BS,aAAaW;QACbT,aAAa;IACf,GAAG;QAACF;KAAY;IAEhB,6FAA6F;IAC7F,kHAAkH;IAClH,MAAMY,iBAAiB;IACrB,cAAc,GAChB;IAEA,MAAMC,SAASvB,QAAQ;QACrB,qBACE,KAACE;YACCW,QAAQA;YACRW,SAASF;YACTG,YAAY;gBAAEC,UAAUN;YAAa;YACrCO,eAAY;sBAGXjB,6BACC,KAACN;gBAAcwB,mBAAmBzB;0BAChC,cAAA,KAACK;oBACCqB,eAAenB,YAAYoB,IAAI;oBAC/BC,eAAerB,YAAYqB,aAAa;oBACxCC,QAAQjB;oBACRS,SAASL;;;;IAMrB,GAAG;QAACC;QAAcL;QAAYF;QAAQH;KAAY;IAElD,2GAA2G;IAC3G,IAAIA,aAAauB,kBAAkBC,gBAAgB;QACjD,qBACE,KAACC;YAAsBD,gBAAgBxB,YAAYuB,gBAAgB,CAACC,cAAc;sBAC/EX;;IAGP;IAEA,OAAOA;AACT,EAAE;AAEF,sFAAsF;AACtF,qFAAqF;AACrF,SAASY,sBAAsB,EAC7BD,cAAc,EACdE,QAAQ,EAIT;IACC,MAAMC,YAAYhC;IAElB,qBACE,KAACC,gBAAgBgC,QAAQ;QACvBC,OAAO;YAAEC,OAAO;gBAAE,GAAGH,SAAS;gBAAE,CAACH,cAAc,CAAC,EAAE,CAAC,EAAE;oBAAEK,OAAOL,cAAc,CAAC,EAAE;oBAAEO,SAAS;gBAAM;YAAE;QAAE;kBAEnGL;;AAGP"}
@@ -1 +1 @@
1
- {"version":3,"file":"PanelEditorForm.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/PanelEditorForm.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAuB,MAAM,OAAO,CAAC;AAE1D,OAAO,EAAE,MAAM,EAAmB,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAgB9E,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,iBAAiB,CAAC;IACjC,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC5C,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,YAAY,CA8NzE;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,sBAAsB,CAAC"}
1
+ {"version":3,"file":"PanelEditorForm.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/PanelEditorForm.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAA4C,MAAM,OAAO,CAAC;AAE/E,OAAO,EAAE,MAAM,EAA+C,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAqB1G,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,iBAAiB,CAAC;IACjC,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC5C,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,YAAY,CAkPzE;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,sBAAsB,CAAC"}