@perses-dev/dashboards 0.23.1 → 0.25.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 (178) hide show
  1. package/dist/cjs/components/AddPanelButton/AddPanelButton.js +9 -2
  2. package/dist/cjs/components/Dashboard/Dashboard.js +23 -6
  3. package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +8 -17
  4. package/dist/cjs/components/EditButton/EditButton.js +41 -0
  5. package/dist/cjs/components/EditButton/index.js +28 -0
  6. package/dist/cjs/components/EditJsonButton/EditJsonButton.js +42 -0
  7. package/dist/cjs/components/EditJsonButton/index.js +28 -0
  8. package/dist/cjs/components/EditJsonDialog/EditJsonDialog.js +86 -0
  9. package/dist/cjs/components/EditJsonDialog/index.js +28 -0
  10. package/dist/cjs/components/EmptyDashboard/EmptyDashboard.js +127 -0
  11. package/dist/cjs/components/EmptyDashboard/index.js +28 -0
  12. package/dist/cjs/components/QuerySummaryTable/QuerySummaryTable.js +185 -0
  13. package/dist/cjs/components/QuerySummaryTable/index.js +28 -0
  14. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +7 -3
  15. package/dist/cjs/components/ToolbarIconButton/ToolbarIconButton.js +6 -3
  16. package/dist/cjs/components/Variables/EditVariablesButton.js +9 -2
  17. package/dist/cjs/components/index.js +4 -0
  18. package/dist/cjs/constants/user-interface-text.js +1 -0
  19. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +12 -6
  20. package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +10 -1
  21. package/dist/cjs/context/DashboardProvider/edit-json-dialog-slice.js +36 -0
  22. package/dist/cjs/context/DatasourceStoreProvider.js +9 -3
  23. package/dist/cjs/stories/decorators/WithDashboard.js +60 -0
  24. package/dist/cjs/stories/decorators/WithPluginRegistry.js +91 -0
  25. package/dist/cjs/stories/decorators/WithQueryClient.js +29 -0
  26. package/dist/cjs/stories/decorators/WithQueryParams.js +29 -0
  27. package/dist/cjs/stories/decorators/WithTemplateVariables.js +27 -0
  28. package/dist/cjs/stories/decorators/index.js +32 -0
  29. package/dist/cjs/views/ViewDashboard/DashboardApp.js +11 -4
  30. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +2 -1
  31. package/dist/components/AddPanelButton/AddPanelButton.d.ts +16 -1
  32. package/dist/components/AddPanelButton/AddPanelButton.d.ts.map +1 -1
  33. package/dist/components/AddPanelButton/AddPanelButton.js +9 -2
  34. package/dist/components/AddPanelButton/AddPanelButton.js.map +1 -1
  35. package/dist/components/Dashboard/Dashboard.d.ts +10 -2
  36. package/dist/components/Dashboard/Dashboard.d.ts.map +1 -1
  37. package/dist/components/Dashboard/Dashboard.js +24 -7
  38. package/dist/components/Dashboard/Dashboard.js.map +1 -1
  39. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
  40. package/dist/components/DashboardToolbar/DashboardToolbar.js +8 -12
  41. package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
  42. package/dist/components/EditButton/EditButton.d.ts +13 -0
  43. package/dist/components/EditButton/EditButton.d.ts.map +1 -0
  44. package/dist/components/EditButton/EditButton.js +30 -0
  45. package/dist/components/EditButton/EditButton.js.map +1 -0
  46. package/dist/components/EditButton/index.d.ts +2 -0
  47. package/dist/components/EditButton/index.d.ts.map +1 -0
  48. package/dist/components/EditButton/index.js +15 -0
  49. package/dist/components/EditButton/index.js.map +1 -0
  50. package/dist/components/EditJsonButton/EditJsonButton.d.ts +3 -0
  51. package/dist/components/EditJsonButton/EditJsonButton.d.ts.map +1 -0
  52. package/dist/components/EditJsonButton/EditJsonButton.js +31 -0
  53. package/dist/components/EditJsonButton/EditJsonButton.js.map +1 -0
  54. package/dist/components/EditJsonButton/index.d.ts +2 -0
  55. package/dist/components/EditJsonButton/index.d.ts.map +1 -0
  56. package/dist/components/EditJsonButton/index.js +15 -0
  57. package/dist/components/EditJsonButton/index.js.map +1 -0
  58. package/dist/components/EditJsonDialog/EditJsonDialog.d.ts +3 -0
  59. package/dist/components/EditJsonDialog/EditJsonDialog.d.ts.map +1 -0
  60. package/dist/components/EditJsonDialog/EditJsonDialog.js +80 -0
  61. package/dist/components/EditJsonDialog/EditJsonDialog.js.map +1 -0
  62. package/dist/components/EditJsonDialog/index.d.ts +2 -0
  63. package/dist/components/EditJsonDialog/index.d.ts.map +1 -0
  64. package/dist/components/EditJsonDialog/index.js +15 -0
  65. package/dist/components/EditJsonDialog/index.js.map +1 -0
  66. package/dist/components/EmptyDashboard/EmptyDashboard.d.ts +33 -0
  67. package/dist/components/EmptyDashboard/EmptyDashboard.d.ts.map +1 -0
  68. package/dist/components/EmptyDashboard/EmptyDashboard.js +123 -0
  69. package/dist/components/EmptyDashboard/EmptyDashboard.js.map +1 -0
  70. package/dist/components/EmptyDashboard/index.d.ts +2 -0
  71. package/dist/components/EmptyDashboard/index.d.ts.map +1 -0
  72. package/dist/components/EmptyDashboard/index.js +15 -0
  73. package/dist/components/EmptyDashboard/index.js.map +1 -0
  74. package/dist/components/QuerySummaryTable/QuerySummaryTable.d.ts +11 -0
  75. package/dist/components/QuerySummaryTable/QuerySummaryTable.d.ts.map +1 -0
  76. package/dist/components/QuerySummaryTable/QuerySummaryTable.js +179 -0
  77. package/dist/components/QuerySummaryTable/QuerySummaryTable.js.map +1 -0
  78. package/dist/components/QuerySummaryTable/index.d.ts +2 -0
  79. package/dist/components/QuerySummaryTable/index.d.ts.map +1 -0
  80. package/dist/components/QuerySummaryTable/index.js +15 -0
  81. package/dist/components/QuerySummaryTable/index.js.map +1 -0
  82. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts +2 -1
  83. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
  84. package/dist/components/TimeRangeControls/TimeRangeControls.js +8 -4
  85. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
  86. package/dist/components/ToolbarIconButton/ToolbarIconButton.d.ts +1 -1
  87. package/dist/components/ToolbarIconButton/ToolbarIconButton.d.ts.map +1 -1
  88. package/dist/components/ToolbarIconButton/ToolbarIconButton.js +6 -3
  89. package/dist/components/ToolbarIconButton/ToolbarIconButton.js.map +1 -1
  90. package/dist/components/Variables/EditVariablesButton.d.ts +16 -1
  91. package/dist/components/Variables/EditVariablesButton.d.ts.map +1 -1
  92. package/dist/components/Variables/EditVariablesButton.js +9 -2
  93. package/dist/components/Variables/EditVariablesButton.js.map +1 -1
  94. package/dist/components/index.d.ts +4 -0
  95. package/dist/components/index.d.ts.map +1 -1
  96. package/dist/components/index.js +4 -0
  97. package/dist/components/index.js.map +1 -1
  98. package/dist/constants/user-interface-text.d.ts +1 -0
  99. package/dist/constants/user-interface-text.d.ts.map +1 -1
  100. package/dist/constants/user-interface-text.js +1 -0
  101. package/dist/constants/user-interface-text.js.map +1 -1
  102. package/dist/context/DashboardProvider/DashboardProvider.d.ts +2 -1
  103. package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
  104. package/dist/context/DashboardProvider/DashboardProvider.js +12 -6
  105. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
  106. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +8 -0
  107. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
  108. package/dist/context/DashboardProvider/dashboard-provider-api.js +10 -0
  109. package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
  110. package/dist/context/DashboardProvider/edit-json-dialog-slice.d.ts +12 -0
  111. package/dist/context/DashboardProvider/edit-json-dialog-slice.d.ts.map +1 -0
  112. package/dist/context/DashboardProvider/edit-json-dialog-slice.js +30 -0
  113. package/dist/context/DashboardProvider/edit-json-dialog-slice.js.map +1 -0
  114. package/dist/context/DatasourceStoreProvider.d.ts +2 -0
  115. package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
  116. package/dist/context/DatasourceStoreProvider.js +9 -3
  117. package/dist/context/DatasourceStoreProvider.js.map +1 -1
  118. package/dist/stories/decorators/WithDashboard.js +48 -0
  119. package/dist/stories/decorators/WithDashboard.js.map +1 -0
  120. package/dist/stories/decorators/WithPluginRegistry.js +46 -0
  121. package/dist/stories/decorators/WithPluginRegistry.js.map +1 -0
  122. package/dist/stories/decorators/WithQueryClient.js +23 -0
  123. package/dist/stories/decorators/WithQueryClient.js.map +1 -0
  124. package/dist/stories/decorators/WithQueryParams.js +23 -0
  125. package/dist/stories/decorators/WithQueryParams.js.map +1 -0
  126. package/dist/stories/decorators/WithTemplateVariables.js +21 -0
  127. package/dist/stories/decorators/WithTemplateVariables.js.map +1 -0
  128. package/dist/stories/decorators/index.js +19 -0
  129. package/dist/stories/decorators/index.js.map +1 -0
  130. package/dist/views/ViewDashboard/DashboardApp.d.ts +2 -0
  131. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
  132. package/dist/views/ViewDashboard/DashboardApp.js +12 -5
  133. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  134. package/dist/views/ViewDashboard/ViewDashboard.d.ts +2 -8
  135. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
  136. package/dist/views/ViewDashboard/ViewDashboard.js +2 -1
  137. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
  138. package/package.json +6 -5
  139. package/dist/cjs/components/Panel/Panel.test.js +0 -137
  140. package/dist/cjs/components/PanelDrawer/PanelDrawer.test.js +0 -131
  141. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.test.js +0 -87
  142. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.test.js +0 -95
  143. package/dist/cjs/components/Variables/variable-model.test.js +0 -106
  144. package/dist/cjs/context/TemplateVariableProvider/query-params.test.js +0 -82
  145. package/dist/cjs/utils/panelUtils.test.js +0 -195
  146. package/dist/cjs/views/ViewDashboard/tests/panelGroups.test.js +0 -110
  147. package/dist/components/Panel/Panel.test.d.ts +0 -2
  148. package/dist/components/Panel/Panel.test.d.ts.map +0 -1
  149. package/dist/components/Panel/Panel.test.js +0 -130
  150. package/dist/components/Panel/Panel.test.js.map +0 -1
  151. package/dist/components/PanelDrawer/PanelDrawer.test.d.ts +0 -2
  152. package/dist/components/PanelDrawer/PanelDrawer.test.d.ts.map +0 -1
  153. package/dist/components/PanelDrawer/PanelDrawer.test.js +0 -124
  154. package/dist/components/PanelDrawer/PanelDrawer.test.js.map +0 -1
  155. package/dist/components/PanelGroupDialog/PanelGroupDialog.test.d.ts +0 -2
  156. package/dist/components/PanelGroupDialog/PanelGroupDialog.test.d.ts.map +0 -1
  157. package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js +0 -80
  158. package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js.map +0 -1
  159. package/dist/components/TimeRangeControls/TimeRangeControls.test.d.ts +0 -2
  160. package/dist/components/TimeRangeControls/TimeRangeControls.test.d.ts.map +0 -1
  161. package/dist/components/TimeRangeControls/TimeRangeControls.test.js +0 -88
  162. package/dist/components/TimeRangeControls/TimeRangeControls.test.js.map +0 -1
  163. package/dist/components/Variables/variable-model.test.d.ts +0 -2
  164. package/dist/components/Variables/variable-model.test.d.ts.map +0 -1
  165. package/dist/components/Variables/variable-model.test.js +0 -104
  166. package/dist/components/Variables/variable-model.test.js.map +0 -1
  167. package/dist/context/TemplateVariableProvider/query-params.test.d.ts +0 -2
  168. package/dist/context/TemplateVariableProvider/query-params.test.d.ts.map +0 -1
  169. package/dist/context/TemplateVariableProvider/query-params.test.js +0 -80
  170. package/dist/context/TemplateVariableProvider/query-params.test.js.map +0 -1
  171. package/dist/utils/panelUtils.test.d.ts +0 -2
  172. package/dist/utils/panelUtils.test.d.ts.map +0 -1
  173. package/dist/utils/panelUtils.test.js +0 -193
  174. package/dist/utils/panelUtils.test.js.map +0 -1
  175. package/dist/views/ViewDashboard/tests/panelGroups.test.d.ts +0 -2
  176. package/dist/views/ViewDashboard/tests/panelGroups.test.d.ts.map +0 -1
  177. package/dist/views/ViewDashboard/tests/panelGroups.test.js +0 -103
  178. package/dist/views/ViewDashboard/tests/panelGroups.test.js.map +0 -1
@@ -29,7 +29,7 @@ function _interopRequireDefault(obj) {
29
29
  default: obj
30
30
  };
31
31
  }
32
- const AddPanelButton = ()=>{
32
+ const AddPanelButton = ({ variant ='text' , color ='primary' , label ='Panel' , fullWidth })=>{
33
33
  const { openAddPanel } = (0, _context.useDashboardActions)();
34
34
  return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.InfoTooltip, {
35
35
  description: _constants.TOOLTIP_TEXT.addPanel,
@@ -37,7 +37,14 @@ const AddPanelButton = ()=>{
37
37
  startIcon: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_chartBoxPlusOutline.default, {}),
38
38
  onClick: openAddPanel,
39
39
  "aria-label": _constants.TOOLTIP_TEXT.addPanel,
40
- children: "Panel"
40
+ variant: variant,
41
+ color: color,
42
+ fullWidth: fullWidth,
43
+ sx: {
44
+ whiteSpace: 'nowrap',
45
+ minWidth: 'auto'
46
+ },
47
+ children: label
41
48
  })
42
49
  });
43
50
  };
@@ -23,15 +23,32 @@ const _material = require("@mui/material");
23
23
  const _components = require("@perses-dev/components");
24
24
  const _context = require("../../context");
25
25
  const _gridLayout = require("../GridLayout");
26
- function Dashboard(props) {
26
+ const _emptyDashboard = require("../EmptyDashboard");
27
+ function Dashboard({ emptyDashboardProps , ...boxProps }) {
27
28
  const panelGroupIds = (0, _context.usePanelGroupIds)();
29
+ const isEmpty = !panelGroupIds.length;
28
30
  return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
29
- ...props,
30
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorBoundary, {
31
+ ...boxProps,
32
+ sx: {
33
+ height: '100%'
34
+ },
35
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_components.ErrorBoundary, {
31
36
  FallbackComponent: _components.ErrorAlert,
32
- children: panelGroupIds.map((panelGroupId)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_gridLayout.GridLayout, {
33
- panelGroupId: panelGroupId
34
- }, panelGroupId))
37
+ children: [
38
+ isEmpty && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
39
+ sx: {
40
+ height: '100%',
41
+ display: 'flex',
42
+ alignItems: 'center'
43
+ },
44
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_emptyDashboard.EmptyDashboard, {
45
+ ...emptyDashboardProps
46
+ })
47
+ }),
48
+ !isEmpty && panelGroupIds.map((panelGroupId)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_gridLayout.GridLayout, {
49
+ panelGroupId: panelGroupId
50
+ }, panelGroupId))
51
+ ]
35
52
  })
36
53
  });
37
54
  }
@@ -21,7 +21,6 @@ Object.defineProperty(exports, "DashboardToolbar", {
21
21
  const _jsxRuntime = require("react/jsx-runtime");
22
22
  const _react = require("react");
23
23
  const _material = require("@mui/material");
24
- const _pencilOutline = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/PencilOutline"));
25
24
  const _components = require("@perses-dev/components");
26
25
  const _context = require("../../context");
27
26
  const _addPanelButton = require("../AddPanelButton");
@@ -29,11 +28,8 @@ const _addGroupButton = require("../AddGroupButton");
29
28
  const _downloadButton = require("../DownloadButton");
30
29
  const _timeRangeControls = require("../TimeRangeControls");
31
30
  const _variables = require("../Variables");
32
- function _interopRequireDefault(obj) {
33
- return obj && obj.__esModule ? obj : {
34
- default: obj
35
- };
36
- }
31
+ const _editButton = require("../EditButton");
32
+ const _editJsonButton = require("../EditJsonButton");
37
33
  const DashboardToolbar = (props)=>{
38
34
  const { dashboardName , dashboardTitleComponent , initialVariableIsSticky , isReadonly , onEditButtonClick , onCancelButtonClick , onSave , } = props;
39
35
  const dashboard = (0, _context.useDashboard)();
@@ -130,7 +126,8 @@ const DashboardToolbar = (props)=>{
130
126
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_addPanelButton.AddPanelButton, {}),
131
127
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_addGroupButton.AddGroupButton, {}),
132
128
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_timeRangeControls.TimeRangeControls, {}),
133
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_downloadButton.DownloadButton, {})
129
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_downloadButton.DownloadButton, {}),
130
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_editJsonButton.EditJsonButton, {})
134
131
  ]
135
132
  }) : // On smaller screens, make it two rows
136
133
  /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
@@ -145,7 +142,8 @@ const DashboardToolbar = (props)=>{
145
142
  },
146
143
  children: [
147
144
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_timeRangeControls.TimeRangeControls, {}),
148
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_downloadButton.DownloadButton, {})
145
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_downloadButton.DownloadButton, {}),
146
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_editJsonButton.EditJsonButton, {})
149
147
  ]
150
148
  }),
151
149
  /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
@@ -185,15 +183,8 @@ const DashboardToolbar = (props)=>{
185
183
  children: [
186
184
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_timeRangeControls.TimeRangeControls, {}),
187
185
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_downloadButton.DownloadButton, {}),
188
- isBiggerThanSm && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
189
- variant: "outlined",
190
- color: "secondary",
191
- startIcon: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pencilOutline.default, {}),
192
- onClick: onEditButtonClick,
193
- sx: {
194
- marginLeft: 'auto'
195
- },
196
- children: "Edit"
186
+ isBiggerThanSm && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_editButton.EditButton, {
187
+ onClick: onEditButtonClick
197
188
  })
198
189
  ]
199
190
  })
@@ -0,0 +1,41 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "EditButton", {
18
+ enumerable: true,
19
+ get: ()=>EditButton
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _material = require("@mui/material");
23
+ const _pencilOutline = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/PencilOutline"));
24
+ function _interopRequireDefault(obj) {
25
+ return obj && obj.__esModule ? obj : {
26
+ default: obj
27
+ };
28
+ }
29
+ const EditButton = ({ label ='Edit' , onClick })=>{
30
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
31
+ onClick: onClick,
32
+ startIcon: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pencilOutline.default, {}),
33
+ variant: "outlined",
34
+ color: "secondary",
35
+ sx: {
36
+ whiteSpace: 'nowrap',
37
+ minWidth: 'auto'
38
+ },
39
+ children: label
40
+ });
41
+ };
@@ -0,0 +1,28 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ _exportStar(require("./EditButton"), exports);
18
+ function _exportStar(from, to) {
19
+ Object.keys(from).forEach(function(k) {
20
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
21
+ enumerable: true,
22
+ get: function() {
23
+ return from[k];
24
+ }
25
+ });
26
+ });
27
+ return from;
28
+ }
@@ -0,0 +1,42 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "EditJsonButton", {
18
+ enumerable: true,
19
+ get: ()=>EditJsonButton
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _codeBraces = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/CodeBraces"));
23
+ const _components = require("@perses-dev/components");
24
+ const _constants = require("../../constants");
25
+ const _toolbarIconButton = require("../ToolbarIconButton");
26
+ const _context = require("../../context");
27
+ function _interopRequireDefault(obj) {
28
+ return obj && obj.__esModule ? obj : {
29
+ default: obj
30
+ };
31
+ }
32
+ const EditJsonButton = ()=>{
33
+ const { openEditJsonDialog } = (0, _context.useEditJsonDialog)();
34
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.InfoTooltip, {
35
+ description: _constants.TOOLTIP_TEXT.editJson,
36
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_toolbarIconButton.ToolbarIconButton, {
37
+ variant: "outlined",
38
+ onClick: ()=>openEditJsonDialog(),
39
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_codeBraces.default, {})
40
+ })
41
+ });
42
+ };
@@ -0,0 +1,28 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ _exportStar(require("./EditJsonButton"), exports);
18
+ function _exportStar(from, to) {
19
+ Object.keys(from).forEach(function(k) {
20
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
21
+ enumerable: true,
22
+ get: function() {
23
+ return from[k];
24
+ }
25
+ });
26
+ });
27
+ return from;
28
+ }
@@ -0,0 +1,86 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "EditJsonDialog", {
18
+ enumerable: true,
19
+ get: ()=>EditJsonDialog
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _react = require("react");
23
+ const _material = require("@mui/material");
24
+ const _components = require("@perses-dev/components");
25
+ const _dashboardProvider = require("../../context/DashboardProvider");
26
+ const _useDashboard = require("../../context/useDashboard");
27
+ const EditJsonDialog = ()=>{
28
+ const { editJsonDialog , closeEditJsonDialog } = (0, _dashboardProvider.useEditJsonDialog)();
29
+ return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_components.Dialog, {
30
+ open: !!(editJsonDialog === null || editJsonDialog === void 0 ? void 0 : editJsonDialog.isOpen),
31
+ scroll: "paper",
32
+ fullWidth: true,
33
+ maxWidth: "lg",
34
+ children: [
35
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.Dialog.Header, {
36
+ onClose: ()=>closeEditJsonDialog(),
37
+ children: "Edit Dashboard"
38
+ }),
39
+ (editJsonDialog === null || editJsonDialog === void 0 ? void 0 : editJsonDialog.isOpen) && /*#__PURE__*/ (0, _jsxRuntime.jsx)(EditJsonDialogForm, {})
40
+ ]
41
+ });
42
+ };
43
+ const EditJsonDialogForm = ()=>{
44
+ const { closeEditJsonDialog } = (0, _dashboardProvider.useEditJsonDialog)();
45
+ const { dashboard , setDashboard } = (0, _useDashboard.useDashboard)();
46
+ const [draftDashboard, setDraftDashboard] = (0, _react.useState)(dashboard);
47
+ const handleApply = (e)=>{
48
+ e.preventDefault();
49
+ setDashboard(draftDashboard);
50
+ closeEditJsonDialog();
51
+ };
52
+ return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_components.Dialog.Form, {
53
+ onSubmit: handleApply,
54
+ children: [
55
+ /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_components.Dialog.Content, {
56
+ sx: {
57
+ width: '100%'
58
+ },
59
+ children: [
60
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Alert, {
61
+ sx: {
62
+ marginBottom: (theme)=>theme.spacing(1)
63
+ },
64
+ severity: "warning",
65
+ children: "Metadata cannot be modified or saved."
66
+ }),
67
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.FormControl, {
68
+ fullWidth: true,
69
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.JSONEditor, {
70
+ minHeight: "300px",
71
+ maxHeight: "700px",
72
+ value: draftDashboard,
73
+ onChange: (value)=>setDraftDashboard(value)
74
+ })
75
+ })
76
+ ]
77
+ }),
78
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.Dialog.Actions, {
79
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.Dialog.PrimaryButton, {
80
+ onClick: handleApply,
81
+ children: "Apply"
82
+ })
83
+ })
84
+ ]
85
+ });
86
+ };
@@ -0,0 +1,28 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ _exportStar(require("./EditJsonDialog"), exports);
18
+ function _exportStar(from, to) {
19
+ Object.keys(from).forEach(function(k) {
20
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
21
+ enumerable: true,
22
+ get: function() {
23
+ return from[k];
24
+ }
25
+ });
26
+ });
27
+ return from;
28
+ }
@@ -0,0 +1,127 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "EmptyDashboard", {
18
+ enumerable: true,
19
+ get: ()=>EmptyDashboard
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _material = require("@mui/material");
23
+ const _context = require("../../context");
24
+ const _addPanelButton = require("../AddPanelButton");
25
+ const _variables = require("../Variables");
26
+ const _editButton = require("../EditButton");
27
+ const DEFAULT_TITLE = "Let's get started";
28
+ const DEFAULT_DESCRIPTION = {
29
+ edit: 'We currently support time series charts, gauge charts, stat charts and more!',
30
+ view: 'This dashboard is currently empty. Get started by clicking the edit button.'
31
+ };
32
+ // Constants from specifics in designs to make the default messaging look good.
33
+ const CONTAINER_WIDTH = '450px';
34
+ const PRIMARY_CONTENT_WIDTH = '289px';
35
+ const COMMON_BUTTON_PROPS = {
36
+ variant: 'outlined',
37
+ color: 'secondary'
38
+ };
39
+ const EmptyDashboardActions = ({ actions , isEditMode , onEditButtonClick })=>{
40
+ if (actions && typeof actions !== 'boolean') {
41
+ // Custom actions
42
+ return actions;
43
+ }
44
+ if (actions === false) {
45
+ // Disable default actions
46
+ return null;
47
+ }
48
+ if (isEditMode) {
49
+ // Default edit mode actions
50
+ return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
51
+ children: [
52
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_addPanelButton.AddPanelButton, {
53
+ variant: "outlined",
54
+ color: "secondary",
55
+ label: "Add Panel",
56
+ fullWidth: true
57
+ }),
58
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_variables.EditVariablesButton, {
59
+ variant: "outlined",
60
+ color: "secondary",
61
+ label: "Add Variables",
62
+ fullWidth: true
63
+ })
64
+ ]
65
+ });
66
+ }
67
+ if (onEditButtonClick) {
68
+ // Default view mode actions
69
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_editButton.EditButton, {
70
+ ...COMMON_BUTTON_PROPS,
71
+ label: "Edit Dashboard",
72
+ onClick: onEditButtonClick
73
+ });
74
+ }
75
+ return null;
76
+ };
77
+ const EmptyDashboard = ({ title =DEFAULT_TITLE , description , additionalText , actions , onEditButtonClick })=>{
78
+ const { isEditMode } = (0, _context.useEditMode)();
79
+ const defaultDescription = isEditMode ? DEFAULT_DESCRIPTION.edit : DEFAULT_DESCRIPTION.view;
80
+ const actionsContent = /*#__PURE__*/ (0, _jsxRuntime.jsx)(EmptyDashboardActions, {
81
+ actions: actions,
82
+ onEditButtonClick: onEditButtonClick,
83
+ isEditMode: isEditMode
84
+ });
85
+ return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
86
+ sx: {
87
+ width: CONTAINER_WIDTH,
88
+ textAlign: 'center',
89
+ margin: '0 auto'
90
+ },
91
+ children: [
92
+ /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
93
+ sx: {
94
+ width: PRIMARY_CONTENT_WIDTH,
95
+ margin: '0 auto'
96
+ },
97
+ children: [
98
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
99
+ variant: "h2",
100
+ gutterBottom: true,
101
+ children: title
102
+ }),
103
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
104
+ variant: "body1",
105
+ children: description !== null && description !== void 0 ? description : defaultDescription
106
+ }),
107
+ actionsContent && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
108
+ sx: {
109
+ display: 'flex',
110
+ gap: 2,
111
+ marginTop: 1,
112
+ justifyContent: 'center'
113
+ },
114
+ children: actionsContent
115
+ })
116
+ ]
117
+ }),
118
+ additionalText && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
119
+ variant: "subtitle1",
120
+ sx: {
121
+ marginTop: 12
122
+ },
123
+ children: additionalText
124
+ })
125
+ ]
126
+ });
127
+ };
@@ -0,0 +1,28 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ _exportStar(require("./EmptyDashboard"), exports);
18
+ function _exportStar(from, to) {
19
+ Object.keys(from).forEach(function(k) {
20
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
21
+ enumerable: true,
22
+ get: function() {
23
+ return from[k];
24
+ }
25
+ });
26
+ });
27
+ return from;
28
+ }