@perses-dev/dashboards 0.53.0-beta.3 → 0.53.0-rc.0

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 (37) hide show
  1. package/dist/cjs/components/GridLayout/GridLayout.js +3 -3
  2. package/dist/cjs/components/LeaveDialog/LeaveDialog.js +3 -3
  3. package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +3 -3
  4. package/dist/cjs/components/PanelGroupDialog/PanelGroupEditorForm.js +3 -3
  5. package/dist/cjs/components/Variables/ListVariableListBox.js +4 -4
  6. package/dist/cjs/components/Variables/Variable.js +3 -3
  7. package/dist/cjs/components/Variables/VariableEditor.js +3 -3
  8. package/dist/cjs/components/Variables/VariableList.js +3 -3
  9. package/dist/cjs/constants/grid-layout-config.js +3 -3
  10. package/dist/cjs/constants/styles.js +7 -7
  11. package/dist/cjs/constants/user-interface-text.js +3 -3
  12. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +4 -4
  13. package/dist/cjs/context/DashboardProvider/common.js +3 -3
  14. package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +19 -19
  15. package/dist/cjs/context/DashboardProvider/duplicate-panel-slice.js +1 -1
  16. package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +1 -1
  17. package/dist/cjs/context/DashboardProvider/panel-group-slice.js +5 -5
  18. package/dist/cjs/context/PanelEditorProvider/PanelEditorProvider.js +3 -3
  19. package/dist/cjs/context/VariableProvider/VariableProvider.js +9 -9
  20. package/dist/cjs/context/VariableProvider/query-params.js +6 -6
  21. package/dist/cjs/context/VariableProvider/utils.js +5 -5
  22. package/dist/cjs/test/dashboard-provider.js +3 -3
  23. package/dist/cjs/test/datasource-provider.js +4 -4
  24. package/dist/cjs/utils/panelUtils.js +11 -48
  25. package/dist/components/Panel/HeaderIconButton.d.ts +6 -4
  26. package/dist/components/Panel/HeaderIconButton.d.ts.map +1 -1
  27. package/dist/components/Panel/HeaderIconButton.js.map +1 -1
  28. package/dist/context/DashboardProvider/duplicate-panel-slice.js +2 -2
  29. package/dist/context/DashboardProvider/duplicate-panel-slice.js.map +1 -1
  30. package/dist/context/DashboardProvider/panel-editor-slice.js +2 -2
  31. package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
  32. package/dist/utils/panelUtils.d.ts +3 -8
  33. package/dist/utils/panelUtils.d.ts.map +1 -1
  34. package/dist/utils/panelUtils.js +7 -49
  35. package/dist/utils/panelUtils.js.map +1 -1
  36. package/package.json +3 -4
  37. package/LICENSE +0 -201
@@ -17,14 +17,14 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- GridLayout: function() {
24
+ get GridLayout () {
25
25
  return GridLayout;
26
26
  },
27
- RepeatGridLayout: function() {
27
+ get RepeatGridLayout () {
28
28
  return RepeatGridLayout;
29
29
  }
30
30
  });
@@ -17,14 +17,14 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- LeaveDialog: function() {
24
+ get LeaveDialog () {
25
25
  return LeaveDialog;
26
26
  },
27
- Prompt: function() {
27
+ get Prompt () {
28
28
  return Prompt;
29
29
  }
30
30
  });
@@ -17,14 +17,14 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- PanelEditorForm: function() {
24
+ get PanelEditorForm () {
25
25
  return PanelEditorForm;
26
26
  },
27
- panelEditorFormId: function() {
27
+ get panelEditorFormId () {
28
28
  return panelEditorFormId;
29
29
  }
30
30
  });
@@ -17,14 +17,14 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- PanelGroupEditorForm: function() {
24
+ get PanelGroupEditorForm () {
25
25
  return PanelGroupEditorForm;
26
26
  },
27
- panelGroupEditorFormId: function() {
27
+ get panelGroupEditorFormId () {
28
28
  return panelGroupEditorFormId;
29
29
  }
30
30
  });
@@ -17,17 +17,17 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- ListVariableListBox: function() {
24
+ get ListVariableListBox () {
25
25
  return ListVariableListBox;
26
26
  },
27
- ListVariableListBoxProvider: function() {
27
+ get ListVariableListBoxProvider () {
28
28
  return ListVariableListBoxProvider;
29
29
  },
30
- useListVariableListBoxContext: function() {
30
+ get useListVariableListBoxContext () {
31
31
  return useListVariableListBoxContext;
32
32
  }
33
33
  });
@@ -17,14 +17,14 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- Variable: function() {
24
+ get Variable () {
25
25
  return Variable;
26
26
  },
27
- useListVariableState: function() {
27
+ get useListVariableState () {
28
28
  return useListVariableState;
29
29
  }
30
30
  });
@@ -17,14 +17,14 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- VariableEditor: function() {
24
+ get VariableEditor () {
25
25
  return VariableEditor;
26
26
  },
27
- VariableName: function() {
27
+ get VariableName () {
28
28
  return VariableName;
29
29
  }
30
30
  });
@@ -17,14 +17,14 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- VariableList: function() {
24
+ get VariableList () {
25
25
  return VariableList;
26
26
  },
27
- VariableListItem: function() {
27
+ get VariableListItem () {
28
28
  return VariableListItem;
29
29
  }
30
30
  });
@@ -17,14 +17,14 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- GRID_LAYOUT_COLS: function() {
24
+ get GRID_LAYOUT_COLS () {
25
25
  return GRID_LAYOUT_COLS;
26
26
  },
27
- GRID_LAYOUT_SMALL_BREAKPOINT: function() {
27
+ get GRID_LAYOUT_SMALL_BREAKPOINT () {
28
28
  return GRID_LAYOUT_SMALL_BREAKPOINT;
29
29
  }
30
30
  });
@@ -17,26 +17,26 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- HEADER_ACTIONS_CONTAINER_NAME: function() {
24
+ get HEADER_ACTIONS_CONTAINER_NAME () {
25
25
  return HEADER_ACTIONS_CONTAINER_NAME;
26
26
  },
27
- HEADER_MEDIUM_WIDTH: function() {
27
+ get HEADER_MEDIUM_WIDTH () {
28
28
  return HEADER_MEDIUM_WIDTH;
29
29
  },
30
- HEADER_SMALL_WIDTH: function() {
30
+ get HEADER_SMALL_WIDTH () {
31
31
  return HEADER_SMALL_WIDTH;
32
32
  },
33
- MAX_VARIABLE_WIDTH: function() {
33
+ get MAX_VARIABLE_WIDTH () {
34
34
  return MAX_VARIABLE_WIDTH;
35
35
  },
36
- MIN_VARIABLE_WIDTH: function() {
36
+ get MIN_VARIABLE_WIDTH () {
37
37
  return MIN_VARIABLE_WIDTH;
38
38
  },
39
- editButtonStyle: function() {
39
+ get editButtonStyle () {
40
40
  return editButtonStyle;
41
41
  }
42
42
  });
@@ -17,14 +17,14 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- ARIA_LABEL_TEXT: function() {
24
+ get ARIA_LABEL_TEXT () {
25
25
  return ARIA_LABEL_TEXT;
26
26
  },
27
- TOOLTIP_TEXT: function() {
27
+ get TOOLTIP_TEXT () {
28
28
  return TOOLTIP_TEXT;
29
29
  }
30
30
  });
@@ -17,17 +17,17 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- DashboardContext: function() {
24
+ get DashboardContext () {
25
25
  return DashboardContext;
26
26
  },
27
- DashboardProvider: function() {
27
+ get DashboardProvider () {
28
28
  return DashboardProvider;
29
29
  },
30
- useDashboardStore: function() {
30
+ get useDashboardStore () {
31
31
  return useDashboardStore;
32
32
  }
33
33
  });
@@ -17,14 +17,14 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- createPanelDefinition: function() {
24
+ get createPanelDefinition () {
25
25
  return createPanelDefinition;
26
26
  },
27
- generateId: function() {
27
+ get generateId () {
28
28
  return generateId;
29
29
  }
30
30
  });
@@ -17,62 +17,62 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- useDashboardActions: function() {
24
+ get useDashboardActions () {
25
25
  return useDashboardActions;
26
26
  },
27
- useDashboardDuration: function() {
27
+ get useDashboardDuration () {
28
28
  return useDashboardDuration;
29
29
  },
30
- useDeletePanelDialog: function() {
30
+ get useDeletePanelDialog () {
31
31
  return useDeletePanelDialog;
32
32
  },
33
- useDeletePanelGroupDialog: function() {
33
+ get useDeletePanelGroupDialog () {
34
34
  return useDeletePanelGroupDialog;
35
35
  },
36
- useDiscardChangesConfirmationDialog: function() {
36
+ get useDiscardChangesConfirmationDialog () {
37
37
  return useDiscardChangesConfirmationDialog;
38
38
  },
39
- useEditJsonDialog: function() {
39
+ get useEditJsonDialog () {
40
40
  return useEditJsonDialog;
41
41
  },
42
- useEditMode: function() {
42
+ get useEditMode () {
43
43
  return useEditMode;
44
44
  },
45
- useListPanelGroups: function() {
45
+ get useListPanelGroups () {
46
46
  return useListPanelGroups;
47
47
  },
48
- usePanel: function() {
48
+ get usePanel () {
49
49
  return usePanel;
50
50
  },
51
- usePanelActions: function() {
51
+ get usePanelActions () {
52
52
  return usePanelActions;
53
53
  },
54
- usePanelEditor: function() {
54
+ get usePanelEditor () {
55
55
  return usePanelEditor;
56
56
  },
57
- usePanelGroup: function() {
57
+ get usePanelGroup () {
58
58
  return usePanelGroup;
59
59
  },
60
- usePanelGroupActions: function() {
60
+ get usePanelGroupActions () {
61
61
  return usePanelGroupActions;
62
62
  },
63
- usePanelGroupEditor: function() {
63
+ get usePanelGroupEditor () {
64
64
  return usePanelGroupEditor;
65
65
  },
66
- usePanelGroupIds: function() {
66
+ get usePanelGroupIds () {
67
67
  return usePanelGroupIds;
68
68
  },
69
- useSaveChangesConfirmationDialog: function() {
69
+ get useSaveChangesConfirmationDialog () {
70
70
  return useSaveChangesConfirmationDialog;
71
71
  },
72
- useViewPanel: function() {
72
+ get useViewPanel () {
73
73
  return useViewPanel;
74
74
  },
75
- useViewPanelGroup: function() {
75
+ get useViewPanelGroup () {
76
76
  return useViewPanelGroup;
77
77
  }
78
78
  });
@@ -49,7 +49,7 @@ function createDuplicatePanelSlice() {
49
49
  if (matchingLayout === undefined) {
50
50
  throw new Error(`Cannot find layout for Panel with key '${panelKey}'`);
51
51
  }
52
- const dupePanelKey = crypto.randomUUID().replaceAll('-', '');
52
+ const dupePanelKey = (0, _panelUtils.generatePanelKey)();
53
53
  state.panels[dupePanelKey] = panelToDupe;
54
54
  const duplicateLayout = {
55
55
  i: (0, _common.generateId)().toString(),
@@ -110,7 +110,7 @@ function createPanelEditorSlice() {
110
110
  panelDefinition: get().initialValues?.panelDefinition ?? (0, _common.createPanelDefinition)()
111
111
  },
112
112
  applyChanges: (next)=>{
113
- const panelKey = crypto.randomUUID().replaceAll('-', '');
113
+ const panelKey = (0, _utils.generatePanelKey)();
114
114
  set((state)=>{
115
115
  // Add a panel
116
116
  state.panels[panelKey] = next.panelDefinition;
@@ -17,20 +17,20 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- addPanelGroup: function() {
24
+ get addPanelGroup () {
25
25
  return addPanelGroup;
26
26
  },
27
- convertLayoutsToPanelGroups: function() {
27
+ get convertLayoutsToPanelGroups () {
28
28
  return convertLayoutsToPanelGroups;
29
29
  },
30
- createEmptyPanelGroup: function() {
30
+ get createEmptyPanelGroup () {
31
31
  return createEmptyPanelGroup;
32
32
  },
33
- createPanelGroupSlice: function() {
33
+ get createPanelGroupSlice () {
34
34
  return createPanelGroupSlice;
35
35
  }
36
36
  });
@@ -17,14 +17,14 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- PanelEditorContext: function() {
24
+ get PanelEditorContext () {
25
25
  return PanelEditorContext;
26
26
  },
27
- PanelEditorProvider: function() {
27
+ get PanelEditorProvider () {
28
28
  return PanelEditorProvider;
29
29
  }
30
30
  });
@@ -17,32 +17,32 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- VariableProvider: function() {
24
+ get VariableProvider () {
25
25
  return VariableProvider;
26
26
  },
27
- VariableProviderWithQueryParams: function() {
27
+ get VariableProviderWithQueryParams () {
28
28
  return VariableProviderWithQueryParams;
29
29
  },
30
- useExternalVariableDefinitions: function() {
30
+ get useExternalVariableDefinitions () {
31
31
  return useExternalVariableDefinitions;
32
32
  },
33
- useVariableDefinitionActions: function() {
33
+ get useVariableDefinitionActions () {
34
34
  return useVariableDefinitionActions;
35
35
  },
36
- useVariableDefinitionAndState: function() {
36
+ get useVariableDefinitionAndState () {
37
37
  return useVariableDefinitionAndState;
38
38
  },
39
- useVariableDefinitionStates: function() {
39
+ get useVariableDefinitionStates () {
40
40
  return useVariableDefinitionStates;
41
41
  },
42
- useVariableDefinitionStoreCtx: function() {
42
+ get useVariableDefinitionStoreCtx () {
43
43
  return useVariableDefinitionStoreCtx;
44
44
  },
45
- useVariableDefinitions: function() {
45
+ get useVariableDefinitions () {
46
46
  return useVariableDefinitions;
47
47
  }
48
48
  });
@@ -17,23 +17,23 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- decodeVariableValue: function() {
24
+ get decodeVariableValue () {
25
25
  return decodeVariableValue;
26
26
  },
27
- encodeVariableValue: function() {
27
+ get encodeVariableValue () {
28
28
  return encodeVariableValue;
29
29
  },
30
- getInitalValuesFromQueryParameters: function() {
30
+ get getInitalValuesFromQueryParameters () {
31
31
  return getInitalValuesFromQueryParameters;
32
32
  },
33
- getURLQueryParamName: function() {
33
+ get getURLQueryParamName () {
34
34
  return getURLQueryParamName;
35
35
  },
36
- useVariableQueryParams: function() {
36
+ get useVariableQueryParams () {
37
37
  return useVariableQueryParams;
38
38
  }
39
39
  });
@@ -17,20 +17,20 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- checkSavedDefaultVariableStatus: function() {
24
+ get checkSavedDefaultVariableStatus () {
25
25
  return checkSavedDefaultVariableStatus;
26
26
  },
27
- findVariableDefinitionByName: function() {
27
+ get findVariableDefinitionByName () {
28
28
  return findVariableDefinitionByName;
29
29
  },
30
- forEachVariableDefinition: function() {
30
+ get forEachVariableDefinition () {
31
31
  return forEachVariableDefinition;
32
32
  },
33
- mergeVariableDefinitions: function() {
33
+ get mergeVariableDefinitions () {
34
34
  return mergeVariableDefinitions;
35
35
  }
36
36
  });
@@ -17,14 +17,14 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- createDashboardProviderSpy: function() {
24
+ get createDashboardProviderSpy () {
25
25
  return createDashboardProviderSpy;
26
26
  },
27
- getTestDashboard: function() {
27
+ get getTestDashboard () {
28
28
  return getTestDashboard;
29
29
  }
30
30
  });
@@ -17,17 +17,17 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- defaultDatasourceProps: function() {
24
+ get defaultDatasourceProps () {
25
25
  return defaultDatasourceProps;
26
26
  },
27
- prometheusDemo: function() {
27
+ get prometheusDemo () {
28
28
  return prometheusDemo;
29
29
  },
30
- prometheusDemoUrl: function() {
30
+ get prometheusDemoUrl () {
31
31
  return prometheusDemoUrl;
32
32
  }
33
33
  });
@@ -17,17 +17,17 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- getValidPanelKey: function() {
25
- return getValidPanelKey;
24
+ get generatePanelKey () {
25
+ return generatePanelKey;
26
26
  },
27
- getYForNewRow: function() {
27
+ get getYForNewRow () {
28
28
  return getYForNewRow;
29
29
  },
30
- insertPanelInLayout: function() {
30
+ get insertPanelInLayout () {
31
31
  return insertPanelInLayout;
32
32
  }
33
33
  });
@@ -127,48 +127,11 @@ function insertPanelInLayout(newLayout, referenceLayout, itemLayouts) {
127
127
  })
128
128
  ];
129
129
  }
130
- function getValidPanelKey(panelKey, panels) {
131
- const uniquePanelKeys = getUniquePanelKeys(panels);
132
- let normalizedPanelKey = getPanelKeyParts(removeWhiteSpaces(panelKey)).name;
133
- const matchingKey = uniquePanelKeys[normalizedPanelKey];
134
- if (typeof matchingKey === 'number') {
135
- normalizedPanelKey += `-${matchingKey + 1}`;
130
+ const generatePanelKey = ()=>{
131
+ /* crypto.randomUUID() is only available in secure contexts (HTTPS), */ if (window.isSecureContext) {
132
+ return crypto.randomUUID().replaceAll('-', '');
136
133
  }
137
- return normalizedPanelKey;
138
- }
139
- const removeWhiteSpaces = (str)=>{
140
- return str.replace(/\s+/g, '');
134
+ const timestamp = String(Date.now());
135
+ const randomSuffix = Math.random().toString(36).substring(2);
136
+ return `${timestamp}${randomSuffix}`;
141
137
  };
142
- /**
143
- * Breaks the specified panel key into the name and the optional `-number` used
144
- * for deduping panels with the same name.
145
- */ function getPanelKeyParts(panelKey) {
146
- const parts = panelKey.match(/(.+)-([0-9]+)/);
147
- if (parts && parts[1] && parts[2]) {
148
- return {
149
- name: parts[1],
150
- number: parseInt(parts[2], 10)
151
- };
152
- }
153
- return {
154
- name: panelKey
155
- };
156
- }
157
- // Find all the unique panel keys and the largest number used for each.
158
- // ex: cpu, cpu-1, cpu-2 count as the same panel key since these panels have the same name
159
- function getUniquePanelKeys(panels) {
160
- const uniquePanelKeys = {};
161
- Object.keys(panels).forEach((panelKey)=>{
162
- const { name, number } = getPanelKeyParts(panelKey);
163
- if (uniquePanelKeys[name] === undefined) {
164
- uniquePanelKeys[name] = 0;
165
- }
166
- const currentValue = uniquePanelKeys[name];
167
- if (typeof currentValue === 'number' && number) {
168
- // Check for the maximum value because we cannot rely on a sequential
169
- // set of numbers when panels are modified.
170
- uniquePanelKeys[name] = Math.max(currentValue, number);
171
- }
172
- });
173
- return uniquePanelKeys;
174
- }
@@ -1,5 +1,7 @@
1
- /// <reference types="react" />
2
- export declare const HeaderIconButton: import("@emotion/styled").StyledComponent<import("@mui/material").IconButtonOwnProps & Omit<import("@mui/material").ButtonBaseOwnProps, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
3
- ref?: ((instance: HTMLButtonElement | null) => void) | import("react").RefObject<HTMLButtonElement> | null | undefined;
4
- }, "color" | "children" | "className" | "style" | "classes" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "tabIndex" | "TouchRippleProps" | "touchRippleRef" | "disableFocusRipple" | "loading" | "loadingIndicator" | "size" | "edge"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
1
+ import { IconButtonProps } from '@mui/material';
2
+ import { StyledComponent } from '@emotion/styled';
3
+ import { Theme } from '@mui/material/styles';
4
+ export declare const HeaderIconButton: StyledComponent<IconButtonProps & {
5
+ theme?: Theme;
6
+ }>;
5
7
  //# sourceMappingURL=HeaderIconButton.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"HeaderIconButton.d.ts","sourceRoot":"","sources":["../../../src/components/Panel/HeaderIconButton.tsx"],"names":[],"mappings":";AAeA,eAAO,MAAM,gBAAgB;;wbAG1B,CAAC"}
1
+ {"version":3,"file":"HeaderIconButton.d.ts","sourceRoot":"","sources":["../../../src/components/Panel/HeaderIconButton.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAc,eAAe,EAAU,MAAM,eAAe,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE7C,eAAO,MAAM,gBAAgB,EAAE,eAAe,CAAC,eAAe,GAAG;IAAE,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,CAKjF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Panel/HeaderIconButton.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 { IconButton, styled } from '@mui/material';\n\nexport const HeaderIconButton = styled(IconButton)(({ theme }) => ({\n borderRadius: theme.shape.borderRadius,\n padding: '4px',\n}));\n"],"names":["IconButton","styled","HeaderIconButton","theme","borderRadius","shape","padding"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,UAAU,EAAEC,MAAM,QAAQ,gBAAgB;AAEnD,OAAO,MAAMC,mBAAmBD,OAAOD,YAAY,CAAC,EAAEG,KAAK,EAAE,GAAM,CAAA;QACjEC,cAAcD,MAAME,KAAK,CAACD,YAAY;QACtCE,SAAS;IACX,CAAA,GAAI"}
1
+ {"version":3,"sources":["../../../src/components/Panel/HeaderIconButton.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 { IconButton, IconButtonProps, styled } from '@mui/material';\nimport { StyledComponent } from '@emotion/styled';\nimport { Theme } from '@mui/material/styles';\n\nexport const HeaderIconButton: StyledComponent<IconButtonProps & { theme?: Theme }> = styled(IconButton)(\n ({ theme }) => ({\n borderRadius: theme.shape.borderRadius,\n padding: '4px',\n })\n);\n"],"names":["IconButton","styled","HeaderIconButton","theme","borderRadius","shape","padding"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,UAAU,EAAmBC,MAAM,QAAQ,gBAAgB;AAIpE,OAAO,MAAMC,mBAAyED,OAAOD,YAC3F,CAAC,EAAEG,KAAK,EAAE,GAAM,CAAA;QACdC,cAAcD,MAAME,KAAK,CAACD,YAAY;QACtCE,SAAS;IACX,CAAA,GACA"}
@@ -10,7 +10,7 @@
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 { insertPanelInLayout } from '../../utils/panelUtils';
13
+ import { generatePanelKey, insertPanelInLayout } from '../../utils/panelUtils';
14
14
  import { generateId } from './common';
15
15
  /**
16
16
  * Curried function for duplicating a panel.
@@ -41,7 +41,7 @@ import { generateId } from './common';
41
41
  if (matchingLayout === undefined) {
42
42
  throw new Error(`Cannot find layout for Panel with key '${panelKey}'`);
43
43
  }
44
- const dupePanelKey = crypto.randomUUID().replaceAll('-', '');
44
+ const dupePanelKey = generatePanelKey();
45
45
  state.panels[dupePanelKey] = panelToDupe;
46
46
  const duplicateLayout = {
47
47
  i: generateId().toString(),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/DashboardProvider/duplicate-panel-slice.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { StateCreator } from 'zustand';\nimport { PanelGroupItemId } from '@perses-dev/core';\nimport { insertPanelInLayout, UnpositionedPanelGroupItemLayout } from '../../utils/panelUtils';\nimport { generateId, Middleware } from './common';\nimport { PanelGroupSlice } from './panel-group-slice';\nimport { PanelSlice } from './panel-slice';\n\n/**\n * Slice that handles duplicating Panels.\n */\nexport interface DuplicatePanelSlice {\n /**\n * Duplicate panel.\n */\n duplicatePanel: (panelGroupItemId: PanelGroupItemId) => void;\n}\n\n/**\n * Curried function for duplicating a panel.\n */\nexport function createDuplicatePanelSlice(): StateCreator<\n // Actions in here need to modify both Panels and Panel Groups state\n DuplicatePanelSlice & PanelSlice & PanelGroupSlice,\n Middleware,\n [],\n DuplicatePanelSlice\n> {\n return (set) => ({\n duplicatePanel(panelGroupItemId: PanelGroupItemId): void {\n set((state) => {\n const panels = state.panels;\n\n // Figure out the panel key at that location\n const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;\n const group = state.panelGroups[panelGroupId];\n if (group === undefined) {\n throw new Error(`Missing panel group ${panelGroupId}`);\n }\n const panelKey = group.itemPanelKeys[panelGroupLayoutId];\n if (panelKey === undefined) {\n throw new Error(`Could not find Panel Group item ${panelGroupItemId}`);\n }\n\n // Find the panel to edit\n const panelToDupe = panels[panelKey];\n if (panelToDupe === undefined) {\n throw new Error(`Cannot find Panel with key '${panelKey}'`);\n }\n\n // Find the layout for the item being duped\n const matchingLayout = group.itemLayouts.find((itemLayout) => {\n return itemLayout.i === panelGroupLayoutId;\n });\n\n if (matchingLayout === undefined) {\n throw new Error(`Cannot find layout for Panel with key '${panelKey}'`);\n }\n\n const dupePanelKey = crypto.randomUUID().replaceAll('-', '');\n\n state.panels[dupePanelKey] = panelToDupe;\n\n const duplicateLayout: UnpositionedPanelGroupItemLayout = {\n i: generateId().toString(),\n w: matchingLayout.w,\n h: matchingLayout.h,\n };\n\n group.itemLayouts = insertPanelInLayout(duplicateLayout, matchingLayout, group.itemLayouts);\n\n group.itemPanelKeys[duplicateLayout.i] = dupePanelKey;\n });\n },\n });\n}\n"],"names":["insertPanelInLayout","generateId","createDuplicatePanelSlice","set","duplicatePanel","panelGroupItemId","state","panels","panelGroupId","panelGroupItemLayoutId","panelGroupLayoutId","group","panelGroups","undefined","Error","panelKey","itemPanelKeys","panelToDupe","matchingLayout","itemLayouts","find","itemLayout","i","dupePanelKey","crypto","randomUUID","replaceAll","duplicateLayout","toString","w","h"],"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;AAIjC,SAASA,mBAAmB,QAA0C,yBAAyB;AAC/F,SAASC,UAAU,QAAoB,WAAW;AAclD;;CAEC,GACD,OAAO,SAASC;IAOd,OAAO,CAACC,MAAS,CAAA;YACfC,gBAAeC,gBAAkC;gBAC/CF,IAAI,CAACG;oBACH,MAAMC,SAASD,MAAMC,MAAM;oBAE3B,4CAA4C;oBAC5C,MAAM,EAAEC,YAAY,EAAEC,wBAAwBC,kBAAkB,EAAE,GAAGL;oBACrE,MAAMM,QAAQL,MAAMM,WAAW,CAACJ,aAAa;oBAC7C,IAAIG,UAAUE,WAAW;wBACvB,MAAM,IAAIC,MAAM,CAAC,oBAAoB,EAAEN,cAAc;oBACvD;oBACA,MAAMO,WAAWJ,MAAMK,aAAa,CAACN,mBAAmB;oBACxD,IAAIK,aAAaF,WAAW;wBAC1B,MAAM,IAAIC,MAAM,CAAC,gCAAgC,EAAET,kBAAkB;oBACvE;oBAEA,yBAAyB;oBACzB,MAAMY,cAAcV,MAAM,CAACQ,SAAS;oBACpC,IAAIE,gBAAgBJ,WAAW;wBAC7B,MAAM,IAAIC,MAAM,CAAC,4BAA4B,EAAEC,SAAS,CAAC,CAAC;oBAC5D;oBAEA,2CAA2C;oBAC3C,MAAMG,iBAAiBP,MAAMQ,WAAW,CAACC,IAAI,CAAC,CAACC;wBAC7C,OAAOA,WAAWC,CAAC,KAAKZ;oBAC1B;oBAEA,IAAIQ,mBAAmBL,WAAW;wBAChC,MAAM,IAAIC,MAAM,CAAC,uCAAuC,EAAEC,SAAS,CAAC,CAAC;oBACvE;oBAEA,MAAMQ,eAAeC,OAAOC,UAAU,GAAGC,UAAU,CAAC,KAAK;oBAEzDpB,MAAMC,MAAM,CAACgB,aAAa,GAAGN;oBAE7B,MAAMU,kBAAoD;wBACxDL,GAAGrB,aAAa2B,QAAQ;wBACxBC,GAAGX,eAAeW,CAAC;wBACnBC,GAAGZ,eAAeY,CAAC;oBACrB;oBAEAnB,MAAMQ,WAAW,GAAGnB,oBAAoB2B,iBAAiBT,gBAAgBP,MAAMQ,WAAW;oBAE1FR,MAAMK,aAAa,CAACW,gBAAgBL,CAAC,CAAC,GAAGC;gBAC3C;YACF;QACF,CAAA;AACF"}
1
+ {"version":3,"sources":["../../../src/context/DashboardProvider/duplicate-panel-slice.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { StateCreator } from 'zustand';\nimport { PanelGroupItemId } from '@perses-dev/core';\nimport { generatePanelKey, insertPanelInLayout, UnpositionedPanelGroupItemLayout } from '../../utils/panelUtils';\nimport { generateId, Middleware } from './common';\nimport { PanelGroupSlice } from './panel-group-slice';\nimport { PanelSlice } from './panel-slice';\n\n/**\n * Slice that handles duplicating Panels.\n */\nexport interface DuplicatePanelSlice {\n /**\n * Duplicate panel.\n */\n duplicatePanel: (panelGroupItemId: PanelGroupItemId) => void;\n}\n\n/**\n * Curried function for duplicating a panel.\n */\nexport function createDuplicatePanelSlice(): StateCreator<\n // Actions in here need to modify both Panels and Panel Groups state\n DuplicatePanelSlice & PanelSlice & PanelGroupSlice,\n Middleware,\n [],\n DuplicatePanelSlice\n> {\n return (set) => ({\n duplicatePanel(panelGroupItemId: PanelGroupItemId): void {\n set((state) => {\n const panels = state.panels;\n\n // Figure out the panel key at that location\n const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;\n const group = state.panelGroups[panelGroupId];\n if (group === undefined) {\n throw new Error(`Missing panel group ${panelGroupId}`);\n }\n const panelKey = group.itemPanelKeys[panelGroupLayoutId];\n if (panelKey === undefined) {\n throw new Error(`Could not find Panel Group item ${panelGroupItemId}`);\n }\n\n // Find the panel to edit\n const panelToDupe = panels[panelKey];\n if (panelToDupe === undefined) {\n throw new Error(`Cannot find Panel with key '${panelKey}'`);\n }\n\n // Find the layout for the item being duped\n const matchingLayout = group.itemLayouts.find((itemLayout) => {\n return itemLayout.i === panelGroupLayoutId;\n });\n\n if (matchingLayout === undefined) {\n throw new Error(`Cannot find layout for Panel with key '${panelKey}'`);\n }\n\n const dupePanelKey = generatePanelKey();\n\n state.panels[dupePanelKey] = panelToDupe;\n\n const duplicateLayout: UnpositionedPanelGroupItemLayout = {\n i: generateId().toString(),\n w: matchingLayout.w,\n h: matchingLayout.h,\n };\n\n group.itemLayouts = insertPanelInLayout(duplicateLayout, matchingLayout, group.itemLayouts);\n\n group.itemPanelKeys[duplicateLayout.i] = dupePanelKey;\n });\n },\n });\n}\n"],"names":["generatePanelKey","insertPanelInLayout","generateId","createDuplicatePanelSlice","set","duplicatePanel","panelGroupItemId","state","panels","panelGroupId","panelGroupItemLayoutId","panelGroupLayoutId","group","panelGroups","undefined","Error","panelKey","itemPanelKeys","panelToDupe","matchingLayout","itemLayouts","find","itemLayout","i","dupePanelKey","duplicateLayout","toString","w","h"],"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;AAIjC,SAASA,gBAAgB,EAAEC,mBAAmB,QAA0C,yBAAyB;AACjH,SAASC,UAAU,QAAoB,WAAW;AAclD;;CAEC,GACD,OAAO,SAASC;IAOd,OAAO,CAACC,MAAS,CAAA;YACfC,gBAAeC,gBAAkC;gBAC/CF,IAAI,CAACG;oBACH,MAAMC,SAASD,MAAMC,MAAM;oBAE3B,4CAA4C;oBAC5C,MAAM,EAAEC,YAAY,EAAEC,wBAAwBC,kBAAkB,EAAE,GAAGL;oBACrE,MAAMM,QAAQL,MAAMM,WAAW,CAACJ,aAAa;oBAC7C,IAAIG,UAAUE,WAAW;wBACvB,MAAM,IAAIC,MAAM,CAAC,oBAAoB,EAAEN,cAAc;oBACvD;oBACA,MAAMO,WAAWJ,MAAMK,aAAa,CAACN,mBAAmB;oBACxD,IAAIK,aAAaF,WAAW;wBAC1B,MAAM,IAAIC,MAAM,CAAC,gCAAgC,EAAET,kBAAkB;oBACvE;oBAEA,yBAAyB;oBACzB,MAAMY,cAAcV,MAAM,CAACQ,SAAS;oBACpC,IAAIE,gBAAgBJ,WAAW;wBAC7B,MAAM,IAAIC,MAAM,CAAC,4BAA4B,EAAEC,SAAS,CAAC,CAAC;oBAC5D;oBAEA,2CAA2C;oBAC3C,MAAMG,iBAAiBP,MAAMQ,WAAW,CAACC,IAAI,CAAC,CAACC;wBAC7C,OAAOA,WAAWC,CAAC,KAAKZ;oBAC1B;oBAEA,IAAIQ,mBAAmBL,WAAW;wBAChC,MAAM,IAAIC,MAAM,CAAC,uCAAuC,EAAEC,SAAS,CAAC,CAAC;oBACvE;oBAEA,MAAMQ,eAAexB;oBAErBO,MAAMC,MAAM,CAACgB,aAAa,GAAGN;oBAE7B,MAAMO,kBAAoD;wBACxDF,GAAGrB,aAAawB,QAAQ;wBACxBC,GAAGR,eAAeQ,CAAC;wBACnBC,GAAGT,eAAeS,CAAC;oBACrB;oBAEAhB,MAAMQ,WAAW,GAAGnB,oBAAoBwB,iBAAiBN,gBAAgBP,MAAMQ,WAAW;oBAE1FR,MAAMK,aAAa,CAACQ,gBAAgBF,CAAC,CAAC,GAAGC;gBAC3C;YACF;QACF,CAAA;AACF"}
@@ -10,7 +10,7 @@
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 { getYForNewRow } from '../../utils';
13
+ import { generatePanelKey, getYForNewRow } from '../../utils';
14
14
  import { generateId, createPanelDefinition } from './common';
15
15
  import { addPanelGroup, createEmptyPanelGroup } from './panel-group-slice';
16
16
  /**
@@ -102,7 +102,7 @@ import { addPanelGroup, createEmptyPanelGroup } from './panel-group-slice';
102
102
  panelDefinition: get().initialValues?.panelDefinition ?? createPanelDefinition()
103
103
  },
104
104
  applyChanges: (next)=>{
105
- const panelKey = crypto.randomUUID().replaceAll('-', '');
105
+ const panelKey = generatePanelKey();
106
106
  set((state)=>{
107
107
  // Add a panel
108
108
  state.panels[panelKey] = next.panelDefinition;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/DashboardProvider/panel-editor-slice.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {\n Action,\n PanelEditorValues,\n PanelGroupId,\n PanelGroupItemId,\n PanelGroupDefinition,\n PanelGroupItemLayout,\n} from '@perses-dev/core';\nimport { StateCreator } from 'zustand';\nimport { getYForNewRow } from '../../utils';\nimport { generateId, Middleware, createPanelDefinition } from './common';\nimport { PanelGroupSlice, addPanelGroup, createEmptyPanelGroup } from './panel-group-slice';\nimport { PanelSlice } from './panel-slice';\n\n/**\n * Slice that handles the visual editor state and actions for adding or editing Panels.\n */\nexport interface PanelEditorSlice {\n /**\n * Initial values for add panel if default panel kind is defined\n */\n initialValues?: Pick<PanelEditorValues, 'panelDefinition'>;\n\n /**\n * State for the panel editor when its open, otherwise undefined when it's closed.\n */\n panelEditor?: PanelEditorState;\n\n /**\n * Opens the editor for editing an existing panel by providing its layout coordinates.\n */\n openEditPanel: (panelGroupItemId: PanelGroupItemId) => void;\n\n /**\n * Opens the editor for adding a new Panel to a panel group.\n */\n openAddPanel: (panelGroupId?: PanelGroupId) => void;\n}\n\nexport interface PanelEditorState {\n /**\n * Whether we're adding a new panel, or editing an existing panel.\n */\n mode: Action;\n\n /*\n * Original item in a PanelGroup edited\n */\n panelGroupItemId?: PanelGroupItemId;\n\n /**\n * Initial values for the things that can be edited about a panel.\n */\n initialValues: PanelEditorValues;\n\n /**\n * Applies changes, but doesn't close the editor.\n */\n applyChanges: (next: PanelEditorValues) => void;\n\n /**\n * Close the editor.\n */\n close: () => void;\n}\n\n/**\n * Curried function for creating the PanelEditorSlice.\n */\nexport function createPanelEditorSlice(): StateCreator<\n // Actions in here need to modify both Panels and Panel Groups state\n PanelEditorSlice & PanelSlice & PanelGroupSlice,\n Middleware,\n [],\n PanelEditorSlice\n> {\n // Return the state creator function for Zustand that uses the panels provided as intitial state\n return (set, get) => ({\n panelEditor: undefined,\n\n openEditPanel(panelGroupItemId): void {\n const { panels, panelGroups } = get();\n\n // Figure out the panel key at that location\n const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;\n const panelKey = panelGroups[panelGroupId]?.itemPanelKeys[panelGroupLayoutId];\n if (panelKey === undefined) {\n throw new Error(`Could not find Panel Group item ${panelGroupItemId}`);\n }\n\n // Find the panel to edit\n const panelToEdit = panels[panelKey];\n if (panelToEdit === undefined) {\n throw new Error(`Cannot find Panel with key '${panelKey}'`);\n }\n\n const editorState: PanelEditorState = {\n mode: 'update',\n panelGroupItemId: panelGroupItemId,\n initialValues: {\n groupId: panelGroupItemId.panelGroupId,\n panelDefinition: panelToEdit,\n },\n applyChanges: (next) => {\n set((state) => {\n state.panels[panelKey] = next.panelDefinition;\n\n // If the panel didn't change groups, nothing else to do\n if (next.groupId === panelGroupId) {\n return;\n }\n\n // Move panel to the new group\n const existingGroup = state.panelGroups[panelGroupId];\n if (existingGroup === undefined) {\n throw new Error(`Missing panel group ${panelGroupId}`);\n }\n\n const existingLayoutIdx = existingGroup.itemLayouts.findIndex((layout) => layout.i === panelGroupLayoutId);\n const existingLayout = existingGroup.itemLayouts[existingLayoutIdx];\n const existingPanelKey = existingGroup.itemPanelKeys[panelGroupLayoutId];\n if (existingLayoutIdx === -1 || existingLayout === undefined || existingPanelKey === undefined) {\n throw new Error(`Missing panel group item ${panelGroupLayoutId}`);\n }\n\n // Remove item from the old group\n existingGroup.itemLayouts.splice(existingLayoutIdx, 1);\n delete existingGroup.itemPanelKeys[panelGroupLayoutId];\n\n // Add item to the end of the new group\n const newGroup = state.panelGroups[next.groupId];\n if (newGroup === undefined) {\n throw new Error(`Could not find new group ${next.groupId}`);\n }\n\n newGroup.itemLayouts.push({\n i: existingLayout.i,\n x: 0,\n y: getYForNewRow(newGroup),\n w: existingLayout.w,\n h: existingLayout.h,\n });\n newGroup.itemPanelKeys[existingLayout.i] = existingPanelKey;\n });\n },\n close: () => {\n set((state) => {\n state.panelEditor = undefined;\n });\n },\n };\n\n // Open the editor with the new state\n set((state) => {\n state.panelEditor = editorState;\n });\n },\n\n openAddPanel(panelGroupId): void {\n // If a panel group isn't supplied, add to the first group or create a group if there aren't any\n let newGroup: PanelGroupDefinition | undefined = undefined;\n panelGroupId ??= get().panelGroupOrder[0];\n if (panelGroupId === undefined) {\n newGroup = createEmptyPanelGroup();\n newGroup.title = 'Panel Group';\n panelGroupId = newGroup.id;\n }\n\n const editorState: PanelEditorState = {\n mode: 'create',\n initialValues: {\n groupId: panelGroupId,\n panelDefinition: get().initialValues?.panelDefinition ?? createPanelDefinition(),\n },\n applyChanges: (next) => {\n const panelKey = crypto.randomUUID().replaceAll('-', '');\n set((state) => {\n // Add a panel\n state.panels[panelKey] = next.panelDefinition;\n\n // Also add a panel group item referencing the panel\n const group = state.panelGroups[next.groupId];\n if (group === undefined) {\n throw new Error(`Missing panel group ${next.groupId}`);\n }\n const layout: PanelGroupItemLayout = {\n i: generateId().toString(),\n x: 0,\n y: getYForNewRow(group),\n w: 12,\n h: 6,\n };\n group.itemLayouts.push(layout);\n group.itemPanelKeys[layout.i] = panelKey;\n });\n },\n close: () => {\n set((state) => {\n state.panelEditor = undefined;\n });\n },\n };\n\n set((state) => {\n // Add the new panel group if one was created for the panel\n if (newGroup !== undefined) {\n addPanelGroup(state, newGroup);\n }\n\n // Open the editor with the new state\n state.panelEditor = editorState;\n });\n },\n });\n}\n"],"names":["getYForNewRow","generateId","createPanelDefinition","addPanelGroup","createEmptyPanelGroup","createPanelEditorSlice","set","get","panelEditor","undefined","openEditPanel","panelGroupItemId","panels","panelGroups","panelGroupId","panelGroupItemLayoutId","panelGroupLayoutId","panelKey","itemPanelKeys","Error","panelToEdit","editorState","mode","initialValues","groupId","panelDefinition","applyChanges","next","state","existingGroup","existingLayoutIdx","itemLayouts","findIndex","layout","i","existingLayout","existingPanelKey","splice","newGroup","push","x","y","w","h","close","openAddPanel","panelGroupOrder","title","id","crypto","randomUUID","replaceAll","group","toString"],"mappings":"AAAA,oCAAoC;AACpC,kE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AiBL,WAAW;oBAC9B6B,WAAWlC;oBACXkC,SAASS,KAAK,GAAG;oBACjBjC,eAAewB,SAASU,EAAE;gBAC5B;gBAEA,MAAM3B,cAAgC;oBACpCC,MAAM;oBACNC,eAAe;wBACbC,SAASV;wBACTW,iBAAiBlB,MAAMgB,aAAa,EAAEE,mBAAmBvB;oBAC3D;oBACAwB,cAAc,CAACC;wBACb,MAAMV,WAAWgC,OAAOC,UAAU,GAAGC,UAAU,CAAC,KAAK;wBACrD7C,IAAI,CAACsB;4BACH,cAAc;4BACdA,MAAMhB,MAAM,CAACK,SAAS,GAAGU,KAAKF,eAAe;4BAE7C,oDAAoD;4BACpD,MAAM2B,QAAQxB,MAAMf,WAAW,CAACc,KAAKH,OAAO,CAAC;4BAC7C,IAAI4B,UAAU3C,WAAW;gCACvB,MAAM,IAAIU,MAAM,CAAC,oBAAoB,EAAEQ,KAAKH,OAAO,EAAE;4BACvD;4BACA,MAAMS,SAA+B;gCACnCC,GAAGjC,aAAaoD,QAAQ;gCACxBb,GAAG;gCACHC,GAAGzC,cAAcoD;gCACjBV,GAAG;gCACHC,GAAG;4BACL;4BACAS,MAAMrB,WAAW,CAACQ,IAAI,CAACN;4BACvBmB,MAAMlC,aAAa,CAACe,OAAOC,CAAC,CAAC,GAAGjB;wBAClC;oBACF;oBACA2B,OAAO;wBACLtC,IAAI,CAACsB;4BACHA,MAAMpB,WAAW,GAAGC;wBACtB;oBACF;gBACF;gBAEAH,IAAI,CAACsB;oBACH,2DAA2D;oBAC3D,IAAIU,aAAa7B,WAAW;wBAC1BN,cAAcyB,OAAOU;oBACvB;oBAEA,qCAAqC;oBACrCV,MAAMpB,WAAW,GAAGa;gBACtB;YACF;QACF,CAAA;AACF"}
1
+ {"version":3,"sources":["../../../src/context/DashboardProvider/panel-editor-slice.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {\n Action,\n PanelEditorValues,\n PanelGroupId,\n PanelGroupItemId,\n PanelGroupDefinition,\n PanelGroupItemLayout,\n} from '@perses-dev/core';\nimport { StateCreator } from 'zustand';\nimport { generatePanelKey, getYForNewRow } from '../../utils';\nimport { generateId, Middleware, createPanelDefinition } from './common';\nimport { PanelGroupSlice, addPanelGroup, createEmptyPanelGroup } from './panel-group-slice';\nimport { PanelSlice } from './panel-slice';\n\n/**\n * Slice that handles the visual editor state and actions for adding or editing Panels.\n */\nexport interface PanelEditorSlice {\n /**\n * Initial values for add panel if default panel kind is defined\n */\n initialValues?: Pick<PanelEditorValues, 'panelDefinition'>;\n\n /**\n * State for the panel editor when its open, otherwise undefined when it's closed.\n */\n panelEditor?: PanelEditorState;\n\n /**\n * Opens the editor for editing an existing panel by providing its layout coordinates.\n */\n openEditPanel: (panelGroupItemId: PanelGroupItemId) => void;\n\n /**\n * Opens the editor for adding a new Panel to a panel group.\n */\n openAddPanel: (panelGroupId?: PanelGroupId) => void;\n}\n\nexport interface PanelEditorState {\n /**\n * Whether we're adding a new panel, or editing an existing panel.\n */\n mode: Action;\n\n /*\n * Original item in a PanelGroup edited\n */\n panelGroupItemId?: PanelGroupItemId;\n\n /**\n * Initial values for the things that can be edited about a panel.\n */\n initialValues: PanelEditorValues;\n\n /**\n * Applies changes, but doesn't close the editor.\n */\n applyChanges: (next: PanelEditorValues) => void;\n\n /**\n * Close the editor.\n */\n close: () => void;\n}\n\n/**\n * Curried function for creating the PanelEditorSlice.\n */\nexport function createPanelEditorSlice(): StateCreator<\n // Actions in here need to modify both Panels and Panel Groups state\n PanelEditorSlice & PanelSlice & PanelGroupSlice,\n Middleware,\n [],\n PanelEditorSlice\n> {\n // Return the state creator function for Zustand that uses the panels provided as intitial state\n return (set, get) => ({\n panelEditor: undefined,\n\n openEditPanel(panelGroupItemId): void {\n const { panels, panelGroups } = get();\n\n // Figure out the panel key at that location\n const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;\n const panelKey = panelGroups[panelGroupId]?.itemPanelKeys[panelGroupLayoutId];\n if (panelKey === undefined) {\n throw new Error(`Could not find Panel Group item ${panelGroupItemId}`);\n }\n\n // Find the panel to edit\n const panelToEdit = panels[panelKey];\n if (panelToEdit === undefined) {\n throw new Error(`Cannot find Panel with key '${panelKey}'`);\n }\n\n const editorState: PanelEditorState = {\n mode: 'update',\n panelGroupItemId: panelGroupItemId,\n initialValues: {\n groupId: panelGroupItemId.panelGroupId,\n panelDefinition: panelToEdit,\n },\n applyChanges: (next) => {\n set((state) => {\n state.panels[panelKey] = next.panelDefinition;\n\n // If the panel didn't change groups, nothing else to do\n if (next.groupId === panelGroupId) {\n return;\n }\n\n // Move panel to the new group\n const existingGroup = state.panelGroups[panelGroupId];\n if (existingGroup === undefined) {\n throw new Error(`Missing panel group ${panelGroupId}`);\n }\n\n const existingLayoutIdx = existingGroup.itemLayouts.findIndex((layout) => layout.i === panelGroupLayoutId);\n const existingLayout = existingGroup.itemLayouts[existingLayoutIdx];\n const existingPanelKey = existingGroup.itemPanelKeys[panelGroupLayoutId];\n if (existingLayoutIdx === -1 || existingLayout === undefined || existingPanelKey === undefined) {\n throw new Error(`Missing panel group item ${panelGroupLayoutId}`);\n }\n\n // Remove item from the old group\n existingGroup.itemLayouts.splice(existingLayoutIdx, 1);\n delete existingGroup.itemPanelKeys[panelGroupLayoutId];\n\n // Add item to the end of the new group\n const newGroup = state.panelGroups[next.groupId];\n if (newGroup === undefined) {\n throw new Error(`Could not find new group ${next.groupId}`);\n }\n\n newGroup.itemLayouts.push({\n i: existingLayout.i,\n x: 0,\n y: getYForNewRow(newGroup),\n w: existingLayout.w,\n h: existingLayout.h,\n });\n newGroup.itemPanelKeys[existingLayout.i] = existingPanelKey;\n });\n },\n close: () => {\n set((state) => {\n state.panelEditor = undefined;\n });\n },\n };\n\n // Open the editor with the new state\n set((state) => {\n state.panelEditor = editorState;\n });\n },\n\n openAddPanel(panelGroupId): void {\n // If a panel group isn't supplied, add to the first group or create a group if there aren't any\n let newGroup: PanelGroupDefinition | undefined = undefined;\n panelGroupId ??= get().panelGroupOrder[0];\n if (panelGroupId === undefined) {\n newGroup = createEmptyPanelGroup();\n newGroup.title = 'Panel Group';\n panelGroupId = newGroup.id;\n }\n\n const editorState: PanelEditorState = {\n mode: 'create',\n initialValues: {\n groupId: panelGroupId,\n panelDefinition: get().initialValues?.panelDefinition ?? createPanelDefinition(),\n },\n applyChanges: (next) => {\n const panelKey = generatePanelKey();\n set((state) => {\n // Add a panel\n state.panels[panelKey] = next.panelDefinition;\n\n // Also add a panel group item referencing the panel\n const group = state.panelGroups[next.groupId];\n if (group === undefined) {\n throw new Error(`Missing panel group ${next.groupId}`);\n }\n const layout: PanelGroupItemLayout = {\n i: generateId().toString(),\n x: 0,\n y: getYForNewRow(group),\n w: 12,\n h: 6,\n };\n group.itemLayouts.push(layout);\n group.itemPanelKeys[layout.i] = panelKey;\n });\n },\n close: () => {\n set((state) => {\n state.panelEditor = undefined;\n });\n },\n };\n\n set((state) => {\n // Add the new panel group if one was created for the panel\n if (newGroup !== undefined) {\n addPanelGroup(state, newGroup);\n }\n\n // Open the editor with the new state\n state.panelEditor = editorState;\n });\n },\n });\n}\n"],"names":["generatePanelKey","getYForNewRow","generateId","createPanelDefinition","addPanelGroup","createEmptyPanelGroup","createPanelEditorSlice","set","get","panelEditor","undefined","openEditPanel","panelGroupItemId","panels","panelGroups","panelGroupId","panelGroupItemLayoutId","panelGroupLayoutId","panelKey","itemPanelKeys","Error","panelToEdit","editorState","mode","initialValues","groupId","panelDefinition","applyChanges","next","state","existingGroup","existingLayoutIdx","itemLayouts","findIndex","layout","i","existingLayout","existingPanelKey","splice","newGroup","push","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gBAChG,IAAIwB,WAA6C7B;gBACjDK,iBAAiBP,MAAMuC,eAAe,CAAC,EAAE;gBACzC,IAAIhC,iBAAiBL,WAAW;oBAC9B6B,WAAWlC;oBACXkC,SAASS,KAAK,GAAG;oBACjBjC,eAAewB,SAASU,EAAE;gBAC5B;gBAEA,MAAM3B,cAAgC;oBACpCC,MAAM;oBACNC,eAAe;wBACbC,SAASV;wBACTW,iBAAiBlB,MAAMgB,aAAa,EAAEE,mBAAmBvB;oBAC3D;oBACAwB,cAAc,CAACC;wBACb,MAAMV,WAAWlB;wBACjBO,IAAI,CAACsB;4BACH,cAAc;4BACdA,MAAMhB,MAAM,CAACK,SAAS,GAAGU,KAAKF,eAAe;4BAE7C,oDAAoD;4BACpD,MAAMwB,QAAQrB,MAAMf,WAAW,CAACc,KAAKH,OAAO,CAAC;4BAC7C,IAAIyB,UAAUxC,WAAW;gCACvB,MAAM,IAAIU,MAAM,CAAC,oBAAoB,EAAEQ,KAAKH,OAAO,EAAE;4BACvD;4BACA,MAAMS,SAA+B;gCACnCC,GAAGjC,aAAaiD,QAAQ;gCACxBV,GAAG;gCACHC,GAAGzC,cAAciD;gCACjBP,GAAG;gCACHC,GAAG;4BACL;4BACAM,MAAMlB,WAAW,CAACQ,IAAI,CAACN;4BACvBgB,MAAM/B,aAAa,CAACe,OAAOC,CAAC,CAAC,GAAGjB;wBAClC;oBACF;oBACA2B,OAAO;wBACLtC,IAAI,CAACsB;4BACHA,MAAMpB,WAAW,GAAGC;wBACtB;oBACF;gBACF;gBAEAH,IAAI,CAACsB;oBACH,2DAA2D;oBAC3D,IAAIU,aAAa7B,WAAW;wBAC1BN,cAAcyB,OAAOU;oBACvB;oBAEA,qCAAqC;oBACrCV,MAAMpB,WAAW,GAAGa;gBACtB;YACF;QACF,CAAA;AACF"}
@@ -1,4 +1,4 @@
1
- import { PanelGroupDefinition, PanelGroupItemLayout, PanelDefinition } from '@perses-dev/core';
1
+ import { PanelGroupDefinition, PanelGroupItemLayout } from '@perses-dev/core';
2
2
  export declare function getYForNewRow(group: PanelGroupDefinition): number;
3
3
  export type UnpositionedPanelGroupItemLayout = Omit<PanelGroupItemLayout, 'x' | 'y'>;
4
4
  /**
@@ -18,12 +18,7 @@ export type UnpositionedPanelGroupItemLayout = Omit<PanelGroupItemLayout, 'x' |
18
18
  */
19
19
  export declare function insertPanelInLayout(newLayout: UnpositionedPanelGroupItemLayout, referenceLayout: PanelGroupItemLayout, itemLayouts: PanelGroupItemLayout[]): PanelGroupItemLayout[];
20
20
  /**
21
- * @deprecated
22
- *
23
- * Get a valid panel key, where a valid key:
24
- * - does not include invalid characters
25
- * - is unique
26
- * TODO: It is not clear why too much complexity is needed for generating a panel key
21
+ * This function generates a unique panel key based on UUID or timestamp and random suffix.
27
22
  */
28
- export declare function getValidPanelKey(panelKey: string, panels: Record<string, PanelDefinition>): string;
23
+ export declare const generatePanelKey: () => string;
29
24
  //# sourceMappingURL=panelUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"panelUtils.d.ts","sourceRoot":"","sources":["../../src/utils/panelUtils.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAI/F,wBAAgB,aAAa,CAAC,KAAK,EAAE,oBAAoB,GAAG,MAAM,CASjE;AA8BD,MAAM,MAAM,gCAAgC,GAAG,IAAI,CAAC,oBAAoB,EAAE,GAAG,GAAG,GAAG,CAAC,CAAC;AAErF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,gCAAgC,EAC3C,eAAe,EAAE,oBAAoB,EACrC,WAAW,EAAE,oBAAoB,EAAE,GAClC,oBAAoB,EAAE,CAyExB;AAED;;;;;;;GAOG;AAEH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,MAAM,CASlG"}
1
+ {"version":3,"file":"panelUtils.d.ts","sourceRoot":"","sources":["../../src/utils/panelUtils.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAI9E,wBAAgB,aAAa,CAAC,KAAK,EAAE,oBAAoB,GAAG,MAAM,CASjE;AA8BD,MAAM,MAAM,gCAAgC,GAAG,IAAI,CAAC,oBAAoB,EAAE,GAAG,GAAG,GAAG,CAAC,CAAC;AAErF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,gCAAgC,EAC3C,eAAe,EAAE,oBAAoB,EACrC,WAAW,EAAE,oBAAoB,EAAE,GAClC,oBAAoB,EAAE,CAyExB;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,QAAO,MAQnC,CAAC"}
@@ -122,56 +122,14 @@ function getPanelBounds({ x, y, w, h }) {
122
122
  ];
123
123
  }
124
124
  /**
125
- * @deprecated
126
- *
127
- * Get a valid panel key, where a valid key:
128
- * - does not include invalid characters
129
- * - is unique
130
- * TODO: It is not clear why too much complexity is needed for generating a panel key
131
- */ export function getValidPanelKey(panelKey, panels) {
132
- const uniquePanelKeys = getUniquePanelKeys(panels);
133
- let normalizedPanelKey = getPanelKeyParts(removeWhiteSpaces(panelKey)).name;
134
- const matchingKey = uniquePanelKeys[normalizedPanelKey];
135
- if (typeof matchingKey === 'number') {
136
- normalizedPanelKey += `-${matchingKey + 1}`;
125
+ * This function generates a unique panel key based on UUID or timestamp and random suffix.
126
+ */ export const generatePanelKey = ()=>{
127
+ /* crypto.randomUUID() is only available in secure contexts (HTTPS), */ if (window.isSecureContext) {
128
+ return crypto.randomUUID().replaceAll('-', '');
137
129
  }
138
- return normalizedPanelKey;
139
- }
140
- const removeWhiteSpaces = (str)=>{
141
- return str.replace(/\s+/g, '');
130
+ const timestamp = String(Date.now());
131
+ const randomSuffix = Math.random().toString(36).substring(2);
132
+ return `${timestamp}${randomSuffix}`;
142
133
  };
143
- /**
144
- * Breaks the specified panel key into the name and the optional `-number` used
145
- * for deduping panels with the same name.
146
- */ function getPanelKeyParts(panelKey) {
147
- const parts = panelKey.match(/(.+)-([0-9]+)/);
148
- if (parts && parts[1] && parts[2]) {
149
- return {
150
- name: parts[1],
151
- number: parseInt(parts[2], 10)
152
- };
153
- }
154
- return {
155
- name: panelKey
156
- };
157
- }
158
- // Find all the unique panel keys and the largest number used for each.
159
- // ex: cpu, cpu-1, cpu-2 count as the same panel key since these panels have the same name
160
- function getUniquePanelKeys(panels) {
161
- const uniquePanelKeys = {};
162
- Object.keys(panels).forEach((panelKey)=>{
163
- const { name, number } = getPanelKeyParts(panelKey);
164
- if (uniquePanelKeys[name] === undefined) {
165
- uniquePanelKeys[name] = 0;
166
- }
167
- const currentValue = uniquePanelKeys[name];
168
- if (typeof currentValue === 'number' && number) {
169
- // Check for the maximum value because we cannot rely on a sequential
170
- // set of numbers when panels are modified.
171
- uniquePanelKeys[name] = Math.max(currentValue, number);
172
- }
173
- });
174
- return uniquePanelKeys;
175
- }
176
134
 
177
135
  //# sourceMappingURL=panelUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/panelUtils.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { PanelGroupDefinition, PanelGroupItemLayout, PanelDefinition } from '@perses-dev/core';\nimport { GRID_LAYOUT_SMALL_BREAKPOINT, GRID_LAYOUT_COLS } from '../constants';\n\n// Given a PanelGroup, will find the Y coordinate for adding a new row to the grid, taking into account the items present\nexport function getYForNewRow(group: PanelGroupDefinition): number {\n let newRowY = 0;\n for (const layout of group.itemLayouts) {\n const itemMaxY = layout.y + layout.h;\n if (itemMaxY > newRowY) {\n newRowY = itemMaxY;\n }\n }\n return newRowY;\n}\n\ntype PanelGroupItemBounds = {\n /**\n * Left horizontal position.\n */\n x1: number;\n /**\n * Right horizontal position.\n */\n x2: number;\n /**\n * Top vertical position.\n */\n y1: number;\n /**\n * Bottom vertical position\n */\n y2: number;\n};\n\nfunction getPanelBounds({ x, y, w, h }: PanelGroupItemLayout): PanelGroupItemBounds {\n return {\n x1: x,\n x2: x + w,\n y1: y,\n y2: y + h,\n };\n}\n\nexport type UnpositionedPanelGroupItemLayout = Omit<PanelGroupItemLayout, 'x' | 'y'>;\n\n/**\n * Inserts a new panel into the layout with placement determined by a specified\n * reference panel. The new panel is placed:\n * - To the right of the reference panel if there is space available without\n * moving other panels.\n * - Otherwise, directly below the reference panel. If other panels are below\n * this location, they will also shift downward because the grid uses\n * vertical-based compacting.\n *\n * @param newLayout - Layout for new panel to insert into the grid.\n * @param referenceLayout - Layout for reference panel used to determine the\n * placement of the new panel.\n * @param itemLayouts - Full grid layout.\n * @returns - Item layouts modified to insert the new panel.\n */\nexport function insertPanelInLayout(\n newLayout: UnpositionedPanelGroupItemLayout,\n referenceLayout: PanelGroupItemLayout,\n itemLayouts: PanelGroupItemLayout[]\n): PanelGroupItemLayout[] {\n const MAX_LAYOUT_WIDTH = GRID_LAYOUT_COLS[GRID_LAYOUT_SMALL_BREAKPOINT];\n\n const referenceBounds = getPanelBounds(referenceLayout);\n\n // Organize layouts based on vertical relation to the item being inserted\n // after.\n const aboveInsertRow: PanelGroupItemLayout[] = [];\n const insertRow: PanelGroupItemLayout[] = [];\n const belowInsertRow: PanelGroupItemLayout[] = [];\n itemLayouts.forEach((itemLayout) => {\n const itemBounds = getPanelBounds(itemLayout);\n\n if (itemBounds.y2 <= referenceBounds.y1) {\n aboveInsertRow.push(itemLayout);\n } else if (itemBounds.y1 >= referenceBounds.y2) {\n belowInsertRow.push(itemLayout);\n } else {\n insertRow.push(itemLayout);\n }\n });\n\n // Cannot safely assume that the order of item layouts array is strictly\n // left to right. Sorting the row by horizontal position to more easily find\n // gaps.\n insertRow.sort((a, b) => a.x - b.x);\n const insertAfterIndex = insertRow.findIndex((item) => item.i === referenceLayout.i);\n\n if (insertAfterIndex === insertRow.length - 1) {\n // Insert to the right when space is available and the reference is the last\n // item in the row.\n if (referenceBounds.x2 + newLayout.w <= MAX_LAYOUT_WIDTH) {\n return [\n ...aboveInsertRow,\n ...insertRow,\n {\n ...newLayout,\n x: referenceBounds.x2,\n y: referenceBounds.y1,\n },\n ...belowInsertRow,\n ];\n }\n } else if (insertAfterIndex >= 0) {\n const nextItem = insertRow[insertAfterIndex + 1];\n\n if (nextItem && getPanelBounds(nextItem).x1 - referenceBounds.x2 >= newLayout.w) {\n // Insert to the right when space is available between the reference and\n // the next item in the row.\n insertRow.splice(insertAfterIndex + 1, 0, {\n ...newLayout,\n x: referenceBounds.x2,\n y: referenceBounds.y1,\n });\n\n return [...aboveInsertRow, ...insertRow, ...belowInsertRow];\n }\n }\n\n // Insert the new item below the original and shift the items below the\n // row where the reference is located.\n return [\n ...aboveInsertRow,\n ...insertRow,\n { x: referenceBounds.x1, y: referenceBounds.y2, ...newLayout },\n ...belowInsertRow.map((itemLayout) => {\n // Note: the grid will not necessarily display all of these items shifted\n // all the way down because of vertical compacting, but shifing their\n // y position ensures the new item gets vertical precedence over items\n // below it in that compacting.\n return { ...itemLayout, y: itemLayout.y + newLayout.h };\n }),\n ];\n}\n\n/**\n * @deprecated\n *\n * Get a valid panel key, where a valid key:\n * - does not include invalid characters\n * - is unique\n * TODO: It is not clear why too much complexity is needed for generating a panel key\n */\n\nexport function getValidPanelKey(panelKey: string, panels: Record<string, PanelDefinition>): string {\n const uniquePanelKeys = getUniquePanelKeys(panels);\n let normalizedPanelKey = getPanelKeyParts(removeWhiteSpaces(panelKey)).name;\n\n const matchingKey = uniquePanelKeys[normalizedPanelKey];\n if (typeof matchingKey === 'number') {\n normalizedPanelKey += `-${matchingKey + 1}`;\n }\n return normalizedPanelKey;\n}\n\ntype PanelKeyParts = {\n name: string;\n number?: number;\n};\n\nconst removeWhiteSpaces = (str: string): string => {\n return str.replace(/\\s+/g, '');\n};\n\n/**\n * Breaks the specified panel key into the name and the optional `-number` used\n * for deduping panels with the same name.\n */\nfunction getPanelKeyParts(panelKey: string): PanelKeyParts {\n const parts = panelKey.match(/(.+)-([0-9]+)/);\n if (parts && parts[1] && parts[2]) {\n return {\n name: parts[1],\n number: parseInt(parts[2], 10),\n };\n }\n\n return {\n name: panelKey,\n };\n}\n\n// Find all the unique panel keys and the largest number used for each.\n// ex: cpu, cpu-1, cpu-2 count as the same panel key since these panels have the same name\nfunction getUniquePanelKeys(panels: Record<string, PanelDefinition>): Record<string, number> {\n const uniquePanelKeys: Record<string, number> = {};\n Object.keys(panels).forEach((panelKey) => {\n const { name, number } = getPanelKeyParts(panelKey);\n if (uniquePanelKeys[name] === undefined) {\n uniquePanelKeys[name] = 0;\n }\n const currentValue = uniquePanelKeys[name];\n if (typeof currentValue === 'number' && number) {\n // Check for the maximum value because we cannot rely on a sequential\n // set of numbers when panels are modified.\n uniquePanelKeys[name] = Math.max(currentValue, number);\n }\n });\n return uniquePanelKeys;\n}\n"],"names":["GRID_LAYOUT_SMALL_BREAKPOINT","GRID_LAYOUT_COLS","getYForNewRow","group","newRowY","layout","itemLayouts","itemMaxY","y","h","getPanelBounds","x","w","x1","x2","y1","y2","insertPanelInLayout","newLayout","referenceLayout","MAX_LAYOUT_WIDTH","referenceBounds","aboveInsertRow","insertRow","belowInsertRow","forEach","itemLayout","itemBounds","push","sort","a","b","insertAfterIndex","findIndex","item","i","length","nextItem","splice","map","getValidPanelKey","panelKey","panels","uniquePanelKeys","getUniquePanelKeys","normalizedPanelKey","getPanelKeyParts","removeWhiteSpaces","name","matchingKey","str","replace","parts","match","number","parseInt","Object","keys","undefined","currentValue","Math","max"],"mappings":"AAAA,oCAAoC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AiBC,QAAgB,EAAEC,MAAuC;IACxF,MAAMC,kBAAkBC,mBAAmBF;IAC3C,IAAIG,qBAAqBC,iBAAiBC,kBAAkBN,WAAWO,IAAI;IAE3E,MAAMC,cAAcN,eAAe,CAACE,mBAAmB;IACvD,IAAI,OAAOI,gBAAgB,UAAU;QACnCJ,sBAAsB,CAAC,CAAC,EAAEI,cAAc,GAAG;IAC7C;IACA,OAAOJ;AACT;AAOA,MAAME,oBAAoB,CAACG;IACzB,OAAOA,IAAIC,OAAO,CAAC,QAAQ;AAC7B;AAEA;;;CAGC,GACD,SAASL,iBAAiBL,QAAgB;IACxC,MAAMW,QAAQX,SAASY,KAAK,CAAC;IAC7B,IAAID,SAASA,KAAK,CAAC,EAAE,IAAIA,KAAK,CAAC,EAAE,EAAE;QACjC,OAAO;YACLJ,MAAMI,KAAK,CAAC,EAAE;YACdE,QAAQC,SAASH,KAAK,CAAC,EAAE,EAAE;QAC7B;IACF;IAEA,OAAO;QACLJ,MAAMP;IACR;AACF;AAEA,uEAAuE;AACvE,0FAA0F;AAC1F,SAASG,mBAAmBF,MAAuC;IACjE,MAAMC,kBAA0C,CAAC;IACjDa,OAAOC,IAAI,CAACf,QAAQjB,OAAO,CAAC,CAACgB;QAC3B,MAAM,EAAEO,IAAI,EAAEM,MAAM,EAAE,GAAGR,iBAAiBL;QAC1C,IAAIE,eAAe,CAACK,KAAK,KAAKU,WAAW;YACvCf,eAAe,CAACK,KAAK,GAAG;QAC1B;QACA,MAAMW,eAAehB,eAAe,CAACK,KAAK;QAC1C,IAAI,OAAOW,iBAAiB,YAAYL,QAAQ;YAC9C,qEAAqE;YACrE,2CAA2C;YAC3CX,eAAe,CAACK,KAAK,GAAGY,KAAKC,GAAG,CAACF,cAAcL;QACjD;IACF;IACA,OAAOX;AACT"}
1
+ {"version":3,"sources":["../../src/utils/panelUtils.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { PanelGroupDefinition, PanelGroupItemLayout } from '@perses-dev/core';\nimport { GRID_LAYOUT_SMALL_BREAKPOINT, GRID_LAYOUT_COLS } from '../constants';\n\n// Given a PanelGroup, will find the Y coordinate for adding a new row to the grid, taking into account the items present\nexport function getYForNewRow(group: PanelGroupDefinition): number {\n let newRowY = 0;\n for (const layout of group.itemLayouts) {\n const itemMaxY = layout.y + layout.h;\n if (itemMaxY > newRowY) {\n newRowY = itemMaxY;\n }\n }\n return newRowY;\n}\n\ntype PanelGroupItemBounds = {\n /**\n * Left horizontal position.\n */\n x1: number;\n /**\n * Right horizontal position.\n */\n x2: number;\n /**\n * Top vertical position.\n */\n y1: number;\n /**\n * Bottom vertical position\n */\n y2: number;\n};\n\nfunction getPanelBounds({ x, y, w, h }: PanelGroupItemLayout): PanelGroupItemBounds {\n return {\n x1: x,\n x2: x + w,\n y1: y,\n y2: y + h,\n };\n}\n\nexport type UnpositionedPanelGroupItemLayout = Omit<PanelGroupItemLayout, 'x' | 'y'>;\n\n/**\n * Inserts a new panel into the layout with placement determined by a specified\n * reference panel. The new panel is placed:\n * - To the right of the reference panel if there is space available without\n * moving other panels.\n * - Otherwise, directly below the reference panel. If other panels are below\n * this location, they will also shift downward because the grid uses\n * vertical-based compacting.\n *\n * @param newLayout - Layout for new panel to insert into the grid.\n * @param referenceLayout - Layout for reference panel used to determine the\n * placement of the new panel.\n * @param itemLayouts - Full grid layout.\n * @returns - Item layouts modified to insert the new panel.\n */\nexport function insertPanelInLayout(\n newLayout: UnpositionedPanelGroupItemLayout,\n referenceLayout: PanelGroupItemLayout,\n itemLayouts: PanelGroupItemLayout[]\n): PanelGroupItemLayout[] {\n const MAX_LAYOUT_WIDTH = GRID_LAYOUT_COLS[GRID_LAYOUT_SMALL_BREAKPOINT];\n\n const referenceBounds = getPanelBounds(referenceLayout);\n\n // Organize layouts based on vertical relation to the item being inserted\n // after.\n const aboveInsertRow: PanelGroupItemLayout[] = [];\n const insertRow: PanelGroupItemLayout[] = [];\n const belowInsertRow: PanelGroupItemLayout[] = [];\n itemLayouts.forEach((itemLayout) => {\n const itemBounds = getPanelBounds(itemLayout);\n\n if (itemBounds.y2 <= referenceBounds.y1) {\n aboveInsertRow.push(itemLayout);\n } else if (itemBounds.y1 >= referenceBounds.y2) {\n belowInsertRow.push(itemLayout);\n } else {\n insertRow.push(itemLayout);\n }\n });\n\n // Cannot safely assume that the order of item layouts array is strictly\n // left to right. Sorting the row by horizontal position to more easily find\n // gaps.\n insertRow.sort((a, b) => a.x - b.x);\n const insertAfterIndex = insertRow.findIndex((item) => item.i === referenceLayout.i);\n\n if (insertAfterIndex === insertRow.length - 1) {\n // Insert to the right when space is available and the reference is the last\n // item in the row.\n if (referenceBounds.x2 + newLayout.w <= MAX_LAYOUT_WIDTH) {\n return [\n ...aboveInsertRow,\n ...insertRow,\n {\n ...newLayout,\n x: referenceBounds.x2,\n y: referenceBounds.y1,\n },\n ...belowInsertRow,\n ];\n }\n } else if (insertAfterIndex >= 0) {\n const nextItem = insertRow[insertAfterIndex + 1];\n\n if (nextItem && getPanelBounds(nextItem).x1 - referenceBounds.x2 >= newLayout.w) {\n // Insert to the right when space is available between the reference and\n // the next item in the row.\n insertRow.splice(insertAfterIndex + 1, 0, {\n ...newLayout,\n x: referenceBounds.x2,\n y: referenceBounds.y1,\n });\n\n return [...aboveInsertRow, ...insertRow, ...belowInsertRow];\n }\n }\n\n // Insert the new item below the original and shift the items below the\n // row where the reference is located.\n return [\n ...aboveInsertRow,\n ...insertRow,\n { x: referenceBounds.x1, y: referenceBounds.y2, ...newLayout },\n ...belowInsertRow.map((itemLayout) => {\n // Note: the grid will not necessarily display all of these items shifted\n // all the way down because of vertical compacting, but shifing their\n // y position ensures the new item gets vertical precedence over items\n // below it in that compacting.\n return { ...itemLayout, y: itemLayout.y + newLayout.h };\n }),\n ];\n}\n\n/**\n * This function generates a unique panel key based on UUID or timestamp and random suffix.\n */\nexport const generatePanelKey = (): string => {\n /* crypto.randomUUID() is only available in secure contexts (HTTPS), */\n if (window.isSecureContext) {\n return crypto.randomUUID().replaceAll('-', '');\n }\n const timestamp = String(Date.now());\n const randomSuffix = Math.random().toString(36).substring(2);\n return `${timestamp}${randomSuffix}`;\n};\n"],"names":["GRID_LAYOUT_SMALL_BREAKPOINT","GRID_LAYOUT_COLS","getYForNewRow","group","newRowY","layout","itemLayouts","itemMaxY","y","h","getPanelBounds","x","w","x1","x2","y1","y2","insertPanelInLayout","newLayout","referenceLayout","MAX_LAYOUT_WIDTH","referenceBounds","aboveInsertRow","insertRow","belowInsertRow","forEach","itemLayout","itemBounds","push","sort","a","b","insertAfterIndex","findIndex","item","i","length","nextItem","splice","map","generatePanelKey","window","isSecureContext","crypto","randomUUID","replaceAll","timestamp","String","Date","now","randomSuffix","Math","random","toString","substring"],"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;AAGjC,SAASA,4BAA4B,EAAEC,gBAAgB,QAAQ,eAAe;AAE9E,yHAAyH;AACzH,OAAO,SAASC,cAAcC,KAA2B;IACvD,IAAIC,UAAU;IACd,KAAK,MAAMC,UAAUF,MAAMG,WAAW,CAAE;QACtC,MAAMC,WAAWF,OAAOG,CAAC,GAAGH,OAAOI,CAAC;QACpC,IAAIF,WAAWH,SAAS;YACtBA,UAAUG;QACZ;IACF;IACA,OAAOH;AACT;AAqBA,SAASM,eAAe,EAAEC,CAAC,EAAEH,CAAC,EAAEI,CAAC,EAAEH,CAAC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ACS,mBAAmB,EAAE;QAEhD,IAAIK,YAAY3B,eAAe2B,UAAUxB,EAAE,GAAGQ,gBAAgBP,EAAE,IAAII,UAAUN,CAAC,EAAE;YAC/E,wEAAwE;YACxE,4BAA4B;YAC5BW,UAAUe,MAAM,CAACN,mBAAmB,GAAG,GAAG;gBACxC,GAAGd,SAAS;gBACZP,GAAGU,gBAAgBP,EAAE;gBACrBN,GAAGa,gBAAgBN,EAAE;YACvB;YAEA,OAAO;mBAAIO;mBAAmBC;mBAAcC;aAAe;QAC7D;IACF;IAEA,uEAAuE;IACvE,sCAAsC;IACtC,OAAO;WACFF;WACAC;QACH;YAAEZ,GAAGU,gBAAgBR,EAAE;YAAEL,GAAGa,gBAAgBL,EAAE;YAAE,GAAGE,SAAS;QAAC;WAC1DM,eAAee,GAAG,CAAC,CAACb;YACrB,yEAAyE;YACzE,qEAAqE;YACrE,sEAAsE;YACtE,+BAA+B;YAC/B,OAAO;gBAAE,GAAGA,UAAU;gBAAElB,GAAGkB,WAAWlB,CAAC,GAAGU,UAAUT,CAAC;YAAC;QACxD;KACD;AACH;AAEA;;CAEC,GACD,OAAO,MAAM+B,mBAAmB;IAC9B,qEAAqE,GACrE,IAAIC,OAAOC,eAAe,EAAE;QAC1B,OAAOC,OAAOC,UAAU,GAAGC,UAAU,CAAC,KAAK;IAC7C;IACA,MAAMC,YAAYC,OAAOC,KAAKC,GAAG;IACjC,MAAMC,eAAeC,KAAKC,MAAM,GAAGC,QAAQ,CAAC,IAAIC,SAAS,CAAC;IAC1D,OAAO,GAAGR,YAAYI,cAAc;AACtC,EAAE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/dashboards",
3
- "version": "0.53.0-beta.3",
3
+ "version": "0.53.0-rc.0",
4
4
  "description": "The dashboards feature in Perses",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/perses/perses/blob/main/README.md",
@@ -29,9 +29,9 @@
29
29
  "lint:fix": "eslint --fix src --ext .ts,.tsx"
30
30
  },
31
31
  "dependencies": {
32
- "@perses-dev/components": "0.53.0-beta.3",
32
+ "@perses-dev/components": "0.53.0-beta.4",
33
33
  "@perses-dev/core": "0.53.0-beta.3",
34
- "@perses-dev/plugin-system": "0.53.0-beta.3",
34
+ "@perses-dev/plugin-system": "0.53.0-beta.4",
35
35
  "@types/react-grid-layout": "^1.3.2",
36
36
  "date-fns": "^4.1.0",
37
37
  "immer": "^10.1.1",
@@ -46,7 +46,6 @@
46
46
  "zustand": "^4.3.3"
47
47
  },
48
48
  "devDependencies": {
49
- "@perses-dev/internal-utils": "0.53.0-beta.3",
50
49
  "history": "^5.3.0",
51
50
  "intersection-observer": "^0.12.2"
52
51
  },
package/LICENSE DELETED
@@ -1,201 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
179
-
180
- To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "[]"
182
- replaced with your own identifying information. (Don't include
183
- the brackets!) The text should be enclosed in the appropriate
184
- comment syntax for the file format. We also recommend that a
185
- file or class name and description of purpose be included on the
186
- same "printed page" as the copyright notice for easier
187
- identification within third-party archives.
188
-
189
- Copyright [yyyy] [name of the copyright owner]
190
-
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
194
-
195
- http://www.apache.org/licenses/LICENSE-2.0
196
-
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.