@perses-dev/dashboards 0.52.0 → 0.53.0-beta.1

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 (178) hide show
  1. package/dist/cjs/components/DashboardStickyToolbar/DashboardStickyToolbar.js +0 -2
  2. package/dist/cjs/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +5 -20
  3. package/dist/cjs/components/GridLayout/GridItemContent.js +9 -67
  4. package/dist/cjs/components/GridLayout/GridLayout.js +1 -1
  5. package/dist/cjs/components/LeaveDialog/LeaveDialog.js +10 -1
  6. package/dist/cjs/components/Panel/Panel.js +4 -3
  7. package/dist/cjs/components/Panel/PanelHeader.js +1 -9
  8. package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +186 -183
  9. package/dist/cjs/components/PanelDrawer/PanelPreview.js +3 -0
  10. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +6 -21
  11. package/dist/cjs/components/QueryViewerDialog/QueryViewerDialog.js +121 -0
  12. package/dist/cjs/components/QueryViewerDialog/index.js +30 -0
  13. package/dist/cjs/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +18 -6
  14. package/dist/cjs/components/SaveDashboardButton/SaveDashboardButton.js +11 -6
  15. package/dist/cjs/components/Variables/ListVariableListBox.js +201 -0
  16. package/dist/cjs/components/Variables/Variable.js +164 -72
  17. package/dist/cjs/components/Variables/VariableList.js +2 -2
  18. package/dist/cjs/components/Variables/index.js +1 -0
  19. package/dist/cjs/components/index.js +2 -1
  20. package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +1 -1
  21. package/dist/cjs/context/DashboardProvider/delete-panel-slice.js +1 -1
  22. package/dist/cjs/context/DashboardProvider/duplicate-panel-slice.js +1 -1
  23. package/dist/cjs/context/DashboardProvider/index.js +1 -1
  24. package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +1 -1
  25. package/dist/cjs/context/DashboardProvider/panel-group-slice.js +1 -7
  26. package/dist/cjs/context/DashboardProvider/view-panel-slice.js +1 -1
  27. package/dist/cjs/context/DatasourceStoreProvider.js +3 -4
  28. package/dist/cjs/context/PanelEditorProvider/PanelEditorProvider.js +49 -0
  29. package/dist/cjs/context/PanelEditorProvider/index.js +23 -0
  30. package/dist/cjs/context/VariableProvider/VariableProvider.js +1 -1
  31. package/dist/cjs/context/VariableProvider/hydrationUtils.js +1 -1
  32. package/dist/cjs/context/VariableProvider/index.js +1 -1
  33. package/dist/cjs/context/VariableProvider/utils.js +1 -1
  34. package/dist/cjs/context/index.js +1 -0
  35. package/dist/cjs/context/useDashboard.js +1 -1
  36. package/dist/cjs/utils/panelUtils.js +1 -1
  37. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.d.ts.map +1 -1
  38. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js +0 -2
  39. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js.map +1 -1
  40. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -1
  41. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +5 -15
  42. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js.map +1 -1
  43. package/dist/components/GridLayout/GridItemContent.d.ts +1 -1
  44. package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
  45. package/dist/components/GridLayout/GridItemContent.js +10 -68
  46. package/dist/components/GridLayout/GridItemContent.js.map +1 -1
  47. package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
  48. package/dist/components/GridLayout/GridLayout.js +1 -1
  49. package/dist/components/GridLayout/GridLayout.js.map +1 -1
  50. package/dist/components/GridLayout/Row.d.ts +2 -2
  51. package/dist/components/GridLayout/Row.d.ts.map +1 -1
  52. package/dist/components/GridLayout/Row.js.map +1 -1
  53. package/dist/components/LeaveDialog/LeaveDialog.d.ts +2 -1
  54. package/dist/components/LeaveDialog/LeaveDialog.d.ts.map +1 -1
  55. package/dist/components/LeaveDialog/LeaveDialog.js +10 -1
  56. package/dist/components/LeaveDialog/LeaveDialog.js.map +1 -1
  57. package/dist/components/Panel/Panel.d.ts +1 -2
  58. package/dist/components/Panel/Panel.d.ts.map +1 -1
  59. package/dist/components/Panel/Panel.js +5 -4
  60. package/dist/components/Panel/Panel.js.map +1 -1
  61. package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
  62. package/dist/components/Panel/PanelHeader.js +2 -10
  63. package/dist/components/Panel/PanelHeader.js.map +1 -1
  64. package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
  65. package/dist/components/PanelDrawer/PanelEditorForm.js +186 -183
  66. package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
  67. package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -1
  68. package/dist/components/PanelDrawer/PanelPreview.js +4 -1
  69. package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
  70. package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -1
  71. package/dist/components/PanelGroupDialog/PanelGroupDialog.js +5 -15
  72. package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
  73. package/dist/components/QueryViewerDialog/QueryViewerDialog.d.ts +9 -0
  74. package/dist/components/QueryViewerDialog/QueryViewerDialog.d.ts.map +1 -0
  75. package/dist/components/QueryViewerDialog/QueryViewerDialog.js +72 -0
  76. package/dist/components/QueryViewerDialog/QueryViewerDialog.js.map +1 -0
  77. package/dist/components/QueryViewerDialog/index.d.ts +2 -0
  78. package/dist/components/QueryViewerDialog/index.d.ts.map +1 -0
  79. package/dist/components/QueryViewerDialog/index.js +15 -0
  80. package/dist/components/QueryViewerDialog/index.js.map +1 -0
  81. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.d.ts.map +1 -1
  82. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +19 -7
  83. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +1 -1
  84. package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts.map +1 -1
  85. package/dist/components/SaveDashboardButton/SaveDashboardButton.js +11 -6
  86. package/dist/components/SaveDashboardButton/SaveDashboardButton.js.map +1 -1
  87. package/dist/components/Variables/EditVariablesButton.d.ts.map +1 -1
  88. package/dist/components/Variables/EditVariablesButton.js.map +1 -1
  89. package/dist/components/Variables/ListVariableListBox.d.ts +16 -0
  90. package/dist/components/Variables/ListVariableListBox.d.ts.map +1 -0
  91. package/dist/components/Variables/ListVariableListBox.js +141 -0
  92. package/dist/components/Variables/ListVariableListBox.js.map +1 -0
  93. package/dist/components/Variables/Variable.d.ts.map +1 -1
  94. package/dist/components/Variables/Variable.js +168 -75
  95. package/dist/components/Variables/Variable.js.map +1 -1
  96. package/dist/components/Variables/VariableEditor.d.ts +1 -2
  97. package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
  98. package/dist/components/Variables/VariableEditor.js.map +1 -1
  99. package/dist/components/Variables/VariableList.d.ts.map +1 -1
  100. package/dist/components/Variables/VariableList.js +2 -2
  101. package/dist/components/Variables/VariableList.js.map +1 -1
  102. package/dist/components/Variables/index.d.ts +1 -0
  103. package/dist/components/Variables/index.d.ts.map +1 -1
  104. package/dist/components/Variables/index.js +1 -0
  105. package/dist/components/Variables/index.js.map +1 -1
  106. package/dist/components/index.d.ts +2 -1
  107. package/dist/components/index.d.ts.map +1 -1
  108. package/dist/components/index.js +2 -1
  109. package/dist/components/index.js.map +1 -1
  110. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +1 -2
  111. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
  112. package/dist/context/DashboardProvider/dashboard-provider-api.js +1 -1
  113. package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
  114. package/dist/context/DashboardProvider/delete-panel-slice.d.ts +2 -1
  115. package/dist/context/DashboardProvider/delete-panel-slice.d.ts.map +1 -1
  116. package/dist/context/DashboardProvider/delete-panel-slice.js +1 -1
  117. package/dist/context/DashboardProvider/delete-panel-slice.js.map +1 -1
  118. package/dist/context/DashboardProvider/duplicate-panel-slice.d.ts +2 -1
  119. package/dist/context/DashboardProvider/duplicate-panel-slice.d.ts.map +1 -1
  120. package/dist/context/DashboardProvider/duplicate-panel-slice.js +1 -1
  121. package/dist/context/DashboardProvider/duplicate-panel-slice.js.map +1 -1
  122. package/dist/context/DashboardProvider/index.d.ts +0 -1
  123. package/dist/context/DashboardProvider/index.d.ts.map +1 -1
  124. package/dist/context/DashboardProvider/index.js +1 -1
  125. package/dist/context/DashboardProvider/index.js.map +1 -1
  126. package/dist/context/DashboardProvider/panel-editor-slice.d.ts +2 -2
  127. package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
  128. package/dist/context/DashboardProvider/panel-editor-slice.js +1 -1
  129. package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
  130. package/dist/context/DashboardProvider/panel-group-slice.d.ts +1 -24
  131. package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
  132. package/dist/context/DashboardProvider/panel-group-slice.js +1 -6
  133. package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
  134. package/dist/context/DashboardProvider/save-changes-dialog-slice.d.ts +2 -1
  135. package/dist/context/DashboardProvider/save-changes-dialog-slice.d.ts.map +1 -1
  136. package/dist/context/DashboardProvider/save-changes-dialog-slice.js.map +1 -1
  137. package/dist/context/DashboardProvider/view-panel-slice.d.ts +1 -1
  138. package/dist/context/DashboardProvider/view-panel-slice.d.ts.map +1 -1
  139. package/dist/context/DashboardProvider/view-panel-slice.js +1 -1
  140. package/dist/context/DashboardProvider/view-panel-slice.js.map +1 -1
  141. package/dist/context/DatasourceStoreProvider.d.ts +1 -17
  142. package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
  143. package/dist/context/DatasourceStoreProvider.js +2 -3
  144. package/dist/context/DatasourceStoreProvider.js.map +1 -1
  145. package/dist/context/PanelEditorProvider/PanelEditorProvider.d.ts +13 -0
  146. package/dist/context/PanelEditorProvider/PanelEditorProvider.d.ts.map +1 -0
  147. package/dist/context/PanelEditorProvider/PanelEditorProvider.js +33 -0
  148. package/dist/context/PanelEditorProvider/PanelEditorProvider.js.map +1 -0
  149. package/dist/context/PanelEditorProvider/index.d.ts +3 -0
  150. package/dist/context/PanelEditorProvider/index.d.ts.map +1 -0
  151. package/dist/context/PanelEditorProvider/index.js +16 -0
  152. package/dist/context/PanelEditorProvider/index.js.map +1 -0
  153. package/dist/context/VariableProvider/VariableProvider.d.ts +1 -10
  154. package/dist/context/VariableProvider/VariableProvider.d.ts.map +1 -1
  155. package/dist/context/VariableProvider/VariableProvider.js +1 -1
  156. package/dist/context/VariableProvider/VariableProvider.js.map +1 -1
  157. package/dist/context/VariableProvider/hydrationUtils.d.ts +1 -2
  158. package/dist/context/VariableProvider/hydrationUtils.d.ts.map +1 -1
  159. package/dist/context/VariableProvider/hydrationUtils.js +1 -1
  160. package/dist/context/VariableProvider/hydrationUtils.js.map +1 -1
  161. package/dist/context/VariableProvider/index.js +1 -1
  162. package/dist/context/VariableProvider/index.js.map +1 -1
  163. package/dist/context/VariableProvider/utils.d.ts +1 -2
  164. package/dist/context/VariableProvider/utils.d.ts.map +1 -1
  165. package/dist/context/VariableProvider/utils.js +1 -1
  166. package/dist/context/VariableProvider/utils.js.map +1 -1
  167. package/dist/context/index.d.ts +1 -0
  168. package/dist/context/index.d.ts.map +1 -1
  169. package/dist/context/index.js +1 -0
  170. package/dist/context/index.js.map +1 -1
  171. package/dist/context/useDashboard.d.ts.map +1 -1
  172. package/dist/context/useDashboard.js +1 -1
  173. package/dist/context/useDashboard.js.map +1 -1
  174. package/dist/utils/panelUtils.d.ts +1 -2
  175. package/dist/utils/panelUtils.d.ts.map +1 -1
  176. package/dist/utils/panelUtils.js +1 -1
  177. package/dist/utils/panelUtils.js.map +1 -1
  178. package/package.json +5 -5
@@ -11,10 +11,10 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
14
- import { IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@mui/material';
15
- import CloseIcon from 'mdi-material-ui/Close';
16
14
  import { useState } from 'react';
17
15
  import { useVariableValues } from '@perses-dev/plugin-system';
16
+ import { Dialog } from '@perses-dev/components';
17
+ import { Button } from '@mui/material';
18
18
  import { usePanelGroupEditor } from '../../context';
19
19
  import { PanelGroupEditorForm, panelGroupEditorFormId } from './PanelGroupEditorForm';
20
20
  /**
@@ -47,23 +47,13 @@ import { PanelGroupEditorForm, panelGroupEditorFormId } from './PanelGroupEditor
47
47
  },
48
48
  children: panelGroupEditor !== undefined && /*#__PURE__*/ _jsxs(_Fragment, {
49
49
  children: [
50
- /*#__PURE__*/ _jsxs(DialogTitle, {
50
+ /*#__PURE__*/ _jsxs(Dialog.Header, {
51
51
  children: [
52
52
  panelGroupEditor.mode,
53
53
  " Panel Group"
54
54
  ]
55
55
  }),
56
- /*#__PURE__*/ _jsx(IconButton, {
57
- "aria-label": "Close",
58
- onClick: panelGroupEditor.close,
59
- sx: (theme)=>({
60
- position: 'absolute',
61
- top: theme.spacing(0.5),
62
- right: theme.spacing(0.5)
63
- }),
64
- children: /*#__PURE__*/ _jsx(CloseIcon, {})
65
- }),
66
- /*#__PURE__*/ _jsx(DialogContent, {
56
+ /*#__PURE__*/ _jsx(Dialog.Content, {
67
57
  dividers: true,
68
58
  sx: {
69
59
  width: '500px'
@@ -74,7 +64,7 @@ import { PanelGroupEditorForm, panelGroupEditorFormId } from './PanelGroupEditor
74
64
  onSubmit: handleSubmit
75
65
  })
76
66
  }),
77
- /*#__PURE__*/ _jsxs(DialogActions, {
67
+ /*#__PURE__*/ _jsxs(Dialog.Actions, {
78
68
  children: [
79
69
  /*#__PURE__*/ _jsx(Button, {
80
70
  variant: "contained",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/PanelGroupDialog/PanelGroupDialog.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@mui/material';\nimport CloseIcon from 'mdi-material-ui/Close';\nimport { ReactElement, useState } from 'react';\nimport { useVariableValues } from '@perses-dev/plugin-system';\nimport { usePanelGroupEditor } from '../../context';\nimport { PanelGroupEditorForm, panelGroupEditorFormId, PanelGroupEditorFormProps } from './PanelGroupEditorForm';\n\n/**\n * A dialog for adding or editing a Panel Group. Open and initial state is controlled by the DashboardStore.\n */\nexport function PanelGroupDialog(): ReactElement {\n const panelGroupEditor = usePanelGroupEditor();\n const variables = useVariableValues();\n\n // When the user clicks close, start closing but don't call the store yet to keep values stable during animtation\n const [isClosing, setIsClosing] = useState(false);\n const handleClose = (): void => setIsClosing(true);\n\n // Don't call close on the store until the Dialog has completely transitioned out\n const handleExited = (): void => {\n panelGroupEditor?.close();\n setIsClosing(false);\n };\n\n // Dialog is open if we have a model and we're not transitioning out\n const isOpen = panelGroupEditor !== undefined && isClosing === false;\n\n const handleSubmit: PanelGroupEditorFormProps['onSubmit'] = (values) => {\n // This shouldn't happen since we don't render the submit button until we have a model, but check to make TS happy\n if (panelGroupEditor === undefined) {\n throw new Error('Cannot apply changes');\n }\n panelGroupEditor.applyChanges(values);\n handleClose();\n };\n\n return (\n <Dialog open={isOpen} TransitionProps={{ onExited: handleExited }}>\n {panelGroupEditor !== undefined && (\n <>\n <DialogTitle>{panelGroupEditor.mode} Panel Group</DialogTitle>\n <IconButton\n aria-label=\"Close\"\n onClick={panelGroupEditor.close}\n sx={(theme) => ({\n position: 'absolute',\n top: theme.spacing(0.5),\n right: theme.spacing(0.5),\n })}\n >\n <CloseIcon />\n </IconButton>\n <DialogContent dividers sx={{ width: '500px' }}>\n <PanelGroupEditorForm\n initialValues={panelGroupEditor.initialValues}\n variables={Object.keys(variables)}\n onSubmit={handleSubmit}\n />\n </DialogContent>\n <DialogActions>\n <Button variant=\"contained\" type=\"submit\" form={panelGroupEditorFormId}>\n {panelGroupEditor.mode === 'Edit' ? 'Apply' : 'Add'}\n </Button>\n <Button variant=\"outlined\" color=\"secondary\" onClick={panelGroupEditor.close}>\n Cancel\n </Button>\n </DialogActions>\n </>\n )}\n </Dialog>\n );\n}\n"],"names":["IconButton","Dialog","DialogTitle","DialogContent","DialogActions","Button","CloseIcon","useState","useVariableValues","usePanelGroupEditor","PanelGroupEditorForm","panelGroupEditorFormId","PanelGroupDialog","panelGroupEditor","variables","isClosing","setIsClosing","handleClose","handleExited","close","isOpen","undefined","handleSubmit","values","Error","applyChanges","open","TransitionProps","onExited","mode","aria-label","onClick","sx","theme","position","top","spacing","right","dividers","width","initialValues","Object","keys","onSubmit","variant","type","form","color"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,UAAU,EAAEC,MAAM,EAAEC,WAAW,EAAEC,aAAa,EAAEC,aAAa,EAAEC,MAAM,QAAQ,gBAAgB;AACtG,OAAOC,eAAe,wBAAwB;AAC9C,SAAuBC,QAAQ,QAAQ,QAAQ;AAC/C,SAASC,iBAAiB,QAAQ,4BAA4B;AAC9D,SAASC,mBAAmB,QAAQ,gBAAgB;AACpD,SAASC,oBAAoB,EAAEC,sBAAsB,QAAmC,yBAAyB;AAEjH;;CAEC,GACD,OAAO,SAASC;IACd,MAAMC,mBAAmBJ;IACzB,MAAMK,YAAYN;IAElB,iHAAiH;IACjH,MAAM,CAACO,WAAWC,aAAa,GAAGT,SAAS;IAC3C,MAAMU,cAAc,IAAYD,aAAa;IAE7C,iFAAiF;IACjF,MAAME,eAAe;QACnBL,kBAAkBM;QAClBH,aAAa;IACf;IAEA,oEAAoE;IACpE,MAAMI,SAASP,qBAAqBQ,aAAaN,cAAc;IAE/D,MAAMO,eAAsD,CAACC;QAC3D,kHAAkH;QAClH,IAAIV,qBAAqBQ,WAAW;YAClC,MAAM,IAAIG,MAAM;QAClB;QACAX,iBAAiBY,YAAY,CAACF;QAC9BN;IACF;IAEA,qBACE,KAAChB;QAAOyB,MAAMN;QAAQO,iBAAiB;YAAEC,UAAUV;QAAa;kBAC7DL,qBAAqBQ,2BACpB;;8BACE,MAACnB;;wBAAaW,iBAAiBgB,IAAI;wBAAC;;;8BACpC,KAAC7B;oBACC8B,cAAW;oBACXC,SAASlB,iBAAiBM,KAAK;oBAC/Ba,IAAI,CAACC,QAAW,CAAA;4BACdC,UAAU;4BACVC,KAAKF,MAAMG,OAAO,CAAC;4BACnBC,OAAOJ,MAAMG,OAAO,CAAC;wBACvB,CAAA;8BAEA,cAAA,KAAC9B;;8BAEH,KAACH;oBAAcmC,QAAQ;oBAACN,IAAI;wBAAEO,OAAO;oBAAQ;8BAC3C,cAAA,KAAC7B;wBACC8B,eAAe3B,iBAAiB2B,aAAa;wBAC7C1B,WAAW2B,OAAOC,IAAI,CAAC5B;wBACvB6B,UAAUrB;;;8BAGd,MAAClB;;sCACC,KAACC;4BAAOuC,SAAQ;4BAAYC,MAAK;4BAASC,MAAMnC;sCAC7CE,iBAAiBgB,IAAI,KAAK,SAAS,UAAU;;sCAEhD,KAACxB;4BAAOuC,SAAQ;4BAAWG,OAAM;4BAAYhB,SAASlB,iBAAiBM,KAAK;sCAAE;;;;;;;AAQ1F"}
1
+ {"version":3,"sources":["../../../src/components/PanelGroupDialog/PanelGroupDialog.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ReactElement, useState } from 'react';\nimport { useVariableValues } from '@perses-dev/plugin-system';\nimport { Dialog } from '@perses-dev/components';\nimport { Button } from '@mui/material';\nimport { usePanelGroupEditor } from '../../context';\nimport { PanelGroupEditorForm, panelGroupEditorFormId, PanelGroupEditorFormProps } from './PanelGroupEditorForm';\n\n/**\n * A dialog for adding or editing a Panel Group. Open and initial state is controlled by the DashboardStore.\n */\nexport function PanelGroupDialog(): ReactElement {\n const panelGroupEditor = usePanelGroupEditor();\n const variables = useVariableValues();\n\n // When the user clicks close, start closing but don't call the store yet to keep values stable during animtation\n const [isClosing, setIsClosing] = useState(false);\n const handleClose = (): void => setIsClosing(true);\n\n // Don't call close on the store until the Dialog has completely transitioned out\n const handleExited = (): void => {\n panelGroupEditor?.close();\n setIsClosing(false);\n };\n\n // Dialog is open if we have a model and we're not transitioning out\n const isOpen = panelGroupEditor !== undefined && isClosing === false;\n\n const handleSubmit: PanelGroupEditorFormProps['onSubmit'] = (values) => {\n // This shouldn't happen since we don't render the submit button until we have a model, but check to make TS happy\n if (panelGroupEditor === undefined) {\n throw new Error('Cannot apply changes');\n }\n panelGroupEditor.applyChanges(values);\n handleClose();\n };\n\n return (\n <Dialog open={isOpen} TransitionProps={{ onExited: handleExited }}>\n {panelGroupEditor !== undefined && (\n <>\n <Dialog.Header>{panelGroupEditor.mode} Panel Group</Dialog.Header>\n <Dialog.Content dividers sx={{ width: '500px' }}>\n <PanelGroupEditorForm\n initialValues={panelGroupEditor.initialValues}\n variables={Object.keys(variables)}\n onSubmit={handleSubmit}\n />\n </Dialog.Content>\n <Dialog.Actions>\n <Button variant=\"contained\" type=\"submit\" form={panelGroupEditorFormId}>\n {panelGroupEditor.mode === 'Edit' ? 'Apply' : 'Add'}\n </Button>\n <Button variant=\"outlined\" color=\"secondary\" onClick={panelGroupEditor.close}>\n Cancel\n </Button>\n </Dialog.Actions>\n </>\n )}\n </Dialog>\n );\n}\n"],"names":["useState","useVariableValues","Dialog","Button","usePanelGroupEditor","PanelGroupEditorForm","panelGroupEditorFormId","PanelGroupDialog","panelGroupEditor","variables","isClosing","setIsClosing","handleClose","handleExited","close","isOpen","undefined","handleSubmit","values","Error","applyChanges","open","TransitionProps","onExited","Header","mode","Content","dividers","sx","width","initialValues","Object","keys","onSubmit","Actions","variant","type","form","color","onClick"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAAuBA,QAAQ,QAAQ,QAAQ;AAC/C,SAASC,iBAAiB,QAAQ,4BAA4B;AAC9D,SAASC,MAAM,QAAQ,yBAAyB;AAChD,SAASC,MAAM,QAAQ,gBAAgB;AACvC,SAASC,mBAAmB,QAAQ,gBAAgB;AACpD,SAASC,oBAAoB,EAAEC,sBAAsB,QAAmC,yBAAyB;AAEjH;;CAEC,GACD,OAAO,SAASC;IACd,MAAMC,mBAAmBJ;IACzB,MAAMK,YAAYR;IAElB,iHAAiH;IACjH,MAAM,CAACS,WAAWC,aAAa,GAAGX,SAAS;IAC3C,MAAMY,cAAc,IAAYD,aAAa;IAE7C,iFAAiF;IACjF,MAAME,eAAe;QACnBL,kBAAkBM;QAClBH,aAAa;IACf;IAEA,oEAAoE;IACpE,MAAMI,SAASP,qBAAqBQ,aAAaN,cAAc;IAE/D,MAAMO,eAAsD,CAACC;QAC3D,kHAAkH;QAClH,IAAIV,qBAAqBQ,WAAW;YAClC,MAAM,IAAIG,MAAM;QAClB;QACAX,iBAAiBY,YAAY,CAACF;QAC9BN;IACF;IAEA,qBACE,KAACV;QAAOmB,MAAMN;QAAQO,iBAAiB;YAAEC,UAAUV;QAAa;kBAC7DL,qBAAqBQ,2BACpB;;8BACE,MAACd,OAAOsB,MAAM;;wBAAEhB,iBAAiBiB,IAAI;wBAAC;;;8BACtC,KAACvB,OAAOwB,OAAO;oBAACC,QAAQ;oBAACC,IAAI;wBAAEC,OAAO;oBAAQ;8BAC5C,cAAA,KAACxB;wBACCyB,eAAetB,iBAAiBsB,aAAa;wBAC7CrB,WAAWsB,OAAOC,IAAI,CAACvB;wBACvBwB,UAAUhB;;;8BAGd,MAACf,OAAOgC,OAAO;;sCACb,KAAC/B;4BAAOgC,SAAQ;4BAAYC,MAAK;4BAASC,MAAM/B;sCAC7CE,iBAAiBiB,IAAI,KAAK,SAAS,UAAU;;sCAEhD,KAACtB;4BAAOgC,SAAQ;4BAAWG,OAAM;4BAAYC,SAAS/B,iBAAiBM,KAAK;sCAAE;;;;;;;AAQ1F"}
@@ -0,0 +1,9 @@
1
+ import { ReactElement } from 'react';
2
+ import { QueryDefinition } from '@perses-dev/core';
3
+ export interface QueryViewerDialogProps {
4
+ open: boolean;
5
+ queryDefinitions: QueryDefinition[];
6
+ onClose: () => void;
7
+ }
8
+ export declare function QueryViewerDialog({ open, queryDefinitions, onClose }: QueryViewerDialogProps): ReactElement;
9
+ //# sourceMappingURL=QueryViewerDialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QueryViewerDialog.d.ts","sourceRoot":"","sources":["../../../src/components/QueryViewerDialog/QueryViewerDialog.tsx"],"names":[],"mappings":"AAaA,OAAc,EAAE,YAAY,EAAW,MAAM,OAAO,CAAC;AAIrD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,OAAO,CAAC;IACd,gBAAgB,EAAE,eAAe,EAAE,CAAC;IACpC,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,wBAAgB,iBAAiB,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,EAAE,sBAAsB,GAAG,YAAY,CAmC3G"}
@@ -0,0 +1,72 @@
1
+ // Copyright 2025 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
+ import React, { useMemo } from 'react';
15
+ import { Dialog } from '@perses-dev/components';
16
+ import { Button, Divider } from '@mui/material';
17
+ import { PluginSpecEditor } from '@perses-dev/plugin-system';
18
+ export function QueryViewerDialog({ open, queryDefinitions, onClose }) {
19
+ const queryRows = useMemo(()=>{
20
+ if (!queryDefinitions?.length) return null;
21
+ const queryItems = [];
22
+ queryDefinitions.forEach((query, index)=>{
23
+ if (query?.spec?.plugin?.kind && query?.kind) {
24
+ queryItems.push(/*#__PURE__*/ _jsxs(React.Fragment, {
25
+ children: [
26
+ /*#__PURE__*/ _jsx(PluginSpecEditor, {
27
+ value: query.spec.plugin.spec,
28
+ pluginSelection: {
29
+ kind: query.spec.plugin.kind,
30
+ type: query.kind
31
+ },
32
+ onChange: ()=>{},
33
+ isReadonly: true
34
+ }),
35
+ index < queryDefinitions.length - 1 && /*#__PURE__*/ _jsx(Divider, {
36
+ sx: {
37
+ my: 2
38
+ }
39
+ })
40
+ ]
41
+ }, `query-${index}`));
42
+ }
43
+ });
44
+ return queryItems;
45
+ }, [
46
+ queryDefinitions
47
+ ]);
48
+ return /*#__PURE__*/ _jsxs(Dialog, {
49
+ open: open,
50
+ onClose: onClose,
51
+ maxWidth: "lg",
52
+ fullWidth: true,
53
+ children: [
54
+ /*#__PURE__*/ _jsx(Dialog.Header, {
55
+ children: "Query Viewer"
56
+ }),
57
+ /*#__PURE__*/ _jsx(Dialog.Content, {
58
+ children: queryRows
59
+ }),
60
+ /*#__PURE__*/ _jsx(Dialog.Actions, {
61
+ children: /*#__PURE__*/ _jsx(Button, {
62
+ variant: "outlined",
63
+ color: "secondary",
64
+ onClick: onClose,
65
+ children: "Close"
66
+ })
67
+ })
68
+ ]
69
+ });
70
+ }
71
+
72
+ //# sourceMappingURL=QueryViewerDialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/QueryViewerDialog/QueryViewerDialog.tsx"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React, { ReactElement, useMemo } from 'react';\nimport { Dialog } from '@perses-dev/components';\nimport { Button, Divider } from '@mui/material';\nimport { PluginSpecEditor } from '@perses-dev/plugin-system';\nimport { QueryDefinition } from '@perses-dev/core';\n\nexport interface QueryViewerDialogProps {\n open: boolean;\n queryDefinitions: QueryDefinition[];\n onClose: () => void;\n}\n\nexport function QueryViewerDialog({ open, queryDefinitions, onClose }: QueryViewerDialogProps): ReactElement {\n const queryRows = useMemo(() => {\n if (!queryDefinitions?.length) return null;\n\n const queryItems: ReactElement[] = [];\n queryDefinitions.forEach((query, index) => {\n if (query?.spec?.plugin?.kind && query?.kind) {\n queryItems.push(\n <React.Fragment key={`query-${index}`}>\n <PluginSpecEditor\n value={query.spec.plugin.spec}\n pluginSelection={{ kind: query.spec.plugin.kind, type: query.kind }}\n onChange={(): void => {}}\n isReadonly\n />\n {index < queryDefinitions.length - 1 && <Divider sx={{ my: 2 }} />}\n </React.Fragment>\n );\n }\n });\n\n return queryItems;\n }, [queryDefinitions]);\n\n return (\n <Dialog open={open} onClose={onClose} maxWidth=\"lg\" fullWidth={true}>\n <Dialog.Header>Query Viewer</Dialog.Header>\n <Dialog.Content>{queryRows}</Dialog.Content>\n <Dialog.Actions>\n <Button variant=\"outlined\" color=\"secondary\" onClick={onClose}>\n Close\n </Button>\n </Dialog.Actions>\n </Dialog>\n );\n}\n"],"names":["React","useMemo","Dialog","Button","Divider","PluginSpecEditor","QueryViewerDialog","open","queryDefinitions","onClose","queryRows","length","queryItems","forEach","query","index","spec","plugin","kind","push","Fragment","value","pluginSelection","type","onChange","isReadonly","sx","my","maxWidth","fullWidth","Header","Content","Actions","variant","color","onClick"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,OAAOA,SAAuBC,OAAO,QAAQ,QAAQ;AACrD,SAASC,MAAM,QAAQ,yBAAyB;AAChD,SAASC,MAAM,EAAEC,OAAO,QAAQ,gBAAgB;AAChD,SAASC,gBAAgB,QAAQ,4BAA4B;AAS7D,OAAO,SAASC,kBAAkB,EAAEC,IAAI,EAAEC,gBAAgB,EAAEC,OAAO,EAA0B;IAC3F,MAAMC,YAAYT,QAAQ;QACxB,IAAI,CAACO,kBAAkBG,QAAQ,OAAO;QAEtC,MAAMC,aAA6B,EAAE;QACrCJ,iBAAiBK,OAAO,CAAC,CAACC,OAAOC;YAC/B,IAAID,OAAOE,MAAMC,QAAQC,QAAQJ,OAAOI,MAAM;gBAC5CN,WAAWO,IAAI,eACb,MAACnB,MAAMoB,QAAQ;;sCACb,KAACf;4BACCgB,OAAOP,MAAME,IAAI,CAACC,MAAM,CAACD,IAAI;4BAC7BM,iBAAiB;gCAAEJ,MAAMJ,MAAME,IAAI,CAACC,MAAM,CAACC,IAAI;gCAAEK,MAAMT,MAAMI,IAAI;4BAAC;4BAClEM,UAAU,KAAa;4BACvBC,UAAU;;wBAEXV,QAAQP,iBAAiBG,MAAM,GAAG,mBAAK,KAACP;4BAAQsB,IAAI;gCAAEC,IAAI;4BAAE;;;mBAP1C,CAAC,MAAM,EAAEZ,OAAO;YAUzC;QACF;QAEA,OAAOH;IACT,GAAG;QAACJ;KAAiB;IAErB,qBACE,MAACN;QAAOK,MAAMA;QAAME,SAASA;QAASmB,UAAS;QAAKC,WAAW;;0BAC7D,KAAC3B,OAAO4B,MAAM;0BAAC;;0BACf,KAAC5B,OAAO6B,OAAO;0BAAErB;;0BACjB,KAACR,OAAO8B,OAAO;0BACb,cAAA,KAAC7B;oBAAO8B,SAAQ;oBAAWC,OAAM;oBAAYC,SAAS1B;8BAAS;;;;;AAMvE"}
@@ -0,0 +1,2 @@
1
+ export * from './QueryViewerDialog';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/QueryViewerDialog/index.ts"],"names":[],"mappings":"AAaA,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,15 @@
1
+ // Copyright 2025 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ export * from './QueryViewerDialog';
14
+
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/QueryViewerDialog/index.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './QueryViewerDialog';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,sBAAsB"}
@@ -1 +1 @@
1
- {"version":3,"file":"SaveChangesConfirmationDialog.d.ts","sourceRoot":"","sources":["../../../src/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAY,MAAM,OAAO,CAAC;AAU/C,eAAO,MAAM,6BAA6B,QAAO,YAqEhD,CAAC"}
1
+ {"version":3,"file":"SaveChangesConfirmationDialog.d.ts","sourceRoot":"","sources":["../../../src/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAY,MAAM,OAAO,CAAC;AAU/C,eAAO,MAAM,6BAA6B,QAAO,YAyFhD,CAAC"}
@@ -13,7 +13,7 @@
13
13
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
14
14
  import { useState } from 'react';
15
15
  import { Checkbox, FormGroup, FormControlLabel, Typography } from '@mui/material';
16
- import { useTimeRange } from '@perses-dev/plugin-system';
16
+ import { DEFAULT_REFRESH_INTERVAL_OPTIONS, useTimeRange } from '@perses-dev/plugin-system';
17
17
  import { isRelativeTimeRange } from '@perses-dev/core';
18
18
  import { Dialog } from '@perses-dev/components';
19
19
  import { useSaveChangesConfirmationDialog, useVariableDefinitionActions } from '../../context';
@@ -22,15 +22,19 @@ export const SaveChangesConfirmationDialog = ()=>{
22
22
  const { saveChangesConfirmationDialog: dialog } = useSaveChangesConfirmationDialog();
23
23
  const isSavedDurationModified = dialog?.isSavedDurationModified ?? true;
24
24
  const isSavedVariableModified = dialog?.isSavedVariableModified ?? true;
25
+ const isSavedRefreshIntervalModified = dialog?.isSavedRefreshIntervalModified ?? true;
25
26
  const [saveDefaultTimeRange, setSaveDefaultTimeRange] = useState(isSavedDurationModified);
26
27
  const [saveDefaultVariables, setSaveDefaultVariables] = useState(isSavedVariableModified);
28
+ const [saveDefaultRefreshInterval, setDefaultRefreshInterval] = useState(isSavedRefreshIntervalModified);
27
29
  const { getSavedVariablesStatus } = useVariableDefinitionActions();
28
30
  const { modifiedVariableNames } = getSavedVariablesStatus();
29
31
  const isOpen = dialog !== undefined;
30
- const { timeRange } = useTimeRange();
32
+ const { timeRange, refreshInterval } = useTimeRange();
31
33
  const currentTimeRangeText = isRelativeTimeRange(timeRange) ? `(Last ${timeRange.pastDuration})` : '(Absolute time ranges can not be saved)';
32
- const saveTimeRangeText = `Save current time range as new default ${currentTimeRangeText}`;
33
- const saveVariablesText = `Save current variable values as new default (${modifiedVariableNames.length > 0 ? modifiedVariableNames.join(', ') : 'No modified variables'})`;
34
+ const saveTimeRangeMessage = `Save current time range as new default ${currentTimeRangeText}`;
35
+ const saveVariableMessage = `Save current variable values as new default (${modifiedVariableNames.length > 0 ? modifiedVariableNames.join(', ') : 'No modified variables'})`;
36
+ const refreshIntervalDisplay = DEFAULT_REFRESH_INTERVAL_OPTIONS.some((i)=>i.display === refreshInterval) ? refreshInterval : DEFAULT_REFRESH_INTERVAL_OPTIONS.find((i)=>i.value.pastDuration === refreshInterval)?.display;
37
+ const saveRefreshIntervalMessage = `Save current refresh interval as new default ${refreshIntervalDisplay ? `(${refreshIntervalDisplay})` : 'refresh interval not modified'}`;
34
38
  return /*#__PURE__*/ _jsx(Dialog, {
35
39
  open: isOpen,
36
40
  children: dialog !== undefined && /*#__PURE__*/ _jsxs(_Fragment, {
@@ -53,7 +57,15 @@ export const SaveChangesConfirmationDialog = ()=>{
53
57
  checked: saveDefaultTimeRange && isSavedDurationModified && isRelativeTimeRange(timeRange),
54
58
  onChange: (e)=>setSaveDefaultTimeRange(e.target.checked)
55
59
  }),
56
- label: saveTimeRangeText
60
+ label: saveTimeRangeMessage
61
+ }),
62
+ /*#__PURE__*/ _jsx(FormControlLabel, {
63
+ control: /*#__PURE__*/ _jsx(Checkbox, {
64
+ disabled: !isSavedRefreshIntervalModified,
65
+ checked: saveDefaultRefreshInterval && isSavedRefreshIntervalModified,
66
+ onChange: (e)=>setDefaultRefreshInterval(e.target.checked)
67
+ }),
68
+ label: saveRefreshIntervalMessage
57
69
  }),
58
70
  /*#__PURE__*/ _jsx(FormControlLabel, {
59
71
  control: /*#__PURE__*/ _jsx(Checkbox, {
@@ -61,7 +73,7 @@ export const SaveChangesConfirmationDialog = ()=>{
61
73
  checked: saveDefaultVariables && isSavedVariableModified,
62
74
  onChange: (e)=>setSaveDefaultVariables(e.target.checked)
63
75
  }),
64
- label: saveVariablesText
76
+ label: saveVariableMessage
65
77
  })
66
78
  ]
67
79
  })
@@ -71,7 +83,7 @@ export const SaveChangesConfirmationDialog = ()=>{
71
83
  children: [
72
84
  /*#__PURE__*/ _jsx(Dialog.PrimaryButton, {
73
85
  onClick: ()=>{
74
- return dialog.onSaveChanges(saveDefaultTimeRange, saveDefaultVariables);
86
+ return dialog.onSaveChanges(saveDefaultTimeRange, saveDefaultRefreshInterval, saveDefaultVariables);
75
87
  },
76
88
  children: "Save Changes"
77
89
  }),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.tsx"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ReactElement, useState } from 'react';\nimport { Checkbox, FormGroup, FormControlLabel, Typography } from '@mui/material';\nimport { useTimeRange } from '@perses-dev/plugin-system';\nimport { isRelativeTimeRange } from '@perses-dev/core';\nimport { Dialog } from '@perses-dev/components';\nimport { useSaveChangesConfirmationDialog, useVariableDefinitionActions } from '../../context';\n\nconst SAVE_DEFAULTS_DIALOG_TEXT =\n 'You have made changes to the time range or the variables values. Would you like to save these as defaults?';\n\nexport const SaveChangesConfirmationDialog = (): ReactElement => {\n const { saveChangesConfirmationDialog: dialog } = useSaveChangesConfirmationDialog();\n const isSavedDurationModified = dialog?.isSavedDurationModified ?? true;\n const isSavedVariableModified = dialog?.isSavedVariableModified ?? true;\n const [saveDefaultTimeRange, setSaveDefaultTimeRange] = useState(isSavedDurationModified);\n const [saveDefaultVariables, setSaveDefaultVariables] = useState(isSavedVariableModified);\n\n const { getSavedVariablesStatus } = useVariableDefinitionActions();\n const { modifiedVariableNames } = getSavedVariablesStatus();\n\n const isOpen = dialog !== undefined;\n\n const { timeRange } = useTimeRange();\n const currentTimeRangeText = isRelativeTimeRange(timeRange)\n ? `(Last ${timeRange.pastDuration})`\n : '(Absolute time ranges can not be saved)';\n\n const saveTimeRangeText = `Save current time range as new default ${currentTimeRangeText}`;\n\n const saveVariablesText = `Save current variable values as new default (${\n modifiedVariableNames.length > 0 ? modifiedVariableNames.join(', ') : 'No modified variables'\n })`;\n\n return (\n <Dialog open={isOpen}>\n {dialog !== undefined && (\n <>\n <Dialog.Header onClose={() => dialog.onCancel()}>Save Dashboard</Dialog.Header>\n\n <Dialog.Content>\n <Typography marginBottom={2}>{dialog.description || SAVE_DEFAULTS_DIALOG_TEXT}</Typography>\n <FormGroup>\n <FormControlLabel\n control={\n <Checkbox\n disabled={!isSavedDurationModified || !isRelativeTimeRange(timeRange)}\n checked={saveDefaultTimeRange && isSavedDurationModified && isRelativeTimeRange(timeRange)}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => setSaveDefaultTimeRange(e.target.checked)}\n />\n }\n label={saveTimeRangeText}\n />\n <FormControlLabel\n control={\n <Checkbox\n disabled={!isSavedVariableModified}\n checked={saveDefaultVariables && isSavedVariableModified}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => setSaveDefaultVariables(e.target.checked)}\n />\n }\n label={saveVariablesText}\n />\n </FormGroup>\n </Dialog.Content>\n\n <Dialog.Actions>\n <Dialog.PrimaryButton\n onClick={() => {\n return dialog.onSaveChanges(saveDefaultTimeRange, saveDefaultVariables);\n }}\n >\n Save Changes\n </Dialog.PrimaryButton>\n <Dialog.SecondaryButton onClick={() => dialog.onCancel()}>Cancel</Dialog.SecondaryButton>\n </Dialog.Actions>\n </>\n )}\n </Dialog>\n );\n};\n"],"names":["useState","Checkbox","FormGroup","FormControlLabel","Typography","useTimeRange","isRelativeTimeRange","Dialog","useSaveChangesConfirmationDialog","useVariableDefinitionActions","SAVE_DEFAULTS_DIALOG_TEXT","SaveChangesConfirmationDialog","saveChangesConfirmationDialog","dialog","isSavedDurationModified","isSavedVariableModified","saveDefaultTimeRange","setSaveDefaultTimeRange","saveDefaultVariables","setSaveDefaultVariables","getSavedVariablesStatus","modifiedVariableNames","isOpen","undefined","timeRange","currentTimeRangeText","pastDuration","saveTimeRangeText","saveVariablesText","length","join","open","Header","onClose","onCancel","Content","marginBottom","description","control","disabled","checked","onChange","e","target","label","Actions","PrimaryButton","onClick","onSaveChanges","SecondaryButton"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAAuBA,QAAQ,QAAQ,QAAQ;AAC/C,SAASC,QAAQ,EAAEC,SAAS,EAAEC,gBAAgB,EAAEC,UAAU,QAAQ,gBAAgB;AAClF,SAASC,YAAY,QAAQ,4BAA4B;AACzD,SAASC,mBAAmB,QAAQ,mBAAmB;AACvD,SAASC,MAAM,QAAQ,yBAAyB;AAChD,SAASC,gCAAgC,EAAEC,4BAA4B,QAAQ,gBAAgB;AAE/F,MAAMC,4BACJ;AAEF,OAAO,MAAMC,gCAAgC;IAC3C,MAAM,EAAEC,+BAA+BC,MAAM,EAAE,GAAGL;IAClD,MAAMM,0BAA0BD,QAAQC,2BAA2B;IACnE,MAAMC,0BAA0BF,QAAQE,2BAA2B;IACnE,MAAM,CAACC,sBAAsBC,wBAAwB,GAAGjB,SAASc;IACjE,MAAM,CAACI,sBAAsBC,wBAAwB,GAAGnB,SAASe;IAEjE,MAAM,EAAEK,uBAAuB,EAAE,GAAGX;IACpC,MAAM,EAAEY,qBAAqB,EAAE,GAAGD;IAElC,MAAME,SAAST,WAAWU;IAE1B,MAAM,EAAEC,SAAS,EAAE,GAAGnB;IACtB,MAAMoB,uBAAuBnB,oBAAoBkB,aAC7C,CAAC,MAAM,EAAEA,UAAUE,YAAY,CAAC,CAAC,CAAC,GAClC;IAEJ,MAAMC,oBAAoB,CAAC,uCAAuC,EAAEF,sBAAsB;IAE1F,MAAMG,oBAAoB,CAAC,6CAA6C,EACtEP,sBAAsBQ,MAAM,GAAG,IAAIR,sBAAsBS,IAAI,CAAC,QAAQ,wBACvE,CAAC,CAAC;IAEH,qBACE,KAACvB;QAAOwB,MAAMT;kBACXT,WAAWU,2BACV;;8BACE,KAAChB,OAAOyB,MAAM;oBAACC,SAAS,IAAMpB,OAAOqB,QAAQ;8BAAI;;8BAEjD,MAAC3B,OAAO4B,OAAO;;sCACb,KAAC/B;4BAAWgC,cAAc;sCAAIvB,OAAOwB,WAAW,IAAI3B;;sCACpD,MAACR;;8CACC,KAACC;oCACCmC,uBACE,KAACrC;wCACCsC,UAAU,CAACzB,2BAA2B,CAACR,oBAAoBkB;wCAC3DgB,SAASxB,wBAAwBF,2BAA2BR,oBAAoBkB;wCAChFiB,UAAU,CAACC,IAA2CzB,wBAAwByB,EAAEC,MAAM,CAACH,OAAO;;oCAGlGI,OAAOjB;;8CAET,KAACxB;oCACCmC,uBACE,KAACrC;wCACCsC,UAAU,CAACxB;wCACXyB,SAAStB,wBAAwBH;wCACjC0B,UAAU,CAACC,IAA2CvB,wBAAwBuB,EAAEC,MAAM,CAACH,OAAO;;oCAGlGI,OAAOhB;;;;;;8BAKb,MAACrB,OAAOsC,OAAO;;sCACb,KAACtC,OAAOuC,aAAa;4BACnBC,SAAS;gCACP,OAAOlC,OAAOmC,aAAa,CAAChC,sBAAsBE;4BACpD;sCACD;;sCAGD,KAACX,OAAO0C,eAAe;4BAACF,SAAS,IAAMlC,OAAOqB,QAAQ;sCAAI;;;;;;;AAMtE,EAAE"}
1
+ {"version":3,"sources":["../../../src/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.tsx"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ReactElement, useState } from 'react';\nimport { Checkbox, FormGroup, FormControlLabel, Typography } from '@mui/material';\nimport { DEFAULT_REFRESH_INTERVAL_OPTIONS, useTimeRange } from '@perses-dev/plugin-system';\nimport { isRelativeTimeRange } from '@perses-dev/core';\nimport { Dialog } from '@perses-dev/components';\nimport { useSaveChangesConfirmationDialog, useVariableDefinitionActions } from '../../context';\n\nconst SAVE_DEFAULTS_DIALOG_TEXT =\n 'You have made changes to the time range or the variables values. Would you like to save these as defaults?';\n\nexport const SaveChangesConfirmationDialog = (): ReactElement => {\n const { saveChangesConfirmationDialog: dialog } = useSaveChangesConfirmationDialog();\n const isSavedDurationModified = dialog?.isSavedDurationModified ?? true;\n const isSavedVariableModified = dialog?.isSavedVariableModified ?? true;\n const isSavedRefreshIntervalModified = dialog?.isSavedRefreshIntervalModified ?? true;\n\n const [saveDefaultTimeRange, setSaveDefaultTimeRange] = useState(isSavedDurationModified);\n const [saveDefaultVariables, setSaveDefaultVariables] = useState(isSavedVariableModified);\n const [saveDefaultRefreshInterval, setDefaultRefreshInterval] = useState(isSavedRefreshIntervalModified);\n\n const { getSavedVariablesStatus } = useVariableDefinitionActions();\n const { modifiedVariableNames } = getSavedVariablesStatus();\n\n const isOpen = dialog !== undefined;\n\n const { timeRange, refreshInterval } = useTimeRange();\n\n const currentTimeRangeText = isRelativeTimeRange(timeRange)\n ? `(Last ${timeRange.pastDuration})`\n : '(Absolute time ranges can not be saved)';\n\n const saveTimeRangeMessage = `Save current time range as new default ${currentTimeRangeText}`;\n\n const saveVariableMessage = `Save current variable values as new default (${\n modifiedVariableNames.length > 0 ? modifiedVariableNames.join(', ') : 'No modified variables'\n })`;\n\n const refreshIntervalDisplay = DEFAULT_REFRESH_INTERVAL_OPTIONS.some((i) => i.display === refreshInterval)\n ? refreshInterval\n : DEFAULT_REFRESH_INTERVAL_OPTIONS.find((i) => i.value.pastDuration === refreshInterval)?.display;\n\n const saveRefreshIntervalMessage = `Save current refresh interval as new default ${refreshIntervalDisplay ? `(${refreshIntervalDisplay})` : 'refresh interval not modified'}`;\n\n return (\n <Dialog open={isOpen}>\n {dialog !== undefined && (\n <>\n <Dialog.Header onClose={() => dialog.onCancel()}>Save Dashboard</Dialog.Header>\n\n <Dialog.Content>\n <Typography marginBottom={2}>{dialog.description || SAVE_DEFAULTS_DIALOG_TEXT}</Typography>\n <FormGroup>\n <FormControlLabel\n control={\n <Checkbox\n disabled={!isSavedDurationModified || !isRelativeTimeRange(timeRange)}\n checked={saveDefaultTimeRange && isSavedDurationModified && isRelativeTimeRange(timeRange)}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => setSaveDefaultTimeRange(e.target.checked)}\n />\n }\n label={saveTimeRangeMessage}\n />\n <FormControlLabel\n control={\n <Checkbox\n disabled={!isSavedRefreshIntervalModified}\n checked={saveDefaultRefreshInterval && isSavedRefreshIntervalModified}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => setDefaultRefreshInterval(e.target.checked)}\n />\n }\n label={saveRefreshIntervalMessage}\n />\n <FormControlLabel\n control={\n <Checkbox\n disabled={!isSavedVariableModified}\n checked={saveDefaultVariables && isSavedVariableModified}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => setSaveDefaultVariables(e.target.checked)}\n />\n }\n label={saveVariableMessage}\n />\n </FormGroup>\n </Dialog.Content>\n\n <Dialog.Actions>\n <Dialog.PrimaryButton\n onClick={() => {\n return dialog.onSaveChanges(saveDefaultTimeRange, saveDefaultRefreshInterval, saveDefaultVariables);\n }}\n >\n Save Changes\n </Dialog.PrimaryButton>\n <Dialog.SecondaryButton onClick={() => dialog.onCancel()}>Cancel</Dialog.SecondaryButton>\n </Dialog.Actions>\n </>\n )}\n </Dialog>\n );\n};\n"],"names":["useState","Checkbox","FormGroup","FormControlLabel","Typography","DEFAULT_REFRESH_INTERVAL_OPTIONS","useTimeRange","isRelativeTimeRange","Dialog","useSaveChangesConfirmationDialog","useVariableDefinitionActions","SAVE_DEFAULTS_DIALOG_TEXT","SaveChangesConfirmationDialog","saveChangesConfirmationDialog","dialog","isSavedDurationModified","isSavedVariableModified","isSavedRefreshIntervalModified","saveDefaultTimeRange","setSaveDefaultTimeRange","saveDefaultVariables","setSaveDefaultVariables","saveDefaultRefreshInterval","setDefaultRefreshInterval","getSavedVariablesStatus","modifiedVariableNames","isOpen","undefined","timeRange","refreshInterval","currentTimeRangeText","pastDuration","saveTimeRangeMessage","saveVariableMessage","length","join","refreshIntervalDisplay","some","i","display","find","value","saveRefreshIntervalMessage","open","Header","onClose","onCancel","Content","marginBottom","description","control","disabled","checked","onChange","e","target","label","Actions","PrimaryButton","onClick","onSaveChanges","SecondaryButton"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAAuBA,QAAQ,QAAQ,QAAQ;AAC/C,SAASC,QAAQ,EAAEC,SAAS,EAAEC,gBAAgB,EAAEC,UAAU,QAAQ,gBAAgB;AAClF,SAASC,gCAAgC,EAAEC,YAAY,QAAQ,4BAA4B;AAC3F,SAASC,mBAAmB,QAAQ,mBAAmB;AACvD,SAASC,MAAM,QAAQ,yBAAyB;AAChD,SAASC,gCAAgC,EAAEC,4BAA4B,QAAQ,gBAAgB;AAE/F,MAAMC,4BACJ;AAEF,OAAO,MAAMC,gCAAgC;IAC3C,MAAM,EAAEC,+BAA+BC,MAAM,EAAE,GAAGL;IAClD,MAAMM,0BAA0BD,QAAQC,2BAA2B;IACnE,MAAMC,0BAA0BF,QAAQE,2BAA2B;IACnE,MAAMC,iCAAiCH,QAAQG,kCAAkC;IAEjF,MAAM,CAACC,sBAAsBC,wBAAwB,GAAGnB,SAASe;IACjE,MAAM,CAACK,sBAAsBC,wBAAwB,GAAGrB,SAASgB;IACjE,MAAM,CAACM,4BAA4BC,0BAA0B,GAAGvB,SAASiB;IAEzE,MAAM,EAAEO,uBAAuB,EAAE,GAAGd;IACpC,MAAM,EAAEe,qBAAqB,EAAE,GAAGD;IAElC,MAAME,SAASZ,WAAWa;IAE1B,MAAM,EAAEC,SAAS,EAAEC,eAAe,EAAE,GAAGvB;IAEvC,MAAMwB,uBAAuBvB,oBAAoBqB,aAC7C,CAAC,MAAM,EAAEA,UAAUG,YAAY,CAAC,CAAC,CAAC,GAClC;IAEJ,MAAMC,uBAAuB,CAAC,uCAAuC,EAAEF,sBAAsB;IAE7F,MAAMG,sBAAsB,CAAC,6CAA6C,EACxER,sBAAsBS,MAAM,GAAG,IAAIT,sBAAsBU,IAAI,CAAC,QAAQ,wBACvE,CAAC,CAAC;IAEH,MAAMC,yBAAyB/B,iCAAiCgC,IAAI,CAAC,CAACC,IAAMA,EAAEC,OAAO,KAAKV,mBACtFA,kBACAxB,iCAAiCmC,IAAI,CAAC,CAACF,IAAMA,EAAEG,KAAK,CAACV,YAAY,KAAKF,kBAAkBU;IAE5F,MAAMG,6BAA6B,CAAC,6CAA6C,EAAEN,yBAAyB,CAAC,CAAC,EAAEA,uBAAuB,CAAC,CAAC,GAAG,iCAAiC;IAE7K,qBACE,KAAC5B;QAAOmC,MAAMjB;kBACXZ,WAAWa,2BACV;;8BACE,KAACnB,OAAOoC,MAAM;oBAACC,SAAS,IAAM/B,OAAOgC,QAAQ;8BAAI;;8BAEjD,MAACtC,OAAOuC,OAAO;;sCACb,KAAC3C;4BAAW4C,cAAc;sCAAIlC,OAAOmC,WAAW,IAAItC;;sCACpD,MAACT;;8CACC,KAACC;oCACC+C,uBACE,KAACjD;wCACCkD,UAAU,CAACpC,2BAA2B,CAACR,oBAAoBqB;wCAC3DwB,SAASlC,wBAAwBH,2BAA2BR,oBAAoBqB;wCAChFyB,UAAU,CAACC,IAA2CnC,wBAAwBmC,EAAEC,MAAM,CAACH,OAAO;;oCAGlGI,OAAOxB;;8CAET,KAAC7B;oCACC+C,uBACE,KAACjD;wCACCkD,UAAU,CAAClC;wCACXmC,SAAS9B,8BAA8BL;wCACvCoC,UAAU,CAACC,IAA2C/B,0BAA0B+B,EAAEC,MAAM,CAACH,OAAO;;oCAGpGI,OAAOd;;8CAET,KAACvC;oCACC+C,uBACE,KAACjD;wCACCkD,UAAU,CAACnC;wCACXoC,SAAShC,wBAAwBJ;wCACjCqC,UAAU,CAACC,IAA2CjC,wBAAwBiC,EAAEC,MAAM,CAACH,OAAO;;oCAGlGI,OAAOvB;;;;;;8BAKb,MAACzB,OAAOiD,OAAO;;sCACb,KAACjD,OAAOkD,aAAa;4BACnBC,SAAS;gCACP,OAAO7C,OAAO8C,aAAa,CAAC1C,sBAAsBI,4BAA4BF;4BAChF;sCACD;;sCAGD,KAACZ,OAAOqD,eAAe;4BAACF,SAAS,IAAM7C,OAAOgC,QAAQ;sCAAI;;;;;;;AAMtE,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"file":"SaveDashboardButton.d.ts","sourceRoot":"","sources":["../../../src/components/SaveDashboardButton/SaveDashboardButton.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAY,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAU,WAAW,EAAE,MAAM,eAAe,CAAC;AAGpD,OAAO,EACL,eAAe,EAKhB,MAAM,eAAe,CAAC;AAEvB,MAAM,WAAW,wBAAyB,SAAQ,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC;IAC9E,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,UAAU,CAAC;CAC7C;AAED,eAAO,MAAM,mBAAmB,qCAI7B,wBAAwB,KAAG,YA8D7B,CAAC"}
1
+ {"version":3,"file":"SaveDashboardButton.d.ts","sourceRoot":"","sources":["../../../src/components/SaveDashboardButton/SaveDashboardButton.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAY,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAU,WAAW,EAAE,MAAM,eAAe,CAAC;AAGpD,OAAO,EACL,eAAe,EAKhB,MAAM,eAAe,CAAC;AAEvB,MAAM,WAAW,wBAAyB,SAAQ,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC;IAC9E,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,UAAU,CAAC;CAC7C;AAED,eAAO,MAAM,mBAAmB,qCAI7B,wBAAwB,KAAG,YAoE7B,CAAC"}
@@ -21,24 +21,28 @@ export const SaveDashboardButton = ({ onSave, isDisabled, variant = 'contained'
21
21
  const { dashboard, setDashboard } = useDashboard();
22
22
  const { getSavedVariablesStatus, setVariableDefaultValues } = useVariableDefinitionActions();
23
23
  const { isSavedVariableModified } = getSavedVariablesStatus();
24
- const { timeRange } = useTimeRange();
24
+ const { timeRange, refreshInterval } = useTimeRange();
25
25
  const { setEditMode } = useEditMode();
26
26
  const { openSaveChangesConfirmationDialog, closeSaveChangesConfirmationDialog } = useSaveChangesConfirmationDialog();
27
27
  const onSaveButtonClick = ()=>{
28
28
  const isSavedDurationModified = isRelativeTimeRange(timeRange) && dashboard.spec.duration !== timeRange.pastDuration;
29
+ const isSavedRefreshIntervalModified = dashboard.spec.refreshInterval !== refreshInterval;
29
30
  // Save dashboard
30
31
  // - if active timeRange from plugin-system is relative and different from currently saved
31
32
  // - or if the saved variables are different from currently saved
32
- if (isSavedDurationModified || isSavedVariableModified) {
33
+ if (isSavedDurationModified || isSavedVariableModified || isSavedRefreshIntervalModified) {
33
34
  openSaveChangesConfirmationDialog({
34
- onSaveChanges: (saveDefaultTimeRange, saveDefaultVariables)=>{
35
- if (isRelativeTimeRange(timeRange) && saveDefaultTimeRange === true) {
35
+ onSaveChanges: (saveDefaultTimeRange, saveDefaultRefreshInterval, saveDefaultVariables)=>{
36
+ if (isRelativeTimeRange(timeRange) && saveDefaultTimeRange) {
36
37
  dashboard.spec.duration = timeRange.pastDuration;
37
38
  }
38
- if (saveDefaultVariables === true) {
39
+ if (saveDefaultVariables) {
39
40
  const variables = setVariableDefaultValues();
40
41
  dashboard.spec.variables = variables;
41
42
  }
43
+ if (saveDefaultRefreshInterval && isSavedRefreshIntervalModified) {
44
+ dashboard.spec.refreshInterval = refreshInterval;
45
+ }
42
46
  setDashboard(dashboard);
43
47
  saveDashboard();
44
48
  },
@@ -46,7 +50,8 @@ export const SaveDashboardButton = ({ onSave, isDisabled, variant = 'contained'
46
50
  closeSaveChangesConfirmationDialog();
47
51
  },
48
52
  isSavedDurationModified,
49
- isSavedVariableModified
53
+ isSavedVariableModified,
54
+ isSavedRefreshIntervalModified
50
55
  });
51
56
  } else {
52
57
  saveDashboard();
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/SaveDashboardButton/SaveDashboardButton.tsx"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ReactElement, useState } from 'react';\nimport { Button, ButtonProps } from '@mui/material';\nimport { isRelativeTimeRange } from '@perses-dev/core';\nimport { useTimeRange } from '@perses-dev/plugin-system';\nimport {\n OnSaveDashboard,\n useDashboard,\n useEditMode,\n useSaveChangesConfirmationDialog,\n useVariableDefinitionActions,\n} from '../../context';\n\nexport interface SaveDashboardButtonProps extends Pick<ButtonProps, 'fullWidth'> {\n onSave?: OnSaveDashboard;\n isDisabled: boolean;\n variant?: 'contained' | 'text' | 'outlined';\n}\n\nexport const SaveDashboardButton = ({\n onSave,\n isDisabled,\n variant = 'contained',\n}: SaveDashboardButtonProps): ReactElement => {\n const [isSavingDashboard, setSavingDashboard] = useState<boolean>(false);\n const { dashboard, setDashboard } = useDashboard();\n const { getSavedVariablesStatus, setVariableDefaultValues } = useVariableDefinitionActions();\n const { isSavedVariableModified } = getSavedVariablesStatus();\n const { timeRange } = useTimeRange();\n const { setEditMode } = useEditMode();\n const { openSaveChangesConfirmationDialog, closeSaveChangesConfirmationDialog } = useSaveChangesConfirmationDialog();\n\n const onSaveButtonClick = (): void => {\n const isSavedDurationModified =\n isRelativeTimeRange(timeRange) && dashboard.spec.duration !== timeRange.pastDuration;\n\n // Save dashboard\n // - if active timeRange from plugin-system is relative and different from currently saved\n // - or if the saved variables are different from currently saved\n if (isSavedDurationModified || isSavedVariableModified) {\n openSaveChangesConfirmationDialog({\n onSaveChanges: (saveDefaultTimeRange, saveDefaultVariables) => {\n if (isRelativeTimeRange(timeRange) && saveDefaultTimeRange === true) {\n dashboard.spec.duration = timeRange.pastDuration;\n }\n if (saveDefaultVariables === true) {\n const variables = setVariableDefaultValues();\n dashboard.spec.variables = variables;\n }\n setDashboard(dashboard);\n saveDashboard();\n },\n onCancel: () => {\n closeSaveChangesConfirmationDialog();\n },\n isSavedDurationModified,\n isSavedVariableModified,\n });\n } else {\n saveDashboard();\n }\n };\n\n const saveDashboard = async (): Promise<void> => {\n if (onSave) {\n try {\n setSavingDashboard(true);\n await onSave(dashboard);\n closeSaveChangesConfirmationDialog();\n setEditMode(false);\n } catch (error) {\n throw new Error(`An error occurred while saving the dashboard. ${error}`);\n } finally {\n setSavingDashboard(false);\n }\n } else {\n setEditMode(false);\n }\n };\n\n return (\n <Button variant={variant} onClick={onSaveButtonClick} disabled={isDisabled || isSavingDashboard}>\n Save\n </Button>\n );\n};\n"],"names":["useState","Button","isRelativeTimeRange","useTimeRange","useDashboard","useEditMode","useSaveChangesConfirmationDialog","useVariableDefinitionActions","SaveDashboardButton","onSave","isDisabled","variant","isSavingDashboard","setSavingDashboard","dashboard","setDashboard","getSavedVariablesStatus","setVariableDefaultValues","isSavedVariableModified","timeRange","setEditMode","openSaveChangesConfirmationDialog","closeSaveChangesConfirmationDialog","onSaveButtonClick","isSavedDurationModified","spec","duration","pastDuration","onSaveChanges","saveDefaultTimeRange","saveDefaultVariables","variables","saveDashboard","onCancel","error","Error","onClick","disabled"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAAuBA,QAAQ,QAAQ,QAAQ;AAC/C,SAASC,MAAM,QAAqB,gBAAgB;AACpD,SAASC,mBAAmB,QAAQ,mBAAmB;AACvD,SAASC,YAAY,QAAQ,4BAA4B;AACzD,SAEEC,YAAY,EACZC,WAAW,EACXC,gCAAgC,EAChCC,4BAA4B,QACvB,gBAAgB;AAQvB,OAAO,MAAMC,sBAAsB,CAAC,EAClCC,MAAM,EACNC,UAAU,EACVC,UAAU,WAAW,EACI;IACzB,MAAM,CAACC,mBAAmBC,mBAAmB,GAAGb,SAAkB;IAClE,MAAM,EAAEc,SAAS,EAAEC,YAAY,EAAE,GAAGX;IACpC,MAAM,EAAEY,uBAAuB,EAAEC,wBAAwB,EAAE,GAAGV;IAC9D,MAAM,EAAEW,uBAAuB,EAAE,GAAGF;IACpC,MAAM,EAAEG,SAAS,EAAE,GAAGhB;IACtB,MAAM,EAAEiB,WAAW,EAAE,GAAGf;IACxB,MAAM,EAAEgB,iCAAiC,EAAEC,kCAAkC,EAAE,GAAGhB;IAElF,MAAMiB,oBAAoB;QACxB,MAAMC,0BACJtB,oBAAoBiB,cAAcL,UAAUW,IAAI,CAACC,QAAQ,KAAKP,UAAUQ,YAAY;QAEtF,iBAAiB;QACjB,0FAA0F;QAC1F,iEAAiE;QACjE,IAAIH,2BAA2BN,yBAAyB;YACtDG,kCAAkC;gBAChCO,eAAe,CAACC,sBAAsBC;oBACpC,IAAI5B,oBAAoBiB,cAAcU,yBAAyB,MAAM;wBACnEf,UAAUW,IAAI,CAACC,QAAQ,GAAGP,UAAUQ,YAAY;oBAClD;oBACA,IAAIG,yBAAyB,MAAM;wBACjC,MAAMC,YAAYd;wBAClBH,UAAUW,IAAI,CAACM,SAAS,GAAGA;oBAC7B;oBACAhB,aAAaD;oBACbkB;gBACF;gBACAC,UAAU;oBACRX;gBACF;gBACAE;gBACAN;YACF;QACF,OAAO;YACLc;QACF;IACF;IAEA,MAAMA,gBAAgB;QACpB,IAAIvB,QAAQ;YACV,IAAI;gBACFI,mBAAmB;gBACnB,MAAMJ,OAAOK;gBACbQ;gBACAF,YAAY;YACd,EAAE,OAAOc,OAAO;gBACd,MAAM,IAAIC,MAAM,CAAC,8CAA8C,EAAED,OAAO;YAC1E,SAAU;gBACRrB,mBAAmB;YACrB;QACF,OAAO;YACLO,YAAY;QACd;IACF;IAEA,qBACE,KAACnB;QAAOU,SAASA;QAASyB,SAASb;QAAmBc,UAAU3B,cAAcE;kBAAmB;;AAIrG,EAAE"}
1
+ {"version":3,"sources":["../../../src/components/SaveDashboardButton/SaveDashboardButton.tsx"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ReactElement, useState } from 'react';\nimport { Button, ButtonProps } from '@mui/material';\nimport { isRelativeTimeRange } from '@perses-dev/core';\nimport { useTimeRange } from '@perses-dev/plugin-system';\nimport {\n OnSaveDashboard,\n useDashboard,\n useEditMode,\n useSaveChangesConfirmationDialog,\n useVariableDefinitionActions,\n} from '../../context';\n\nexport interface SaveDashboardButtonProps extends Pick<ButtonProps, 'fullWidth'> {\n onSave?: OnSaveDashboard;\n isDisabled: boolean;\n variant?: 'contained' | 'text' | 'outlined';\n}\n\nexport const SaveDashboardButton = ({\n onSave,\n isDisabled,\n variant = 'contained',\n}: SaveDashboardButtonProps): ReactElement => {\n const [isSavingDashboard, setSavingDashboard] = useState<boolean>(false);\n const { dashboard, setDashboard } = useDashboard();\n const { getSavedVariablesStatus, setVariableDefaultValues } = useVariableDefinitionActions();\n const { isSavedVariableModified } = getSavedVariablesStatus();\n const { timeRange, refreshInterval } = useTimeRange();\n const { setEditMode } = useEditMode();\n const { openSaveChangesConfirmationDialog, closeSaveChangesConfirmationDialog } = useSaveChangesConfirmationDialog();\n\n const onSaveButtonClick = (): void => {\n const isSavedDurationModified =\n isRelativeTimeRange(timeRange) && dashboard.spec.duration !== timeRange.pastDuration;\n\n const isSavedRefreshIntervalModified = dashboard.spec.refreshInterval !== refreshInterval;\n\n // Save dashboard\n // - if active timeRange from plugin-system is relative and different from currently saved\n // - or if the saved variables are different from currently saved\n if (isSavedDurationModified || isSavedVariableModified || isSavedRefreshIntervalModified) {\n openSaveChangesConfirmationDialog({\n onSaveChanges: (saveDefaultTimeRange, saveDefaultRefreshInterval, saveDefaultVariables) => {\n if (isRelativeTimeRange(timeRange) && saveDefaultTimeRange) {\n dashboard.spec.duration = timeRange.pastDuration;\n }\n if (saveDefaultVariables) {\n const variables = setVariableDefaultValues();\n dashboard.spec.variables = variables;\n }\n if (saveDefaultRefreshInterval && isSavedRefreshIntervalModified) {\n dashboard.spec.refreshInterval = refreshInterval;\n }\n setDashboard(dashboard);\n saveDashboard();\n },\n onCancel: () => {\n closeSaveChangesConfirmationDialog();\n },\n isSavedDurationModified,\n isSavedVariableModified,\n isSavedRefreshIntervalModified,\n });\n } else {\n saveDashboard();\n }\n };\n\n const saveDashboard = async (): Promise<void> => {\n if (onSave) {\n try {\n setSavingDashboard(true);\n await onSave(dashboard);\n closeSaveChangesConfirmationDialog();\n setEditMode(false);\n } catch (error) {\n throw new Error(`An error occurred while saving the dashboard. ${error}`);\n } finally {\n setSavingDashboard(false);\n }\n } else {\n setEditMode(false);\n }\n };\n\n return (\n <Button variant={variant} onClick={onSaveButtonClick} disabled={isDisabled || isSavingDashboard}>\n Save\n </Button>\n );\n};\n"],"names":["useState","Button","isRelativeTimeRange","useTimeRange","useDashboard","useEditMode","useSaveChangesConfirmationDialog","useVariableDefinitionActions","SaveDashboardButton","onSave","isDisabled","variant","isSavingDashboard","setSavingDashboard","dashboard","setDashboard","getSavedVariablesStatus","setVariableDefaultValues","isSavedVariableModified","timeRange","refreshInterval","setEditMode","openSaveChangesConfirmationDialog","closeSaveChangesConfirmationDialog","onSaveButtonClick","isSavedDurationModified","spec","duration","pastDuration","isSavedRefreshIntervalModified","onSaveChanges","saveDefaultTimeRange","saveDefaultRefreshInterval","saveDefaultVariables","variables","saveDashboard","onCancel","error","Error","onClick","disabled"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAAuBA,QAAQ,QAAQ,QAAQ;AAC/C,SAASC,MAAM,QAAqB,gBAAgB;AACpD,SAASC,mBAAmB,QAAQ,mBAAmB;AACvD,SAASC,YAAY,QAAQ,4BAA4B;AACzD,SAEEC,YAAY,EACZC,WAAW,EACXC,gCAAgC,EAChCC,4BAA4B,QACvB,gBAAgB;AAQvB,OAAO,MAAMC,sBAAsB,CAAC,EAClCC,MAAM,EACNC,UAAU,EACVC,UAAU,WAAW,EACI;IACzB,MAAM,CAACC,mBAAmBC,mBAAmB,GAAGb,SAAkB;IAClE,MAAM,EAAEc,SAAS,EAAEC,YAAY,EAAE,GAAGX;IACpC,MAAM,EAAEY,uBAAuB,EAAEC,wBAAwB,EAAE,GAAGV;IAC9D,MAAM,EAAEW,uBAAuB,EAAE,GAAGF;IACpC,MAAM,EAAEG,SAAS,EAAEC,eAAe,EAAE,GAAGjB;IACvC,MAAM,EAAEkB,WAAW,EAAE,GAAGhB;IACxB,MAAM,EAAEiB,iCAAiC,EAAEC,kCAAkC,EAAE,GAAGjB;IAElF,MAAMkB,oBAAoB;QACxB,MAAMC,0BACJvB,oBAAoBiB,cAAcL,UAAUY,IAAI,CAACC,QAAQ,KAAKR,UAAUS,YAAY;QAEtF,MAAMC,iCAAiCf,UAAUY,IAAI,CAACN,eAAe,KAAKA;QAE1E,iBAAiB;QACjB,0FAA0F;QAC1F,iEAAiE;QACjE,IAAIK,2BAA2BP,2BAA2BW,gCAAgC;YACxFP,kCAAkC;gBAChCQ,eAAe,CAACC,sBAAsBC,4BAA4BC;oBAChE,IAAI/B,oBAAoBiB,cAAcY,sBAAsB;wBAC1DjB,UAAUY,IAAI,CAACC,QAAQ,GAAGR,UAAUS,YAAY;oBAClD;oBACA,IAAIK,sBAAsB;wBACxB,MAAMC,YAAYjB;wBAClBH,UAAUY,IAAI,CAACQ,SAAS,GAAGA;oBAC7B;oBACA,IAAIF,8BAA8BH,gCAAgC;wBAChEf,UAAUY,IAAI,CAACN,eAAe,GAAGA;oBACnC;oBACAL,aAAaD;oBACbqB;gBACF;gBACAC,UAAU;oBACRb;gBACF;gBACAE;gBACAP;gBACAW;YACF;QACF,OAAO;YACLM;QACF;IACF;IAEA,MAAMA,gBAAgB;QACpB,IAAI1B,QAAQ;YACV,IAAI;gBACFI,mBAAmB;gBACnB,MAAMJ,OAAOK;gBACbS;gBACAF,YAAY;YACd,EAAE,OAAOgB,OAAO;gBACd,MAAM,IAAIC,MAAM,CAAC,8CAA8C,EAAED,OAAO;YAC1E,SAAU;gBACRxB,mBAAmB;YACrB;QACF,OAAO;YACLQ,YAAY;QACd;IACF;IAEA,qBACE,KAACpB;QAAOU,SAASA;QAAS4B,SAASf;QAAmBgB,UAAU9B,cAAcE;kBAAmB;;AAIrG,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"file":"EditVariablesButton.d.ts","sourceRoot":"","sources":["../../../src/components/Variables/EditVariablesButton.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAY,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAU,WAAW,EAAE,MAAM,eAAe,CAAC;AAcpD,MAAM,WAAW,wBAAyB,SAAQ,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC;IAC9E;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAE9B;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC;IAEhC;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,mBAAmB,CAAC,EAClC,OAAgB,EAChB,KAAmB,EACnB,KAAiB,EACjB,SAAS,GACV,EAAE,wBAAwB,GAAG,YAAY,CAiDzC"}
1
+ {"version":3,"file":"EditVariablesButton.d.ts","sourceRoot":"","sources":["../../../src/components/Variables/EditVariablesButton.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAY,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAU,WAAW,EAAE,MAAM,eAAe,CAAC;AASpD,MAAM,WAAW,wBAAyB,SAAQ,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC;IAC9E;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAE9B;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC;IAEhC;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,mBAAmB,CAAC,EAClC,OAAgB,EAChB,KAAmB,EACnB,KAAiB,EACjB,SAAS,GACV,EAAE,wBAAwB,GAAG,YAAY,CAiDzC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Variables/EditVariablesButton.tsx"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { 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 { BuiltinVariableDefinition, VariableDefinition } from '@perses-dev/core';\nimport { useBuiltinVariableDefinitions } from '@perses-dev/plugin-system';\nimport { TOOLTIP_TEXT, editButtonStyle } from '../../constants';\nimport {\n ExternalVariableDefinition,\n useExternalVariableDefinitions,\n useVariableDefinitionActions,\n useVariableDefinitions,\n} from '../../context';\nimport { VariableEditor } from './VariableEditor';\n\nexport interface EditVariablesButtonProps 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 EditVariablesButton({\n variant = 'text',\n label = 'Variables',\n color = 'primary',\n fullWidth,\n}: EditVariablesButtonProps): ReactElement {\n const [isVariableEditorOpen, setIsVariableEditorOpen] = useState(false);\n const variableDefinitions: VariableDefinition[] = useVariableDefinitions();\n const externalVariableDefinitions: ExternalVariableDefinition[] = useExternalVariableDefinitions();\n const builtinVariableDefinitions: BuiltinVariableDefinition[] = useBuiltinVariableDefinitions();\n const { setVariableDefinitions } = useVariableDefinitionActions();\n\n const openVariableEditor = (): void => {\n setIsVariableEditorOpen(true);\n };\n\n const closeVariableEditor = (): void => {\n setIsVariableEditorOpen(false);\n };\n\n return (\n <>\n <InfoTooltip description={TOOLTIP_TEXT.editVariables}>\n <Button\n startIcon={<PencilIcon />}\n onClick={openVariableEditor}\n aria-label={TOOLTIP_TEXT.editVariables}\n variant={variant}\n color={color}\n fullWidth={fullWidth}\n sx={editButtonStyle}\n >\n {label}\n </Button>\n </InfoTooltip>\n <Drawer\n isOpen={isVariableEditorOpen}\n onClose={closeVariableEditor}\n PaperProps={{ sx: { width: '50%' } }}\n data-testid=\"variable-editor\"\n >\n <VariableEditor\n variableDefinitions={variableDefinitions}\n externalVariableDefinitions={externalVariableDefinitions}\n builtinVariableDefinitions={builtinVariableDefinitions}\n onCancel={closeVariableEditor}\n onChange={(variables: VariableDefinition[]) => {\n setVariableDefinitions(variables);\n setIsVariableEditorOpen(false);\n }}\n />\n </Drawer>\n </>\n );\n}\n"],"names":["useState","Button","PencilIcon","Drawer","InfoTooltip","useBuiltinVariableDefinitions","TOOLTIP_TEXT","editButtonStyle","useExternalVariableDefinitions","useVariableDefinitionActions","useVariableDefinitions","VariableEditor","EditVariablesButton","variant","label","color","fullWidth","isVariableEditorOpen","setIsVariableEditorOpen","variableDefinitions","externalVariableDefinitions","builtinVariableDefinitions","setVariableDefinitions","openVariableEditor","closeVariableEditor","description","editVariables","startIcon","onClick","aria-label","sx","isOpen","onClose","PaperProps","width","data-testid","onCancel","onChange","variables"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAAuBA,QAAQ,QAAQ,QAAQ;AAC/C,SAASC,MAAM,QAAqB,gBAAgB;AACpD,OAAOC,gBAAgB,gCAAgC;AACvD,SAASC,MAAM,EAAEC,WAAW,QAAQ,yBAAyB;AAE7D,SAASC,6BAA6B,QAAQ,4BAA4B;AAC1E,SAASC,YAAY,EAAEC,eAAe,QAAQ,kBAAkB;AAChE,SAEEC,8BAA8B,EAC9BC,4BAA4B,EAC5BC,sBAAsB,QACjB,gBAAgB;AACvB,SAASC,cAAc,QAAQ,mBAAmB;AAmBlD,OAAO,SAASC,oBAAoB,EAClCC,UAAU,MAAM,EAChBC,QAAQ,WAAW,EACnBC,QAAQ,SAAS,EACjBC,SAAS,EACgB;IACzB,MAAM,CAACC,sBAAsBC,wBAAwB,GAAGlB,SAAS;IACjE,MAAMmB,sBAA4CT;IAClD,MAAMU,8BAA4DZ;IAClE,MAAMa,6BAA0DhB;IAChE,MAAM,EAAEiB,sBAAsB,EAAE,GAAGb;IAEnC,MAAMc,qBAAqB;QACzBL,wBAAwB;IAC1B;IAEA,MAAMM,sBAAsB;QAC1BN,wBAAwB;IAC1B;IAEA,qBACE;;0BACE,KAACd;gBAAYqB,aAAanB,aAAaoB,aAAa;0BAClD,cAAA,KAACzB;oBACC0B,yBAAW,KAACzB;oBACZ0B,SAASL;oBACTM,cAAYvB,aAAaoB,aAAa;oBACtCb,SAASA;oBACTE,OAAOA;oBACPC,WAAWA;oBACXc,IAAIvB;8BAEHO;;;0BAGL,KAACX;gBACC4B,QAAQd;gBACRe,SAASR;gBACTS,YAAY;oBAAEH,IAAI;wBAAEI,OAAO;oBAAM;gBAAE;gBACnCC,eAAY;0BAEZ,cAAA,KAACxB;oBACCQ,qBAAqBA;oBACrBC,6BAA6BA;oBAC7BC,4BAA4BA;oBAC5Be,UAAUZ;oBACVa,UAAU,CAACC;wBACThB,uBAAuBgB;wBACvBpB,wBAAwB;oBAC1B;;;;;AAKV"}
1
+ {"version":3,"sources":["../../../src/components/Variables/EditVariablesButton.tsx"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { 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 { BuiltinVariableDefinition, VariableDefinition, ExternalVariableDefinition } from '@perses-dev/core';\nimport { useBuiltinVariableDefinitions } from '@perses-dev/plugin-system';\nimport { TOOLTIP_TEXT, editButtonStyle } from '../../constants';\nimport { useExternalVariableDefinitions, useVariableDefinitionActions, useVariableDefinitions } from '../../context';\nimport { VariableEditor } from './VariableEditor';\n\nexport interface EditVariablesButtonProps 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 EditVariablesButton({\n variant = 'text',\n label = 'Variables',\n color = 'primary',\n fullWidth,\n}: EditVariablesButtonProps): ReactElement {\n const [isVariableEditorOpen, setIsVariableEditorOpen] = useState(false);\n const variableDefinitions: VariableDefinition[] = useVariableDefinitions();\n const externalVariableDefinitions: ExternalVariableDefinition[] = useExternalVariableDefinitions();\n const builtinVariableDefinitions: BuiltinVariableDefinition[] = useBuiltinVariableDefinitions();\n const { setVariableDefinitions } = useVariableDefinitionActions();\n\n const openVariableEditor = (): void => {\n setIsVariableEditorOpen(true);\n };\n\n const closeVariableEditor = (): void => {\n setIsVariableEditorOpen(false);\n };\n\n return (\n <>\n <InfoTooltip description={TOOLTIP_TEXT.editVariables}>\n <Button\n startIcon={<PencilIcon />}\n onClick={openVariableEditor}\n aria-label={TOOLTIP_TEXT.editVariables}\n variant={variant}\n color={color}\n fullWidth={fullWidth}\n sx={editButtonStyle}\n >\n {label}\n </Button>\n </InfoTooltip>\n <Drawer\n isOpen={isVariableEditorOpen}\n onClose={closeVariableEditor}\n PaperProps={{ sx: { width: '50%' } }}\n data-testid=\"variable-editor\"\n >\n <VariableEditor\n variableDefinitions={variableDefinitions}\n externalVariableDefinitions={externalVariableDefinitions}\n builtinVariableDefinitions={builtinVariableDefinitions}\n onCancel={closeVariableEditor}\n onChange={(variables: VariableDefinition[]) => {\n setVariableDefinitions(variables);\n setIsVariableEditorOpen(false);\n }}\n />\n </Drawer>\n </>\n );\n}\n"],"names":["useState","Button","PencilIcon","Drawer","InfoTooltip","useBuiltinVariableDefinitions","TOOLTIP_TEXT","editButtonStyle","useExternalVariableDefinitions","useVariableDefinitionActions","useVariableDefinitions","VariableEditor","EditVariablesButton","variant","label","color","fullWidth","isVariableEditorOpen","setIsVariableEditorOpen","variableDefinitions","externalVariableDefinitions","builtinVariableDefinitions","setVariableDefinitions","openVariableEditor","closeVariableEditor","description","editVariables","startIcon","onClick","aria-label","sx","isOpen","onClose","PaperProps","width","data-testid","onCancel","onChange","variables"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAAuBA,QAAQ,QAAQ,QAAQ;AAC/C,SAASC,MAAM,QAAqB,gBAAgB;AACpD,OAAOC,gBAAgB,gCAAgC;AACvD,SAASC,MAAM,EAAEC,WAAW,QAAQ,yBAAyB;AAE7D,SAASC,6BAA6B,QAAQ,4BAA4B;AAC1E,SAASC,YAAY,EAAEC,eAAe,QAAQ,kBAAkB;AAChE,SAASC,8BAA8B,EAAEC,4BAA4B,EAAEC,sBAAsB,QAAQ,gBAAgB;AACrH,SAASC,cAAc,QAAQ,mBAAmB;AAmBlD,OAAO,SAASC,oBAAoB,EAClCC,UAAU,MAAM,EAChBC,QAAQ,WAAW,EACnBC,QAAQ,SAAS,EACjBC,SAAS,EACgB;IACzB,MAAM,CAACC,sBAAsBC,wBAAwB,GAAGlB,SAAS;IACjE,MAAMmB,sBAA4CT;IAClD,MAAMU,8BAA4DZ;IAClE,MAAMa,6BAA0DhB;IAChE,MAAM,EAAEiB,sBAAsB,EAAE,GAAGb;IAEnC,MAAMc,qBAAqB;QACzBL,wBAAwB;IAC1B;IAEA,MAAMM,sBAAsB;QAC1BN,wBAAwB;IAC1B;IAEA,qBACE;;0BACE,KAACd;gBAAYqB,aAAanB,aAAaoB,aAAa;0BAClD,cAAA,KAACzB;oBACC0B,yBAAW,KAACzB;oBACZ0B,SAASL;oBACTM,cAAYvB,aAAaoB,aAAa;oBACtCb,SAASA;oBACTE,OAAOA;oBACPC,WAAWA;oBACXc,IAAIvB;8BAEHO;;;0BAGL,KAACX;gBACC4B,QAAQd;gBACRe,SAASR;gBACTS,YAAY;oBAAEH,IAAI;wBAAEI,OAAO;oBAAM;gBAAE;gBACnCC,eAAY;0BAEZ,cAAA,KAACxB;oBACCQ,qBAAqBA;oBACrBC,6BAA6BA;oBAC7BC,4BAA4BA;oBAC5Be,UAAUZ;oBACVa,UAAU,CAACC;wBACThB,uBAAuBgB;wBACvBpB,wBAAwB;oBAC1B;;;;;AAKV"}
@@ -0,0 +1,16 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { VariableOption } from '@perses-dev/plugin-system';
3
+ export interface ListVariableListBoxContextValue {
4
+ options: VariableOption[];
5
+ selectedOptions: VariableOption[];
6
+ filteredOptions: VariableOption[];
7
+ allowAllValue: boolean;
8
+ onChange: (selectedOptions: VariableOption[]) => void;
9
+ }
10
+ export declare function useListVariableListBoxContext(): ListVariableListBoxContextValue;
11
+ export declare function ListVariableListBoxProvider({ value, children, }: {
12
+ value: ListVariableListBoxContextValue;
13
+ children: ReactNode;
14
+ }): React.ReactElement;
15
+ export declare const ListVariableListBox: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLUListElement> & React.RefAttributes<HTMLUListElement>>;
16
+ //# sourceMappingURL=ListVariableListBox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ListVariableListBox.d.ts","sourceRoot":"","sources":["../../../src/components/Variables/ListVariableListBox.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,EAAgC,SAAS,EAAmC,MAAM,OAAO,CAAC;AAExG,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAG3D,MAAM,WAAW,+BAA+B;IAC9C,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,aAAa,EAAE,OAAO,CAAC;IACvB,QAAQ,EAAE,CAAC,eAAe,EAAE,cAAc,EAAE,KAAK,IAAI,CAAC;CACvD;AAID,wBAAgB,6BAA6B,IAAI,+BAA+B,CAI/E;AAmED,wBAAgB,2BAA2B,CAAC,EAC1C,KAAK,EACL,QAAQ,GACT,EAAE;IACD,KAAK,EAAE,+BAA+B,CAAC;IACvC,QAAQ,EAAE,SAAS,CAAC;CACrB,GAAG,KAAK,CAAC,YAAY,CAErB;AAED,eAAO,MAAM,mBAAmB,iHA0C9B,CAAC"}