@perses-dev/dashboards 0.54.0-beta.0 → 0.54.0-beta.2

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 (202) hide show
  1. package/dist/cjs/components/GridLayout/GridItemContent.js +2 -2
  2. package/dist/cjs/components/Panel/Panel.js +4 -1
  3. package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +2 -2
  4. package/dist/cjs/components/Variables/VariableEditor.js +51 -17
  5. package/dist/cjs/constants/defaults.js +32 -0
  6. package/dist/cjs/constants/index.js +1 -0
  7. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +3 -3
  8. package/dist/cjs/context/DatasourceStoreProvider.js +4 -1
  9. package/dist/cjs/context/VariableProvider/VariableProvider.js +10 -6
  10. package/dist/cjs/index.js +1 -0
  11. package/dist/cjs/keyboard-shortcuts/index.js +3 -0
  12. package/dist/cjs/keyboard-shortcuts/utils.js +11 -0
  13. package/dist/cjs/model/PanelGroupDefinition.js +25 -0
  14. package/dist/cjs/model/VariableDefinition.js +16 -0
  15. package/dist/cjs/model/index.js +1 -0
  16. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +3 -3
  17. package/dist/components/AddGroupButton/AddGroupButton.js +1 -1
  18. package/dist/components/AddGroupButton/AddGroupButton.js.map +1 -1
  19. package/dist/components/AddPanelButton/AddPanelButton.js +1 -1
  20. package/dist/components/AddPanelButton/AddPanelButton.js.map +1 -1
  21. package/dist/components/Dashboard/Dashboard.js +1 -1
  22. package/dist/components/Dashboard/Dashboard.js.map +1 -1
  23. package/dist/components/DashboardLinks/DashboardLinksEditor.js +1 -1
  24. package/dist/components/DashboardLinks/DashboardLinksEditor.js.map +1 -1
  25. package/dist/components/DashboardLinks/EditDashboardLinksButton.js +1 -1
  26. package/dist/components/DashboardLinks/EditDashboardLinksButton.js.map +1 -1
  27. package/dist/components/DashboardShortcuts/useDashboardShortcuts.js.map +1 -1
  28. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js +1 -1
  29. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js.map +1 -1
  30. package/dist/components/DashboardToolbar/DashboardToolbar.js +1 -1
  31. package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
  32. package/dist/components/Datasources/DatasourceEditor.d.ts.map +1 -1
  33. package/dist/components/Datasources/DatasourceEditor.js +1 -1
  34. package/dist/components/Datasources/DatasourceEditor.js.map +1 -1
  35. package/dist/components/Datasources/EditDatasourcesButton.js +1 -1
  36. package/dist/components/Datasources/EditDatasourcesButton.js.map +1 -1
  37. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js +1 -1
  38. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js.map +1 -1
  39. package/dist/components/DownloadButton/DownloadButton.js +1 -1
  40. package/dist/components/DownloadButton/DownloadButton.js.map +1 -1
  41. package/dist/components/EditButton/EditButton.js +1 -1
  42. package/dist/components/EditButton/EditButton.js.map +1 -1
  43. package/dist/components/EditJsonButton/EditJsonButton.js +1 -1
  44. package/dist/components/EditJsonButton/EditJsonButton.js.map +1 -1
  45. package/dist/components/EditJsonDialog/EditJsonDialog.js +1 -1
  46. package/dist/components/EditJsonDialog/EditJsonDialog.js.map +1 -1
  47. package/dist/components/EmptyDashboard/EmptyDashboard.js +1 -1
  48. package/dist/components/EmptyDashboard/EmptyDashboard.js.map +1 -1
  49. package/dist/components/GridLayout/GridContainer.js +1 -1
  50. package/dist/components/GridLayout/GridContainer.js.map +1 -1
  51. package/dist/components/GridLayout/GridItemContent.d.ts +1 -1
  52. package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
  53. package/dist/components/GridLayout/GridItemContent.js +2 -2
  54. package/dist/components/GridLayout/GridItemContent.js.map +1 -1
  55. package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
  56. package/dist/components/GridLayout/GridLayout.js +1 -1
  57. package/dist/components/GridLayout/GridLayout.js.map +1 -1
  58. package/dist/components/GridLayout/GridTitle.js +1 -1
  59. package/dist/components/GridLayout/GridTitle.js.map +1 -1
  60. package/dist/components/GridLayout/Row.d.ts +1 -1
  61. package/dist/components/GridLayout/Row.d.ts.map +1 -1
  62. package/dist/components/GridLayout/Row.js +1 -1
  63. package/dist/components/GridLayout/Row.js.map +1 -1
  64. package/dist/components/LeaveDialog/LeaveDialog.js +1 -1
  65. package/dist/components/LeaveDialog/LeaveDialog.js.map +1 -1
  66. package/dist/components/LinksDisplay/LinksDisplay.js +1 -1
  67. package/dist/components/LinksDisplay/LinksDisplay.js.map +1 -1
  68. package/dist/components/Panel/Panel.d.ts +1 -1
  69. package/dist/components/Panel/Panel.d.ts.map +1 -1
  70. package/dist/components/Panel/Panel.js +5 -2
  71. package/dist/components/Panel/Panel.js.map +1 -1
  72. package/dist/components/Panel/PanelActions.js +1 -1
  73. package/dist/components/Panel/PanelActions.js.map +1 -1
  74. package/dist/components/Panel/PanelContent.js +1 -1
  75. package/dist/components/Panel/PanelContent.js.map +1 -1
  76. package/dist/components/Panel/PanelHeader.js +1 -1
  77. package/dist/components/Panel/PanelHeader.js.map +1 -1
  78. package/dist/components/Panel/PanelPluginLoader.js +1 -1
  79. package/dist/components/Panel/PanelPluginLoader.js.map +1 -1
  80. package/dist/components/Panel/useSelectionItemActions.js +1 -1
  81. package/dist/components/Panel/useSelectionItemActions.js.map +1 -1
  82. package/dist/components/PanelDrawer/PanelDrawer.js +1 -1
  83. package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
  84. package/dist/components/PanelDrawer/PanelEditorForm.d.ts +1 -1
  85. package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
  86. package/dist/components/PanelDrawer/PanelEditorForm.js +3 -3
  87. package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
  88. package/dist/components/PanelDrawer/PanelPreview.js +1 -1
  89. package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
  90. package/dist/components/PanelDrawer/PanelQueriesSharedControls.js +1 -1
  91. package/dist/components/PanelDrawer/PanelQueriesSharedControls.js.map +1 -1
  92. package/dist/components/PanelGroupDialog/PanelGroupDialog.js +1 -1
  93. package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
  94. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js +1 -1
  95. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js.map +1 -1
  96. package/dist/components/QuerySummaryTable/QuerySummaryTable.js +1 -1
  97. package/dist/components/QuerySummaryTable/QuerySummaryTable.js.map +1 -1
  98. package/dist/components/QueryViewerDialog/QueryViewerDialog.js +1 -1
  99. package/dist/components/QueryViewerDialog/QueryViewerDialog.js.map +1 -1
  100. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +1 -1
  101. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +1 -1
  102. package/dist/components/Variables/EditVariablesButton.js +1 -1
  103. package/dist/components/Variables/EditVariablesButton.js.map +1 -1
  104. package/dist/components/Variables/ListVariableListBox.js +1 -1
  105. package/dist/components/Variables/ListVariableListBox.js.map +1 -1
  106. package/dist/components/Variables/Variable.js +2 -2
  107. package/dist/components/Variables/Variable.js.map +1 -1
  108. package/dist/components/Variables/VariableEditor.d.ts +1 -1
  109. package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
  110. package/dist/components/Variables/VariableEditor.js +56 -22
  111. package/dist/components/Variables/VariableEditor.js.map +1 -1
  112. package/dist/components/Variables/VariableList.d.ts.map +1 -1
  113. package/dist/components/Variables/VariableList.js +1 -1
  114. package/dist/components/Variables/VariableList.js.map +1 -1
  115. package/dist/constants/defaults.d.ts +4 -0
  116. package/dist/constants/defaults.d.ts.map +1 -0
  117. package/dist/constants/defaults.js +16 -0
  118. package/dist/constants/defaults.js.map +1 -0
  119. package/dist/constants/index.d.ts +1 -0
  120. package/dist/constants/index.d.ts.map +1 -1
  121. package/dist/constants/index.js +1 -0
  122. package/dist/constants/index.js.map +1 -1
  123. package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
  124. package/dist/context/DashboardProvider/DashboardProvider.js +2 -2
  125. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
  126. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +1 -2
  127. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
  128. package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
  129. package/dist/context/DashboardProvider/delete-panel-slice.d.ts +1 -1
  130. package/dist/context/DashboardProvider/delete-panel-slice.d.ts.map +1 -1
  131. package/dist/context/DashboardProvider/delete-panel-slice.js.map +1 -1
  132. package/dist/context/DashboardProvider/duplicate-panel-slice.d.ts +1 -1
  133. package/dist/context/DashboardProvider/duplicate-panel-slice.d.ts.map +1 -1
  134. package/dist/context/DashboardProvider/duplicate-panel-slice.js.map +1 -1
  135. package/dist/context/DashboardProvider/panel-editor-slice.d.ts +2 -1
  136. package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
  137. package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
  138. package/dist/context/DashboardProvider/panel-group-slice.d.ts +1 -1
  139. package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
  140. package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
  141. package/dist/context/DashboardProvider/view-panel-slice.d.ts +1 -1
  142. package/dist/context/DashboardProvider/view-panel-slice.d.ts.map +1 -1
  143. package/dist/context/DashboardProvider/view-panel-slice.js.map +1 -1
  144. package/dist/context/DatasourceStoreProvider.d.ts +1 -1
  145. package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
  146. package/dist/context/DatasourceStoreProvider.js +5 -2
  147. package/dist/context/DatasourceStoreProvider.js.map +1 -1
  148. package/dist/context/PanelEditorProvider/PanelEditorProvider.js +1 -1
  149. package/dist/context/PanelEditorProvider/PanelEditorProvider.js.map +1 -1
  150. package/dist/context/VariableProvider/VariableProvider.d.ts +3 -2
  151. package/dist/context/VariableProvider/VariableProvider.d.ts.map +1 -1
  152. package/dist/context/VariableProvider/VariableProvider.js +12 -8
  153. package/dist/context/VariableProvider/VariableProvider.js.map +1 -1
  154. package/dist/context/VariableProvider/hydrationUtils.d.ts +1 -1
  155. package/dist/context/VariableProvider/hydrationUtils.d.ts.map +1 -1
  156. package/dist/context/VariableProvider/hydrationUtils.js.map +1 -1
  157. package/dist/context/VariableProvider/utils.d.ts +1 -1
  158. package/dist/context/VariableProvider/utils.d.ts.map +1 -1
  159. package/dist/context/VariableProvider/utils.js.map +1 -1
  160. package/dist/context/useDashboard.d.ts +1 -2
  161. package/dist/context/useDashboard.d.ts.map +1 -1
  162. package/dist/context/useDashboard.js.map +1 -1
  163. package/dist/index.d.ts +1 -0
  164. package/dist/index.d.ts.map +1 -1
  165. package/dist/index.js +1 -0
  166. package/dist/index.js.map +1 -1
  167. package/dist/keyboard-shortcuts/PanelFocusProvider.js +1 -1
  168. package/dist/keyboard-shortcuts/PanelFocusProvider.js.map +1 -1
  169. package/dist/keyboard-shortcuts/index.d.ts +1 -1
  170. package/dist/keyboard-shortcuts/index.d.ts.map +1 -1
  171. package/dist/keyboard-shortcuts/index.js +1 -1
  172. package/dist/keyboard-shortcuts/index.js.map +1 -1
  173. package/dist/keyboard-shortcuts/utils.d.ts +8 -0
  174. package/dist/keyboard-shortcuts/utils.d.ts.map +1 -1
  175. package/dist/keyboard-shortcuts/utils.js +13 -0
  176. package/dist/keyboard-shortcuts/utils.js.map +1 -1
  177. package/dist/model/PanelGroupDefinition.d.ts +59 -0
  178. package/dist/model/PanelGroupDefinition.d.ts.map +1 -0
  179. package/dist/model/PanelGroupDefinition.js +19 -0
  180. package/dist/model/PanelGroupDefinition.js.map +1 -0
  181. package/dist/model/VariableDefinition.d.ts +50 -0
  182. package/dist/model/VariableDefinition.d.ts.map +1 -0
  183. package/dist/model/VariableDefinition.js +20 -0
  184. package/dist/model/VariableDefinition.js.map +1 -0
  185. package/dist/model/index.d.ts +1 -0
  186. package/dist/model/index.d.ts.map +1 -1
  187. package/dist/model/index.js +1 -0
  188. package/dist/model/index.js.map +1 -1
  189. package/dist/test/datasource-provider.d.ts +1 -1
  190. package/dist/test/datasource-provider.d.ts.map +1 -1
  191. package/dist/test/datasource-provider.js.map +1 -1
  192. package/dist/test/render.js +1 -1
  193. package/dist/test/render.js.map +1 -1
  194. package/dist/utils/panelUtils.d.ts +1 -1
  195. package/dist/utils/panelUtils.d.ts.map +1 -1
  196. package/dist/utils/panelUtils.js.map +1 -1
  197. package/dist/views/ViewDashboard/DashboardApp.js +1 -1
  198. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  199. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
  200. package/dist/views/ViewDashboard/ViewDashboard.js +2 -2
  201. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
  202. package/package.json +6 -9
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/DashboardLinks/EditDashboardLinksButton.tsx"],"sourcesContent":["// Copyright 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 { Button, ButtonProps } from '@mui/material';\nimport PencilIcon from 'mdi-material-ui/PencilOutline';\nimport { Drawer, InfoTooltip } from '@perses-dev/components';\nimport { Link } from '@perses-dev/spec';\nimport { TOOLTIP_TEXT, editButtonStyle } from '../../constants';\nimport { useDashboardLinks, useDashboardLinksActions } from '../../context';\nimport { DashboardLinksEditor } from './DashboardLinksEditor';\n\nexport interface EditDashboardLinksButtonProps extends Pick<ButtonProps, 'fullWidth'> {\n /**\n * The variant to use to display the button.\n */\n variant?: 'text' | 'outlined';\n\n /**\n * The color to use to display the button.\n */\n color?: 'primary' | 'secondary';\n\n /**\n * The label used inside the button.\n */\n label?: string;\n}\n\nexport function EditDashboardLinksButton({\n variant = 'text',\n label = 'Links',\n color = 'primary',\n fullWidth,\n}: EditDashboardLinksButtonProps): ReactElement {\n const [isLinksEditorOpen, setIsLinksEditorOpen] = useState(false);\n const links = useDashboardLinks();\n const { setLinks } = useDashboardLinksActions();\n\n const openLinksEditor = (): void => {\n setIsLinksEditorOpen(true);\n };\n\n const closeLinksEditor = (): void => {\n setIsLinksEditorOpen(false);\n };\n\n return (\n <>\n <InfoTooltip description={TOOLTIP_TEXT.editLinks}>\n <Button\n startIcon={<PencilIcon />}\n onClick={openLinksEditor}\n aria-label={TOOLTIP_TEXT.editLinks}\n variant={variant}\n color={color}\n fullWidth={fullWidth}\n sx={editButtonStyle}\n >\n {label}\n </Button>\n </InfoTooltip>\n <Drawer\n isOpen={isLinksEditorOpen}\n onClose={closeLinksEditor}\n PaperProps={{ sx: { width: '50%' } }}\n data-testid=\"dashboard-links-editor\"\n >\n <DashboardLinksEditor\n links={links}\n onCancel={closeLinksEditor}\n onChange={(updatedLinks: Link[]) => {\n setLinks?.(updatedLinks);\n setIsLinksEditorOpen(false);\n }}\n />\n </Drawer>\n </>\n );\n}\n"],"names":["useState","Button","PencilIcon","Drawer","InfoTooltip","TOOLTIP_TEXT","editButtonStyle","useDashboardLinks","useDashboardLinksActions","DashboardLinksEditor","EditDashboardLinksButton","variant","label","color","fullWidth","isLinksEditorOpen","setIsLinksEditorOpen","links","setLinks","openLinksEditor","closeLinksEditor","description","editLinks","startIcon","onClick","aria-label","sx","isOpen","onClose","PaperProps","width","data-testid","onCancel","onChange","updatedLinks"],"mappings":"AAAA,+BAA+B;AAC/B,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,QAAqB,gBAAgB;AACpD,OAAOC,gBAAgB,gCAAgC;AACvD,SAASC,MAAM,EAAEC,WAAW,QAAQ,yBAAyB;AAE7D,SAASC,YAAY,EAAEC,eAAe,QAAQ,kBAAkB;AAChE,SAASC,iBAAiB,EAAEC,wBAAwB,QAAQ,gBAAgB;AAC5E,SAASC,oBAAoB,QAAQ,yBAAyB;AAmB9D,OAAO,SAASC,yBAAyB,EACvCC,UAAU,MAAM,EAChBC,QAAQ,OAAO,EACfC,QAAQ,SAAS,EACjBC,SAAS,EACqB;IAC9B,MAAM,CAACC,mBAAmBC,qBAAqB,GAAGhB,SAAS;IAC3D,MAAMiB,QAAQV;IACd,MAAM,EAAEW,QAAQ,EAAE,GAAGV;IAErB,MAAMW,kBAAkB;QACtBH,qBAAqB;IACvB;IAEA,MAAMI,mBAAmB;QACvBJ,qBAAqB;IACvB;IAEA,qBACE;;0BACE,KAACZ;gBAAYiB,aAAahB,aAAaiB,SAAS;0BAC9C,cAAA,KAACrB;oBACCsB,yBAAW,KAACrB;oBACZsB,SAASL;oBACTM,cAAYpB,aAAaiB,SAAS;oBAClCX,SAASA;oBACTE,OAAOA;oBACPC,WAAWA;oBACXY,IAAIpB;8BAEHM;;;0BAGL,KAACT;gBACCwB,QAAQZ;gBACRa,SAASR;gBACTS,YAAY;oBAAEH,IAAI;wBAAEI,OAAO;oBAAM;gBAAE;gBACnCC,eAAY;0BAEZ,cAAA,KAACtB;oBACCQ,OAAOA;oBACPe,UAAUZ;oBACVa,UAAU,CAACC;wBACThB,WAAWgB;wBACXlB,qBAAqB;oBACvB;;;;;AAKV"}
1
+ {"version":3,"sources":["../../../src/components/DashboardLinks/EditDashboardLinksButton.tsx"],"sourcesContent":["// Copyright 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 { Button, ButtonProps } from '@mui/material';\nimport PencilIcon from 'mdi-material-ui/PencilOutline';\nimport { Drawer, InfoTooltip } from '@perses-dev/components';\nimport { Link } from '@perses-dev/spec';\nimport { TOOLTIP_TEXT, editButtonStyle } from '../../constants';\nimport { useDashboardLinks, useDashboardLinksActions } from '../../context';\nimport { DashboardLinksEditor } from './DashboardLinksEditor';\n\nexport interface EditDashboardLinksButtonProps extends Pick<ButtonProps, 'fullWidth'> {\n /**\n * The variant to use to display the button.\n */\n variant?: 'text' | 'outlined';\n\n /**\n * The color to use to display the button.\n */\n color?: 'primary' | 'secondary';\n\n /**\n * The label used inside the button.\n */\n label?: string;\n}\n\nexport function EditDashboardLinksButton({\n variant = 'text',\n label = 'Links',\n color = 'primary',\n fullWidth,\n}: EditDashboardLinksButtonProps): ReactElement {\n const [isLinksEditorOpen, setIsLinksEditorOpen] = useState(false);\n const links = useDashboardLinks();\n const { setLinks } = useDashboardLinksActions();\n\n const openLinksEditor = (): void => {\n setIsLinksEditorOpen(true);\n };\n\n const closeLinksEditor = (): void => {\n setIsLinksEditorOpen(false);\n };\n\n return (\n <>\n <InfoTooltip description={TOOLTIP_TEXT.editLinks}>\n <Button\n startIcon={<PencilIcon />}\n onClick={openLinksEditor}\n aria-label={TOOLTIP_TEXT.editLinks}\n variant={variant}\n color={color}\n fullWidth={fullWidth}\n sx={editButtonStyle}\n >\n {label}\n </Button>\n </InfoTooltip>\n <Drawer\n isOpen={isLinksEditorOpen}\n onClose={closeLinksEditor}\n PaperProps={{ sx: { width: '50%' } }}\n data-testid=\"dashboard-links-editor\"\n >\n <DashboardLinksEditor\n links={links}\n onCancel={closeLinksEditor}\n onChange={(updatedLinks: Link[]) => {\n setLinks?.(updatedLinks);\n setIsLinksEditorOpen(false);\n }}\n />\n </Drawer>\n </>\n );\n}\n"],"names":["useState","Button","PencilIcon","Drawer","InfoTooltip","TOOLTIP_TEXT","editButtonStyle","useDashboardLinks","useDashboardLinksActions","DashboardLinksEditor","EditDashboardLinksButton","variant","label","color","fullWidth","isLinksEditorOpen","setIsLinksEditorOpen","links","setLinks","openLinksEditor","closeLinksEditor","description","editLinks","startIcon","onClick","aria-label","sx","isOpen","onClose","PaperProps","width","data-testid","onCancel","onChange","updatedLinks"],"mappings":";AAAA,+BAA+B;AAC/B,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,QAAqB,gBAAgB;AACpD,OAAOC,gBAAgB,gCAAgC;AACvD,SAASC,MAAM,EAAEC,WAAW,QAAQ,yBAAyB;AAE7D,SAASC,YAAY,EAAEC,eAAe,QAAQ,kBAAkB;AAChE,SAASC,iBAAiB,EAAEC,wBAAwB,QAAQ,gBAAgB;AAC5E,SAASC,oBAAoB,QAAQ,yBAAyB;AAmB9D,OAAO,SAASC,yBAAyB,EACvCC,UAAU,MAAM,EAChBC,QAAQ,OAAO,EACfC,QAAQ,SAAS,EACjBC,SAAS,EACqB;IAC9B,MAAM,CAACC,mBAAmBC,qBAAqB,GAAGhB,SAAS;IAC3D,MAAMiB,QAAQV;IACd,MAAM,EAAEW,QAAQ,EAAE,GAAGV;IAErB,MAAMW,kBAAkB;QACtBH,qBAAqB;IACvB;IAEA,MAAMI,mBAAmB;QACvBJ,qBAAqB;IACvB;IAEA,qBACE;;0BACE,KAACZ;gBAAYiB,aAAahB,aAAaiB,SAAS;0BAC9C,cAAA,KAACrB;oBACCsB,yBAAW,KAACrB;oBACZsB,SAASL;oBACTM,cAAYpB,aAAaiB,SAAS;oBAClCX,SAASA;oBACTE,OAAOA;oBACPC,WAAWA;oBACXY,IAAIpB;8BAEHM;;;0BAGL,KAACT;gBACCwB,QAAQZ;gBACRa,SAASR;gBACTS,YAAY;oBAAEH,IAAI;wBAAEI,OAAO;oBAAM;gBAAE;gBACnCC,eAAY;0BAEZ,cAAA,KAACtB;oBACCQ,OAAOA;oBACPe,UAAUZ;oBACVa,UAAU,CAACC;wBACThB,WAAWgB;wBACXlB,qBAAqB;oBACvB;;;;;AAKV"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/DashboardShortcuts/useDashboardShortcuts.ts"],"sourcesContent":["// Copyright 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 { useCallback } from 'react';\nimport { AbsoluteTimeRange, TimeRangeValue, isRelativeTimeRange, toAbsoluteTimeRange } from '@perses-dev/spec';\nimport { PanelGroupItemId } from '@perses-dev/core';\nimport { useSnackbar } from '@perses-dev/components';\nimport { useTimeRange } from '@perses-dev/plugin-system';\nimport { useHotkeys, useHotkeySequences } from '@tanstack/react-hotkeys';\nimport {\n useFocusedPanel,\n buildShortcutOptions,\n requireShortcutHotkey,\n requireShortcutSequence,\n SAVE_DASHBOARD_SHORTCUT,\n REFRESH_DASHBOARD_SHORTCUT,\n TOGGLE_EDIT_MODE_SHORTCUT,\n TIME_ZOOM_OUT_SHORTCUT,\n TIME_ZOOM_IN_SHORTCUT,\n TIME_SHIFT_BACK_SHORTCUT,\n TIME_SHIFT_FORWARD_SHORTCUT,\n TIME_MAKE_ABSOLUTE_SHORTCUT,\n TIME_COPY_SHORTCUT,\n TIME_PASTE_SHORTCUT,\n PANEL_EDIT_SHORTCUT,\n PANEL_FULLSCREEN_SHORTCUT,\n PANEL_DUPLICATE_SHORTCUT,\n PANEL_DELETE_SHORTCUT,\n} from '../../keyboard-shortcuts';\nimport {\n OnSaveDashboard,\n useEditMode,\n useDashboardStore,\n DashboardStoreState,\n useViewPanelGroup,\n useSaveDashboard,\n} from '../../context/DashboardProvider';\n\nconst SAVE_SHORTCUT_EDIT_MODE_MESSAGE = 'Enter edit mode to save this dashboard.';\nconst SAVE_SHORTCUT_READONLY_MESSAGE = 'This dashboard is read-only. Keyboard save is disabled.';\nconst SAVE_SHORTCUT_UNAVAILABLE_MESSAGE = 'Save action is unavailable for this dashboard.';\n\nfunction parsePanelKey(panelKey: string): PanelGroupItemId | null {\n const dashIndex = panelKey.indexOf('-');\n if (dashIndex === -1) return null;\n\n const panelGroupId = parseInt(panelKey.substring(0, dashIndex), 10);\n const panelGroupItemLayoutId = panelKey.substring(dashIndex + 1);\n\n if (isNaN(panelGroupId)) return null;\n\n return { panelGroupId, panelGroupItemLayoutId };\n}\n\n// Zoom limits: 1 second minimum, 10 years maximum\nconst MIN_ZOOM_DURATION_MS = 1_000;\nconst MAX_ZOOM_DURATION_MS = 10 * 365.25 * 24 * 60 * 60 * 1_000;\n\nfunction resolveAbsoluteRange(timeRange: TimeRangeValue): {\n absoluteRange: AbsoluteTimeRange;\n durationMs: number;\n midpointMs: number;\n} {\n const absoluteRange = isRelativeTimeRange(timeRange) ? toAbsoluteTimeRange(timeRange) : timeRange;\n const startMs = absoluteRange.start.getTime();\n const endMs = absoluteRange.end.getTime();\n const durationMs = endMs - startMs;\n const midpointMs = Math.round(startMs + durationMs / 2);\n return { absoluteRange, durationMs, midpointMs };\n}\n\nconst selectPanelStoreActions = (\n state: DashboardStoreState\n): {\n openEditPanel: DashboardStoreState['openEditPanel'];\n duplicatePanel: DashboardStoreState['duplicatePanel'];\n openDeletePanelDialog: DashboardStoreState['openDeletePanelDialog'];\n setViewPanel: DashboardStoreState['setViewPanel'];\n panelEditor: DashboardStoreState['panelEditor'];\n} => ({\n openEditPanel: state.openEditPanel,\n duplicatePanel: state.duplicatePanel,\n openDeletePanelDialog: state.openDeletePanelDialog,\n setViewPanel: state.setViewPanel,\n panelEditor: state.panelEditor,\n});\n\nexport interface UseDashboardShortcutsOptions {\n onSave?: OnSaveDashboard;\n onRefresh?: () => void;\n isReadonly: boolean;\n onEditButtonClick?: () => void;\n onCancelButtonClick?: () => void;\n disabled?: boolean;\n}\n\n/** Registers dashboard, time-range, and panel keyboard shortcuts. Requires DashboardProvider context. */\nexport function useDashboardShortcuts({\n onSave,\n onRefresh,\n isReadonly,\n onEditButtonClick,\n onCancelButtonClick,\n disabled = false,\n}: UseDashboardShortcutsOptions): void {\n const focusedPanelKey = useFocusedPanel();\n const { isEditMode, setEditMode } = useEditMode();\n const { timeRange, setTimeRange, refresh } = useTimeRange();\n const { infoSnackbar, warningSnackbar } = useSnackbar();\n const viewPanel = useViewPanelGroup();\n const { openEditPanel, duplicatePanel, openDeletePanelDialog, setViewPanel, panelEditor } =\n useDashboardStore(selectPanelStoreActions);\n const { saveDashboard } = useSaveDashboard(onSave);\n\n const panelFocused = focusedPanelKey !== null;\n\n // --- Handlers ---\n\n const handleSave = useCallback(() => {\n if (isReadonly) {\n warningSnackbar(SAVE_SHORTCUT_READONLY_MESSAGE);\n return;\n }\n\n if (!isEditMode) {\n infoSnackbar(SAVE_SHORTCUT_EDIT_MODE_MESSAGE);\n return;\n }\n\n if (!onSave) {\n warningSnackbar(SAVE_SHORTCUT_UNAVAILABLE_MESSAGE);\n return;\n }\n\n saveDashboard();\n }, [infoSnackbar, isEditMode, isReadonly, onSave, saveDashboard, warningSnackbar]);\n\n const handleRefresh = useCallback(() => {\n refresh();\n infoSnackbar('Dashboard refreshed.');\n if (onRefresh) {\n onRefresh();\n }\n }, [refresh, infoSnackbar, onRefresh]);\n\n const handleToggleEditMode = useCallback(() => {\n if (isEditMode) {\n // Switching from edit to view: delegate to cancel flow (shows discard dialog if needed)\n if (onCancelButtonClick) {\n onCancelButtonClick();\n } else {\n setEditMode(false);\n }\n } else {\n // Switching from view to edit: delegate to edit flow (saves original state)\n if (onEditButtonClick) {\n onEditButtonClick();\n } else {\n setEditMode(true);\n }\n }\n }, [isEditMode, setEditMode, onCancelButtonClick, onEditButtonClick]);\n\n // Time range handlers\n\n const handleTimeZoomOut = useCallback(() => {\n const { durationMs, midpointMs } = resolveAbsoluteRange(timeRange);\n const newDuration = Math.min(durationMs * 2, MAX_ZOOM_DURATION_MS);\n const halfNew = Math.round(newDuration / 2);\n setTimeRange({\n start: new Date(midpointMs - halfNew),\n end: new Date(midpointMs + halfNew),\n });\n }, [timeRange, setTimeRange]);\n\n const handleTimeZoomIn = useCallback(() => {\n const { durationMs, midpointMs } = resolveAbsoluteRange(timeRange);\n const newDuration = Math.max(Math.round(durationMs / 2), MIN_ZOOM_DURATION_MS);\n const halfNew = Math.round(newDuration / 2);\n setTimeRange({\n start: new Date(midpointMs - halfNew),\n end: new Date(midpointMs + halfNew),\n });\n }, [timeRange, setTimeRange]);\n\n const handleTimeShiftBack = useCallback(() => {\n const { absoluteRange, durationMs } = resolveAbsoluteRange(timeRange);\n const shift = Math.round(durationMs / 2);\n setTimeRange({\n start: new Date(absoluteRange.start.getTime() - shift),\n end: new Date(absoluteRange.end.getTime() - shift),\n });\n }, [timeRange, setTimeRange]);\n\n const handleTimeShiftForward = useCallback(() => {\n const { absoluteRange, durationMs } = resolveAbsoluteRange(timeRange);\n const shift = Math.round(durationMs / 2);\n setTimeRange({\n start: new Date(absoluteRange.start.getTime() + shift),\n end: new Date(absoluteRange.end.getTime() + shift),\n });\n }, [timeRange, setTimeRange]);\n\n const handleTimeMakeAbsolute = useCallback(() => {\n if (isRelativeTimeRange(timeRange)) {\n setTimeRange(toAbsoluteTimeRange(timeRange));\n }\n }, [timeRange, setTimeRange]);\n\n const handleTimeCopy = useCallback(() => {\n const absoluteRange = isRelativeTimeRange(timeRange) ? toAbsoluteTimeRange(timeRange) : timeRange;\n const text = `${absoluteRange.start.toISOString()} - ${absoluteRange.end.toISOString()}`;\n navigator.clipboard\n .writeText(text)\n .then(() => {\n infoSnackbar('Time range copied to clipboard.');\n })\n .catch(() => {\n warningSnackbar('Failed to copy time range to clipboard.');\n });\n }, [timeRange, infoSnackbar, warningSnackbar]);\n\n const handleTimePaste = useCallback(() => {\n const FORMAT_HINT = 'Expected format: \"<ISO date format> - <ISO date format>\".';\n navigator.clipboard\n .readText()\n .then((text) => {\n const parts = text.split(' - ');\n if (parts.length !== 2) {\n warningSnackbar(`Clipboard does not contain a valid time range. ${FORMAT_HINT}`);\n return;\n }\n const [startStr, endStr] = parts as [string, string];\n const start = new Date(startStr.trim());\n const end = new Date(endStr.trim());\n if (isNaN(start.getTime()) || isNaN(end.getTime())) {\n warningSnackbar(`Clipboard does not contain a valid time range. ${FORMAT_HINT}`);\n return;\n }\n if (start >= end) {\n warningSnackbar('Invalid time range: start must be before end.');\n return;\n }\n const newRange: AbsoluteTimeRange = { start, end };\n setTimeRange(newRange);\n infoSnackbar('Time range pasted from clipboard.');\n })\n .catch(() => {\n warningSnackbar('Unable to read from clipboard. Check browser permissions.');\n });\n }, [setTimeRange, infoSnackbar, warningSnackbar]);\n\n // Panel handlers\n const handlePanelEditToggle = useCallback(() => {\n if (panelEditor !== undefined) {\n panelEditor.close();\n return;\n }\n\n if (focusedPanelKey && isEditMode) {\n const panelId = parsePanelKey(focusedPanelKey);\n if (panelId) {\n openEditPanel(panelId);\n }\n }\n }, [focusedPanelKey, isEditMode, openEditPanel, panelEditor]);\n\n const handlePanelFullscreenToggle = useCallback(() => {\n if (viewPanel !== undefined) {\n setViewPanel(undefined);\n return;\n }\n\n if (focusedPanelKey) {\n const panelId = parsePanelKey(focusedPanelKey);\n if (panelId) {\n setViewPanel(panelId);\n }\n }\n }, [focusedPanelKey, setViewPanel, viewPanel]);\n\n const handlePanelDuplicate = useCallback(() => {\n if (focusedPanelKey && isEditMode) {\n const panelId = parsePanelKey(focusedPanelKey);\n if (panelId) {\n duplicatePanel(panelId);\n }\n }\n }, [focusedPanelKey, isEditMode, duplicatePanel]);\n\n const handlePanelDelete = useCallback(() => {\n if (focusedPanelKey && isEditMode) {\n const panelId = parsePanelKey(focusedPanelKey);\n if (panelId) {\n openDeletePanelDialog(panelId);\n }\n }\n }, [focusedPanelKey, isEditMode, openDeletePanelDialog]);\n\n // Register shortcuts\n\n useHotkeys(\n [\n { def: SAVE_DASHBOARD_SHORTCUT, enabled: !disabled, callback: handleSave },\n {\n def: PANEL_EDIT_SHORTCUT,\n enabled: !disabled && (panelFocused || panelEditor !== undefined),\n callback: handlePanelEditToggle,\n },\n {\n def: PANEL_FULLSCREEN_SHORTCUT,\n enabled: !disabled && (panelFocused || viewPanel !== undefined),\n callback: handlePanelFullscreenToggle,\n },\n ].map(({ def, enabled, callback }) => ({\n hotkey: requireShortcutHotkey(def),\n callback,\n options: buildShortcutOptions(def, enabled),\n }))\n );\n\n useHotkeySequences(\n [\n { def: REFRESH_DASHBOARD_SHORTCUT, enabled: !disabled, callback: handleRefresh },\n { def: TOGGLE_EDIT_MODE_SHORTCUT, enabled: !disabled, callback: handleToggleEditMode },\n { def: TIME_ZOOM_OUT_SHORTCUT, enabled: !disabled, callback: handleTimeZoomOut },\n { def: TIME_ZOOM_IN_SHORTCUT, enabled: !disabled, callback: handleTimeZoomIn },\n { def: TIME_SHIFT_BACK_SHORTCUT, enabled: !disabled, callback: handleTimeShiftBack },\n { def: TIME_SHIFT_FORWARD_SHORTCUT, enabled: !disabled, callback: handleTimeShiftForward },\n { def: TIME_MAKE_ABSOLUTE_SHORTCUT, enabled: !disabled, callback: handleTimeMakeAbsolute },\n { def: TIME_COPY_SHORTCUT, enabled: !disabled, callback: handleTimeCopy },\n { def: TIME_PASTE_SHORTCUT, enabled: !disabled, callback: handleTimePaste },\n { def: PANEL_DUPLICATE_SHORTCUT, enabled: !disabled && panelFocused, callback: handlePanelDuplicate },\n { def: PANEL_DELETE_SHORTCUT, enabled: !disabled && panelFocused, callback: handlePanelDelete },\n ].map(({ def, enabled, callback }) => ({\n sequence: requireShortcutSequence(def),\n callback,\n options: buildShortcutOptions(def, enabled),\n }))\n );\n}\n"],"names":["useCallback","isRelativeTimeRange","toAbsoluteTimeRange","useSnackbar","useTimeRange","useHotkeys","useHotkeySequences","useFocusedPanel","buildShortcutOptions","requireShortcutHotkey","requireShortcutSequence","SAVE_DASHBOARD_SHORTCUT","REFRESH_DASHBOARD_SHORTCUT","TOGGLE_EDIT_MODE_SHORTCUT","TIME_ZOOM_OUT_SHORTCUT","TIME_ZOOM_IN_SHORTCUT","TIME_SHIFT_BACK_SHORTCUT","TIME_SHIFT_FORWARD_SHORTCUT","TIME_MAKE_ABSOLUTE_SHORTCUT","TIME_COPY_SHORTCUT","TIME_PASTE_SHORTCUT","PANEL_EDIT_SHORTCUT","PANEL_FULLSCREEN_SHORTCUT","PANEL_DUPLICATE_SHORTCUT","PANEL_DELETE_SHORTCUT","useEditMode","useDashboardStore","useViewPanelGroup","useSaveDashboard","SAVE_SHORTCUT_EDIT_MODE_MESSAGE","SAVE_SHORTCUT_READONLY_MESSAGE","SAVE_SHORTCUT_UNAVAILABLE_MESSAGE","parsePanelKey","panelKey","dashIndex","indexOf","panelGroupId","parseInt","substring","panelGroupItemLayoutId","isNaN","MIN_ZOOM_DURATION_MS","MAX_ZOOM_DURATION_MS","resolveAbsoluteRange","timeRange","absoluteRange","startMs","start","getTime","endMs","end","durationMs","midpointMs","Math","round","selectPanelStoreActions","state","openEditPanel","duplicatePanel","openDeletePanelDialog","setViewPanel","panelEditor","useDashboardShortcuts","onSave","onRefresh","isReadonly","onEditButtonClick","onCancelButtonClick","disabled","focusedPanelKey","isEditMode","setEditMode","setTimeRange","refresh","infoSnackbar","warningSnackbar","viewPanel","saveDashboard","panelFocused","handleSave","handleRefresh","handleToggleEditMode","handleTimeZoomOut","newDuration","min","halfNew","Date","handleTimeZoomIn","max","handleTimeShiftBack","shift","handleTimeShiftForward","handleTimeMakeAbsolute","handleTimeCopy","text","toISOString","navigator","clipboard","writeText","then","catch","handleTimePaste","FORMAT_HINT","readText","parts","split","length","startStr","endStr","trim","newRange","handlePanelEditToggle","undefined","close","panelId","handlePanelFullscreenToggle","handlePanelDuplicate","handlePanelDelete","def","enabled","callback","map","hotkey","options","sequence"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,WAAW,QAAQ,QAAQ;AACpC,SAA4CC,mBAAmB,EAAEC,mBAAmB,QAAQ,mBAAmB;AAE/G,SAASC,WAAW,QAAQ,yBAAyB;AACrD,SAASC,YAAY,QAAQ,4BAA4B;AACzD,SAASC,UAAU,EAAEC,kBAAkB,QAAQ,0BAA0B;AACzE,SACEC,eAAe,EACfC,oBAAoB,EACpBC,qBAAqB,EACrBC,uBAAuB,EACvBC,uBAAuB,EACvBC,0BAA0B,EAC1BC,yBAAyB,EACzBC,sBAAsB,EACtBC,qBAAqB,EACrBC,wBAAwB,EACxBC,2BAA2B,EAC3BC,2BAA2B,EAC3BC,kBAAkB,EAClBC,mBAAmB,EACnBC,mBAAmB,EACnBC,yBAAyB,EACzBC,wBAAwB,EACxBC,qBAAqB,QAChB,2BAA2B;AAClC,SAEEC,WAAW,EACXC,iBAAiB,EAEjBC,iBAAiB,EACjBC,gBAAgB,QACX,kCAAkC;AAEzC,MAAMC,kCAAkC;AACxC,MAAMC,iCAAiC;AACvC,MAAMC,oCAAoC;AAE1C,SAASC,cAAcC,QAAgB;IACrC,MAAMC,YAAYD,SAASE,OAAO,CAAC;IACnC,IAAID,cAAc,CAAC,GAAG,OAAO;IAE7B,MAAME,eAAeC,SAASJ,SAASK,SAAS,CAAC,G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7E;YAAE+B,KAAKtG;YAA0BuG,SAAS,CAACnD;YAAUoD,UAAU/B;QAAoB;QACnF;YAAE6B,KAAKrG;YAA6BsG,SAAS,CAACnD;YAAUoD,UAAU7B;QAAuB;QACzF;YAAE2B,KAAKpG;YAA6BqG,SAAS,CAACnD;YAAUoD,UAAU5B;QAAuB;QACzF;YAAE0B,KAAKnG;YAAoBoG,SAAS,CAACnD;YAAUoD,UAAU3B;QAAe;QACxE;YAAEyB,KAAKlG;YAAqBmG,SAAS,CAACnD;YAAUoD,UAAUnB;QAAgB;QAC1E;YAAEiB,KAAK/F;YAA0BgG,SAAS,CAACnD,YAAYU;YAAc0C,UAAUJ;QAAqB;QACpG;YAAEE,KAAK9F;YAAuB+F,SAAS,CAACnD,YAAYU;YAAc0C,UAAUH;QAAkB;KAC/F,CAACI,GAAG,CAAC,CAAC,EAAEH,GAAG,EAAEC,OAAO,EAAEC,QAAQ,EAAE,GAAM,CAAA;YACrCI,UAAUlH,wBAAwB4G;YAClCE;YACAG,SAASnH,qBAAqB8G,KAAKC;QACrC,CAAA;AAEJ"}
1
+ {"version":3,"sources":["../../../src/components/DashboardShortcuts/useDashboardShortcuts.ts"],"sourcesContent":["// Copyright 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 { useCallback } from 'react';\nimport { AbsoluteTimeRange, TimeRangeValue, isRelativeTimeRange, toAbsoluteTimeRange } from '@perses-dev/spec';\nimport { useSnackbar } from '@perses-dev/components';\nimport { useTimeRange } from '@perses-dev/plugin-system';\nimport { useHotkeys, useHotkeySequences } from '@tanstack/react-hotkeys';\nimport { PanelGroupItemId } from '../../model';\nimport {\n useFocusedPanel,\n buildShortcutOptions,\n requireShortcutHotkey,\n requireShortcutSequence,\n SAVE_DASHBOARD_SHORTCUT,\n REFRESH_DASHBOARD_SHORTCUT,\n TOGGLE_EDIT_MODE_SHORTCUT,\n TIME_ZOOM_OUT_SHORTCUT,\n TIME_ZOOM_IN_SHORTCUT,\n TIME_SHIFT_BACK_SHORTCUT,\n TIME_SHIFT_FORWARD_SHORTCUT,\n TIME_MAKE_ABSOLUTE_SHORTCUT,\n TIME_COPY_SHORTCUT,\n TIME_PASTE_SHORTCUT,\n PANEL_EDIT_SHORTCUT,\n PANEL_FULLSCREEN_SHORTCUT,\n PANEL_DUPLICATE_SHORTCUT,\n PANEL_DELETE_SHORTCUT,\n} from '../../keyboard-shortcuts';\nimport {\n OnSaveDashboard,\n useEditMode,\n useDashboardStore,\n DashboardStoreState,\n useViewPanelGroup,\n useSaveDashboard,\n} from '../../context/DashboardProvider';\n\nconst SAVE_SHORTCUT_EDIT_MODE_MESSAGE = 'Enter edit mode to save this dashboard.';\nconst SAVE_SHORTCUT_READONLY_MESSAGE = 'This dashboard is read-only. Keyboard save is disabled.';\nconst SAVE_SHORTCUT_UNAVAILABLE_MESSAGE = 'Save action is unavailable for this dashboard.';\n\nfunction parsePanelKey(panelKey: string): PanelGroupItemId | null {\n const dashIndex = panelKey.indexOf('-');\n if (dashIndex === -1) return null;\n\n const panelGroupId = parseInt(panelKey.substring(0, dashIndex), 10);\n const panelGroupItemLayoutId = panelKey.substring(dashIndex + 1);\n\n if (isNaN(panelGroupId)) return null;\n\n return { panelGroupId, panelGroupItemLayoutId };\n}\n\n// Zoom limits: 1 second minimum, 10 years maximum\nconst MIN_ZOOM_DURATION_MS = 1_000;\nconst MAX_ZOOM_DURATION_MS = 10 * 365.25 * 24 * 60 * 60 * 1_000;\n\nfunction resolveAbsoluteRange(timeRange: TimeRangeValue): {\n absoluteRange: AbsoluteTimeRange;\n durationMs: number;\n midpointMs: number;\n} {\n const absoluteRange = isRelativeTimeRange(timeRange) ? toAbsoluteTimeRange(timeRange) : timeRange;\n const startMs = absoluteRange.start.getTime();\n const endMs = absoluteRange.end.getTime();\n const durationMs = endMs - startMs;\n const midpointMs = Math.round(startMs + durationMs / 2);\n return { absoluteRange, durationMs, midpointMs };\n}\n\nconst selectPanelStoreActions = (\n state: DashboardStoreState\n): {\n openEditPanel: DashboardStoreState['openEditPanel'];\n duplicatePanel: DashboardStoreState['duplicatePanel'];\n openDeletePanelDialog: DashboardStoreState['openDeletePanelDialog'];\n setViewPanel: DashboardStoreState['setViewPanel'];\n panelEditor: DashboardStoreState['panelEditor'];\n} => ({\n openEditPanel: state.openEditPanel,\n duplicatePanel: state.duplicatePanel,\n openDeletePanelDialog: state.openDeletePanelDialog,\n setViewPanel: state.setViewPanel,\n panelEditor: state.panelEditor,\n});\n\nexport interface UseDashboardShortcutsOptions {\n onSave?: OnSaveDashboard;\n onRefresh?: () => void;\n isReadonly: boolean;\n onEditButtonClick?: () => void;\n onCancelButtonClick?: () => void;\n disabled?: boolean;\n}\n\n/** Registers dashboard, time-range, and panel keyboard shortcuts. Requires DashboardProvider context. */\nexport function useDashboardShortcuts({\n onSave,\n onRefresh,\n isReadonly,\n onEditButtonClick,\n onCancelButtonClick,\n disabled = false,\n}: UseDashboardShortcutsOptions): void {\n const focusedPanelKey = useFocusedPanel();\n const { isEditMode, setEditMode } = useEditMode();\n const { timeRange, setTimeRange, refresh } = useTimeRange();\n const { infoSnackbar, warningSnackbar } = useSnackbar();\n const viewPanel = useViewPanelGroup();\n const { openEditPanel, duplicatePanel, openDeletePanelDialog, setViewPanel, panelEditor } =\n useDashboardStore(selectPanelStoreActions);\n const { saveDashboard } = useSaveDashboard(onSave);\n\n const panelFocused = focusedPanelKey !== null;\n\n // --- Handlers ---\n\n const handleSave = useCallback(() => {\n if (isReadonly) {\n warningSnackbar(SAVE_SHORTCUT_READONLY_MESSAGE);\n return;\n }\n\n if (!isEditMode) {\n infoSnackbar(SAVE_SHORTCUT_EDIT_MODE_MESSAGE);\n return;\n }\n\n if (!onSave) {\n warningSnackbar(SAVE_SHORTCUT_UNAVAILABLE_MESSAGE);\n return;\n }\n\n saveDashboard();\n }, [infoSnackbar, isEditMode, isReadonly, onSave, saveDashboard, warningSnackbar]);\n\n const handleRefresh = useCallback(() => {\n refresh();\n infoSnackbar('Dashboard refreshed.');\n if (onRefresh) {\n onRefresh();\n }\n }, [refresh, infoSnackbar, onRefresh]);\n\n const handleToggleEditMode = useCallback(() => {\n if (isEditMode) {\n // Switching from edit to view: delegate to cancel flow (shows discard dialog if needed)\n if (onCancelButtonClick) {\n onCancelButtonClick();\n } else {\n setEditMode(false);\n }\n } else {\n // Switching from view to edit: delegate to edit flow (saves original state)\n if (onEditButtonClick) {\n onEditButtonClick();\n } else {\n setEditMode(true);\n }\n }\n }, [isEditMode, setEditMode, onCancelButtonClick, onEditButtonClick]);\n\n // Time range handlers\n\n const handleTimeZoomOut = useCallback(() => {\n const { durationMs, midpointMs } = resolveAbsoluteRange(timeRange);\n const newDuration = Math.min(durationMs * 2, MAX_ZOOM_DURATION_MS);\n const halfNew = Math.round(newDuration / 2);\n setTimeRange({\n start: new Date(midpointMs - halfNew),\n end: new Date(midpointMs + halfNew),\n });\n }, [timeRange, setTimeRange]);\n\n const handleTimeZoomIn = useCallback(() => {\n const { durationMs, midpointMs } = resolveAbsoluteRange(timeRange);\n const newDuration = Math.max(Math.round(durationMs / 2), MIN_ZOOM_DURATION_MS);\n const halfNew = Math.round(newDuration / 2);\n setTimeRange({\n start: new Date(midpointMs - halfNew),\n end: new Date(midpointMs + halfNew),\n });\n }, [timeRange, setTimeRange]);\n\n const handleTimeShiftBack = useCallback(() => {\n const { absoluteRange, durationMs } = resolveAbsoluteRange(timeRange);\n const shift = Math.round(durationMs / 2);\n setTimeRange({\n start: new Date(absoluteRange.start.getTime() - shift),\n end: new Date(absoluteRange.end.getTime() - shift),\n });\n }, [timeRange, setTimeRange]);\n\n const handleTimeShiftForward = useCallback(() => {\n const { absoluteRange, durationMs } = resolveAbsoluteRange(timeRange);\n const shift = Math.round(durationMs / 2);\n setTimeRange({\n start: new Date(absoluteRange.start.getTime() + shift),\n end: new Date(absoluteRange.end.getTime() + shift),\n });\n }, [timeRange, setTimeRange]);\n\n const handleTimeMakeAbsolute = useCallback(() => {\n if (isRelativeTimeRange(timeRange)) {\n setTimeRange(toAbsoluteTimeRange(timeRange));\n }\n }, [timeRange, setTimeRange]);\n\n const handleTimeCopy = useCallback(() => {\n const absoluteRange = isRelativeTimeRange(timeRange) ? toAbsoluteTimeRange(timeRange) : timeRange;\n const text = `${absoluteRange.start.toISOString()} - ${absoluteRange.end.toISOString()}`;\n navigator.clipboard\n .writeText(text)\n .then(() => {\n infoSnackbar('Time range copied to clipboard.');\n })\n .catch(() => {\n warningSnackbar('Failed to copy time range to clipboard.');\n });\n }, [timeRange, infoSnackbar, warningSnackbar]);\n\n const handleTimePaste = useCallback(() => {\n const FORMAT_HINT = 'Expected format: \"<ISO date format> - <ISO date format>\".';\n navigator.clipboard\n .readText()\n .then((text) => {\n const parts = text.split(' - ');\n if (parts.length !== 2) {\n warningSnackbar(`Clipboard does not contain a valid time range. ${FORMAT_HINT}`);\n return;\n }\n const [startStr, endStr] = parts as [string, string];\n const start = new Date(startStr.trim());\n const end = new Date(endStr.trim());\n if (isNaN(start.getTime()) || isNaN(end.getTime())) {\n warningSnackbar(`Clipboard does not contain a valid time range. ${FORMAT_HINT}`);\n return;\n }\n if (start >= end) {\n warningSnackbar('Invalid time range: start must be before end.');\n return;\n }\n const newRange: AbsoluteTimeRange = { start, end };\n setTimeRange(newRange);\n infoSnackbar('Time range pasted from clipboard.');\n })\n .catch(() => {\n warningSnackbar('Unable to read from clipboard. Check browser permissions.');\n });\n }, [setTimeRange, infoSnackbar, warningSnackbar]);\n\n // Panel handlers\n const handlePanelEditToggle = useCallback(() => {\n if (panelEditor !== undefined) {\n panelEditor.close();\n return;\n }\n\n if (focusedPanelKey && isEditMode) {\n const panelId = parsePanelKey(focusedPanelKey);\n if (panelId) {\n openEditPanel(panelId);\n }\n }\n }, [focusedPanelKey, isEditMode, openEditPanel, panelEditor]);\n\n const handlePanelFullscreenToggle = useCallback(() => {\n if (viewPanel !== undefined) {\n setViewPanel(undefined);\n return;\n }\n\n if (focusedPanelKey) {\n const panelId = parsePanelKey(focusedPanelKey);\n if (panelId) {\n setViewPanel(panelId);\n }\n }\n }, [focusedPanelKey, setViewPanel, viewPanel]);\n\n const handlePanelDuplicate = useCallback(() => {\n if (focusedPanelKey && isEditMode) {\n const panelId = parsePanelKey(focusedPanelKey);\n if (panelId) {\n duplicatePanel(panelId);\n }\n }\n }, [focusedPanelKey, isEditMode, duplicatePanel]);\n\n const handlePanelDelete = useCallback(() => {\n if (focusedPanelKey && isEditMode) {\n const panelId = parsePanelKey(focusedPanelKey);\n if (panelId) {\n openDeletePanelDialog(panelId);\n }\n }\n }, [focusedPanelKey, isEditMode, openDeletePanelDialog]);\n\n // Register shortcuts\n\n useHotkeys(\n [\n { def: SAVE_DASHBOARD_SHORTCUT, enabled: !disabled, callback: handleSave },\n {\n def: PANEL_EDIT_SHORTCUT,\n enabled: !disabled && (panelFocused || panelEditor !== undefined),\n callback: handlePanelEditToggle,\n },\n {\n def: PANEL_FULLSCREEN_SHORTCUT,\n enabled: !disabled && (panelFocused || viewPanel !== undefined),\n callback: handlePanelFullscreenToggle,\n },\n ].map(({ def, enabled, callback }) => ({\n hotkey: requireShortcutHotkey(def),\n callback,\n options: buildShortcutOptions(def, enabled),\n }))\n );\n\n useHotkeySequences(\n [\n { def: REFRESH_DASHBOARD_SHORTCUT, enabled: !disabled, callback: handleRefresh },\n { def: TOGGLE_EDIT_MODE_SHORTCUT, enabled: !disabled, callback: handleToggleEditMode },\n { def: TIME_ZOOM_OUT_SHORTCUT, enabled: !disabled, callback: handleTimeZoomOut },\n { def: TIME_ZOOM_IN_SHORTCUT, enabled: !disabled, callback: handleTimeZoomIn },\n { def: TIME_SHIFT_BACK_SHORTCUT, enabled: !disabled, callback: handleTimeShiftBack },\n { def: TIME_SHIFT_FORWARD_SHORTCUT, enabled: !disabled, callback: handleTimeShiftForward },\n { def: TIME_MAKE_ABSOLUTE_SHORTCUT, enabled: !disabled, callback: handleTimeMakeAbsolute },\n { def: TIME_COPY_SHORTCUT, enabled: !disabled, callback: handleTimeCopy },\n { def: TIME_PASTE_SHORTCUT, enabled: !disabled, callback: handleTimePaste },\n { def: PANEL_DUPLICATE_SHORTCUT, enabled: !disabled && panelFocused, callback: handlePanelDuplicate },\n { def: PANEL_DELETE_SHORTCUT, enabled: !disabled && panelFocused, callback: handlePanelDelete },\n ].map(({ def, enabled, callback }) => ({\n sequence: requireShortcutSequence(def),\n callback,\n options: buildShortcutOptions(def, enabled),\n }))\n );\n}\n"],"names":["useCallback","isRelativeTimeRange","toAbsoluteTimeRange","useSnackbar","useTimeRange","useHotkeys","useHotkeySequences","useFocusedPanel","buildShortcutOptions","requireShortcutHotkey","requireShortcutSequence","SAVE_DASHBOARD_SHORTCUT","REFRESH_DASHBOARD_SHORTCUT","TOGGLE_EDIT_MODE_SHORTCUT","TIME_ZOOM_OUT_SHORTCUT","TIME_ZOOM_IN_SHORTCUT","TIME_SHIFT_BACK_SHORTCUT","TIME_SHIFT_FORWARD_SHORTCUT","TIME_MAKE_ABSOLUTE_SHORTCUT","TIME_COPY_SHORTCUT","TIME_PASTE_SHORTCUT","PANEL_EDIT_SHORTCUT","PANEL_FULLSCREEN_SHORTCUT","PANEL_DUPLICATE_SHORTCUT","PANEL_DELETE_SHORTCUT","useEditMode","useDashboardStore","useViewPanelGroup","useSaveDashboard","SAVE_SHORTCUT_EDIT_MODE_MESSAGE","SAVE_SHORTCUT_READONLY_MESSAGE","SAVE_SHORTCUT_UNAVAILABLE_MESSAGE","parsePanelKey","panelKey","dashIndex","indexOf","panelGroupId","parseInt","substring","panelGroupItemLayoutId","isNaN","MIN_ZOOM_DURATION_MS","MAX_ZOOM_DURATION_MS","resolveAbsoluteRange","timeRange","absoluteRange","startMs","start","getTime","endMs","end","durationMs","midpointMs","Math","round","selectPanelStoreActions","state","openEditPanel","duplicatePanel","openDeletePanelDialog","setViewPanel","panelEditor","useDashboardShortcuts","onSave","onRefresh","isReadonly","onEditButtonClick","onCancelButtonClick","disabled","focusedPanelKey","isEditMode","setEditMode","setTimeRange","refresh","infoSnackbar","warningSnackbar","viewPanel","saveDashboard","panelFocused","handleSave","handleRefresh","handleToggleEditMode","handleTimeZoomOut","newDuration","min","halfNew","Date","handleTimeZoomIn","max","handleTimeShiftBack","shift","handleTimeShiftForward","handleTimeMakeAbsolute","handleTimeCopy","text","toISOString","navigator","clipboard","writeText","then","catch","handleTimePaste","FORMAT_HINT","readText","parts","split","length","startStr","endStr","trim","newRange","handlePanelEditToggle","undefined","close","panelId","handlePanelFullscreenToggle","handlePanelDuplicate","handlePanelDelete","def","enabled","callback","map","hotkey","options","sequence"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,WAAW,QAAQ,QAAQ;AACpC,SAA4CC,mBAAmB,EAAEC,mBAAmB,QAAQ,mBAAmB;AAC/G,SAASC,WAAW,QAAQ,yBAAyB;AACrD,SAASC,YAAY,QAAQ,4BAA4B;AACzD,SAASC,UAAU,EAAEC,kBAAkB,QAAQ,0BAA0B;AAEzE,SACEC,eAAe,EACfC,oBAAoB,EACpBC,qBAAqB,EACrBC,uBAAuB,EACvBC,uBAAuB,EACvBC,0BAA0B,EAC1BC,yBAAyB,EACzBC,sBAAsB,EACtBC,qBAAqB,EACrBC,wBAAwB,EACxBC,2BAA2B,EAC3BC,2BAA2B,EAC3BC,kBAAkB,EAClBC,mBAAmB,EACnBC,mBAAmB,EACnBC,yBAAyB,EACzBC,wBAAwB,EACxBC,qBAAqB,QA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ACrC,CAAA;IAGFjH,mBACE;QACE;YAAEgH,KAAK1G;YAA4B2G,SAAS,CAACnD;YAAUoD,UAAUxC;QAAc;QAC/E;YAAEsC,KAAKzG;YAA2B0G,SAAS,CAACnD;YAAUoD,UAAUvC;QAAqB;QACrF;YAAEqC,KAAKxG;YAAwByG,SAAS,CAACnD;YAAUoD,UAAUtC;QAAkB;QAC/E;YAAEoC,KAAKvG;YAAuBwG,SAAS,CAACnD;YAAUoD,UAAUjC;QAAiB;QAC7E;YAAE+B,KAAKtG;YAA0BuG,SAAS,CAACnD;YAAUoD,UAAU/B;QAAoB;QACnF;YAAE6B,KAAKrG;YAA6BsG,SAAS,CAACnD;YAAUoD,UAAU7B;QAAuB;QACzF;YAAE2B,KAAKpG;YAA6BqG,SAAS,CAACnD;YAAUoD,UAAU5B;QAAuB;QACzF;YAAE0B,KAAKnG;YAAoBoG,SAAS,CAACnD;YAAUoD,UAAU3B;QAAe;QACxE;YAAEyB,KAAKlG;YAAqBmG,SAAS,CAACnD;YAAUoD,UAAUnB;QAAgB;QAC1E;YAAEiB,KAAK/F;YAA0BgG,SAAS,CAACnD,YAAYU;YAAc0C,UAAUJ;QAAqB;QACpG;YAAEE,KAAK9F;YAAuB+F,SAAS,CAACnD,YAAYU;YAAc0C,UAAUH;QAAkB;KAC/F,CAACI,GAAG,CAAC,CAAC,EAAEH,GAAG,EAAEC,OAAO,EAAEC,QAAQ,EAAE,GAAM,CAAA;YACrCI,UAAUlH,wBAAwB4G;YAClCE;YACAG,SAASnH,qBAAqB8G,KAAKC;QACrC,CAAA;AAEJ"}
@@ -1,3 +1,4 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
2
  // Copyright The Perses Authors
2
3
  // Licensed under the Apache License, Version 2.0 (the "License");
3
4
  // you may not use this file except in compliance with the License.
@@ -10,7 +11,6 @@
10
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
12
  // See the License for the specific language governing permissions and
12
13
  // limitations under the License.
13
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  import { useState } from 'react';
15
15
  import { AppBar, Box, IconButton, Stack, useMediaQuery, useScrollTrigger, useTheme } from '@mui/material';
16
16
  import PinOutline from 'mdi-material-ui/PinOutline';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/DashboardStickyToolbar/DashboardStickyToolbar.tsx"],"sourcesContent":["// Copyright 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 {\n AppBar,\n Box,\n IconButton,\n Stack,\n SxProps,\n Theme,\n useMediaQuery,\n useScrollTrigger,\n useTheme,\n} from '@mui/material';\nimport PinOutline from 'mdi-material-ui/PinOutline';\nimport PinOffOutline from 'mdi-material-ui/PinOffOutline';\nimport { TimeRangeControls, useTimeZoneParams } from '@perses-dev/plugin-system';\nimport { VariableList } from '../Variables';\n\ninterface DashboardStickyToolbarProps {\n initialVariableIsSticky?: boolean;\n sx?: SxProps<Theme>;\n}\n\nexport function DashboardStickyToolbar(props: DashboardStickyToolbarProps): ReactElement {\n const [isPin, setIsPin] = useState(props.initialVariableIsSticky);\n\n const scrollTrigger = useScrollTrigger({ disableHysteresis: true });\n const isSticky = scrollTrigger && props.initialVariableIsSticky && isPin;\n\n const isBiggerThanMd = useMediaQuery(useTheme().breakpoints.up('md'));\n\n const { timeZone, setTimeZone } = useTimeZoneParams('local');\n\n return (\n // marginBottom={-1} counteracts the marginBottom={1} on every variable input.\n // The margin on the inputs is for spacing between inputs, but is not meant to add space to bottom of the container.\n <Box marginBottom={-1} data-testid=\"variable-list\">\n <AppBar\n color=\"inherit\"\n position={isSticky ? 'fixed' : 'static'}\n elevation={isSticky ? 4 : 0}\n sx={{ backgroundColor: 'inherit', ...props.sx }}\n >\n <Box\n display=\"flex\"\n justifyContent=\"space-between\"\n sx={{\n flexDirection: isBiggerThanMd ? 'row' : 'column',\n }}\n >\n <Box\n display=\"flex\"\n flexWrap={!isSticky && isBiggerThanMd ? 'wrap' : 'nowrap'}\n maxWidth={isSticky || !isBiggerThanMd ? '100vw' : '100%'}\n pt={1}\n pl={isSticky ? 1 : 0}\n mt={isSticky && isBiggerThanMd ? 0.5 : 0}\n ml={isSticky && isBiggerThanMd ? 0.5 : 0}\n sx={{\n overflowX: !isSticky && isBiggerThanMd ? 'hidden' : 'auto',\n // Firefox:\n scrollbarWidth: 'thin',\n // Safari and Chrome:\n '&::-webkit-scrollbar': {\n height: '8px',\n backgroundColor: (theme) => theme.palette.grey['300'],\n },\n '&::-webkit-scrollbar-thumb': {\n background: (theme) => theme.palette.grey['600'],\n },\n }}\n gap={1}\n >\n <VariableList />\n {props.initialVariableIsSticky && (\n <IconButton style={{ width: 'fit-content', height: 'fit-content' }} onClick={() => setIsPin(!isPin)}>\n {isPin ? <PinOutline /> : <PinOffOutline />}\n </IconButton>\n )}\n </Box>\n {isSticky && (\n <Stack\n m={isBiggerThanMd ? 1.5 : 1}\n mt={isBiggerThanMd ? 1.5 : 0}\n ml={isBiggerThanMd ? 1.5 : 'auto'}\n direction=\"row\"\n justifyContent=\"end\"\n >\n <TimeRangeControls timeZone={timeZone} onTimeZoneChange={(tz) => setTimeZone(tz.value)} />\n </Stack>\n )}\n </Box>\n </AppBar>\n </Box>\n );\n}\n"],"names":["useState","AppBar","Box","IconButton","Stack","useMediaQuery","useScrollTrigger","useTheme","PinOutline","PinOffOutline","TimeRangeControls","useTimeZoneParams","VariableList","DashboardStickyToolbar","props","isPin","setIsPin","initialVariableIsSticky","scrollTrigger","disableHysteresis","isSticky","isBiggerThanMd","breakpoints","up","timeZone","setTimeZone","marginBottom","data-testid","color","position","elevation","sx","backgroundColor","display","justifyContent","flexDirection","flexWrap","maxWidth","pt","pl","mt","ml","overflowX","scrollbarWidth","height","theme","palette","grey","background","gap","style","width","onClick","m","direction","onTimeZoneChange","tz","value"],"mappings":"AAAA,+BAA+B;AAC/B,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,SACEC,MAAM,EACNC,GAAG,EACHC,UAAU,EACVC,KAAK,EAGLC,aAAa,EACbC,gBAAgB,EAChBC,QAAQ,QACH,gBAAgB;AACvB,OAAOC,gBAAgB,6BAA6B;AACpD,OAAOC,mBAAmB,gCAAgC;AAC1D,SAASC,iBAAiB,EAAEC,iBAAiB,QAAQ,4BAA4B;AACjF,SAASC,YAAY,QAAQ,eAAe;AAO5C,OAAO,SAASC,uBAAuBC,KAAkC;IACvE,MAAM,CAACC,OAAOC,SAAS,GAAGhB,SAASc,MAAMG,uBAAuB;IAEhE,MAAMC,gBAAgBZ,iBAAiB;QAAEa,mBAAmB;IAAK;IACjE,MAAMC,WAAWF,iBAAiBJ,MAAMG,uBAAuB,IAAIF;IAEnE,MAAMM,iBAAiBhB,cAAcE,WAAWe,WAAW,CAACC,EAAE,CAAC;IAE/D,MAAM,EAAEC,QAAQ,EAAEC,WAAW,EAAE,GAAGd,kBAAkB;IAEpD,OACE,8EAA8E;IAC9E,oHAAoH;kBACpH,KAACT;QAAIwB,cAAc,CAAC;QAAGC,eAAY;kBACjC,cAAA,KAAC1B;YACC2B,OAAM;YACNC,UAAUT,WAAW,UAAU;YAC/BU,WAAWV,WAAW,IAAI;YAC1BW,IAAI;gBAAEC,iBAAiB;gBAAW,GAAGlB,MAAMiB,EAAE;YAAC;sBAE9C,cAAA,MAAC7B;gBACC+B,SAAQ;gBACRC,gBAAe;gBACfH,IAAI;oBACFI,eAAed,iBAAiB,QAAQ;gBAC1C;;kCAEA,MAACnB;wBACC+B,SAAQ;wBACRG,UAAU,CAAChB,YAAYC,iBAAiB,SAAS;wBACjDgB,UAAUjB,YAAY,CAACC,iBAAiB,UAAU;wBAClDiB,IAAI;wBACJC,IAAInB,WAAW,IAAI;wBACnBoB,IAAIpB,YAAYC,iBAAiB,MAAM;wBACvCoB,IAAIrB,YAAYC,iBAAiB,MAAM;wBACvCU,IAAI;4BACFW,WAAW,CAACtB,YAAYC,iBAAiB,WAAW;4BACpD,WAAW;4BACXsB,gBAAgB;4BAChB,qBAAqB;4BACrB,wBAAwB;gCACtBC,QAAQ;gCACRZ,iBAAiB,CAACa,QAAUA,MAAMC,OAAO,CAACC,IAAI,CAAC,MAAM;4BACvD;4BACA,8BAA8B;gCAC5BC,YAAY,CAACH,QAAUA,MAAMC,OAAO,CAACC,IAAI,CAAC,MAAM;4BAClD;wBACF;wBACAE,KAAK;;0CAEL,KAACrC;4BACAE,MAAMG,uBAAuB,kBAC5B,KAACd;gCAAW+C,OAAO;oCAAEC,OAAO;oCAAeP,QAAQ;gCAAc;gCAAGQ,SAAS,IAAMpC,SAAS,CAACD;0CAC1FA,sBAAQ,KAACP,gCAAgB,KAACC;;;;oBAIhCW,0BACC,KAAChB;wBACCiD,GAAGhC,iBAAiB,MAAM;wBAC1BmB,IAAInB,iBAAiB,MAAM;wBAC3BoB,IAAIpB,iBAAiB,MAAM;wBAC3BiC,WAAU;wBACVpB,gBAAe;kCAEf,cAAA,KAACxB;4BAAkBc,UAAUA;4BAAU+B,kBAAkB,CAACC,KAAO/B,YAAY+B,GAAGC,KAAK;;;;;;;AAOnG"}
1
+ {"version":3,"sources":["../../../src/components/DashboardStickyToolbar/DashboardStickyToolbar.tsx"],"sourcesContent":["// Copyright 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 {\n AppBar,\n Box,\n IconButton,\n Stack,\n SxProps,\n Theme,\n useMediaQuery,\n useScrollTrigger,\n useTheme,\n} from '@mui/material';\nimport PinOutline from 'mdi-material-ui/PinOutline';\nimport PinOffOutline from 'mdi-material-ui/PinOffOutline';\nimport { TimeRangeControls, useTimeZoneParams } from '@perses-dev/plugin-system';\nimport { VariableList } from '../Variables';\n\ninterface DashboardStickyToolbarProps {\n initialVariableIsSticky?: boolean;\n sx?: SxProps<Theme>;\n}\n\nexport function DashboardStickyToolbar(props: DashboardStickyToolbarProps): ReactElement {\n const [isPin, setIsPin] = useState(props.initialVariableIsSticky);\n\n const scrollTrigger = useScrollTrigger({ disableHysteresis: true });\n const isSticky = scrollTrigger && props.initialVariableIsSticky && isPin;\n\n const isBiggerThanMd = useMediaQuery(useTheme().breakpoints.up('md'));\n\n const { timeZone, setTimeZone } = useTimeZoneParams('local');\n\n return (\n // marginBottom={-1} counteracts the marginBottom={1} on every variable input.\n // The margin on the inputs is for spacing between inputs, but is not meant to add space to bottom of the container.\n <Box marginBottom={-1} data-testid=\"variable-list\">\n <AppBar\n color=\"inherit\"\n position={isSticky ? 'fixed' : 'static'}\n elevation={isSticky ? 4 : 0}\n sx={{ backgroundColor: 'inherit', ...props.sx }}\n >\n <Box\n display=\"flex\"\n justifyContent=\"space-between\"\n sx={{\n flexDirection: isBiggerThanMd ? 'row' : 'column',\n }}\n >\n <Box\n display=\"flex\"\n flexWrap={!isSticky && isBiggerThanMd ? 'wrap' : 'nowrap'}\n maxWidth={isSticky || !isBiggerThanMd ? '100vw' : '100%'}\n pt={1}\n pl={isSticky ? 1 : 0}\n mt={isSticky && isBiggerThanMd ? 0.5 : 0}\n ml={isSticky && isBiggerThanMd ? 0.5 : 0}\n sx={{\n overflowX: !isSticky && isBiggerThanMd ? 'hidden' : 'auto',\n // Firefox:\n scrollbarWidth: 'thin',\n // Safari and Chrome:\n '&::-webkit-scrollbar': {\n height: '8px',\n backgroundColor: (theme) => theme.palette.grey['300'],\n },\n '&::-webkit-scrollbar-thumb': {\n background: (theme) => theme.palette.grey['600'],\n },\n }}\n gap={1}\n >\n <VariableList />\n {props.initialVariableIsSticky && (\n <IconButton style={{ width: 'fit-content', height: 'fit-content' }} onClick={() => setIsPin(!isPin)}>\n {isPin ? <PinOutline /> : <PinOffOutline />}\n </IconButton>\n )}\n </Box>\n {isSticky && (\n <Stack\n m={isBiggerThanMd ? 1.5 : 1}\n mt={isBiggerThanMd ? 1.5 : 0}\n ml={isBiggerThanMd ? 1.5 : 'auto'}\n direction=\"row\"\n justifyContent=\"end\"\n >\n <TimeRangeControls timeZone={timeZone} onTimeZoneChange={(tz) => setTimeZone(tz.value)} />\n </Stack>\n )}\n </Box>\n </AppBar>\n </Box>\n );\n}\n"],"names":["useState","AppBar","Box","IconButton","Stack","useMediaQuery","useScrollTrigger","useTheme","PinOutline","PinOffOutline","TimeRangeControls","useTimeZoneParams","VariableList","DashboardStickyToolbar","props","isPin","setIsPin","initialVariableIsSticky","scrollTrigger","disableHysteresis","isSticky","isBiggerThanMd","breakpoints","up","timeZone","setTimeZone","marginBottom","data-testid","color","position","elevation","sx","backgroundColor","display","justifyContent","flexDirection","flexWrap","maxWidth","pt","pl","mt","ml","overflowX","scrollbarWidth","height","theme","palette","grey","background","gap","style","width","onClick","m","direction","onTimeZoneChange","tz","value"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAAuBA,Q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iBAAiB,WAAW;4BACpD,WAAW;4BACXsB,gBAAgB;4BAChB,qBAAqB;4BACrB,wBAAwB;gCACtBC,QAAQ;gCACRZ,iBAAiB,CAACa,QAAUA,MAAMC,OAAO,CAACC,IAAI,CAAC,MAAM;4BACvD;4BACA,8BAA8B;gCAC5BC,YAAY,CAACH,QAAUA,MAAMC,OAAO,CAACC,IAAI,CAAC,MAAM;4BAClD;wBACF;wBACAE,KAAK;;0CAEL,KAACrC;4BACAE,MAAMG,uBAAuB,kBAC5B,KAACd;gCAAW+C,OAAO;oCAAEC,OAAO;oCAAeP,QAAQ;gCAAc;gCAAGQ,SAAS,IAAMpC,SAAS,CAACD;0CAC1FA,sBAAQ,KAACP,gCAAgB,KAACC;;;;oBAIhCW,0BACC,KAAChB;wBACCiD,GAAGhC,iBAAiB,MAAM;wBAC1BmB,IAAInB,iBAAiB,MAAM;wBAC3BoB,IAAIpB,iBAAiB,MAAM;wBAC3BiC,WAAU;wBACVpB,gBAAe;kCAEf,cAAA,KAACxB;4BAAkBc,UAAUA;4BAAU+B,kBAAkB,CAACC,KAAO/B,YAAY+B,GAAGC,KAAK;;;;;;;AAOnG"}
@@ -1,3 +1,4 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
1
2
  // Copyright The Perses Authors
2
3
  // Licensed under the Apache License, Version 2.0 (the "License");
3
4
  // you may not use this file except in compliance with the License.
@@ -10,7 +11,6 @@
10
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
12
  // See the License for the specific language governing permissions and
12
13
  // limitations under the License.
13
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
14
14
  import { Typography, Stack, Button, Box, useTheme, useMediaQuery, Alert } from '@mui/material';
15
15
  import { ErrorBoundary, ErrorAlert } from '@perses-dev/components';
16
16
  import { TimeRangeControls, useTimeZoneParams } from '@perses-dev/plugin-system';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/DashboardToolbar/DashboardToolbar.tsx"],"sourcesContent":["// Copyright 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 { Typography, Stack, Button, Box, useTheme, useMediaQuery, Alert } from '@mui/material';\nimport { ErrorBoundary, ErrorAlert } from '@perses-dev/components';\nimport { TimeRangeControls, useTimeZoneParams } from '@perses-dev/plugin-system';\nimport { ReactElement, ReactNode } from 'react';\nimport { OnSaveDashboard, useEditMode, useDashboardLinks } from '../../context';\nimport { AddPanelButton } from '../AddPanelButton';\nimport { AddGroupButton } from '../AddGroupButton';\nimport { DownloadButton } from '../DownloadButton';\nimport { EditVariablesButton } from '../Variables';\nimport { EditDatasourcesButton } from '../Datasources';\nimport { EditButton } from '../EditButton';\nimport { EditJsonButton } from '../EditJsonButton';\nimport { SaveDashboardButton } from '../SaveDashboardButton';\nimport { DashboardStickyToolbar } from '../DashboardStickyToolbar';\nimport { EditDashboardLinksButton } from '../DashboardLinks';\nimport { LinksDisplay } from '../LinksDisplay';\n\nexport interface DashboardToolbarProps {\n dashboardName: string;\n dashboardTitleComponent?: ReactNode;\n initialVariableIsSticky?: boolean;\n isReadonly: boolean;\n isVariableEnabled: boolean;\n isDatasourceEnabled: boolean;\n isLinksEnabled?: boolean;\n onEditButtonClick: () => void;\n onCancelButtonClick: () => void;\n onSave?: OnSaveDashboard;\n}\n\nexport const DashboardToolbar = (props: DashboardToolbarProps): ReactElement => {\n const {\n dashboardName,\n dashboardTitleComponent,\n initialVariableIsSticky,\n isReadonly,\n isVariableEnabled,\n isDatasourceEnabled,\n isLinksEnabled = true,\n onEditButtonClick,\n onCancelButtonClick,\n onSave,\n } = props;\n\n const { isEditMode } = useEditMode();\n const { timeZone, setTimeZone } = useTimeZoneParams('local');\n const dashboardLinks = useDashboardLinks();\n\n const isBiggerThanSm = useMediaQuery(useTheme().breakpoints.up('sm'));\n const isBiggerThanMd = useMediaQuery(useTheme().breakpoints.up('md'));\n\n const dashboardTitle = dashboardTitleComponent ? (\n dashboardTitleComponent\n ) : (\n <Typography variant=\"h2\">{dashboardName}</Typography>\n );\n\n const testId = 'dashboard-toolbar';\n\n return (\n <>\n <Stack data-testid={testId}>\n <Box\n px={2}\n py={1.5}\n display=\"flex\"\n sx={{ gap: 2, backgroundColor: (theme) => theme.palette.primary.main + (isEditMode ? '30' : '0') }}\n >\n {dashboardTitle}\n {isLinksEnabled && (\n <Stack display=\"flex\" justifyItems=\"center\" alignItems=\"center\" justifyContent=\"center\">\n <LinksDisplay links={dashboardLinks} variant=\"dashboard\" />\n </Stack>\n )}\n {isEditMode ? (\n <Stack direction=\"row\" gap={1} ml=\"auto\">\n {isReadonly && (\n <Alert severity=\"warning\" sx={{ backgroundColor: 'transparent', padding: 0 }}>\n Dashboard managed via code only. Download JSON and commit changes to save.\n </Alert>\n )}\n <Stack direction=\"row\" spacing={0.5} ml={1} whiteSpace=\"nowrap\">\n {isVariableEnabled && <EditVariablesButton />}\n {isDatasourceEnabled && <EditDatasourcesButton />}\n {isLinksEnabled && <EditDashboardLinksButton />}\n <AddPanelButton />\n <AddGroupButton />\n </Stack>\n <SaveDashboardButton onSave={onSave} isDisabled={isReadonly} />\n <Button variant=\"outlined\" onClick={onCancelButtonClick}>\n Cancel\n </Button>\n </Stack>\n ) : (\n <>\n {isBiggerThanSm && (\n <Stack direction=\"row\" gap={1} ml=\"auto\">\n <EditButton onClick={onEditButtonClick} />\n </Stack>\n )}\n </>\n )}\n </Box>\n <Box\n sx={{\n display: 'flex',\n width: '100%',\n alignItems: 'start',\n padding: (theme) => theme.spacing(1, 2, 0, 2),\n flexDirection: isBiggerThanMd ? 'row' : 'column',\n flexWrap: 'nowrap',\n gap: 1,\n }}\n >\n <Box width=\"100%\">\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <DashboardStickyToolbar\n initialVariableIsSticky={initialVariableIsSticky}\n sx={{\n backgroundColor: ({ palette }) => palette.background.default,\n }}\n />\n </ErrorBoundary>\n </Box>\n <Stack direction=\"row\" ml=\"auto\" flexWrap=\"wrap\" justifyContent=\"end\">\n <Stack direction=\"row\" spacing={1} mt={1} ml={1}>\n <TimeRangeControls timeZone={timeZone} onTimeZoneChange={(tz) => setTimeZone(tz.value)} />\n <DownloadButton />\n <EditJsonButton isReadonly={!isEditMode} />\n </Stack>\n </Stack>\n </Box>\n </Stack>\n </>\n );\n};\n"],"names":["Typography","Stack","Button","Box","useTheme","useMediaQuery","Alert","ErrorBoundary","ErrorAlert","TimeRangeControls","useTimeZoneParams","useEditMode","useDashboardLinks","AddPanelButton","AddGroupButton","DownloadButton","EditVariablesButton","EditDatasourcesButton","EditButton","EditJsonButton","SaveDashboardButton","DashboardStickyToolbar","EditDashboardLinksButton","LinksDisplay","DashboardToolbar","props","dashboardName","dashboardTitleComponent","initialVariableIsSticky","isReadonly","isVariableEnabled","isDatasourceEnabled","isLinksEnabled","onEditButtonClick","onCancelButtonClick","onSave","isEditMode","timeZone","setTimeZone","dashboardLinks","isBiggerThanSm","breakpoints","up","isBiggerThanMd","dashboardTitle","variant","testId","data-testid","px","py","display","sx","gap","backgroundColor","theme","palette","primary","main","justifyItems","alignItems","justifyContent","links","direction","ml","severity","padding","spacing","whiteSpace","isDisabled","onClick","width","flexDirection","flexWrap","FallbackComponent","background","default","mt","onTimeZoneChange","tz","value"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,UAAU,EAAEC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BAAyBA;oCACzBuB,IAAI;wCACFE,iBAAiB,CAAC,EAAEE,OAAO,EAAE,GAAKA,QAAQmB,UAAU,CAACC,OAAO;oCAC9D;;;;sCAIN,KAAC1E;4BAAM6D,WAAU;4BAAMC,IAAG;4BAAOS,UAAS;4BAAOZ,gBAAe;sCAC9D,cAAA,MAAC3D;gCAAM6D,WAAU;gCAAMI,SAAS;gCAAGU,IAAI;gCAAGb,IAAI;;kDAC5C,KAACtD;wCAAkB4B,UAAUA;wCAAUwC,kBAAkB,CAACC,KAAOxC,YAAYwC,GAAGC,KAAK;;kDACrF,KAAChE;kDACD,KAACI;wCAAeU,YAAY,CAACO;;;;;;;;;;AAO3C,EAAE"}
1
+ {"version":3,"sources":["../../../src/components/DashboardToolbar/DashboardToolbar.tsx"],"sourcesContent":["// Copyright 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 { Typography, Stack, Button, Box, useTheme, useMediaQuery, Alert } from '@mui/material';\nimport { ErrorBoundary, ErrorAlert } from '@perses-dev/components';\nimport { TimeRangeControls, useTimeZoneParams } from '@perses-dev/plugin-system';\nimport { ReactElement, ReactNode } from 'react';\nimport { OnSaveDashboard, useEditMode, useDashboardLinks } from '../../context';\nimport { AddPanelButton } from '../AddPanelButton';\nimport { AddGroupButton } from '../AddGroupButton';\nimport { DownloadButton } from '../DownloadButton';\nimport { EditVariablesButton } from '../Variables';\nimport { EditDatasourcesButton } from '../Datasources';\nimport { EditButton } from '../EditButton';\nimport { EditJsonButton } from '../EditJsonButton';\nimport { SaveDashboardButton } from '../SaveDashboardButton';\nimport { DashboardStickyToolbar } from '../DashboardStickyToolbar';\nimport { EditDashboardLinksButton } from '../DashboardLinks';\nimport { LinksDisplay } from '../LinksDisplay';\n\nexport interface DashboardToolbarProps {\n dashboardName: string;\n dashboardTitleComponent?: ReactNode;\n initialVariableIsSticky?: boolean;\n isReadonly: boolean;\n isVariableEnabled: boolean;\n isDatasourceEnabled: boolean;\n isLinksEnabled?: boolean;\n onEditButtonClick: () => void;\n onCancelButtonClick: () => void;\n onSave?: OnSaveDashboard;\n}\n\nexport const DashboardToolbar = (props: DashboardToolbarProps): ReactElement => {\n const {\n dashboardName,\n dashboardTitleComponent,\n initialVariableIsSticky,\n isReadonly,\n isVariableEnabled,\n isDatasourceEnabled,\n isLinksEnabled = true,\n onEditButtonClick,\n onCancelButtonClick,\n onSave,\n } = props;\n\n const { isEditMode } = useEditMode();\n const { timeZone, setTimeZone } = useTimeZoneParams('local');\n const dashboardLinks = useDashboardLinks();\n\n const isBiggerThanSm = useMediaQuery(useTheme().breakpoints.up('sm'));\n const isBiggerThanMd = useMediaQuery(useTheme().breakpoints.up('md'));\n\n const dashboardTitle = dashboardTitleComponent ? (\n dashboardTitleComponent\n ) : (\n <Typography variant=\"h2\">{dashboardName}</Typography>\n );\n\n const testId = 'dashboard-toolbar';\n\n return (\n <>\n <Stack data-testid={testId}>\n <Box\n px={2}\n py={1.5}\n display=\"flex\"\n sx={{ gap: 2, backgroundColor: (theme) => theme.palette.primary.main + (isEditMode ? '30' : '0') }}\n >\n {dashboardTitle}\n {isLinksEnabled && (\n <Stack display=\"flex\" justifyItems=\"center\" alignItems=\"center\" justifyContent=\"center\">\n <LinksDisplay links={dashboardLinks} variant=\"dashboard\" />\n </Stack>\n )}\n {isEditMode ? (\n <Stack direction=\"row\" gap={1} ml=\"auto\">\n {isReadonly && (\n <Alert severity=\"warning\" sx={{ backgroundColor: 'transparent', padding: 0 }}>\n Dashboard managed via code only. Download JSON and commit changes to save.\n </Alert>\n )}\n <Stack direction=\"row\" spacing={0.5} ml={1} whiteSpace=\"nowrap\">\n {isVariableEnabled && <EditVariablesButton />}\n {isDatasourceEnabled && <EditDatasourcesButton />}\n {isLinksEnabled && <EditDashboardLinksButton />}\n <AddPanelButton />\n <AddGroupButton />\n </Stack>\n <SaveDashboardButton onSave={onSave} isDisabled={isReadonly} />\n <Button variant=\"outlined\" onClick={onCancelButtonClick}>\n Cancel\n </Button>\n </Stack>\n ) : (\n <>\n {isBiggerThanSm && (\n <Stack direction=\"row\" gap={1} ml=\"auto\">\n <EditButton onClick={onEditButtonClick} />\n </Stack>\n )}\n </>\n )}\n </Box>\n <Box\n sx={{\n display: 'flex',\n width: '100%',\n alignItems: 'start',\n padding: (theme) => theme.spacing(1, 2, 0, 2),\n flexDirection: isBiggerThanMd ? 'row' : 'column',\n flexWrap: 'nowrap',\n gap: 1,\n }}\n >\n <Box width=\"100%\">\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <DashboardStickyToolbar\n initialVariableIsSticky={initialVariableIsSticky}\n sx={{\n backgroundColor: ({ palette }) => palette.background.default,\n }}\n />\n </ErrorBoundary>\n </Box>\n <Stack direction=\"row\" ml=\"auto\" flexWrap=\"wrap\" justifyContent=\"end\">\n <Stack direction=\"row\" spacing={1} mt={1} ml={1}>\n <TimeRangeControls timeZone={timeZone} onTimeZoneChange={(tz) => setTimeZone(tz.value)} />\n <DownloadButton />\n <EditJsonButton isReadonly={!isEditMode} />\n </Stack>\n </Stack>\n </Box>\n </Stack>\n </>\n );\n};\n"],"names":["Typography","Stack","Button","Box","useTheme","useMediaQuery","Alert","ErrorBoundary","ErrorAlert","TimeRangeControls","useTimeZoneParams","useEditMode","useDashboardLinks","AddPanelButton","AddGroupButton","DownloadButton","EditVariablesButton","EditDatasourcesButton","EditButton","EditJsonButton","SaveDashboardButton","DashboardStickyToolbar","EditDashboardLinksButton","LinksDisplay","DashboardToolbar","props","dashboardName","dashboardTitleComponent","initialVariableIsSticky","isReadonly","isVariableEnabled","isDatasourceEnabled","isLinksEnabled","onEditButtonClick","onCancelButtonClick","onSave","isEditMode","timeZone","setTimeZone","dashboardLinks","isBiggerThanSm","breakpoints","up","isBiggerThanMd","dashboardTitle","variant","testId","data-testid","px","py","display","sx","gap","backgroundColor","theme","palette","primary","main","justifyItems","alignItems","justifyContent","links","direction","ml","severity","padding","spacing","whiteSpace","isDisabled","onClick","width","flexDirection","flexWrap","FallbackComponent","background","default","mt","onTimeZoneChange","tz","value"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,UAAU,EAAEC,KAAK,EAAEC,MAAM,EAAEC,GAAG,EAAEC,QAAQ,EAAEC,aAAa,EAAEC,KAAK,QAAQ,gBAAgB;AAC/F,SAASC,aAAa,EAAEC,UAAU,QAAQ,yBAAyB;AACnE,SAASC,iBAAiB,EAAEC,iBAAiB,QAAQ,4BAA4B;AAEjF,SAA0BC,WAAW,EAAEC,iBAAiB,QAAQ,gBAAgB;AAChF,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,mBAAmB,QAAQ,eAAe;AACnD,SAASC,qBAAqB,QAAQ,iBAAiB;AACvD,SAASC,UAAU,QAAQ,gBAAgB;AAC3C,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,mBAAmB,QAAQ,yBAAyB;AAC7D,SAASC,sBAAsB,QAAQ,4BAA4B;AACnE,SAASC,wBAAwB,QAAQ,oBAAoB;AAC7D,SAASC,YAAY,QAAQ,kBAAkB;AAe/C,OAAO,MAAMC,mBAAmB,CAACC;IAC/B,MAAM,EACJC,aAAa,EACbC,uBAAuB,EACvBC,uBAAuB,EACvBC,UAAU,EACVC,iBAAiB,EACjBC,mBAAmB,EACnBC,iBAAiB,IAAI,EACrB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AAWwB,SAASnC;8CAAqB;;;2CAK3D;sCACGM,gCACC,KAACvC;gCAAM6D,WAAU;gCAAMV,KAAK;gCAAGW,IAAG;0CAChC,cAAA,KAAC7C;oCAAWmD,SAASpC;;;;;;8BAM/B,MAAC9B;oBACCgD,IAAI;wBACFD,SAAS;wBACToB,OAAO;wBACPX,YAAY;wBACZM,SAAS,CAACX,QAAUA,MAAMY,OAAO,CAAC,GAAG,GAAG,GAAG;wBAC3CK,eAAe5B,iBAAiB,QAAQ;wBACxC6B,UAAU;wBACVpB,KAAK;oBACP;;sCAEA,KAACjD;4BAAImE,OAAM;sCACT,cAAA,KAAC/D;gCAAckE,mBAAmBjE;0CAChC,cAAA,KAACa;oCACCO,yBAAyBA;oCACzBuB,IAAI;wCACFE,iBAAiB,CAAC,EAAEE,OAAO,EAAE,GAAKA,QAAQmB,UAAU,CAACC,OAAO;oCAC9D;;;;sCAIN,KAAC1E;4BAAM6D,WAAU;4BAAMC,IAAG;4BAAOS,UAAS;4BAAOZ,gBAAe;sCAC9D,cAAA,MAAC3D;gCAAM6D,WAAU;gCAAMI,SAAS;gCAAGU,IAAI;gCAAGb,IAAI;;kDAC5C,KAACtD;wCAAkB4B,UAAUA;wCAAUwC,kBAAkB,CAACC,KAAOxC,YAAYwC,GAAGC,KAAK;;kDACrF,KAAChE;kDACD,KAACI;wCAAeU,YAAY,CAACO;;;;;;;;;;AAO3C,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"file":"DatasourceEditor.d.ts","sourceRoot":"","sources":["../../../src/components/Datasources/DatasourceEditor.tsx"],"names":[],"mappings":"AA8BA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,YAAY,EAAY,MAAM,OAAO,CAAC;AAI/C,wBAAgB,gBAAgB,CAAC,KAAK,EAAE;IACtC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC5C,QAAQ,EAAE,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,KAAK,IAAI,CAAC;IAChE,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB,GAAG,YAAY,CA4Jf"}
1
+ {"version":3,"file":"DatasourceEditor.d.ts","sourceRoot":"","sources":["../../../src/components/Datasources/DatasourceEditor.tsx"],"names":[],"mappings":"AA8BA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,YAAY,EAAY,MAAM,OAAO,CAAC;AAK/C,wBAAgB,gBAAgB,CAAC,KAAK,EAAE;IACtC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC5C,QAAQ,EAAE,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,KAAK,IAAI,CAAC;IAChE,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB,GAAG,YAAY,CA4Jf"}
@@ -1,3 +1,4 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
1
2
  // Copyright The Perses Authors
2
3
  // Licensed under the Apache License, Version 2.0 (the "License");
3
4
  // you may not use this file except in compliance with the License.
@@ -10,7 +11,6 @@
10
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
12
  // See the License for the specific language governing permissions and
12
13
  // limitations under the License.
13
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
14
14
  import { Box, Button, IconButton, Stack, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Typography } from '@mui/material';
15
15
  import AddIcon from 'mdi-material-ui/Plus';
16
16
  import PencilIcon from 'mdi-material-ui/Pencil';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Datasources/DatasourceEditor.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {\n Box,\n Button,\n IconButton,\n Stack,\n Table,\n TableBody,\n TableCell,\n TableContainer,\n TableHead,\n TableRow,\n Typography,\n} from '@mui/material';\nimport AddIcon from 'mdi-material-ui/Plus';\nimport PencilIcon from 'mdi-material-ui/Pencil';\nimport TrashIcon from 'mdi-material-ui/TrashCan';\nimport { Action, DatasourceDefinition } from '@perses-dev/core'; // TODO\nimport { DatasourceSpec } from '@perses-dev/spec';\nimport { DatasourceEditorForm, ValidationProvider } from '@perses-dev/plugin-system';\nimport { ReactElement, useState } from 'react';\nimport { useImmer } from 'use-immer';\nimport { useDiscardChangesConfirmationDialog } from '../../context';\n\nexport function DatasourceEditor(props: {\n datasources: Record<string, DatasourceSpec>;\n onChange: (datasources: Record<string, DatasourceSpec>) => void;\n onCancel: () => void;\n}): ReactElement {\n const [datasources, setDatasources] = useImmer(props.datasources);\n const [datasourceFormAction, setDatasourceFormAction] = useState<Action>('update');\n const [datasourceEdit, setDatasourceEdit] = useState<DatasourceDefinition | null>(null);\n const defaultSpec: DatasourceSpec = {\n default: false,\n plugin: {\n // TODO: find a way to avoid assuming that the PrometheusDatasource plugin is installed\n kind: 'PrometheusDatasource',\n spec: {},\n },\n };\n\n const { openDiscardChangesConfirmationDialog, closeDiscardChangesConfirmationDialog } =\n useDiscardChangesConfirmationDialog();\n\n const handleCancel = (): void => {\n if (JSON.stringify(props.datasources) !== JSON.stringify(datasources)) {\n openDiscardChangesConfirmationDialog({\n onDiscardChanges: () => {\n closeDiscardChangesConfirmationDialog();\n props.onCancel();\n },\n onCancel: () => {\n closeDiscardChangesConfirmationDialog();\n },\n description:\n 'You have unapplied changes. Are you sure you want to discard these changes? Changes cannot be recovered.',\n });\n } else {\n props.onCancel();\n }\n };\n\n const removeDatasource = (name: string): void => {\n setDatasources((draft) => {\n delete draft[name];\n });\n };\n\n const addDatasource = (): void => {\n setDatasourceFormAction('create');\n setDatasourceEdit({\n name: 'NewDatasource',\n spec: defaultSpec,\n });\n };\n\n const editDatasource = (name: string): void => {\n setDatasourceFormAction('update');\n setDatasourceEdit({\n name: name,\n spec: datasources[name] ?? defaultSpec,\n });\n };\n\n return (\n <>\n {datasourceEdit ? (\n <ValidationProvider>\n <DatasourceEditorForm\n initialDatasourceDefinition={datasourceEdit}\n action={datasourceFormAction}\n isDraft={true}\n onActionChange={setDatasourceFormAction}\n onSave={(def: DatasourceDefinition) => {\n setDatasources((draft) => {\n delete draft[datasourceEdit.name]; // to tackle the case where datasource name has been changed\n draft[def.name] = def.spec;\n setDatasourceEdit(null);\n });\n }}\n onClose={() => {\n setDatasourceEdit(null);\n }}\n />\n </ValidationProvider>\n ) : (\n <>\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n padding: (theme) => theme.spacing(1, 2),\n borderBottom: (theme) => `1px solid ${theme.palette.divider}`,\n }}\n >\n <Typography variant=\"h2\">Edit Dashboard Datasources</Typography>\n <Stack direction=\"row\" spacing={1} marginLeft=\"auto\">\n <Button\n disabled={props.datasources === datasources}\n variant=\"contained\"\n onClick={() => {\n props.onChange(datasources);\n }}\n >\n Apply\n </Button>\n <Button color=\"secondary\" variant=\"outlined\" onClick={handleCancel}>\n Cancel\n </Button>\n </Stack>\n </Box>\n <Box padding={2} sx={{ overflowY: 'scroll' }}>\n <Stack spacing={2}>\n <Stack spacing={2}>\n <TableContainer>\n <Table sx={{ minWidth: 650 }} aria-label=\"table of datasources\">\n <TableHead>\n <TableRow>\n <TableCell>Name</TableCell>\n <TableCell>Type</TableCell>\n <TableCell>Description</TableCell>\n <TableCell align=\"right\">Actions</TableCell>\n </TableRow>\n </TableHead>\n <TableBody>\n {Object.entries(datasources).map(([name, spec]) => {\n return (\n <TableRow key={name}>\n <TableCell component=\"th\" scope=\"row\" sx={{ fontWeight: 'bold' }}>\n {name}\n </TableCell>\n <TableCell>{spec.plugin.kind}</TableCell>\n <TableCell>{spec.display?.description ?? ''}</TableCell>\n <TableCell align=\"right\" sx={{ whiteSpace: 'nowrap' }}>\n <IconButton onClick={() => editDatasource(name)}>\n <PencilIcon />\n </IconButton>\n <IconButton onClick={() => removeDatasource(name)}>\n <TrashIcon />\n </IconButton>\n </TableCell>\n </TableRow>\n );\n })}\n </TableBody>\n </Table>\n </TableContainer>\n <Box display=\"flex\">\n <Button\n variant=\"contained\"\n startIcon={<AddIcon />}\n sx={{ marginLeft: 'auto' }}\n onClick={addDatasource}\n >\n Add Datasource\n </Button>\n </Box>\n </Stack>\n </Stack>\n </Box>\n </>\n )}\n </>\n );\n}\n"],"names":["Box","Button","IconButton","Stack","Table","TableBody","TableCell","TableContainer","TableHead","TableRow","Typography","AddIcon","PencilIcon","TrashIcon","DatasourceEditorForm","ValidationProvider","useState","useImmer","useDiscardChangesConfirmationDialog","DatasourceEditor","props","datasources","setDatasources","datasourceFormAction","setDatasourceFormAction","datasourceEdit","setDatasourceEdit","defaultSpec","default","plugin","kind","spec","openDiscardChangesConfirmationDialog","closeDiscardChangesConfirmationDialog","handleCancel","JSON","stringify","onDiscardChanges","onCancel","description","removeDatasource","name","draft","addDatasource","editDatasource","initialDatasourceDefinition","action","isDraft","onActionChange","onSave","def","onClose","sx","display","alignItems","padding","theme","spacing","borderBottom","palette","divider","variant","direction","marginLeft","disabled","onClick","onChange","color","overflowY","minWidth","aria-label","align","Object","entries","map","component","scope","fontWeight","whiteSpace","startIcon"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SACEA,GAAG,EACHC,MAAM,EACNC,UAAU,EACVC,KAAK,EACLC,KAAK,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AM;sEAAQ;;;;;0DAG7B,KAAClE;0DACEmE,OAAOC,OAAO,CAACpD,aAAaqD,GAAG,CAAC,CAAC,CAACjC,MAAMV,KAAK;oDAC5C,qBACE,MAACtB;;0EACC,KAACH;gEAAUqE,WAAU;gEAAKC,OAAM;gEAAMxB,IAAI;oEAAEyB,YAAY;gEAAO;0EAC5DpC;;0EAEH,KAACnC;0EAAWyB,KAAKF,MAAM,CAACC,IAAI;;0EAC5B,KAACxB;0EAAWyB,KAAKsB,OAAO,EAAEd,eAAe;;0EACzC,MAACjC;gEAAUiE,OAAM;gEAAQnB,IAAI;oEAAE0B,YAAY;gEAAS;;kFAClD,KAAC5E;wEAAW+D,SAAS,IAAMrB,eAAeH;kFACxC,cAAA,KAAC7B;;kFAEH,KAACV;wEAAW+D,SAAS,IAAMzB,iBAAiBC;kFAC1C,cAAA,KAAC5B;;;;;uDAXQ4B;gDAgBnB;;;;;8CAIN,KAACzC;oCAAIqD,SAAQ;8CACX,cAAA,KAACpD;wCACC4D,SAAQ;wCACRkB,yBAAW,KAACpE;wCACZyC,IAAI;4CAAEW,YAAY;wCAAO;wCACzBE,SAAStB;kDACV;;;;;;;;;;AAWnB"}
1
+ {"version":3,"sources":["../../../src/components/Datasources/DatasourceEditor.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {\n Box,\n Button,\n IconButton,\n Stack,\n Table,\n TableBody,\n TableCell,\n TableContainer,\n TableHead,\n TableRow,\n Typography,\n} from '@mui/material';\nimport AddIcon from 'mdi-material-ui/Plus';\nimport PencilIcon from 'mdi-material-ui/Pencil';\nimport TrashIcon from 'mdi-material-ui/TrashCan';\nimport { Action } from '@perses-dev/components';\nimport { DatasourceSpec } from '@perses-dev/spec';\nimport { DatasourceEditorForm, ValidationProvider } from '@perses-dev/plugin-system';\nimport { ReactElement, useState } from 'react';\nimport { useImmer } from 'use-immer';\nimport { DatasourceDefinition } from '@perses-dev/client';\nimport { useDiscardChangesConfirmationDialog } from '../../context';\n\nexport function DatasourceEditor(props: {\n datasources: Record<string, DatasourceSpec>;\n onChange: (datasources: Record<string, DatasourceSpec>) => void;\n onCancel: () => void;\n}): ReactElement {\n const [datasources, setDatasources] = useImmer(props.datasources);\n const [datasourceFormAction, setDatasourceFormAction] = useState<Action>('update');\n const [datasourceEdit, setDatasourceEdit] = useState<DatasourceDefinition | null>(null);\n const defaultSpec: DatasourceSpec = {\n default: false,\n plugin: {\n // TODO: find a way to avoid assuming that the PrometheusDatasource plugin is installed\n kind: 'PrometheusDatasource',\n spec: {},\n },\n };\n\n const { openDiscardChangesConfirmationDialog, closeDiscardChangesConfirmationDialog } =\n useDiscardChangesConfirmationDialog();\n\n const handleCancel = (): void => {\n if (JSON.stringify(props.datasources) !== JSON.stringify(datasources)) {\n openDiscardChangesConfirmationDialog({\n onDiscardChanges: () => {\n closeDiscardChangesConfirmationDialog();\n props.onCancel();\n },\n onCancel: () => {\n closeDiscardChangesConfirmationDialog();\n },\n description:\n 'You have unapplied changes. Are you sure you want to discard these changes? Changes cannot be recovered.',\n });\n } else {\n props.onCancel();\n }\n };\n\n const removeDatasource = (name: string): void => {\n setDatasources((draft) => {\n delete draft[name];\n });\n };\n\n const addDatasource = (): void => {\n setDatasourceFormAction('create');\n setDatasourceEdit({\n name: 'NewDatasource',\n spec: defaultSpec,\n });\n };\n\n const editDatasource = (name: string): void => {\n setDatasourceFormAction('update');\n setDatasourceEdit({\n name: name,\n spec: datasources[name] ?? defaultSpec,\n });\n };\n\n return (\n <>\n {datasourceEdit ? (\n <ValidationProvider>\n <DatasourceEditorForm\n initialDatasourceDefinition={datasourceEdit}\n action={datasourceFormAction}\n isDraft={true}\n onActionChange={setDatasourceFormAction}\n onSave={(def: DatasourceDefinition) => {\n setDatasources((draft) => {\n delete draft[datasourceEdit.name]; // to tackle the case where datasource name has been changed\n draft[def.name] = def.spec;\n setDatasourceEdit(null);\n });\n }}\n onClose={() => {\n setDatasourceEdit(null);\n }}\n />\n </ValidationProvider>\n ) : (\n <>\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n padding: (theme) => theme.spacing(1, 2),\n borderBottom: (theme) => `1px solid ${theme.palette.divider}`,\n }}\n >\n <Typography variant=\"h2\">Edit Dashboard Datasources</Typography>\n <Stack direction=\"row\" spacing={1} marginLeft=\"auto\">\n <Button\n disabled={props.datasources === datasources}\n variant=\"contained\"\n onClick={() => {\n props.onChange(datasources);\n }}\n >\n Apply\n </Button>\n <Button color=\"secondary\" variant=\"outlined\" onClick={handleCancel}>\n Cancel\n </Button>\n </Stack>\n </Box>\n <Box padding={2} sx={{ overflowY: 'scroll' }}>\n <Stack spacing={2}>\n <Stack spacing={2}>\n <TableContainer>\n <Table sx={{ minWidth: 650 }} aria-label=\"table of datasources\">\n <TableHead>\n <TableRow>\n <TableCell>Name</TableCell>\n <TableCell>Type</TableCell>\n <TableCell>Description</TableCell>\n <TableCell align=\"right\">Actions</TableCell>\n </TableRow>\n </TableHead>\n <TableBody>\n {Object.entries(datasources).map(([name, spec]) => {\n return (\n <TableRow key={name}>\n <TableCell component=\"th\" scope=\"row\" sx={{ fontWeight: 'bold' }}>\n {name}\n </TableCell>\n <TableCell>{spec.plugin.kind}</TableCell>\n <TableCell>{spec.display?.description ?? ''}</TableCell>\n <TableCell align=\"right\" sx={{ whiteSpace: 'nowrap' }}>\n <IconButton onClick={() => editDatasource(name)}>\n <PencilIcon />\n </IconButton>\n <IconButton onClick={() => removeDatasource(name)}>\n <TrashIcon />\n </IconButton>\n </TableCell>\n </TableRow>\n );\n })}\n </TableBody>\n </Table>\n </TableContainer>\n <Box display=\"flex\">\n <Button\n variant=\"contained\"\n startIcon={<AddIcon />}\n sx={{ marginLeft: 'auto' }}\n onClick={addDatasource}\n >\n Add Datasource\n </Button>\n </Box>\n </Stack>\n </Stack>\n </Box>\n </>\n )}\n </>\n );\n}\n"],"names":["Box","Button","IconButton","Stack","Table","TableBody","TableCell","TableContainer","TableHead","TableRow","Typography","AddIcon","PencilIcon","TrashIcon","DatasourceEditorForm","ValidationProvider","useState","useImmer","useDiscardChangesConfirmationDialog","DatasourceEditor","props","datasources","setDatasources","datasourceFormAction","setDatasourceFormAction","datasourceEdit","setDatasourceEdit","defaultSpec","default","plugin","kind","spec","openDiscardChangesConfirmationDialog","closeDiscardChangesConfirmationDialog","handleCancel","JSON","stringify","onDiscardChanges","onCancel","description","removeDatasource","name","draft","addDatasource","editDatasource","initialDatasourceDefinition","action","isDraft","onActionChange","onSave","def","onClose","sx","display","alignItems","padding","theme","spacing","borderBottom","palette","divider","variant","direction","marginLeft","disabled","onClick","onChange","color","overflowY","minWidth","aria-label","align","Object","entries","map","component","scope","fontWeight","whiteSpace","startIcon"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SACEA,GAAG,EACHC,MAAM,EACNC,UAAU,EACVC,KAAK,EACLC,KAAK,EACLC,SAAS,EACTC,SAAS,EACTC,cAAc,EACdC,SAAS,EACTC,QAAQ,EACRC,UAAU,QACL,gBAAgB;AACvB,OAAOC,aAAa,uBAAuB;AAC3C,OAAOC,gBAAgB,yBAAyB;AAChD,OAAOC,eAAe,2BAA2B;AAGjD,SAASC,oBAAoB,EAAEC,kBAAkB,QAAQ,4BAA4B;AACrF,SAAuBC,QAAQ,QAAQ,QAAQ;AAC/C,SAASC,QAAQ,QAAQ,YAAY;AAErC,SAASC,mCAAmC,QA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d,eAAe;;0EACzC,MAACjC;gEAAUiE,OAAM;gEAAQnB,IAAI;oEAAE0B,YAAY;gEAAS;;kFAClD,KAAC5E;wEAAW+D,SAAS,IAAMrB,eAAeH;kFACxC,cAAA,KAAC7B;;kFAEH,KAACV;wEAAW+D,SAAS,IAAMzB,iBAAiBC;kFAC1C,cAAA,KAAC5B;;;;;uDAXQ4B;gDAgBnB;;;;;8CAIN,KAACzC;oCAAIqD,SAAQ;8CACX,cAAA,KAACpD;wCACC4D,SAAQ;wCACRkB,yBAAW,KAACpE;wCACZyC,IAAI;4CAAEW,YAAY;wCAAO;wCACzBE,SAAStB;kDACV;;;;;;;;;;AAWnB"}
@@ -1,3 +1,4 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
1
2
  // Copyright The Perses Authors
2
3
  // Licensed under the Apache License, Version 2.0 (the "License");
3
4
  // you may not use this file except in compliance with the License.
@@ -10,7 +11,6 @@
10
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
12
  // See the License for the specific language governing permissions and
12
13
  // limitations under the License.
13
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
14
14
  import { useState } from 'react';
15
15
  import { Button } from '@mui/material';
16
16
  import PencilIcon from 'mdi-material-ui/PencilOutline';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Datasources/EditDatasourcesButton.tsx"],"sourcesContent":["// Copyright 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 { Button } from '@mui/material';\nimport PencilIcon from 'mdi-material-ui/PencilOutline';\nimport { Drawer, InfoTooltip } from '@perses-dev/components';\nimport { DatasourceSpec } from '@perses-dev/spec';\nimport { useDatasourceStore } from '@perses-dev/plugin-system';\nimport { TOOLTIP_TEXT, editButtonStyle } from '../../constants';\nimport { useDashboard } from '../../context';\nimport { DatasourceEditor } from './DatasourceEditor';\n\nexport function EditDatasourcesButton(): ReactElement {\n const [isDatasourceEditorOpen, setIsDatasourceEditorOpen] = useState(false);\n const { getLocalDatasources, setLocalDatasources, getSavedDatasources, setSavedDatasources } = useDatasourceStore();\n const localDatasources: Record<string, DatasourceSpec> = getLocalDatasources();\n const savedDatasources: Record<string, DatasourceSpec> = getSavedDatasources();\n const { dashboard, setDashboard } = useDashboard();\n\n const openDatasourceEditor = (): void => {\n setIsDatasourceEditorOpen(true);\n };\n\n const closeDatasourceEditor = (): void => {\n setIsDatasourceEditorOpen(false);\n };\n\n const handleChangeDatasources = (datasources: Record<string, DatasourceSpec>): void => {\n // Calculates the new list of datasources that are allowed to be used.\n const newSavedDatasources: Record<string, DatasourceSpec> = Object.keys(datasources)\n .filter((key) => {\n // Datasources are allowed to be used if a) they are direct, or b) they are proxied, and their\n // proxy is the same as what we have saved.\n const isDirect = 'directUrl' in (datasources[key]?.plugin?.spec ?? {});\n const isSavedProxy =\n !isDirect &&\n !('directUrl' in (savedDatasources[key]?.plugin?.spec ?? {})) &&\n datasources[key]?.plugin?.spec?.proxy === savedDatasources[key]?.plugin?.spec?.proxy;\n\n return isDirect || isSavedProxy;\n })\n .reduce(\n (obj, key) => {\n obj[key] = datasources[key] as DatasourceSpec;\n\n return obj;\n },\n {} as Record<string, DatasourceSpec>\n );\n\n setDashboard({\n ...dashboard,\n spec: {\n ...dashboard.spec,\n datasources: datasources,\n },\n });\n setSavedDatasources(newSavedDatasources);\n setLocalDatasources(datasources);\n setIsDatasourceEditorOpen(false);\n };\n\n return (\n <>\n <InfoTooltip description={TOOLTIP_TEXT.editDatasources}>\n <Button\n startIcon={<PencilIcon />}\n onClick={openDatasourceEditor}\n aria-label={TOOLTIP_TEXT.editDatasources}\n variant=\"text\"\n color=\"primary\"\n sx={editButtonStyle}\n >\n Datasources\n </Button>\n </InfoTooltip>\n <Drawer\n isOpen={isDatasourceEditorOpen}\n onClose={closeDatasourceEditor}\n PaperProps={{ sx: { width: '50%' } }}\n data-testid=\"datasource-editor\"\n >\n <DatasourceEditor\n datasources={localDatasources}\n onCancel={closeDatasourceEditor}\n onChange={handleChangeDatasources}\n />\n </Drawer>\n </>\n );\n}\n"],"names":["useState","Button","PencilIcon","Drawer","InfoTooltip","useDatasourceStore","TOOLTIP_TEXT","editButtonStyle","useDashboard","DatasourceEditor","EditDatasourcesButton","isDatasourceEditorOpen","setIsDatasourceEditorOpen","getLocalDatasources","setLocalDatasources","getSavedDatasources","setSavedDatasources","localDatasources","savedDatasources","dashboard","setDashboard","openDatasourceEditor","closeDatasourceEditor","handleChangeDatasources","datasources","newSavedDatasources","Object","keys","filter","key","isDirect","plugin","spec","isSavedProxy","proxy","reduce","obj","description","editDatasources","startIcon","onClick","aria-label","variant","color","sx","isOpen","onClose","PaperProps","width","data-testid","onCancel","onChange"],"mappings":"AAAA,+BAA+B;AAC/B,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,QAAQ,gBAAgB;AACvC,OAAOC,gBAAgB,gCAAgC;AACvD,SAASC,MAAM,EAAEC,WAAW,QAAQ,yBAAyB;AAE7D,SAASC,kBAAkB,QAAQ,4BAA4B;AAC/D,SAASC,YAAY,EAAEC,eAAe,QAAQ,kBAAkB;AAChE,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,gBAAgB,QAAQ,qBAAqB;AAEtD,OAAO,SAASC;IACd,MA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oBACNC,IAAIrC;8BACL;;;0BAIH,KAACJ;gBACC0C,QAAQlC;gBACRmC,SAASxB;gBACTyB,YAAY;oBAAEH,IAAI;wBAAEI,OAAO;oBAAM;gBAAE;gBACnCC,eAAY;0BAEZ,cAAA,KAACxC;oBACCe,aAAaP;oBACbiC,UAAU5B;oBACV6B,UAAU5B;;;;;AAKpB"}
1
+ {"version":3,"sources":["../../../src/components/Datasources/EditDatasourcesButton.tsx"],"sourcesContent":["// Copyright 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 { Button } from '@mui/material';\nimport PencilIcon from 'mdi-material-ui/PencilOutline';\nimport { Drawer, InfoTooltip } from '@perses-dev/components';\nimport { DatasourceSpec } from '@perses-dev/spec';\nimport { useDatasourceStore } from '@perses-dev/plugin-system';\nimport { TOOLTIP_TEXT, editButtonStyle } from '../../constants';\nimport { useDashboard } from '../../context';\nimport { DatasourceEditor } from './DatasourceEditor';\n\nexport function EditDatasourcesButton(): ReactElement {\n const [isDatasourceEditorOpen, setIsDatasourceEditorOpen] = useState(false);\n const { getLocalDatasources, setLocalDatasources, getSavedDatasources, setSavedDatasources } = useDatasourceStore();\n const localDatasources: Record<string, DatasourceSpec> = getLocalDatasources();\n const savedDatasources: Record<string, DatasourceSpec> = getSavedDatasources();\n const { dashboard, setDashboard } = useDashboard();\n\n const openDatasourceEditor = (): void => {\n setIsDatasourceEditorOpen(true);\n };\n\n const closeDatasourceEditor = (): void => {\n setIsDatasourceEditorOpen(false);\n };\n\n const handleChangeDatasources = (datasources: Record<string, DatasourceSpec>): void => {\n // Calculates the new list of datasources that are allowed to be used.\n const newSavedDatasources: Record<string, DatasourceSpec> = Object.keys(datasources)\n .filter((key) => {\n // Datasources are allowed to be used if a) they are direct, or b) they are proxied, and their\n // proxy is the same as what we have saved.\n const isDirect = 'directUrl' in (datasources[key]?.plugin?.spec ?? {});\n const isSavedProxy =\n !isDirect &&\n !('directUrl' in (savedDatasources[key]?.plugin?.spec ?? {})) &&\n datasources[key]?.plugin?.spec?.proxy === savedDatasources[key]?.plugin?.spec?.proxy;\n\n return isDirect || isSavedProxy;\n })\n .reduce(\n (obj, key) => {\n obj[key] = datasources[key] as DatasourceSpec;\n\n return obj;\n },\n {} as Record<string, DatasourceSpec>\n );\n\n setDashboard({\n ...dashboard,\n spec: {\n ...dashboard.spec,\n datasources: datasources,\n },\n });\n setSavedDatasources(newSavedDatasources);\n setLocalDatasources(datasources);\n setIsDatasourceEditorOpen(false);\n };\n\n return (\n <>\n <InfoTooltip description={TOOLTIP_TEXT.editDatasources}>\n <Button\n startIcon={<PencilIcon />}\n onClick={openDatasourceEditor}\n aria-label={TOOLTIP_TEXT.editDatasources}\n variant=\"text\"\n color=\"primary\"\n sx={editButtonStyle}\n >\n Datasources\n </Button>\n </InfoTooltip>\n <Drawer\n isOpen={isDatasourceEditorOpen}\n onClose={closeDatasourceEditor}\n PaperProps={{ sx: { width: '50%' } }}\n data-testid=\"datasource-editor\"\n >\n <DatasourceEditor\n datasources={localDatasources}\n onCancel={closeDatasourceEditor}\n onChange={handleChangeDatasources}\n />\n </Drawer>\n </>\n );\n}\n"],"names":["useState","Button","PencilIcon","Drawer","InfoTooltip","useDatasourceStore","TOOLTIP_TEXT","editButtonStyle","useDashboard","DatasourceEditor","EditDatasourcesButton","isDatasourceEditorOpen","setIsDatasourceEditorOpen","getLocalDatasources","setLocalDatasources","getSavedDatasources","setSavedDatasources","localDatasources","savedDatasources","dashboard","setDashboard","openDatasourceEditor","closeDatasourceEditor","handleChangeDatasources","datasources","newSavedDatasources","Object","keys","filter","key","isDirect","plugin","spec","isSavedProxy","proxy","reduce","obj","description","editDatasources","startIcon","onClick","aria-label","variant","color","sx","isOpen","onClose","PaperProps","width","data-testid","onCancel","onChange"],"mappings":";AAAA,+BAA+B;AAC/B,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,QAAQ,gBAAgB;AACvC,OAAOC,gBAAgB,gCAAgC;AACvD,SAASC,MAAM,EAAEC,WAAW,QAAQ,yBAAyB;AAE7D,SAASC,kBAAkB,QAAQ,4BAA4B;AAC/D,SAASC,YAAY,EAAEC,eAAe,QAAQ,kBAAkB;AAChE,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,gBAAgB,QAAQ,qBAAqB;AAEtD,OAAO,SAASC;IACd,MAAM,CAACC,wBAAwBC,0BAA0B,GAAGZ,SAAS;IACrE,MAAM,EAAEa,mBAAmB,EAAEC,mBAAmB,EAAEC,mBAAmB,EAAEC,mBAAmB,EAAE,GAAGX;IAC/F,MAAMY,mBAAmDJ;IACzD,MAAMK,mBAAmDH;IACzD,MAAM,EAAEI,SAAS,EAAEC,YAAY,EAAE,GAAGZ;IAEpC,MAAMa,uBAAuB;QAC3BT,0BAA0B;IAC5B;IAEA,MAAMU,wBAAwB;QAC5BV,0BAA0B;IAC5B;IAEA,MAAMW,0BAA0B,CAACC;QAC/B,sEAAsE;QACtE,MAAMC,sBAAsDC,OAAOC,IAAI,CAACH,aACrEI,MAAM,CAAC,CAACC;YACP,8FAA8F;YAC9F,2CAA2C;YAC3C,MAAMC,WAAW,eAAgBN,CAAAA,WAAW,CAACK,IAAI,EAAEE,QAAQC,QAAQ,CAAC,CAAA;YACpE,MAAMC,eACJ,CAACH,YACD,CAAE,CAAA,eAAgBZ,CAAAA,gBAAgB,CAACW,IAAI,EAAEE,QAAQC,QAAQ,CAAC,CAAA,CAAC,KAC3DR,WAAW,CAACK,IAAI,EAAEE,QAAQC,MAAME,UAAUhB,gBAAgB,CAACW,IAAI,EAAEE,QAAQC,MAAME;YAEjF,OAAOJ,YAAYG;QACrB,GACCE,MAAM,CACL,CAACC,KAAKP;YACJO,GAAG,CAACP,IAAI,GAAGL,WAAW,CAACK,IAAI;YAE3B,OAAOO;QACT,GACA,CAAC;QAGLhB,aAAa;YACX,GAAGD,SAAS;YACZa,MAAM;gBACJ,GAAGb,UAAUa,IAAI;gBACjBR,aAAaA;YACf;QACF;QACAR,oBAAoBS;QACpBX,oBAAoBU;QACpBZ,0BAA0B;IAC5B;IAEA,qBACE;;0BACE,KAACR;gBAAYiC,aAAa/B,aAAagC,eAAe;0BACpD,cAAA,KAACrC;oBACCsC,yBAAW,KAACrC;oBACZsC,SAASnB;oBACToB,cAAYnC,aAAagC,eAAe;oBACxCI,SAAQ;oBACRC,OAAM;oBACNC,IAAIrC;8BACL;;;0BAIH,KAACJ;gBACC0C,QAAQlC;gBACRmC,SAASxB;gBACTyB,YAAY;oBAAEH,IAAI;wBAAEI,OAAO;oBAAM;gBAAE;gBACnCC,eAAY;0BAEZ,cAAA,KAACxC;oBACCe,aAAaP;oBACbiC,UAAU5B;oBACV6B,UAAU5B;;;;;AAKpB"}
@@ -1,3 +1,4 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
1
2
  // Copyright The Perses Authors
2
3
  // Licensed under the Apache License, Version 2.0 (the "License");
3
4
  // you may not use this file except in compliance with the License.
@@ -10,7 +11,6 @@
10
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
12
  // See the License for the specific language governing permissions and
12
13
  // limitations under the License.
13
- import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { DiscardChangesConfirmationDialog } from '@perses-dev/components';
15
15
  import { useDiscardChangesConfirmationDialog } from '../../context';
16
16
  export const DashboardDiscardChangesConfirmationDialog = ()=>{
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.tsx"],"sourcesContent":["// Copyright 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 { DiscardChangesConfirmationDialog } from '@perses-dev/components';\nimport { ReactElement } from 'react';\nimport { useDiscardChangesConfirmationDialog } from '../../context';\n\nexport const DashboardDiscardChangesConfirmationDialog = (): ReactElement | null => {\n const { discardChangesConfirmationDialog: dialog } = useDiscardChangesConfirmationDialog();\n if (dialog === undefined) {\n return null;\n }\n return (\n <DiscardChangesConfirmationDialog\n description={\n dialog.description ||\n 'You have unsaved changes in this dashboard. Are you sure you want to discard these changes? Changes cannot be recovered.'\n }\n isOpen={true}\n onCancel={dialog.onCancel}\n onDiscardChanges={dialog.onDiscardChanges}\n />\n );\n};\n"],"names":["DiscardChangesConfirmationDialog","useDiscardChangesConfirmationDialog","DashboardDiscardChangesConfirmationDialog","discardChangesConfirmationDialog","dialog","undefined","description","isOpen","onCancel","onDiscardChanges"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,gCAAgC,QAAQ,yBAAyB;AAE1E,SAASC,mCAAmC,QAAQ,gBAAgB;AAEpE,OAAO,MAAMC,4CAA4C;IACvD,MAAM,EAAEC,kCAAkCC,MAAM,EAAE,GAAGH;IACrD,IAAIG,WAAWC,WAAW;QACxB,OAAO;IACT;IACA,qBACE,KAACL;QACCM,aACEF,OAAOE,WAAW,IAClB;QAEFC,QAAQ;QACRC,UAAUJ,OAAOI,QAAQ;QACzBC,kBAAkBL,OAAOK,gBAAgB;;AAG/C,EAAE"}
1
+ {"version":3,"sources":["../../../src/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.tsx"],"sourcesContent":["// Copyright 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 { DiscardChangesConfirmationDialog } from '@perses-dev/components';\nimport { ReactElement } from 'react';\nimport { useDiscardChangesConfirmationDialog } from '../../context';\n\nexport const DashboardDiscardChangesConfirmationDialog = (): ReactElement | null => {\n const { discardChangesConfirmationDialog: dialog } = useDiscardChangesConfirmationDialog();\n if (dialog === undefined) {\n return null;\n }\n return (\n <DiscardChangesConfirmationDialog\n description={\n dialog.description ||\n 'You have unsaved changes in this dashboard. Are you sure you want to discard these changes? Changes cannot be recovered.'\n }\n isOpen={true}\n onCancel={dialog.onCancel}\n onDiscardChanges={dialog.onDiscardChanges}\n />\n );\n};\n"],"names":["DiscardChangesConfirmationDialog","useDiscardChangesConfirmationDialog","DashboardDiscardChangesConfirmationDialog","discardChangesConfirmationDialog","dialog","undefined","description","isOpen","onCancel","onDiscardChanges"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,gCAAgC,QAAQ,yBAAyB;AAE1E,SAASC,mCAAmC,QAAQ,gBAAgB;AAEpE,OAAO,MAAMC,4CAA4C;IACvD,MAAM,EAAEC,kCAAkCC,MAAM,EAAE,GAAGH;IACrD,IAAIG,WAAWC,WAAW;QACxB,OAAO;IACT;IACA,qBACE,KAACL;QACCM,aACEF,OAAOE,WAAW,IAClB;QAEFC,QAAQ;QACRC,UAAUJ,OAAOI,QAAQ;QACzBC,kBAAkBL,OAAOK,gBAAgB;;AAG/C,EAAE"}
@@ -1,3 +1,4 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
1
2
  // Copyright The Perses Authors
2
3
  // Licensed under the Apache License, Version 2.0 (the "License");
3
4
  // you may not use this file except in compliance with the License.
@@ -10,7 +11,6 @@
10
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
12
  // See the License for the specific language governing permissions and
12
13
  // limitations under the License.
13
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
14
14
  import { ClickAwayListener, Menu, MenuItem, MenuList } from '@mui/material';
15
15
  import { ToolbarIconButton } from '@perses-dev/components';
16
16
  import DownloadIcon from 'mdi-material-ui/DownloadOutline';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/DownloadButton/DownloadButton.tsx"],"sourcesContent":["// Copyright 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 { ClickAwayListener, Menu, MenuItem, MenuList } from '@mui/material';\nimport { ToolbarIconButton } from '@perses-dev/components';\nimport DownloadIcon from 'mdi-material-ui/DownloadOutline';\nimport React, { ReactElement, useRef } from 'react';\nimport { useDashboard } from '../../context';\nimport { serializeDashboard } from './serializeDashboard';\n\n// Button that enables downloading the dashboard as a JSON file\nexport function DownloadButton(): ReactElement {\n const { dashboard } = useDashboard();\n const hiddenLinkRef = useRef<HTMLAnchorElement>(null);\n const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);\n const open = Boolean(anchorEl);\n const handleClick = (event: React.MouseEvent<HTMLButtonElement>): void => {\n setAnchorEl(event.currentTarget);\n };\n const handleItemClick = (format: 'json' | 'yaml', shape?: 'cr-v1alpha1' | 'cr-v1alpha2') => (): void => {\n setAnchorEl(null);\n\n const { contentType, content } = serializeDashboard(dashboard, format, shape);\n\n if (!hiddenLinkRef || !hiddenLinkRef.current) return;\n // Create blob URL\n const hiddenLinkUrl = URL.createObjectURL(new Blob([content], { type: contentType }));\n // Simulate click\n hiddenLinkRef.current.download = `${dashboard.metadata.name}${shape ? `-${shape}` : ''}.${format}`;\n hiddenLinkRef.current.href = hiddenLinkUrl;\n hiddenLinkRef.current.click();\n // Remove blob URL (for memory management)\n URL.revokeObjectURL(hiddenLinkUrl);\n };\n\n return (\n <>\n <ToolbarIconButton\n id=\"download-dashboard-button\"\n aria-controls={open ? 'basic-menu' : undefined}\n aria-haspopup=\"true\"\n aria-expanded={open ? 'true' : undefined}\n onClick={handleClick}\n >\n <DownloadIcon />\n </ToolbarIconButton>\n\n <Menu\n id=\"download-dashboard-formats\"\n anchorEl={anchorEl}\n open={open}\n hideBackdrop={true}\n onClose={() => setAnchorEl(null)}\n MenuListProps={{\n 'aria-labelledby': 'download-dashboard-button',\n }}\n >\n <div>\n <ClickAwayListener onClickAway={() => setAnchorEl(null)}>\n <MenuList>\n <MenuItem onClick={handleItemClick('json')}>JSON</MenuItem>\n <MenuItem onClick={handleItemClick('yaml')}>YAML</MenuItem>\n <MenuItem onClick={handleItemClick('yaml', 'cr-v1alpha2')}>YAML (CR v1alpha2)</MenuItem>\n <MenuItem onClick={handleItemClick('yaml', 'cr-v1alpha1')}>YAML (CR v1alpha1)</MenuItem>\n </MenuList>\n </ClickAwayListener>\n </div>\n </Menu>\n\n {/* Hidden link to download the dashboard as a JSON or YAML file */}\n {/* eslint-disable jsx-a11y/anchor-has-content */}\n {/* eslint-disable jsx-a11y/anchor-is-valid */}\n <a ref={hiddenLinkRef} style={{ display: 'none' }} />\n </>\n );\n}\n"],"names":["ClickAwayListener","Menu","MenuItem","MenuList","ToolbarIconButton","DownloadIcon","React","useRef","useDashboard","serializeDashboard","DownloadButton","dashboard","hiddenLinkRef","anchorEl","setAnchorEl","useState","open","Boolean","handleClick","event","currentTarget","handleItemClick","format","shape","contentType","content","current","hiddenLinkUrl","URL","createObjectURL","Blob","type","download","metadata","name","href","click","revokeObjectURL","id","aria-controls","undefined","aria-haspopup","aria-expanded","onClick","hideBackdrop","onClose","MenuListProps","div","onClickAway","a","ref","style","display"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,iBAAiB,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,QAAQ,QAAQ,gBAAgB;AAC5E,SAASC,iBAAiB,QAAQ,yBAAyB;AAC3D,OAAOC,kBAAkB,kCAAkC;AAC3D,OAAOC,SAAuBC,MAAM,QAAQ,QAAQ;AACpD,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,kBAAkB,QAAQ,uBAAuB;AAE1D,+DAA+D;AAC/D,OAAO,SAASC;IACd,MAAM,EAAEC,SAAS,EAAE,GAAGH;IACtB,MAAMI,gBAAgBL,OAA0B;IAChD,MAAM,CAACM,UAAUC,YAAY,GAAGR,MAAMS,QAAQ,CAAqB;IACnE,MAAMC,OAAOC,QAAQJ;IACrB,MAAMK,cAAc,CAACC;QACnBL,YAAYK,MAAMC,aAAa;I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O;oBAAEC,SAAS;gBAAO;;;;AAGtD"}
1
+ {"version":3,"sources":["../../../src/components/DownloadButton/DownloadButton.tsx"],"sourcesContent":["// Copyright 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 { ClickAwayListener, Menu, MenuItem, MenuList } from '@mui/material';\nimport { ToolbarIconButton } from '@perses-dev/components';\nimport DownloadIcon from 'mdi-material-ui/DownloadOutline';\nimport React, { ReactElement, useRef } from 'react';\nimport { useDashboard } from '../../context';\nimport { serializeDashboard } from './serializeDashboard';\n\n// Button that enables downloading the dashboard as a JSON file\nexport function DownloadButton(): ReactElement {\n const { dashboard } = useDashboard();\n const hiddenLinkRef = useRef<HTMLAnchorElement>(null);\n const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);\n const open = Boolean(anchorEl);\n const handleClick = (event: React.MouseEvent<HTMLButtonElement>): void => {\n setAnchorEl(event.currentTarget);\n };\n const handleItemClick = (format: 'json' | 'yaml', shape?: 'cr-v1alpha1' | 'cr-v1alpha2') => (): void => {\n setAnchorEl(null);\n\n const { contentType, content } = serializeDashboard(dashboard, format, shape);\n\n if (!hiddenLinkRef || !hiddenLinkRef.current) return;\n // Create blob URL\n const hiddenLinkUrl = URL.createObjectURL(new Blob([content], { type: contentType }));\n // Simulate click\n hiddenLinkRef.current.download = `${dashboard.metadata.name}${shape ? `-${shape}` : ''}.${format}`;\n hiddenLinkRef.current.href = hiddenLinkUrl;\n hiddenLinkRef.current.click();\n // Remove blob URL (for memory management)\n URL.revokeObjectURL(hiddenLinkUrl);\n };\n\n return (\n <>\n <ToolbarIconButton\n id=\"download-dashboard-button\"\n aria-controls={open ? 'basic-menu' : undefined}\n aria-haspopup=\"true\"\n aria-expanded={open ? 'true' : undefined}\n onClick={handleClick}\n >\n <DownloadIcon />\n </ToolbarIconButton>\n\n <Menu\n id=\"download-dashboard-formats\"\n anchorEl={anchorEl}\n open={open}\n hideBackdrop={true}\n onClose={() => setAnchorEl(null)}\n MenuListProps={{\n 'aria-labelledby': 'download-dashboard-button',\n }}\n >\n <div>\n <ClickAwayListener onClickAway={() => setAnchorEl(null)}>\n <MenuList>\n <MenuItem onClick={handleItemClick('json')}>JSON</MenuItem>\n <MenuItem onClick={handleItemClick('yaml')}>YAML</MenuItem>\n <MenuItem onClick={handleItemClick('yaml', 'cr-v1alpha2')}>YAML (CR v1alpha2)</MenuItem>\n <MenuItem onClick={handleItemClick('yaml', 'cr-v1alpha1')}>YAML (CR v1alpha1)</MenuItem>\n </MenuList>\n </ClickAwayListener>\n </div>\n </Menu>\n\n {/* Hidden link to download the dashboard as a JSON or YAML file */}\n {/* eslint-disable jsx-a11y/anchor-has-content */}\n {/* eslint-disable jsx-a11y/anchor-is-valid */}\n <a ref={hiddenLinkRef} style={{ display: 'none' }} />\n </>\n );\n}\n"],"names":["ClickAwayListener","Menu","MenuItem","MenuList","ToolbarIconButton","DownloadIcon","React","useRef","useDashboard","serializeDashboard","DownloadButton","dashboard","hiddenLinkRef","anchorEl","setAnchorEl","useState","open","Boolean","handleClick","event","currentTarget","handleItemClick","format","shape","contentType","content","current","hiddenLinkUrl","URL","createObjectURL","Blob","type","download","metadata","name","href","click","revokeObjectURL","id","aria-controls","undefined","aria-haspopup","aria-expanded","onClick","hideBackdrop","onClose","MenuListProps","div","onClickAway","a","ref","style","display"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,i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ACb;;0BAGH,KAACJ;gBACCqC,IAAG;gBACHzB,UAAUA;gBACVG,MAAMA;gBACN4B,cAAc;gBACdC,SAAS,IAAM/B,YAAY;gBAC3BgC,eAAe;oBACb,mBAAmB;gBACrB;0BAEA,cAAA,KAACC;8BACC,cAAA,KAAC/C;wBAAkBgD,aAAa,IAAMlC,YAAY;kCAChD,cAAA,MAACX;;8CACC,KAACD;oCAASyC,SAAStB,gBAAgB;8CAAS;;8CAC5C,KAACnB;oCAASyC,SAAStB,gBAAgB;8CAAS;;8CAC5C,KAACnB;oCAASyC,SAAStB,gBAAgB,QAAQ;8CAAgB;;8CAC3D,KAACnB;oCAASyC,SAAStB,gBAAgB,QAAQ;8CAAgB;;;;;;;0BASnE,KAAC4B;gBAAEC,KAAKtC;gBAAeuC,OAAO;oBAAEC,SAAS;gBAAO;;;;AAGtD"}
@@ -1,3 +1,4 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
1
2
  // Copyright The Perses Authors
2
3
  // Licensed under the Apache License, Version 2.0 (the "License");
3
4
  // you may not use this file except in compliance with the License.
@@ -10,7 +11,6 @@
10
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
12
  // See the License for the specific language governing permissions and
12
13
  // limitations under the License.
13
- import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { Button } from '@mui/material';
15
15
  import PencilIcon from 'mdi-material-ui/PencilOutline';
16
16
  export const EditButton = ({ label = 'Edit', onClick })=>{
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/EditButton/EditButton.tsx"],"sourcesContent":["// Copyright 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 { Button } from '@mui/material';\nimport PencilIcon from 'mdi-material-ui/PencilOutline';\nimport { ReactElement } from 'react';\n\nexport interface EditButtonProps {\n /**\n * The label used inside the button.\n */\n label?: string;\n\n /**\n * Handler that puts the dashboard into editing mode.\n */\n onClick: () => void;\n}\n\nexport const EditButton = ({ label = 'Edit', onClick }: EditButtonProps): ReactElement => {\n return (\n <Button\n onClick={onClick}\n startIcon={<PencilIcon />}\n variant=\"outlined\"\n color=\"secondary\"\n sx={{ whiteSpace: 'nowrap', minWidth: 'auto' }}\n >\n {label}\n </Button>\n );\n};\n"],"names":["Button","PencilIcon","EditButton","label","onClick","startIcon","variant","color","sx","whiteSpace","minWidth"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,MAAM,QAAQ,gBAAgB;AACvC,OAAOC,gBAAgB,gCAAgC;AAevD,OAAO,MAAMC,aAAa,CAAC,EAAEC,QAAQ,MAAM,EAAEC,OAAO,EAAmB;IACrE,qBACE,KAACJ;QACCI,SAASA;QACTC,yBAAW,KAACJ;QACZK,SAAQ;QACRC,OAAM;QACNC,IAAI;YAAEC,YAAY;YAAUC,UAAU;QAAO;kBAE5CP;;AAGP,EAAE"}
1
+ {"version":3,"sources":["../../../src/components/EditButton/EditButton.tsx"],"sourcesContent":["// Copyright 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 { Button } from '@mui/material';\nimport PencilIcon from 'mdi-material-ui/PencilOutline';\nimport { ReactElement } from 'react';\n\nexport interface EditButtonProps {\n /**\n * The label used inside the button.\n */\n label?: string;\n\n /**\n * Handler that puts the dashboard into editing mode.\n */\n onClick: () => void;\n}\n\nexport const EditButton = ({ label = 'Edit', onClick }: EditButtonProps): ReactElement => {\n return (\n <Button\n onClick={onClick}\n startIcon={<PencilIcon />}\n variant=\"outlined\"\n color=\"secondary\"\n sx={{ whiteSpace: 'nowrap', minWidth: 'auto' }}\n >\n {label}\n </Button>\n );\n};\n"],"names":["Button","PencilIcon","EditButton","label","onClick","startIcon","variant","color","sx","whiteSpace","minWidth"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,MAAM,QAAQ,gBAAgB;AACvC,OAAOC,gBAAgB,gCAAgC;AAevD,OAAO,MAAMC,aAAa,CAAC,EAAEC,QAAQ,MAAM,EAAEC,OAAO,EAAmB;IACrE,qBACE,KAACJ;QACCI,SAASA;QACTC,yBAAW,KAACJ;QACZK,SAAQ;QACRC,OAAM;QACNC,IAAI;YAAEC,YAAY;YAAUC,UAAU;QAAO;kBAE5CP;;AAGP,EAAE"}
@@ -1,3 +1,4 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
1
2
  // Copyright The Perses Authors
2
3
  // Licensed under the Apache License, Version 2.0 (the "License");
3
4
  // you may not use this file except in compliance with the License.
@@ -10,7 +11,6 @@
10
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
12
  // See the License for the specific language governing permissions and
12
13
  // limitations under the License.
13
- import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import CodeIcon from 'mdi-material-ui/CodeBraces';
15
15
  import { InfoTooltip, ToolbarIconButton } from '@perses-dev/components';
16
16
  import { TOOLTIP_TEXT } from '../../constants';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/EditJsonButton/EditJsonButton.tsx"],"sourcesContent":["// Copyright 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 CodeIcon from 'mdi-material-ui/CodeBraces';\nimport { InfoTooltip, ToolbarIconButton } from '@perses-dev/components';\nimport { ReactElement } from 'react';\nimport { TOOLTIP_TEXT } from '../../constants';\nimport { useEditJsonDialog } from '../../context';\n\nexport interface EditJsonButtonProps {\n isReadonly: boolean;\n}\n\nexport const EditJsonButton = (props: EditJsonButtonProps): ReactElement => {\n const { isReadonly } = props;\n const { openEditJsonDialog } = useEditJsonDialog();\n\n const info = isReadonly ? TOOLTIP_TEXT.viewJson : TOOLTIP_TEXT.editJson;\n\n return (\n <InfoTooltip description={info}>\n <ToolbarIconButton aria-label={info} variant=\"outlined\" onClick={() => openEditJsonDialog()}>\n <CodeIcon />\n </ToolbarIconButton>\n </InfoTooltip>\n );\n};\n"],"names":["CodeIcon","InfoTooltip","ToolbarIconButton","TOOLTIP_TEXT","useEditJsonDialog","EditJsonButton","props","isReadonly","openEditJsonDialog","info","viewJson","editJson","description","aria-label","variant","onClick"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,OAAOA,cAAc,6BAA6B;AAClD,SAASC,WAAW,EAAEC,iBAAiB,QAAQ,yBAAyB;AAExE,SAASC,YAAY,QAAQ,kBAAkB;AAC/C,SAASC,iBAAiB,QAAQ,gBAAgB;AAMlD,OAAO,MAAMC,iBAAiB,CAACC;IAC7B,MAAM,EAAEC,UAAU,EAAE,GAAGD;IACvB,MAAM,EAAEE,kBAAkB,EAAE,GAAGJ;IAE/B,MAAMK,OAAOF,aAAaJ,aAAaO,QAAQ,GAAGP,aAAaQ,QAAQ;IAEvE,qBACE,KAACV;QAAYW,aAAaH;kBACxB,cAAA,KAACP;YAAkBW,cAAYJ;YAAMK,SAAQ;YAAWC,SAAS,IAAMP;sBACrE,cAAA,KAACR;;;AAIT,EAAE"}
1
+ {"version":3,"sources":["../../../src/components/EditJsonButton/EditJsonButton.tsx"],"sourcesContent":["// Copyright 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 CodeIcon from 'mdi-material-ui/CodeBraces';\nimport { InfoTooltip, ToolbarIconButton } from '@perses-dev/components';\nimport { ReactElement } from 'react';\nimport { TOOLTIP_TEXT } from '../../constants';\nimport { useEditJsonDialog } from '../../context';\n\nexport interface EditJsonButtonProps {\n isReadonly: boolean;\n}\n\nexport const EditJsonButton = (props: EditJsonButtonProps): ReactElement => {\n const { isReadonly } = props;\n const { openEditJsonDialog } = useEditJsonDialog();\n\n const info = isReadonly ? TOOLTIP_TEXT.viewJson : TOOLTIP_TEXT.editJson;\n\n return (\n <InfoTooltip description={info}>\n <ToolbarIconButton aria-label={info} variant=\"outlined\" onClick={() => openEditJsonDialog()}>\n <CodeIcon />\n </ToolbarIconButton>\n </InfoTooltip>\n );\n};\n"],"names":["CodeIcon","InfoTooltip","ToolbarIconButton","TOOLTIP_TEXT","useEditJsonDialog","EditJsonButton","props","isReadonly","openEditJsonDialog","info","viewJson","editJson","description","aria-label","variant","onClick"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAOA,cAAc,6BAA6B;AAClD,SAASC,WAAW,EAAEC,iBAAiB,QAAQ,yBAAyB;AAExE,SAASC,YAAY,QAAQ,kBAAkB;AAC/C,SAASC,iBAAiB,QAAQ,gBAAgB;AAMlD,OAAO,MAAMC,iBAAiB,CAACC;IAC7B,MAAM,EAAEC,UAAU,EAAE,GAAGD;IACvB,MAAM,EAAEE,kBAAkB,EAAE,GAAGJ;IAE/B,MAAMK,OAAOF,aAAaJ,aAAaO,QAAQ,GAAGP,aAAaQ,QAAQ;IAEvE,qBACE,KAACV;QAAYW,aAAaH;kBACxB,cAAA,KAACP;YAAkBW,cAAYJ;YAAMK,SAAQ;YAAWC,SAAS,IAAMP;sBACrE,cAAA,KAACR;;;AAIT,EAAE"}
@@ -1,3 +1,4 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
2
  // Copyright The Perses Authors
2
3
  // Licensed under the Apache License, Version 2.0 (the "License");
3
4
  // you may not use this file except in compliance with the License.
@@ -10,7 +11,6 @@
10
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
12
  // See the License for the specific language governing permissions and
12
13
  // limitations under the License.
13
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  import { useState } from 'react';
15
15
  import { Alert, FormControl } from '@mui/material';
16
16
  import { Dialog, JSONEditor } from '@perses-dev/components';