@perses-dev/dashboards 0.0.0-snapshot-saving-defaults-refinements-1b25cec → 0.0.0-snapshot-core-types-move-units-c7c5d31

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 (74) hide show
  1. package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +18 -35
  2. package/dist/cjs/components/EditJsonDialog/EditJsonDialog.js +2 -1
  3. package/dist/cjs/components/GridLayout/GridTitle.js +4 -2
  4. package/dist/cjs/components/Panel/PanelHeader.js +39 -33
  5. package/dist/cjs/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +10 -6
  6. package/dist/cjs/components/SaveDashboardButton/SaveDashboardButton.js +7 -3
  7. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +54 -9
  8. package/dist/cjs/components/Variables/TemplateVariable.js +3 -3
  9. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +15 -0
  10. package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +5 -2
  11. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +4 -2
  12. package/dist/cjs/context/TemplateVariableProvider/TemplateVariableProvider.js +18 -9
  13. package/dist/cjs/context/TemplateVariableProvider/hydrationUtils.js +3 -3
  14. package/dist/cjs/context/useDashboard.js +5 -3
  15. package/dist/cjs/stories/decorators/constants.js +1 -0
  16. package/dist/cjs/test/testDashboard.js +1 -0
  17. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +4 -0
  18. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
  19. package/dist/components/DashboardToolbar/DashboardToolbar.js +18 -35
  20. package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
  21. package/dist/components/EditJsonDialog/EditJsonDialog.js +2 -1
  22. package/dist/components/EditJsonDialog/EditJsonDialog.js.map +1 -1
  23. package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
  24. package/dist/components/GridLayout/GridTitle.js +4 -2
  25. package/dist/components/GridLayout/GridTitle.js.map +1 -1
  26. package/dist/components/Panel/PanelHeader.d.ts +1 -1
  27. package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
  28. package/dist/components/Panel/PanelHeader.js +39 -33
  29. package/dist/components/Panel/PanelHeader.js.map +1 -1
  30. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.d.ts.map +1 -1
  31. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +10 -6
  32. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +1 -1
  33. package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts.map +1 -1
  34. package/dist/components/SaveDashboardButton/SaveDashboardButton.js +7 -3
  35. package/dist/components/SaveDashboardButton/SaveDashboardButton.js.map +1 -1
  36. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts +7 -3
  37. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
  38. package/dist/components/TimeRangeControls/TimeRangeControls.js +53 -9
  39. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
  40. package/dist/components/Variables/TemplateVariable.d.ts.map +1 -1
  41. package/dist/components/Variables/TemplateVariable.js +1 -1
  42. package/dist/components/Variables/TemplateVariable.js.map +1 -1
  43. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
  44. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +15 -0
  45. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  46. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +1 -0
  47. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -1
  48. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +5 -2
  49. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
  50. package/dist/context/DashboardProvider/DashboardProvider.d.ts +1 -0
  51. package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
  52. package/dist/context/DashboardProvider/DashboardProvider.js +4 -2
  53. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
  54. package/dist/context/DashboardProvider/save-changes-dialog-slice.d.ts +2 -0
  55. package/dist/context/DashboardProvider/save-changes-dialog-slice.d.ts.map +1 -1
  56. package/dist/context/DashboardProvider/save-changes-dialog-slice.js.map +1 -1
  57. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts.map +1 -1
  58. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js +14 -5
  59. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js.map +1 -1
  60. package/dist/context/TemplateVariableProvider/hydrationUtils.d.ts.map +1 -1
  61. package/dist/context/TemplateVariableProvider/hydrationUtils.js +1 -1
  62. package/dist/context/TemplateVariableProvider/hydrationUtils.js.map +1 -1
  63. package/dist/context/useDashboard.d.ts.map +1 -1
  64. package/dist/context/useDashboard.js +5 -3
  65. package/dist/context/useDashboard.js.map +1 -1
  66. package/dist/stories/decorators/constants.js +1 -0
  67. package/dist/stories/decorators/constants.js.map +1 -1
  68. package/dist/test/testDashboard.d.ts.map +1 -1
  69. package/dist/test/testDashboard.js +1 -0
  70. package/dist/test/testDashboard.js.map +1 -1
  71. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
  72. package/dist/views/ViewDashboard/ViewDashboard.js +5 -1
  73. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
  74. package/package.json +7 -10
@@ -34,8 +34,8 @@ const _dashboardStickyToolbar = require("../DashboardStickyToolbar");
34
34
  const DashboardToolbar = (props)=>{
35
35
  const { dashboardName , dashboardTitleComponent , initialVariableIsSticky , isReadonly , onEditButtonClick , onCancelButtonClick , onSave , } = props;
36
36
  const { isEditMode } = (0, _context.useEditMode)();
37
- const isBiggerThanMd = (0, _material.useMediaQuery)((0, _material.useTheme)().breakpoints.up('md'));
38
37
  const isBiggerThanSm = (0, _material.useMediaQuery)((0, _material.useTheme)().breakpoints.up('sm'));
38
+ const isBiggerThanLg = (0, _material.useMediaQuery)((0, _material.useTheme)().breakpoints.up('lg'));
39
39
  const dashboardTitle = dashboardTitleComponent ? dashboardTitleComponent : /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
40
40
  variant: "h2",
41
41
  children: dashboardName
@@ -85,7 +85,7 @@ const DashboardToolbar = (props)=>{
85
85
  display: 'flex',
86
86
  width: '100%',
87
87
  alignItems: 'start',
88
- padding: (theme)=>theme.spacing(1, 2, 2, 2)
88
+ padding: (theme)=>theme.spacing(1, 2)
89
89
  },
90
90
  children: [
91
91
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorBoundary, {
@@ -93,54 +93,37 @@ const DashboardToolbar = (props)=>{
93
93
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_dashboardStickyToolbar.DashboardStickyToolbar, {
94
94
  initialVariableIsSticky: initialVariableIsSticky,
95
95
  sx: {
96
- backgroundColor: ({ palette })=>palette.mode === 'dark' ? palette.background.default : palette.background.paper
96
+ backgroundColor: ({ palette })=>palette.background.default
97
97
  }
98
98
  })
99
99
  }),
100
- isBiggerThanMd ? // On bigger screens, make it one row
101
100
  /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
101
+ ml: "auto",
102
102
  direction: "row",
103
- spacing: 1,
104
- marginLeft: "auto",
105
- sx: {
106
- whiteSpace: 'nowrap'
107
- },
108
- children: [
109
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_variables.EditVariablesButton, {}),
110
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_addPanelButton.AddPanelButton, {}),
111
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_addGroupButton.AddGroupButton, {}),
112
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_timeRangeControls.TimeRangeControls, {}),
113
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_downloadButton.DownloadButton, {}),
114
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_editJsonButton.EditJsonButton, {})
115
- ]
116
- }) : // On smaller screens, make it two rows
117
- /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
118
- spacing: 1,
103
+ flexWrap: isBiggerThanLg ? 'nowrap' : 'wrap-reverse',
104
+ justifyContent: "end",
119
105
  children: [
120
106
  /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
121
107
  direction: "row",
122
108
  spacing: 1,
123
- marginLeft: "auto",
124
- sx: {
125
- whiteSpace: 'nowrap'
126
- },
109
+ ml: 1,
110
+ mb: 1,
111
+ whiteSpace: "nowrap",
127
112
  children: [
128
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_timeRangeControls.TimeRangeControls, {}),
129
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_downloadButton.DownloadButton, {}),
130
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_editJsonButton.EditJsonButton, {})
113
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_variables.EditVariablesButton, {}),
114
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_addPanelButton.AddPanelButton, {}),
115
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_addGroupButton.AddGroupButton, {})
131
116
  ]
132
117
  }),
133
118
  /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
134
119
  direction: "row",
135
120
  spacing: 1,
136
- marginLeft: "auto",
137
- sx: {
138
- whiteSpace: 'nowrap'
139
- },
121
+ ml: 1,
122
+ mb: 1,
140
123
  children: [
141
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_variables.EditVariablesButton, {}),
142
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_addPanelButton.AddPanelButton, {}),
143
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_addGroupButton.AddGroupButton, {})
124
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_timeRangeControls.TimeRangeControls, {}),
125
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_downloadButton.DownloadButton, {}),
126
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_editJsonButton.EditJsonButton, {})
144
127
  ]
145
128
  })
146
129
  ]
@@ -181,7 +164,7 @@ const DashboardToolbar = (props)=>{
181
164
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_dashboardStickyToolbar.DashboardStickyToolbar, {
182
165
  initialVariableIsSticky: initialVariableIsSticky,
183
166
  sx: {
184
- backgroundColor: ({ palette })=>palette.mode === 'dark' ? palette.background.default : palette.background.paper
167
+ backgroundColor: ({ palette })=>palette.background.default
185
168
  }
186
169
  })
187
170
  })
@@ -43,7 +43,7 @@ const EditJsonDialog = ()=>{
43
43
  };
44
44
  const EditJsonDialogForm = ()=>{
45
45
  const { closeEditJsonDialog } = (0, _dashboardProvider.useEditJsonDialog)();
46
- const { setTimeRange } = (0, _pluginSystem.useTimeRange)();
46
+ const { setTimeRange , setRefreshInterval } = (0, _pluginSystem.useTimeRange)();
47
47
  const { dashboard , setDashboard } = (0, _useDashboard.useDashboard)();
48
48
  const [draftDashboard, setDraftDashboard] = (0, _react.useState)(dashboard);
49
49
  const handleApply = (e)=>{
@@ -52,6 +52,7 @@ const EditJsonDialogForm = ()=>{
52
52
  setTimeRange({
53
53
  pastDuration: draftDashboard.spec.duration
54
54
  });
55
+ setRefreshInterval(draftDashboard.spec.refreshInterval);
55
56
  closeEditJsonDialog();
56
57
  };
57
58
  return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_components.Dialog.Form, {
@@ -28,6 +28,7 @@ const _arrowUp = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/A
28
28
  const _arrowDown = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/ArrowDown"));
29
29
  const _deleteOutline = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/DeleteOutline"));
30
30
  const _components = require("@perses-dev/components");
31
+ const _pluginSystem = require("@perses-dev/plugin-system");
31
32
  const _constants = require("../../constants");
32
33
  const _context = require("../../context");
33
34
  function _interopRequireDefault(obj) {
@@ -36,7 +37,8 @@ function _interopRequireDefault(obj) {
36
37
  };
37
38
  }
38
39
  function GridTitle(props) {
39
- const { panelGroupId , title , collapse } = props;
40
+ const { panelGroupId , title: rawTitle , collapse } = props;
41
+ const title = (0, _pluginSystem.useReplaceVariablesInString)(rawTitle);
40
42
  const { openAddPanel , openEditPanelGroup , moveUp , moveDown } = (0, _context.usePanelGroupActions)(panelGroupId);
41
43
  const { openDeletePanelGroupDialog } = (0, _context.useDeletePanelGroupDialog)();
42
44
  const { isEditMode } = (0, _context.useEditMode)();
@@ -52,7 +54,7 @@ function GridTitle(props) {
52
54
  alignItems: 'center',
53
55
  padding: (theme)=>theme.spacing(1),
54
56
  cursor: collapse ? 'pointer' : 'auto',
55
- backgroundColor: ({ palette })=>palette.mode === 'dark' ? palette.background.paper : palette.background.default
57
+ backgroundColor: ({ palette })=>palette.background.paper
56
58
  },
57
59
  "data-testid": "panel-group-header",
58
60
  children: collapse ? /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
@@ -26,15 +26,18 @@ const _pencilOutline = /*#__PURE__*/ _interopRequireDefault(require("mdi-materia
26
26
  const _deleteOutline = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/DeleteOutline"));
27
27
  const _dragVertical = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/DragVertical"));
28
28
  const _contentCopy = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/ContentCopy"));
29
+ const _pluginSystem = require("@perses-dev/plugin-system");
29
30
  const _constants = require("../../constants");
30
31
  function _interopRequireDefault(obj) {
31
32
  return obj && obj.__esModule ? obj : {
32
33
  default: obj
33
34
  };
34
35
  }
35
- function PanelHeader({ id , title , description , editHandlers , sx , ...rest }) {
36
+ function PanelHeader({ id , title: rawTitle , description: rawDescription , editHandlers , sx , ...rest }) {
36
37
  const titleElementId = `${id}-title`;
37
38
  const descriptionTooltipId = `${id}-description`;
39
+ const title = (0, _pluginSystem.useReplaceVariablesInString)(rawTitle);
40
+ const description = (0, _pluginSystem.useReplaceVariablesInString)(rawDescription);
38
41
  let actions = undefined;
39
42
  if (editHandlers !== undefined) {
40
43
  // If there are edit handlers, always just show the edit buttons
@@ -94,25 +97,6 @@ function PanelHeader({ id , title , description , editHandlers , sx , ...rest })
94
97
  })
95
98
  ]
96
99
  });
97
- } else if (description !== undefined) {
98
- // If there aren't edit handlers and we have a description, show a button with a tooltip for the panel description
99
- actions = /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.InfoTooltip, {
100
- id: descriptionTooltipId,
101
- description: description,
102
- enterDelay: 100,
103
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(HeaderIconButton, {
104
- "aria-label": "panel description",
105
- size: "small",
106
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_informationOutline.default, {
107
- "aria-describedby": "info-tooltip",
108
- "aria-hidden": false,
109
- fontSize: "inherit",
110
- sx: {
111
- color: (theme)=>theme.palette.grey[700]
112
- }
113
- })
114
- })
115
- });
116
100
  }
117
101
  return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.CardHeader, {
118
102
  id: id,
@@ -120,19 +104,41 @@ function PanelHeader({ id , title , description , editHandlers , sx , ...rest })
120
104
  "aria-labelledby": titleElementId,
121
105
  "aria-describedby": descriptionTooltipId,
122
106
  disableTypography: true,
123
- title: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
124
- id: titleElementId,
125
- variant: "subtitle1",
126
- sx: {
127
- // `minHeight` guarantees that the header has the correct height
128
- // when there is no title (i.e. in the preview)
129
- lineHeight: '24px',
130
- minHeight: '24px',
131
- whiteSpace: 'nowrap',
132
- overflow: 'hidden',
133
- textOverflow: 'ellipsis'
134
- },
135
- children: title
107
+ title: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
108
+ direction: "row",
109
+ children: [
110
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
111
+ id: titleElementId,
112
+ variant: "subtitle1",
113
+ sx: {
114
+ // `minHeight` guarantees that the header has the correct height
115
+ // when there is no title (i.e. in the preview)
116
+ lineHeight: '24px',
117
+ minHeight: '24px',
118
+ whiteSpace: 'nowrap',
119
+ overflow: 'hidden',
120
+ textOverflow: 'ellipsis'
121
+ },
122
+ children: title
123
+ }),
124
+ description !== undefined && description.trim().length > 0 && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.InfoTooltip, {
125
+ id: descriptionTooltipId,
126
+ description: description,
127
+ enterDelay: 100,
128
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(HeaderIconButton, {
129
+ "aria-label": "panel description",
130
+ size: "small",
131
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_informationOutline.default, {
132
+ "aria-describedby": "info-tooltip",
133
+ "aria-hidden": false,
134
+ fontSize: "inherit",
135
+ sx: {
136
+ color: (theme)=>theme.palette.text.secondary
137
+ }
138
+ })
139
+ })
140
+ })
141
+ ]
136
142
  }),
137
143
  action: /*#__PURE__*/ (0, _jsxRuntime.jsx)(HeaderActionWrapper, {
138
144
  direction: "row",
@@ -26,11 +26,15 @@ const _core = require("@perses-dev/core");
26
26
  const _components = require("@perses-dev/components");
27
27
  const _context = require("../../context");
28
28
  const SaveChangesConfirmationDialog = ()=>{
29
- const [saveDefaultTimeRange, setSaveDefaultTimeRange] = (0, _react.useState)(true);
30
- const [saveDefaultVariables, setSaveDefaultVariables] = (0, _react.useState)(true);
31
- const { getSavedVariablesStatus } = (0, _context.useTemplateVariableActions)();
32
- const { isSavedVariableModified , modifiedVariableNames } = getSavedVariablesStatus();
33
29
  const { saveChangesConfirmationDialog: dialog } = (0, _context.useSaveChangesConfirmationDialog)();
30
+ var ref;
31
+ const isSavedDurationModified = (ref = dialog === null || dialog === void 0 ? void 0 : dialog.isSavedDurationModified) !== null && ref !== void 0 ? ref : true;
32
+ var ref1;
33
+ const isSavedVariableModified = (ref1 = dialog === null || dialog === void 0 ? void 0 : dialog.isSavedVariableModified) !== null && ref1 !== void 0 ? ref1 : true;
34
+ const [saveDefaultTimeRange, setSaveDefaultTimeRange] = (0, _react.useState)(isSavedDurationModified);
35
+ const [saveDefaultVariables, setSaveDefaultVariables] = (0, _react.useState)(isSavedVariableModified);
36
+ const { getSavedVariablesStatus } = (0, _context.useTemplateVariableActions)();
37
+ const { modifiedVariableNames } = getSavedVariablesStatus();
34
38
  const isOpen = dialog !== undefined;
35
39
  const { timeRange } = (0, _pluginSystem.useTimeRange)();
36
40
  const currentTimeRangeText = (0, _core.isRelativeTimeRange)(timeRange) ? `(Last ${timeRange.pastDuration})` : '(Absolute time ranges can not be saved)';
@@ -54,8 +58,8 @@ const SaveChangesConfirmationDialog = ()=>{
54
58
  children: [
55
59
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.FormControlLabel, {
56
60
  control: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Checkbox, {
57
- disabled: !(0, _core.isRelativeTimeRange)(timeRange),
58
- checked: saveDefaultTimeRange && (0, _core.isRelativeTimeRange)(timeRange),
61
+ disabled: !isSavedDurationModified || !(0, _core.isRelativeTimeRange)(timeRange),
62
+ checked: saveDefaultTimeRange && isSavedDurationModified && (0, _core.isRelativeTimeRange)(timeRange),
59
63
  onChange: (e)=>setSaveDefaultTimeRange(e.target.checked)
60
64
  }),
61
65
  label: saveTimeRangeText
@@ -45,11 +45,14 @@ const SaveDashboardButton = ({ onSave , isDisabled , variant ='contained' })=>{
45
45
  const variables = setVariableDefaultValues();
46
46
  dashboard.spec.variables = variables;
47
47
  }
48
+ setDashboard(dashboard);
48
49
  saveDashboard();
49
50
  },
50
51
  onCancel: ()=>{
51
52
  closeSaveChangesConfirmationDialog();
52
- }
53
+ },
54
+ isSavedDurationModified,
55
+ isSavedVariableModified
53
56
  });
54
57
  } else {
55
58
  saveDashboard();
@@ -62,11 +65,12 @@ const SaveDashboardButton = ({ onSave , isDisabled , variant ='contained' })=>{
62
65
  await onSave(dashboard);
63
66
  closeSaveChangesConfirmationDialog();
64
67
  setEditMode(false);
65
- setDashboard(dashboard);
66
68
  } catch (error) {
67
69
  throw new Error(`An error occurred while saving the dashboard. ${error}`);
68
70
  } finally{
69
- setSavingDashboard(false);
71
+ if (isSavingDashboard) {
72
+ setSavingDashboard(false);
73
+ }
70
74
  }
71
75
  } else {
72
76
  setEditMode(false);
@@ -21,7 +21,8 @@ function _export(target, all) {
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- TIME_OPTIONS: ()=>TIME_OPTIONS,
24
+ DEFAULT_TIME_RANGE_OPTIONS: ()=>DEFAULT_TIME_RANGE_OPTIONS,
25
+ DEFAULT_REFRESH_INTERVAL_OPTIONS: ()=>DEFAULT_REFRESH_INTERVAL_OPTIONS,
25
26
  TimeRangeControls: ()=>TimeRangeControls
26
27
  });
27
28
  const _jsxRuntime = require("react/jsx-runtime");
@@ -38,7 +39,7 @@ function _interopRequireDefault(obj) {
38
39
  default: obj
39
40
  };
40
41
  }
41
- const TIME_OPTIONS = [
42
+ const DEFAULT_TIME_RANGE_OPTIONS = [
42
43
  {
43
44
  value: {
44
45
  pastDuration: '5m'
@@ -94,17 +95,55 @@ const TIME_OPTIONS = [
94
95
  display: 'Last 14 days'
95
96
  }
96
97
  ];
98
+ const DEFAULT_REFRESH_INTERVAL_OPTIONS = [
99
+ {
100
+ value: {
101
+ pastDuration: '0s'
102
+ },
103
+ display: 'Off'
104
+ },
105
+ {
106
+ value: {
107
+ pastDuration: '5s'
108
+ },
109
+ display: '5s'
110
+ },
111
+ {
112
+ value: {
113
+ pastDuration: '10s'
114
+ },
115
+ display: '10s'
116
+ },
117
+ {
118
+ value: {
119
+ pastDuration: '15s'
120
+ },
121
+ display: '15s'
122
+ },
123
+ {
124
+ value: {
125
+ pastDuration: '30s'
126
+ },
127
+ display: '30s'
128
+ },
129
+ {
130
+ value: {
131
+ pastDuration: '60s'
132
+ },
133
+ display: '1m'
134
+ }
135
+ ];
97
136
  const DEFAULT_HEIGHT = '34px';
98
- function TimeRangeControls({ heightPx , showRefresh =true }) {
99
- const { timeRange , setTimeRange , refresh } = (0, _pluginSystem.useTimeRange)();
137
+ function TimeRangeControls({ heightPx , showTimeRangeSelector =true , showRefreshButton =true , showRefreshInterval =true , timePresets =DEFAULT_TIME_RANGE_OPTIONS }) {
138
+ const { timeRange , setTimeRange , refresh , refreshInterval , setRefreshInterval } = (0, _pluginSystem.useTimeRange)();
100
139
  // TODO: Remove this since it couples to the dashboard context
101
140
  const dashboardDuration = (0, _context.useDashboardDuration)();
102
141
  // Convert height to a string, then use the string for styling
103
142
  const height = heightPx === undefined ? DEFAULT_HEIGHT : `${heightPx}px`;
104
143
  // add time shortcut if one does not match duration from dashboard JSON
105
- if (!TIME_OPTIONS.some((option)=>option.value.pastDuration === dashboardDuration)) {
144
+ if (!timePresets.some((option)=>option.value.pastDuration === dashboardDuration)) {
106
145
  if ((0, _core.isDurationString)(dashboardDuration)) {
107
- TIME_OPTIONS.push({
146
+ timePresets.push({
108
147
  value: {
109
148
  pastDuration: dashboardDuration
110
149
  },
@@ -116,13 +155,13 @@ function TimeRangeControls({ heightPx , showRefresh =true }) {
116
155
  direction: "row",
117
156
  spacing: 1,
118
157
  children: [
119
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.DateTimeRangePicker, {
120
- timeOptions: TIME_OPTIONS,
158
+ showTimeRangeSelector && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.DateTimeRangePicker, {
159
+ timeOptions: timePresets,
121
160
  value: timeRange,
122
161
  onChange: setTimeRange,
123
162
  height: height
124
163
  }),
125
- showRefresh && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.InfoTooltip, {
164
+ showRefreshButton && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.InfoTooltip, {
126
165
  description: _constants.TOOLTIP_TEXT.refreshDashboard,
127
166
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_toolbarIconButton.ToolbarIconButton, {
128
167
  "aria-label": _constants.TOOLTIP_TEXT.refreshDashboard,
@@ -132,6 +171,12 @@ function TimeRangeControls({ heightPx , showRefresh =true }) {
132
171
  },
133
172
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_refresh.default, {})
134
173
  })
174
+ }),
175
+ showRefreshInterval && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.RefreshIntervalPicker, {
176
+ timeOptions: DEFAULT_REFRESH_INTERVAL_OPTIONS,
177
+ value: refreshInterval,
178
+ onChange: setRefreshInterval,
179
+ height: height
135
180
  })
136
181
  ]
137
182
  });
@@ -21,7 +21,7 @@ Object.defineProperty(exports, "TemplateVariable", {
21
21
  const _jsxRuntime = require("react/jsx-runtime");
22
22
  const _react = require("react");
23
23
  const _material = require("@mui/material");
24
- const _pluginSystem = require("@perses-dev/plugin-system");
24
+ const _core = require("@perses-dev/core");
25
25
  const _context = require("../../context");
26
26
  const _variableModel = require("./variable-model");
27
27
  function TemplateVariable({ name }) {
@@ -83,7 +83,7 @@ function ListVariable({ name }) {
83
83
  if (allowAllValue) {
84
84
  computedOptions = [
85
85
  {
86
- value: _pluginSystem.DEFAULT_ALL_VALUE,
86
+ value: _core.DEFAULT_ALL_VALUE,
87
87
  label: 'All'
88
88
  },
89
89
  ...computedOptions
@@ -142,7 +142,7 @@ function ListVariable({ name }) {
142
142
  // Must be selected
143
143
  if (e.target.value === null || e.target.value.length === 0) {
144
144
  if (allowAllValue) {
145
- setVariableValue(name, _pluginSystem.DEFAULT_ALL_VALUE);
145
+ setVariableValue(name, _core.DEFAULT_ALL_VALUE);
146
146
  }
147
147
  return;
148
148
  }
@@ -368,8 +368,23 @@ function VariableEditForm(props) {
368
368
  label: "Allow All option"
369
369
  }),
370
370
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
371
+ mb: 1,
371
372
  variant: "caption",
372
373
  children: "Enables an option to include all variable values"
374
+ }),
375
+ state.listVariableFields.allowAll && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
376
+ label: "Custom All Value",
377
+ value: state.listVariableFields.customAllValue,
378
+ onChange: (e)=>{
379
+ setState((draft)=>{
380
+ if (e.target.value) {
381
+ draft.listVariableFields.customAllValue = e.target.value;
382
+ } else {
383
+ draft.listVariableFields.customAllValue = undefined;
384
+ }
385
+ });
386
+ },
387
+ helperText: "When All is selected, this value will be used"
373
388
  })
374
389
  ]
375
390
  })
@@ -37,7 +37,8 @@ function getInitialState(initialVariableDefinition) {
37
37
  plugin: {
38
38
  kind: '',
39
39
  spec: {}
40
- }
40
+ },
41
+ customAllValue: undefined
41
42
  };
42
43
  if (initialVariableDefinition.kind === 'ListVariable') {
43
44
  var _allow_all_value;
@@ -46,6 +47,7 @@ function getInitialState(initialVariableDefinition) {
46
47
  listVariableFields.allowAll = (_allow_all_value1 = initialVariableDefinition.spec.allow_all_value) !== null && _allow_all_value1 !== void 0 ? _allow_all_value1 : false;
47
48
  listVariableFields.capturing_regexp = initialVariableDefinition.spec.capturing_regexp;
48
49
  listVariableFields.plugin = initialVariableDefinition.spec.plugin;
50
+ listVariableFields.customAllValue = initialVariableDefinition.spec.custom_all_value;
49
51
  }
50
52
  return {
51
53
  name: initialVariableDefinition.spec.name,
@@ -80,7 +82,8 @@ function getVariableDefinitionFromState(state) {
80
82
  allow_multiple: state.listVariableFields.allowMultiple,
81
83
  allow_all_value: state.listVariableFields.allowAll,
82
84
  capturing_regexp: state.listVariableFields.capturing_regexp,
83
- plugin: state.listVariableFields.plugin
85
+ plugin: state.listVariableFields.plugin,
86
+ custom_all_value: state.listVariableFields.customAllValue
84
87
  }
85
88
  };
86
89
  }
@@ -82,7 +82,7 @@ function DashboardProvider(props) {
82
82
  }
83
83
  function initStore(props) {
84
84
  const { initialState: { dashboardResource , isEditMode } , } = props;
85
- const { spec: { display , duration } , metadata , } = dashboardResource;
85
+ const { spec: { display , duration , refreshInterval } , metadata , } = dashboardResource;
86
86
  let { spec: { layouts , panels } , } = dashboardResource;
87
87
  // Set fallbacks in case the frontend is used with a non-Perses backend
88
88
  layouts = layouts !== null && layouts !== void 0 ? layouts : [];
@@ -103,11 +103,12 @@ function initStore(props) {
103
103
  metadata,
104
104
  display,
105
105
  duration,
106
+ refreshInterval,
106
107
  isEditMode: !!isEditMode,
107
108
  setEditMode: (isEditMode)=>set({
108
109
  isEditMode
109
110
  }),
110
- setDashboard: ({ metadata , spec: { display , panels ={} , layouts =[] , duration } })=>{
111
+ setDashboard: ({ metadata , spec: { display , panels ={} , layouts =[] , duration , refreshInterval } })=>{
111
112
  set((state)=>{
112
113
  state.metadata = metadata;
113
114
  state.display = display;
@@ -116,6 +117,7 @@ function initStore(props) {
116
117
  state.panelGroups = panelGroups;
117
118
  state.panelGroupOrder = panelGroupOrder;
118
119
  state.duration = duration;
120
+ state.refreshInterval = refreshInterval;
119
121
  });
120
122
  }
121
123
  };
@@ -35,6 +35,7 @@ const _immer = require("zustand/middleware/immer");
35
35
  const _middleware = require("zustand/middleware");
36
36
  const _immer1 = /*#__PURE__*/ _interopRequireDefault(require("immer"));
37
37
  const _pluginSystem = require("@perses-dev/plugin-system");
38
+ const _core = require("@perses-dev/core");
38
39
  const _utils = require("./utils");
39
40
  const _hydrationUtils = require("./hydrationUtils");
40
41
  const _queryParams = require("./query-params");
@@ -103,6 +104,7 @@ function useTemplateVariableStore() {
103
104
  }
104
105
  function PluginProvider({ children }) {
105
106
  const originalValues = useTemplateVariableValues();
107
+ const definitions = useTemplateVariableDefinitions();
106
108
  const values = (0, _react.useMemo)(()=>{
107
109
  const contextValues = {};
108
110
  // This will loop through all the current variables values
@@ -112,16 +114,23 @@ function PluginProvider({ children }) {
112
114
  const v = {
113
115
  ...originalValues[name]
114
116
  };
115
- if (v.value === _pluginSystem.DEFAULT_ALL_VALUE) {
116
- var ref;
117
- var ref1;
118
- v.value = (ref1 = (ref = v.options) === null || ref === void 0 ? void 0 : ref.map((o)=>o.value)) !== null && ref1 !== void 0 ? ref1 : null;
117
+ if (v.value === _core.DEFAULT_ALL_VALUE) {
118
+ const definition = definitions.find((d)=>d.spec.name === name);
119
+ // If the variable is a list variable and has a custom all value, then use that value instead
120
+ if ((definition === null || definition === void 0 ? void 0 : definition.kind) === 'ListVariable' && definition.spec.custom_all_value) {
121
+ v.value = definition.spec.custom_all_value;
122
+ } else {
123
+ var ref;
124
+ var ref1;
125
+ v.value = (ref1 = (ref = v.options) === null || ref === void 0 ? void 0 : ref.map((o)=>o.value)) !== null && ref1 !== void 0 ? ref1 : null;
126
+ }
119
127
  }
120
128
  contextValues[name] = v;
121
129
  });
122
130
  return contextValues;
123
131
  }, [
124
- originalValues
132
+ originalValues,
133
+ definitions
125
134
  ]);
126
135
  return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.TemplateVariableContext.Provider, {
127
136
  value: {
@@ -168,11 +177,11 @@ function createTemplateVariableSrvStore({ initialVariableDefinitions =[] , query
168
177
  return;
169
178
  }
170
179
  // Make sure there is only one all value
171
- if (Array.isArray(val) && val.includes(_pluginSystem.DEFAULT_ALL_VALUE)) {
172
- if (val.at(-1) === _pluginSystem.DEFAULT_ALL_VALUE) {
173
- val = _pluginSystem.DEFAULT_ALL_VALUE;
180
+ if (Array.isArray(val) && val.includes(_core.DEFAULT_ALL_VALUE)) {
181
+ if (val.at(-1) === _core.DEFAULT_ALL_VALUE) {
182
+ val = _core.DEFAULT_ALL_VALUE;
174
183
  } else {
175
- val = val.filter((v)=>v !== _pluginSystem.DEFAULT_ALL_VALUE);
184
+ val = val.filter((v)=>v !== _core.DEFAULT_ALL_VALUE);
176
185
  }
177
186
  }
178
187
  if (queryParams) {
@@ -18,7 +18,7 @@ Object.defineProperty(exports, "hydrateTemplateVariableStates", {
18
18
  enumerable: true,
19
19
  get: ()=>hydrateTemplateVariableStates
20
20
  });
21
- const _pluginSystem = require("@perses-dev/plugin-system");
21
+ const _core = require("@perses-dev/core");
22
22
  // TODO: move to TemplateVariableProvider/utils.ts
23
23
  function hydrateTemplateVariableState(variable, initialValue) {
24
24
  const varState = {
@@ -49,8 +49,8 @@ function hydrateTemplateVariableState(variable, initialValue) {
49
49
  // to end up in a buggy state if the variables are initialized with an "all"
50
50
  // value inside an array. When hydrating variables, normalize this to minimize
51
51
  // bugs.
52
- if (Array.isArray(varState.value) && varState.value.length === 1 && varState.value[0] === _pluginSystem.DEFAULT_ALL_VALUE) {
53
- varState.value = _pluginSystem.DEFAULT_ALL_VALUE;
52
+ if (Array.isArray(varState.value) && varState.value.length === 1 && varState.value[0] === _core.DEFAULT_ALL_VALUE) {
53
+ varState.value = _core.DEFAULT_ALL_VALUE;
54
54
  }
55
55
  break;
56
56
  default:
@@ -22,14 +22,15 @@ const _core = require("@perses-dev/core");
22
22
  const _dashboardProvider = require("./DashboardProvider");
23
23
  const _templateVariableProvider = require("./TemplateVariableProvider");
24
24
  function useDashboard() {
25
- const { panels , panelGroups , panelGroupOrder , setDashboard: setDashboardResource , metadata , display , duration , } = (0, _dashboardProvider.useDashboardStore)(({ panels , panelGroups , panelGroupOrder , setDashboard , metadata , display , duration })=>({
25
+ const { panels , panelGroups , panelGroupOrder , setDashboard: setDashboardResource , metadata , display , duration , refreshInterval , } = (0, _dashboardProvider.useDashboardStore)(({ panels , panelGroups , panelGroupOrder , setDashboard , metadata , display , duration , refreshInterval })=>({
26
26
  panels,
27
27
  panelGroups,
28
28
  panelGroupOrder,
29
29
  setDashboard,
30
30
  metadata,
31
31
  display,
32
- duration
32
+ duration,
33
+ refreshInterval
33
34
  }));
34
35
  const { setVariableDefinitions } = (0, _templateVariableProvider.useTemplateVariableActions)();
35
36
  const variables = (0, _templateVariableProvider.useTemplateVariableDefinitions)();
@@ -42,7 +43,8 @@ function useDashboard() {
42
43
  panels,
43
44
  layouts,
44
45
  variables,
45
- duration
46
+ duration,
47
+ refreshInterval
46
48
  }
47
49
  };
48
50
  const setDashboard = (dashboardResource)=>{
@@ -29,6 +29,7 @@ const EMPTY_DASHBOARD_RESOURCE = {
29
29
  },
30
30
  spec: {
31
31
  duration: '1h',
32
+ refreshInterval: '0s',
32
33
  variables: [],
33
34
  layouts: [],
34
35
  panels: {}