@perses-dev/dashboards 0.0.0-snapshot-color-palette-gen-test-0ebddd6 → 0.0.0-snapshot-saving-defaults-refinements-1b25cec

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 (212) hide show
  1. package/dist/cjs/components/DashboardStickyToolbar/DashboardStickyToolbar.js +79 -0
  2. package/dist/cjs/{stories/decorators/WithQueryParams.js → components/DashboardStickyToolbar/index.js} +11 -12
  3. package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +8 -24
  4. package/dist/cjs/components/EditJsonButton/EditJsonButton.js +1 -0
  5. package/dist/cjs/components/EditJsonDialog/EditJsonDialog.js +5 -0
  6. package/dist/cjs/components/GridLayout/GridItemContent.js +22 -4
  7. package/dist/cjs/components/GridLayout/GridLayout.js +31 -2
  8. package/dist/cjs/components/GridLayout/GridTitle.js +30 -9
  9. package/dist/cjs/components/Panel/Panel.js +2 -2
  10. package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +41 -34
  11. package/dist/cjs/components/PanelDrawer/PanelPreview.js +32 -18
  12. package/dist/cjs/components/PanelDrawer/usePanelEditor.js +87 -0
  13. package/dist/cjs/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +92 -0
  14. package/dist/cjs/components/SaveChangesConfirmationDialog/index.js +28 -0
  15. package/dist/cjs/components/SaveDashboardButton/SaveDashboardButton.js +81 -0
  16. package/dist/cjs/components/SaveDashboardButton/index.js +28 -0
  17. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +5 -5
  18. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +124 -198
  19. package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +178 -0
  20. package/dist/cjs/components/Variables/VariableEditorForm/index.js +1 -0
  21. package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +7 -8
  22. package/dist/cjs/components/Variables/VariableList.js +16 -55
  23. package/dist/cjs/components/Variables/index.js +1 -0
  24. package/dist/cjs/components/index.js +3 -0
  25. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +9 -8
  26. package/dist/cjs/context/DashboardProvider/common.js +26 -6
  27. package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +13 -4
  28. package/dist/cjs/context/DashboardProvider/index.js +1 -0
  29. package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +8 -32
  30. package/dist/cjs/context/DashboardProvider/save-changes-dialog-slice.js +33 -0
  31. package/dist/cjs/context/TemplateVariableProvider/TemplateVariableProvider.js +56 -7
  32. package/dist/cjs/context/TemplateVariableProvider/hydrationUtils.js +2 -0
  33. package/dist/cjs/context/TemplateVariableProvider/utils.js +44 -0
  34. package/dist/cjs/context/useDashboard.js +4 -4
  35. package/dist/cjs/stories/decorators/WithDatasourceStore.js +2 -47
  36. package/dist/cjs/stories/decorators/index.js +0 -4
  37. package/dist/cjs/test/datasource-provider.js +70 -0
  38. package/dist/cjs/test/index.js +1 -0
  39. package/dist/cjs/test/plugin-registry.js +11 -5
  40. package/dist/cjs/test/render.js +35 -13
  41. package/dist/cjs/test/testDashboard.js +79 -79
  42. package/dist/cjs/utils/index.js +1 -0
  43. package/dist/cjs/{stories/decorators/WithQueryClient.js → utils/time.js} +9 -11
  44. package/dist/cjs/views/ViewDashboard/DashboardApp.js +2 -1
  45. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.d.ts +9 -0
  46. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.d.ts.map +1 -0
  47. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js +68 -0
  48. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js.map +1 -0
  49. package/dist/components/DashboardStickyToolbar/index.d.ts +2 -0
  50. package/dist/components/DashboardStickyToolbar/index.d.ts.map +1 -0
  51. package/dist/{stories/decorators/WithQueryClient.js → components/DashboardStickyToolbar/index.js} +2 -10
  52. package/dist/components/DashboardStickyToolbar/index.js.map +1 -0
  53. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts +2 -2
  54. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
  55. package/dist/components/DashboardToolbar/DashboardToolbar.js +10 -26
  56. package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
  57. package/dist/components/EditJsonButton/EditJsonButton.js +1 -0
  58. package/dist/components/EditJsonButton/EditJsonButton.js.map +1 -1
  59. package/dist/components/EditJsonDialog/EditJsonDialog.d.ts.map +1 -1
  60. package/dist/components/EditJsonDialog/EditJsonDialog.js +5 -0
  61. package/dist/components/EditJsonDialog/EditJsonDialog.js.map +1 -1
  62. package/dist/components/GridLayout/GridItemContent.d.ts +1 -0
  63. package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
  64. package/dist/components/GridLayout/GridItemContent.js +22 -4
  65. package/dist/components/GridLayout/GridItemContent.js.map +1 -1
  66. package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
  67. package/dist/components/GridLayout/GridLayout.js +31 -2
  68. package/dist/components/GridLayout/GridLayout.js.map +1 -1
  69. package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
  70. package/dist/components/GridLayout/GridTitle.js +30 -9
  71. package/dist/components/GridLayout/GridTitle.js.map +1 -1
  72. package/dist/components/Panel/Panel.d.ts +1 -1
  73. package/dist/components/Panel/Panel.d.ts.map +1 -1
  74. package/dist/components/Panel/Panel.js +3 -3
  75. package/dist/components/Panel/Panel.js.map +1 -1
  76. package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
  77. package/dist/components/PanelDrawer/PanelEditorForm.js +42 -35
  78. package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
  79. package/dist/components/PanelDrawer/PanelPreview.d.ts +1 -1
  80. package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -1
  81. package/dist/components/PanelDrawer/PanelPreview.js +32 -18
  82. package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
  83. package/dist/components/PanelDrawer/usePanelEditor.d.ts +15 -0
  84. package/dist/components/PanelDrawer/usePanelEditor.d.ts.map +1 -0
  85. package/dist/components/PanelDrawer/usePanelEditor.js +84 -0
  86. package/dist/components/PanelDrawer/usePanelEditor.js.map +1 -0
  87. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.d.ts +3 -0
  88. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.d.ts.map +1 -0
  89. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +86 -0
  90. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +1 -0
  91. package/dist/components/SaveChangesConfirmationDialog/index.d.ts +2 -0
  92. package/dist/components/SaveChangesConfirmationDialog/index.d.ts.map +1 -0
  93. package/dist/{stories/decorators/WithQueryParams.js → components/SaveChangesConfirmationDialog/index.js} +2 -10
  94. package/dist/components/SaveChangesConfirmationDialog/index.js.map +1 -0
  95. package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts +10 -0
  96. package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts.map +1 -0
  97. package/dist/components/SaveDashboardButton/SaveDashboardButton.js +75 -0
  98. package/dist/components/SaveDashboardButton/SaveDashboardButton.js.map +1 -0
  99. package/dist/components/SaveDashboardButton/index.d.ts +2 -0
  100. package/dist/components/SaveDashboardButton/index.d.ts.map +1 -0
  101. package/dist/components/SaveDashboardButton/index.js +15 -0
  102. package/dist/components/SaveDashboardButton/index.js.map +1 -0
  103. package/dist/components/TimeRangeControls/TimeRangeControls.js +6 -6
  104. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
  105. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +4 -2
  106. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
  107. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +127 -196
  108. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  109. package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts +16 -0
  110. package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts.map +1 -0
  111. package/dist/components/Variables/VariableEditorForm/VariablePreview.js +122 -0
  112. package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -0
  113. package/dist/components/Variables/VariableEditorForm/index.d.ts +1 -0
  114. package/dist/components/Variables/VariableEditorForm/index.d.ts.map +1 -1
  115. package/dist/components/Variables/VariableEditorForm/index.js +1 -0
  116. package/dist/components/Variables/VariableEditorForm/index.js.map +1 -1
  117. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -1
  118. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +7 -8
  119. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
  120. package/dist/components/Variables/VariableList.d.ts +1 -7
  121. package/dist/components/Variables/VariableList.d.ts.map +1 -1
  122. package/dist/components/Variables/VariableList.js +18 -52
  123. package/dist/components/Variables/VariableList.js.map +1 -1
  124. package/dist/components/Variables/index.d.ts +1 -0
  125. package/dist/components/Variables/index.d.ts.map +1 -1
  126. package/dist/components/Variables/index.js +1 -0
  127. package/dist/components/Variables/index.js.map +1 -1
  128. package/dist/components/index.d.ts +3 -0
  129. package/dist/components/index.d.ts.map +1 -1
  130. package/dist/components/index.js +3 -0
  131. package/dist/components/index.js.map +1 -1
  132. package/dist/context/DashboardProvider/DashboardProvider.d.ts +4 -3
  133. package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
  134. package/dist/context/DashboardProvider/DashboardProvider.js +9 -8
  135. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
  136. package/dist/context/DashboardProvider/common.d.ts +3 -0
  137. package/dist/context/DashboardProvider/common.d.ts.map +1 -1
  138. package/dist/context/DashboardProvider/common.js +17 -2
  139. package/dist/context/DashboardProvider/common.js.map +1 -1
  140. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +6 -1
  141. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
  142. package/dist/context/DashboardProvider/dashboard-provider-api.js +11 -3
  143. package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
  144. package/dist/context/DashboardProvider/index.d.ts +1 -0
  145. package/dist/context/DashboardProvider/index.d.ts.map +1 -1
  146. package/dist/context/DashboardProvider/index.js +1 -0
  147. package/dist/context/DashboardProvider/index.js.map +1 -1
  148. package/dist/context/DashboardProvider/panel-editor-slice.d.ts +3 -6
  149. package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
  150. package/dist/context/DashboardProvider/panel-editor-slice.js +9 -33
  151. package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
  152. package/dist/context/DashboardProvider/save-changes-dialog-slice.d.ts +15 -0
  153. package/dist/context/DashboardProvider/save-changes-dialog-slice.d.ts.map +1 -0
  154. package/dist/context/DashboardProvider/save-changes-dialog-slice.js +27 -0
  155. package/dist/context/DashboardProvider/save-changes-dialog-slice.js.map +1 -0
  156. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts +10 -0
  157. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts.map +1 -1
  158. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js +51 -7
  159. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js.map +1 -1
  160. package/dist/context/TemplateVariableProvider/hydrationUtils.d.ts.map +1 -1
  161. package/dist/context/TemplateVariableProvider/hydrationUtils.js +2 -0
  162. package/dist/context/TemplateVariableProvider/hydrationUtils.js.map +1 -1
  163. package/dist/context/TemplateVariableProvider/utils.d.ts +7 -0
  164. package/dist/context/TemplateVariableProvider/utils.d.ts.map +1 -0
  165. package/dist/context/TemplateVariableProvider/utils.js +40 -0
  166. package/dist/context/TemplateVariableProvider/utils.js.map +1 -0
  167. package/dist/context/useDashboard.d.ts.map +1 -1
  168. package/dist/context/useDashboard.js +4 -4
  169. package/dist/context/useDashboard.js.map +1 -1
  170. package/dist/stories/decorators/WithDashboard.js.map +1 -1
  171. package/dist/stories/decorators/WithDatasourceStore.js +1 -46
  172. package/dist/stories/decorators/WithDatasourceStore.js.map +1 -1
  173. package/dist/stories/decorators/WithTemplateVariables.js.map +1 -1
  174. package/dist/stories/decorators/index.js +0 -4
  175. package/dist/stories/decorators/index.js.map +1 -1
  176. package/dist/test/datasource-provider.d.ts +6 -0
  177. package/dist/test/datasource-provider.d.ts.map +1 -0
  178. package/dist/test/datasource-provider.js +60 -0
  179. package/dist/test/datasource-provider.js.map +1 -0
  180. package/dist/test/index.d.ts +1 -0
  181. package/dist/test/index.d.ts.map +1 -1
  182. package/dist/test/index.js +1 -0
  183. package/dist/test/index.js.map +1 -1
  184. package/dist/test/plugin-registry.d.ts.map +1 -1
  185. package/dist/test/plugin-registry.js +11 -5
  186. package/dist/test/plugin-registry.js.map +1 -1
  187. package/dist/test/render.d.ts.map +1 -1
  188. package/dist/test/render.js +35 -13
  189. package/dist/test/render.js.map +1 -1
  190. package/dist/test/testDashboard.js +79 -79
  191. package/dist/test/testDashboard.js.map +1 -1
  192. package/dist/utils/index.d.ts +1 -0
  193. package/dist/utils/index.d.ts.map +1 -1
  194. package/dist/utils/index.js +1 -0
  195. package/dist/utils/index.js.map +1 -1
  196. package/dist/utils/time.d.ts +5 -0
  197. package/dist/utils/time.d.ts.map +1 -0
  198. package/dist/utils/time.js +23 -0
  199. package/dist/utils/time.js.map +1 -0
  200. package/dist/views/ViewDashboard/DashboardApp.d.ts +2 -1
  201. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
  202. package/dist/views/ViewDashboard/DashboardApp.js +3 -2
  203. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  204. package/package.json +7 -6
  205. package/dist/cjs/stories/decorators/WithPluginRegistry.js +0 -91
  206. package/dist/cjs/stories/decorators/WithTimeRange.js +0 -38
  207. package/dist/stories/decorators/WithPluginRegistry.js +0 -46
  208. package/dist/stories/decorators/WithPluginRegistry.js.map +0 -1
  209. package/dist/stories/decorators/WithQueryClient.js.map +0 -1
  210. package/dist/stories/decorators/WithQueryParams.js.map +0 -1
  211. package/dist/stories/decorators/WithTimeRange.js +0 -32
  212. package/dist/stories/decorators/WithTimeRange.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.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 { useState } from 'react';\nimport { Checkbox, FormGroup, FormControlLabel, Typography } from '@mui/material';\nimport { useTimeRange } from '@perses-dev/plugin-system';\nimport { isRelativeTimeRange, SAVE_DEFAULTS_DIALOG_TEXT } from '@perses-dev/core';\nimport { Dialog } from '@perses-dev/components';\nimport { useSaveChangesConfirmationDialog, useTemplateVariableActions } from '../../context';\n\nexport const SaveChangesConfirmationDialog = () => {\n const [saveDefaultTimeRange, setSaveDefaultTimeRange] = useState(true);\n const [saveDefaultVariables, setSaveDefaultVariables] = useState(true);\n\n const { getSavedVariablesStatus } = useTemplateVariableActions();\n const { isSavedVariableModified, modifiedVariableNames } = getSavedVariablesStatus();\n\n const { saveChangesConfirmationDialog: dialog } = useSaveChangesConfirmationDialog();\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={!isRelativeTimeRange(timeRange)}\n checked={saveDefaultTimeRange && 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","SAVE_DEFAULTS_DIALOG_TEXT","Dialog","useSaveChangesConfirmationDialog","useTemplateVariableActions","SaveChangesConfirmationDialog","saveDefaultTimeRange","setSaveDefaultTimeRange","saveDefaultVariables","setSaveDefaultVariables","getSavedVariablesStatus","isSavedVariableModified","modifiedVariableNames","saveChangesConfirmationDialog","dialog","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,kEA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AAa;4BACnBC,OAAO,EAAE,IAAM;gCACb,OAAO1B,MAAM,CAAC2B,aAAa,CAACnC,oBAAoB,EAAEE,oBAAoB,CAAC,CAAC;4BAC1E,CAAC;sCACF,cAED;0BAAuB;sCACvB,KAACN,MAAM,CAACwC,eAAe;4BAACF,OAAO,EAAE,IAAM1B,MAAM,CAACa,QAAQ,EAAE;sCAAE,QAAM;0BAAyB;;kBAC1E;;UAChB,AACJ;MACM,CACT;AACJ,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './SaveChangesConfirmationDialog';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/SaveChangesConfirmationDialog/index.ts"],"names":[],"mappings":"AAaA,cAAc,iCAAiC,CAAC"}
@@ -10,14 +10,6 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- import { jsx as _jsx } from "react/jsx-runtime";
14
- import { WindowHistoryAdapter } from 'use-query-params/adapters/window';
15
- import { QueryParamProvider } from 'use-query-params';
16
- export const WithQueryParams = (Story)=>{
17
- return /*#__PURE__*/ _jsx(QueryParamProvider, {
18
- adapter: WindowHistoryAdapter,
19
- children: /*#__PURE__*/ _jsx(Story, {})
20
- });
21
- };
13
+ export * from './SaveChangesConfirmationDialog';
22
14
 
23
- //# sourceMappingURL=WithQueryParams.js.map
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/SaveChangesConfirmationDialog/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './SaveChangesConfirmationDialog';\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,iCAAiC,CAAC"}
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import { ButtonProps } from '@mui/material';
3
+ import { OnSaveDashboard } from '../../context';
4
+ export interface SaveDashboardButtonProps extends Pick<ButtonProps, 'fullWidth'> {
5
+ onSave?: OnSaveDashboard;
6
+ isDisabled: boolean;
7
+ variant?: 'contained' | 'text' | 'outlined';
8
+ }
9
+ export declare const SaveDashboardButton: ({ onSave, isDisabled, variant }: SaveDashboardButtonProps) => JSX.Element;
10
+ //# sourceMappingURL=SaveDashboardButton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SaveDashboardButton.d.ts","sourceRoot":"","sources":["../../../src/components/SaveDashboardButton/SaveDashboardButton.tsx"],"names":[],"mappings":";AAcA,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,oCAAmD,wBAAwB,gBA0D1G,CAAC"}
@@ -0,0 +1,75 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { useState } from 'react';
15
+ import { Button } from '@mui/material';
16
+ import { isRelativeTimeRange } from '@perses-dev/core';
17
+ import { useTimeRange } from '@perses-dev/plugin-system';
18
+ import { useDashboard, useEditMode, useSaveChangesConfirmationDialog, useTemplateVariableActions } from '../../context';
19
+ export const SaveDashboardButton = ({ onSave , isDisabled , variant ='contained' })=>{
20
+ const [isSavingDashboard, setSavingDashboard] = useState(false);
21
+ const { dashboard , setDashboard } = useDashboard();
22
+ const { getSavedVariablesStatus , setVariableDefaultValues } = useTemplateVariableActions();
23
+ const { isSavedVariableModified } = getSavedVariablesStatus();
24
+ const { timeRange } = useTimeRange();
25
+ const { setEditMode } = useEditMode();
26
+ const { openSaveChangesConfirmationDialog , closeSaveChangesConfirmationDialog } = useSaveChangesConfirmationDialog();
27
+ const onSaveButtonClick = ()=>{
28
+ const isSavedDurationModified = isRelativeTimeRange(timeRange) && dashboard.spec.duration !== timeRange.pastDuration;
29
+ // Save dashboard if active timeRange from plugin-system is relative and different than currently saved
30
+ if (isSavedDurationModified || isSavedVariableModified) {
31
+ openSaveChangesConfirmationDialog({
32
+ onSaveChanges: (saveDefaultTimeRange, saveDefaultVariables)=>{
33
+ if (isRelativeTimeRange(timeRange) && saveDefaultTimeRange === true) {
34
+ dashboard.spec.duration = timeRange.pastDuration;
35
+ }
36
+ if (saveDefaultVariables === true) {
37
+ const variables = setVariableDefaultValues();
38
+ dashboard.spec.variables = variables;
39
+ }
40
+ saveDashboard();
41
+ },
42
+ onCancel: ()=>{
43
+ closeSaveChangesConfirmationDialog();
44
+ }
45
+ });
46
+ } else {
47
+ saveDashboard();
48
+ }
49
+ };
50
+ const saveDashboard = async ()=>{
51
+ if (onSave) {
52
+ try {
53
+ setSavingDashboard(true);
54
+ await onSave(dashboard);
55
+ closeSaveChangesConfirmationDialog();
56
+ setEditMode(false);
57
+ setDashboard(dashboard);
58
+ } catch (error) {
59
+ throw new Error(`An error occurred while saving the dashboard. ${error}`);
60
+ } finally{
61
+ setSavingDashboard(false);
62
+ }
63
+ } else {
64
+ setEditMode(false);
65
+ }
66
+ };
67
+ return /*#__PURE__*/ _jsx(Button, {
68
+ variant: variant,
69
+ onClick: onSaveButtonClick,
70
+ disabled: isDisabled || isSavingDashboard,
71
+ children: "Save"
72
+ });
73
+ };
74
+
75
+ //# sourceMappingURL=SaveDashboardButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/SaveDashboardButton/SaveDashboardButton.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 { 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 useTemplateVariableActions,\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 = ({ onSave, isDisabled, variant = 'contained' }: SaveDashboardButtonProps) => {\n const [isSavingDashboard, setSavingDashboard] = useState<boolean>(false);\n const { dashboard, setDashboard } = useDashboard();\n const { getSavedVariablesStatus, setVariableDefaultValues } = useTemplateVariableActions();\n const { isSavedVariableModified } = getSavedVariablesStatus();\n const { timeRange } = useTimeRange();\n const { setEditMode } = useEditMode();\n const { openSaveChangesConfirmationDialog, closeSaveChangesConfirmationDialog } = useSaveChangesConfirmationDialog();\n\n const onSaveButtonClick = () => {\n const isSavedDurationModified =\n isRelativeTimeRange(timeRange) && dashboard.spec.duration !== timeRange.pastDuration;\n\n // Save dashboard if active timeRange from plugin-system is relative and different than 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 saveDashboard();\n },\n onCancel: () => {\n closeSaveChangesConfirmationDialog();\n },\n });\n } else {\n saveDashboard();\n }\n };\n\n const saveDashboard = async () => {\n if (onSave) {\n try {\n setSavingDashboard(true);\n await onSave(dashboard);\n closeSaveChangesConfirmationDialog();\n setEditMode(false);\n setDashboard(dashboard);\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","useTemplateVariableActions","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;AAAA,SAASA,QAAQ,QAAQ,OAAO,CAAC;AACjC,SAASC,MAAM,QAAqB,eAAe,CAAC;AACpD,SAASC,mBAAmB,QAAQ,kBAAkB,CAAC;AACvD,SAASC,YAAY,QAAQ,2BAA2B,CAAC;AACzD,SAEEC,YAAY,EACZC,WAAW,EACXC,gCAAgC,EAChCC,0BAA0B,QACrB,eAAe,CAAC;AAQvB,OAAO,MAAMC,mBAAmB,GAAG,CAAC,EAAEC,MAAM,CAAA,EAAEC,UAAU,CAAA,EAAEC,OAAO,EAAG,WAAW,CAAA,EAA4B,GAAK;IAC9G,MAAM,CAACC,iBAAiB,EAAEC,kBAAkB,CAAC,GAAGb,QAAQ,CAAU,KAAK,CAAC,AAAC;IACzE,MAAM,EAAEc,SAAS,CAAA,EAAEC,YAAY,CAAA,EAAE,GAAGX,YAAY,EAAE,AAAC;IACnD,MAAM,EAAEY,uBAAuB,CAAA,EAAEC,wBAAwB,CAAA,EAAE,GAAGV,0BAA0B,EAAE,AAAC;IAC3F,MAAM,EAAEW,uBAAuB,CAAA,EAAE,GAAGF,uBAAuB,EAAE,AAAC;IAC9D,MAAM,EAAEG,SAAS,CAAA,EAAE,GAAGhB,YAAY,EAAE,AAAC;IACrC,MAAM,EAAEiB,WAAW,CAAA,EAAE,GAAGf,WAAW,EAAE,AAAC;IACtC,MAAM,EAAEgB,iCAAiC,CAAA,EAAEC,kCAAkC,CAAA,EAAE,GAAGhB,gCAAgC,EAAE,AAAC;IAErH,MAAMiB,iBAAiB,GAAG,IAAM;QAC9B,MA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LO,WAAW,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC;IACH,CAAC,AAAC;IAEF,qBACE,KAACnB,MAAM;QAACU,OAAO,EAAEA,OAAO;QAAEyB,OAAO,EAAEb,iBAAiB;QAAEc,QAAQ,EAAE3B,UAAU,IAAIE,iBAAiB;kBAAE,MAEjG;MAAS,CACT;AACJ,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './SaveDashboardButton';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/SaveDashboardButton/index.tsx"],"names":[],"mappings":"AAaA,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,15 @@
1
+ // Copyright 2023 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 './SaveDashboardButton';
14
+
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/SaveDashboardButton/index.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\nexport * from './SaveDashboardButton';\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,uBAAuB,CAAC"}
@@ -17,7 +17,7 @@ import { DateTimeRangePicker, InfoTooltip } from '@perses-dev/components';
17
17
  import { useTimeRange } from '@perses-dev/plugin-system';
18
18
  import { isDurationString } from '@perses-dev/core';
19
19
  import { TOOLTIP_TEXT } from '../../constants';
20
- import { useDefaultTimeRange } from '../../context';
20
+ import { useDashboardDuration } from '../../context';
21
21
  import { ToolbarIconButton } from '../ToolbarIconButton';
22
22
  export const TIME_OPTIONS = [
23
23
  {
@@ -79,17 +79,17 @@ const DEFAULT_HEIGHT = '34px';
79
79
  export function TimeRangeControls({ heightPx , showRefresh =true }) {
80
80
  const { timeRange , setTimeRange , refresh } = useTimeRange();
81
81
  // TODO: Remove this since it couples to the dashboard context
82
- const defaultTimeRange = useDefaultTimeRange();
82
+ const dashboardDuration = useDashboardDuration();
83
83
  // Convert height to a string, then use the string for styling
84
84
  const height = heightPx === undefined ? DEFAULT_HEIGHT : `${heightPx}px`;
85
85
  // add time shortcut if one does not match duration from dashboard JSON
86
- if (!TIME_OPTIONS.some((option)=>option.value.pastDuration === defaultTimeRange.pastDuration)) {
87
- if (isDurationString(defaultTimeRange.pastDuration)) {
86
+ if (!TIME_OPTIONS.some((option)=>option.value.pastDuration === dashboardDuration)) {
87
+ if (isDurationString(dashboardDuration)) {
88
88
  TIME_OPTIONS.push({
89
89
  value: {
90
- pastDuration: defaultTimeRange.pastDuration
90
+ pastDuration: dashboardDuration
91
91
  },
92
- display: `Last ${defaultTimeRange.pastDuration}`
92
+ display: `Last ${dashboardDuration}`
93
93
  });
94
94
  }
95
95
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/TimeRangeControls/TimeRangeControls.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 RefreshIcon from 'mdi-material-ui/Refresh';\nimport { Stack } from '@mui/material';\nimport { DateTimeRangePicker, InfoTooltip, TimeOption } from '@perses-dev/components';\nimport { useTimeRange } from '@perses-dev/plugin-system';\nimport { isDurationString } from '@perses-dev/core';\nimport { TOOLTIP_TEXT } from '../../constants';\nimport { useDefaultTimeRange } from '../../context';\nimport { ToolbarIconButton } from '../ToolbarIconButton';\n\nexport const TIME_OPTIONS: TimeOption[] = [\n { value: { pastDuration: '5m' }, display: 'Last 5 minutes' },\n { value: { pastDuration: '15m' }, display: 'Last 15 minutes' },\n { value: { pastDuration: '30m' }, display: 'Last 30 minutes' },\n { value: { pastDuration: '1h' }, display: 'Last 1 hour' },\n { value: { pastDuration: '6h' }, display: 'Last 6 hours' },\n { value: { pastDuration: '12h' }, display: 'Last 12 hours' },\n { value: { pastDuration: '24h' }, display: 'Last 1 day' },\n { value: { pastDuration: '7d' }, display: 'Last 7 days' },\n { value: { pastDuration: '14d' }, display: 'Last 14 days' },\n];\n\nconst DEFAULT_HEIGHT = '34px';\n\ninterface TimeRangeControlsProps {\n // The controls look best at heights >= 28 pixels\n heightPx?: number;\n\n // Whether to show the refresh button or not\n showRefresh?: boolean;\n}\n\nexport function TimeRangeControls({ heightPx, showRefresh = true }: TimeRangeControlsProps) {\n const { timeRange, setTimeRange, refresh } = useTimeRange();\n // TODO: Remove this since it couples to the dashboard context\n const defaultTimeRange = useDefaultTimeRange();\n\n // Convert height to a string, then use the string for styling\n const height = heightPx === undefined ? DEFAULT_HEIGHT : `${heightPx}px`;\n\n // add time shortcut if one does not match duration from dashboard JSON\n if (!TIME_OPTIONS.some((option) => option.value.pastDuration === defaultTimeRange.pastDuration)) {\n if (isDurationString(defaultTimeRange.pastDuration)) {\n TIME_OPTIONS.push({\n value: { pastDuration: defaultTimeRange.pastDuration },\n display: `Last ${defaultTimeRange.pastDuration}`,\n });\n }\n }\n\n return (\n <Stack direction=\"row\" spacing={1}>\n <DateTimeRangePicker timeOptions={TIME_OPTIONS} value={timeRange} onChange={setTimeRange} height={height} />\n {showRefresh && (\n <InfoTooltip description={TOOLTIP_TEXT.refreshDashboard}>\n <ToolbarIconButton aria-label={TOOLTIP_TEXT.refreshDashboard} onClick={refresh} sx={{ height }}>\n <RefreshIcon />\n </ToolbarIconButton>\n </InfoTooltip>\n )}\n </Stack>\n );\n}\n"],"names":["RefreshIcon","Stack","DateTimeRangePicker","InfoTooltip","useTimeRange","isDurationString","TOOLTIP_TEXT","useDefaultTimeRange","ToolbarIconButton","TIME_OPTIONS","value","pastDuration","display","DEFAULT_HEIGHT","TimeRangeControls","heightPx","showRefresh","timeRange","setTimeRange","refresh","defaultTimeRange","height","undefined","some","option","push","direction","spacing","timeOptions","onChange","description","refreshDashboard","aria-label","onClick","sx"],"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;AAAA,OAAOA,WAAW,MAAM,yBAAyB,CAAC;AAClD,SAASC,KAAK,QAAQ,eAAe,CAAC;AACtC,SAASC,mBAAmB,EAAEC,WAAW,QAAoB,wBAAwB,CAAC;AACtF,SAASC,YAAY,QAAQ,2BAA2B,CAAC;AACzD,SAASC,gBAAgB,QAAQ,kBAAkB,CAAC;AACpD,SAASC,YAAY,QAAQ,iBAAiB,CAAC;AAC/C,SAASC,mBAAmB,QAAQ,eAAe,CAAC;AACpD,SAASC,iBAAiB,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KO,SAAS,GAAGT,cAAc,GAAG,CAAC,EAAEE,QAAQ,CAAC,EAAE,CAAC,AAAC;IAEzE,uEAAuE;IACvE,IAAI,CAACN,YAAY,CAACc,IAAI,CAAC,CAACC,MAAM,GAAKA,MAAM,CAACd,KAAK,CAACC,YAAY,KAAKS,gBAAgB,CAACT,YAAY,CAAC,EAAE;QAC/F,IAAIN,gBAAgB,CAACe,gBAAgB,CAACT,YAAY,CAAC,EAAE;YACnDF,YAAY,CAACgB,IAAI,CAAC;gBAChBf,KAAK,EAAE;oBAAEC,YAAY,EAAES,gBAAgB,CAACT,YAAY;iBAAE;gBACtDC,OAAO,EAAE,CAAC,KAAK,EAAEQ,gBAAgB,CAACT,YAAY,CAAC,CAAC;aACjD,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,qBACE,MAACV,KAAK;QAACyB,SAAS,EAAC,KAAK;QAACC,OAAO,EAAE,CAAC;;0BAC/B,KAACzB,mBAAmB;gBAAC0B,WAAW,EAAEnB,YAAY;gBAAEC,KAAK,EAAEO,SAAS;gBAAEY,QAAQ,EAAEX,YAAY;gBAAEG,MAAM,EAAEA,MAAM;cAAI;YAC3GL,WAAW,kBACV,KAACb,WAAW;gBAAC2B,WAAW,EAAExB,YAAY,CAACyB,gBAAgB;0BACrD,cAAA,KAACvB,iBAAiB;oBAACwB,YAAU,EAAE1B,YAAY,CAACyB,gBAAgB;oBAAEE,OAAO,EAAEd,OAAO;oBAAEe,EAAE,EAAE;wBAAEb,MAAM;qBAAE;8BAC5F,cAAA,KAACrB,WAAW,KAAG;kBACG;cACR,AACf;;MACK,CACR;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../../src/components/TimeRangeControls/TimeRangeControls.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 RefreshIcon from 'mdi-material-ui/Refresh';\nimport { Stack } from '@mui/material';\nimport { DateTimeRangePicker, InfoTooltip, TimeOption } from '@perses-dev/components';\nimport { useTimeRange } from '@perses-dev/plugin-system';\nimport { isDurationString } from '@perses-dev/core';\nimport { TOOLTIP_TEXT } from '../../constants';\nimport { useDashboardDuration } from '../../context';\nimport { ToolbarIconButton } from '../ToolbarIconButton';\n\nexport const TIME_OPTIONS: TimeOption[] = [\n { value: { pastDuration: '5m' }, display: 'Last 5 minutes' },\n { value: { pastDuration: '15m' }, display: 'Last 15 minutes' },\n { value: { pastDuration: '30m' }, display: 'Last 30 minutes' },\n { value: { pastDuration: '1h' }, display: 'Last 1 hour' },\n { value: { pastDuration: '6h' }, display: 'Last 6 hours' },\n { value: { pastDuration: '12h' }, display: 'Last 12 hours' },\n { value: { pastDuration: '24h' }, display: 'Last 1 day' },\n { value: { pastDuration: '7d' }, display: 'Last 7 days' },\n { value: { pastDuration: '14d' }, display: 'Last 14 days' },\n];\n\nconst DEFAULT_HEIGHT = '34px';\n\ninterface TimeRangeControlsProps {\n // The controls look best at heights >= 28 pixels\n heightPx?: number;\n\n // Whether to show the refresh button or not\n showRefresh?: boolean;\n}\n\nexport function TimeRangeControls({ heightPx, showRefresh = true }: TimeRangeControlsProps) {\n const { timeRange, setTimeRange, refresh } = useTimeRange();\n // TODO: Remove this since it couples to the dashboard context\n const dashboardDuration = useDashboardDuration();\n\n // Convert height to a string, then use the string for styling\n const height = heightPx === undefined ? DEFAULT_HEIGHT : `${heightPx}px`;\n\n // add time shortcut if one does not match duration from dashboard JSON\n if (!TIME_OPTIONS.some((option) => option.value.pastDuration === dashboardDuration)) {\n if (isDurationString(dashboardDuration)) {\n TIME_OPTIONS.push({\n value: { pastDuration: dashboardDuration },\n display: `Last ${dashboardDuration}`,\n });\n }\n }\n\n return (\n <Stack direction=\"row\" spacing={1}>\n <DateTimeRangePicker timeOptions={TIME_OPTIONS} value={timeRange} onChange={setTimeRange} height={height} />\n {showRefresh && (\n <InfoTooltip description={TOOLTIP_TEXT.refreshDashboard}>\n <ToolbarIconButton aria-label={TOOLTIP_TEXT.refreshDashboard} onClick={refresh} sx={{ height }}>\n <RefreshIcon />\n </ToolbarIconButton>\n </InfoTooltip>\n )}\n </Stack>\n );\n}\n"],"names":["RefreshIcon","Stack","DateTimeRangePicker","InfoTooltip","useTimeRange","isDurationString","TOOLTIP_TEXT","useDashboardDuration","ToolbarIconButton","TIME_OPTIONS","value","pastDuration","display","DEFAULT_HEIGHT","TimeRangeControls","heightPx","showRefresh","timeRange","setTimeRange","refresh","dashboardDuration","height","undefined","some","option","push","direction","spacing","timeOptions","onChange","description","refreshDashboard","aria-label","onClick","sx"],"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;AAAA,OAAOA,WAAW,MAAM,yBAAyB,CAAC;AAClD,SAASC,KAAK,QAAQ,eAAe,CAAC;AACtC,SAASC,mBAAmB,EAAEC,WAAW,QAAoB,wBAAwB,CAAC;AACtF,SAASC,YAAY,QAAQ,2BAA2B,CAAC;AACzD,SAASC,gBAAgB,QAAQ,kBAAkB,CAAC;AACpD,SAASC,YAAY,QAAQ,iBAAiB,CAAC;AAC/C,SAASC,oBAAoB,QAAQ,eAAe,CAAC;AACrD,SAASC,iBAAiB,QAAQ,sBAAsB,CAAC;AAEzD,OAAO,MAAMC,YAAY,GAAiB;IACxC;QAAEC,KAAK,EAAE;YAAEC,YAAY,EAAE,IAAI;SAAE;QAAEC,OAAO,EAAE,gBAAgB;KAAE;IAC5D;QAAEF,KAAK,EAAE;YAAEC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Y,KAAKS,iBAAiB,CAAC,EAAE;QACnF,IAAIf,gBAAgB,CAACe,iBAAiB,CAAC,EAAE;YACvCX,YAAY,CAACgB,IAAI,CAAC;gBAChBf,KAAK,EAAE;oBAAEC,YAAY,EAAES,iBAAiB;iBAAE;gBAC1CR,OAAO,EAAE,CAAC,KAAK,EAAEQ,iBAAiB,CAAC,CAAC;aACrC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,qBACE,MAACnB,KAAK;QAACyB,SAAS,EAAC,KAAK;QAACC,OAAO,EAAE,CAAC;;0BAC/B,KAACzB,mBAAmB;gBAAC0B,WAAW,EAAEnB,YAAY;gBAAEC,KAAK,EAAEO,SAAS;gBAAEY,QAAQ,EAAEX,YAAY;gBAAEG,MAAM,EAAEA,MAAM;cAAI;YAC3GL,WAAW,kBACV,KAACb,WAAW;gBAAC2B,WAAW,EAAExB,YAAY,CAACyB,gBAAgB;0BACrD,cAAA,KAACvB,iBAAiB;oBAACwB,YAAU,EAAE1B,YAAY,CAACyB,gBAAgB;oBAAEE,OAAO,EAAEd,OAAO;oBAAEe,EAAE,EAAE;wBAAEb,MAAM;qBAAE;8BAC5F,cAAA,KAACrB,WAAW,KAAG;kBACG;cACR,AACf;;MACK,CACR;AACJ,CAAC"}
@@ -1,8 +1,10 @@
1
1
  /// <reference types="react" />
2
2
  import { VariableDefinition } from '@perses-dev/core';
3
- export declare function VariableEditForm({ initialVariableDefinition, onChange, onCancel, }: {
3
+ interface VariableEditFormProps {
4
4
  initialVariableDefinition: VariableDefinition;
5
5
  onChange: (def: VariableDefinition) => void;
6
6
  onCancel: () => void;
7
- }): JSX.Element;
7
+ }
8
+ export declare function VariableEditForm(props: VariableEditFormProps): JSX.Element;
9
+ export {};
8
10
  //# sourceMappingURL=VariableEditorForm.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"VariableEditorForm.d.ts","sourceRoot":"","sources":["../../../../src/components/Variables/VariableEditorForm/VariableEditorForm.tsx"],"names":[],"mappings":";AAiCA,OAAO,EAAE,kBAAkB,EAA0B,MAAM,kBAAkB,CAAC;AAsF9E,wBAAgB,gBAAgB,CAAC,EAC/B,yBAAyB,EACzB,QAAQ,EACR,QAAQ,GACT,EAAE;IACD,yBAAyB,EAAE,kBAAkB,CAAC;IAC9C,QAAQ,EAAE,CAAC,GAAG,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAC5C,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB,eAgNA"}
1
+ {"version":3,"file":"VariableEditorForm.d.ts","sourceRoot":"","sources":["../../../../src/components/Variables/VariableEditorForm/VariableEditorForm.tsx"],"names":[],"mappings":";AAgCA,OAAO,EAAE,kBAAkB,EAA0B,MAAM,kBAAkB,CAAC;AA6B9E,UAAU,qBAAqB;IAC7B,yBAAyB,EAAE,kBAAkB,CAAC;IAC9C,QAAQ,EAAE,CAAC,GAAG,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAC5C,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,eA+O5D"}