@perses-dev/explore 0.0.0-snapshot-scatter-chart-embed-8efdfab → 0.0.0-snapshot-explorer-plugin-c4a7621

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 (80) hide show
  1. package/dist/cjs/components/ExploreManager/ExploreManager.js +109 -0
  2. package/dist/cjs/components/ExploreManager/ExplorerManagerProvider.js +84 -0
  3. package/dist/cjs/components/ExploreManager/ExplorerManagerProviderWithQueryParams.js +45 -0
  4. package/dist/cjs/components/ExploreManager/index.js +32 -0
  5. package/dist/cjs/components/ExploreManager/query-params.js +49 -0
  6. package/dist/cjs/components/ExploreToolbar/ExploreToolbar.js +9 -3
  7. package/dist/cjs/components/{TimeSeriesQueryEditor/index.js → index.js} +3 -2
  8. package/dist/cjs/index.js +1 -0
  9. package/dist/cjs/views/ViewExplore/ViewExplore.js +26 -27
  10. package/dist/cjs/views/ViewExplore/ViewExploreApp.js +7 -22
  11. package/dist/components/ExploreManager/ExploreManager.d.ts +6 -0
  12. package/dist/components/ExploreManager/ExploreManager.d.ts.map +1 -0
  13. package/dist/components/ExploreManager/ExploreManager.js +101 -0
  14. package/dist/components/ExploreManager/ExploreManager.js.map +1 -0
  15. package/dist/components/ExploreManager/ExplorerManagerProvider.d.ts +20 -0
  16. package/dist/components/ExploreManager/ExplorerManagerProvider.d.ts.map +1 -0
  17. package/dist/components/ExploreManager/ExplorerManagerProvider.js +68 -0
  18. package/dist/components/ExploreManager/ExplorerManagerProvider.js.map +1 -0
  19. package/dist/components/ExploreManager/ExplorerManagerProviderWithQueryParams.d.ts +7 -0
  20. package/dist/components/ExploreManager/ExplorerManagerProviderWithQueryParams.d.ts.map +1 -0
  21. package/dist/components/ExploreManager/ExplorerManagerProviderWithQueryParams.js +32 -0
  22. package/dist/components/ExploreManager/ExplorerManagerProviderWithQueryParams.js.map +1 -0
  23. package/dist/components/ExploreManager/index.d.ts +4 -0
  24. package/dist/components/ExploreManager/index.d.ts.map +1 -0
  25. package/dist/components/ExploreManager/index.js +17 -0
  26. package/dist/components/ExploreManager/index.js.map +1 -0
  27. package/dist/components/ExploreManager/query-params.d.ts +17 -0
  28. package/dist/components/ExploreManager/query-params.d.ts.map +1 -0
  29. package/dist/components/ExploreManager/query-params.js +34 -0
  30. package/dist/components/ExploreManager/query-params.js.map +1 -0
  31. package/dist/components/ExploreToolbar/ExploreToolbar.d.ts +3 -3
  32. package/dist/components/ExploreToolbar/ExploreToolbar.d.ts.map +1 -1
  33. package/dist/components/ExploreToolbar/ExploreToolbar.js +3 -2
  34. package/dist/components/ExploreToolbar/ExploreToolbar.js.map +1 -1
  35. package/dist/components/index.d.ts +3 -0
  36. package/dist/components/index.d.ts.map +1 -0
  37. package/dist/components/{TimeSeriesQueryEditor/index.js → index.js} +3 -2
  38. package/dist/components/index.js.map +1 -0
  39. package/dist/index.d.ts +1 -0
  40. package/dist/index.d.ts.map +1 -1
  41. package/dist/index.js +1 -0
  42. package/dist/index.js.map +1 -1
  43. package/dist/test/setup-tests.js.map +1 -1
  44. package/dist/views/ViewExplore/ViewExplore.d.ts +5 -7
  45. package/dist/views/ViewExplore/ViewExplore.d.ts.map +1 -1
  46. package/dist/views/ViewExplore/ViewExplore.js +22 -28
  47. package/dist/views/ViewExplore/ViewExplore.js.map +1 -1
  48. package/dist/views/ViewExplore/ViewExploreApp.d.ts +3 -3
  49. package/dist/views/ViewExplore/ViewExploreApp.d.ts.map +1 -1
  50. package/dist/views/ViewExplore/ViewExploreApp.js +7 -22
  51. package/dist/views/ViewExplore/ViewExploreApp.js.map +1 -1
  52. package/package.json +16 -13
  53. package/dist/cjs/components/PanelEditor/PanelEditorForm.js +0 -138
  54. package/dist/cjs/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js +0 -51
  55. package/dist/cjs/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js +0 -96
  56. package/dist/cjs/context/usePanelEditor.js +0 -89
  57. package/dist/cjs/context/useTimeSeriesQueryEditorActions.js +0 -132
  58. package/dist/components/PanelEditor/PanelEditorForm.d.ts +0 -15
  59. package/dist/components/PanelEditor/PanelEditorForm.d.ts.map +0 -1
  60. package/dist/components/PanelEditor/PanelEditorForm.js +0 -125
  61. package/dist/components/PanelEditor/PanelEditorForm.js.map +0 -1
  62. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts +0 -12
  63. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts.map +0 -1
  64. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js +0 -43
  65. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js.map +0 -1
  66. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts +0 -12
  67. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts.map +0 -1
  68. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js +0 -83
  69. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js.map +0 -1
  70. package/dist/components/TimeSeriesQueryEditor/index.d.ts +0 -2
  71. package/dist/components/TimeSeriesQueryEditor/index.d.ts.map +0 -1
  72. package/dist/components/TimeSeriesQueryEditor/index.js.map +0 -1
  73. package/dist/context/usePanelEditor.d.ts +0 -15
  74. package/dist/context/usePanelEditor.d.ts.map +0 -1
  75. package/dist/context/usePanelEditor.js +0 -84
  76. package/dist/context/usePanelEditor.js.map +0 -1
  77. package/dist/context/useTimeSeriesQueryEditorActions.d.ts +0 -14
  78. package/dist/context/useTimeSeriesQueryEditorActions.d.ts.map +0 -1
  79. package/dist/context/useTimeSeriesQueryEditorActions.js +0 -119
  80. package/dist/context/useTimeSeriesQueryEditorActions.js.map +0 -1
@@ -0,0 +1,109 @@
1
+ // Copyright 2024 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, "ExploreManager", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return ExploreManager;
21
+ }
22
+ });
23
+ const _jsxruntime = require("react/jsx-runtime");
24
+ const _material = require("@mui/material");
25
+ const _pluginsystem = require("@perses-dev/plugin-system");
26
+ const _react = require("react");
27
+ const _ExploreToolbar = require("../ExploreToolbar");
28
+ const _ExplorerManagerProvider = require("./ExplorerManagerProvider");
29
+ function ExploreManager(props) {
30
+ const { exploreTitleComponent } = props;
31
+ const { explorer, setExplorer } = (0, _ExplorerManagerProvider.useExplorerManagerContext)();
32
+ const plugins = (0, _pluginsystem.useListPluginMetadata)([
33
+ 'Explore'
34
+ ]);
35
+ const smallScreen = (0, _material.useMediaQuery)('(max-width: 768px)');
36
+ const explorerPluginsMap = (0, _react.useMemo)(()=>Object.fromEntries(plugins.data?.map((plugin)=>[
37
+ `${plugin.module.name}-${plugin.spec.name}`,
38
+ plugin
39
+ ]) ?? []), [
40
+ plugins.data
41
+ ]);
42
+ (0, _react.useEffect)(()=>{
43
+ const plugins = Object.keys(explorerPluginsMap);
44
+ if (!explorer && plugins?.[0]) {
45
+ setExplorer(plugins[0]);
46
+ }
47
+ }, [
48
+ explorerPluginsMap,
49
+ explorer,
50
+ setExplorer
51
+ ]);
52
+ const currentPlugin = explorer ? explorerPluginsMap[explorer] : undefined;
53
+ if (!explorer) {
54
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
55
+ children: "No explorer plugin available"
56
+ });
57
+ }
58
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
59
+ sx: {
60
+ width: '100%'
61
+ },
62
+ px: 2,
63
+ pb: 2,
64
+ pt: 1.5,
65
+ gap: 3,
66
+ children: [
67
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_ExploreToolbar.ExploreToolbar, {
68
+ exploreTitleComponent: exploreTitleComponent
69
+ }),
70
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
71
+ direction: smallScreen ? 'column' : 'row',
72
+ gap: 2,
73
+ sx: {
74
+ width: '100%'
75
+ },
76
+ children: [
77
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Tabs, {
78
+ orientation: smallScreen ? 'horizontal' : 'vertical',
79
+ value: explorer,
80
+ onChange: (_, state)=>setExplorer(state),
81
+ variant: smallScreen ? 'fullWidth' : 'scrollable',
82
+ sx: {
83
+ borderRight: smallScreen ? 0 : 1,
84
+ borderBottom: smallScreen ? 1 : 0,
85
+ borderColor: 'divider',
86
+ minWidth: '100px'
87
+ },
88
+ children: plugins.data?.map((plugin)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Tab, {
89
+ value: `${plugin.module.name}-${plugin.spec.name}`,
90
+ label: plugin.spec.display.name
91
+ }, `${plugin.module.name}-${plugin.spec.name}`))
92
+ }),
93
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Card, {
94
+ sx: {
95
+ padding: '10px',
96
+ width: '100%'
97
+ },
98
+ children: currentPlugin && /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.PluginLoaderComponent, {
99
+ plugin: {
100
+ name: currentPlugin.spec.name,
101
+ moduleName: currentPlugin.module.name
102
+ }
103
+ }, `${currentPlugin.module.name}-${currentPlugin.spec.name}`)
104
+ })
105
+ ]
106
+ })
107
+ ]
108
+ });
109
+ }
@@ -0,0 +1,84 @@
1
+ // Copyright 2024 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
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: all[name]
21
+ });
22
+ }
23
+ _export(exports, {
24
+ ExplorerManagerProvider: function() {
25
+ return ExplorerManagerProvider;
26
+ },
27
+ useExplorerManagerContext: function() {
28
+ return useExplorerManagerContext;
29
+ }
30
+ });
31
+ const _jsxruntime = require("react/jsx-runtime");
32
+ const _react = require("react");
33
+ const ExplorerManagerContext = /*#__PURE__*/ (0, _react.createContext)(undefined);
34
+ function ExplorerManagerProvider({ children, store: externalStore }) {
35
+ // cache the state of currently not rendered explore UIs
36
+ const [explorerStateCache, setExplorerStateCache] = (0, _react.useState)({});
37
+ // local store in case external store is not provided by prop
38
+ const localStore = (0, _react.useState)({
39
+ explorer: undefined,
40
+ data: {}
41
+ });
42
+ // use store provided by 'store' prop if available, otherwise use local store
43
+ const [explorerState, setExplorerState] = externalStore ? externalStore : localStore;
44
+ const { explorer, data } = explorerState;
45
+ function setExplorer(newExplorer) {
46
+ if (explorer) {
47
+ // store current explorer state
48
+ explorerStateCache[explorer] = {
49
+ data
50
+ };
51
+ setExplorerStateCache(explorerStateCache);
52
+ }
53
+ // restore previous explorer state (if any)
54
+ const state = explorerStateCache[newExplorer] ?? {
55
+ data: {}
56
+ };
57
+ setExplorerState({
58
+ explorer: newExplorer,
59
+ data: state.data
60
+ });
61
+ }
62
+ function setData(newData) {
63
+ setExplorerState({
64
+ explorer,
65
+ data: newData
66
+ });
67
+ }
68
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(ExplorerManagerContext.Provider, {
69
+ value: {
70
+ explorer,
71
+ data,
72
+ setExplorer,
73
+ setData
74
+ },
75
+ children: children
76
+ });
77
+ }
78
+ function useExplorerManagerContext() {
79
+ const ctx = (0, _react.useContext)(ExplorerManagerContext);
80
+ if (ctx === undefined) {
81
+ throw new Error('No ExplorerManagerContext found. Did you forget a Provider?');
82
+ }
83
+ return ctx;
84
+ }
@@ -0,0 +1,45 @@
1
+ // Copyright 2024 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, "ExplorerManagerProviderWithQueryParams", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return ExplorerManagerProviderWithQueryParams;
21
+ }
22
+ });
23
+ const _jsxruntime = require("react/jsx-runtime");
24
+ const _react = /*#__PURE__*/ _interop_require_default(require("react"));
25
+ const _usequeryparams = require("use-query-params");
26
+ const _ExplorerManagerProvider = require("./ExplorerManagerProvider");
27
+ function _interop_require_default(obj) {
28
+ return obj && obj.__esModule ? obj : {
29
+ default: obj
30
+ };
31
+ }
32
+ const exploreQueryConfig = {
33
+ explorer: (0, _usequeryparams.withDefault)(_usequeryparams.StringParam, undefined),
34
+ data: (0, _usequeryparams.withDefault)(_usequeryparams.JsonParam, {})
35
+ };
36
+ function ExplorerManagerProviderWithQueryParams({ children }) {
37
+ const [queryParams, setQueryParams] = (0, _usequeryparams.useQueryParams)(exploreQueryConfig);
38
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_ExplorerManagerProvider.ExplorerManagerProvider, {
39
+ store: [
40
+ queryParams,
41
+ setQueryParams
42
+ ],
43
+ children: children
44
+ });
45
+ }
@@ -0,0 +1,32 @@
1
+ // Copyright 2024 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
+ _export_star(require("./ExploreManager"), exports);
18
+ _export_star(require("./ExplorerManagerProvider"), exports);
19
+ _export_star(require("./query-params"), exports);
20
+ function _export_star(from, to) {
21
+ Object.keys(from).forEach(function(k) {
22
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
23
+ Object.defineProperty(to, k, {
24
+ enumerable: true,
25
+ get: function() {
26
+ return from[k];
27
+ }
28
+ });
29
+ }
30
+ });
31
+ return from;
32
+ }
@@ -0,0 +1,49 @@
1
+ // Copyright 2024 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
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: all[name]
21
+ });
22
+ }
23
+ _export(exports, {
24
+ explorerQueryConfig: function() {
25
+ return explorerQueryConfig;
26
+ },
27
+ useExplorerQueryParams: function() {
28
+ return useExplorerQueryParams;
29
+ }
30
+ });
31
+ const _usequeryparams = require("use-query-params");
32
+ const _pluginsystem = require("@perses-dev/plugin-system");
33
+ const _qs = require("qs");
34
+ const explorerQueryConfig = {
35
+ refresh: _pluginsystem.TimeRangeParam,
36
+ start: _pluginsystem.TimeRangeParam,
37
+ end: _pluginsystem.TimeRangeParam,
38
+ explorer: _usequeryparams.StringParam,
39
+ data: _usequeryparams.JsonParam
40
+ };
41
+ function useExplorerQueryParams(inputs) {
42
+ const [query] = (0, _usequeryparams.useQueryParams)(explorerQueryConfig, {
43
+ updateType: 'replaceIn'
44
+ });
45
+ return (0, _qs.stringify)((0, _usequeryparams.encodeQueryParams)(explorerQueryConfig, {
46
+ ...query,
47
+ ...inputs
48
+ }));
49
+ }
@@ -22,9 +22,15 @@ Object.defineProperty(exports, "ExploreToolbar", {
22
22
  });
23
23
  const _jsxruntime = require("react/jsx-runtime");
24
24
  const _material = require("@mui/material");
25
- const _dashboards = require("@perses-dev/dashboards");
25
+ const _pluginsystem = require("@perses-dev/plugin-system");
26
+ const _react = /*#__PURE__*/ _interop_require_default(require("react"));
27
+ function _interop_require_default(obj) {
28
+ return obj && obj.__esModule ? obj : {
29
+ default: obj
30
+ };
31
+ }
26
32
  const ExploreToolbar = (props)=>{
27
- const { exploreTitleComponent } = props;
33
+ const { exploreTitleComponent } = props;
28
34
  const isBiggerThanLg = (0, _material.useMediaQuery)((0, _material.useTheme)().breakpoints.up('lg'));
29
35
  const testId = 'explore-toolbar';
30
36
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
@@ -42,7 +48,7 @@ const ExploreToolbar = (props)=>{
42
48
  ml: "auto",
43
49
  flexWrap: isBiggerThanLg ? 'nowrap' : 'wrap-reverse',
44
50
  justifyContent: "end",
45
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_dashboards.TimeRangeControls, {})
51
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.TimeRangeControls, {})
46
52
  })
47
53
  ]
48
54
  })
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright 2024 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -14,7 +14,8 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
- _export_star(require("./TimeSeriesQueryEditor"), exports);
17
+ _export_star(require("./ExploreManager"), exports);
18
+ _export_star(require("./ExploreToolbar"), exports);
18
19
  function _export_star(from, to) {
19
20
  Object.keys(from).forEach(function(k) {
20
21
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
package/dist/cjs/index.js CHANGED
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
17
  _export_star(require("./views"), exports);
18
+ _export_star(require("./components"), exports);
18
19
  function _export_star(from, to) {
19
20
  Object.keys(from).forEach(function(k) {
20
21
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright 2024 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -26,38 +26,37 @@ const _pluginsystem = require("@perses-dev/plugin-system");
26
26
  const _core = require("@perses-dev/core");
27
27
  const _components = require("@perses-dev/components");
28
28
  const _dashboards = require("@perses-dev/dashboards");
29
+ const _react = /*#__PURE__*/ _interop_require_default(require("react"));
29
30
  const _ViewExploreApp = require("./ViewExploreApp");
31
+ function _interop_require_default(obj) {
32
+ return obj && obj.__esModule ? obj : {
33
+ default: obj
34
+ };
35
+ }
30
36
  function ViewExplore(props) {
31
- const { dashboardResource , datasourceApi , externalVariableDefinitions , sx , exploreTitleComponent , ...others } = props;
37
+ const { datasourceApi, externalVariableDefinitions, sx, exploreTitleComponent, ...others } = props;
32
38
  const initialTimeRange = (0, _pluginsystem.useInitialTimeRange)(_core.DEFAULT_DASHBOARD_DURATION);
33
39
  const initialRefreshInterval = (0, _pluginsystem.useInitialRefreshInterval)(_core.DEFAULT_REFRESH_INTERVAL);
34
40
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(_dashboards.DatasourceStoreProvider, {
35
- dashboardResource: dashboardResource,
36
41
  datasourceApi: datasourceApi,
37
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_dashboards.DashboardProvider, {
38
- initialState: {
39
- dashboardResource,
40
- isEditMode: true
41
- },
42
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.TimeRangeProviderWithQueryParams, {
43
- initialTimeRange: initialTimeRange,
44
- initialRefreshInterval: initialRefreshInterval,
45
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_dashboards.TemplateVariableProvider, {
46
- externalVariableDefinitions: externalVariableDefinitions,
47
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
48
- sx: (0, _components.combineSx)({
49
- display: 'flex',
50
- width: '100%',
51
- height: '100%',
52
- position: 'relative',
53
- overflow: 'hidden'
54
- }, sx),
55
- ...others,
56
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ErrorBoundary, {
57
- FallbackComponent: _components.ErrorAlert,
58
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_ViewExploreApp.ViewExploreApp, {
59
- exploreTitleComponent: exploreTitleComponent
60
- })
42
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.TimeRangeProviderWithQueryParams, {
43
+ initialTimeRange: initialTimeRange,
44
+ initialRefreshInterval: initialRefreshInterval,
45
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_dashboards.VariableProvider, {
46
+ externalVariableDefinitions: externalVariableDefinitions,
47
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
48
+ sx: (0, _components.combineSx)({
49
+ display: 'flex',
50
+ width: '100%',
51
+ height: '100%',
52
+ position: 'relative',
53
+ overflow: 'hidden'
54
+ }, sx),
55
+ ...others,
56
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ErrorBoundary, {
57
+ FallbackComponent: _components.ErrorAlert,
58
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_ViewExploreApp.ViewExploreApp, {
59
+ exploreTitleComponent: exploreTitleComponent
61
60
  })
62
61
  })
63
62
  })
@@ -23,26 +23,11 @@ Object.defineProperty(exports, "ViewExploreApp", {
23
23
  const _jsxruntime = require("react/jsx-runtime");
24
24
  const _material = require("@mui/material");
25
25
  const _components = require("@perses-dev/components");
26
- const _PanelEditorForm = require("../../components/PanelEditor/PanelEditorForm");
26
+ const _components1 = require("../../components");
27
+ const _ExplorerManagerProviderWithQueryParams = require("../../components/ExploreManager/ExplorerManagerProviderWithQueryParams");
27
28
  function ViewExploreApp(props) {
28
- const { exploreTitleComponent } = props;
29
+ const { exploreTitleComponent } = props;
29
30
  const chartsTheme = (0, _components.useChartsTheme)();
30
- const data = {
31
- groupId: 0,
32
- panelDefinition: {
33
- kind: 'Panel',
34
- spec: {
35
- display: {
36
- name: ''
37
- },
38
- plugin: {
39
- kind: 'TimeSeriesChart',
40
- spec: {}
41
- },
42
- queries: []
43
- }
44
- }
45
- };
46
31
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
47
32
  sx: {
48
33
  flexGrow: 1,
@@ -54,10 +39,10 @@ function ViewExploreApp(props) {
54
39
  children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ChartsProvider, {
55
40
  chartsTheme: chartsTheme,
56
41
  enablePinning: false,
57
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_PanelEditorForm.PanelEditorForm, {
58
- initialAction: "update",
59
- initialValues: data,
60
- exploreTitleComponent: exploreTitleComponent
42
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_ExplorerManagerProviderWithQueryParams.ExplorerManagerProviderWithQueryParams, {
43
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components1.ExploreManager, {
44
+ exploreTitleComponent: exploreTitleComponent
45
+ })
61
46
  })
62
47
  })
63
48
  });
@@ -0,0 +1,6 @@
1
+ import { ReactElement, ReactNode } from 'react';
2
+ export interface ExploreManagerProps {
3
+ exploreTitleComponent?: ReactNode;
4
+ }
5
+ export declare function ExploreManager(props: ExploreManagerProps): ReactElement;
6
+ //# sourceMappingURL=ExploreManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExploreManager.d.ts","sourceRoot":"","sources":["../../../src/components/ExploreManager/ExploreManager.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAsB,MAAM,OAAO,CAAC;AAIpE,MAAM,WAAW,mBAAmB;IAClC,qBAAqB,CAAC,EAAE,SAAS,CAAC;CACnC;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,YAAY,CAkEvE"}
@@ -0,0 +1,101 @@
1
+ // Copyright 2024 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
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
+ import { Card, Stack, Tab, Tabs, useMediaQuery } from '@mui/material';
15
+ import { PluginLoaderComponent, useListPluginMetadata } from '@perses-dev/plugin-system';
16
+ import { useEffect, useMemo } from 'react';
17
+ import { ExploreToolbar } from '../ExploreToolbar';
18
+ import { useExplorerManagerContext } from './ExplorerManagerProvider';
19
+ export function ExploreManager(props) {
20
+ const { exploreTitleComponent } = props;
21
+ const { explorer, setExplorer } = useExplorerManagerContext();
22
+ const plugins = useListPluginMetadata([
23
+ 'Explore'
24
+ ]);
25
+ const smallScreen = useMediaQuery('(max-width: 768px)');
26
+ const explorerPluginsMap = useMemo(()=>Object.fromEntries(plugins.data?.map((plugin)=>[
27
+ `${plugin.module.name}-${plugin.spec.name}`,
28
+ plugin
29
+ ]) ?? []), [
30
+ plugins.data
31
+ ]);
32
+ useEffect(()=>{
33
+ const plugins = Object.keys(explorerPluginsMap);
34
+ if (!explorer && plugins?.[0]) {
35
+ setExplorer(plugins[0]);
36
+ }
37
+ }, [
38
+ explorerPluginsMap,
39
+ explorer,
40
+ setExplorer
41
+ ]);
42
+ const currentPlugin = explorer ? explorerPluginsMap[explorer] : undefined;
43
+ if (!explorer) {
44
+ return /*#__PURE__*/ _jsx("div", {
45
+ children: "No explorer plugin available"
46
+ });
47
+ }
48
+ return /*#__PURE__*/ _jsxs(Stack, {
49
+ sx: {
50
+ width: '100%'
51
+ },
52
+ px: 2,
53
+ pb: 2,
54
+ pt: 1.5,
55
+ gap: 3,
56
+ children: [
57
+ /*#__PURE__*/ _jsx(ExploreToolbar, {
58
+ exploreTitleComponent: exploreTitleComponent
59
+ }),
60
+ /*#__PURE__*/ _jsxs(Stack, {
61
+ direction: smallScreen ? 'column' : 'row',
62
+ gap: 2,
63
+ sx: {
64
+ width: '100%'
65
+ },
66
+ children: [
67
+ /*#__PURE__*/ _jsx(Tabs, {
68
+ orientation: smallScreen ? 'horizontal' : 'vertical',
69
+ value: explorer,
70
+ onChange: (_, state)=>setExplorer(state),
71
+ variant: smallScreen ? 'fullWidth' : 'scrollable',
72
+ sx: {
73
+ borderRight: smallScreen ? 0 : 1,
74
+ borderBottom: smallScreen ? 1 : 0,
75
+ borderColor: 'divider',
76
+ minWidth: '100px'
77
+ },
78
+ children: plugins.data?.map((plugin)=>/*#__PURE__*/ _jsx(Tab, {
79
+ value: `${plugin.module.name}-${plugin.spec.name}`,
80
+ label: plugin.spec.display.name
81
+ }, `${plugin.module.name}-${plugin.spec.name}`))
82
+ }),
83
+ /*#__PURE__*/ _jsx(Card, {
84
+ sx: {
85
+ padding: '10px',
86
+ width: '100%'
87
+ },
88
+ children: currentPlugin && /*#__PURE__*/ _jsx(PluginLoaderComponent, {
89
+ plugin: {
90
+ name: currentPlugin.spec.name,
91
+ moduleName: currentPlugin.module.name
92
+ }
93
+ }, `${currentPlugin.module.name}-${currentPlugin.spec.name}`)
94
+ })
95
+ ]
96
+ })
97
+ ]
98
+ });
99
+ }
100
+
101
+ //# sourceMappingURL=ExploreManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/ExploreManager/ExploreManager.tsx"],"sourcesContent":["// Copyright 2024 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 { Card, Stack, Tab, Tabs, useMediaQuery } from '@mui/material';\nimport { PluginLoaderComponent, useListPluginMetadata } from '@perses-dev/plugin-system';\nimport { ReactElement, ReactNode, useEffect, useMemo } from 'react';\nimport { ExploreToolbar } from '../ExploreToolbar';\nimport { useExplorerManagerContext } from './ExplorerManagerProvider';\n\nexport interface ExploreManagerProps {\n exploreTitleComponent?: ReactNode;\n}\n\nexport function ExploreManager(props: ExploreManagerProps): ReactElement {\n const { exploreTitleComponent } = props;\n const { explorer, setExplorer } = useExplorerManagerContext();\n\n const plugins = useListPluginMetadata(['Explore']);\n\n const smallScreen = useMediaQuery('(max-width: 768px)');\n\n const explorerPluginsMap = useMemo(\n () =>\n Object.fromEntries(plugins.data?.map((plugin) => [`${plugin.module.name}-${plugin.spec.name}`, plugin]) ?? []),\n [plugins.data]\n );\n\n useEffect(() => {\n const plugins = Object.keys(explorerPluginsMap);\n if (!explorer && plugins?.[0]) {\n setExplorer(plugins[0]);\n }\n }, [explorerPluginsMap, explorer, setExplorer]);\n\n const currentPlugin = explorer ? explorerPluginsMap[explorer] : undefined;\n\n if (!explorer) {\n return <div>No explorer plugin available</div>;\n }\n\n return (\n <Stack sx={{ width: '100%' }} px={2} pb={2} pt={1.5} gap={3}>\n <ExploreToolbar exploreTitleComponent={exploreTitleComponent} />\n\n <Stack direction={smallScreen ? 'column' : 'row'} gap={2} sx={{ width: '100%' }}>\n <Tabs\n orientation={smallScreen ? 'horizontal' : 'vertical'}\n value={explorer}\n onChange={(_, state) => setExplorer(state)}\n variant={smallScreen ? 'fullWidth' : 'scrollable'}\n sx={{\n borderRight: smallScreen ? 0 : 1,\n borderBottom: smallScreen ? 1 : 0,\n borderColor: 'divider',\n minWidth: '100px',\n }}\n >\n {plugins.data?.map((plugin) => (\n <Tab\n key={`${plugin.module.name}-${plugin.spec.name}`}\n value={`${plugin.module.name}-${plugin.spec.name}`}\n label={plugin.spec.display.name}\n />\n ))}\n </Tabs>\n <Card sx={{ padding: '10px', width: '100%' }}>\n {currentPlugin && (\n <PluginLoaderComponent\n key={`${currentPlugin.module.name}-${currentPlugin.spec.name}`}\n plugin={{\n name: currentPlugin.spec.name,\n moduleName: currentPlugin.module.name,\n }}\n />\n )}\n </Card>\n </Stack>\n </Stack>\n );\n}\n"],"names":["Card","Stack","Tab","Tabs","useMediaQuery","PluginLoaderComponent","useListPluginMetadata","useEffect","useMemo","ExploreToolbar","useExplorerManagerContext","ExploreManager","props","exploreTitleComponent","explorer","setExplorer","plugins","smallScreen","explorerPluginsMap","Object","fromEntries","data","map","plugin","module","name","spec","keys","currentPlugin","undefined","div","sx","width","px","pb","pt","gap","direction","orientation","value","onChange","_","state","variant","borderRight","borderBottom","borderColor","minWidth","label","display","padding","moduleName"],"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,IAAI,EAAEC,KAAK,EAAEC,GAAG,EAAEC,IAAI,EAAEC,aAAa,QAAQ,gBAAgB;AACtE,SAASC,qBAAqB,EAAEC,qBAAqB,QAAQ,4BAA4B;AACzF,SAAkCC,SAAS,EAAEC,OAAO,QAAQ,QAAQ;AACpE,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,yBAAyB,QAAQ,4BAA4B;AAMtE,OAAO,SAASC,eAAeC,KAA0B;IACvD,MAAM,EAAEC,qBAAqB,EAAE,GAAGD;IAClC,MAAM,EAAEE,QAAQ,EAAEC,WAAW,EAAE,GAAGL;IAElC,MAAMM,UAAUV,sBAAsB;QAAC;KAAU;IAEjD,MAAMW,cAAcb,cAAc;IAElC,MAAMc,qBAAqBV,QACzB,IACEW,OAAOC,WAAW,CAACJ,QAAQK,IAAI,EAAEC,IAAI,CAACC,SAAW;gBAAC,CAAC,EAAEA,OAAOC,MAAM,CAACC,IAAI,CAAC,CAAC,EAAEF,OAAOG,IAAI,CAACD,IAAI,CAAC,CAAC;gBAAEF;aAAO,KAAK,EAAE,GAC/G;QAACP,QAAQK,IAAI;KAAC;IAGhBd,UAAU;QACR,MAAMS,UAAUG,OAAOQ,IAAI,CAACT;QAC5B,IAAI,CAACJ,YAAYE,SAAS,CAAC,EAAE,EAAE;YAC7BD,YAAYC,OAAO,CAAC,EAAE;QACxB;IACF,GAAG;QAACE;QAAoBJ;QAAUC;KAAY;IAE9C,MAAMa,gBAAgBd,WAAWI,kBAAkB,CAACJ,SAAS,GAAGe;IAEhE,IAAI,CAACf,UAAU;QACb,qBAAO,KAACgB;sBAAI;;IACd;IAEA,qBACE,MAAC7B;QAAM8B,IAAI;YAAEC,OAAO;QAAO;QAAGC,IAAI;QAAGC,IAAI;QAAGC,IAAI;QAAKC,KAAK;;0BACxD,KAAC3B;gBAAeI,uBAAuBA;;0BAEvC,MAACZ;gBAAMoC,WAAWpB,cAAc,WAAW;gBAAOmB,KAAK;gBAAGL,IAAI;oBAAEC,OAAO;gBAAO;;kCAC5E,KAAC7B;wBACCmC,aAAarB,cAAc,eAAe;wBAC1CsB,OAAOzB;wBACP0B,UAAU,CAACC,GAAGC,QAAU3B,YAAY2B;wBACpCC,SAAS1B,cAAc,cAAc;wBACrCc,IAAI;4BACFa,aAAa3B,cAAc,IAAI;4BAC/B4B,cAAc5B,cAAc,IAAI;4BAChC6B,aAAa;4BACbC,UAAU;wBACZ;kCAEC/B,QAAQK,IAAI,EAAEC,IAAI,CAACC,uBAClB,KAACrB;gCAECqC,OAAO,CAAC,EAAEhB,OAAOC,MAAM,CAACC,IAAI,CAAC,CAAC,EAAEF,OAAOG,IAAI,CAACD,IAAI,CAAC,CAAC;gCAClDuB,OAAOzB,OAAOG,IAAI,CAACuB,OAAO,CAACxB,IAAI;+BAF1B,CAAC,EAAEF,OAAOC,MAAM,CAACC,IAAI,CAAC,CAAC,EAAEF,OAAOG,IAAI,CAACD,IAAI,CAAC,CAAC;;kCAMtD,KAACzB;wBAAK+B,IAAI;4BAAEmB,SAAS;4BAAQlB,OAAO;wBAAO;kCACxCJ,+BACC,KAACvB;4BAECkB,QAAQ;gCACNE,MAAMG,cAAcF,IAAI,CAACD,IAAI;gCAC7B0B,YAAYvB,cAAcJ,MAAM,CAACC,IAAI;4BACvC;2BAJK,CAAC,EAAEG,cAAcJ,MAAM,CAACC,IAAI,CAAC,CAAC,EAAEG,cAAcF,IAAI,CAACD,IAAI,CAAC,CAAC;;;;;;AAW5E"}
@@ -0,0 +1,20 @@
1
+ import { ReactElement, ReactNode } from 'react';
2
+ interface ExplorerState<T> {
3
+ explorer?: string;
4
+ data: T;
5
+ }
6
+ interface ExplorerManagerContextType<T> {
7
+ /** observability signal, for example metrics or traces */
8
+ explorer?: string;
9
+ data: T;
10
+ setExplorer: (explorer: string) => void;
11
+ setData: (data: T) => void;
12
+ }
13
+ interface ExplorerManagerProviderProps {
14
+ children: ReactNode;
15
+ store?: [ExplorerState<unknown>, (state: ExplorerState<unknown>) => void];
16
+ }
17
+ export declare function ExplorerManagerProvider({ children, store: externalStore, }: ExplorerManagerProviderProps): ReactElement;
18
+ export declare function useExplorerManagerContext<T>(): ExplorerManagerContextType<T>;
19
+ export {};
20
+ //# sourceMappingURL=ExplorerManagerProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExplorerManagerProvider.d.ts","sourceRoot":"","sources":["../../../src/components/ExploreManager/ExplorerManagerProvider.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAiB,YAAY,EAAE,SAAS,EAAwB,MAAM,OAAO,CAAC;AAErF,UAAU,aAAa,CAAC,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,CAAC,CAAC;CAGT;AAED,UAAU,0BAA0B,CAAC,CAAC;IACpC,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,CAAC,CAAC;IACR,WAAW,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;CAC5B;AAID,UAAU,4BAA4B;IACpC,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,CAAC,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC,CAAC;CAC3E;AAED,wBAAgB,uBAAuB,CAAC,EACtC,QAAQ,EACR,KAAK,EAAE,aAAa,GACrB,EAAE,4BAA4B,GAAG,YAAY,CAgC7C;AAED,wBAAgB,yBAAyB,CAAC,CAAC,KAAK,0BAA0B,CAAC,CAAC,CAAC,CAM5E"}