@perses-dev/explore 0.0.0-snapshot-scatterplot-fix-imports-95e1b59 → 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.
- package/dist/cjs/components/ExploreManager/ExploreManager.js +109 -0
- package/dist/cjs/components/ExploreManager/ExplorerManagerProvider.js +84 -0
- package/dist/cjs/components/ExploreManager/ExplorerManagerProviderWithQueryParams.js +45 -0
- package/dist/cjs/components/ExploreManager/index.js +32 -0
- package/dist/cjs/components/ExploreManager/query-params.js +49 -0
- package/dist/cjs/components/index.js +31 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/views/ViewExplore/ViewExplore.js +2 -2
- package/dist/cjs/views/ViewExplore/ViewExploreApp.js +6 -9
- package/dist/components/ExploreManager/ExploreManager.d.ts +6 -0
- package/dist/components/ExploreManager/ExploreManager.d.ts.map +1 -0
- package/dist/components/ExploreManager/ExploreManager.js +101 -0
- package/dist/components/ExploreManager/ExploreManager.js.map +1 -0
- package/dist/components/ExploreManager/ExplorerManagerProvider.d.ts +20 -0
- package/dist/components/ExploreManager/ExplorerManagerProvider.d.ts.map +1 -0
- package/dist/components/ExploreManager/ExplorerManagerProvider.js +68 -0
- package/dist/components/ExploreManager/ExplorerManagerProvider.js.map +1 -0
- package/dist/components/ExploreManager/ExplorerManagerProviderWithQueryParams.d.ts +7 -0
- package/dist/components/ExploreManager/ExplorerManagerProviderWithQueryParams.d.ts.map +1 -0
- package/dist/components/ExploreManager/ExplorerManagerProviderWithQueryParams.js +32 -0
- package/dist/components/ExploreManager/ExplorerManagerProviderWithQueryParams.js.map +1 -0
- package/dist/components/ExploreManager/index.d.ts +4 -0
- package/dist/components/ExploreManager/index.d.ts.map +1 -0
- package/dist/components/ExploreManager/index.js +17 -0
- package/dist/components/ExploreManager/index.js.map +1 -0
- package/dist/components/ExploreManager/query-params.d.ts +17 -0
- package/dist/components/ExploreManager/query-params.d.ts.map +1 -0
- package/dist/components/ExploreManager/query-params.js +34 -0
- package/dist/components/ExploreManager/query-params.js.map +1 -0
- package/dist/components/ExploreToolbar/ExploreToolbar.d.ts +2 -2
- package/dist/components/ExploreToolbar/ExploreToolbar.d.ts.map +1 -1
- package/dist/components/ExploreToolbar/ExploreToolbar.js.map +1 -1
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +16 -0
- package/dist/components/index.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/views/ViewExplore/ViewExplore.d.ts +4 -4
- package/dist/views/ViewExplore/ViewExplore.d.ts.map +1 -1
- package/dist/views/ViewExplore/ViewExplore.js +3 -3
- package/dist/views/ViewExplore/ViewExplore.js.map +1 -1
- package/dist/views/ViewExplore/ViewExploreApp.d.ts +3 -3
- package/dist/views/ViewExplore/ViewExploreApp.d.ts.map +1 -1
- package/dist/views/ViewExplore/ViewExploreApp.js +6 -4
- package/dist/views/ViewExplore/ViewExploreApp.js.map +1 -1
- package/package.json +16 -12
- package/dist/cjs/components/TimeSeriesExplorer/TimeSeriesExplorer.js +0 -166
- package/dist/components/TimeSeriesExplorer/TimeSeriesExplorer.d.ts +0 -11
- package/dist/components/TimeSeriesExplorer/TimeSeriesExplorer.d.ts.map +0 -1
- package/dist/components/TimeSeriesExplorer/TimeSeriesExplorer.js +0 -109
- package/dist/components/TimeSeriesExplorer/TimeSeriesExplorer.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
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
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("./ExploreToolbar"), exports);
|
|
19
|
+
function _export_star(from, to) {
|
|
20
|
+
Object.keys(from).forEach(function(k) {
|
|
21
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
22
|
+
Object.defineProperty(to, k, {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function() {
|
|
25
|
+
return from[k];
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return from;
|
|
31
|
+
}
|
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
|
|
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
|
|
@@ -42,7 +42,7 @@ function ViewExplore(props) {
|
|
|
42
42
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.TimeRangeProviderWithQueryParams, {
|
|
43
43
|
initialTimeRange: initialTimeRange,
|
|
44
44
|
initialRefreshInterval: initialRefreshInterval,
|
|
45
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_dashboards.
|
|
45
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_dashboards.VariableProvider, {
|
|
46
46
|
externalVariableDefinitions: externalVariableDefinitions,
|
|
47
47
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
48
48
|
sx: (0, _components.combineSx)({
|
|
@@ -23,13 +23,8 @@ 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
|
|
27
|
-
const
|
|
28
|
-
function _interop_require_default(obj) {
|
|
29
|
-
return obj && obj.__esModule ? obj : {
|
|
30
|
-
default: obj
|
|
31
|
-
};
|
|
32
|
-
}
|
|
26
|
+
const _components1 = require("../../components");
|
|
27
|
+
const _ExplorerManagerProviderWithQueryParams = require("../../components/ExploreManager/ExplorerManagerProviderWithQueryParams");
|
|
33
28
|
function ViewExploreApp(props) {
|
|
34
29
|
const { exploreTitleComponent } = props;
|
|
35
30
|
const chartsTheme = (0, _components.useChartsTheme)();
|
|
@@ -44,8 +39,10 @@ function ViewExploreApp(props) {
|
|
|
44
39
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ChartsProvider, {
|
|
45
40
|
chartsTheme: chartsTheme,
|
|
46
41
|
enablePinning: false,
|
|
47
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(
|
|
48
|
-
|
|
42
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_ExplorerManagerProviderWithQueryParams.ExplorerManagerProviderWithQueryParams, {
|
|
43
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components1.ExploreManager, {
|
|
44
|
+
exploreTitleComponent: exploreTitleComponent
|
|
45
|
+
})
|
|
49
46
|
})
|
|
50
47
|
})
|
|
51
48
|
});
|
|
@@ -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"}
|
|
@@ -0,0 +1,68 @@
|
|
|
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 } from "react/jsx-runtime";
|
|
14
|
+
import { createContext, useContext, useState } from 'react';
|
|
15
|
+
const ExplorerManagerContext = /*#__PURE__*/ createContext(undefined);
|
|
16
|
+
export function ExplorerManagerProvider({ children, store: externalStore }) {
|
|
17
|
+
// cache the state of currently not rendered explore UIs
|
|
18
|
+
const [explorerStateCache, setExplorerStateCache] = useState({});
|
|
19
|
+
// local store in case external store is not provided by prop
|
|
20
|
+
const localStore = useState({
|
|
21
|
+
explorer: undefined,
|
|
22
|
+
data: {}
|
|
23
|
+
});
|
|
24
|
+
// use store provided by 'store' prop if available, otherwise use local store
|
|
25
|
+
const [explorerState, setExplorerState] = externalStore ? externalStore : localStore;
|
|
26
|
+
const { explorer, data } = explorerState;
|
|
27
|
+
function setExplorer(newExplorer) {
|
|
28
|
+
if (explorer) {
|
|
29
|
+
// store current explorer state
|
|
30
|
+
explorerStateCache[explorer] = {
|
|
31
|
+
data
|
|
32
|
+
};
|
|
33
|
+
setExplorerStateCache(explorerStateCache);
|
|
34
|
+
}
|
|
35
|
+
// restore previous explorer state (if any)
|
|
36
|
+
const state = explorerStateCache[newExplorer] ?? {
|
|
37
|
+
data: {}
|
|
38
|
+
};
|
|
39
|
+
setExplorerState({
|
|
40
|
+
explorer: newExplorer,
|
|
41
|
+
data: state.data
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function setData(newData) {
|
|
45
|
+
setExplorerState({
|
|
46
|
+
explorer,
|
|
47
|
+
data: newData
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return /*#__PURE__*/ _jsx(ExplorerManagerContext.Provider, {
|
|
51
|
+
value: {
|
|
52
|
+
explorer,
|
|
53
|
+
data,
|
|
54
|
+
setExplorer,
|
|
55
|
+
setData
|
|
56
|
+
},
|
|
57
|
+
children: children
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
export function useExplorerManagerContext() {
|
|
61
|
+
const ctx = useContext(ExplorerManagerContext);
|
|
62
|
+
if (ctx === undefined) {
|
|
63
|
+
throw new Error('No ExplorerManagerContext found. Did you forget a Provider?');
|
|
64
|
+
}
|
|
65
|
+
return ctx;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
//# sourceMappingURL=ExplorerManagerProvider.js.map
|
|
@@ -0,0 +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 { 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"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from 'react';
|
|
2
|
+
interface ExplorerManagerProviderWithQueryParamsProps {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
}
|
|
5
|
+
export declare function ExplorerManagerProviderWithQueryParams({ children, }: ExplorerManagerProviderWithQueryParamsProps): ReactElement;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=ExplorerManagerProviderWithQueryParams.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExplorerManagerProviderWithQueryParams.d.ts","sourceRoot":"","sources":["../../../src/components/ExploreManager/ExplorerManagerProviderWithQueryParams.tsx"],"names":[],"mappings":"AAaA,OAAc,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAUvD,UAAU,2CAA2C;IACnD,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,wBAAgB,sCAAsC,CAAC,EACrD,QAAQ,GACT,EAAE,2CAA2C,GAAG,YAAY,CAI5D"}
|