@perses-dev/dashboards 0.0.0-snapshot-core-types-move-units-c7c5d31 → 0.0.0-snapshot-panel-extra-content-2-2767e21

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 (93) hide show
  1. package/dist/cjs/components/Dashboard/Dashboard.js +3 -2
  2. package/dist/cjs/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js +12 -52
  3. package/dist/cjs/components/EditJsonDialog/EditJsonDialog.js +2 -1
  4. package/dist/cjs/components/GridLayout/GridItemContent.js +2 -1
  5. package/dist/cjs/components/GridLayout/GridLayout.js +1 -0
  6. package/dist/cjs/components/GridLayout/index.js +3 -1
  7. package/dist/cjs/components/Panel/Panel.js +5 -3
  8. package/dist/cjs/components/Panel/PanelHeader.js +7 -3
  9. package/dist/cjs/components/Variables/TemplateVariable.js +2 -2
  10. package/dist/cjs/components/Variables/VariableEditor.js +17 -6
  11. package/dist/cjs/components/Variables/index.js +0 -2
  12. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +3 -2
  13. package/dist/cjs/context/DatasourceStoreProvider.js +22 -18
  14. package/dist/cjs/views/ViewDashboard/DashboardApp.js +1 -1
  15. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +3 -2
  16. package/dist/components/Dashboard/Dashboard.d.ts +3 -1
  17. package/dist/components/Dashboard/Dashboard.d.ts.map +1 -1
  18. package/dist/components/Dashboard/Dashboard.js +3 -2
  19. package/dist/components/Dashboard/Dashboard.js.map +1 -1
  20. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.d.ts +1 -1
  21. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.d.ts.map +1 -1
  22. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js +11 -46
  23. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js.map +1 -1
  24. package/dist/components/EditJsonDialog/EditJsonDialog.js +2 -1
  25. package/dist/components/EditJsonDialog/EditJsonDialog.js.map +1 -1
  26. package/dist/components/GridLayout/GridItemContent.d.ts +2 -0
  27. package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
  28. package/dist/components/GridLayout/GridItemContent.js +2 -1
  29. package/dist/components/GridLayout/GridItemContent.js.map +1 -1
  30. package/dist/components/GridLayout/GridLayout.d.ts +2 -0
  31. package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
  32. package/dist/components/GridLayout/GridLayout.js +1 -0
  33. package/dist/components/GridLayout/GridLayout.js.map +1 -1
  34. package/dist/components/GridLayout/index.d.ts +3 -1
  35. package/dist/components/GridLayout/index.d.ts.map +1 -1
  36. package/dist/components/GridLayout/index.js +3 -1
  37. package/dist/components/GridLayout/index.js.map +1 -1
  38. package/dist/components/Panel/Panel.d.ts +8 -0
  39. package/dist/components/Panel/Panel.d.ts.map +1 -1
  40. package/dist/components/Panel/Panel.js +5 -3
  41. package/dist/components/Panel/Panel.js.map +1 -1
  42. package/dist/components/Panel/PanelHeader.d.ts +2 -1
  43. package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
  44. package/dist/components/Panel/PanelHeader.js +7 -3
  45. package/dist/components/Panel/PanelHeader.js.map +1 -1
  46. package/dist/components/Variables/TemplateVariable.d.ts.map +1 -1
  47. package/dist/components/Variables/TemplateVariable.js +1 -1
  48. package/dist/components/Variables/TemplateVariable.js.map +1 -1
  49. package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
  50. package/dist/components/Variables/VariableEditor.js +15 -4
  51. package/dist/components/Variables/VariableEditor.js.map +1 -1
  52. package/dist/components/Variables/index.d.ts +0 -2
  53. package/dist/components/Variables/index.d.ts.map +1 -1
  54. package/dist/components/Variables/index.js +0 -2
  55. package/dist/components/Variables/index.js.map +1 -1
  56. package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
  57. package/dist/context/DashboardProvider/DashboardProvider.js +3 -2
  58. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
  59. package/dist/context/DatasourceStoreProvider.d.ts +4 -3
  60. package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
  61. package/dist/context/DatasourceStoreProvider.js +22 -18
  62. package/dist/context/DatasourceStoreProvider.js.map +1 -1
  63. package/dist/views/ViewDashboard/DashboardApp.js +2 -2
  64. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  65. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
  66. package/dist/views/ViewDashboard/ViewDashboard.js +3 -2
  67. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
  68. package/package.json +6 -6
  69. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +0 -399
  70. package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +0 -178
  71. package/dist/cjs/components/Variables/VariableEditorForm/index.js +0 -29
  72. package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +0 -91
  73. package/dist/cjs/components/Variables/variable-model.js +0 -117
  74. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +0 -10
  75. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +0 -1
  76. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +0 -354
  77. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +0 -1
  78. package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts +0 -16
  79. package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts.map +0 -1
  80. package/dist/components/Variables/VariableEditorForm/VariablePreview.js +0 -122
  81. package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +0 -1
  82. package/dist/components/Variables/VariableEditorForm/index.d.ts +0 -3
  83. package/dist/components/Variables/VariableEditorForm/index.d.ts.map +0 -1
  84. package/dist/components/Variables/VariableEditorForm/index.js +0 -16
  85. package/dist/components/Variables/VariableEditorForm/index.js.map +0 -1
  86. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +0 -23
  87. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +0 -1
  88. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +0 -79
  89. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +0 -1
  90. package/dist/components/Variables/variable-model.d.ts +0 -16
  91. package/dist/components/Variables/variable-model.d.ts.map +0 -1
  92. package/dist/components/Variables/variable-model.js +0 -105
  93. package/dist/components/Variables/variable-model.js.map +0 -1
@@ -24,7 +24,7 @@ const _components = require("@perses-dev/components");
24
24
  const _context = require("../../context");
25
25
  const _gridLayout = require("../GridLayout");
26
26
  const _emptyDashboard = require("../EmptyDashboard");
27
- function Dashboard({ emptyDashboardProps , ...boxProps }) {
27
+ function Dashboard({ emptyDashboardProps , panelOptions , ...boxProps }) {
28
28
  const panelGroupIds = (0, _context.usePanelGroupIds)();
29
29
  const isEmpty = !panelGroupIds.length;
30
30
  return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
@@ -46,7 +46,8 @@ function Dashboard({ emptyDashboardProps , ...boxProps }) {
46
46
  })
47
47
  }),
48
48
  !isEmpty && panelGroupIds.map((panelGroupId)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_gridLayout.GridLayout, {
49
- panelGroupId: panelGroupId
49
+ panelGroupId: panelGroupId,
50
+ panelOptions: panelOptions
50
51
  }, panelGroupId))
51
52
  ]
52
53
  })
@@ -14,62 +14,22 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
- Object.defineProperty(exports, "DiscardChangesConfirmationDialog", {
17
+ Object.defineProperty(exports, "DashboardDiscardChangesConfirmationDialog", {
18
18
  enumerable: true,
19
- get: ()=>DiscardChangesConfirmationDialog
19
+ get: ()=>DashboardDiscardChangesConfirmationDialog
20
20
  });
21
21
  const _jsxRuntime = require("react/jsx-runtime");
22
- const _material = require("@mui/material");
23
- const _close = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/Close"));
22
+ const _components = require("@perses-dev/components");
24
23
  const _context = require("../../context");
25
- function _interopRequireDefault(obj) {
26
- return obj && obj.__esModule ? obj : {
27
- default: obj
28
- };
29
- }
30
- const DiscardChangesConfirmationDialog = ()=>{
24
+ const DashboardDiscardChangesConfirmationDialog = ()=>{
31
25
  const { discardChangesConfirmationDialog: dialog } = (0, _context.useDiscardChangesConfirmationDialog)();
32
- const isOpen = dialog !== undefined;
33
- return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Dialog, {
34
- open: isOpen,
35
- children: dialog !== undefined && /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
36
- children: [
37
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.DialogTitle, {
38
- children: "Discard Changes"
39
- }),
40
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
41
- "aria-label": "Close",
42
- onClick: dialog.onCancel,
43
- sx: (theme)=>({
44
- position: 'absolute',
45
- top: theme.spacing(0.5),
46
- right: theme.spacing(0.5)
47
- }),
48
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_close.default, {})
49
- }),
50
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.DialogContent, {
51
- dividers: true,
52
- sx: {
53
- width: '500px'
54
- },
55
- children: dialog.description || 'You have unsaved changes in this dashboard. Are you sure you want to discard these changes? Changes cannot be recovered.'
56
- }),
57
- /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.DialogActions, {
58
- children: [
59
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
60
- variant: "contained",
61
- onClick: dialog.onDiscardChanges,
62
- children: "Discard Changes"
63
- }),
64
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
65
- variant: "outlined",
66
- color: "secondary",
67
- onClick: dialog.onCancel,
68
- children: "Cancel"
69
- })
70
- ]
71
- })
72
- ]
73
- })
26
+ if (dialog === undefined) {
27
+ return null;
28
+ }
29
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.DiscardChangesConfirmationDialog, {
30
+ description: dialog.description || 'You have unsaved changes in this dashboard. Are you sure you want to discard these changes? Changes cannot be recovered.',
31
+ isOpen: true,
32
+ onCancel: dialog.onCancel,
33
+ onDiscardChanges: dialog.onDiscardChanges
74
34
  });
75
35
  };
@@ -52,7 +52,8 @@ const EditJsonDialogForm = ()=>{
52
52
  setTimeRange({
53
53
  pastDuration: draftDashboard.spec.duration
54
54
  });
55
- setRefreshInterval(draftDashboard.spec.refreshInterval);
55
+ var _refreshInterval;
56
+ setRefreshInterval((_refreshInterval = draftDashboard.spec.refreshInterval) !== null && _refreshInterval !== void 0 ? _refreshInterval : '0s');
56
57
  closeEditJsonDialog();
57
58
  };
58
59
  return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_components.Dialog.Form, {
@@ -54,7 +54,8 @@ function GridItemContent(props) {
54
54
  },
55
55
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_panel.Panel, {
56
56
  definition: panelDefinition,
57
- editHandlers: editHandlers
57
+ editHandlers: editHandlers,
58
+ panelOptions: props.panelOptions
58
59
  })
59
60
  });
60
61
  }
@@ -105,6 +105,7 @@ function GridLayout(props) {
105
105
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorBoundary, {
106
106
  FallbackComponent: _components.ErrorAlert,
107
107
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_gridItemContent.GridItemContent, {
108
+ panelOptions: props.panelOptions,
108
109
  panelGroupItemId: {
109
110
  panelGroupId,
110
111
  panelGroupItemLayoutId: i
@@ -14,8 +14,10 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
- _exportStar(require("./GridLayout"), exports);
17
+ _exportStar(require("./GridContainer"), exports);
18
18
  _exportStar(require("./GridItemContent"), exports);
19
+ _exportStar(require("./GridLayout"), exports);
20
+ _exportStar(require("./GridTitle"), exports);
19
21
  function _exportStar(from, to) {
20
22
  Object.keys(from).forEach(function(k) {
21
23
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
@@ -32,7 +32,8 @@ function _interopRequireDefault(obj) {
32
32
  };
33
33
  }
34
34
  const Panel = /*#__PURE__*/ (0, _react.memo)(function Panel(props) {
35
- const { definition , editHandlers , onMouseEnter , onMouseLeave , sx , ...others } = props;
35
+ var ref;
36
+ const { definition , editHandlers , onMouseEnter , onMouseLeave , sx , panelOptions , ...others } = props;
36
37
  // Make sure we have an ID we can use for aria attributes
37
38
  const generatedPanelId = (0, _components.useId)('Panel');
38
39
  const headerId = `${generatedPanelId}-header`;
@@ -50,7 +51,7 @@ const Panel = /*#__PURE__*/ (0, _react.memo)(function Panel(props) {
50
51
  width,
51
52
  height
52
53
  ]);
53
- const { ref , inView } = (0, _reactIntersectionObserver.useInView)({
54
+ const { ref: ref1 , inView } = (0, _reactIntersectionObserver.useInView)({
54
55
  threshold: 0.3,
55
56
  initialInView: false,
56
57
  triggerOnce: true
@@ -63,7 +64,7 @@ const Panel = /*#__PURE__*/ (0, _react.memo)(function Panel(props) {
63
64
  onMouseLeave === null || onMouseLeave === void 0 ? void 0 : onMouseLeave(e);
64
65
  };
65
66
  return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Card, {
66
- ref: ref,
67
+ ref: ref1,
67
68
  component: "section",
68
69
  sx: (0, _components.combineSx)({
69
70
  width: '100%',
@@ -80,6 +81,7 @@ const Panel = /*#__PURE__*/ (0, _react.memo)(function Panel(props) {
80
81
  ...others,
81
82
  children: [
82
83
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_panelHeader.PanelHeader, {
84
+ extra: panelOptions === null || panelOptions === void 0 ? void 0 : (ref = panelOptions.extra) === null || ref === void 0 ? void 0 : ref.call(panelOptions),
83
85
  id: headerId,
84
86
  title: definition.spec.display.name,
85
87
  description: definition.spec.display.description,
@@ -33,7 +33,7 @@ function _interopRequireDefault(obj) {
33
33
  default: obj
34
34
  };
35
35
  }
36
- function PanelHeader({ id , title: rawTitle , description: rawDescription , editHandlers , sx , ...rest }) {
36
+ function PanelHeader({ id , title: rawTitle , description: rawDescription , editHandlers , sx , extra , ...rest }) {
37
37
  const titleElementId = `${id}-title`;
38
38
  const descriptionTooltipId = `${id}-description`;
39
39
  const title = (0, _pluginSystem.useReplaceVariablesInString)(rawTitle);
@@ -140,11 +140,15 @@ function PanelHeader({ id , title: rawTitle , description: rawDescription , edit
140
140
  })
141
141
  ]
142
142
  }),
143
- action: /*#__PURE__*/ (0, _jsxRuntime.jsx)(HeaderActionWrapper, {
143
+ action: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(HeaderActionWrapper, {
144
144
  direction: "row",
145
145
  spacing: 0.25,
146
146
  alignItems: "center",
147
- children: actions
147
+ children: [
148
+ editHandlers === undefined && extra,
149
+ " ",
150
+ actions
151
+ ]
148
152
  }),
149
153
  sx: (0, _components.combineSx)((theme)=>({
150
154
  padding: theme.spacing(1),
@@ -22,8 +22,8 @@ const _jsxRuntime = require("react/jsx-runtime");
22
22
  const _react = require("react");
23
23
  const _material = require("@mui/material");
24
24
  const _core = require("@perses-dev/core");
25
+ const _pluginSystem = require("@perses-dev/plugin-system");
25
26
  const _context = require("../../context");
26
- const _variableModel = require("./variable-model");
27
27
  function TemplateVariable({ name }) {
28
28
  var ref;
29
29
  const ctx = (0, _context.useTemplateVariable)(name);
@@ -49,7 +49,7 @@ function ListVariable({ name }) {
49
49
  var ref, ref1, ref2, ref3;
50
50
  const ctx = (0, _context.useTemplateVariable)(name);
51
51
  const definition = ctx.definition;
52
- const variablesOptionsQuery = (0, _variableModel.useListVariablePluginValues)(definition);
52
+ const variablesOptionsQuery = (0, _pluginSystem.useListVariablePluginValues)(definition);
53
53
  const { setVariableValue , setVariableLoading , setVariableOptions } = (0, _context.useTemplateVariableActions)();
54
54
  const allowMultiple = (definition === null || definition === void 0 ? void 0 : definition.spec.allow_multiple) === true;
55
55
  const allowAllValue = (definition === null || definition === void 0 ? void 0 : definition.spec.allow_all_value) === true;
@@ -27,9 +27,8 @@ const _pencil = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/Pe
27
27
  const _trashCan = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/TrashCan"));
28
28
  const _arrowUp = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/ArrowUp"));
29
29
  const _arrowDown = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/ArrowDown"));
30
+ const _pluginSystem = require("@perses-dev/plugin-system");
30
31
  const _context = require("../../context");
31
- const _variableEditorForm = require("./VariableEditorForm");
32
- const _variableModel = require("./variable-model");
33
32
  function _interopRequireDefault(obj) {
34
33
  return obj && obj.__esModule ? obj : {
35
34
  default: obj
@@ -37,7 +36,7 @@ function _interopRequireDefault(obj) {
37
36
  }
38
37
  function getVariableLabelByKind(kind) {
39
38
  var ref;
40
- return (ref = _variableModel.VARIABLE_TYPES.find((variableType)=>variableType.kind === kind)) === null || ref === void 0 ? void 0 : ref.label;
39
+ return (ref = _pluginSystem.VARIABLE_TYPES.find((variableType)=>variableType.kind === kind)) === null || ref === void 0 ? void 0 : ref.label;
41
40
  }
42
41
  function getValidation(variableDefinitions) {
43
42
  const errors = [];
@@ -54,6 +53,7 @@ function getValidation(variableDefinitions) {
54
53
  function VariableEditor(props) {
55
54
  const [variableDefinitions, setVariableDefinitions] = (0, _useImmer.useImmer)(props.variableDefinitions);
56
55
  const [variableEditIdx, setVariableEditIdx] = (0, _react.useState)(null);
56
+ const [variableFormAction, setVariableFormAction] = (0, _react.useState)('update');
57
57
  const validation = (0, _react.useMemo)(()=>getValidation(variableDefinitions), [
58
58
  variableDefinitions
59
59
  ]);
@@ -81,6 +81,7 @@ function VariableEditor(props) {
81
81
  });
82
82
  };
83
83
  const addVariable = ()=>{
84
+ setVariableFormAction('create');
84
85
  setVariableDefinitions((draft)=>{
85
86
  draft.push({
86
87
  kind: 'TextVariable',
@@ -92,6 +93,10 @@ function VariableEditor(props) {
92
93
  });
93
94
  setVariableEditIdx(variableDefinitions.length);
94
95
  };
96
+ const editVariable = (index)=>{
97
+ setVariableFormAction('update');
98
+ setVariableEditIdx(index);
99
+ };
95
100
  const toggleVariableVisibility = (index, visible)=>{
96
101
  setVariableDefinitions((draft)=>{
97
102
  const v = draft[index];
@@ -131,7 +136,7 @@ function VariableEditor(props) {
131
136
  var ref;
132
137
  return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
133
138
  children: [
134
- currentEditingVariableDefinition && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_variableEditorForm.VariableEditForm, {
139
+ currentEditingVariableDefinition && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.VariableEditForm, {
135
140
  initialVariableDefinition: currentEditingVariableDefinition,
136
141
  onChange: (definition)=>{
137
142
  setVariableDefinitions((draft)=>{
@@ -139,7 +144,13 @@ function VariableEditor(props) {
139
144
  setVariableEditIdx(null);
140
145
  });
141
146
  },
142
- onCancel: ()=>setVariableEditIdx(null)
147
+ onCancel: ()=>{
148
+ if (variableFormAction === 'create') {
149
+ removeVariable(variableEditIdx);
150
+ }
151
+ setVariableEditIdx(null);
152
+ },
153
+ action: variableFormAction
143
154
  }),
144
155
  !currentEditingVariableDefinition && /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
145
156
  children: [
@@ -255,7 +266,7 @@ function VariableEditor(props) {
255
266
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_arrowDown.default, {})
256
267
  }),
257
268
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
258
- onClick: ()=>setVariableEditIdx(idx),
269
+ onClick: ()=>editVariable(idx),
259
270
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pencil.default, {})
260
271
  }),
261
272
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
@@ -17,9 +17,7 @@ Object.defineProperty(exports, "__esModule", {
17
17
  _exportStar(require("./EditVariablesButton"), exports);
18
18
  _exportStar(require("./TemplateVariable"), exports);
19
19
  _exportStar(require("./VariableEditor"), exports);
20
- _exportStar(require("./VariableEditorForm"), exports);
21
20
  _exportStar(require("./VariableList"), exports);
22
- _exportStar(require("./variable-model"), exports);
23
21
  function _exportStar(from, to) {
24
22
  Object.keys(from).forEach(function(k) {
25
23
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
@@ -31,6 +31,7 @@ const _middleware = require("zustand/middleware");
31
31
  const _immer = require("zustand/middleware/immer");
32
32
  const _shallow = require("zustand/shallow");
33
33
  const _react = require("react");
34
+ const _core = require("@perses-dev/core");
34
35
  const _pluginSystem = require("@perses-dev/plugin-system");
35
36
  const _panelGroupEditorSlice = require("./panel-group-editor-slice");
36
37
  const _panelGroupSlice = require("./panel-group-slice");
@@ -82,7 +83,7 @@ function DashboardProvider(props) {
82
83
  }
83
84
  function initStore(props) {
84
85
  const { initialState: { dashboardResource , isEditMode } , } = props;
85
- const { spec: { display , duration , refreshInterval } , metadata , } = dashboardResource;
86
+ const { spec: { display , duration , refreshInterval =_core.DEFAULT_REFRESH_INTERVAL } , metadata , } = dashboardResource;
86
87
  let { spec: { layouts , panels } , } = dashboardResource;
87
88
  // Set fallbacks in case the frontend is used with a non-Perses backend
88
89
  layouts = layouts !== null && layouts !== void 0 ? layouts : [];
@@ -117,7 +118,7 @@ function initStore(props) {
117
118
  state.panelGroups = panelGroups;
118
119
  state.panelGroupOrder = panelGroupOrder;
119
120
  state.duration = duration;
120
- state.refreshInterval = refreshInterval;
121
+ state.refreshInterval = refreshInterval !== null && refreshInterval !== void 0 ? refreshInterval : _core.DEFAULT_REFRESH_INTERVAL;
121
122
  });
122
123
  }
123
124
  };
@@ -23,26 +23,30 @@ const _react = require("react");
23
23
  const _core = require("@perses-dev/core");
24
24
  const _pluginSystem = require("@perses-dev/plugin-system");
25
25
  function DatasourceStoreProvider(props) {
26
- const { dashboardResource , datasourceApi , onCreate , children } = props;
27
- const { project } = dashboardResource.metadata;
26
+ const { dashboardResource , projectName , datasourceApi , onCreate , children } = props;
27
+ const project = projectName !== null && projectName !== void 0 ? projectName : dashboardResource === null || dashboardResource === void 0 ? void 0 : dashboardResource.metadata.project;
28
28
  const { getPlugin , listPluginMetadata } = (0, _pluginSystem.usePluginRegistry)();
29
29
  const findDatasource = (0, _core.useEvent)(async (selector)=>{
30
30
  // Try to find it in dashboard spec
31
- const { datasources } = dashboardResource.spec;
32
- const dashboardDatasource = findDashboardDatasource(datasources, selector);
33
- if (dashboardDatasource !== undefined) {
34
- return {
35
- spec: dashboardDatasource,
36
- proxyUrl: undefined
37
- };
31
+ if (dashboardResource) {
32
+ const { datasources } = dashboardResource.spec;
33
+ const dashboardDatasource = findDashboardDatasource(datasources, selector);
34
+ if (dashboardDatasource !== undefined) {
35
+ return {
36
+ spec: dashboardDatasource,
37
+ proxyUrl: undefined
38
+ };
39
+ }
38
40
  }
39
- // Try to find it at the project level as a Datasource resource
40
- const datasource = await datasourceApi.getDatasource(project, selector);
41
- if (datasource !== undefined) {
42
- return {
43
- spec: datasource.resource.spec,
44
- proxyUrl: datasource.proxyUrl
45
- };
41
+ if (project) {
42
+ // Try to find it at the project level as a Datasource resource
43
+ const datasource = await datasourceApi.getDatasource(project, selector);
44
+ if (datasource !== undefined) {
45
+ return {
46
+ spec: datasource.resource.spec,
47
+ proxyUrl: datasource.proxyUrl
48
+ };
49
+ }
46
50
  }
47
51
  // Try to find it at the global level as a GlobalDatasource resource
48
52
  const globalDatasource = await datasourceApi.getGlobalDatasource(selector);
@@ -84,7 +88,7 @@ function DatasourceStoreProvider(props) {
84
88
  const listDatasourceMetadata = (0, _core.useEvent)(async (datasourcePluginKind)=>{
85
89
  const [pluginMetadata, datasources, globalDatasources] = await Promise.all([
86
90
  listPluginMetadata('Datasource'),
87
- datasourceApi.listDatasources(project, datasourcePluginKind),
91
+ project ? datasourceApi.listDatasources(project, datasourcePluginKind) : [],
88
92
  datasourceApi.listGlobalDatasources(datasourcePluginKind)
89
93
  ]);
90
94
  // Find the metadata for the plugin type they asked for so we can use it for the name of the default datasource
@@ -95,7 +99,7 @@ function DatasourceStoreProvider(props) {
95
99
  // Get helper for de-duping results properly
96
100
  const { results , addResult } = buildListDatasourceMetadataResults(datasourcePluginMetadata.display.name);
97
101
  // Start with dashboard datasources that have highest precedence
98
- if (dashboardResource.spec.datasources !== undefined) {
102
+ if (dashboardResource === null || dashboardResource === void 0 ? void 0 : dashboardResource.spec.datasources) {
99
103
  for(const selectorName in dashboardResource.spec.datasources){
100
104
  const spec = dashboardResource.spec.datasources[selectorName];
101
105
  if (spec === undefined || spec.plugin.kind !== datasourcePluginKind) continue;
@@ -97,7 +97,7 @@ const DashboardApp = (props)=>{
97
97
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.PanelGroupDialog, {}),
98
98
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.DeletePanelGroupDialog, {}),
99
99
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.DeletePanelDialog, {}),
100
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.DiscardChangesConfirmationDialog, {}),
100
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.DashboardDiscardChangesConfirmationDialog, {}),
101
101
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.EditJsonDialog, {}),
102
102
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.SaveChangesConfirmationDialog, {})
103
103
  ]
@@ -20,6 +20,7 @@ Object.defineProperty(exports, "ViewDashboard", {
20
20
  });
21
21
  const _jsxRuntime = require("react/jsx-runtime");
22
22
  const _material = require("@mui/material");
23
+ const _core = require("@perses-dev/core");
23
24
  const _components = require("@perses-dev/components");
24
25
  const _pluginSystem = require("@perses-dev/plugin-system");
25
26
  const _context = require("../../context");
@@ -28,9 +29,9 @@ function ViewDashboard(props) {
28
29
  const { dashboardResource , datasourceApi , dashboardTitleComponent , emptyDashboardProps , onSave , onDiscard , initialVariableIsSticky , isReadonly , isEditing , sx , ...others } = props;
29
30
  const { spec } = dashboardResource;
30
31
  var _duration;
31
- const dashboardDuration = (_duration = spec.duration) !== null && _duration !== void 0 ? _duration : '1h';
32
+ const dashboardDuration = (_duration = spec.duration) !== null && _duration !== void 0 ? _duration : _core.DEFAULT_DASHBOARD_DURATION;
32
33
  var _refreshInterval;
33
- const dashhboardRefreshInterval = (_refreshInterval = spec.refreshInterval) !== null && _refreshInterval !== void 0 ? _refreshInterval : '0s';
34
+ const dashhboardRefreshInterval = (_refreshInterval = spec.refreshInterval) !== null && _refreshInterval !== void 0 ? _refreshInterval : _core.DEFAULT_REFRESH_INTERVAL;
34
35
  const initialTimeRange = (0, _pluginSystem.useInitialTimeRange)(dashboardDuration);
35
36
  const initialRefreshInterval = (0, _pluginSystem.useInitialRefreshInterval)(dashhboardRefreshInterval);
36
37
  return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_context.DatasourceStoreProvider, {
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { BoxProps } from '@mui/material';
3
3
  import { EmptyDashboardProps } from '../EmptyDashboard';
4
+ import { PanelOptions } from '../Panel';
4
5
  export declare type DashboardProps = BoxProps & {
5
6
  /**
6
7
  * Props for `EmptyDashboard` component that will be rendered when the dashboard
@@ -8,9 +9,10 @@ export declare type DashboardProps = BoxProps & {
8
9
  * be used.
9
10
  */
10
11
  emptyDashboardProps?: EmptyDashboardProps;
12
+ panelOptions?: PanelOptions;
11
13
  };
12
14
  /**
13
15
  * Renders a Dashboard for the provided Dashboard spec.
14
16
  */
15
- export declare function Dashboard({ emptyDashboardProps, ...boxProps }: DashboardProps): JSX.Element;
17
+ export declare function Dashboard({ emptyDashboardProps, panelOptions, ...boxProps }: DashboardProps): JSX.Element;
16
18
  //# sourceMappingURL=Dashboard.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Dashboard.d.ts","sourceRoot":"","sources":["../../../src/components/Dashboard/Dashboard.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAO,QAAQ,EAAE,MAAM,eAAe,CAAC;AAI9C,OAAO,EAAkB,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExE,oBAAY,cAAc,GAAG,QAAQ,GAAG;IACtC;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;CAC3C,CAAC;AAEF;;GAEG;AACH,wBAAgB,SAAS,CAAC,EAAE,mBAAmB,EAAE,GAAG,QAAQ,EAAE,EAAE,cAAc,eAgB7E"}
1
+ {"version":3,"file":"Dashboard.d.ts","sourceRoot":"","sources":["../../../src/components/Dashboard/Dashboard.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAO,QAAQ,EAAE,MAAM,eAAe,CAAC;AAI9C,OAAO,EAAkB,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,oBAAY,cAAc,GAAG,QAAQ,GAAG;IACtC;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,CAAC;AAEF;;GAEG;AACH,wBAAgB,SAAS,CAAC,EAAE,mBAAmB,EAAE,YAAY,EAAE,GAAG,QAAQ,EAAE,EAAE,cAAc,eAmB3F"}
@@ -18,7 +18,7 @@ import { GridLayout } from '../GridLayout';
18
18
  import { EmptyDashboard } from '../EmptyDashboard';
19
19
  /**
20
20
  * Renders a Dashboard for the provided Dashboard spec.
21
- */ export function Dashboard({ emptyDashboardProps , ...boxProps }) {
21
+ */ export function Dashboard({ emptyDashboardProps , panelOptions , ...boxProps }) {
22
22
  const panelGroupIds = usePanelGroupIds();
23
23
  const isEmpty = !panelGroupIds.length;
24
24
  return /*#__PURE__*/ _jsx(Box, {
@@ -40,7 +40,8 @@ import { EmptyDashboard } from '../EmptyDashboard';
40
40
  })
41
41
  }),
42
42
  !isEmpty && panelGroupIds.map((panelGroupId)=>/*#__PURE__*/ _jsx(GridLayout, {
43
- panelGroupId: panelGroupId
43
+ panelGroupId: panelGroupId,
44
+ panelOptions: panelOptions
44
45
  }, panelGroupId))
45
46
  ]
46
47
  })
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Dashboard/Dashboard.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 { Box, BoxProps } from '@mui/material';\nimport { ErrorBoundary, ErrorAlert } from '@perses-dev/components';\nimport { usePanelGroupIds } from '../../context';\nimport { GridLayout } from '../GridLayout';\nimport { EmptyDashboard, EmptyDashboardProps } from '../EmptyDashboard';\n\nexport type DashboardProps = BoxProps & {\n /**\n * Props for `EmptyDashboard` component that will be rendered when the dashboard\n * is empty (i.e. has no panel groups). If not specified, the defaults will\n * be used.\n */\n emptyDashboardProps?: EmptyDashboardProps;\n};\n\n/**\n * Renders a Dashboard for the provided Dashboard spec.\n */\nexport function Dashboard({ emptyDashboardProps, ...boxProps }: DashboardProps) {\n const panelGroupIds = usePanelGroupIds();\n const isEmpty = !panelGroupIds.length;\n\n return (\n <Box {...boxProps} sx={{ height: '100%' }}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n {isEmpty && (\n <Box sx={{ height: '100%', display: 'flex', alignItems: 'center' }}>\n <EmptyDashboard {...emptyDashboardProps} />\n </Box>\n )}\n {!isEmpty && panelGroupIds.map((panelGroupId) => <GridLayout key={panelGroupId} panelGroupId={panelGroupId} />)}\n </ErrorBoundary>\n </Box>\n );\n}\n"],"names":["Box","ErrorBoundary","ErrorAlert","usePanelGroupIds","GridLayout","EmptyDashboard","Dashboard","emptyDashboardProps","boxProps","panelGroupIds","isEmpty","length","sx","height","FallbackComponent","display","alignItems","map","panelGroupId"],"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,GAAG,QAAkB,eAAe,CAAC;AAC9C,SAASC,aAAa,EAAEC,UAAU,QAAQ,wBAAwB,CAAC;AACnE,SAASC,gBAAgB,QAAQ,eAAe,CAAC;AACjD,SAASC,UAAU,QAAQ,eAAe,CAAC;AAC3C,SAASC,cAAc,QAA6B,mBAAmB,CAAC;AAWxE;;CAEC,GACD,OAAO,SAASC,SAAS,CAAC,EAAEC,mBAAmB,CAAA,EAAE,GAAGC,QAAQ,EAAkB,EAAE;IAC9E,MAAMC,aAAa,GAAGN,gBAAgB,EAAE,AAAC;IACzC,MAAMO,OAAO,GAAG,CAACD,aAAa,CAACE,MAAM,AAAC;IAEtC,qBACE,KAACX,GAAG;QAAE,GAAGQ,QAAQ;QAAEI,EAAE,EAAE;YAAEC,MAAM,EAAE,MAAM;SAAE;kBACvC,cAAA,MAACZ,aAAa;YAACa,iBAAiB,EAAEZ,UAAU;;gBACzCQ,OAAO,kBACN,KAACV,GAAG;oBAACY,EAAE,EAAE;wBAAEC,MAAM,EAAE,MAAM;wBAAEE,OAAO,EAAE,MAAM;wBAAEC,UAAU,EAAE,QAAQ;qBAAE;8BAChE,cAAA,KAACX,cAAc;wBAAE,GAAGE,mBAAmB;sBAAI;kBACvC,AACP;gBACA,CAACG,OAAO,IAAID,aAAa,CAACQ,GAAG,CAAC,CAACC,YAAY,iBAAK,KAACd,UAAU;wBAAoBc,YAAY,EAAEA,YAAY;uBAAxCA,YAAY,CAAgC,CAAC;;UACjG;MACZ,CACN;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../../src/components/Dashboard/Dashboard.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 { Box, BoxProps } from '@mui/material';\nimport { ErrorBoundary, ErrorAlert } from '@perses-dev/components';\nimport { usePanelGroupIds } from '../../context';\nimport { GridLayout } from '../GridLayout';\nimport { EmptyDashboard, EmptyDashboardProps } from '../EmptyDashboard';\nimport { PanelOptions } from '../Panel';\nexport type DashboardProps = BoxProps & {\n /**\n * Props for `EmptyDashboard` component that will be rendered when the dashboard\n * is empty (i.e. has no panel groups). If not specified, the defaults will\n * be used.\n */\n emptyDashboardProps?: EmptyDashboardProps;\n panelOptions?: PanelOptions;\n};\n\n/**\n * Renders a Dashboard for the provided Dashboard spec.\n */\nexport function Dashboard({ emptyDashboardProps, panelOptions, ...boxProps }: DashboardProps) {\n const panelGroupIds = usePanelGroupIds();\n const isEmpty = !panelGroupIds.length;\n\n return (\n <Box {...boxProps} sx={{ height: '100%' }}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n {isEmpty && (\n <Box sx={{ height: '100%', display: 'flex', alignItems: 'center' }}>\n <EmptyDashboard {...emptyDashboardProps} />\n </Box>\n )}\n {!isEmpty &&\n panelGroupIds.map((panelGroupId) => (\n <GridLayout key={panelGroupId} panelGroupId={panelGroupId} panelOptions={panelOptions} />\n ))}\n </ErrorBoundary>\n </Box>\n );\n}\n"],"names":["Box","ErrorBoundary","ErrorAlert","usePanelGroupIds","GridLayout","EmptyDashboard","Dashboard","emptyDashboardProps","panelOptions","boxProps","panelGroupIds","isEmpty","length","sx","height","FallbackComponent","display","alignItems","map","panelGroupId"],"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,GAAG,QAAkB,eAAe,CAAC;AAC9C,SAASC,aAAa,EAAEC,UAAU,QAAQ,wBAAwB,CAAC;AACnE,SAASC,gBAAgB,QAAQ,eAAe,CAAC;AACjD,SAASC,UAAU,QAAQ,eAAe,CAAC;AAC3C,SAASC,cAAc,QAA6B,mBAAmB,CAAC;AAYxE;;CAEC,GACD,OAAO,SAASC,SAAS,CAAC,EAAEC,mBAAmB,CAAA,EAAEC,YAAY,CAAA,EAAE,GAAGC,QAAQ,EAAkB,EAAE;IAC5F,MAAMC,aAAa,GAAGP,gBAAgB,EAAE,AAAC;IACzC,MAAMQ,OAAO,GAAG,CAACD,aAAa,CAACE,MAAM,AAAC;IAEtC,qBACE,KAACZ,GAAG;QAAE,GAAGS,QAAQ;QAAEI,EAAE,EAAE;YAAEC,MAAM,EAAE,MAAM;SAAE;kBACvC,cAAA,MAACb,aAAa;YAACc,iBAAiB,EAAEb,UAAU;;gBACzCS,OAAO,kBACN,KAACX,GAAG;oBAACa,EAAE,EAAE;wBAAEC,MAAM,EAAE,MAAM;wBAAEE,OAAO,EAAE,MAAM;wBAAEC,UAAU,EAAE,QAAQ;qBAAE;8BAChE,cAAA,KAACZ,cAAc;wBAAE,GAAGE,mBAAmB;sBAAI;kBACvC,AACP;gBACA,CAACI,OAAO,IACPD,aAAa,CAACQ,GAAG,CAAC,CAACC,YAAY,iBAC7B,KAACf,UAAU;wBAAoBe,YAAY,EAAEA,YAAY;wBAAEX,YAAY,EAAEA,YAAY;uBAApEW,YAAY,CAA4D,AAC1F,CAAC;;UACU;MACZ,CACN;AACJ,CAAC"}
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
- export declare const DiscardChangesConfirmationDialog: () => JSX.Element;
2
+ export declare const DashboardDiscardChangesConfirmationDialog: () => JSX.Element | null;
3
3
  //# sourceMappingURL=DiscardChangesConfirmationDialog.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DiscardChangesConfirmationDialog.d.ts","sourceRoot":"","sources":["../../../src/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.tsx"],"names":[],"mappings":";AAiBA,eAAO,MAAM,gCAAgC,mBAoC5C,CAAC"}
1
+ {"version":3,"file":"DiscardChangesConfirmationDialog.d.ts","sourceRoot":"","sources":["../../../src/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.tsx"],"names":[],"mappings":";AAgBA,eAAO,MAAM,yCAAyC,0BAgBrD,CAAC"}
@@ -10,54 +10,19 @@
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, 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';
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { DiscardChangesConfirmationDialog } from '@perses-dev/components';
16
15
  import { useDiscardChangesConfirmationDialog } from '../../context';
17
- export const DiscardChangesConfirmationDialog = ()=>{
16
+ export const DashboardDiscardChangesConfirmationDialog = ()=>{
18
17
  const { discardChangesConfirmationDialog: dialog } = useDiscardChangesConfirmationDialog();
19
- const isOpen = dialog !== undefined;
20
- return /*#__PURE__*/ _jsx(Dialog, {
21
- open: isOpen,
22
- children: dialog !== undefined && /*#__PURE__*/ _jsxs(_Fragment, {
23
- children: [
24
- /*#__PURE__*/ _jsx(DialogTitle, {
25
- children: "Discard Changes"
26
- }),
27
- /*#__PURE__*/ _jsx(IconButton, {
28
- "aria-label": "Close",
29
- onClick: dialog.onCancel,
30
- sx: (theme)=>({
31
- position: 'absolute',
32
- top: theme.spacing(0.5),
33
- right: theme.spacing(0.5)
34
- }),
35
- children: /*#__PURE__*/ _jsx(CloseIcon, {})
36
- }),
37
- /*#__PURE__*/ _jsx(DialogContent, {
38
- dividers: true,
39
- sx: {
40
- width: '500px'
41
- },
42
- children: dialog.description || 'You have unsaved changes in this dashboard. Are you sure you want to discard these changes? Changes cannot be recovered.'
43
- }),
44
- /*#__PURE__*/ _jsxs(DialogActions, {
45
- children: [
46
- /*#__PURE__*/ _jsx(Button, {
47
- variant: "contained",
48
- onClick: dialog.onDiscardChanges,
49
- children: "Discard Changes"
50
- }),
51
- /*#__PURE__*/ _jsx(Button, {
52
- variant: "outlined",
53
- color: "secondary",
54
- onClick: dialog.onCancel,
55
- children: "Cancel"
56
- })
57
- ]
58
- })
59
- ]
60
- })
18
+ if (dialog === undefined) {
19
+ return null;
20
+ }
21
+ return /*#__PURE__*/ _jsx(DiscardChangesConfirmationDialog, {
22
+ description: dialog.description || 'You have unsaved changes in this dashboard. Are you sure you want to discard these changes? Changes cannot be recovered.',
23
+ isOpen: true,
24
+ onCancel: dialog.onCancel,
25
+ onDiscardChanges: dialog.onDiscardChanges
61
26
  });
62
27
  };
63
28
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.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 { useDiscardChangesConfirmationDialog } from '../../context';\n\nexport const DiscardChangesConfirmationDialog = () => {\n const { discardChangesConfirmationDialog: dialog } = useDiscardChangesConfirmationDialog();\n const isOpen = dialog !== undefined;\n\n return (\n <Dialog open={isOpen}>\n {dialog !== undefined && (\n <>\n <DialogTitle>Discard Changes</DialogTitle>\n <IconButton\n aria-label=\"Close\"\n onClick={dialog.onCancel}\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 {dialog.description ||\n 'You have unsaved changes in this dashboard. Are you sure you want to discard these changes? Changes cannot be recovered.'}\n </DialogContent>\n <DialogActions>\n <Button variant=\"contained\" onClick={dialog.onDiscardChanges}>\n Discard Changes\n </Button>\n <Button variant=\"outlined\" color=\"secondary\" onClick={dialog.onCancel}>\n Cancel\n </Button>\n </DialogActions>\n </>\n )}\n </Dialog>\n );\n};\n"],"names":["IconButton","Dialog","DialogTitle","DialogContent","DialogActions","Button","CloseIcon","useDiscardChangesConfirmationDialog","DiscardChangesConfirmationDialog","discardChangesConfirmationDialog","dialog","isOpen","undefined","open","aria-label","onClick","onCancel","sx","theme","position","top","spacing","right","dividers","width","description","variant","onDiscardChanges","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;AAAA,SAASA,UAAU,EAAEC,MAAM,EAAEC,WAAW,EAAEC,aAAa,EAAEC,aAAa,EAAEC,MAAM,QAAQ,eAAe,CAAC;AACtG,OAAOC,SAAS,MAAM,uBAAuB,CAAC;AAC9C,SAASC,mCAAmC,QAAQ,eAAe,CAAC;AAEpE,OAAO,MAAMC,gCAAgC,GAAG,IAAM;IACpD,MAAM,EAAEC,gCAAgC,EAAEC,MAAM,CAAA,EAAE,GAAGH,mCAAmC,EAAE,AAAC;IAC3F,MAAMI,MAAM,GAAGD,MAAM,KAAKE,SAAS,AAAC;IAEpC,qBACE,KAACX,MAAM;QAACY,IAAI,EAAEF,MAAM;kBACjBD,MAAM,KAAKE,SAAS,kBACnB;;8BACE,KAACV,WAAW;8BAAC,iBAAe;kBAAc;8BAC1C,KAACF,UAAU;oBACTc,YAAU,EAAC,OAAO;oBAClBC,OAAO,EAAEL,MAAM,CAACM,QAAQ;oBACxBC,EAAE,EAAE,CAACC,KAAK,GAAM,CAAA;4BACdC,QAAQ,EAAE,UAAU;4BACpBC,GAAG,EAAEF,KAAK,CAACG,OAAO,CAAC,GAAG,CAAC;4BACvBC,KAAK,EAAEJ,KAAK,CAACG,OAAO,CAAC,GAAG,CAAC;yBAC1B,CAAA,AAAC;8BAEF,cAAA,KAACf,SAAS,KAAG;kBACF;8BACb,KAACH,aAAa;oBAACoB,QAAQ;oBAACN,EAAE,EAAE;wBAAEO,KAAK,EAAE,OAAO;qBAAE;8BAC3Cd,MAAM,CAACe,WAAW,IACjB,0HAA0H;kBAC9G;8BAChB,MAACrB,aAAa;;sCACZ,KAACC,MAAM;4BAACqB,OAAO,EAAC,WAAW;4BAACX,OAAO,EAAEL,MAAM,CAACiB,gBAAgB;sCAAE,iBAE9D;0BAAS;sCACT,KAACtB,MAAM;4BAACqB,OAAO,EAAC,UAAU;4BAACE,KAAK,EAAC,WAAW;4BAACb,OAAO,EAAEL,MAAM,CAACM,QAAQ;sCAAE,QAEvE;0BAAS;;kBACK;;UACf,AACJ;MACM,CACT;AACJ,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../../src/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.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 { DiscardChangesConfirmationDialog } from '@perses-dev/components';\nimport { useDiscardChangesConfirmationDialog } from '../../context';\n\nexport const DashboardDiscardChangesConfirmationDialog = () => {\n const { discardChangesConfirmationDialog: dialog } = useDiscardChangesConfirmationDialog();\n if (dialog === undefined) {\n return null;\n }\n return (\n <DiscardChangesConfirmationDialog\n description={\n dialog.description ||\n 'You have unsaved changes in this dashboard. Are you sure you want to discard these changes? Changes cannot be recovered.'\n }\n isOpen={true}\n onCancel={dialog.onCancel}\n onDiscardChanges={dialog.onDiscardChanges}\n />\n );\n};\n"],"names":["DiscardChangesConfirmationDialog","useDiscardChangesConfirmationDialog","DashboardDiscardChangesConfirmationDialog","discardChangesConfirmationDialog","dialog","undefined","description","isOpen","onCancel","onDiscardChanges"],"mappings":"AAAA,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,gCAAgC,QAAQ,wBAAwB,CAAC;AAC1E,SAASC,mCAAmC,QAAQ,eAAe,CAAC;AAEpE,OAAO,MAAMC,yCAAyC,GAAG,IAAM;IAC7D,MAAM,EAAEC,gCAAgC,EAAEC,MAAM,CAAA,EAAE,GAAGH,mCAAmC,EAAE,AAAC;IAC3F,IAAIG,MAAM,KAAKC,SAAS,EAAE;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,qBACE,KAACL,gCAAgC;QAC/BM,WAAW,EACTF,MAAM,CAACE,WAAW,IAClB,0HAA0H;QAE5HC,MAAM,EAAE,IAAI;QACZC,QAAQ,EAAEJ,MAAM,CAACI,QAAQ;QACzBC,gBAAgB,EAAEL,MAAM,CAACK,gBAAgB;MACzC,CACF;AACJ,CAAC,CAAC"}
@@ -44,7 +44,8 @@ const EditJsonDialogForm = ()=>{
44
44
  setTimeRange({
45
45
  pastDuration: draftDashboard.spec.duration
46
46
  });
47
- setRefreshInterval(draftDashboard.spec.refreshInterval);
47
+ var _refreshInterval;
48
+ setRefreshInterval((_refreshInterval = draftDashboard.spec.refreshInterval) !== null && _refreshInterval !== void 0 ? _refreshInterval : '0s');
48
49
  closeEditJsonDialog();
49
50
  };
50
51
  return /*#__PURE__*/ _jsxs(Dialog.Form, {