@perses-dev/explore 0.50.0 → 0.51.0-beta.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 (98) hide show
  1. package/dist/cjs/components/ExploreManager/ExploreManager.js +39 -18
  2. package/dist/cjs/components/ExploreManager/ExplorerManagerProvider.js +10 -50
  3. package/dist/cjs/components/ExploreManager/ExplorerManagerProviderWithQueryParams.js +1 -4
  4. package/dist/cjs/components/ExploreManager/index.js +2 -0
  5. package/dist/cjs/components/index.js +0 -1
  6. package/dist/components/ExploreManager/ExploreManager.d.ts.map +1 -1
  7. package/dist/components/ExploreManager/ExploreManager.js +39 -18
  8. package/dist/components/ExploreManager/ExploreManager.js.map +1 -1
  9. package/dist/components/ExploreManager/ExplorerManagerProvider.d.ts +2 -2
  10. package/dist/components/ExploreManager/ExplorerManagerProvider.d.ts.map +1 -1
  11. package/dist/components/ExploreManager/ExplorerManagerProvider.js +10 -9
  12. package/dist/components/ExploreManager/ExplorerManagerProvider.js.map +1 -1
  13. package/dist/components/ExploreManager/ExplorerManagerProviderWithQueryParams.js +2 -5
  14. package/dist/components/ExploreManager/ExplorerManagerProviderWithQueryParams.js.map +1 -1
  15. package/dist/components/ExploreManager/index.d.ts +2 -0
  16. package/dist/components/ExploreManager/index.d.ts.map +1 -1
  17. package/dist/components/ExploreManager/index.js +2 -0
  18. package/dist/components/ExploreManager/index.js.map +1 -1
  19. package/dist/components/index.d.ts +0 -1
  20. package/dist/components/index.d.ts.map +1 -1
  21. package/dist/components/index.js +0 -1
  22. package/dist/components/index.js.map +1 -1
  23. package/package.json +8 -10
  24. package/dist/cjs/components/ExploreManager/MetricsExplorer.js +0 -203
  25. package/dist/cjs/components/ExploreManager/TracesExplorer.js +0 -175
  26. package/dist/cjs/components/ExploreManager/constants.js +0 -32
  27. package/dist/cjs/components/PrometheusMetricsFinder/PrometheusMetricsFinder.js +0 -310
  28. package/dist/cjs/components/PrometheusMetricsFinder/display/MetricChip.js +0 -61
  29. package/dist/cjs/components/PrometheusMetricsFinder/display/list/MetricList.js +0 -224
  30. package/dist/cjs/components/PrometheusMetricsFinder/filter/FilterInputs.js +0 -232
  31. package/dist/cjs/components/PrometheusMetricsFinder/filter/FinderFilters.js +0 -139
  32. package/dist/cjs/components/PrometheusMetricsFinder/index.js +0 -30
  33. package/dist/cjs/components/PrometheusMetricsFinder/overview/MetricOverview.js +0 -244
  34. package/dist/cjs/components/PrometheusMetricsFinder/overview/tabs/JobTab.js +0 -146
  35. package/dist/cjs/components/PrometheusMetricsFinder/overview/tabs/OverviewTab.js +0 -413
  36. package/dist/cjs/components/PrometheusMetricsFinder/overview/tabs/SimilarTab.js +0 -54
  37. package/dist/cjs/components/PrometheusMetricsFinder/types.js +0 -25
  38. package/dist/cjs/components/PrometheusMetricsFinder/utils.js +0 -203
  39. package/dist/components/ExploreManager/MetricsExplorer.d.ts +0 -3
  40. package/dist/components/ExploreManager/MetricsExplorer.d.ts.map +0 -1
  41. package/dist/components/ExploreManager/MetricsExplorer.js +0 -190
  42. package/dist/components/ExploreManager/MetricsExplorer.js.map +0 -1
  43. package/dist/components/ExploreManager/TracesExplorer.d.ts +0 -3
  44. package/dist/components/ExploreManager/TracesExplorer.d.ts.map +0 -1
  45. package/dist/components/ExploreManager/TracesExplorer.js +0 -167
  46. package/dist/components/ExploreManager/TracesExplorer.js.map +0 -1
  47. package/dist/components/ExploreManager/constants.d.ts +0 -3
  48. package/dist/components/ExploreManager/constants.d.ts.map +0 -1
  49. package/dist/components/ExploreManager/constants.js +0 -16
  50. package/dist/components/ExploreManager/constants.js.map +0 -1
  51. package/dist/components/PrometheusMetricsFinder/PrometheusMetricsFinder.d.ts +0 -31
  52. package/dist/components/PrometheusMetricsFinder/PrometheusMetricsFinder.d.ts.map +0 -1
  53. package/dist/components/PrometheusMetricsFinder/PrometheusMetricsFinder.js +0 -245
  54. package/dist/components/PrometheusMetricsFinder/PrometheusMetricsFinder.js.map +0 -1
  55. package/dist/components/PrometheusMetricsFinder/display/MetricChip.d.ts +0 -4
  56. package/dist/components/PrometheusMetricsFinder/display/MetricChip.d.ts.map +0 -1
  57. package/dist/components/PrometheusMetricsFinder/display/MetricChip.js +0 -53
  58. package/dist/components/PrometheusMetricsFinder/display/MetricChip.js.map +0 -1
  59. package/dist/components/PrometheusMetricsFinder/display/list/MetricList.d.ts +0 -27
  60. package/dist/components/PrometheusMetricsFinder/display/list/MetricList.d.ts.map +0 -1
  61. package/dist/components/PrometheusMetricsFinder/display/list/MetricList.js +0 -162
  62. package/dist/components/PrometheusMetricsFinder/display/list/MetricList.js.map +0 -1
  63. package/dist/components/PrometheusMetricsFinder/filter/FilterInputs.d.ts +0 -23
  64. package/dist/components/PrometheusMetricsFinder/filter/FilterInputs.d.ts.map +0 -1
  65. package/dist/components/PrometheusMetricsFinder/filter/FilterInputs.js +0 -210
  66. package/dist/components/PrometheusMetricsFinder/filter/FilterInputs.js.map +0 -1
  67. package/dist/components/PrometheusMetricsFinder/filter/FinderFilters.d.ts +0 -13
  68. package/dist/components/PrometheusMetricsFinder/filter/FinderFilters.d.ts.map +0 -1
  69. package/dist/components/PrometheusMetricsFinder/filter/FinderFilters.js +0 -85
  70. package/dist/components/PrometheusMetricsFinder/filter/FinderFilters.js.map +0 -1
  71. package/dist/components/PrometheusMetricsFinder/index.d.ts +0 -2
  72. package/dist/components/PrometheusMetricsFinder/index.d.ts.map +0 -1
  73. package/dist/components/PrometheusMetricsFinder/index.js +0 -15
  74. package/dist/components/PrometheusMetricsFinder/index.js.map +0 -1
  75. package/dist/components/PrometheusMetricsFinder/overview/MetricOverview.d.ts +0 -23
  76. package/dist/components/PrometheusMetricsFinder/overview/MetricOverview.d.ts.map +0 -1
  77. package/dist/components/PrometheusMetricsFinder/overview/MetricOverview.js +0 -223
  78. package/dist/components/PrometheusMetricsFinder/overview/MetricOverview.js.map +0 -1
  79. package/dist/components/PrometheusMetricsFinder/overview/tabs/JobTab.d.ts +0 -28
  80. package/dist/components/PrometheusMetricsFinder/overview/tabs/JobTab.d.ts.map +0 -1
  81. package/dist/components/PrometheusMetricsFinder/overview/tabs/JobTab.js +0 -127
  82. package/dist/components/PrometheusMetricsFinder/overview/tabs/JobTab.js.map +0 -1
  83. package/dist/components/PrometheusMetricsFinder/overview/tabs/OverviewTab.d.ts +0 -25
  84. package/dist/components/PrometheusMetricsFinder/overview/tabs/OverviewTab.d.ts.map +0 -1
  85. package/dist/components/PrometheusMetricsFinder/overview/tabs/OverviewTab.js +0 -389
  86. package/dist/components/PrometheusMetricsFinder/overview/tabs/OverviewTab.js.map +0 -1
  87. package/dist/components/PrometheusMetricsFinder/overview/tabs/SimilarTab.d.ts +0 -12
  88. package/dist/components/PrometheusMetricsFinder/overview/tabs/SimilarTab.d.ts.map +0 -1
  89. package/dist/components/PrometheusMetricsFinder/overview/tabs/SimilarTab.js +0 -46
  90. package/dist/components/PrometheusMetricsFinder/overview/tabs/SimilarTab.js.map +0 -1
  91. package/dist/components/PrometheusMetricsFinder/types.d.ts +0 -22
  92. package/dist/components/PrometheusMetricsFinder/types.d.ts.map +0 -1
  93. package/dist/components/PrometheusMetricsFinder/types.js +0 -17
  94. package/dist/components/PrometheusMetricsFinder/types.js.map +0 -1
  95. package/dist/components/PrometheusMetricsFinder/utils.d.ts +0 -20
  96. package/dist/components/PrometheusMetricsFinder/utils.d.ts.map +0 -1
  97. package/dist/components/PrometheusMetricsFinder/utils.js +0 -185
  98. package/dist/components/PrometheusMetricsFinder/utils.js.map +0 -1
@@ -22,14 +22,39 @@ Object.defineProperty(exports, "ExploreManager", {
22
22
  });
23
23
  const _jsxruntime = require("react/jsx-runtime");
24
24
  const _material = require("@mui/material");
25
+ const _pluginsystem = require("@perses-dev/plugin-system");
26
+ const _react = require("react");
25
27
  const _ExploreToolbar = require("../ExploreToolbar");
26
- const _TracesExplorer = require("./TracesExplorer");
27
- const _MetricsExplorer = require("./MetricsExplorer");
28
28
  const _ExplorerManagerProvider = require("./ExplorerManagerProvider");
29
29
  function ExploreManager(props) {
30
30
  const { exploreTitleComponent } = props;
31
31
  const { explorer, setExplorer } = (0, _ExplorerManagerProvider.useExplorerManagerContext)();
32
+ const plugins = (0, _pluginsystem.useListPluginMetadata)([
33
+ 'Explore'
34
+ ]);
32
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
+ }
33
58
  return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
34
59
  sx: {
35
60
  width: '100%'
@@ -49,7 +74,7 @@ function ExploreManager(props) {
49
74
  width: '100%'
50
75
  },
51
76
  children: [
52
- /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Tabs, {
77
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Tabs, {
53
78
  orientation: smallScreen ? 'horizontal' : 'vertical',
54
79
  value: explorer,
55
80
  onChange: (_, state)=>setExplorer(state),
@@ -60,26 +85,22 @@ function ExploreManager(props) {
60
85
  borderColor: 'divider',
61
86
  minWidth: '100px'
62
87
  },
63
- children: [
64
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Tab, {
65
- value: "metrics",
66
- label: "Metrics"
67
- }),
68
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Tab, {
69
- value: "traces",
70
- label: "Traces"
71
- })
72
- ]
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}`))
73
92
  }),
74
- /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Card, {
93
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Card, {
75
94
  sx: {
76
95
  padding: '10px',
77
96
  width: '100%'
78
97
  },
79
- children: [
80
- explorer === 'metrics' && /*#__PURE__*/ (0, _jsxruntime.jsx)(_MetricsExplorer.MetricsExplorer, {}),
81
- explorer === 'traces' && /*#__PURE__*/ (0, _jsxruntime.jsx)(_TracesExplorer.TracesExplorer, {})
82
- ]
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}`)
83
104
  })
84
105
  ]
85
106
  })
@@ -29,69 +29,29 @@ _export(exports, {
29
29
  }
30
30
  });
31
31
  const _jsxruntime = require("react/jsx-runtime");
32
- const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
33
- function _getRequireWildcardCache(nodeInterop) {
34
- if (typeof WeakMap !== "function") return null;
35
- var cacheBabelInterop = new WeakMap();
36
- var cacheNodeInterop = new WeakMap();
37
- return (_getRequireWildcardCache = function(nodeInterop) {
38
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
39
- })(nodeInterop);
40
- }
41
- function _interop_require_wildcard(obj, nodeInterop) {
42
- if (!nodeInterop && obj && obj.__esModule) {
43
- return obj;
44
- }
45
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
46
- return {
47
- default: obj
48
- };
49
- }
50
- var cache = _getRequireWildcardCache(nodeInterop);
51
- if (cache && cache.has(obj)) {
52
- return cache.get(obj);
53
- }
54
- var newObj = {
55
- __proto__: null
56
- };
57
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
58
- for(var key in obj){
59
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
60
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
61
- if (desc && (desc.get || desc.set)) {
62
- Object.defineProperty(newObj, key, desc);
63
- } else {
64
- newObj[key] = obj[key];
65
- }
66
- }
67
- }
68
- newObj.default = obj;
69
- if (cache) {
70
- cache.set(obj, newObj);
71
- }
72
- return newObj;
73
- }
32
+ const _react = require("react");
74
33
  const ExplorerManagerContext = /*#__PURE__*/ (0, _react.createContext)(undefined);
75
34
  function ExplorerManagerProvider({ children, store: externalStore }) {
76
35
  // cache the state of currently not rendered explore UIs
77
36
  const [explorerStateCache, setExplorerStateCache] = (0, _react.useState)({});
78
37
  // local store in case external store is not provided by prop
79
38
  const localStore = (0, _react.useState)({
80
- explorer: 'metrics',
39
+ explorer: undefined,
81
40
  data: {}
82
41
  });
83
42
  // use store provided by 'store' prop if available, otherwise use local store
84
43
  const [explorerState, setExplorerState] = externalStore ? externalStore : localStore;
85
44
  const { explorer, data } = explorerState;
86
45
  function setExplorer(newExplorer) {
87
- // store current explorer state
88
- explorerStateCache[explorer] = {
89
- data
90
- };
91
- setExplorerStateCache(explorerStateCache);
92
- var _explorerStateCache_newExplorer;
46
+ if (explorer) {
47
+ // store current explorer state
48
+ explorerStateCache[explorer] = {
49
+ data
50
+ };
51
+ setExplorerStateCache(explorerStateCache);
52
+ }
93
53
  // restore previous explorer state (if any)
94
- const state = (_explorerStateCache_newExplorer = explorerStateCache[newExplorer]) !== null && _explorerStateCache_newExplorer !== void 0 ? _explorerStateCache_newExplorer : {
54
+ const state = explorerStateCache[newExplorer] ?? {
95
55
  data: {}
96
56
  };
97
57
  setExplorerState({
@@ -30,10 +30,7 @@ function _interop_require_default(obj) {
30
30
  };
31
31
  }
32
32
  const exploreQueryConfig = {
33
- explorer: (0, _usequeryparams.withDefault)((0, _usequeryparams.createEnumParam)([
34
- 'metrics',
35
- 'traces'
36
- ]), 'metrics'),
33
+ explorer: (0, _usequeryparams.withDefault)(_usequeryparams.StringParam, undefined),
37
34
  data: (0, _usequeryparams.withDefault)(_usequeryparams.JsonParam, {})
38
35
  };
39
36
  function ExplorerManagerProviderWithQueryParams({ children }) {
@@ -15,6 +15,8 @@ Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
17
  _export_star(require("./ExploreManager"), exports);
18
+ _export_star(require("./ExplorerManagerProvider"), exports);
19
+ _export_star(require("./query-params"), exports);
18
20
  function _export_star(from, to) {
19
21
  Object.keys(from).forEach(function(k) {
20
22
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
@@ -16,7 +16,6 @@ Object.defineProperty(exports, "__esModule", {
16
16
  });
17
17
  _export_star(require("./ExploreManager"), exports);
18
18
  _export_star(require("./ExploreToolbar"), exports);
19
- _export_star(require("./PrometheusMetricsFinder"), exports);
20
19
  function _export_star(from, to) {
21
20
  Object.keys(from).forEach(function(k) {
22
21
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
@@ -1 +1 @@
1
- {"version":3,"file":"ExploreManager.d.ts","sourceRoot":"","sources":["../../../src/components/ExploreManager/ExploreManager.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAMhD,MAAM,WAAW,mBAAmB;IAClC,qBAAqB,CAAC,EAAE,SAAS,CAAC;CACnC;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,YAAY,CAgCvE"}
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"}
@@ -12,14 +12,39 @@
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
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';
15
17
  import { ExploreToolbar } from '../ExploreToolbar';
16
- import { TracesExplorer } from './TracesExplorer';
17
- import { MetricsExplorer } from './MetricsExplorer';
18
18
  import { useExplorerManagerContext } from './ExplorerManagerProvider';
19
19
  export function ExploreManager(props) {
20
20
  const { exploreTitleComponent } = props;
21
21
  const { explorer, setExplorer } = useExplorerManagerContext();
22
+ const plugins = useListPluginMetadata([
23
+ 'Explore'
24
+ ]);
22
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
+ }
23
48
  return /*#__PURE__*/ _jsxs(Stack, {
24
49
  sx: {
25
50
  width: '100%'
@@ -39,7 +64,7 @@ export function ExploreManager(props) {
39
64
  width: '100%'
40
65
  },
41
66
  children: [
42
- /*#__PURE__*/ _jsxs(Tabs, {
67
+ /*#__PURE__*/ _jsx(Tabs, {
43
68
  orientation: smallScreen ? 'horizontal' : 'vertical',
44
69
  value: explorer,
45
70
  onChange: (_, state)=>setExplorer(state),
@@ -50,26 +75,22 @@ export function ExploreManager(props) {
50
75
  borderColor: 'divider',
51
76
  minWidth: '100px'
52
77
  },
53
- children: [
54
- /*#__PURE__*/ _jsx(Tab, {
55
- value: "metrics",
56
- label: "Metrics"
57
- }),
58
- /*#__PURE__*/ _jsx(Tab, {
59
- value: "traces",
60
- label: "Traces"
61
- })
62
- ]
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}`))
63
82
  }),
64
- /*#__PURE__*/ _jsxs(Card, {
83
+ /*#__PURE__*/ _jsx(Card, {
65
84
  sx: {
66
85
  padding: '10px',
67
86
  width: '100%'
68
87
  },
69
- children: [
70
- explorer === 'metrics' && /*#__PURE__*/ _jsx(MetricsExplorer, {}),
71
- explorer === 'traces' && /*#__PURE__*/ _jsx(TracesExplorer, {})
72
- ]
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}`)
73
94
  })
74
95
  ]
75
96
  })
@@ -1 +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 { ReactElement, ReactNode } from 'react';\nimport { ExploreToolbar } from '../ExploreToolbar';\nimport { TracesExplorer } from './TracesExplorer';\nimport { MetricsExplorer } from './MetricsExplorer';\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 smallScreen = useMediaQuery('(max-width: 768px)');\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 <Tab value=\"metrics\" label=\"Metrics\" />\n <Tab value=\"traces\" label=\"Traces\" />\n </Tabs>\n <Card sx={{ padding: '10px', width: '100%' }}>\n {explorer === 'metrics' && <MetricsExplorer />}\n {explorer === 'traces' && <TracesExplorer />}\n </Card>\n </Stack>\n </Stack>\n );\n}\n"],"names":["Card","Stack","Tab","Tabs","useMediaQuery","ExploreToolbar","TracesExplorer","MetricsExplorer","useExplorerManagerContext","ExploreManager","props","exploreTitleComponent","explorer","setExplorer","smallScreen","sx","width","px","pb","pt","gap","direction","orientation","value","onChange","_","state","variant","borderRight","borderBottom","borderColor","minWidth","label","padding"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,IAAI,EAAEC,KAAK,EAAEC,GAAG,EAAEC,IAAI,EAAEC,aAAa,QAAQ,gBAAgB;AAEtE,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,cAAc,QAAQ,mBAAmB;AAClD,SAASC,eAAe,QAAQ,oBAAoB;AACpD,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,cAAcV,cAAc;IAClC,qBACE,MAACH;QAAMc,IAAI;YAAEC,OAAO;QAAO;QAAGC,IAAI;QAAGC,IAAI;QAAGC,IAAI;QAAKC,KAAK;;0BACxD,KAACf;gBAAeM,uBAAuBA;;0BAEvC,MAACV;gBAAMoB,WAAWP,cAAc,WAAW;gBAAOM,KAAK;gBAAGL,IAAI;oBAAEC,OAAO;gBAAO;;kCAC5E,MAACb;wBACCmB,aAAaR,cAAc,eAAe;wBAC1CS,OAAOX;wBACPY,UAAU,CAACC,GAAGC,QAAUb,YAAYa;wBACpCC,SAASb,cAAc,cAAc;wBACrCC,IAAI;4BACFa,aAAad,cAAc,IAAI;4BAC/Be,cAAcf,cAAc,IAAI;4BAChCgB,aAAa;4BACbC,UAAU;wBACZ;;0CAEA,KAAC7B;gCAAIqB,OAAM;gCAAUS,OAAM;;0CAC3B,KAAC9B;gCAAIqB,OAAM;gCAASS,OAAM;;;;kCAE5B,MAAChC;wBAAKe,IAAI;4BAAEkB,SAAS;4BAAQjB,OAAO;wBAAO;;4BACxCJ,aAAa,2BAAa,KAACL;4BAC3BK,aAAa,0BAAY,KAACN;;;;;;;AAKrC"}
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"}
@@ -1,11 +1,11 @@
1
1
  import { ReactElement, ReactNode } from 'react';
2
2
  interface ExplorerState<T> {
3
- explorer: string;
3
+ explorer?: string;
4
4
  data: T;
5
5
  }
6
6
  interface ExplorerManagerContextType<T> {
7
7
  /** observability signal, for example metrics or traces */
8
- explorer: string;
8
+ explorer?: string;
9
9
  data: T;
10
10
  setExplorer: (explorer: string) => void;
11
11
  setData: (data: T) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"ExplorerManagerProvider.d.ts","sourceRoot":"","sources":["../../../src/components/ExploreManager/ExplorerManagerProvider.tsx"],"names":[],"mappings":"AAaA,OAAc,EAAiB,YAAY,EAAE,SAAS,EAAwB,MAAM,OAAO,CAAC;AAE5F,UAAU,aAAa,CAAC,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,CAAC,CAAC;CAGT;AAED,UAAU,0BAA0B,CAAC,CAAC;IACpC,0DAA0D;IAC1D,QAAQ,EAAE,MAAM,CAAC;IACjB,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,CA8B7C;AAED,wBAAgB,yBAAyB,CAAC,CAAC,KAAK,0BAA0B,CAAC,CAAC,CAAC,CAM5E"}
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"}
@@ -11,28 +11,29 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
- import React, { createContext, useContext, useState } from 'react';
14
+ import { createContext, useContext, useState } from 'react';
15
15
  const ExplorerManagerContext = /*#__PURE__*/ createContext(undefined);
16
16
  export function ExplorerManagerProvider({ children, store: externalStore }) {
17
17
  // cache the state of currently not rendered explore UIs
18
18
  const [explorerStateCache, setExplorerStateCache] = useState({});
19
19
  // local store in case external store is not provided by prop
20
20
  const localStore = useState({
21
- explorer: 'metrics',
21
+ explorer: undefined,
22
22
  data: {}
23
23
  });
24
24
  // use store provided by 'store' prop if available, otherwise use local store
25
25
  const [explorerState, setExplorerState] = externalStore ? externalStore : localStore;
26
26
  const { explorer, data } = explorerState;
27
27
  function setExplorer(newExplorer) {
28
- // store current explorer state
29
- explorerStateCache[explorer] = {
30
- data
31
- };
32
- setExplorerStateCache(explorerStateCache);
33
- var _explorerStateCache_newExplorer;
28
+ if (explorer) {
29
+ // store current explorer state
30
+ explorerStateCache[explorer] = {
31
+ data
32
+ };
33
+ setExplorerStateCache(explorerStateCache);
34
+ }
34
35
  // restore previous explorer state (if any)
35
- const state = (_explorerStateCache_newExplorer = explorerStateCache[newExplorer]) !== null && _explorerStateCache_newExplorer !== void 0 ? _explorerStateCache_newExplorer : {
36
+ const state = explorerStateCache[newExplorer] ?? {
36
37
  data: {}
37
38
  };
38
39
  setExplorerState({
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/ExploreManager/ExplorerManagerProvider.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 React, { createContext, ReactElement, ReactNode, useContext, useState } from 'react';\n\ninterface ExplorerState<T> {\n explorer: string;\n data: T;\n // tab: number;\n // queries: QueryDefinition[];\n}\n\ninterface ExplorerManagerContextType<T> {\n /** observability signal, for example metrics or traces */\n explorer: string;\n data: T;\n setExplorer: (explorer: string) => void;\n setData: (data: T) => void;\n}\n\nconst ExplorerManagerContext = createContext<ExplorerManagerContextType<unknown> | undefined>(undefined);\n\ninterface ExplorerManagerProviderProps {\n children: ReactNode;\n store?: [ExplorerState<unknown>, (state: ExplorerState<unknown>) => void];\n}\n\nexport function ExplorerManagerProvider({\n children,\n store: externalStore,\n}: ExplorerManagerProviderProps): ReactElement {\n // cache the state of currently not rendered explore UIs\n const [explorerStateCache, setExplorerStateCache] = useState<\n Record<string, Omit<ExplorerState<unknown>, 'explorer'>>\n >({});\n // local store in case external store is not provided by prop\n const localStore = useState<ExplorerState<unknown>>({ explorer: 'metrics', data: {} });\n // use store provided by 'store' prop if available, otherwise use local store\n const [explorerState, setExplorerState] = externalStore ? externalStore : localStore;\n const { explorer, data } = explorerState;\n\n function setExplorer(newExplorer: string): void {\n // store current explorer state\n explorerStateCache[explorer] = { data };\n setExplorerStateCache(explorerStateCache);\n\n // restore previous explorer state (if any)\n const state = explorerStateCache[newExplorer] ?? { data: {} };\n setExplorerState({ explorer: newExplorer, data: state.data });\n }\n\n function setData(newData: unknown): void {\n setExplorerState({ explorer, data: newData });\n }\n\n return (\n <ExplorerManagerContext.Provider value={{ explorer, data, setExplorer, setData }}>\n {children}\n </ExplorerManagerContext.Provider>\n );\n}\n\nexport function useExplorerManagerContext<T>(): ExplorerManagerContextType<T> {\n const ctx = useContext(ExplorerManagerContext);\n if (ctx === undefined) {\n throw new Error('No ExplorerManagerContext found. Did you forget a Provider?');\n }\n return ctx as ExplorerManagerContextType<T>;\n}\n"],"names":["React","createContext","useContext","useState","ExplorerManagerContext","undefined","ExplorerManagerProvider","children","store","externalStore","explorerStateCache","setExplorerStateCache","localStore","explorer","data","explorerState","setExplorerState","setExplorer","newExplorer","state","setData","newData","Provider","value","useExplorerManagerContext","ctx","Error"],"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,OAAOA,SAASC,aAAa,EAA2BC,UAAU,EAAEC,QAAQ,QAAQ,QAAQ;AAiB5F,MAAMC,uCAAyBH,cAA+DI;AAO9F,OAAO,SAASC,wBAAwB,EACtCC,QAAQ,EACRC,OAAOC,aAAa,EACS;IAC7B,wDAAwD;IACxD,MAAM,CAACC,oBAAoBC,sBAAsB,GAAGR,SAElD,CAAC;IACH,6DAA6D;IAC7D,MAAMS,aAAaT,SAAiC;QAAEU,UAAU;QAAWC,MAAM,CAAC;IAAE;IACpF,6EAA6E;IAC7E,MAAM,CAACC,eAAeC,iBAAiB,GAAGP,gBAAgBA,gBAAgBG;IAC1E,MAAM,EAAEC,QAAQ,EAAEC,IAAI,EAAE,GAAGC;IAE3B,SAASE,YAAYC,WAAmB;QACtC,+BAA+B;QAC/BR,kBAAkB,CAACG,SAAS,GAAG;YAAEC;QAAK;QACtCH,sBAAsBD;YAGRA;QADd,2CAA2C;QAC3C,MAAMS,QAAQT,CAAAA,kCAAAA,kBAAkB,CAACQ,YAAY,cAA/BR,6CAAAA,kCAAmC;YAAEI,MAAM,CAAC;QAAE;QAC5DE,iBAAiB;YAAEH,UAAUK;YAAaJ,MAAMK,MAAML,IAAI;QAAC;IAC7D;IAEA,SAASM,QAAQC,OAAgB;QAC/BL,iBAAiB;YAAEH;YAAUC,MAAMO;QAAQ;IAC7C;IAEA,qBACE,KAACjB,uBAAuBkB,QAAQ;QAACC,OAAO;YAAEV;YAAUC;YAAMG;YAAaG;QAAQ;kBAC5Eb;;AAGP;AAEA,OAAO,SAASiB;IACd,MAAMC,MAAMvB,WAAWE;IACvB,IAAIqB,QAAQpB,WAAW;QACrB,MAAM,IAAIqB,MAAM;IAClB;IACA,OAAOD;AACT"}
1
+ {"version":3,"sources":["../../../src/components/ExploreManager/ExplorerManagerProvider.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 { createContext, ReactElement, ReactNode, useContext, useState } from 'react';\n\ninterface ExplorerState<T> {\n explorer?: string;\n data: T;\n // tab: number;\n // queries: QueryDefinition[];\n}\n\ninterface ExplorerManagerContextType<T> {\n /** observability signal, for example metrics or traces */\n explorer?: string;\n data: T;\n setExplorer: (explorer: string) => void;\n setData: (data: T) => void;\n}\n\nconst ExplorerManagerContext = createContext<ExplorerManagerContextType<unknown> | undefined>(undefined);\n\ninterface ExplorerManagerProviderProps {\n children: ReactNode;\n store?: [ExplorerState<unknown>, (state: ExplorerState<unknown>) => void];\n}\n\nexport function ExplorerManagerProvider({\n children,\n store: externalStore,\n}: ExplorerManagerProviderProps): ReactElement {\n // cache the state of currently not rendered explore UIs\n const [explorerStateCache, setExplorerStateCache] = useState<\n Record<string, Omit<ExplorerState<unknown>, 'explorer'>>\n >({});\n // local store in case external store is not provided by prop\n const localStore = useState<ExplorerState<unknown>>({ explorer: undefined, data: {} });\n // use store provided by 'store' prop if available, otherwise use local store\n const [explorerState, setExplorerState] = externalStore ? externalStore : localStore;\n const { explorer, data } = explorerState;\n\n function setExplorer(newExplorer: string): void {\n if (explorer) {\n // store current explorer state\n explorerStateCache[explorer] = { data };\n setExplorerStateCache(explorerStateCache);\n }\n\n // restore previous explorer state (if any)\n const state = explorerStateCache[newExplorer] ?? { data: {} };\n setExplorerState({ explorer: newExplorer, data: state.data });\n }\n\n function setData(newData: unknown): void {\n setExplorerState({ explorer, data: newData });\n }\n\n return (\n <ExplorerManagerContext.Provider value={{ explorer, data, setExplorer, setData }}>\n {children}\n </ExplorerManagerContext.Provider>\n );\n}\n\nexport function useExplorerManagerContext<T>(): ExplorerManagerContextType<T> {\n const ctx = useContext(ExplorerManagerContext);\n if (ctx === undefined) {\n throw new Error('No ExplorerManagerContext found. Did you forget a Provider?');\n }\n return ctx as ExplorerManagerContextType<T>;\n}\n"],"names":["createContext","useContext","useState","ExplorerManagerContext","undefined","ExplorerManagerProvider","children","store","externalStore","explorerStateCache","setExplorerStateCache","localStore","explorer","data","explorerState","setExplorerState","setExplorer","newExplorer","state","setData","newData","Provider","value","useExplorerManagerContext","ctx","Error"],"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,aAAa,EAA2BC,UAAU,EAAEC,QAAQ,QAAQ,QAAQ;AAiBrF,MAAMC,uCAAyBH,cAA+DI;AAO9F,OAAO,SAASC,wBAAwB,EACtCC,QAAQ,EACRC,OAAOC,aAAa,EACS;IAC7B,wDAAwD;IACxD,MAAM,CAACC,oBAAoBC,sBAAsB,GAAGR,SAElD,CAAC;IACH,6DAA6D;IAC7D,MAAMS,aAAaT,SAAiC;QAAEU,UAAUR;QAAWS,MAAM,CAAC;IAAE;IACpF,6EAA6E;IAC7E,MAAM,CAACC,eAAeC,iBAAiB,GAAGP,gBAAgBA,gBAAgBG;IAC1E,MAAM,EAAEC,QAAQ,EAAEC,IAAI,EAAE,GAAGC;IAE3B,SAASE,YAAYC,WAAmB;QACtC,IAAIL,UAAU;YACZ,+BAA+B;YAC/BH,kBAAkB,CAACG,SAAS,GAAG;gBAAEC;YAAK;YACtCH,sBAAsBD;QACxB;QAEA,2CAA2C;QAC3C,MAAMS,QAAQT,kBAAkB,CAACQ,YAAY,IAAI;YAAEJ,MAAM,CAAC;QAAE;QAC5DE,iBAAiB;YAAEH,UAAUK;YAAaJ,MAAMK,MAAML,IAAI;QAAC;IAC7D;IAEA,SAASM,QAAQC,OAAgB;QAC/BL,iBAAiB;YAAEH;YAAUC,MAAMO;QAAQ;IAC7C;IAEA,qBACE,KAACjB,uBAAuBkB,QAAQ;QAACC,OAAO;YAAEV;YAAUC;YAAMG;YAAaG;QAAQ;kBAC5Eb;;AAGP;AAEA,OAAO,SAASiB;IACd,MAAMC,MAAMvB,WAAWE;IACvB,IAAIqB,QAAQpB,WAAW;QACrB,MAAM,IAAIqB,MAAM;IAClB;IACA,OAAOD;AACT"}
@@ -12,13 +12,10 @@
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import React from 'react';
15
- import { createEnumParam, JsonParam, useQueryParams, withDefault } from 'use-query-params';
15
+ import { JsonParam, StringParam, useQueryParams, withDefault } from 'use-query-params';
16
16
  import { ExplorerManagerProvider } from './ExplorerManagerProvider';
17
17
  const exploreQueryConfig = {
18
- explorer: withDefault(createEnumParam([
19
- 'metrics',
20
- 'traces'
21
- ]), 'metrics'),
18
+ explorer: withDefault(StringParam, undefined),
22
19
  data: withDefault(JsonParam, {})
23
20
  };
24
21
  export function ExplorerManagerProviderWithQueryParams({ children }) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/ExploreManager/ExplorerManagerProviderWithQueryParams.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 React, { ReactElement, ReactNode } from 'react';\n\nimport { createEnumParam, JsonParam, useQueryParams, withDefault } from 'use-query-params';\nimport { ExplorerManagerProvider } from './ExplorerManagerProvider';\n\nconst exploreQueryConfig = {\n explorer: withDefault(createEnumParam(['metrics', 'traces']), 'metrics'),\n data: withDefault(JsonParam, {}),\n};\n\ninterface ExplorerManagerProviderWithQueryParamsProps {\n children: ReactNode;\n}\n\nexport function ExplorerManagerProviderWithQueryParams({\n children,\n}: ExplorerManagerProviderWithQueryParamsProps): ReactElement {\n const [queryParams, setQueryParams] = useQueryParams(exploreQueryConfig);\n\n return <ExplorerManagerProvider store={[queryParams, setQueryParams]}>{children}</ExplorerManagerProvider>;\n}\n"],"names":["React","createEnumParam","JsonParam","useQueryParams","withDefault","ExplorerManagerProvider","exploreQueryConfig","explorer","data","ExplorerManagerProviderWithQueryParams","children","queryParams","setQueryParams","store"],"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,OAAOA,WAAwC,QAAQ;AAEvD,SAASC,eAAe,EAAEC,SAAS,EAAEC,cAAc,EAAEC,WAAW,QAAQ,mBAAmB;AAC3F,SAASC,uBAAuB,QAAQ,4BAA4B;AAEpE,MAAMC,qBAAqB;IACzBC,UAAUH,YAAYH,gBAAgB;QAAC;QAAW;KAAS,GAAG;IAC9DO,MAAMJ,YAAYF,WAAW,CAAC;AAChC;AAMA,OAAO,SAASO,uCAAuC,EACrDC,QAAQ,EACoC;IAC5C,MAAM,CAACC,aAAaC,eAAe,GAAGT,eAAeG;IAErD,qBAAO,KAACD;QAAwBQ,OAAO;YAACF;YAAaC;SAAe;kBAAGF;;AACzE"}
1
+ {"version":3,"sources":["../../../src/components/ExploreManager/ExplorerManagerProviderWithQueryParams.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 React, { ReactElement, ReactNode } from 'react';\n\nimport { JsonParam, StringParam, useQueryParams, withDefault } from 'use-query-params';\nimport { ExplorerManagerProvider } from './ExplorerManagerProvider';\n\nconst exploreQueryConfig = {\n explorer: withDefault(StringParam, undefined),\n data: withDefault(JsonParam, {}),\n};\n\ninterface ExplorerManagerProviderWithQueryParamsProps {\n children: ReactNode;\n}\n\nexport function ExplorerManagerProviderWithQueryParams({\n children,\n}: ExplorerManagerProviderWithQueryParamsProps): ReactElement {\n const [queryParams, setQueryParams] = useQueryParams(exploreQueryConfig);\n\n return <ExplorerManagerProvider store={[queryParams, setQueryParams]}>{children}</ExplorerManagerProvider>;\n}\n"],"names":["React","JsonParam","StringParam","useQueryParams","withDefault","ExplorerManagerProvider","exploreQueryConfig","explorer","undefined","data","ExplorerManagerProviderWithQueryParams","children","queryParams","setQueryParams","store"],"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,OAAOA,WAAwC,QAAQ;AAEvD,SAASC,SAAS,EAAEC,WAAW,EAAEC,cAAc,EAAEC,WAAW,QAAQ,mBAAmB;AACvF,SAASC,uBAAuB,QAAQ,4BAA4B;AAEpE,MAAMC,qBAAqB;IACzBC,UAAUH,YAAYF,aAAaM;IACnCC,MAAML,YAAYH,WAAW,CAAC;AAChC;AAMA,OAAO,SAASS,uCAAuC,EACrDC,QAAQ,EACoC;IAC5C,MAAM,CAACC,aAAaC,eAAe,GAAGV,eAAeG;IAErD,qBAAO,KAACD;QAAwBS,OAAO;YAACF;YAAaC;SAAe;kBAAGF;;AACzE"}
@@ -1,2 +1,4 @@
1
1
  export * from './ExploreManager';
2
+ export * from './ExplorerManagerProvider';
3
+ export * from './query-params';
2
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/ExploreManager/index.ts"],"names":[],"mappings":"AAaA,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/ExploreManager/index.ts"],"names":[],"mappings":"AAaA,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC"}
@@ -11,5 +11,7 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  export * from './ExploreManager';
14
+ export * from './ExplorerManagerProvider';
15
+ export * from './query-params';
14
16
 
15
17
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/ExploreManager/index.ts"],"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\nexport * from './ExploreManager';\n"],"names":[],"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,cAAc,mBAAmB"}
1
+ {"version":3,"sources":["../../../src/components/ExploreManager/index.ts"],"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\nexport * from './ExploreManager';\nexport * from './ExplorerManagerProvider';\nexport * from './query-params';\n"],"names":[],"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,cAAc,mBAAmB;AACjC,cAAc,4BAA4B;AAC1C,cAAc,iBAAiB"}
@@ -1,4 +1,3 @@
1
1
  export * from './ExploreManager';
2
2
  export * from './ExploreToolbar';
3
- export * from './PrometheusMetricsFinder';
4
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAaA,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAaA,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC"}
@@ -12,6 +12,5 @@
12
12
  // limitations under the License.
13
13
  export * from './ExploreManager';
14
14
  export * from './ExploreToolbar';
15
- export * from './PrometheusMetricsFinder';
16
15
 
17
16
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/index.ts"],"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\nexport * from './ExploreManager';\nexport * from './ExploreToolbar';\nexport * from './PrometheusMetricsFinder';\n"],"names":[],"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,cAAc,mBAAmB;AACjC,cAAc,mBAAmB;AACjC,cAAc,4BAA4B"}
1
+ {"version":3,"sources":["../../src/components/index.ts"],"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\nexport * from './ExploreManager';\nexport * from './ExploreToolbar';\n"],"names":[],"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,cAAc,mBAAmB;AACjC,cAAc,mBAAmB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/explore",
3
- "version": "0.50.0",
3
+ "version": "0.51.0-beta.0",
4
4
  "description": "The explore feature in Perses",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/perses/perses/blob/main/README.md",
@@ -28,12 +28,10 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@nexucis/fuzzy": "^0.5.1",
31
- "@perses-dev/components": "0.50.0",
32
- "@perses-dev/core": "0.50.0",
33
- "@perses-dev/dashboards": "0.50.0",
34
- "@perses-dev/panels-plugin": "0.50.0",
35
- "@perses-dev/plugin-system": "0.50.0",
36
- "@perses-dev/prometheus-plugin": "0.50.0",
31
+ "@perses-dev/components": "0.51.0-beta.0",
32
+ "@perses-dev/core": "0.51.0-beta.0",
33
+ "@perses-dev/dashboards": "0.51.0-beta.0",
34
+ "@perses-dev/plugin-system": "0.51.0-beta.0",
37
35
  "@types/react-grid-layout": "^1.3.2",
38
36
  "date-fns": "^2.28.0",
39
37
  "immer": "^9.0.15",
@@ -49,15 +47,15 @@
49
47
  "zustand": "^4.3.3"
50
48
  },
51
49
  "devDependencies": {
52
- "@perses-dev/internal-utils": "0.50.0",
53
- "@perses-dev/storybook": "0.50.0",
50
+ "@perses-dev/internal-utils": "0.51.0-beta.0",
51
+ "@perses-dev/storybook": "0.51.0-beta.0",
54
52
  "history": "^5.3.0",
55
53
  "intersection-observer": "^0.12.2",
56
54
  "react-router-dom": "^6.11.0"
57
55
  },
58
56
  "peerDependencies": {
59
57
  "@mui/material": "^6.1.10",
60
- "@tanstack/react-query": "^4.7.1",
58
+ "@tanstack/react-query": "^5.64.2",
61
59
  "react": "^17.0.2 || ^18.0.0",
62
60
  "react-dom": "^17.0.2 || ^18.0.0"
63
61
  },