@perses-dev/dashboards 0.24.0 → 0.26.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 (161) 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 +128 -0
  11. package/dist/cjs/components/EmptyDashboard/index.js +28 -0
  12. package/dist/cjs/components/Panel/Panel.js +0 -4
  13. package/dist/cjs/components/Panel/PanelHeader.js +2 -2
  14. package/dist/cjs/components/QuerySummaryTable/QuerySummaryTable.js +185 -0
  15. package/dist/cjs/components/QuerySummaryTable/index.js +28 -0
  16. package/dist/cjs/components/ToolbarIconButton/ToolbarIconButton.js +6 -3
  17. package/dist/cjs/components/Variables/EditVariablesButton.js +9 -2
  18. package/dist/cjs/components/index.js +4 -0
  19. package/dist/cjs/constants/user-interface-text.js +1 -0
  20. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +12 -6
  21. package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +10 -1
  22. package/dist/cjs/context/DashboardProvider/edit-json-dialog-slice.js +36 -0
  23. package/dist/cjs/context/DatasourceStoreProvider.js +9 -3
  24. package/dist/cjs/context/TemplateVariableProvider/TemplateVariableProvider.js +3 -41
  25. package/dist/cjs/context/TemplateVariableProvider/hydrationUtils.js +68 -0
  26. package/dist/cjs/stories/decorators/WithDashboard.js +39 -0
  27. package/dist/cjs/stories/decorators/WithDatasourceStore.js +82 -0
  28. package/dist/cjs/stories/decorators/WithPluginRegistry.js +91 -0
  29. package/dist/cjs/stories/decorators/WithQueryClient.js +29 -0
  30. package/dist/cjs/stories/decorators/WithQueryParams.js +29 -0
  31. package/dist/cjs/stories/decorators/WithTemplateVariables.js +35 -0
  32. package/dist/cjs/stories/decorators/WithTimeRange.js +38 -0
  33. package/dist/cjs/stories/decorators/constants.js +36 -0
  34. package/dist/cjs/stories/decorators/index.js +35 -0
  35. package/dist/cjs/views/ViewDashboard/DashboardApp.js +11 -4
  36. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +2 -1
  37. package/dist/components/AddPanelButton/AddPanelButton.d.ts +16 -1
  38. package/dist/components/AddPanelButton/AddPanelButton.d.ts.map +1 -1
  39. package/dist/components/AddPanelButton/AddPanelButton.js +9 -2
  40. package/dist/components/AddPanelButton/AddPanelButton.js.map +1 -1
  41. package/dist/components/Dashboard/Dashboard.d.ts +10 -2
  42. package/dist/components/Dashboard/Dashboard.d.ts.map +1 -1
  43. package/dist/components/Dashboard/Dashboard.js +24 -7
  44. package/dist/components/Dashboard/Dashboard.js.map +1 -1
  45. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
  46. package/dist/components/DashboardToolbar/DashboardToolbar.js +8 -12
  47. package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
  48. package/dist/components/EditButton/EditButton.d.ts +13 -0
  49. package/dist/components/EditButton/EditButton.d.ts.map +1 -0
  50. package/dist/components/EditButton/EditButton.js +30 -0
  51. package/dist/components/EditButton/EditButton.js.map +1 -0
  52. package/dist/components/EditButton/index.d.ts +2 -0
  53. package/dist/components/EditButton/index.d.ts.map +1 -0
  54. package/dist/components/EditButton/index.js +15 -0
  55. package/dist/components/EditButton/index.js.map +1 -0
  56. package/dist/components/EditJsonButton/EditJsonButton.d.ts +3 -0
  57. package/dist/components/EditJsonButton/EditJsonButton.d.ts.map +1 -0
  58. package/dist/components/EditJsonButton/EditJsonButton.js +31 -0
  59. package/dist/components/EditJsonButton/EditJsonButton.js.map +1 -0
  60. package/dist/components/EditJsonButton/index.d.ts +2 -0
  61. package/dist/components/EditJsonButton/index.d.ts.map +1 -0
  62. package/dist/components/EditJsonButton/index.js +15 -0
  63. package/dist/components/EditJsonButton/index.js.map +1 -0
  64. package/dist/components/EditJsonDialog/EditJsonDialog.d.ts +3 -0
  65. package/dist/components/EditJsonDialog/EditJsonDialog.d.ts.map +1 -0
  66. package/dist/components/EditJsonDialog/EditJsonDialog.js +80 -0
  67. package/dist/components/EditJsonDialog/EditJsonDialog.js.map +1 -0
  68. package/dist/components/EditJsonDialog/index.d.ts +2 -0
  69. package/dist/components/EditJsonDialog/index.d.ts.map +1 -0
  70. package/dist/components/EditJsonDialog/index.js +15 -0
  71. package/dist/components/EditJsonDialog/index.js.map +1 -0
  72. package/dist/components/EmptyDashboard/EmptyDashboard.d.ts +37 -0
  73. package/dist/components/EmptyDashboard/EmptyDashboard.d.ts.map +1 -0
  74. package/dist/components/EmptyDashboard/EmptyDashboard.js +124 -0
  75. package/dist/components/EmptyDashboard/EmptyDashboard.js.map +1 -0
  76. package/dist/components/EmptyDashboard/index.d.ts +2 -0
  77. package/dist/components/EmptyDashboard/index.d.ts.map +1 -0
  78. package/dist/components/EmptyDashboard/index.js +15 -0
  79. package/dist/components/EmptyDashboard/index.js.map +1 -0
  80. package/dist/components/Panel/Panel.d.ts.map +1 -1
  81. package/dist/components/Panel/Panel.js +0 -4
  82. package/dist/components/Panel/Panel.js.map +1 -1
  83. package/dist/components/Panel/PanelHeader.d.ts +1 -2
  84. package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
  85. package/dist/components/Panel/PanelHeader.js +2 -2
  86. package/dist/components/Panel/PanelHeader.js.map +1 -1
  87. package/dist/components/QuerySummaryTable/QuerySummaryTable.d.ts +11 -0
  88. package/dist/components/QuerySummaryTable/QuerySummaryTable.d.ts.map +1 -0
  89. package/dist/components/QuerySummaryTable/QuerySummaryTable.js +179 -0
  90. package/dist/components/QuerySummaryTable/QuerySummaryTable.js.map +1 -0
  91. package/dist/components/QuerySummaryTable/index.d.ts +2 -0
  92. package/dist/components/QuerySummaryTable/index.d.ts.map +1 -0
  93. package/dist/components/QuerySummaryTable/index.js +15 -0
  94. package/dist/components/QuerySummaryTable/index.js.map +1 -0
  95. package/dist/components/ToolbarIconButton/ToolbarIconButton.d.ts +1 -1
  96. package/dist/components/ToolbarIconButton/ToolbarIconButton.d.ts.map +1 -1
  97. package/dist/components/ToolbarIconButton/ToolbarIconButton.js +6 -3
  98. package/dist/components/ToolbarIconButton/ToolbarIconButton.js.map +1 -1
  99. package/dist/components/Variables/EditVariablesButton.d.ts +16 -1
  100. package/dist/components/Variables/EditVariablesButton.d.ts.map +1 -1
  101. package/dist/components/Variables/EditVariablesButton.js +9 -2
  102. package/dist/components/Variables/EditVariablesButton.js.map +1 -1
  103. package/dist/components/index.d.ts +4 -0
  104. package/dist/components/index.d.ts.map +1 -1
  105. package/dist/components/index.js +4 -0
  106. package/dist/components/index.js.map +1 -1
  107. package/dist/constants/user-interface-text.d.ts +1 -0
  108. package/dist/constants/user-interface-text.d.ts.map +1 -1
  109. package/dist/constants/user-interface-text.js +1 -0
  110. package/dist/constants/user-interface-text.js.map +1 -1
  111. package/dist/context/DashboardProvider/DashboardProvider.d.ts +2 -1
  112. package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
  113. package/dist/context/DashboardProvider/DashboardProvider.js +12 -6
  114. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
  115. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +8 -0
  116. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
  117. package/dist/context/DashboardProvider/dashboard-provider-api.js +10 -0
  118. package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
  119. package/dist/context/DashboardProvider/edit-json-dialog-slice.d.ts +12 -0
  120. package/dist/context/DashboardProvider/edit-json-dialog-slice.d.ts.map +1 -0
  121. package/dist/context/DashboardProvider/edit-json-dialog-slice.js +30 -0
  122. package/dist/context/DashboardProvider/edit-json-dialog-slice.js.map +1 -0
  123. package/dist/context/DatasourceStoreProvider.d.ts +2 -0
  124. package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
  125. package/dist/context/DatasourceStoreProvider.js +9 -3
  126. package/dist/context/DatasourceStoreProvider.js.map +1 -1
  127. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts +3 -2
  128. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts.map +1 -1
  129. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js +1 -39
  130. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js.map +1 -1
  131. package/dist/context/TemplateVariableProvider/hydrationUtils.d.ts +4 -0
  132. package/dist/context/TemplateVariableProvider/hydrationUtils.d.ts.map +1 -0
  133. package/dist/context/TemplateVariableProvider/hydrationUtils.js +62 -0
  134. package/dist/context/TemplateVariableProvider/hydrationUtils.js.map +1 -0
  135. package/dist/stories/decorators/WithDashboard.js +33 -0
  136. package/dist/stories/decorators/WithDashboard.js.map +1 -0
  137. package/dist/stories/decorators/WithDatasourceStore.js +76 -0
  138. package/dist/stories/decorators/WithDatasourceStore.js.map +1 -0
  139. package/dist/stories/decorators/WithPluginRegistry.js +46 -0
  140. package/dist/stories/decorators/WithPluginRegistry.js.map +1 -0
  141. package/dist/stories/decorators/WithQueryClient.js +23 -0
  142. package/dist/stories/decorators/WithQueryClient.js.map +1 -0
  143. package/dist/stories/decorators/WithQueryParams.js +23 -0
  144. package/dist/stories/decorators/WithQueryParams.js.map +1 -0
  145. package/dist/stories/decorators/WithTemplateVariables.js +29 -0
  146. package/dist/stories/decorators/WithTemplateVariables.js.map +1 -0
  147. package/dist/stories/decorators/WithTimeRange.js +32 -0
  148. package/dist/stories/decorators/WithTimeRange.js.map +1 -0
  149. package/dist/stories/decorators/constants.js +30 -0
  150. package/dist/stories/decorators/constants.js.map +1 -0
  151. package/dist/stories/decorators/index.js +22 -0
  152. package/dist/stories/decorators/index.js.map +1 -0
  153. package/dist/views/ViewDashboard/DashboardApp.d.ts +2 -0
  154. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
  155. package/dist/views/ViewDashboard/DashboardApp.js +12 -5
  156. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  157. package/dist/views/ViewDashboard/ViewDashboard.d.ts +2 -8
  158. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
  159. package/dist/views/ViewDashboard/ViewDashboard.js +2 -1
  160. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
  161. package/package.json +4 -4
@@ -0,0 +1,82 @@
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, "WithDatasourceStore", {
18
+ enumerable: true,
19
+ get: ()=>WithDatasourceStore
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _dashboards = require("@perses-dev/dashboards");
23
+ const _constants = require("./constants");
24
+ // Type guard because storybook types parameters as `any`
25
+ function isWithDatasourceStoreParameter(parameter) {
26
+ return !!parameter && typeof parameter === 'object' && 'props' in parameter;
27
+ }
28
+ const prometheusDemoUrl = 'https://prometheus.demo.do.prometheus.io';
29
+ const prometheusDemo = {
30
+ kind: 'GlobalDatasource',
31
+ metadata: {
32
+ name: 'PrometheusDemo',
33
+ created_at: '0001-01-01T00:00:00Z',
34
+ updated_at: '0001-01-01T00:00:00Z',
35
+ version: 0
36
+ },
37
+ spec: {
38
+ default: true,
39
+ plugin: {
40
+ kind: 'PrometheusDatasource',
41
+ spec: {
42
+ direct_url: prometheusDemoUrl
43
+ }
44
+ }
45
+ }
46
+ };
47
+ const WithDatasourceStore = (Story, context)=>{
48
+ const initParameter = context.parameters.withDatasourceStore;
49
+ const parameter = isWithDatasourceStoreParameter(initParameter) ? initParameter : undefined;
50
+ const props = parameter === null || parameter === void 0 ? void 0 : parameter.props;
51
+ // This default currently defines the bare minimum to get a story working in
52
+ // the `Dashboard` storybook with the Prometheus demo api. We'll likely want
53
+ // to expand it to do more in the future.
54
+ const defaultDatasourceProps = {
55
+ dashboardResource: _constants.EMPTY_DASHBOARD_RESOURCE,
56
+ datasourceApi: {
57
+ getDatasource: ()=>{
58
+ return Promise.resolve(undefined);
59
+ },
60
+ getGlobalDatasource: (selector)=>{
61
+ if (selector.kind === 'PrometheusDatasource') {
62
+ return Promise.resolve({
63
+ resource: prometheusDemo,
64
+ proxyUrl: prometheusDemoUrl
65
+ });
66
+ }
67
+ return Promise.resolve(undefined);
68
+ },
69
+ listDatasources: ()=>{
70
+ return Promise.resolve([]);
71
+ },
72
+ listGlobalDatasources: ()=>{
73
+ return Promise.resolve([]);
74
+ }
75
+ }
76
+ };
77
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_dashboards.DatasourceStoreProvider, {
78
+ ...defaultDatasourceProps,
79
+ ...props,
80
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(Story, {})
81
+ });
82
+ };
@@ -0,0 +1,91 @@
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, "WithPluginRegistry", {
18
+ enumerable: true,
19
+ get: ()=>WithPluginRegistry
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _pluginSystem = require("@perses-dev/plugin-system");
23
+ function _getRequireWildcardCache(nodeInterop) {
24
+ if (typeof WeakMap !== "function") return null;
25
+ var cacheBabelInterop = new WeakMap();
26
+ var cacheNodeInterop = new WeakMap();
27
+ return (_getRequireWildcardCache = function(nodeInterop) {
28
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
29
+ })(nodeInterop);
30
+ }
31
+ function _interopRequireWildcard(obj, nodeInterop) {
32
+ if (!nodeInterop && obj && obj.__esModule) {
33
+ return obj;
34
+ }
35
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
36
+ return {
37
+ default: obj
38
+ };
39
+ }
40
+ var cache = _getRequireWildcardCache(nodeInterop);
41
+ if (cache && cache.has(obj)) {
42
+ return cache.get(obj);
43
+ }
44
+ var newObj = {};
45
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
46
+ for(var key in obj){
47
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
48
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
49
+ if (desc && (desc.get || desc.set)) {
50
+ Object.defineProperty(newObj, key, desc);
51
+ } else {
52
+ newObj[key] = obj[key];
53
+ }
54
+ }
55
+ }
56
+ newObj.default = obj;
57
+ if (cache) {
58
+ cache.set(obj, newObj);
59
+ }
60
+ return newObj;
61
+ }
62
+ // NOTE: the aliases we use for components break these top level imports, so we
63
+ // import relatively.
64
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
65
+ const prometheusResource = require('../../../../prometheus-plugin/plugin.json');
66
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
67
+ const panelsResource = require('../../../../panels-plugin/plugin.json');
68
+ const bundledPluginLoader = (0, _pluginSystem.dynamicImportPluginLoader)([
69
+ {
70
+ resource: prometheusResource,
71
+ // This throws an error in CI (but not locally for some reason), likely because
72
+ // this package isn't a dependency for dashboards. We probably do not want to
73
+ // make it one solely for type-checking in storybook.
74
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
75
+ // @ts-ignore
76
+ importPlugin: ()=>Promise.resolve().then(()=>/*#__PURE__*/ _interopRequireWildcard(require("@perses-dev/prometheus-plugin")))
77
+ },
78
+ {
79
+ resource: panelsResource,
80
+ // Same comment as above.
81
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
82
+ // @ts-ignore
83
+ importPlugin: ()=>Promise.resolve().then(()=>/*#__PURE__*/ _interopRequireWildcard(require("@perses-dev/panels-plugin")))
84
+ }
85
+ ]);
86
+ const WithPluginRegistry = (Story)=>{
87
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.PluginRegistry, {
88
+ pluginLoader: bundledPluginLoader,
89
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(Story, {})
90
+ });
91
+ };
@@ -0,0 +1,29 @@
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, "WithQueryClient", {
18
+ enumerable: true,
19
+ get: ()=>WithQueryClient
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _reactQuery = require("@tanstack/react-query");
23
+ const WithQueryClient = (Story)=>{
24
+ const queryClient = new _reactQuery.QueryClient({});
25
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_reactQuery.QueryClientProvider, {
26
+ client: queryClient,
27
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(Story, {})
28
+ });
29
+ };
@@ -0,0 +1,29 @@
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, "WithQueryParams", {
18
+ enumerable: true,
19
+ get: ()=>WithQueryParams
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _window = require("use-query-params/adapters/window");
23
+ const _useQueryParams = require("use-query-params");
24
+ const WithQueryParams = (Story)=>{
25
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_useQueryParams.QueryParamProvider, {
26
+ adapter: _window.WindowHistoryAdapter,
27
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(Story, {})
28
+ });
29
+ };
@@ -0,0 +1,35 @@
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, "WithTemplateVariables", {
18
+ enumerable: true,
19
+ get: ()=>WithTemplateVariables
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _dashboards = require("@perses-dev/dashboards");
23
+ // Type guard because storybook types parameters as `any`
24
+ function isWithTemplateVariableParameter(parameter) {
25
+ return !!parameter && typeof parameter === 'object' && 'props' in parameter;
26
+ }
27
+ const WithTemplateVariables = (Story, context)=>{
28
+ const initParameter = context.parameters.withTemplateVariables;
29
+ const parameter = isWithTemplateVariableParameter(initParameter) ? initParameter : undefined;
30
+ const props = parameter === null || parameter === void 0 ? void 0 : parameter.props;
31
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_dashboards.TemplateVariableProvider, {
32
+ ...props,
33
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(Story, {})
34
+ });
35
+ };
@@ -0,0 +1,38 @@
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, "WithTimeRange", {
18
+ enumerable: true,
19
+ get: ()=>WithTimeRange
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _pluginSystem = require("@perses-dev/plugin-system");
23
+ // Type guard because storybook types parameters as `any`
24
+ function isWithTimeRangeParameter(parameter) {
25
+ return !!parameter && typeof parameter === 'object' && 'props' in parameter;
26
+ }
27
+ const WithTimeRange = (Story, context)=>{
28
+ const initParameter = context.parameters.withTimeRange;
29
+ const parameter = isWithTimeRangeParameter(initParameter) ? initParameter : undefined;
30
+ const props = parameter === null || parameter === void 0 ? void 0 : parameter.props;
31
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.TimeRangeProvider, {
32
+ initialTimeRange: {
33
+ pastDuration: '1h'
34
+ },
35
+ ...props,
36
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(Story, {})
37
+ });
38
+ };
@@ -0,0 +1,36 @@
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, "EMPTY_DASHBOARD_RESOURCE", {
18
+ enumerable: true,
19
+ get: ()=>EMPTY_DASHBOARD_RESOURCE
20
+ });
21
+ const EMPTY_DASHBOARD_RESOURCE = {
22
+ kind: 'Dashboard',
23
+ metadata: {
24
+ name: 'My Dashboard',
25
+ project: 'Storybook',
26
+ created_at: '2021-11-09T00:00:00Z',
27
+ updated_at: '2021-11-09T00:00:00Z',
28
+ version: 0
29
+ },
30
+ spec: {
31
+ duration: '1h',
32
+ variables: [],
33
+ layouts: [],
34
+ panels: {}
35
+ }
36
+ };
@@ -0,0 +1,35 @@
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("./constants"), exports);
18
+ _exportStar(require("./WithDashboard"), exports);
19
+ _exportStar(require("./WithDatasourceStore"), exports);
20
+ _exportStar(require("./WithPluginRegistry"), exports);
21
+ _exportStar(require("./WithQueryClient"), exports);
22
+ _exportStar(require("./WithQueryParams"), exports);
23
+ _exportStar(require("./WithTemplateVariables"), exports);
24
+ _exportStar(require("./WithTimeRange"), exports);
25
+ function _exportStar(from, to) {
26
+ Object.keys(from).forEach(function(k) {
27
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
28
+ enumerable: true,
29
+ get: function() {
30
+ return from[k];
31
+ }
32
+ });
33
+ });
34
+ return from;
35
+ }
@@ -25,7 +25,7 @@ const _components = require("@perses-dev/components");
25
25
  const _components1 = require("../../components");
26
26
  const _context = require("../../context");
27
27
  const DashboardApp = (props)=>{
28
- const { dashboardResource , dashboardTitleComponent , onSave , onDiscard , initialVariableIsSticky , isReadonly } = props;
28
+ const { dashboardResource , dashboardTitleComponent , emptyDashboardProps , onSave , onDiscard , initialVariableIsSticky , isReadonly , } = props;
29
29
  const { setEditMode } = (0, _context.useEditMode)();
30
30
  const { dashboard , setDashboard } = (0, _context.useDashboard)();
31
31
  const [originalDashboard, setOriginalDashboard] = (0, _react.useState)(undefined);
@@ -80,18 +80,25 @@ const DashboardApp = (props)=>{
80
80
  }),
81
81
  /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
82
82
  sx: {
83
- padding: (theme)=>theme.spacing(2)
83
+ padding: (theme)=>theme.spacing(2),
84
+ height: '100%'
84
85
  },
85
86
  children: [
86
87
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorBoundary, {
87
88
  FallbackComponent: _components.ErrorAlert,
88
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.Dashboard, {})
89
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.Dashboard, {
90
+ emptyDashboardProps: {
91
+ onEditButtonClick,
92
+ ...emptyDashboardProps
93
+ }
94
+ })
89
95
  }),
90
96
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.PanelDrawer, {}),
91
97
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.PanelGroupDialog, {}),
92
98
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.DeletePanelGroupDialog, {}),
93
99
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.DeletePanelDialog, {}),
94
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.DiscardChangesConfirmationDialog, {})
100
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.DiscardChangesConfirmationDialog, {}),
101
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.EditJsonDialog, {})
95
102
  ]
96
103
  })
97
104
  ]
@@ -25,7 +25,7 @@ const _pluginSystem = require("@perses-dev/plugin-system");
25
25
  const _context = require("../../context");
26
26
  const _dashboardApp = require("./DashboardApp");
27
27
  function ViewDashboard(props) {
28
- const { dashboardResource , datasourceApi , dashboardTitleComponent , onSave , onDiscard , initialVariableIsSticky , isReadonly , isEditing , sx , ...others } = props;
28
+ const { dashboardResource , datasourceApi , dashboardTitleComponent , emptyDashboardProps , onSave , onDiscard , initialVariableIsSticky , isReadonly , isEditing , sx , ...others } = props;
29
29
  const { spec } = dashboardResource;
30
30
  var _duration;
31
31
  const dashboardDuration = (_duration = spec.duration) !== null && _duration !== void 0 ? _duration : '1h';
@@ -57,6 +57,7 @@ function ViewDashboard(props) {
57
57
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_dashboardApp.DashboardApp, {
58
58
  dashboardResource: dashboardResource,
59
59
  dashboardTitleComponent: dashboardTitleComponent,
60
+ emptyDashboardProps: emptyDashboardProps,
60
61
  onSave: onSave,
61
62
  onDiscard: onDiscard,
62
63
  initialVariableIsSticky: initialVariableIsSticky,
@@ -1,3 +1,18 @@
1
1
  /// <reference types="react" />
2
- export declare const AddPanelButton: () => JSX.Element;
2
+ import { ButtonProps } from '@mui/material';
3
+ export interface AddPanelButtonProps extends Pick<ButtonProps, 'fullWidth'> {
4
+ /**
5
+ * The variant to use to display the button.
6
+ */
7
+ variant?: 'text' | 'outlined';
8
+ /**
9
+ * The color to use to display the button.
10
+ */
11
+ color?: 'primary' | 'secondary';
12
+ /**
13
+ * The label used inside the button.
14
+ */
15
+ label?: string;
16
+ }
17
+ export declare const AddPanelButton: ({ variant, color, label, fullWidth, }: AddPanelButtonProps) => JSX.Element;
3
18
  //# sourceMappingURL=AddPanelButton.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AddPanelButton.d.ts","sourceRoot":"","sources":["../../../src/components/AddPanelButton/AddPanelButton.tsx"],"names":[],"mappings":";AAmBA,eAAO,MAAM,cAAc,mBAU1B,CAAC"}
1
+ {"version":3,"file":"AddPanelButton.d.ts","sourceRoot":"","sources":["../../../src/components/AddPanelButton/AddPanelButton.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAU,WAAW,EAAE,MAAM,eAAe,CAAC;AAMpD,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC;IACzE;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAE9B;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC;IAEhC;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,cAAc,0CAKxB,mBAAmB,gBAkBrB,CAAC"}
@@ -16,7 +16,7 @@ import AddPanelIcon from 'mdi-material-ui/ChartBoxPlusOutline';
16
16
  import { InfoTooltip } from '@perses-dev/components';
17
17
  import { TOOLTIP_TEXT } from '../../constants';
18
18
  import { useDashboardActions } from '../../context';
19
- export const AddPanelButton = ()=>{
19
+ export const AddPanelButton = ({ variant ='text' , color ='primary' , label ='Panel' , fullWidth })=>{
20
20
  const { openAddPanel } = useDashboardActions();
21
21
  return /*#__PURE__*/ _jsx(InfoTooltip, {
22
22
  description: TOOLTIP_TEXT.addPanel,
@@ -24,7 +24,14 @@ export const AddPanelButton = ()=>{
24
24
  startIcon: /*#__PURE__*/ _jsx(AddPanelIcon, {}),
25
25
  onClick: openAddPanel,
26
26
  "aria-label": TOOLTIP_TEXT.addPanel,
27
- children: "Panel"
27
+ variant: variant,
28
+ color: color,
29
+ fullWidth: fullWidth,
30
+ sx: {
31
+ whiteSpace: 'nowrap',
32
+ minWidth: 'auto'
33
+ },
34
+ children: label
28
35
  })
29
36
  });
30
37
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/AddPanelButton/AddPanelButton.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Button } from '@mui/material';\nimport AddPanelIcon from 'mdi-material-ui/ChartBoxPlusOutline';\nimport { InfoTooltip } from '@perses-dev/components';\nimport { TOOLTIP_TEXT } from '../../constants';\nimport { useDashboardActions } from '../../context';\n\nexport const AddPanelButton = () => {\n const { openAddPanel } = useDashboardActions();\n\n return (\n <InfoTooltip description={TOOLTIP_TEXT.addPanel}>\n <Button startIcon={<AddPanelIcon />} onClick={openAddPanel} aria-label={TOOLTIP_TEXT.addPanel}>\n Panel\n </Button>\n </InfoTooltip>\n );\n};\n"],"names":["Button","AddPanelIcon","InfoTooltip","TOOLTIP_TEXT","useDashboardActions","AddPanelButton","openAddPanel","description","addPanel","startIcon","onClick","aria-label"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,MAAM,QAAQ,eAAe,CAAC;AACvC,OAAOC,YAAY,MAAM,qCAAqC,CAAC;AAC/D,SAASC,WAAW,QAAQ,wBAAwB,CAAC;AACrD,SAASC,YAAY,QAAQ,iBAAiB,CAAC;AAC/C,SAASC,mBAAmB,QAAQ,eAAe,CAAC;AAEpD,OAAO,MAAMC,cAAc,GAAG,IAAM;IAClC,MAAM,EAAEC,YAAY,CAAA,EAAE,GAAGF,mBAAmB,EAAE,AAAC;IAE/C,qBACE,KAACF,WAAW;QAACK,WAAW,EAAEJ,YAAY,CAACK,QAAQ;kBAC7C,cAAA,KAACR,MAAM;YAACS,SAAS,gBAAE,KAACR,YAAY,KAAG;YAAES,OAAO,EAAEJ,YAAY;YAAEK,YAAU,EAAER,YAAY,CAACK,QAAQ;sBAAE,OAE/F;UAAS;MACG,CACd;AACJ,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../../src/components/AddPanelButton/AddPanelButton.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Button, ButtonProps } from '@mui/material';\nimport AddPanelIcon from 'mdi-material-ui/ChartBoxPlusOutline';\nimport { InfoTooltip } from '@perses-dev/components';\nimport { TOOLTIP_TEXT } from '../../constants';\nimport { useDashboardActions } from '../../context';\n\nexport interface AddPanelButtonProps extends Pick<ButtonProps, 'fullWidth'> {\n /**\n * The variant to use to display the button.\n */\n variant?: 'text' | 'outlined';\n\n /**\n * The color to use to display the button.\n */\n color?: 'primary' | 'secondary';\n\n /**\n * The label used inside the button.\n */\n label?: string;\n}\n\nexport const AddPanelButton = ({\n variant = 'text',\n color = 'primary',\n label = 'Panel',\n fullWidth,\n}: AddPanelButtonProps) => {\n const { openAddPanel } = useDashboardActions();\n\n return (\n <InfoTooltip description={TOOLTIP_TEXT.addPanel}>\n <Button\n startIcon={<AddPanelIcon />}\n onClick={openAddPanel}\n aria-label={TOOLTIP_TEXT.addPanel}\n variant={variant}\n color={color}\n fullWidth={fullWidth}\n sx={{ whiteSpace: 'nowrap', minWidth: 'auto' }}\n >\n {label}\n </Button>\n </InfoTooltip>\n );\n};\n"],"names":["Button","AddPanelIcon","InfoTooltip","TOOLTIP_TEXT","useDashboardActions","AddPanelButton","variant","color","label","fullWidth","openAddPanel","description","addPanel","startIcon","onClick","aria-label","sx","whiteSpace","minWidth"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,MAAM,QAAqB,eAAe,CAAC;AACpD,OAAOC,YAAY,MAAM,qCAAqC,CAAC;AAC/D,SAASC,WAAW,QAAQ,wBAAwB,CAAC;AACrD,SAASC,YAAY,QAAQ,iBAAiB,CAAC;AAC/C,SAASC,mBAAmB,QAAQ,eAAe,CAAC;AAmBpD,OAAO,MAAMC,cAAc,GAAG,CAAC,EAC7BC,OAAO,EAAG,MAAM,CAAA,EAChBC,KAAK,EAAG,SAAS,CAAA,EACjBC,KAAK,EAAG,OAAO,CAAA,EACfC,SAAS,CAAA,EACW,GAAK;IACzB,MAAM,EAAEC,YAAY,CAAA,EAAE,GAAGN,mBAAmB,EAAE,AAAC;IAE/C,qBACE,KAACF,WAAW;QAACS,WAAW,EAAER,YAAY,CAACS,QAAQ;kBAC7C,cAAA,KAACZ,MAAM;YACLa,SAAS,gBAAE,KAACZ,YAAY,KAAG;YAC3Ba,OAAO,EAAEJ,YAAY;YACrBK,YAAU,EAAEZ,YAAY,CAACS,QAAQ;YACjCN,OAAO,EAAEA,OAAO;YAChBC,KAAK,EAAEA,KAAK;YACZE,SAAS,EAAEA,SAAS;YACpBO,EAAE,EAAE;gBAAEC,UAAU,EAAE,QAAQ;gBAAEC,QAAQ,EAAE,MAAM;aAAE;sBAE7CV,KAAK;UACC;MACG,CACd;AACJ,CAAC,CAAC"}
@@ -1,8 +1,16 @@
1
1
  /// <reference types="react" />
2
2
  import { BoxProps } from '@mui/material';
3
- export declare type DashboardProps = BoxProps;
3
+ import { EmptyDashboardProps } from '../EmptyDashboard';
4
+ export declare type DashboardProps = BoxProps & {
5
+ /**
6
+ * Props for `EmptyDashboard` component that will be rendered when the dashboard
7
+ * is empty (i.e. has no panel groups). If not specified, the defaults will
8
+ * be used.
9
+ */
10
+ emptyDashboardProps?: EmptyDashboardProps;
11
+ };
4
12
  /**
5
13
  * Renders a Dashboard for the provided Dashboard spec.
6
14
  */
7
- export declare function Dashboard(props: DashboardProps): JSX.Element;
15
+ export declare function Dashboard({ emptyDashboardProps, ...boxProps }: DashboardProps): JSX.Element;
8
16
  //# sourceMappingURL=Dashboard.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Dashboard.d.ts","sourceRoot":"","sources":["../../../src/components/Dashboard/Dashboard.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAO,QAAQ,EAAE,MAAM,eAAe,CAAC;AAK9C,oBAAY,cAAc,GAAG,QAAQ,CAAC;AAEtC;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,eAW9C"}
1
+ {"version":3,"file":"Dashboard.d.ts","sourceRoot":"","sources":["../../../src/components/Dashboard/Dashboard.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAO,QAAQ,EAAE,MAAM,eAAe,CAAC;AAI9C,OAAO,EAAkB,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExE,oBAAY,cAAc,GAAG,QAAQ,GAAG;IACtC;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;CAC3C,CAAC;AAEF;;GAEG;AACH,wBAAgB,SAAS,CAAC,EAAE,mBAAmB,EAAE,GAAG,QAAQ,EAAE,EAAE,cAAc,eAgB7E"}
@@ -10,22 +10,39 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  import { Box } from '@mui/material';
15
15
  import { ErrorBoundary, ErrorAlert } from '@perses-dev/components';
16
16
  import { usePanelGroupIds } from '../../context';
17
17
  import { GridLayout } from '../GridLayout';
18
+ import { EmptyDashboard } from '../EmptyDashboard';
18
19
  /**
19
20
  * Renders a Dashboard for the provided Dashboard spec.
20
- */ export function Dashboard(props) {
21
+ */ export function Dashboard({ emptyDashboardProps , ...boxProps }) {
21
22
  const panelGroupIds = usePanelGroupIds();
23
+ const isEmpty = !panelGroupIds.length;
22
24
  return /*#__PURE__*/ _jsx(Box, {
23
- ...props,
24
- children: /*#__PURE__*/ _jsx(ErrorBoundary, {
25
+ ...boxProps,
26
+ sx: {
27
+ height: '100%'
28
+ },
29
+ children: /*#__PURE__*/ _jsxs(ErrorBoundary, {
25
30
  FallbackComponent: ErrorAlert,
26
- children: panelGroupIds.map((panelGroupId)=>/*#__PURE__*/ _jsx(GridLayout, {
27
- panelGroupId: panelGroupId
28
- }, panelGroupId))
31
+ children: [
32
+ isEmpty && /*#__PURE__*/ _jsx(Box, {
33
+ sx: {
34
+ height: '100%',
35
+ display: 'flex',
36
+ alignItems: 'center'
37
+ },
38
+ children: /*#__PURE__*/ _jsx(EmptyDashboard, {
39
+ ...emptyDashboardProps
40
+ })
41
+ }),
42
+ !isEmpty && panelGroupIds.map((panelGroupId)=>/*#__PURE__*/ _jsx(GridLayout, {
43
+ panelGroupId: panelGroupId
44
+ }, panelGroupId))
45
+ ]
29
46
  })
30
47
  });
31
48
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Dashboard/Dashboard.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box, BoxProps } from '@mui/material';\nimport { ErrorBoundary, ErrorAlert } from '@perses-dev/components';\nimport { usePanelGroupIds } from '../../context';\nimport { GridLayout } from '../GridLayout';\n\nexport type DashboardProps = BoxProps;\n\n/**\n * Renders a Dashboard for the provided Dashboard spec.\n */\nexport function Dashboard(props: DashboardProps) {\n const panelGroupIds = usePanelGroupIds();\n return (\n <Box {...props}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n {panelGroupIds.map((panelGroupId) => (\n <GridLayout key={panelGroupId} panelGroupId={panelGroupId} />\n ))}\n </ErrorBoundary>\n </Box>\n );\n}\n"],"names":["Box","ErrorBoundary","ErrorAlert","usePanelGroupIds","GridLayout","Dashboard","props","panelGroupIds","FallbackComponent","map","panelGroupId"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,GAAG,QAAkB,eAAe,CAAC;AAC9C,SAASC,aAAa,EAAEC,UAAU,QAAQ,wBAAwB,CAAC;AACnE,SAASC,gBAAgB,QAAQ,eAAe,CAAC;AACjD,SAASC,UAAU,QAAQ,eAAe,CAAC;AAI3C;;CAEC,GACD,OAAO,SAASC,SAAS,CAACC,KAAqB,EAAE;IAC/C,MAAMC,aAAa,GAAGJ,gBAAgB,EAAE,AAAC;IACzC,qBACE,KAACH,GAAG;QAAE,GAAGM,KAAK;kBACZ,cAAA,KAACL,aAAa;YAACO,iBAAiB,EAAEN,UAAU;sBACzCK,aAAa,CAACE,GAAG,CAAC,CAACC,YAAY,iBAC9B,KAACN,UAAU;oBAAoBM,YAAY,EAAEA,YAAY;mBAAxCA,YAAY,CAAgC,AAC9D,CAAC;UACY;MACZ,CACN;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../../src/components/Dashboard/Dashboard.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box, BoxProps } from '@mui/material';\nimport { ErrorBoundary, ErrorAlert } from '@perses-dev/components';\nimport { usePanelGroupIds } from '../../context';\nimport { GridLayout } from '../GridLayout';\nimport { EmptyDashboard, EmptyDashboardProps } from '../EmptyDashboard';\n\nexport type DashboardProps = BoxProps & {\n /**\n * Props for `EmptyDashboard` component that will be rendered when the dashboard\n * is empty (i.e. has no panel groups). If not specified, the defaults will\n * be used.\n */\n emptyDashboardProps?: EmptyDashboardProps;\n};\n\n/**\n * Renders a Dashboard for the provided Dashboard spec.\n */\nexport function Dashboard({ emptyDashboardProps, ...boxProps }: DashboardProps) {\n const panelGroupIds = usePanelGroupIds();\n const isEmpty = !panelGroupIds.length;\n\n return (\n <Box {...boxProps} sx={{ height: '100%' }}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n {isEmpty && (\n <Box sx={{ height: '100%', display: 'flex', alignItems: 'center' }}>\n <EmptyDashboard {...emptyDashboardProps} />\n </Box>\n )}\n {!isEmpty && panelGroupIds.map((panelGroupId) => <GridLayout key={panelGroupId} panelGroupId={panelGroupId} />)}\n </ErrorBoundary>\n </Box>\n );\n}\n"],"names":["Box","ErrorBoundary","ErrorAlert","usePanelGroupIds","GridLayout","EmptyDashboard","Dashboard","emptyDashboardProps","boxProps","panelGroupIds","isEmpty","length","sx","height","FallbackComponent","display","alignItems","map","panelGroupId"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,GAAG,QAAkB,eAAe,CAAC;AAC9C,SAASC,aAAa,EAAEC,UAAU,QAAQ,wBAAwB,CAAC;AACnE,SAASC,gBAAgB,QAAQ,eAAe,CAAC;AACjD,SAASC,UAAU,QAAQ,eAAe,CAAC;AAC3C,SAASC,cAAc,QAA6B,mBAAmB,CAAC;AAWxE;;CAEC,GACD,OAAO,SAASC,SAAS,CAAC,EAAEC,mBAAmB,CAAA,EAAE,GAAGC,QAAQ,EAAkB,EAAE;IAC9E,MAAMC,aAAa,GAAGN,gBAAgB,EAAE,AAAC;IACzC,MAAMO,OAAO,GAAG,CAACD,aAAa,CAACE,MAAM,AAAC;IAEtC,qBACE,KAACX,GAAG;QAAE,GAAGQ,QAAQ;QAAEI,EAAE,EAAE;YAAEC,MAAM,EAAE,MAAM;SAAE;kBACvC,cAAA,MAACZ,aAAa;YAACa,iBAAiB,EAAEZ,UAAU;;gBACzCQ,OAAO,kBACN,KAACV,GAAG;oBAACY,EAAE,EAAE;wBAAEC,MAAM,EAAE,MAAM;wBAAEE,OAAO,EAAE,MAAM;wBAAEC,UAAU,EAAE,QAAQ;qBAAE;8BAChE,cAAA,KAACX,cAAc;wBAAE,GAAGE,mBAAmB;sBAAI;kBACvC,AACP;gBACA,CAACG,OAAO,IAAID,aAAa,CAACQ,GAAG,CAAC,CAACC,YAAY,iBAAK,KAACd,UAAU;wBAAoBc,YAAY,EAAEA,YAAY;uBAAxCA,YAAY,CAAgC,CAAC;;UACjG;MACZ,CACN;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"DashboardToolbar.d.ts","sourceRoot":"","sources":["../../../src/components/DashboardToolbar/DashboardToolbar.tsx"],"names":[],"mappings":";AAiBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAQrD,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,uBAAuB,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACtC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,UAAU,EAAE,OAAO,CAAC;IACpB,iBAAiB,EAAE,MAAM,IAAI,CAAC;IAC9B,mBAAmB,EAAE,MAAM,IAAI,CAAC;IAChC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;CACpE;AAED,eAAO,MAAM,gBAAgB,UAAW,qBAAqB,gBA4I5D,CAAC"}
1
+ {"version":3,"file":"DashboardToolbar.d.ts","sourceRoot":"","sources":["../../../src/components/DashboardToolbar/DashboardToolbar.tsx"],"names":[],"mappings":";AAgBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAUrD,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,uBAAuB,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACtC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,UAAU,EAAE,OAAO,CAAC;IACpB,iBAAiB,EAAE,MAAM,IAAI,CAAC;IAC9B,mBAAmB,EAAE,MAAM,IAAI,CAAC;IAChC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;CACpE;AAED,eAAO,MAAM,gBAAgB,UAAW,qBAAqB,gBAoI5D,CAAC"}