@perses-dev/dashboards 0.0.0-snapshot-ts-panel-actions-90e9ef0 → 0.0.0-snapshot-reverse-proxy-75afbd7
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/DashboardStickyToolbar/DashboardStickyToolbar.js +0 -2
- package/dist/cjs/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +5 -20
- package/dist/cjs/components/GridLayout/GridItemContent.js +79 -17
- package/dist/cjs/components/GridLayout/GridLayout.js +78 -126
- package/dist/cjs/components/GridLayout/Row.js +150 -0
- package/dist/cjs/components/GridLayout/index.js +1 -0
- package/dist/cjs/components/LeaveDialog/LeaveDialog.js +81 -0
- package/dist/cjs/components/LeaveDialog/index.js +30 -0
- package/dist/cjs/components/Panel/Panel.js +90 -2
- package/dist/cjs/components/Panel/PanelActions.js +37 -11
- package/dist/cjs/components/Panel/PanelHeader.js +37 -16
- package/dist/cjs/components/Panel/index.js +1 -0
- package/dist/cjs/components/PanelDrawer/PanelDrawer.js +58 -21
- package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +202 -180
- package/dist/cjs/components/PanelDrawer/PanelPreview.js +3 -0
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +9 -21
- package/dist/cjs/components/PanelGroupDialog/PanelGroupEditorForm.js +35 -15
- package/dist/cjs/components/QueryViewerDialog/QueryViewerDialog.js +121 -0
- package/dist/cjs/components/QueryViewerDialog/index.js +30 -0
- package/dist/cjs/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +2 -1
- package/dist/cjs/components/Variables/ListVariableListBox.js +201 -0
- package/dist/cjs/components/Variables/Variable.js +130 -72
- package/dist/cjs/components/Variables/VariableEditor.js +22 -15
- package/dist/cjs/components/Variables/index.js +1 -0
- package/dist/cjs/components/index.js +3 -1
- package/dist/cjs/constants/user-interface-text.js +4 -2
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +7 -8
- package/dist/cjs/context/DashboardProvider/DashboardProviderWithQueryParams.js +4 -4
- package/dist/cjs/context/DashboardProvider/duplicate-panel-slice.js +1 -1
- package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +2 -2
- package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +6 -2
- package/dist/cjs/context/DashboardProvider/panel-group-slice.js +1 -0
- package/dist/cjs/context/DashboardProvider/view-panel-slice.js +10 -3
- package/dist/cjs/context/PanelEditorProvider/PanelEditorProvider.js +49 -0
- package/dist/cjs/context/PanelEditorProvider/index.js +23 -0
- package/dist/cjs/context/VariableProvider/VariableProvider.js +1 -1
- package/dist/cjs/context/index.js +1 -0
- package/dist/cjs/context/useDashboard.js +5 -4
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +7 -3
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +9 -8
- package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.d.ts.map +1 -1
- package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js +0 -2
- package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js.map +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts +2 -2
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -1
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +5 -15
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js.map +1 -1
- package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
- package/dist/components/GridLayout/GridItemContent.js +39 -18
- package/dist/components/GridLayout/GridItemContent.js.map +1 -1
- package/dist/components/GridLayout/GridLayout.d.ts +8 -0
- package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
- package/dist/components/GridLayout/GridLayout.js +72 -126
- package/dist/components/GridLayout/GridLayout.js.map +1 -1
- package/dist/components/GridLayout/Row.d.ts +17 -0
- package/dist/components/GridLayout/Row.d.ts.map +1 -0
- package/dist/components/GridLayout/Row.js +142 -0
- package/dist/components/GridLayout/Row.js.map +1 -0
- package/dist/components/GridLayout/index.d.ts +1 -0
- package/dist/components/GridLayout/index.d.ts.map +1 -1
- package/dist/components/GridLayout/index.js +1 -0
- package/dist/components/GridLayout/index.js.map +1 -1
- package/dist/components/LeaveDialog/LeaveDialog.d.ts +13 -0
- package/dist/components/LeaveDialog/LeaveDialog.d.ts.map +1 -0
- package/dist/components/LeaveDialog/LeaveDialog.js +70 -0
- package/dist/components/LeaveDialog/LeaveDialog.js.map +1 -0
- package/dist/components/LeaveDialog/index.d.ts +2 -0
- package/dist/components/LeaveDialog/index.d.ts.map +1 -0
- package/dist/components/LeaveDialog/index.js +15 -0
- package/dist/components/LeaveDialog/index.js.map +1 -0
- package/dist/components/Panel/HeaderIconButton.d.ts +1 -1
- package/dist/components/Panel/Panel.d.ts +6 -0
- package/dist/components/Panel/Panel.d.ts.map +1 -1
- package/dist/components/Panel/Panel.js +92 -4
- package/dist/components/Panel/Panel.js.map +1 -1
- package/dist/components/Panel/PanelActions.d.ts +7 -1
- package/dist/components/Panel/PanelActions.d.ts.map +1 -1
- package/dist/components/Panel/PanelActions.js +37 -11
- package/dist/components/Panel/PanelActions.js.map +1 -1
- package/dist/components/Panel/PanelHeader.d.ts +8 -1
- package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
- package/dist/components/Panel/PanelHeader.js +38 -17
- package/dist/components/Panel/PanelHeader.js.map +1 -1
- package/dist/components/Panel/index.d.ts +1 -0
- package/dist/components/Panel/index.d.ts.map +1 -1
- package/dist/components/Panel/index.js +1 -0
- package/dist/components/Panel/index.js.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.js +59 -22
- package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.js +205 -183
- package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.js +4 -1
- package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js +8 -15
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts +1 -0
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js +36 -16
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js.map +1 -1
- package/dist/components/QueryViewerDialog/QueryViewerDialog.d.ts +9 -0
- package/dist/components/QueryViewerDialog/QueryViewerDialog.d.ts.map +1 -0
- package/dist/components/QueryViewerDialog/QueryViewerDialog.js +72 -0
- package/dist/components/QueryViewerDialog/QueryViewerDialog.js.map +1 -0
- package/dist/components/QueryViewerDialog/index.d.ts +2 -0
- package/dist/components/QueryViewerDialog/index.d.ts.map +1 -0
- package/dist/components/QueryViewerDialog/index.js +15 -0
- package/dist/components/QueryViewerDialog/index.js.map +1 -0
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.d.ts.map +1 -1
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +2 -1
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +1 -1
- package/dist/components/Variables/ListVariableListBox.d.ts +16 -0
- package/dist/components/Variables/ListVariableListBox.d.ts.map +1 -0
- package/dist/components/Variables/ListVariableListBox.js +141 -0
- package/dist/components/Variables/ListVariableListBox.js.map +1 -0
- package/dist/components/Variables/Variable.d.ts.map +1 -1
- package/dist/components/Variables/Variable.js +134 -76
- package/dist/components/Variables/Variable.js.map +1 -1
- package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditor.js +24 -17
- package/dist/components/Variables/VariableEditor.js.map +1 -1
- package/dist/components/Variables/index.d.ts +1 -0
- package/dist/components/Variables/index.d.ts.map +1 -1
- package/dist/components/Variables/index.js +1 -0
- package/dist/components/Variables/index.js.map +1 -1
- package/dist/components/index.d.ts +3 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +3 -1
- package/dist/components/index.js.map +1 -1
- package/dist/constants/user-interface-text.d.ts +2 -0
- package/dist/constants/user-interface-text.d.ts.map +1 -1
- package/dist/constants/user-interface-text.js +4 -2
- package/dist/constants/user-interface-text.js.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.d.ts +5 -5
- package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.js +7 -8
- package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
- package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.d.ts.map +1 -1
- package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.js +5 -5
- package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.js.map +1 -1
- package/dist/context/DashboardProvider/common.d.ts +1 -1
- package/dist/context/DashboardProvider/common.d.ts.map +1 -1
- package/dist/context/DashboardProvider/common.js.map +1 -1
- package/dist/context/DashboardProvider/duplicate-panel-slice.js +2 -2
- package/dist/context/DashboardProvider/duplicate-panel-slice.js.map +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts +1 -0
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.js +3 -3
- package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
- package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts +1 -0
- package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-group-editor-slice.js +6 -2
- package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -1
- package/dist/context/DashboardProvider/panel-group-slice.d.ts +3 -0
- package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-group-slice.js +1 -0
- package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
- package/dist/context/DashboardProvider/view-panel-slice.d.ts +6 -2
- package/dist/context/DashboardProvider/view-panel-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/view-panel-slice.js +10 -3
- package/dist/context/DashboardProvider/view-panel-slice.js.map +1 -1
- package/dist/context/PanelEditorProvider/PanelEditorProvider.d.ts +13 -0
- package/dist/context/PanelEditorProvider/PanelEditorProvider.d.ts.map +1 -0
- package/dist/context/PanelEditorProvider/PanelEditorProvider.js +33 -0
- package/dist/context/PanelEditorProvider/PanelEditorProvider.js.map +1 -0
- package/dist/context/PanelEditorProvider/index.d.ts +3 -0
- package/dist/context/PanelEditorProvider/index.d.ts.map +1 -0
- package/dist/context/PanelEditorProvider/index.js +16 -0
- package/dist/context/PanelEditorProvider/index.js.map +1 -0
- package/dist/context/VariableProvider/VariableProvider.js +1 -1
- package/dist/context/VariableProvider/VariableProvider.js.map +1 -1
- package/dist/context/index.d.ts +1 -0
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +1 -0
- package/dist/context/index.js.map +1 -1
- package/dist/context/useDashboard.js +5 -4
- package/dist/context/useDashboard.js.map +1 -1
- package/dist/utils/panelUtils.d.ts +3 -0
- package/dist/utils/panelUtils.d.ts.map +1 -1
- package/dist/utils/panelUtils.js +3 -0
- package/dist/utils/panelUtils.js.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.d.ts +7 -6
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.js +8 -4
- package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.js +9 -8
- package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
- package/package.json +8 -8
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Copyright 2025 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("./LeaveDialog"), exports);
|
|
18
|
+
function _export_star(from, to) {
|
|
19
|
+
Object.keys(from).forEach(function(k) {
|
|
20
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
21
|
+
Object.defineProperty(to, k, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function() {
|
|
24
|
+
return from[k];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return from;
|
|
30
|
+
}
|
|
@@ -34,7 +34,7 @@ function _interop_require_default(obj) {
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
const Panel = /*#__PURE__*/ (0, _react.memo)(function Panel(props) {
|
|
37
|
-
const { definition, readHandlers, editHandlers, onMouseEnter, onMouseLeave, sx, panelOptions, panelGroupItemId, ...others } = props;
|
|
37
|
+
const { definition, readHandlers, editHandlers, onMouseEnter, onMouseLeave, sx, panelOptions, panelGroupItemId, viewQueriesHandler, ...others } = props;
|
|
38
38
|
// Make sure we have an ID we can use for aria attributes
|
|
39
39
|
const generatedPanelId = (0, _components.useId)('Panel');
|
|
40
40
|
const headerId = `${generatedPanelId}-header`;
|
|
@@ -54,12 +54,96 @@ const Panel = /*#__PURE__*/ (0, _react.memo)(function Panel(props) {
|
|
|
54
54
|
]);
|
|
55
55
|
const chartsTheme = (0, _components.useChartsTheme)();
|
|
56
56
|
const { queryResults } = (0, _pluginsystem.useDataQueriesContext)();
|
|
57
|
+
const { getPlugin } = (0, _pluginsystem.usePluginRegistry)();
|
|
58
|
+
const panelPropsForActions = (0, _react.useMemo)(()=>{
|
|
59
|
+
return {
|
|
60
|
+
spec: definition.spec.plugin.spec,
|
|
61
|
+
queryResults: queryResults.map((query)=>({
|
|
62
|
+
definition: query.definition,
|
|
63
|
+
data: query.data
|
|
64
|
+
})),
|
|
65
|
+
contentDimensions,
|
|
66
|
+
definition
|
|
67
|
+
};
|
|
68
|
+
}, [
|
|
69
|
+
definition,
|
|
70
|
+
contentDimensions,
|
|
71
|
+
queryResults
|
|
72
|
+
]);
|
|
73
|
+
// Load plugin actions from the plugin
|
|
74
|
+
const [pluginActions, setPluginActions] = (0, _react.useState)([]);
|
|
75
|
+
(0, _react.useEffect)(()=>{
|
|
76
|
+
let cancelled = false;
|
|
77
|
+
const loadPluginActions = async ()=>{
|
|
78
|
+
const panelPluginKind = definition.spec.plugin.kind;
|
|
79
|
+
const panelProps = panelPropsForActions;
|
|
80
|
+
if (!panelPluginKind || !panelProps) {
|
|
81
|
+
if (!cancelled) {
|
|
82
|
+
setPluginActions([]);
|
|
83
|
+
}
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
// Add defensive check for getPlugin availability
|
|
88
|
+
if (!getPlugin || typeof getPlugin !== 'function') {
|
|
89
|
+
if (!cancelled) {
|
|
90
|
+
setPluginActions([]);
|
|
91
|
+
}
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const plugin = await getPlugin('Panel', panelPluginKind);
|
|
95
|
+
if (cancelled) return;
|
|
96
|
+
// More defensive checking for plugin and actions
|
|
97
|
+
if (!plugin || typeof plugin !== 'object' || !plugin.actions || !Array.isArray(plugin.actions) || plugin.actions.length === 0) {
|
|
98
|
+
if (!cancelled) {
|
|
99
|
+
setPluginActions([]);
|
|
100
|
+
}
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
// Render plugin actions in header location
|
|
104
|
+
const headerActions = plugin.actions.filter((action)=>!action.location || action.location === 'header').map((action, index)=>{
|
|
105
|
+
const ActionComponent = action.component;
|
|
106
|
+
try {
|
|
107
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
108
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(ActionComponent, {
|
|
109
|
+
...panelProps
|
|
110
|
+
}, `plugin-action-${index}`);
|
|
111
|
+
} catch (error) {
|
|
112
|
+
console.warn(`Failed to render plugin action ${index}:`, error);
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
}).filter((item)=>Boolean(item));
|
|
116
|
+
if (!cancelled) {
|
|
117
|
+
setPluginActions(headerActions);
|
|
118
|
+
}
|
|
119
|
+
} catch (error) {
|
|
120
|
+
if (!cancelled) {
|
|
121
|
+
console.warn('Failed to load plugin actions:', error);
|
|
122
|
+
setPluginActions([]);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
// Use setTimeout to defer the async operation to the next tick
|
|
127
|
+
const timeoutId = setTimeout(()=>{
|
|
128
|
+
loadPluginActions();
|
|
129
|
+
}, 0);
|
|
130
|
+
return ()=>{
|
|
131
|
+
cancelled = true;
|
|
132
|
+
clearTimeout(timeoutId);
|
|
133
|
+
};
|
|
134
|
+
}, [
|
|
135
|
+
definition.spec.plugin.kind,
|
|
136
|
+
panelPropsForActions,
|
|
137
|
+
getPlugin
|
|
138
|
+
]);
|
|
57
139
|
const handleMouseEnter = (e)=>{
|
|
58
140
|
onMouseEnter?.(e);
|
|
59
141
|
};
|
|
60
142
|
const handleMouseLeave = (e)=>{
|
|
61
143
|
onMouseLeave?.(e);
|
|
62
144
|
};
|
|
145
|
+
// default value for showIcons: if the dashboard is in editing mode or the panel is in fullscreen mode: 'always', otherwise 'hover'
|
|
146
|
+
const showIcons = panelOptions?.showIcons ?? (editHandlers || readHandlers?.isPanelViewed ? 'always' : 'hover');
|
|
63
147
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Card, {
|
|
64
148
|
component: "section",
|
|
65
149
|
sx: (0, _components.combineSx)({
|
|
@@ -90,10 +174,14 @@ const Panel = /*#__PURE__*/ (0, _react.memo)(function Panel(props) {
|
|
|
90
174
|
queryResults: queryResults,
|
|
91
175
|
readHandlers: readHandlers,
|
|
92
176
|
editHandlers: editHandlers,
|
|
177
|
+
viewQueriesHandler: viewQueriesHandler,
|
|
93
178
|
links: definition.spec.links,
|
|
179
|
+
pluginActions: pluginActions,
|
|
180
|
+
showIcons: showIcons,
|
|
94
181
|
sx: {
|
|
95
182
|
paddingX: `${chartsTheme.container.padding.default}px`
|
|
96
|
-
}
|
|
183
|
+
},
|
|
184
|
+
dimension: contentDimensions
|
|
97
185
|
}),
|
|
98
186
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.CardContent, {
|
|
99
187
|
component: "figure",
|
|
@@ -24,6 +24,7 @@ const _jsxruntime = require("react/jsx-runtime");
|
|
|
24
24
|
const _material = require("@mui/material");
|
|
25
25
|
const _react = require("react");
|
|
26
26
|
const _components = require("@perses-dev/components");
|
|
27
|
+
const _DatabaseSearch = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/DatabaseSearch"));
|
|
27
28
|
const _ArrowCollapse = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/ArrowCollapse"));
|
|
28
29
|
const _ArrowExpand = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/ArrowExpand"));
|
|
29
30
|
const _PencilOutline = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/PencilOutline"));
|
|
@@ -47,7 +48,7 @@ const ConditionalBox = (0, _material.styled)(_material.Box)({
|
|
|
47
48
|
flexGrow: 1,
|
|
48
49
|
justifyContent: 'flex-end'
|
|
49
50
|
});
|
|
50
|
-
const PanelActions = ({ editHandlers, readHandlers, extra, title, description, descriptionTooltipId, links, queryResults })=>{
|
|
51
|
+
const PanelActions = ({ editHandlers, readHandlers, viewQueriesHandler, extra, title, description, descriptionTooltipId, links, queryResults, pluginActions = [], showIcons })=>{
|
|
51
52
|
const descriptionAction = (0, _react.useMemo)(()=>{
|
|
52
53
|
if (description && description.trim().length > 0) {
|
|
53
54
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.InfoTooltip, {
|
|
@@ -82,8 +83,6 @@ const PanelActions = ({ editHandlers, readHandlers, extra, title, description, d
|
|
|
82
83
|
const isFetching = queryResults.some((q)=>q.isFetching);
|
|
83
84
|
const queryErrors = queryResults.filter((q)=>q.error);
|
|
84
85
|
if (isFetching && hasData) {
|
|
85
|
-
// If the panel has no data, the panel content will show the loading overlay.
|
|
86
|
-
// Therefore, show the circular loading indicator only in case the panel doesn't display the loading overlay already.
|
|
87
86
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.CircularProgress, {
|
|
88
87
|
"aria-label": "loading",
|
|
89
88
|
size: "1.125rem"
|
|
@@ -126,6 +125,23 @@ const PanelActions = ({ editHandlers, readHandlers, extra, title, description, d
|
|
|
126
125
|
readHandlers,
|
|
127
126
|
title
|
|
128
127
|
]);
|
|
128
|
+
const viewQueryAction = (0, _react.useMemo)(()=>{
|
|
129
|
+
if (!viewQueriesHandler?.onClick) return null;
|
|
130
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.InfoTooltip, {
|
|
131
|
+
description: _constants.TOOLTIP_TEXT.queryView,
|
|
132
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_HeaderIconButton.HeaderIconButton, {
|
|
133
|
+
"aria-label": _constants.ARIA_LABEL_TEXT.openQueryView(title),
|
|
134
|
+
size: "small",
|
|
135
|
+
onClick: viewQueriesHandler.onClick,
|
|
136
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_DatabaseSearch.default, {
|
|
137
|
+
fontSize: "inherit"
|
|
138
|
+
})
|
|
139
|
+
})
|
|
140
|
+
});
|
|
141
|
+
}, [
|
|
142
|
+
viewQueriesHandler,
|
|
143
|
+
title
|
|
144
|
+
]);
|
|
129
145
|
const editActions = (0, _react.useMemo)(()=>{
|
|
130
146
|
if (editHandlers !== undefined) {
|
|
131
147
|
// If there are edit handlers, always just show the edit buttons
|
|
@@ -205,8 +221,8 @@ const PanelActions = ({ editHandlers, readHandlers, extra, title, description, d
|
|
|
205
221
|
flexGrow: 1
|
|
206
222
|
}
|
|
207
223
|
});
|
|
208
|
-
// if the panel is in non-editing, non-fullscreen mode
|
|
209
|
-
const OnHover = ({ children })=>
|
|
224
|
+
// By default, the panel header shows certain icons only on hover if the panel is in non-editing, non-fullscreen mode
|
|
225
|
+
const OnHover = ({ children })=>showIcons === 'hover' ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
210
226
|
sx: {
|
|
211
227
|
display: 'var(--panel-hover, none)'
|
|
212
228
|
},
|
|
@@ -237,8 +253,10 @@ const PanelActions = ({ editHandlers, readHandlers, extra, title, description, d
|
|
|
237
253
|
" ",
|
|
238
254
|
extraActions,
|
|
239
255
|
" ",
|
|
256
|
+
viewQueryAction,
|
|
240
257
|
readActions,
|
|
241
258
|
" ",
|
|
259
|
+
pluginActions,
|
|
242
260
|
editActions
|
|
243
261
|
]
|
|
244
262
|
}),
|
|
@@ -267,11 +285,16 @@ const PanelActions = ({ editHandlers, readHandlers, extra, title, description, d
|
|
|
267
285
|
/*#__PURE__*/ (0, _jsxruntime.jsxs)(OnHover, {
|
|
268
286
|
children: [
|
|
269
287
|
extraActions,
|
|
270
|
-
" ",
|
|
271
288
|
readActions,
|
|
272
|
-
/*#__PURE__*/ (0, _jsxruntime.
|
|
289
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(OverflowMenu, {
|
|
273
290
|
title: title,
|
|
274
|
-
children:
|
|
291
|
+
children: [
|
|
292
|
+
editActions,
|
|
293
|
+
" ",
|
|
294
|
+
viewQueryAction,
|
|
295
|
+
" ",
|
|
296
|
+
pluginActions
|
|
297
|
+
]
|
|
275
298
|
}),
|
|
276
299
|
moveAction
|
|
277
300
|
]
|
|
@@ -300,11 +323,14 @@ const PanelActions = ({ editHandlers, readHandlers, extra, title, description, d
|
|
|
300
323
|
/*#__PURE__*/ (0, _jsxruntime.jsxs)(OnHover, {
|
|
301
324
|
children: [
|
|
302
325
|
extraActions,
|
|
303
|
-
|
|
326
|
+
viewQueryAction,
|
|
304
327
|
readActions,
|
|
305
328
|
" ",
|
|
306
329
|
editActions,
|
|
307
|
-
|
|
330
|
+
pluginActions.length <= 1 ? pluginActions : /*#__PURE__*/ (0, _jsxruntime.jsx)(OverflowMenu, {
|
|
331
|
+
title: title,
|
|
332
|
+
children: pluginActions
|
|
333
|
+
}),
|
|
308
334
|
moveAction
|
|
309
335
|
]
|
|
310
336
|
})
|
|
@@ -318,7 +344,7 @@ const OverflowMenu = ({ children, title })=>{
|
|
|
318
344
|
// do not show overflow menu if there is no content (for example, edit actions are hidden)
|
|
319
345
|
const hasContent = /*#__PURE__*/ (0, _react.isValidElement)(children) || Array.isArray(children) && children.some(_react.isValidElement);
|
|
320
346
|
if (!hasContent) {
|
|
321
|
-
return
|
|
347
|
+
return null;
|
|
322
348
|
}
|
|
323
349
|
const handleClick = (event)=>{
|
|
324
350
|
setAnchorPosition(event.currentTarget.getBoundingClientRect());
|
|
@@ -24,13 +24,24 @@ const _jsxruntime = require("react/jsx-runtime");
|
|
|
24
24
|
const _material = require("@mui/material");
|
|
25
25
|
const _components = require("@perses-dev/components");
|
|
26
26
|
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
27
|
+
const _react = require("react");
|
|
27
28
|
const _constants = require("../../constants");
|
|
28
29
|
const _PanelActions = require("./PanelActions");
|
|
29
|
-
function PanelHeader({ id, title: rawTitle, description: rawDescription, links, queryResults, readHandlers, editHandlers, sx, extra, ...rest }) {
|
|
30
|
+
function PanelHeader({ id, title: rawTitle, description: rawDescription, links, queryResults, readHandlers, editHandlers, sx, extra, pluginActions, showIcons, viewQueriesHandler, dimension, ...rest }) {
|
|
30
31
|
const titleElementId = `${id}-title`;
|
|
31
32
|
const descriptionTooltipId = `${id}-description`;
|
|
32
33
|
const title = (0, _pluginsystem.useReplaceVariablesInString)(rawTitle);
|
|
33
34
|
const description = (0, _pluginsystem.useReplaceVariablesInString)(rawDescription);
|
|
35
|
+
const textRef = (0, _react.useRef)(null);
|
|
36
|
+
const [isEllipsisActive, setIsEllipsisActive] = (0, _react.useState)(false);
|
|
37
|
+
(0, _react.useEffect)(()=>{
|
|
38
|
+
if (textRef.current && dimension?.width) {
|
|
39
|
+
setIsEllipsisActive(textRef.current.scrollWidth > textRef.current.clientWidth);
|
|
40
|
+
}
|
|
41
|
+
}, [
|
|
42
|
+
title,
|
|
43
|
+
dimension?.width
|
|
44
|
+
]);
|
|
34
45
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.CardHeader, {
|
|
35
46
|
id: id,
|
|
36
47
|
component: "header",
|
|
@@ -39,30 +50,40 @@ function PanelHeader({ id, title: rawTitle, description: rawDescription, links,
|
|
|
39
50
|
disableTypography: true,
|
|
40
51
|
title: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
41
52
|
direction: "row",
|
|
53
|
+
alignItems: "center",
|
|
54
|
+
height: "var(--panel-header-height, 30px)",
|
|
42
55
|
children: [
|
|
43
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Tooltip, {
|
|
57
|
+
title: title,
|
|
58
|
+
disableHoverListener: !isEllipsisActive,
|
|
59
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
60
|
+
id: titleElementId,
|
|
61
|
+
variant: "subtitle1",
|
|
62
|
+
ref: textRef,
|
|
63
|
+
sx: {
|
|
64
|
+
// `minHeight` guarantees that the header has the correct height
|
|
65
|
+
// when there is no title (i.e. in the preview)
|
|
66
|
+
lineHeight: '24px',
|
|
67
|
+
minHeight: '26px',
|
|
68
|
+
whiteSpace: 'nowrap',
|
|
69
|
+
overflow: 'hidden',
|
|
70
|
+
textOverflow: 'ellipsis'
|
|
71
|
+
},
|
|
72
|
+
children: title
|
|
73
|
+
})
|
|
56
74
|
}),
|
|
57
75
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_PanelActions.PanelActions, {
|
|
58
76
|
title: title,
|
|
59
77
|
description: description,
|
|
60
78
|
descriptionTooltipId: descriptionTooltipId,
|
|
61
79
|
links: links,
|
|
62
|
-
queryResults: queryResults,
|
|
63
80
|
readHandlers: readHandlers,
|
|
64
81
|
editHandlers: editHandlers,
|
|
65
|
-
|
|
82
|
+
viewQueriesHandler: viewQueriesHandler,
|
|
83
|
+
extra: extra,
|
|
84
|
+
queryResults: queryResults,
|
|
85
|
+
pluginActions: pluginActions,
|
|
86
|
+
showIcons: showIcons
|
|
66
87
|
})
|
|
67
88
|
]
|
|
68
89
|
}),
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
+
_export_star(require("./HeaderIconButton"), exports);
|
|
17
18
|
_export_star(require("./Panel"), exports);
|
|
18
19
|
_export_star(require("./PanelPluginLoader"), exports);
|
|
19
20
|
function _export_star(from, to) {
|
|
@@ -23,6 +23,7 @@ Object.defineProperty(exports, "PanelDrawer", {
|
|
|
23
23
|
const _jsxruntime = require("react/jsx-runtime");
|
|
24
24
|
const _react = require("react");
|
|
25
25
|
const _components = require("@perses-dev/components");
|
|
26
|
+
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
26
27
|
const _context = require("../../context");
|
|
27
28
|
const _PanelEditorForm = require("./PanelEditorForm");
|
|
28
29
|
const PanelDrawer = ()=>{
|
|
@@ -30,42 +31,78 @@ const PanelDrawer = ()=>{
|
|
|
30
31
|
// When the user clicks close, start closing but don't call the store yet to keep values stable during animtation
|
|
31
32
|
const [isClosing, setIsClosing] = (0, _react.useState)(false);
|
|
32
33
|
// Drawer is open if we have a model and we're not transitioning out
|
|
33
|
-
const isOpen = panelEditor !== undefined && isClosing
|
|
34
|
-
|
|
34
|
+
const isOpen = panelEditor !== undefined && !isClosing;
|
|
35
|
+
const handleSave = (0, _react.useCallback)((values)=>{
|
|
35
36
|
// This shouldn't happen since we don't render the submit button until we have a model, but check to make TS happy
|
|
36
37
|
if (panelEditor === undefined || values === undefined) {
|
|
37
38
|
throw new Error('Cannot apply changes');
|
|
38
39
|
}
|
|
39
40
|
panelEditor.applyChanges(values);
|
|
40
41
|
setIsClosing(true);
|
|
41
|
-
}
|
|
42
|
+
}, [
|
|
43
|
+
panelEditor
|
|
44
|
+
]);
|
|
42
45
|
const handleClose = ()=>{
|
|
43
46
|
setIsClosing(true);
|
|
44
47
|
};
|
|
45
48
|
// Don't call closeDrawer on the store until the Drawer has completely transitioned out and reset close state
|
|
46
|
-
const handleExited = ()=>{
|
|
49
|
+
const handleExited = (0, _react.useCallback)(()=>{
|
|
47
50
|
panelEditor?.close();
|
|
48
51
|
setIsClosing(false);
|
|
49
|
-
}
|
|
52
|
+
}, [
|
|
53
|
+
panelEditor
|
|
54
|
+
]);
|
|
50
55
|
// Disables closing on click out. This is a quick-win solution to avoid losing draft changes.
|
|
51
56
|
// -> TODO find a way to enable closing by clicking-out in edit view, with a discard confirmation modal popping up
|
|
52
57
|
const handleClickOut = ()=>{
|
|
53
58
|
/* do nothing */ };
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
59
|
+
const drawer = (0, _react.useMemo)(()=>{
|
|
60
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.Drawer, {
|
|
61
|
+
isOpen: isOpen,
|
|
62
|
+
onClose: handleClickOut,
|
|
63
|
+
SlideProps: {
|
|
64
|
+
onExited: handleExited
|
|
65
|
+
},
|
|
66
|
+
"data-testid": "panel-editor",
|
|
67
|
+
children: panelEditor && /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ErrorBoundary, {
|
|
68
|
+
FallbackComponent: _components.ErrorAlert,
|
|
69
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_PanelEditorForm.PanelEditorForm, {
|
|
70
|
+
initialAction: panelEditor.mode,
|
|
71
|
+
initialValues: panelEditor.initialValues,
|
|
72
|
+
onSave: handleSave,
|
|
73
|
+
onClose: handleClose
|
|
74
|
+
})
|
|
68
75
|
})
|
|
69
|
-
})
|
|
70
|
-
}
|
|
76
|
+
});
|
|
77
|
+
}, [
|
|
78
|
+
handleExited,
|
|
79
|
+
handleSave,
|
|
80
|
+
isOpen,
|
|
81
|
+
panelEditor
|
|
82
|
+
]);
|
|
83
|
+
// If the panel editor is using a repeat variable, we need to wrap the drawer in a VariableContext.Provider
|
|
84
|
+
if (panelEditor?.panelGroupItemId?.repeatVariable) {
|
|
85
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(RepeatVariableWrapper, {
|
|
86
|
+
repeatVariable: panelEditor.panelGroupItemId.repeatVariable,
|
|
87
|
+
children: drawer
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
return drawer;
|
|
71
91
|
};
|
|
92
|
+
// Wraps the drawer in a VariableContext.Provider to provide the repeat variable value
|
|
93
|
+
// This is necessary for previewing panels that use repeat variables and query editor
|
|
94
|
+
function RepeatVariableWrapper({ repeatVariable, children }) {
|
|
95
|
+
const variables = (0, _pluginsystem.useVariableValues)();
|
|
96
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.VariableContext.Provider, {
|
|
97
|
+
value: {
|
|
98
|
+
state: {
|
|
99
|
+
...variables,
|
|
100
|
+
[repeatVariable[0]]: {
|
|
101
|
+
value: repeatVariable[1],
|
|
102
|
+
loading: false
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
children: children
|
|
107
|
+
});
|
|
108
|
+
}
|