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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/dist/cjs/components/GridLayout/GridItemContent.js +3 -3
  2. package/dist/cjs/components/GridLayout/GridLayout.js +1 -1
  3. package/dist/cjs/components/Panel/Panel.js +4 -3
  4. package/dist/cjs/components/Panel/PanelHeader.js +1 -9
  5. package/dist/cjs/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +18 -6
  6. package/dist/cjs/components/SaveDashboardButton/SaveDashboardButton.js +11 -6
  7. package/dist/cjs/components/Variables/Variable.js +34 -0
  8. package/dist/cjs/components/Variables/VariableList.js +2 -2
  9. package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +1 -1
  10. package/dist/cjs/context/DashboardProvider/delete-panel-slice.js +1 -1
  11. package/dist/cjs/context/DashboardProvider/duplicate-panel-slice.js +1 -1
  12. package/dist/cjs/context/DashboardProvider/index.js +1 -1
  13. package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +1 -1
  14. package/dist/cjs/context/DashboardProvider/panel-group-slice.js +1 -7
  15. package/dist/cjs/context/DashboardProvider/view-panel-slice.js +1 -1
  16. package/dist/cjs/context/DatasourceStoreProvider.js +3 -4
  17. package/dist/cjs/context/VariableProvider/VariableProvider.js +1 -1
  18. package/dist/cjs/context/VariableProvider/hydrationUtils.js +1 -1
  19. package/dist/cjs/context/VariableProvider/index.js +1 -1
  20. package/dist/cjs/context/VariableProvider/utils.js +1 -1
  21. package/dist/cjs/context/useDashboard.js +1 -1
  22. package/dist/cjs/utils/panelUtils.js +1 -1
  23. package/dist/components/GridLayout/GridItemContent.d.ts +1 -1
  24. package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
  25. package/dist/components/GridLayout/GridItemContent.js +2 -2
  26. package/dist/components/GridLayout/GridItemContent.js.map +1 -1
  27. package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
  28. package/dist/components/GridLayout/GridLayout.js +1 -1
  29. package/dist/components/GridLayout/GridLayout.js.map +1 -1
  30. package/dist/components/GridLayout/Row.d.ts +2 -2
  31. package/dist/components/GridLayout/Row.d.ts.map +1 -1
  32. package/dist/components/GridLayout/Row.js.map +1 -1
  33. package/dist/components/Panel/Panel.d.ts +1 -2
  34. package/dist/components/Panel/Panel.d.ts.map +1 -1
  35. package/dist/components/Panel/Panel.js +5 -4
  36. package/dist/components/Panel/Panel.js.map +1 -1
  37. package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
  38. package/dist/components/Panel/PanelHeader.js +2 -10
  39. package/dist/components/Panel/PanelHeader.js.map +1 -1
  40. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.d.ts.map +1 -1
  41. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +19 -7
  42. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +1 -1
  43. package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts.map +1 -1
  44. package/dist/components/SaveDashboardButton/SaveDashboardButton.js +11 -6
  45. package/dist/components/SaveDashboardButton/SaveDashboardButton.js.map +1 -1
  46. package/dist/components/Variables/EditVariablesButton.d.ts.map +1 -1
  47. package/dist/components/Variables/EditVariablesButton.js.map +1 -1
  48. package/dist/components/Variables/Variable.js +37 -2
  49. package/dist/components/Variables/Variable.js.map +1 -1
  50. package/dist/components/Variables/VariableEditor.d.ts +1 -2
  51. package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
  52. package/dist/components/Variables/VariableEditor.js.map +1 -1
  53. package/dist/components/Variables/VariableList.d.ts.map +1 -1
  54. package/dist/components/Variables/VariableList.js +2 -2
  55. package/dist/components/Variables/VariableList.js.map +1 -1
  56. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +1 -2
  57. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
  58. package/dist/context/DashboardProvider/dashboard-provider-api.js +1 -1
  59. package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
  60. package/dist/context/DashboardProvider/delete-panel-slice.d.ts +2 -1
  61. package/dist/context/DashboardProvider/delete-panel-slice.d.ts.map +1 -1
  62. package/dist/context/DashboardProvider/delete-panel-slice.js +1 -1
  63. package/dist/context/DashboardProvider/delete-panel-slice.js.map +1 -1
  64. package/dist/context/DashboardProvider/duplicate-panel-slice.d.ts +2 -1
  65. package/dist/context/DashboardProvider/duplicate-panel-slice.d.ts.map +1 -1
  66. package/dist/context/DashboardProvider/duplicate-panel-slice.js +1 -1
  67. package/dist/context/DashboardProvider/duplicate-panel-slice.js.map +1 -1
  68. package/dist/context/DashboardProvider/index.d.ts +0 -1
  69. package/dist/context/DashboardProvider/index.d.ts.map +1 -1
  70. package/dist/context/DashboardProvider/index.js +1 -1
  71. package/dist/context/DashboardProvider/index.js.map +1 -1
  72. package/dist/context/DashboardProvider/panel-editor-slice.d.ts +2 -2
  73. package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
  74. package/dist/context/DashboardProvider/panel-editor-slice.js +1 -1
  75. package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
  76. package/dist/context/DashboardProvider/panel-group-slice.d.ts +1 -24
  77. package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
  78. package/dist/context/DashboardProvider/panel-group-slice.js +1 -6
  79. package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
  80. package/dist/context/DashboardProvider/save-changes-dialog-slice.d.ts +2 -1
  81. package/dist/context/DashboardProvider/save-changes-dialog-slice.d.ts.map +1 -1
  82. package/dist/context/DashboardProvider/save-changes-dialog-slice.js.map +1 -1
  83. package/dist/context/DashboardProvider/view-panel-slice.d.ts +1 -1
  84. package/dist/context/DashboardProvider/view-panel-slice.d.ts.map +1 -1
  85. package/dist/context/DashboardProvider/view-panel-slice.js +1 -1
  86. package/dist/context/DashboardProvider/view-panel-slice.js.map +1 -1
  87. package/dist/context/DatasourceStoreProvider.d.ts +1 -17
  88. package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
  89. package/dist/context/DatasourceStoreProvider.js +2 -3
  90. package/dist/context/DatasourceStoreProvider.js.map +1 -1
  91. package/dist/context/VariableProvider/VariableProvider.d.ts +1 -10
  92. package/dist/context/VariableProvider/VariableProvider.d.ts.map +1 -1
  93. package/dist/context/VariableProvider/VariableProvider.js +1 -1
  94. package/dist/context/VariableProvider/VariableProvider.js.map +1 -1
  95. package/dist/context/VariableProvider/hydrationUtils.d.ts +1 -2
  96. package/dist/context/VariableProvider/hydrationUtils.d.ts.map +1 -1
  97. package/dist/context/VariableProvider/hydrationUtils.js +1 -1
  98. package/dist/context/VariableProvider/hydrationUtils.js.map +1 -1
  99. package/dist/context/VariableProvider/index.js +1 -1
  100. package/dist/context/VariableProvider/index.js.map +1 -1
  101. package/dist/context/VariableProvider/utils.d.ts +1 -2
  102. package/dist/context/VariableProvider/utils.d.ts.map +1 -1
  103. package/dist/context/VariableProvider/utils.js +1 -1
  104. package/dist/context/VariableProvider/utils.js.map +1 -1
  105. package/dist/context/useDashboard.d.ts.map +1 -1
  106. package/dist/context/useDashboard.js +1 -1
  107. package/dist/context/useDashboard.js.map +1 -1
  108. package/dist/utils/panelUtils.d.ts +1 -2
  109. package/dist/utils/panelUtils.d.ts.map +1 -1
  110. package/dist/utils/panelUtils.js +1 -1
  111. package/dist/utils/panelUtils.js.map +1 -1
  112. package/package.json +5 -5
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright 2025 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -25,9 +25,9 @@ const _material = require("@mui/material");
25
25
  const _reactintersectionobserver = require("react-intersection-observer");
26
26
  const _pluginsystem = require("@perses-dev/plugin-system");
27
27
  const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
28
+ const _core = require("@perses-dev/core");
28
29
  const _context = require("../../context");
29
30
  const _Panel = require("../Panel");
30
- const _panelgroupslice = require("../../context/DashboardProvider/panel-group-slice");
31
31
  const _QueryViewerDialog = require("../QueryViewerDialog");
32
32
  function _getRequireWildcardCache(nodeInterop) {
33
33
  if (typeof WeakMap !== "function") return null;
@@ -94,7 +94,7 @@ function GridItemContent(props) {
94
94
  queries
95
95
  ]);
96
96
  const readHandlers = {
97
- isPanelViewed: (0, _panelgroupslice.isPanelGroupItemIdEqual)(viewPanelGroupItemId, panelGroupItemId),
97
+ isPanelViewed: (0, _core.isPanelGroupItemIdEqual)(viewPanelGroupItemId, panelGroupItemId),
98
98
  onViewPanelClick: function() {
99
99
  if (viewPanelGroupItemId === undefined) {
100
100
  viewPanel(panelGroupItemId);
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright 2025 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright 2025 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -52,7 +52,6 @@ const Panel = /*#__PURE__*/ (0, _react.memo)(function Panel(props) {
52
52
  width,
53
53
  height
54
54
  ]);
55
- const chartsTheme = (0, _components.useChartsTheme)();
56
55
  const { queryResults } = (0, _pluginsystem.useDataQueriesContext)();
57
56
  const { getPlugin } = (0, _pluginsystem.usePluginRegistry)();
58
57
  const panelPropsForActions = (0, _react.useMemo)(()=>{
@@ -179,7 +178,9 @@ const Panel = /*#__PURE__*/ (0, _react.memo)(function Panel(props) {
179
178
  pluginActions: pluginActions,
180
179
  showIcons: showIcons,
181
180
  sx: {
182
- paddingX: `${chartsTheme.container.padding.default}px`
181
+ py: '2px',
182
+ pl: '8px',
183
+ pr: '2px'
183
184
  },
184
185
  dimension: contentDimensions
185
186
  }),
@@ -33,15 +33,7 @@ function PanelHeader({ id, title: rawTitle, description: rawDescription, links,
33
33
  const title = (0, _pluginsystem.useReplaceVariablesInString)(rawTitle);
34
34
  const description = (0, _pluginsystem.useReplaceVariablesInString)(rawDescription);
35
35
  const textRef = (0, _react.useRef)(null);
36
- const [isEllipsisActive, setIsEllipsisActive] = (0, _react.useState)(false);
37
- (0, _react.useEffect)(()=>{
38
- if (textRef.current && dimension?.width) {
39
- setIsEllipsisActive(textRef.current.scrollWidth > textRef.current.clientWidth);
40
- }
41
- }, [
42
- title,
43
- dimension?.width
44
- ]);
36
+ const isEllipsisActive = textRef.current && dimension?.width ? textRef.current.scrollWidth > textRef.current.clientWidth : false;
45
37
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.CardHeader, {
46
38
  id: id,
47
39
  component: "header",
@@ -32,15 +32,19 @@ const SaveChangesConfirmationDialog = ()=>{
32
32
  const { saveChangesConfirmationDialog: dialog } = (0, _context.useSaveChangesConfirmationDialog)();
33
33
  const isSavedDurationModified = dialog?.isSavedDurationModified ?? true;
34
34
  const isSavedVariableModified = dialog?.isSavedVariableModified ?? true;
35
+ const isSavedRefreshIntervalModified = dialog?.isSavedRefreshIntervalModified ?? true;
35
36
  const [saveDefaultTimeRange, setSaveDefaultTimeRange] = (0, _react.useState)(isSavedDurationModified);
36
37
  const [saveDefaultVariables, setSaveDefaultVariables] = (0, _react.useState)(isSavedVariableModified);
38
+ const [saveDefaultRefreshInterval, setDefaultRefreshInterval] = (0, _react.useState)(isSavedRefreshIntervalModified);
37
39
  const { getSavedVariablesStatus } = (0, _context.useVariableDefinitionActions)();
38
40
  const { modifiedVariableNames } = getSavedVariablesStatus();
39
41
  const isOpen = dialog !== undefined;
40
- const { timeRange } = (0, _pluginsystem.useTimeRange)();
42
+ const { timeRange, refreshInterval } = (0, _pluginsystem.useTimeRange)();
41
43
  const currentTimeRangeText = (0, _core.isRelativeTimeRange)(timeRange) ? `(Last ${timeRange.pastDuration})` : '(Absolute time ranges can not be saved)';
42
- const saveTimeRangeText = `Save current time range as new default ${currentTimeRangeText}`;
43
- const saveVariablesText = `Save current variable values as new default (${modifiedVariableNames.length > 0 ? modifiedVariableNames.join(', ') : 'No modified variables'})`;
44
+ const saveTimeRangeMessage = `Save current time range as new default ${currentTimeRangeText}`;
45
+ const saveVariableMessage = `Save current variable values as new default (${modifiedVariableNames.length > 0 ? modifiedVariableNames.join(', ') : 'No modified variables'})`;
46
+ const refreshIntervalDisplay = _pluginsystem.DEFAULT_REFRESH_INTERVAL_OPTIONS.some((i)=>i.display === refreshInterval) ? refreshInterval : _pluginsystem.DEFAULT_REFRESH_INTERVAL_OPTIONS.find((i)=>i.value.pastDuration === refreshInterval)?.display;
47
+ const saveRefreshIntervalMessage = `Save current refresh interval as new default ${refreshIntervalDisplay ? `(${refreshIntervalDisplay})` : 'refresh interval not modified'}`;
44
48
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.Dialog, {
45
49
  open: isOpen,
46
50
  children: dialog !== undefined && /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
@@ -63,7 +67,15 @@ const SaveChangesConfirmationDialog = ()=>{
63
67
  checked: saveDefaultTimeRange && isSavedDurationModified && (0, _core.isRelativeTimeRange)(timeRange),
64
68
  onChange: (e)=>setSaveDefaultTimeRange(e.target.checked)
65
69
  }),
66
- label: saveTimeRangeText
70
+ label: saveTimeRangeMessage
71
+ }),
72
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.FormControlLabel, {
73
+ control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Checkbox, {
74
+ disabled: !isSavedRefreshIntervalModified,
75
+ checked: saveDefaultRefreshInterval && isSavedRefreshIntervalModified,
76
+ onChange: (e)=>setDefaultRefreshInterval(e.target.checked)
77
+ }),
78
+ label: saveRefreshIntervalMessage
67
79
  }),
68
80
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.FormControlLabel, {
69
81
  control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Checkbox, {
@@ -71,7 +83,7 @@ const SaveChangesConfirmationDialog = ()=>{
71
83
  checked: saveDefaultVariables && isSavedVariableModified,
72
84
  onChange: (e)=>setSaveDefaultVariables(e.target.checked)
73
85
  }),
74
- label: saveVariablesText
86
+ label: saveVariableMessage
75
87
  })
76
88
  ]
77
89
  })
@@ -81,7 +93,7 @@ const SaveChangesConfirmationDialog = ()=>{
81
93
  children: [
82
94
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.Dialog.PrimaryButton, {
83
95
  onClick: ()=>{
84
- return dialog.onSaveChanges(saveDefaultTimeRange, saveDefaultVariables);
96
+ return dialog.onSaveChanges(saveDefaultTimeRange, saveDefaultRefreshInterval, saveDefaultVariables);
85
97
  },
86
98
  children: "Save Changes"
87
99
  }),
@@ -31,24 +31,28 @@ const SaveDashboardButton = ({ onSave, isDisabled, variant = 'contained' })=>{
31
31
  const { dashboard, setDashboard } = (0, _context.useDashboard)();
32
32
  const { getSavedVariablesStatus, setVariableDefaultValues } = (0, _context.useVariableDefinitionActions)();
33
33
  const { isSavedVariableModified } = getSavedVariablesStatus();
34
- const { timeRange } = (0, _pluginsystem.useTimeRange)();
34
+ const { timeRange, refreshInterval } = (0, _pluginsystem.useTimeRange)();
35
35
  const { setEditMode } = (0, _context.useEditMode)();
36
36
  const { openSaveChangesConfirmationDialog, closeSaveChangesConfirmationDialog } = (0, _context.useSaveChangesConfirmationDialog)();
37
37
  const onSaveButtonClick = ()=>{
38
38
  const isSavedDurationModified = (0, _core.isRelativeTimeRange)(timeRange) && dashboard.spec.duration !== timeRange.pastDuration;
39
+ const isSavedRefreshIntervalModified = dashboard.spec.refreshInterval !== refreshInterval;
39
40
  // Save dashboard
40
41
  // - if active timeRange from plugin-system is relative and different from currently saved
41
42
  // - or if the saved variables are different from currently saved
42
- if (isSavedDurationModified || isSavedVariableModified) {
43
+ if (isSavedDurationModified || isSavedVariableModified || isSavedRefreshIntervalModified) {
43
44
  openSaveChangesConfirmationDialog({
44
- onSaveChanges: (saveDefaultTimeRange, saveDefaultVariables)=>{
45
- if ((0, _core.isRelativeTimeRange)(timeRange) && saveDefaultTimeRange === true) {
45
+ onSaveChanges: (saveDefaultTimeRange, saveDefaultRefreshInterval, saveDefaultVariables)=>{
46
+ if ((0, _core.isRelativeTimeRange)(timeRange) && saveDefaultTimeRange) {
46
47
  dashboard.spec.duration = timeRange.pastDuration;
47
48
  }
48
- if (saveDefaultVariables === true) {
49
+ if (saveDefaultVariables) {
49
50
  const variables = setVariableDefaultValues();
50
51
  dashboard.spec.variables = variables;
51
52
  }
53
+ if (saveDefaultRefreshInterval && isSavedRefreshIntervalModified) {
54
+ dashboard.spec.refreshInterval = refreshInterval;
55
+ }
52
56
  setDashboard(dashboard);
53
57
  saveDashboard();
54
58
  },
@@ -56,7 +60,8 @@ const SaveDashboardButton = ({ onSave, isDisabled, variant = 'contained' })=>{
56
60
  closeSaveChangesConfirmationDialog();
57
61
  },
58
62
  isSavedDurationModified,
59
- isSavedVariableModified
63
+ isSavedVariableModified,
64
+ isSavedRefreshIntervalModified
60
65
  });
61
66
  } else {
62
67
  saveDashboard();
@@ -338,6 +338,40 @@ function ListVariable({ name, source }) {
338
338
  option.label
339
339
  ]
340
340
  }, key);
341
+ },
342
+ renderTags: (value, getTagProps, ownerState)=>{
343
+ // When focused, if there are too much value selected, it will use all screen place. Putting limit to 200px (~6 lines of chips)
344
+ if (ownerState.focused) {
345
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
346
+ sx: {
347
+ maxHeight: 200,
348
+ overflowY: 'auto'
349
+ },
350
+ children: value.map((option, index)=>/*#__PURE__*/ (0, _react.createElement)(_material.Chip, {
351
+ ...getTagProps({
352
+ index
353
+ }),
354
+ key: index,
355
+ label: option.label,
356
+ size: "small"
357
+ }))
358
+ });
359
+ }
360
+ const limitTags = ownerState.limitTags;
361
+ const numTags = value.length;
362
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
363
+ children: [
364
+ value.slice(0, limitTags).map((option, index)=>/*#__PURE__*/ (0, _react.createElement)(_material.Chip, {
365
+ ...getTagProps({
366
+ index
367
+ }),
368
+ key: index,
369
+ label: option.label,
370
+ size: "small"
371
+ })),
372
+ limitTags && numTags > limitTags && ` +${numTags - limitTags}`
373
+ ]
374
+ });
341
375
  }
342
376
  });
343
377
  }, [
@@ -63,6 +63,6 @@ function VariableListItem({ spec, source }) {
63
63
  children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Variable.Variable, {
64
64
  name: spec.name,
65
65
  source: source
66
- }, (spec.name + source) ?? '')
67
- }, (spec.name + source) ?? '');
66
+ }, spec.name + (source ?? ''))
67
+ }, spec.name + (source ?? ''));
68
68
  }
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright 2025 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright 2025 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright 2025 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright 2025 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright 2025 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright 2025 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -32,16 +32,10 @@ _export(exports, {
32
32
  },
33
33
  createPanelGroupSlice: function() {
34
34
  return createPanelGroupSlice;
35
- },
36
- isPanelGroupItemIdEqual: function() {
37
- return isPanelGroupItemIdEqual;
38
35
  }
39
36
  });
40
37
  const _core = require("@perses-dev/core");
41
38
  const _common = require("./common");
42
- function isPanelGroupItemIdEqual(a, b) {
43
- return a?.panelGroupId === b?.panelGroupId && a?.panelGroupItemLayoutId === b?.panelGroupItemLayoutId;
44
- }
45
39
  function createPanelGroupSlice(layouts) {
46
40
  const { panelGroups, panelGroupOrder } = convertLayoutsToPanelGroups(layouts);
47
41
  // Return the state creator function for Zustand
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright 2025 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright 2025 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -22,7 +22,6 @@ Object.defineProperty(exports, "DatasourceStoreProvider", {
22
22
  });
23
23
  const _jsxruntime = require("react/jsx-runtime");
24
24
  const _react = require("react");
25
- const _core = require("@perses-dev/core");
26
25
  const _pluginsystem = require("@perses-dev/plugin-system");
27
26
  function DatasourceStoreProvider(props) {
28
27
  const { projectName, datasourceApi, onCreate, children } = props;
@@ -30,7 +29,7 @@ function DatasourceStoreProvider(props) {
30
29
  const [savedDatasources, setSavedDatasources] = (0, _react.useState)(props.savedDatasources ?? {});
31
30
  const project = projectName ?? dashboardResource?.metadata.project;
32
31
  const { getPlugin, listPluginMetadata } = (0, _pluginsystem.usePluginRegistry)();
33
- const findDatasource = (0, _core.useEvent)(async (selector)=>{
32
+ const findDatasource = (0, _pluginsystem.useEvent)(async (selector)=>{
34
33
  // Try to find it in dashboard spec
35
34
  if (dashboardResource) {
36
35
  const { datasources } = dashboardResource.spec;
@@ -98,7 +97,7 @@ function DatasourceStoreProvider(props) {
98
97
  getPlugin,
99
98
  onCreate
100
99
  ]);
101
- const listDatasourceSelectItems = (0, _core.useEvent)(async (datasourcePluginName)=>{
100
+ const listDatasourceSelectItems = (0, _pluginsystem.useEvent)(async (datasourcePluginName)=>{
102
101
  const [pluginMetadata, datasources, globalDatasources] = await Promise.all([
103
102
  listPluginMetadata([
104
103
  'Datasource'
@@ -1,4 +1,4 @@
1
- // Copyright 2024 The Perses Authors
1
+ // Copyright 2025 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2024 The Perses Authors
1
+ // Copyright 2025 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2024 The Perses Authors
1
+ // Copyright 2025 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2024 The Perses Authors
1
+ // Copyright 2025 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2024 The Perses Authors
1
+ // Copyright 2025 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright 2025 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,5 +1,5 @@
1
1
  import { ReactElement } from 'react';
2
- import { PanelGroupItemId } from '../../context';
2
+ import { PanelGroupItemId } from '@perses-dev/core';
3
3
  import { PanelOptions } from '../Panel';
4
4
  export interface GridItemContentProps {
5
5
  panelGroupItemId: PanelGroupItemId;
@@ -1 +1 @@
1
- {"version":3,"file":"GridItemContent.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridItemContent.tsx"],"names":[],"mappings":"AAgBA,OAAc,EAAE,YAAY,EAAqB,MAAM,OAAO,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAA6D,MAAM,eAAe,CAAC;AAC5G,OAAO,EAAqB,YAAY,EAAE,MAAM,UAAU,CAAC;AAI3D,MAAM,WAAW,oBAAoB;IACnC,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,YAAY,CAmGzE"}
1
+ {"version":3,"file":"GridItemContent.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridItemContent.tsx"],"names":[],"mappings":"AAgBA,OAAc,EAAE,YAAY,EAAqB,MAAM,OAAO,CAAC;AAC/D,OAAO,EAA2B,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAE7E,OAAO,EAAqB,YAAY,EAAE,MAAM,UAAU,CAAC;AAG3D,MAAM,WAAW,oBAAoB;IACnC,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,YAAY,CAmGzE"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright 2025 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -15,9 +15,9 @@ import { Box } from '@mui/material';
15
15
  import { useInView } from 'react-intersection-observer';
16
16
  import { DataQueriesProvider, usePlugin, useSuggestedStepMs } from '@perses-dev/plugin-system';
17
17
  import React, { useMemo, useState } from 'react';
18
+ import { isPanelGroupItemIdEqual } from '@perses-dev/core';
18
19
  import { useEditMode, usePanel, usePanelActions, useViewPanelGroup } from '../../context';
19
20
  import { Panel } from '../Panel';
20
- import { isPanelGroupItemIdEqual } from '../../context/DashboardProvider/panel-group-slice';
21
21
  import { QueryViewerDialog } from '../QueryViewerDialog';
22
22
  /**
23
23
  * Resolves the reference to panel content in a GridItemDefinition and renders the panel.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/GridLayout/GridItemContent.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 } from '@mui/material';\nimport { useInView } from 'react-intersection-observer';\nimport { DataQueriesProvider, usePlugin, useSuggestedStepMs } from '@perses-dev/plugin-system';\nimport React, { ReactElement, useMemo, useState } from 'react';\nimport { PanelGroupItemId, useEditMode, usePanel, usePanelActions, useViewPanelGroup } from '../../context';\nimport { Panel, PanelProps, PanelOptions } from '../Panel';\nimport { isPanelGroupItemIdEqual } from '../../context/DashboardProvider/panel-group-slice';\nimport { QueryViewerDialog } from '../QueryViewerDialog';\n\nexport interface GridItemContentProps {\n panelGroupItemId: PanelGroupItemId;\n width: number; // necessary for determining the suggested step ms\n panelOptions?: PanelOptions;\n}\n\n/**\n * Resolves the reference to panel content in a GridItemDefinition and renders the panel.\n */\nexport function GridItemContent(props: GridItemContentProps): ReactElement {\n const { panelGroupItemId, width } = props;\n const panelDefinition = usePanel(panelGroupItemId);\n\n const {\n spec: { queries },\n } = panelDefinition;\n\n const { isEditMode } = useEditMode();\n const { openEditPanel, openDeletePanelDialog, duplicatePanel, viewPanel } = usePanelActions(panelGroupItemId);\n const viewPanelGroupItemId = useViewPanelGroup();\n const { ref, inView } = useInView({\n threshold: 0.2, // we have the flexibility to adjust this threshold to trigger queries slightly earlier or later based on performance\n initialInView: false,\n triggerOnce: true,\n });\n\n const [openQueryViewer, setOpenQueryViewer] = useState(false);\n\n const viewQueriesHandler = useMemo(() => {\n return isEditMode || !queries?.length\n ? undefined\n : {\n onClick: (): void => {\n setOpenQueryViewer(true);\n },\n };\n }, [isEditMode, queries]);\n\n const readHandlers = {\n isPanelViewed: isPanelGroupItemIdEqual(viewPanelGroupItemId, panelGroupItemId),\n onViewPanelClick: function (): void {\n if (viewPanelGroupItemId === undefined) {\n viewPanel(panelGroupItemId);\n } else {\n viewPanel(undefined);\n }\n },\n };\n\n // Provide actions to the panel when in edit mode\n let editHandlers: PanelProps['editHandlers'] = undefined;\n if (isEditMode) {\n editHandlers = {\n onEditPanelClick: openEditPanel,\n onDuplicatePanelClick: duplicatePanel,\n onDeletePanelClick: openDeletePanelDialog,\n };\n }\n\n // map TimeSeriesQueryDefinition to Definition<UnknownSpec>\n const suggestedStepMs = useSuggestedStepMs(width);\n\n const { data: plugin } = usePlugin('Panel', panelDefinition.spec.plugin.kind);\n\n const queryDefinitions = queries ?? [];\n const definitions = queryDefinitions.map((query) => {\n return {\n kind: query.spec.plugin.kind,\n spec: query.spec.plugin.spec,\n };\n });\n\n const pluginQueryOptions =\n typeof plugin?.queryOptions === 'function'\n ? plugin?.queryOptions(panelDefinition.spec.plugin.spec)\n : plugin?.queryOptions;\n\n return (\n <Box\n ref={ref}\n sx={{\n width: '100%',\n height: '100%',\n }}\n >\n <DataQueriesProvider\n definitions={definitions}\n options={{ suggestedStepMs, ...pluginQueryOptions }}\n queryOptions={{ enabled: inView }}\n >\n {inView && (\n <Panel\n definition={panelDefinition}\n readHandlers={readHandlers}\n editHandlers={editHandlers}\n viewQueriesHandler={viewQueriesHandler}\n panelOptions={props.panelOptions}\n panelGroupItemId={panelGroupItemId}\n />\n )}\n </DataQueriesProvider>\n <QueryViewerDialog\n open={openQueryViewer}\n queryDefinitions={queryDefinitions}\n onClose={() => setOpenQueryViewer(false)}\n />\n </Box>\n );\n}\n"],"names":["Box","useInView","DataQueriesProvider","usePlugin","useSuggestedStepMs","React","useMemo","useState","useEditMode","usePanel","usePanelActions","useViewPanelGroup","Panel","isPanelGroupItemIdEqual","QueryViewerDialog","GridItemContent","props","panelGroupItemId","width","panelDefinition","spec","queries","isEditMode","openEditPanel","openDeletePanelDialog","duplicatePanel","viewPanel","viewPanelGroupItemId","ref","inView","threshold","initialInView","triggerOnce","openQueryViewer","setOpenQueryViewer","viewQueriesHandler","length","undefined","onClick","readHandlers","isPanelViewed","onViewPanelClick","editHandlers","onEditPanelClick","onDuplicatePanelClick","onDeletePanelClick","suggestedStepMs","data","plugin","kind","queryDefinitions","definitions","map","query","pluginQueryOptions","queryOptions","sx","height","options","enabled","definition","panelOptions","open","onClose"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,GAAG,QAAQ,gBAAgB;AACpC,SAASC,SAAS,QAAQ,8BAA8B;AAC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B,oBAAoBrB;QACtB;IACF;IAEA,2DAA2D;IAC3D,MAAMsB,kBAAkB1C,mBAAmBc;IAE3C,MAAM,EAAE6B,MAAMC,MAAM,EAAE,GAAG7C,UAAU,SAASgB,gBAAgBC,IAAI,CAAC4B,MAAM,CAACC,IAAI;IAE5E,MAAMC,mBAAmB7B,WAAW,EAAE;IACtC,MAAM8B,cAAcD,iBAAiBE,GAAG,CAAC,CAACC;QACxC,OAAO;YACLJ,MAAMI,MAAMjC,IAAI,CAAC4B,MAAM,CAACC,IAAI;YAC5B7B,MAAMiC,MAAMjC,IAAI,CAAC4B,MAAM,CAAC5B,IAAI;QAC9B;IACF;IAEA,MAAMkC,qBACJ,OAAON,QAAQO,iBAAiB,aAC5BP,QAAQO,aAAapC,gBAAgBC,IAAI,CAAC4B,MAAM,CAAC5B,IAAI,IACrD4B,QAAQO;IAEd,qBACE,MAACvD;QACC4B,KAAKA;QACL4B,IAAI;YACFtC,OAAO;YACPuC,QAAQ;QACV;;0BAEA,KAACvD;gBACCiD,aAAaA;gBACbO,SAAS;oBAAEZ;oBAAiB,GAAGQ,kBAAkB;gBAAC;gBAClDC,cAAc;oBAAEI,SAAS9B;gBAAO;0BAE/BA,wBACC,KAACjB;oBACCgD,YAAYzC;oBACZoB,cAAcA;oBACdG,cAAcA;oBACdP,oBAAoBA;oBACpB0B,cAAc7C,MAAM6C,YAAY;oBAChC5C,kBAAkBA;;;0BAIxB,KAACH;gBACCgD,MAAM7B;gBACNiB,kBAAkBA;gBAClBa,SAAS,IAAM7B,mBAAmB;;;;AAI1C"}
1
+ {"version":3,"sources":["../../../src/components/GridLayout/GridItemContent.tsx"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box } from '@mui/material';\nimport { useInView } from 'react-intersection-observer';\nimport { DataQueriesProvider, usePlugin, useSuggestedStepMs } from '@perses-dev/plugin-system';\nimport React, { ReactElement, useMemo, useState } from 'react';\nimport { isPanelGroupItemIdEqual, PanelGroupItemId } from '@perses-dev/core';\nimport { useEditMode, usePanel, usePanelActions, useViewPanelGroup } from '../../context';\nimport { Panel, PanelProps, PanelOptions } from '../Panel';\nimport { QueryViewerDialog } from '../QueryViewerDialog';\n\nexport interface GridItemContentProps {\n panelGroupItemId: PanelGroupItemId;\n width: number; // necessary for determining the suggested step ms\n panelOptions?: PanelOptions;\n}\n\n/**\n * Resolves the reference to panel content in a GridItemDefinition and renders the panel.\n */\nexport function GridItemContent(props: GridItemContentProps): ReactElement {\n const { panelGroupItemId, width } = props;\n const panelDefinition = usePanel(panelGroupItemId);\n\n const {\n spec: { queries },\n } = panelDefinition;\n\n const { isEditMode } = useEditMode();\n const { openEditPanel, openDeletePanelDialog, duplicatePanel, viewPanel } = usePanelActions(panelGroupItemId);\n const viewPanelGroupItemId = useViewPanelGroup();\n const { ref, inView } = useInView({\n threshold: 0.2, // we have the flexibility to adjust this threshold to trigger queries slightly earlier or later based on performance\n initialInView: false,\n triggerOnce: true,\n });\n\n const [openQueryViewer, setOpenQueryViewer] = useState(false);\n\n const viewQueriesHandler = useMemo(() => {\n return isEditMode || !queries?.length\n ? undefined\n : {\n onClick: (): void => {\n setOpenQueryViewer(true);\n },\n };\n }, [isEditMode, queries]);\n\n const readHandlers = {\n isPanelViewed: isPanelGroupItemIdEqual(viewPanelGroupItemId, panelGroupItemId),\n onViewPanelClick: function (): void {\n if (viewPanelGroupItemId === undefined) {\n viewPanel(panelGroupItemId);\n } else {\n viewPanel(undefined);\n }\n },\n };\n\n // Provide actions to the panel when in edit mode\n let editHandlers: PanelProps['editHandlers'] = undefined;\n if (isEditMode) {\n editHandlers = {\n onEditPanelClick: openEditPanel,\n onDuplicatePanelClick: duplicatePanel,\n onDeletePanelClick: openDeletePanelDialog,\n };\n }\n\n // map TimeSeriesQueryDefinition to Definition<UnknownSpec>\n const suggestedStepMs = useSuggestedStepMs(width);\n\n const { data: plugin } = usePlugin('Panel', panelDefinition.spec.plugin.kind);\n\n const queryDefinitions = queries ?? [];\n const definitions = queryDefinitions.map((query) => {\n return {\n kind: query.spec.plugin.kind,\n spec: query.spec.plugin.spec,\n };\n });\n\n const pluginQueryOptions =\n typeof plugin?.queryOptions === 'function'\n ? plugin?.queryOptions(panelDefinition.spec.plugin.spec)\n : plugin?.queryOptions;\n\n return (\n <Box\n ref={ref}\n sx={{\n width: '100%',\n height: '100%',\n }}\n >\n <DataQueriesProvider\n definitions={definitions}\n options={{ suggestedStepMs, ...pluginQueryOptions }}\n queryOptions={{ enabled: inView }}\n >\n {inView && (\n <Panel\n definition={panelDefinition}\n readHandlers={readHandlers}\n editHandlers={editHandlers}\n viewQueriesHandler={viewQueriesHandler}\n panelOptions={props.panelOptions}\n panelGroupItemId={panelGroupItemId}\n />\n )}\n </DataQueriesProvider>\n <QueryViewerDialog\n open={openQueryViewer}\n queryDefinitions={queryDefinitions}\n onClose={() => setOpenQueryViewer(false)}\n />\n </Box>\n );\n}\n"],"names":["Box","useInView","DataQueriesProvider","usePlugin","useSuggestedStepMs","React","useMemo","useState","isPanelGroupItemIdEqual","useEditMode","usePanel","usePanelActions","useViewPanelGroup","Panel","QueryViewerDialog","GridItemContent","props","panelGroupItemId","width","panelDefinition","spec","queries","isEditMode","openEditPanel","openDeletePanelDialog","duplicatePanel","viewPanel","viewPanelGroupItemId","ref","inView","threshold","initialInView","triggerOnce","openQueryViewer","setOpenQueryViewer","viewQueriesHandler","length","undefined","onClick","readHandlers","isPanelViewed","onViewPanelClick","editHandlers","onEditPanelClick","onDuplicatePanelClick","onDeletePanelClick","suggestedStepMs","data","plugin","kind","queryDefinitions","definitions","map","query","pluginQuery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AM7B,mBAAmB;;;;AAI1C"}
@@ -1 +1 @@
1
- {"version":3,"file":"GridLayout.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridLayout.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAE,YAAY,EAAY,MAAM,OAAO,CAAC;AAE/C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAUhD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAO,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtC,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,YAAY,CAmE/D;AAED,MAAM,WAAW,qBAAsB,SAAQ,QAAQ;IACrD,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,UAAkB,EAClB,cAAc,EACd,aAAa,GACd,EAAE,qBAAqB,GAAG,YAAY,GAAG,IAAI,CA0C7C"}
1
+ {"version":3,"file":"GridLayout.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridLayout.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAE,YAAY,EAAY,MAAM,OAAO,CAAC;AAE/C,OAAO,EAAE,YAAY,EAAwB,MAAM,kBAAkB,CAAC;AAItE,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAO,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtC,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,YAAY,CAmE/D;AAED,MAAM,WAAW,qBAAsB,SAAQ,QAAQ;IACrD,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,UAAkB,EAClB,cAAc,EACd,aAAa,GACd,EAAE,qBAAqB,GAAG,YAAY,GAAG,IAAI,CA0C7C"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright 2025 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/GridLayout/GridLayout.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.\nimport { ReactElement, useState } from 'react';\nimport { Layouts, Layout } from 'react-grid-layout';\nimport { PanelGroupId } from '@perses-dev/core';\nimport { useVariableValues, VariableContext } from '@perses-dev/plugin-system';\nimport {\n useEditMode,\n usePanelGroup,\n usePanelGroupActions,\n useViewPanelGroup,\n PanelGroupDefinition,\n} from '../../context';\nimport { GRID_LAYOUT_SMALL_BREAKPOINT } from '../../constants';\nimport { PanelOptions } from '../Panel';\nimport { Row, RowProps } from './Row';\n\nexport interface GridLayoutProps {\n panelGroupId: PanelGroupId;\n panelOptions?: PanelOptions;\n panelFullHeight?: number;\n}\n\n/**\n * Layout component that arranges children in a Grid based on the definition.\n */\nexport function GridLayout(props: GridLayoutProps): ReactElement {\n const { panelGroupId, panelOptions, panelFullHeight } = props;\n const groupDefinition: PanelGroupDefinition = usePanelGroup(panelGroupId);\n const { updatePanelGroupLayouts } = usePanelGroupActions(panelGroupId);\n const viewPanelItemId = useViewPanelGroup();\n const { isEditMode } = useEditMode();\n\n const [gridColWidth, setGridColWidth] = useState(0);\n\n const hasViewPanel = viewPanelItemId?.panelGroupId === panelGroupId; // current panelGroup contains the panel extended?\n\n const handleLayoutChange = (currentLayout: Layout[], allLayouts: Layouts): void => {\n // Using the value from `allLayouts` instead of `currentLayout` because of\n // a bug in react-layout-grid where `currentLayout` does not adjust properly\n // when going to a smaller breakpoint and then back to a larger breakpoint.\n // https://github.com/react-grid-layout/react-grid-layout/issues/1663\n const smallLayout = allLayouts[GRID_LAYOUT_SMALL_BREAKPOINT];\n if (smallLayout && !hasViewPanel) {\n updatePanelGroupLayouts(smallLayout);\n }\n };\n\n /**\n * Calculate the column width so we can determine the width of each panel for suggested step ms\n * https://github.com/react-grid-layout/react-grid-layout/blob/master/lib/calculateUtils.js#L14-L35\n */\n const handleWidthChange = (\n containerWidth: number,\n margin: [number, number],\n cols: number,\n containerPadding: [number, number]\n ): void => {\n const marginX = margin[0];\n const marginWidth = marginX * (cols - 1);\n const containerPaddingWidth = containerPadding[0] * 2;\n // exclude margin and padding from total width\n setGridColWidth((containerWidth - marginWidth - containerPaddingWidth) / cols);\n };\n\n return (\n <>\n {!groupDefinition.repeatVariable ? (\n <Row\n panelGroupId={panelGroupId}\n groupDefinition={groupDefinition}\n gridColWidth={gridColWidth}\n panelFullHeight={panelFullHeight}\n panelOptions={panelOptions}\n isEditMode={isEditMode}\n onLayoutChange={handleLayoutChange}\n onWidthChange={handleWidthChange}\n />\n ) : (\n <RepeatGridLayout\n repeatVariableName={groupDefinition.repeatVariable}\n panelGroupId={panelGroupId}\n groupDefinition={groupDefinition}\n gridColWidth={gridColWidth}\n panelFullHeight={panelFullHeight}\n panelOptions={panelOptions}\n isEditMode={isEditMode}\n onLayoutChange={handleLayoutChange}\n onWidthChange={handleWidthChange}\n />\n )}\n </>\n );\n}\n\nexport interface RepeatGridLayoutProps extends RowProps {\n repeatVariableName: string;\n}\n\n/**\n * Renders a grid layout for a repeated variable, where each value of the variable will create a new row.\n */\nexport function RepeatGridLayout({\n repeatVariableName,\n panelGroupId,\n groupDefinition,\n gridColWidth,\n panelFullHeight,\n panelOptions,\n isEditMode = false,\n onLayoutChange,\n onWidthChange,\n}: RepeatGridLayoutProps): ReactElement | null {\n const variables = useVariableValues();\n const variable = variables[repeatVariableName];\n\n // If the variable is not defined, or if it is defined but has no values, render a standard row without repeating\n if (variable === undefined || !Array.isArray(variable.value) || variable.value.length === 0) {\n return (\n <Row\n panelGroupId={panelGroupId}\n groupDefinition={groupDefinition}\n gridColWidth={gridColWidth}\n panelFullHeight={panelFullHeight}\n panelOptions={panelOptions}\n isEditMode={isEditMode}\n onLayoutChange={onLayoutChange}\n onWidthChange={onWidthChange}\n />\n );\n }\n\n return (\n <>\n {variable.value.map((value) => (\n <VariableContext.Provider\n key={`${repeatVariableName}-${value}`}\n value={{ state: { ...variables, [repeatVariableName]: { value, loading: false } } }}\n >\n <Row\n panelGroupId={panelGroupId}\n groupDefinition={groupDefinition}\n gridColWidth={gridColWidth}\n panelFullHeight={panelFullHeight}\n panelOptions={panelOptions}\n isEditMode={isEditMode}\n onLayoutChange={onLayoutChange}\n onWidthChange={onWidthChange}\n repeatVariable={[repeatVariableName, value]}\n />\n </VariableContext.Provider>\n ))}\n </>\n );\n}\n"],"names":["useState","useVariableValues","VariableContext","useEditMode","usePanelGroup","usePanelGroupActions","useViewPanelGroup","GRID_LAYOUT_SMALL_BREAKPOINT","Row","GridLayout","props","panelGroupId","panelOptions","panelFullHeight","groupDefinition","updatePanelGroupLayouts","viewPanelItemId","isEditMode","gridColWidth","setGridColWidth","hasViewPanel","handleLayoutChange","currentLayout","allLayouts","smallLayout","handleWidthChange","containerWidth","margin","cols","containerPadding","marginX","marginWidth","containerPaddingWidth","repeatVariable","onLayoutChange","onWidthChange","RepeatGridLayout","repeatVariableName","variables","variable","undefined","Array","isArray","value","length","map","Provider","state","loading"],"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;;AACjC,SAAuBA,QAAQ,QAAQ,QAAQ;AAG/C,SAASC,iBAAiB,EAAEC,eAAe,QAAQ,4BAA4B;AAC/E,SACEC,WAAW,EACXC,aAAa,EACbC,oBAAoB,EACpBC,iBAAiB,QAEZ,gBAAgB;AACvB,SAASC,4BAA4B,QAAQ,kBAAkB;AAE/D,SAASC,GAAG,QAAkB,QAAQ;AAQtC;;CAEC,GACD,OAAO,SAASC,WAAWC,KAAsB;IAC/C,MAAM,EAAEC,YAAY,EAAEC,YAAY,EAAEC,eAAe,EAAE,GAAGH;IACxD,MAAMI,kBAAwCV,cAAcO;IAC5D,MAAM,EAAEI,uBAAuB,EAAE,GAAGV,qBAAqBM;IACzD,MAAMK,kBAAkBV;IACxB,MAAM,EAAEW,UAAU,EAAE,GAAGd;IAEvB,MAAM,CAACe,cAAcC,gBAAgB,GAAGnB,SAAS;IAEjD,MAAMoB,eAAeJ,iBAAiBL,iBAAiBA,cAAc,kDAAkD;IAEvH,MAAMU,qBAAqB,CAACC,eAAyBC;QACnD,0EAA0E;QAC1E,4EAA4E;QAC5E,2EAA2E;QAC3E,qEAAqE;QACrE,MAAMC,cAAcD,UAAU,CAAChB,6BAA6B;QAC5D,IAAIiB,eAAe,CAACJ,cAAc;YAChCL,wBAAwBS;QAC1B;IACF;IAEA;;;GAGC,GACD,MAAMC,oBAAoB,CACxBC,gBACAC,QACAC,MACAC;QAEA,MAAMC,UAAUH,MA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K,SAAS;wBAAM;oBAAE;gBAAE;0BAElF,cAAA,KAACxC;oBACCG,cAAcA;oBACdG,iBAAiBA;oBACjBI,cAAcA;oBACdL,iBAAiBA;oBACjBD,cAAcA;oBACdK,YAAYA;oBACZiB,gBAAgBA;oBAChBC,eAAeA;oBACfF,gBAAgB;wBAACI;wBAAoBM;qBAAM;;eAZxC,GAAGN,mBAAmB,CAAC,EAAEM,OAAO;;AAkB/C"}
1
+ {"version":3,"sources":["../../../src/components/GridLayout/GridLayout.tsx"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { ReactElement, useState } from 'react';\nimport { Layouts, Layout } from 'react-grid-layout';\nimport { PanelGroupId, PanelGroupDefinition } from '@perses-dev/core';\nimport { useVariableValues, VariableContext } from '@perses-dev/plugin-system';\nimport { useEditMode, usePanelGroup, usePanelGroupActions, useViewPanelGroup } from '../../context';\nimport { GRID_LAYOUT_SMALL_BREAKPOINT } from '../../constants';\nimport { PanelOptions } from '../Panel';\nimport { Row, RowProps } from './Row';\n\nexport interface GridLayoutProps {\n panelGroupId: PanelGroupId;\n panelOptions?: PanelOptions;\n panelFullHeight?: number;\n}\n\n/**\n * Layout component that arranges children in a Grid based on the definition.\n */\nexport function GridLayout(props: GridLayoutProps): ReactElement {\n const { panelGroupId, panelOptions, panelFullHeight } = props;\n const groupDefinition: PanelGroupDefinition = usePanelGroup(panelGroupId);\n const { updatePanelGroupLayouts } = usePanelGroupActions(panelGroupId);\n const viewPanelItemId = useViewPanelGroup();\n const { isEditMode } = useEditMode();\n\n const [gridColWidth, setGridColWidth] = useState(0);\n\n const hasViewPanel = viewPanelItemId?.panelGroupId === panelGroupId; // current panelGroup contains the panel extended?\n\n const handleLayoutChange = (currentLayout: Layout[], allLayouts: Layouts): void => {\n // Using the value from `allLayouts` instead of `currentLayout` because of\n // a bug in react-layout-grid where `currentLayout` does not adjust properly\n // when going to a smaller breakpoint and then back to a larger breakpoint.\n // https://github.com/react-grid-layout/react-grid-layout/issues/1663\n const smallLayout = allLayouts[GRID_LAYOUT_SMALL_BREAKPOINT];\n if (smallLayout && !hasViewPanel) {\n updatePanelGroupLayouts(smallLayout);\n }\n };\n\n /**\n * Calculate the column width so we can determine the width of each panel for suggested step ms\n * https://github.com/react-grid-layout/react-grid-layout/blob/master/lib/calculateUtils.js#L14-L35\n */\n const handleWidthChange = (\n containerWidth: number,\n margin: [number, number],\n cols: number,\n containerPadding: [number, number]\n ): void => {\n const marginX = margin[0];\n const marginWidth = marginX * (cols - 1);\n const containerPaddingWidth = containerPadding[0] * 2;\n // exclude margin and padding from total width\n setGridColWidth((containerWidth - marginWidth - containerPaddingWidth) / cols);\n };\n\n return (\n <>\n {!groupDefinition.repeatVariable ? (\n <Row\n panelGroupId={panelGroupId}\n groupDefinition={groupDefinition}\n gridColWidth={gridColWidth}\n panelFullHeight={panelFullHeight}\n panelOptions={panelOptions}\n isEditMode={isEditMode}\n onLayoutChange={handleLayoutChange}\n onWidthChange={handleWidthChange}\n />\n ) : (\n <RepeatGridLayout\n repeatVariableName={groupDefinition.repeatVariable}\n panelGroupId={panelGroupId}\n groupDefinition={groupDefinition}\n gridColWidth={gridColWidth}\n panelFullHeight={panelFullHeight}\n panelOptions={panelOptions}\n isEditMode={isEditMode}\n onLayoutChange={handleLayoutChange}\n onWidthChange={handleWidthChange}\n />\n )}\n </>\n );\n}\n\nexport interface RepeatGridLayoutProps extends RowProps {\n repeatVariableName: string;\n}\n\n/**\n * Renders a grid layout for a repeated variable, where each value of the variable will create a new row.\n */\nexport function RepeatGridLayout({\n repeatVariableName,\n panelGroupId,\n groupDefinition,\n gridColWidth,\n panelFullHeight,\n panelOptions,\n isEditMode = false,\n onLayoutChange,\n onWidthChange,\n}: RepeatGridLayoutProps): ReactElement | null {\n const variables = useVariableValues();\n const variable = variables[repeatVariableName];\n\n // If the variable is not defined, or if it is defined but has no values, render a standard row without repeating\n if (variable === undefined || !Array.isArray(variable.value) || variable.value.length === 0) {\n return (\n <Row\n panelGroupId={panelGroupId}\n groupDefinition={groupDefinition}\n gridColWidth={gridColWidth}\n panelFullHeight={panelFullHeight}\n panelOptions={panelOptions}\n isEditMode={isEditMode}\n onLayoutChange={onLayoutChange}\n onWidthChange={onWidthChange}\n />\n );\n }\n\n return (\n <>\n {variable.value.map((value) => (\n <VariableContext.Provider\n key={`${repeatVariableName}-${value}`}\n value={{ state: { ...variables, [repeatVariableName]: { value, loading: false } } }}\n >\n <Row\n panelGroupId={panelGroupId}\n groupDefinition={groupDefinition}\n gridColWidth={gridColWidth}\n panelFullHeight={panelFullHeight}\n panelOptions={panelOptions}\n isEditMode={isEditMode}\n onLayoutChange={onLayoutChange}\n onWidthChange={onWidthChange}\n repeatVariable={[repeatVariableName, value]}\n />\n </VariableContext.Provider>\n ))}\n </>\n );\n}\n"],"names":["useState","useVariableValues","VariableContext","useEditMode","usePanelGroup","usePanelGroupActions","useViewPanelGroup","GRID_LAYOUT_SMALL_BREAKPOINT","Row","GridLayout","props","panelGroupId","panelOptions","panelFullHeight","groupDefinition","updatePanelGroupLayouts","viewPanelItemId","isEditMode","gridColWidth","setGridColWidth","hasViewPanel","handleLayoutChange","currentLayout","allLayouts","smallLayout","handleWidthChange","containerWidth","margin","cols","containerPadding","marginX","marginWidth","containerPaddingWidth","repeatVariable","onLayoutChange","onWidthChange","RepeatGridLayout","repeatVariableName","variables","variable","undefined","Array","isArray","value","length","map","Provider","state","loading"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAs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+1,5 @@
1
- import { PanelGroupId } from '@perses-dev/core';
2
- import { PanelGroupDefinition, PanelOptions } from '@perses-dev/dashboards';
1
+ import { PanelGroupId, PanelGroupDefinition } from '@perses-dev/core';
2
+ import { PanelOptions } from '@perses-dev/dashboards';
3
3
  import { ReactElement } from 'react';
4
4
  import { Layout, Layouts } from 'react-grid-layout';
5
5
  export interface RowProps {
@@ -1 +1 @@
1
- {"version":3,"file":"Row.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/Row.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAwB,YAAY,EAAqB,MAAM,wBAAwB,CAAC;AACrH,OAAO,EAAE,YAAY,EAAgC,MAAM,OAAO,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,OAAO,EAA6B,MAAM,mBAAmB,CAAC;AAU/E,MAAM,WAAW,QAAQ;IACvB,YAAY,EAAE,YAAY,CAAC;IAC3B,eAAe,EAAE,oBAAoB,CAAC;IACtC,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;IACxE,aAAa,CAAC,EAAE,CACd,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EACxB,IAAI,EAAE,MAAM,EACZ,gBAAgB,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,KAC/B,IAAI,CAAC;IACV,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC;AAED,wBAAgB,GAAG,CAAC,EAClB,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,UAAkB,EAClB,cAAc,EACd,aAAa,EACb,cAAc,GACf,EAAE,QAAQ,GAAG,YAAY,CAoGzB"}
1
+ {"version":3,"file":"Row.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/Row.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAwB,MAAM,kBAAkB,CAAC;AAC5F,OAAO,EAAE,YAAY,EAAqB,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,YAAY,EAAgC,MAAM,OAAO,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,OAAO,EAA6B,MAAM,mBAAmB,CAAC;AAU/E,MAAM,WAAW,QAAQ;IACvB,YAAY,EAAE,YAAY,CAAC;IAC3B,eAAe,EAAE,oBAAoB,CAAC;IACtC,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;IACxE,aAAa,CAAC,EAAE,CACd,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EACxB,IAAI,EAAE,MAAM,EACZ,gBAAgB,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,KAC/B,IAAI,CAAC;IACV,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC;AAED,wBAAgB,GAAG,CAAC,EAClB,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,UAAkB,EAClB,cAAc,EACd,aAAa,EACb,cAAc,GACf,EAAE,QAAQ,GAAG,YAAY,CAoGzB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/GridLayout/Row.tsx"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Collapse, useTheme } from '@mui/material';\nimport { PanelGroupId } from '@perses-dev/core';\nimport { PanelGroupDefinition, PanelGroupItemLayout, PanelOptions, useViewPanelGroup } from '@perses-dev/dashboards';\nimport { ReactElement, useEffect, useMemo, useState } from 'react';\nimport { Layout, Layouts, Responsive, WidthProvider } from 'react-grid-layout';\nimport { ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport { GRID_LAYOUT_COLS, GRID_LAYOUT_SMALL_BREAKPOINT } from '../../constants';\nimport { GridContainer } from './GridContainer';\nimport { GridItemContent } from './GridItemContent';\nimport { GridTitle } from './GridTitle';\n\nconst DEFAULT_MARGIN = 10;\nconst ROW_HEIGHT = 30;\n\nexport interface RowProps {\n panelGroupId: PanelGroupId;\n groupDefinition: PanelGroupDefinition;\n gridColWidth: number;\n panelFullHeight?: number;\n panelOptions?: PanelOptions;\n isEditMode?: boolean;\n onLayoutChange?: (currentLayout: Layout[], allLayouts: Layouts) => void;\n onWidthChange?: (\n containerWidth: number,\n margin: [number, number],\n cols: number,\n containerPadding: [number, number]\n ) => void;\n repeatVariable?: [string, string];\n}\n\nexport function Row({\n panelGroupId,\n groupDefinition,\n gridColWidth,\n panelFullHeight,\n panelOptions,\n isEditMode = false,\n onLayoutChange,\n onWidthChange,\n repeatVariable,\n}: RowProps): ReactElement {\n const ResponsiveGridLayout = useMemo(() => WidthProvider(Responsive), []);\n const theme = useTheme();\n const viewPanelItemId = useViewPanelGroup();\n\n const [isOpen, setIsOpen] = useState(!groupDefinition.isCollapsed);\n\n const hasViewPanel =\n viewPanelItemId?.panelGroupId === panelGroupId &&\n // Check for repeatVariable panels\n viewPanelItemId.repeatVariable?.[0] === repeatVariable?.[0] &&\n viewPanelItemId.repeatVariable?.[1] === repeatVariable?.[1];\n const itemLayoutViewed = viewPanelItemId?.panelGroupItemLayoutId;\n\n // If there is a panel in view mode, we should hide the grid if the panel is not in the current group.\n const isGridDisplayed = !viewPanelItemId || hasViewPanel;\n\n // TODO: handle it without useEffect\n useEffect(() => {\n if (hasViewPanel) {\n setIsOpen(true);\n }\n }, [hasViewPanel]);\n\n // Item layout is override if there is a panel in view mode\n const itemLayouts: PanelGroupItemLayout[] = useMemo(() => {\n if (itemLayoutViewed) {\n return groupDefinition.itemLayouts.map((itemLayout) => {\n if (itemLayout.i === itemLayoutViewed) {\n const rowTitleHeight = 40 + 8; // 40 is the height of the row title and 8 is the margin height\n return {\n h: Math.round(((panelFullHeight ?? window.innerHeight) - rowTitleHeight) / (ROW_HEIGHT + DEFAULT_MARGIN)), // Viewed panel should take the full height remaining\n i: itemLayoutViewed,\n w: 48,\n x: 0,\n y: 0,\n } as PanelGroupItemLayout;\n }\n return itemLayout;\n });\n }\n return groupDefinition.itemLayouts;\n }, [groupDefinition.itemLayouts, itemLayoutViewed, panelFullHeight]);\n\n return (\n <GridContainer\n sx={{\n display: isGridDisplayed ? 'block' : 'none',\n height: itemLayoutViewed ? `${panelFullHeight}px` : 'unset',\n overflow: itemLayoutViewed ? 'hidden' : 'unset',\n }}\n >\n {groupDefinition.title && (\n <GridTitle\n panelGroupId={panelGroupId}\n title={groupDefinition.title}\n collapse={\n groupDefinition.isCollapsed === undefined\n ? undefined\n : { isOpen: isOpen, onToggleOpen: () => setIsOpen((current) => !current) }\n }\n />\n )}\n <Collapse in={isOpen} unmountOnExit appear={false} data-testid=\"panel-group-content\">\n <ResponsiveGridLayout\n className=\"layout\"\n breakpoints={{ [GRID_LAYOUT_SMALL_BREAKPOINT]: theme.breakpoints.values.sm, xxs: 0 }}\n cols={GRID_LAYOUT_COLS}\n rowHeight={ROW_HEIGHT}\n draggableHandle=\".drag-handle\"\n resizeHandles={['se']}\n isDraggable={isEditMode && !hasViewPanel}\n isResizable={isEditMode && !hasViewPanel}\n margin={[DEFAULT_MARGIN, DEFAULT_MARGIN]}\n containerPadding={[0, 10]}\n layouts={{ sm: itemLayouts }}\n onLayoutChange={onLayoutChange}\n onWidthChange={onWidthChange}\n allowOverlap={hasViewPanel} // Enabling overlap when viewing a specific panel because panel in front of the viewed panel will add empty spaces (empty row height)\n >\n {itemLayouts.map(({ i, w }) => (\n <div\n key={i}\n style={{\n display: itemLayoutViewed ? (itemLayoutViewed === i ? 'unset' : 'none') : 'unset',\n }}\n >\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <GridItemContent\n panelOptions={panelOptions}\n panelGroupItemId={{ panelGroupId, panelGroupItemLayoutId: i, repeatVariable }}\n width={calculateGridItemWidth(w, gridColWidth)}\n />\n </ErrorBoundary>\n </div>\n ))}\n </ResponsiveGridLayout>\n </Collapse>\n </GridContainer>\n );\n}\n\nconst calculateGridItemWidth = (w: number, colWidth: number): number => {\n // 0 * Infinity === NaN, which causes problems with resize contraints\n if (!Number.isFinite(w)) return w;\n return Math.round(colWidth * w + Math.max(0, w - 1) * DEFAULT_MARGIN);\n};\n"],"names":["Collapse","useTheme","useViewPanelGroup","useEffect","useMemo","useState","Responsive","WidthProvider","ErrorAlert","ErrorBoundary","GRID_LAYOUT_COLS","GRID_LAYOUT_SMALL_BREAKPOINT","GridContainer","GridItemContent","GridTitle","DEFAULT_MARGIN","ROW_HEIGHT","Row","panelGroupId","groupDefinition","gridColWidth","panelFullHeight","panelOptions","isEditMode","onLayoutChange","onWidthChange","repeatVariable","ResponsiveGridLayout","theme","viewPanelItemId","isOpen","setIsOpen","isCollapsed","hasViewPanel","itemLayoutViewed","panelGroupItemLayoutId","isGridDisplayed","itemLayouts","map","itemLayout","i","rowTitleHeight","h","Math","round","window","innerHeight","w","x","y","sx","display","height","overflow","title","collapse","undefined","onToggleOpen","current","in","unmountOnExit","appear","data-testid","className","breakpoints","values","sm","xxs","cols","rowHeight","draggableHandle","resizeHandles","isDraggable","isResizable","margin","containerPadding","layouts","allowOverlap","div","style","FallbackComponent","panelGroupItemId","width","calculateGridItemWidth","colWidth","Number","isFinite","max"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,QAAQ,EAAEC,QAAQ,QAAQ,gBAAgB;AAEnD,SAAmEC,iBAAiB,QAAQ,yBAAyB;AACrH,SAAuBC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AACnE,SAA0BC,UAAU,EAAEC,aAAa,QAAQ,oBAAoB;AAC/E,SAASC,UAAU,EAAEC,aAAa,QAAQ,yBAAyB;AACnE,SAASC,gBAAgB,EAAEC,4BAA4B,QAAQ,kBAAkB;AACjF,SAASC,aAAa,QAAQ,kBAAkB;AAChD,SAASC,eAAe,QAAQ,oBAAoB;AACpD,SAASC,SAAS,QAAQ,cAAc;AAExC,MAAMC,iBAAiB;AACvB,MAAMC,aAAa;AAmBnB,OAAO,SAASC,IAAI,EAClBC,YAAY,EACZC,eAAe,EACfC,YAAY,EACZC,eAAe,EACfC,YAAY,EACZC,aAAa,KAAK,EAClBC,cAAc,EACdC,aAAa,EACbC,cAAc,EACL;IACT,MAAMC,uBAAuBvB,QAAQ,IAAMG,cAAcD,aAAa,EAAE;IACxE,MAAMsB,QAAQ3B;IACd,MAAM4B,kBAAkB3B;IAExB,MAAM,CAAC4B,QAAQC,UAAU,GAAG1B,SAAS,CAACc,gBAAgBa,WAAW;IAEjE,MAAMC,eACJJ,iBAAiBX,iBAAiBA,gBAClC,kCAAkC;IAClCW,gBAAgBH,cAAc,EAAE,CAAC,EAAE,KAAKA,gBAAgB,CAAC,EAAE,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OC,eAAY;0BAC7D,cAAA,KAACnC;oBACCoC,WAAU;oBACVC,aAAa;wBAAE,CAACrD,6BAA6B,EAAEiB,MAAMoC,WAAW,CAACC,MAAM,CAACC,EAAE;wBAAEC,KAAK;oBAAE;oBACnFC,MAAM1D;oBACN2D,WAAWrD;oBACXsD,iBAAgB;oBAChBC,eAAe;wBAAC;qBAAK;oBACrBC,aAAajD,cAAc,CAACU;oBAC5BwC,aAAalD,cAAc,CAACU;oBAC5ByC,QAAQ;wBAAC3D;wBAAgBA;qBAAe;oBACxC4D,kBAAkB;wBAAC;wBAAG;qBAAG;oBACzBC,SAAS;wBAAEV,IAAI7B;oBAAY;oBAC3Bb,gBAAgBA;oBAChBC,eAAeA;oBACfoD,cAAc5C;8BAEbI,YAAYC,GAAG,CAAC,CAAC,EAAEE,CAAC,EAAEO,CAAC,EAAE,iBACxB,KAAC+B;4BAECC,OAAO;gCACL5B,SAASjB,mBAAoBA,qBAAqBM,IAAI,UAAU,SAAU;4BAC5E;sCAEA,cAAA,KAAC/B;gCAAcuE,mBAAmBxE;0CAChC,cAAA,KAACK;oCACCS,cAAcA;oCACd2D,kBAAkB;wCAAE/D;wCAAciB,wBAAwBK;wCAAGd;oCAAe;oCAC5EwD,OAAOC,uBAAuBpC,GAAG3B;;;2BAThCoB;;;;;AAkBnB;AAEA,MAAM2C,yBAAyB,CAACpC,GAAWqC;IACzC,qEAAqE;IACrE,IAAI,CAACC,OAAOC,QAAQ,CAACvC,IAAI,OAAOA;IAChC,OAAOJ,KAAKC,KAAK,CAACwC,WAAWrC,IAAIJ,KAAK4C,GAAG,CAAC,GAAGxC,IAAI,KAAKhC;AACxD"}
1
+ {"version":3,"sources":["../../../src/components/GridLayout/Row.tsx"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Collapse, useTheme } from '@mui/material';\nimport { PanelGroupId, PanelGroupDefinition, PanelGroupItemLayout } from '@perses-dev/core';\nimport { PanelOptions, useViewPanelGroup } from '@perses-dev/dashboards';\nimport { ReactElement, useEffect, useMemo, useState } from 'react';\nimport { Layout, Layouts, Responsive, WidthProvider } from 'react-grid-layout';\nimport { ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport { GRID_LAYOUT_COLS, GRID_LAYOUT_SMALL_BREAKPOINT } from '../../constants';\nimport { GridContainer } from './GridContainer';\nimport { GridItemContent } from './GridItemContent';\nimport { GridTitle } from './GridTitle';\n\nconst DEFAULT_MARGIN = 10;\nconst ROW_HEIGHT = 30;\n\nexport interface RowProps {\n panelGroupId: PanelGroupId;\n groupDefinition: PanelGroupDefinition;\n gridColWidth: number;\n panelFullHeight?: number;\n panelOptions?: PanelOptions;\n isEditMode?: boolean;\n onLayoutChange?: (currentLayout: Layout[], allLayouts: Layouts) => void;\n onWidthChange?: (\n containerWidth: number,\n margin: [number, number],\n cols: number,\n containerPadding: [number, number]\n ) => void;\n repeatVariable?: [string, string];\n}\n\nexport function Row({\n panelGroupId,\n groupDefinition,\n gridColWidth,\n panelFullHeight,\n panelOptions,\n isEditMode = false,\n onLayoutChange,\n onWidthChange,\n repeatVariable,\n}: RowProps): ReactElement {\n const ResponsiveGridLayout = useMemo(() => WidthProvider(Responsive), []);\n const theme = useTheme();\n const viewPanelItemId = useViewPanelGroup();\n\n const [isOpen, setIsOpen] = useState(!groupDefinition.isCollapsed);\n\n const hasViewPanel =\n viewPanelItemId?.panelGroupId === panelGroupId &&\n // Check for repeatVariable panels\n viewPanelItemId.repeatVariable?.[0] === repeatVariable?.[0] &&\n viewPanelItemId.repeatVariable?.[1] === repeatVariable?.[1];\n const itemLayoutViewed = viewPanelItemId?.panelGroupItemLayoutId;\n\n // If there is a panel in view mode, we should hide the grid if the panel is not in the current group.\n const isGridDisplayed = !viewPanelItemId || hasViewPanel;\n\n // TODO: handle it without useEffect\n useEffect(() => {\n if (hasViewPanel) {\n setIsOpen(true);\n }\n }, [hasViewPanel]);\n\n // Item layout is override if there is a panel in view mode\n const itemLayouts: PanelGroupItemLayout[] = useMemo(() => {\n if (itemLayoutViewed) {\n return groupDefinition.itemLayouts.map((itemLayout) => {\n if (itemLayout.i === itemLayoutViewed) {\n const rowTitleHeight = 40 + 8; // 40 is the height of the row title and 8 is the margin height\n return {\n h: Math.round(((panelFullHeight ?? window.innerHeight) - rowTitleHeight) / (ROW_HEIGHT + DEFAULT_MARGIN)), // Viewed panel should take the full height remaining\n i: itemLayoutViewed,\n w: 48,\n x: 0,\n y: 0,\n } as PanelGroupItemLayout;\n }\n return itemLayout;\n });\n }\n return groupDefinition.itemLayouts;\n }, [groupDefinition.itemLayouts, itemLayoutViewed, panelFullHeight]);\n\n return (\n <GridContainer\n sx={{\n display: isGridDisplayed ? 'block' : 'none',\n height: itemLayoutViewed ? `${panelFullHeight}px` : 'unset',\n overflow: itemLayoutViewed ? 'hidden' : 'unset',\n }}\n >\n {groupDefinition.title && (\n <GridTitle\n panelGroupId={panelGroupId}\n title={groupDefinition.title}\n collapse={\n groupDefinition.isCollapsed === undefined\n ? undefined\n : { isOpen: isOpen, onToggleOpen: () => setIsOpen((current) => !current) }\n }\n />\n )}\n <Collapse in={isOpen} unmountOnExit appear={false} data-testid=\"panel-group-content\">\n <ResponsiveGridLayout\n className=\"layout\"\n breakpoints={{ [GRID_LAYOUT_SMALL_BREAKPOINT]: theme.breakpoints.values.sm, xxs: 0 }}\n cols={GRID_LAYOUT_COLS}\n rowHeight={ROW_HEIGHT}\n draggableHandle=\".drag-handle\"\n resizeHandles={['se']}\n isDraggable={isEditMode && !hasViewPanel}\n isResizable={isEditMode && !hasViewPanel}\n margin={[DEFAULT_MARGIN, DEFAULT_MARGIN]}\n containerPadding={[0, 10]}\n layouts={{ sm: itemLayouts }}\n onLayoutChange={onLayoutChange}\n onWidthChange={onWidthChange}\n allowOverlap={hasViewPanel} // Enabling overlap when viewing a specific panel because panel in front of the viewed panel will add empty spaces (empty row height)\n >\n {itemLayouts.map(({ i, w }) => (\n <div\n key={i}\n style={{\n display: itemLayoutViewed ? (itemLayoutViewed === i ? 'unset' : 'none') : 'unset',\n }}\n >\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <GridItemContent\n panelOptions={panelOptions}\n panelGroupItemId={{ panelGroupId, panelGroupItemLayoutId: i, repeatVariable }}\n width={calculateGridItemWidth(w, gridColWidth)}\n />\n </ErrorBoundary>\n </div>\n ))}\n </ResponsiveGridLayout>\n </Collapse>\n </GridContainer>\n );\n}\n\nconst calculateGridItemWidth = (w: number, colWidth: number): number => {\n // 0 * Infinity === NaN, which causes problems with resize contraints\n if (!Number.isFinite(w)) return w;\n return Math.round(colWidth * w + Math.max(0, w - 1) * DEFAULT_MARGIN);\n};\n"],"names":["Collapse","useTheme","useViewPanelGroup","useEffect","useMemo","useState","Responsive","WidthProvider","ErrorAlert","ErrorBoundary","GRID_LAYOUT_COLS","GRID_LAYOUT_SMALL_BREAKPOINT","GridContainer","GridItemContent","GridTitle","DEFAULT_MARGIN","ROW_HEIGHT","Row","panelGroupId","groupDefinition","gridColWidth","panelFullHeight","panelOptions","isEditMode","onLayoutChange","onWidthChange","repeatVariable","ResponsiveGridLayout","theme","viewPanelItemId","isOpen","setIsOpen","isCollapsed","hasViewPanel","itemLayoutViewed","panelGroupItemLayoutId","isGridDisplayed","itemLayouts","map","itemLayout","i","rowTitleHeight","h","Math","round","window","innerHeight","w","x","y","sx","display","height","overflow","title","collapse","undefined","onToggleOpen","current","in","unmountOnExit","appear","data-testid","className","breakpoints","values","sm","xxs","cols","rowHeight","draggableHandle","resizeHandles","isDraggable","isResizable","margin","containerPadding","layouts","allowOverlap","div","style","FallbackComponent","panelGroupItemId","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BAAEC,KAAK;oBAAE;oBACnFC,MAAM1D;oBACN2D,WAAWrD;oBACXsD,iBAAgB;oBAChBC,eAAe;wBAAC;qBAAK;oBACrBC,aAAajD,cAAc,CAACU;oBAC5BwC,aAAalD,cAAc,CAACU;oBAC5ByC,QAAQ;wBAAC3D;wBAAgBA;qBAAe;oBACxC4D,kBAAkB;wBAAC;wBAAG;qBAAG;oBACzBC,SAAS;wBAAEV,IAAI7B;oBAAY;oBAC3Bb,gBAAgBA;oBAChBC,eAAeA;oBACfoD,cAAc5C;8BAEbI,YAAYC,GAAG,CAAC,CAAC,EAAEE,CAAC,EAAEO,CAAC,EAAE,iBACxB,KAAC+B;4BAECC,OAAO;gCACL5B,SAASjB,mBAAoBA,qBAAqBM,IAAI,UAAU,SAAU;4BAC5E;sCAEA,cAAA,KAAC/B;gCAAcuE,mBAAmBxE;0CAChC,cAAA,KAACK;oCACCS,cAAcA;oCACd2D,kBAAkB;wCAAE/D;wCAAciB,wBAAwBK;wCAAGd;oCAAe;oCAC5EwD,OAAOC,uBAAuBpC,GAAG3B;;;2BAThCoB;;;;;AAkBnB;AAEA,MAAM2C,yBAAyB,CAACpC,GAAWqC;IACzC,qEAAqE;IACrE,IAAI,CAACC,OAAOC,QAAQ,CAACvC,IAAI,OAAOA;IAChC,OAAOJ,KAAKC,KAAK,CAACwC,WAAWrC,IAAIJ,KAAK4C,GAAG,CAAC,GAAGxC,IAAI,KAAKhC;AACxD"}
@@ -1,7 +1,6 @@
1
1
  import { CardProps } from '@mui/material';
2
- import { PanelDefinition } from '@perses-dev/core';
2
+ import { PanelDefinition, PanelGroupItemId } from '@perses-dev/core';
3
3
  import { ReactNode } from 'react';
4
- import { PanelGroupItemId } from '../../context';
5
4
  import { PanelHeaderProps } from './PanelHeader';
6
5
  export interface PanelProps extends CardProps<'section'> {
7
6
  definition: PanelDefinition;