@perses-dev/dashboards 0.53.0-rc.2 → 0.53.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.
- package/dist/cjs/components/Panel/PanelHeader.js +28 -1
- package/dist/cjs/components/PanelDrawer/PanelDrawer.js +8 -3
- package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +20 -5
- package/dist/cjs/constants/user-interface-text.js +7 -7
- package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +14 -0
- package/dist/components/Panel/PanelActions.d.ts +1 -1
- package/dist/components/Panel/PanelActions.d.ts.map +1 -1
- package/dist/components/Panel/PanelActions.js.map +1 -1
- package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
- package/dist/components/Panel/PanelHeader.js +28 -1
- package/dist/components/Panel/PanelHeader.js.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.js +9 -4
- package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts +1 -0
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.js +20 -5
- package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
- package/dist/constants/user-interface-text.d.ts +7 -7
- package/dist/constants/user-interface-text.d.ts.map +1 -1
- package/dist/constants/user-interface-text.js +7 -7
- package/dist/constants/user-interface-text.js.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +1 -0
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.js +11 -0
- package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
- package/package.json +5 -5
|
@@ -43,7 +43,7 @@ function PanelHeader({ id, title: rawTitle, description: rawDescription, links,
|
|
|
43
43
|
});
|
|
44
44
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
45
45
|
children: [
|
|
46
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.CardHeader, {
|
|
46
|
+
title ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.CardHeader, {
|
|
47
47
|
id: id,
|
|
48
48
|
component: "header",
|
|
49
49
|
"aria-labelledby": titleElementId,
|
|
@@ -99,6 +99,33 @@ function PanelHeader({ id, title: rawTitle, description: rawDescription, links,
|
|
|
99
99
|
}
|
|
100
100
|
}), sx),
|
|
101
101
|
...rest
|
|
102
|
+
}) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
|
|
103
|
+
id: id,
|
|
104
|
+
component: "header",
|
|
105
|
+
"aria-describedby": descriptionTooltipId,
|
|
106
|
+
sx: (0, _components.combineSx)({
|
|
107
|
+
position: 'absolute',
|
|
108
|
+
right: 0,
|
|
109
|
+
top: 0,
|
|
110
|
+
zIndex: 5,
|
|
111
|
+
containerType: 'inline-size',
|
|
112
|
+
containerName: _constants.HEADER_ACTIONS_CONTAINER_NAME
|
|
113
|
+
}, sx),
|
|
114
|
+
...rest,
|
|
115
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_PanelActions.PanelActions, {
|
|
116
|
+
title: title,
|
|
117
|
+
description: description,
|
|
118
|
+
descriptionTooltipId: descriptionTooltipId,
|
|
119
|
+
links: links,
|
|
120
|
+
readHandlers: readHandlers,
|
|
121
|
+
editHandlers: editHandlers,
|
|
122
|
+
viewQueriesHandler: viewQueriesHandler,
|
|
123
|
+
extra: extra,
|
|
124
|
+
queryResults: queryResults,
|
|
125
|
+
pluginActions: pluginActions,
|
|
126
|
+
itemActions: actionButtons,
|
|
127
|
+
showIcons: showIcons
|
|
128
|
+
})
|
|
102
129
|
}),
|
|
103
130
|
confirmDialog
|
|
104
131
|
]
|
|
@@ -40,6 +40,7 @@ const _context = require("../../context");
|
|
|
40
40
|
const _PanelEditorForm = require("./PanelEditorForm");
|
|
41
41
|
const PanelDrawer = ()=>{
|
|
42
42
|
const panelEditor = (0, _context.usePanelEditor)();
|
|
43
|
+
const panelKey = (0, _context.usePanelKey)(panelEditor?.panelGroupItemId);
|
|
43
44
|
// When the user clicks close, start closing but don't call the store yet to keep values stable during animtation
|
|
44
45
|
const [isClosing, setIsClosing] = (0, _react.useState)(false);
|
|
45
46
|
// Drawer is open if we have a model and we're not transitioning out
|
|
@@ -72,13 +73,16 @@ const PanelDrawer = ()=>{
|
|
|
72
73
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.Drawer, {
|
|
73
74
|
isOpen: isOpen,
|
|
74
75
|
onClose: handleClickOut,
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
slotProps: {
|
|
77
|
+
transition: {
|
|
78
|
+
onExited: handleExited
|
|
79
|
+
}
|
|
77
80
|
},
|
|
78
81
|
"data-testid": "panel-editor",
|
|
79
82
|
children: panelEditor && /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ErrorBoundary, {
|
|
80
83
|
FallbackComponent: _components.ErrorAlert,
|
|
81
84
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_PanelEditorForm.PanelEditorForm, {
|
|
85
|
+
panelKey: panelKey,
|
|
82
86
|
initialAction: panelEditor.mode,
|
|
83
87
|
initialValues: panelEditor.initialValues,
|
|
84
88
|
onSave: handleSave,
|
|
@@ -90,7 +94,8 @@ const PanelDrawer = ()=>{
|
|
|
90
94
|
handleExited,
|
|
91
95
|
handleSave,
|
|
92
96
|
isOpen,
|
|
93
|
-
panelEditor
|
|
97
|
+
panelEditor,
|
|
98
|
+
panelKey
|
|
94
99
|
]);
|
|
95
100
|
// If the panel editor is using a repeat variable, we need to wrap the drawer in a VariableContext.Provider
|
|
96
101
|
if (panelEditor?.panelGroupItemId?.repeatVariable) {
|
|
@@ -40,7 +40,7 @@ const _PanelEditorProvider = require("../../context/PanelEditorProvider/PanelEdi
|
|
|
40
40
|
const _usePanelEditor = require("./usePanelEditor");
|
|
41
41
|
const _PanelQueriesSharedControls = require("./PanelQueriesSharedControls");
|
|
42
42
|
function PanelEditorForm(props) {
|
|
43
|
-
const { initialValues, initialAction, onSave, onClose } = props;
|
|
43
|
+
const { initialValues, initialAction, panelKey, onSave, onClose } = props;
|
|
44
44
|
const panelGroups = (0, _context.useListPanelGroups)();
|
|
45
45
|
const { panelDefinition, setName, setDescription, setLinks, setQueries, setPlugin, setPanelDefinition } = (0, _usePanelEditor.usePanelEditor)(initialValues.panelDefinition);
|
|
46
46
|
const { plugin } = panelDefinition.spec;
|
|
@@ -154,11 +154,26 @@ function PanelEditorForm(props) {
|
|
|
154
154
|
borderBottom: (theme)=>`1px solid ${theme.palette.divider}`
|
|
155
155
|
},
|
|
156
156
|
children: [
|
|
157
|
-
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.
|
|
158
|
-
|
|
157
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
158
|
+
direction: "row",
|
|
159
|
+
spacing: 1,
|
|
160
|
+
alignItems: "center",
|
|
159
161
|
children: [
|
|
160
|
-
|
|
161
|
-
|
|
162
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Typography, {
|
|
163
|
+
variant: "h2",
|
|
164
|
+
children: [
|
|
165
|
+
titleAction,
|
|
166
|
+
" Panel"
|
|
167
|
+
]
|
|
168
|
+
}),
|
|
169
|
+
panelKey && /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Typography, {
|
|
170
|
+
variant: "subtitle1",
|
|
171
|
+
children: [
|
|
172
|
+
"(ID: ",
|
|
173
|
+
panelKey,
|
|
174
|
+
")"
|
|
175
|
+
]
|
|
176
|
+
})
|
|
162
177
|
]
|
|
163
178
|
}),
|
|
164
179
|
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
@@ -61,11 +61,11 @@ const ARIA_LABEL_TEXT = {
|
|
|
61
61
|
moveGroupDown: (groupName)=>`move group ${groupName} down`,
|
|
62
62
|
moveGroupUp: (groupName)=>`move group ${groupName} up`,
|
|
63
63
|
// Panel buttons
|
|
64
|
-
viewPanel: (panelName)
|
|
65
|
-
editPanel: (panelName)
|
|
66
|
-
duplicatePanel: (panelName)
|
|
67
|
-
deletePanel: (panelName)
|
|
68
|
-
showPanelActions: (panelName)
|
|
69
|
-
movePanel: (panelName)
|
|
70
|
-
openQueryView: (panelName)
|
|
64
|
+
viewPanel: (panelName)=>panelName ? `toggle panel ${panelName} view mode` : 'toggle panel view mode',
|
|
65
|
+
editPanel: (panelName)=>panelName ? `edit panel ${panelName}` : 'edit panel',
|
|
66
|
+
duplicatePanel: (panelName)=>panelName ? `duplicate panel ${panelName}` : 'duplicate panel',
|
|
67
|
+
deletePanel: (panelName)=>panelName ? `delete panel ${panelName}` : 'delete panel',
|
|
68
|
+
showPanelActions: (panelName)=>panelName ? `show panel actions for ${panelName}` : 'show panel actions',
|
|
69
|
+
movePanel: (panelName)=>panelName ? `move panel ${panelName}` : 'move panel',
|
|
70
|
+
openQueryView: (panelName)=>panelName ? `open query view for panel ${panelName}` : 'open query view for panel'
|
|
71
71
|
};
|
|
@@ -66,6 +66,9 @@ _export(exports, {
|
|
|
66
66
|
get usePanelGroupIds () {
|
|
67
67
|
return usePanelGroupIds;
|
|
68
68
|
},
|
|
69
|
+
get usePanelKey () {
|
|
70
|
+
return usePanelKey;
|
|
71
|
+
},
|
|
69
72
|
get useSaveChangesConfirmationDialog () {
|
|
70
73
|
return useSaveChangesConfirmationDialog;
|
|
71
74
|
},
|
|
@@ -186,6 +189,17 @@ function useDeletePanelGroupDialog() {
|
|
|
186
189
|
closeDeletePanelGroupDialog: ()=>closeDeletePanelGroupDialog()
|
|
187
190
|
};
|
|
188
191
|
}
|
|
192
|
+
function usePanelKey(panelGroupItemId) {
|
|
193
|
+
const panelKey = (0, _DashboardProvider.useDashboardStore)((0, _react.useCallback)((store)=>{
|
|
194
|
+
if (panelGroupItemId === undefined) {
|
|
195
|
+
return undefined;
|
|
196
|
+
}
|
|
197
|
+
return store.panelGroups[panelGroupItemId.panelGroupId]?.itemPanelKeys[panelGroupItemId.panelGroupItemLayoutId];
|
|
198
|
+
}, [
|
|
199
|
+
panelGroupItemId
|
|
200
|
+
]));
|
|
201
|
+
return panelKey;
|
|
202
|
+
}
|
|
189
203
|
function usePanel(panelGroupItemId) {
|
|
190
204
|
const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;
|
|
191
205
|
const panel = (0, _DashboardProvider.useDashboardStore)((0, _react.useCallback)((store)=>{
|
|
@@ -3,7 +3,7 @@ import { QueryData } from '@perses-dev/plugin-system';
|
|
|
3
3
|
import { Link } from '@perses-dev/core';
|
|
4
4
|
import { PanelOptions } from './Panel';
|
|
5
5
|
export interface PanelActionsProps {
|
|
6
|
-
title
|
|
6
|
+
title?: string;
|
|
7
7
|
description?: string;
|
|
8
8
|
descriptionTooltipId: string;
|
|
9
9
|
links?: Link[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PanelActions.d.ts","sourceRoot":"","sources":["../../../src/components/Panel/PanelActions.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAmD,SAAS,EAAqB,MAAM,OAAO,CAAC;AAEtG,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAatD,OAAO,EAAE,IAAI,EAAU,MAAM,kBAAkB,CAAC;AAUhD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAQvC,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"PanelActions.d.ts","sourceRoot":"","sources":["../../../src/components/Panel/PanelActions.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAmD,SAAS,EAAqB,MAAM,OAAO,CAAC;AAEtG,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAatD,OAAO,EAAE,IAAI,EAAU,MAAM,kBAAkB,CAAC;AAUhD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAQvC,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IACf,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,YAAY,CAAC,EAAE;QACb,gBAAgB,EAAE,MAAM,IAAI,CAAC;QAC7B,qBAAqB,EAAE,MAAM,IAAI,CAAC;QAClC,kBAAkB,EAAE,MAAM,IAAI,CAAC;KAChC,CAAC;IACF,YAAY,CAAC,EAAE;QACb,aAAa,CAAC,EAAE,OAAO,CAAC;QACxB,gBAAgB,EAAE,MAAM,IAAI,CAAC;KAC9B,CAAC;IACF,kBAAkB,CAAC,EAAE;QACnB,OAAO,EAAE,MAAM,IAAI,CAAC;KACrB,CAAC;IACF,YAAY,EAAE,SAAS,EAAE,CAAC;IAC1B,aAAa,CAAC,EAAE,SAAS,EAAE,CAAC;IAC5B,WAAW,CAAC,EAAE,SAAS,EAAE,CAAC;IAC1B,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,SAAS,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC;CACtC;AASD,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAgQpD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Panel/PanelActions.tsx"],"sourcesContent":["// Copyright 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 { Stack, Box, Popover, CircularProgress, styled, PopoverPosition } from '@mui/material';\nimport { isValidElement, PropsWithChildren, ReactElement, ReactNode, useMemo, useState } from 'react';\nimport { InfoTooltip } from '@perses-dev/components';\nimport { QueryData } from '@perses-dev/plugin-system';\nimport DatabaseSearch from 'mdi-material-ui/DatabaseSearch';\nimport ArrowCollapseIcon from 'mdi-material-ui/ArrowCollapse';\nimport ArrowExpandIcon from 'mdi-material-ui/ArrowExpand';\nimport PencilIcon from 'mdi-material-ui/PencilOutline';\nimport DeleteIcon from 'mdi-material-ui/DeleteOutline';\nimport DragIcon from 'mdi-material-ui/DragVertical';\nimport ContentCopyIcon from 'mdi-material-ui/ContentCopy';\nimport MenuIcon from 'mdi-material-ui/Menu';\nimport AlertIcon from 'mdi-material-ui/Alert';\nimport AlertCircleIcon from 'mdi-material-ui/AlertCircle';\nimport InformationOutlineIcon from 'mdi-material-ui/InformationOutline';\nimport LightningBoltIcon from 'mdi-material-ui/LightningBolt';\nimport { Link, Notice } from '@perses-dev/core';\nimport {\n ARIA_LABEL_TEXT,\n HEADER_ACTIONS_CONTAINER_NAME,\n HEADER_MEDIUM_WIDTH,\n HEADER_SMALL_WIDTH,\n TOOLTIP_TEXT,\n} from '../../constants';\nimport { HeaderIconButton } from './HeaderIconButton';\nimport { PanelLinks } from './PanelLinks';\nimport { PanelOptions } from './Panel';\n\nconst noticeTypeToIcon: Record<Notice['type'], ReactNode> = {\n error: <AlertCircleIcon color=\"error\" />,\n warning: <AlertIcon fontSize=\"inherit\" color=\"warning\" />,\n info: <InformationOutlineIcon fontSize=\"inherit\" color=\"info\" />,\n};\n\nexport interface PanelActionsProps {\n title: string;\n description?: string;\n descriptionTooltipId: string;\n links?: Link[];\n extra?: React.ReactNode;\n editHandlers?: {\n onEditPanelClick: () => void;\n onDuplicatePanelClick: () => void;\n onDeletePanelClick: () => void;\n };\n readHandlers?: {\n isPanelViewed?: boolean;\n onViewPanelClick: () => void;\n };\n viewQueriesHandler?: {\n onClick: () => void;\n };\n queryResults: QueryData[];\n pluginActions?: ReactNode[];\n itemActions?: ReactNode[];\n areItemActionsDisabled?: boolean;\n showIcons: PanelOptions['showIcons'];\n}\n\nconst ConditionalBox = styled(Box)({\n display: 'none',\n alignItems: 'center',\n flexGrow: 1,\n justifyContent: 'flex-end',\n});\n\nexport const PanelActions: React.FC<PanelActionsProps> = ({\n editHandlers,\n readHandlers,\n viewQueriesHandler,\n extra,\n title,\n description,\n descriptionTooltipId,\n links,\n queryResults,\n pluginActions = [],\n itemActions = [],\n showIcons,\n}) => {\n const descriptionAction = useMemo((): ReactNode | undefined => {\n if (description && description.trim().length > 0) {\n return (\n <InfoTooltip id={descriptionTooltipId} description={description} enterDelay={100}>\n <HeaderIconButton aria-label=\"panel description\" size=\"small\">\n <InformationOutlineIcon\n aria-describedby=\"info-tooltip\"\n aria-hidden={false}\n fontSize=\"inherit\"\n sx={{ color: (theme) => theme.palette.text.secondary }}\n />\n </HeaderIconButton>\n </InfoTooltip>\n );\n }\n return undefined;\n }, [descriptionTooltipId, description]);\n\n const linksAction = links && links.length > 0 && <PanelLinks links={links} />;\n const extraActions = editHandlers === undefined && extra;\n\n const queryStateIndicator = useMemo((): ReactNode | undefined => {\n const hasData = queryResults.some((q) => q.data);\n const isFetching = queryResults.some((q) => q.isFetching);\n const queryErrors = queryResults.filter((q) => q.error);\n\n if (isFetching && hasData) {\n return <CircularProgress aria-label=\"loading\" size=\"1.125rem\" />;\n } else if (queryErrors.length > 0) {\n const errorTexts = queryErrors\n .map((q) => q.error)\n .map((e) => e.message)\n .join('\\n');\n\n return (\n <InfoTooltip description={errorTexts}>\n <HeaderIconButton aria-label=\"panel errors\" size=\"small\">\n <AlertIcon\n fontSize=\"inherit\"\n sx={{\n color: (theme) => theme.palette.error.main,\n }}\n />\n </HeaderIconButton>\n </InfoTooltip>\n );\n }\n }, [queryResults]);\n\n const noticesIndicator = useMemo(() => {\n const notices = queryResults.flatMap((q) => {\n return q.data?.metadata?.notices ?? [];\n });\n\n if (notices.length > 0) {\n const lastNotice = notices[notices.length - 1]!;\n\n return (\n <InfoTooltip description={lastNotice.message}>\n <HeaderIconButton aria-label=\"panel notices\" size=\"small\">\n {noticeTypeToIcon[lastNotice.type]}\n </HeaderIconButton>\n </InfoTooltip>\n );\n }\n }, [queryResults]);\n\n const readActions = useMemo((): ReactNode | undefined => {\n if (readHandlers !== undefined) {\n return (\n <InfoTooltip description={TOOLTIP_TEXT.viewPanel}>\n <HeaderIconButton\n aria-label={ARIA_LABEL_TEXT.viewPanel(title)}\n size=\"small\"\n onClick={readHandlers.onViewPanelClick}\n >\n {readHandlers.isPanelViewed ? (\n <ArrowCollapseIcon fontSize=\"inherit\" />\n ) : (\n <ArrowExpandIcon fontSize=\"inherit\" />\n )}\n </HeaderIconButton>\n </InfoTooltip>\n );\n }\n return undefined;\n }, [readHandlers, title]);\n\n const viewQueryAction = useMemo(() => {\n if (!viewQueriesHandler?.onClick) return null;\n return (\n <InfoTooltip description={TOOLTIP_TEXT.queryView}>\n <HeaderIconButton\n aria-label={ARIA_LABEL_TEXT.openQueryView(title)}\n size=\"small\"\n onClick={viewQueriesHandler.onClick}\n >\n <DatabaseSearch fontSize=\"inherit\" />\n </HeaderIconButton>\n </InfoTooltip>\n );\n }, [viewQueriesHandler, title]);\n\n const editActions = useMemo((): ReactNode | undefined => {\n if (editHandlers !== undefined) {\n // If there are edit handlers, always just show the edit buttons\n return (\n <>\n <InfoTooltip description={TOOLTIP_TEXT.editPanel}>\n <HeaderIconButton\n aria-label={ARIA_LABEL_TEXT.editPanel(title)}\n size=\"small\"\n onClick={editHandlers.onEditPanelClick}\n >\n <PencilIcon fontSize=\"inherit\" />\n </HeaderIconButton>\n </InfoTooltip>\n <InfoTooltip description={TOOLTIP_TEXT.duplicatePanel}>\n <HeaderIconButton\n aria-label={ARIA_LABEL_TEXT.duplicatePanel(title)}\n size=\"small\"\n onClick={editHandlers.onDuplicatePanelClick}\n >\n <ContentCopyIcon\n fontSize=\"inherit\"\n sx={{\n // Shrink this icon a little bit to look more consistent\n // with the other icons in the header.\n transform: 'scale(0.925)',\n }}\n />\n </HeaderIconButton>\n </InfoTooltip>\n <InfoTooltip description={TOOLTIP_TEXT.deletePanel}>\n <HeaderIconButton\n aria-label={ARIA_LABEL_TEXT.deletePanel(title)}\n size=\"small\"\n onClick={editHandlers.onDeletePanelClick}\n >\n <DeleteIcon fontSize=\"inherit\" />\n </HeaderIconButton>\n </InfoTooltip>\n </>\n );\n }\n return undefined;\n }, [editHandlers, title]);\n\n const moveAction = useMemo((): ReactNode | undefined => {\n if (editActions && !readHandlers?.isPanelViewed) {\n return (\n <InfoTooltip description={TOOLTIP_TEXT.movePanel}>\n <HeaderIconButton aria-label={ARIA_LABEL_TEXT.movePanel(title)} size=\"small\">\n <DragIcon className=\"drag-handle\" sx={{ cursor: 'grab' }} fontSize=\"inherit\" />\n </HeaderIconButton>\n </InfoTooltip>\n );\n }\n return undefined;\n }, [editActions, readHandlers, title]);\n\n const divider = <Box sx={{ flexGrow: 1 }}></Box>;\n\n // By default, the panel header shows certain icons only on hover if the panel is in non-editing, non-fullscreen mode\n const OnHover = ({ children }: PropsWithChildren): ReactNode =>\n showIcons === 'hover' ? <Box sx={{ display: 'var(--panel-hover, none)' }}>{children}</Box> : <>{children}</>;\n\n return (\n <>\n {/* small panel width: move all icons except move/grab to overflow menu */}\n <ConditionalBox\n sx={(theme) => ({\n [theme.containerQueries(HEADER_ACTIONS_CONTAINER_NAME).between(0, HEADER_SMALL_WIDTH)]: { display: 'flex' },\n })}\n >\n {divider}\n <OnHover>\n <OverflowMenu title={title}>\n {descriptionAction} {linksAction} {queryStateIndicator} {noticesIndicator} {extraActions} {viewQueryAction}\n {readActions} {pluginActions} {itemActions}\n {editActions}\n </OverflowMenu>\n {moveAction}\n </OnHover>\n </ConditionalBox>\n\n {/* medium panel width: move edit icons to overflow menu */}\n <ConditionalBox\n sx={(theme) => ({\n [theme.containerQueries(HEADER_ACTIONS_CONTAINER_NAME).between(HEADER_SMALL_WIDTH, HEADER_MEDIUM_WIDTH)]: {\n display: 'flex',\n },\n })}\n >\n <OnHover>\n {descriptionAction} {linksAction}\n </OnHover>\n {divider} {queryStateIndicator}\n {noticesIndicator}\n <OnHover>\n {extraActions}\n {readActions}\n <OverflowMenu title={title}>\n {editActions} {viewQueryAction} {pluginActions} {itemActions}\n </OverflowMenu>\n {moveAction}\n </OnHover>\n </ConditionalBox>\n\n {/* large panel width: show all icons in panel header */}\n <ConditionalBox\n sx={(theme) => ({\n // flip the logic here; if the browser (or jsdom) does not support container queries, always show all icons\n display: 'flex',\n [theme.containerQueries(HEADER_ACTIONS_CONTAINER_NAME).down(HEADER_MEDIUM_WIDTH)]: { display: 'none' },\n })}\n >\n <OnHover>\n {descriptionAction} {linksAction}\n </OnHover>\n {divider} {queryStateIndicator}\n {noticesIndicator}\n <OnHover>\n {extraActions}\n {viewQueryAction}\n {readActions} {editActions}\n {/* Show plugin actions inside a menu if it gets crowded */}\n {pluginActions.length <= 1 ? pluginActions : <OverflowMenu title={title}>{pluginActions}</OverflowMenu>}\n {itemActions.length <= 1 ? (\n itemActions\n ) : (\n <InfoTooltip description={`${itemActions.length} actions`}>\n <OverflowMenu icon={<LightningBoltIcon fontSize=\"inherit\" />} direction=\"column\" title={title}>\n {itemActions}\n </OverflowMenu>\n </InfoTooltip>\n )}\n {moveAction}\n </OnHover>\n </ConditionalBox>\n </>\n );\n};\n\nconst OverflowMenu: React.FC<\n PropsWithChildren<{ title: string; icon?: ReactElement; direction?: 'row' | 'column' }>\n> = ({ children, title, icon, direction = 'row' }) => {\n const [anchorPosition, setAnchorPosition] = useState<PopoverPosition>();\n\n // do not show overflow menu if there is no content (for example, edit actions are hidden)\n const hasContent = isValidElement(children) || (Array.isArray(children) && children.some(isValidElement));\n if (!hasContent) {\n return null;\n }\n\n const handleClick = (event: React.MouseEvent<HTMLElement>): void => {\n setAnchorPosition(event.currentTarget.getBoundingClientRect());\n };\n\n const handleClose = (): void => {\n setAnchorPosition(undefined);\n };\n\n const open = Boolean(anchorPosition);\n const id = open ? 'actions-menu' : undefined;\n\n return (\n <>\n <HeaderIconButton\n className=\"show-actions\"\n aria-describedby={id}\n onClick={handleClick}\n aria-label={ARIA_LABEL_TEXT.showPanelActions(title)}\n size=\"small\"\n >\n {icon ?? <MenuIcon fontSize=\"inherit\" />}\n </HeaderIconButton>\n <Popover\n id={id}\n open={open}\n anchorReference=\"anchorPosition\"\n anchorPosition={anchorPosition}\n onClose={handleClose}\n anchorOrigin={{\n vertical: 'bottom',\n horizontal: 'left',\n }}\n >\n <Stack direction={direction} alignItems=\"center\" sx={{ padding: 1 }} onClick={handleClose}>\n {children}\n </Stack>\n </Popover>\n </>\n );\n};\n"],"names":["Stack","Box","Popover","CircularProgress","styled","isValidElement","useMemo","useState","InfoTooltip","DatabaseSearch","ArrowCollapseIcon","ArrowExpandIcon","PencilIcon","DeleteIcon","DragIcon","ContentCopyIcon","MenuIcon","AlertIcon","AlertCircleIcon","InformationOutlineIcon","LightningBoltIcon","ARIA_LABEL_TEXT","HEADER_ACTIONS_CONTAINER_NAME","HEADER_MEDIUM_WIDTH","HEADER_SMALL_WIDTH","TOOLTIP_TEXT","HeaderIconButton","PanelLinks","noticeTypeToIcon","error","color","warning","fontSize","info","ConditionalBox","display","alignItems","flexGrow","justifyContent","PanelActions","editHandlers","readHandlers","viewQueriesHandler","extra","title","description","descriptionTooltipId","links","queryResults","pluginActions","itemActions","showIcons","descriptionAction","trim","length","id","enterDelay","aria-label","size","aria-describedby","aria-hidden","sx","theme","palette","text","secondary","undefined","linksAction","extraActions","queryStateIndicator","hasData","some","q","data","isFetching","queryErrors","filter","errorTexts","map","e","message","join","main","noticesIndicator","notices","flatMap","metadata","lastNotice","type","readActions","viewPanel","onClick","onViewPanelClick","isPanelViewed","viewQueryAction","queryView","openQueryView","editActions","editPanel","onEditPanelClick","duplicatePanel","onDuplicatePanelClick","transform","deletePanel","onDeletePanelClick","moveAction","movePanel","className","cursor","divider","OnHover","children","containerQueries","between","OverflowMenu","down","icon","direction","anchorPosition","setAnchorPosition","hasContent","Array","isArray","handleClick","event","currentTarget","getBoundingClientRect","handleClose","open","Boolean","showPanelActions","anchorReference","onClose","anchorOrigin","vertical","horizontal","padding"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,KAAK,EAAEC,GAAG,EAAEC,OAAO,EAAEC,gBAAgB,EAAEC,MAAM,QAAyB,gBAAgB;AAC/F,SAASC,cAAc,EAA8CC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AACtG,SAASC,WAAW,QAAQ,yBAAyB;AAErD,OAAOC,oBAAoB,iCAAiC;AAC5D,OAAOC,uBAAuB,gCAAgC;AAC9D,OAAOC,qBAAqB,8BAA8B;AAC1D,OAAOC,gBAAgB,gCAAgC;AACvD,OAAOC,gBAAgB,gCAAgC;AACvD,OAAOC,cAAc,+BAA+B;AACpD,OAAOC,qBAAqB,8BAA8B;AAC1D,OAAOC,cAAc,uBAAuB;AAC5C,OAAOC,eAAe,wBAAwB;AAC9C,OAAOC,qBAAqB,8BAA8B;AAC1D,OAAOC,4BAA4B,qCAAqC;AACxE,OAAOC,uBAAuB,gCAAgC;AAE9D,SACEC,eAAe,EACfC,6BAA6B,EAC7BC,mBAAmB,EACnBC,kBAAkB,EAClBC,YAAY,QACP,kBAAkB;AACzB,SAASC,gBAAgB,QAAQ,qBAAqB;AACtD,SAASC,UAAU,QAAQ,eAAe;AAG1C,MAAMC,mBAAsD;IAC1DC,qBAAO,KAACX;QAAgBY,OAAM;;IAC9BC,uBAAS,KAACd;QAAUe,UAAS;QAAUF,OAAM;;IAC7CG,oBAAM,KAACd;QAAuBa,UAAS;QAAUF,OAAM;;AACzD;AA2BA,MAAMI,iBAAiB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;0BAE9B,KAAC9B;gBACCqD,IAAIA;gBACJyE,MAAMA;gBACNG,iBAAgB;gBAChBb,gBAAgBA;gBAChBc,SAASL;gBACTM,cAAc;oBACZC,UAAU;oBACVC,YAAY;gBACd;0BAEA,cAAA,KAACvI;oBAAMqH,WAAWA;oBAAWjF,YAAW;oBAASyB,IAAI;wBAAE2E,SAAS;oBAAE;oBAAG7C,SAASoC;8BAC3EhB;;;;;AAKX"}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Panel/PanelActions.tsx"],"sourcesContent":["// Copyright 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 { Stack, Box, Popover, CircularProgress, styled, PopoverPosition } from '@mui/material';\nimport { isValidElement, PropsWithChildren, ReactElement, ReactNode, useMemo, useState } from 'react';\nimport { InfoTooltip } from '@perses-dev/components';\nimport { QueryData } from '@perses-dev/plugin-system';\nimport DatabaseSearch from 'mdi-material-ui/DatabaseSearch';\nimport ArrowCollapseIcon from 'mdi-material-ui/ArrowCollapse';\nimport ArrowExpandIcon from 'mdi-material-ui/ArrowExpand';\nimport PencilIcon from 'mdi-material-ui/PencilOutline';\nimport DeleteIcon from 'mdi-material-ui/DeleteOutline';\nimport DragIcon from 'mdi-material-ui/DragVertical';\nimport ContentCopyIcon from 'mdi-material-ui/ContentCopy';\nimport MenuIcon from 'mdi-material-ui/Menu';\nimport AlertIcon from 'mdi-material-ui/Alert';\nimport AlertCircleIcon from 'mdi-material-ui/AlertCircle';\nimport InformationOutlineIcon from 'mdi-material-ui/InformationOutline';\nimport LightningBoltIcon from 'mdi-material-ui/LightningBolt';\nimport { Link, Notice } from '@perses-dev/core';\nimport {\n ARIA_LABEL_TEXT,\n HEADER_ACTIONS_CONTAINER_NAME,\n HEADER_MEDIUM_WIDTH,\n HEADER_SMALL_WIDTH,\n TOOLTIP_TEXT,\n} from '../../constants';\nimport { HeaderIconButton } from './HeaderIconButton';\nimport { PanelLinks } from './PanelLinks';\nimport { PanelOptions } from './Panel';\n\nconst noticeTypeToIcon: Record<Notice['type'], ReactNode> = {\n error: <AlertCircleIcon color=\"error\" />,\n warning: <AlertIcon fontSize=\"inherit\" color=\"warning\" />,\n info: <InformationOutlineIcon fontSize=\"inherit\" color=\"info\" />,\n};\n\nexport interface PanelActionsProps {\n title?: string;\n description?: string;\n descriptionTooltipId: string;\n links?: Link[];\n extra?: React.ReactNode;\n editHandlers?: {\n onEditPanelClick: () => void;\n onDuplicatePanelClick: () => void;\n onDeletePanelClick: () => void;\n };\n readHandlers?: {\n isPanelViewed?: boolean;\n onViewPanelClick: () => void;\n };\n viewQueriesHandler?: {\n onClick: () => void;\n };\n queryResults: QueryData[];\n pluginActions?: ReactNode[];\n itemActions?: ReactNode[];\n areItemActionsDisabled?: boolean;\n showIcons: PanelOptions['showIcons'];\n}\n\nconst ConditionalBox = styled(Box)({\n display: 'none',\n alignItems: 'center',\n flexGrow: 1,\n justifyContent: 'flex-end',\n});\n\nexport const PanelActions: React.FC<PanelActionsProps> = ({\n editHandlers,\n readHandlers,\n viewQueriesHandler,\n extra,\n title,\n description,\n descriptionTooltipId,\n links,\n queryResults,\n pluginActions = [],\n itemActions = [],\n showIcons,\n}) => {\n const descriptionAction = useMemo((): ReactNode | undefined => {\n if (description && description.trim().length > 0) {\n return (\n <InfoTooltip id={descriptionTooltipId} description={description} enterDelay={100}>\n <HeaderIconButton aria-label=\"panel description\" size=\"small\">\n <InformationOutlineIcon\n aria-describedby=\"info-tooltip\"\n aria-hidden={false}\n fontSize=\"inherit\"\n sx={{ color: (theme) => theme.palette.text.secondary }}\n />\n </HeaderIconButton>\n </InfoTooltip>\n );\n }\n return undefined;\n }, [descriptionTooltipId, description]);\n\n const linksAction = links && links.length > 0 && <PanelLinks links={links} />;\n const extraActions = editHandlers === undefined && extra;\n\n const queryStateIndicator = useMemo((): ReactNode | undefined => {\n const hasData = queryResults.some((q) => q.data);\n const isFetching = queryResults.some((q) => q.isFetching);\n const queryErrors = queryResults.filter((q) => q.error);\n\n if (isFetching && hasData) {\n return <CircularProgress aria-label=\"loading\" size=\"1.125rem\" />;\n } else if (queryErrors.length > 0) {\n const errorTexts = queryErrors\n .map((q) => q.error)\n .map((e) => e.message)\n .join('\\n');\n\n return (\n <InfoTooltip description={errorTexts}>\n <HeaderIconButton aria-label=\"panel errors\" size=\"small\">\n <AlertIcon\n fontSize=\"inherit\"\n sx={{\n color: (theme) => theme.palette.error.main,\n }}\n />\n </HeaderIconButton>\n </InfoTooltip>\n );\n }\n }, [queryResults]);\n\n const noticesIndicator = useMemo(() => {\n const notices = queryResults.flatMap((q) => {\n return q.data?.metadata?.notices ?? [];\n });\n\n if (notices.length > 0) {\n const lastNotice = notices[notices.length - 1]!;\n\n return (\n <InfoTooltip description={lastNotice.message}>\n <HeaderIconButton aria-label=\"panel notices\" size=\"small\">\n {noticeTypeToIcon[lastNotice.type]}\n </HeaderIconButton>\n </InfoTooltip>\n );\n }\n }, [queryResults]);\n\n const readActions = useMemo((): ReactNode | undefined => {\n if (readHandlers !== undefined) {\n return (\n <InfoTooltip description={TOOLTIP_TEXT.viewPanel}>\n <HeaderIconButton\n aria-label={ARIA_LABEL_TEXT.viewPanel(title)}\n size=\"small\"\n onClick={readHandlers.onViewPanelClick}\n >\n {readHandlers.isPanelViewed ? (\n <ArrowCollapseIcon fontSize=\"inherit\" />\n ) : (\n <ArrowExpandIcon fontSize=\"inherit\" />\n )}\n </HeaderIconButton>\n </InfoTooltip>\n );\n }\n return undefined;\n }, [readHandlers, title]);\n\n const viewQueryAction = useMemo(() => {\n if (!viewQueriesHandler?.onClick) return null;\n return (\n <InfoTooltip description={TOOLTIP_TEXT.queryView}>\n <HeaderIconButton\n aria-label={ARIA_LABEL_TEXT.openQueryView(title)}\n size=\"small\"\n onClick={viewQueriesHandler.onClick}\n >\n <DatabaseSearch fontSize=\"inherit\" />\n </HeaderIconButton>\n </InfoTooltip>\n );\n }, [viewQueriesHandler, title]);\n\n const editActions = useMemo((): ReactNode | undefined => {\n if (editHandlers !== undefined) {\n // If there are edit handlers, always just show the edit buttons\n return (\n <>\n <InfoTooltip description={TOOLTIP_TEXT.editPanel}>\n <HeaderIconButton\n aria-label={ARIA_LABEL_TEXT.editPanel(title)}\n size=\"small\"\n onClick={editHandlers.onEditPanelClick}\n >\n <PencilIcon fontSize=\"inherit\" />\n </HeaderIconButton>\n </InfoTooltip>\n <InfoTooltip description={TOOLTIP_TEXT.duplicatePanel}>\n <HeaderIconButton\n aria-label={ARIA_LABEL_TEXT.duplicatePanel(title)}\n size=\"small\"\n onClick={editHandlers.onDuplicatePanelClick}\n >\n <ContentCopyIcon\n fontSize=\"inherit\"\n sx={{\n // Shrink this icon a little bit to look more consistent\n // with the other icons in the header.\n transform: 'scale(0.925)',\n }}\n />\n </HeaderIconButton>\n </InfoTooltip>\n <InfoTooltip description={TOOLTIP_TEXT.deletePanel}>\n <HeaderIconButton\n aria-label={ARIA_LABEL_TEXT.deletePanel(title)}\n size=\"small\"\n onClick={editHandlers.onDeletePanelClick}\n >\n <DeleteIcon fontSize=\"inherit\" />\n </HeaderIconButton>\n </InfoTooltip>\n </>\n );\n }\n return undefined;\n }, [editHandlers, title]);\n\n const moveAction = useMemo((): ReactNode | undefined => {\n if (editActions && !readHandlers?.isPanelViewed) {\n return (\n <InfoTooltip description={TOOLTIP_TEXT.movePanel}>\n <HeaderIconButton aria-label={ARIA_LABEL_TEXT.movePanel(title)} size=\"small\">\n <DragIcon className=\"drag-handle\" sx={{ cursor: 'grab' }} fontSize=\"inherit\" />\n </HeaderIconButton>\n </InfoTooltip>\n );\n }\n return undefined;\n }, [editActions, readHandlers, title]);\n\n const divider = <Box sx={{ flexGrow: 1 }}></Box>;\n\n // By default, the panel header shows certain icons only on hover if the panel is in non-editing, non-fullscreen mode\n const OnHover = ({ children }: PropsWithChildren): ReactNode =>\n showIcons === 'hover' ? <Box sx={{ display: 'var(--panel-hover, none)' }}>{children}</Box> : <>{children}</>;\n\n return (\n <>\n {/* small panel width: move all icons except move/grab to overflow menu */}\n <ConditionalBox\n sx={(theme) => ({\n [theme.containerQueries(HEADER_ACTIONS_CONTAINER_NAME).between(0, HEADER_SMALL_WIDTH)]: { display: 'flex' },\n })}\n >\n {divider}\n <OnHover>\n <OverflowMenu title={title}>\n {descriptionAction} {linksAction} {queryStateIndicator} {noticesIndicator} {extraActions} {viewQueryAction}\n {readActions} {pluginActions} {itemActions}\n {editActions}\n </OverflowMenu>\n {moveAction}\n </OnHover>\n </ConditionalBox>\n\n {/* medium panel width: move edit icons to overflow menu */}\n <ConditionalBox\n sx={(theme) => ({\n [theme.containerQueries(HEADER_ACTIONS_CONTAINER_NAME).between(HEADER_SMALL_WIDTH, HEADER_MEDIUM_WIDTH)]: {\n display: 'flex',\n },\n })}\n >\n <OnHover>\n {descriptionAction} {linksAction}\n </OnHover>\n {divider} {queryStateIndicator}\n {noticesIndicator}\n <OnHover>\n {extraActions}\n {readActions}\n <OverflowMenu title={title}>\n {editActions} {viewQueryAction} {pluginActions} {itemActions}\n </OverflowMenu>\n {moveAction}\n </OnHover>\n </ConditionalBox>\n\n {/* large panel width: show all icons in panel header */}\n <ConditionalBox\n sx={(theme) => ({\n // flip the logic here; if the browser (or jsdom) does not support container queries, always show all icons\n display: 'flex',\n [theme.containerQueries(HEADER_ACTIONS_CONTAINER_NAME).down(HEADER_MEDIUM_WIDTH)]: { display: 'none' },\n })}\n >\n <OnHover>\n {descriptionAction} {linksAction}\n </OnHover>\n {divider} {queryStateIndicator}\n {noticesIndicator}\n <OnHover>\n {extraActions}\n {viewQueryAction}\n {readActions} {editActions}\n {/* Show plugin actions inside a menu if it gets crowded */}\n {pluginActions.length <= 1 ? pluginActions : <OverflowMenu title={title}>{pluginActions}</OverflowMenu>}\n {itemActions.length <= 1 ? (\n itemActions\n ) : (\n <InfoTooltip description={`${itemActions.length} actions`}>\n <OverflowMenu icon={<LightningBoltIcon fontSize=\"inherit\" />} direction=\"column\" title={title}>\n {itemActions}\n </OverflowMenu>\n </InfoTooltip>\n )}\n {moveAction}\n </OnHover>\n </ConditionalBox>\n </>\n );\n};\n\nconst OverflowMenu: React.FC<\n PropsWithChildren<{ title?: string; icon?: ReactElement; direction?: 'row' | 'column' }>\n> = ({ children, title, icon, direction = 'row' }) => {\n const [anchorPosition, setAnchorPosition] = useState<PopoverPosition>();\n\n // do not show overflow menu if there is no content (for example, edit actions are hidden)\n const hasContent = isValidElement(children) || (Array.isArray(children) && children.some(isValidElement));\n if (!hasContent) {\n return null;\n }\n\n const handleClick = (event: React.MouseEvent<HTMLElement>): void => {\n setAnchorPosition(event.currentTarget.getBoundingClientRect());\n };\n\n const handleClose = (): void => {\n setAnchorPosition(undefined);\n };\n\n const open = Boolean(anchorPosition);\n const id = open ? 'actions-menu' : undefined;\n\n return (\n <>\n <HeaderIconButton\n className=\"show-actions\"\n aria-describedby={id}\n onClick={handleClick}\n aria-label={ARIA_LABEL_TEXT.showPanelActions(title)}\n size=\"small\"\n >\n {icon ?? <MenuIcon fontSize=\"inherit\" />}\n </HeaderIconButton>\n <Popover\n id={id}\n open={open}\n anchorReference=\"anchorPosition\"\n anchorPosition={anchorPosition}\n onClose={handleClose}\n anchorOrigin={{\n vertical: 'bottom',\n horizontal: 'left',\n }}\n >\n <Stack direction={direction} alignItems=\"center\" sx={{ padding: 1 }} onClick={handleClose}>\n {children}\n </Stack>\n </Popover>\n </>\n );\n};\n"],"names":["Stack","Box","Popover","CircularProgress","styled","isValidElement","useMemo","useState","InfoTooltip","DatabaseSearch","ArrowCollapseIcon","ArrowExpandIcon","PencilIcon","DeleteIcon","DragIcon","ContentCopyIcon","MenuIcon","AlertIcon","AlertCircleIcon","InformationOutlineIcon","LightningBoltIcon","ARIA_LABEL_TEXT","HEADER_ACTIONS_CONTAINER_NAME","HEADER_MEDIUM_WIDTH","HEADER_SMALL_WIDTH","TOOLTIP_TEXT","HeaderIconButton","PanelLinks","noticeTypeToIcon","error","color","warning","fontSize","info","ConditionalBox","display","alignItems","flexGrow","justifyContent","PanelActions","editHandlers","readHandlers","viewQueriesHandler","extra","title","description","descriptionTooltipId","links","queryResults","pluginActions","itemActions","showIcons","descriptionAction","trim","length","id","enterDelay","aria-label","size","aria-describedby","aria-hidden","sx","theme","palette","text","secondary","undefined","linksAction","extraActions","queryStateIndicator","hasData","some","q","data","isFetching","queryErrors","filter","errorTexts","map","e","message","join","main","noticesIndicator","notices","flatMap","metadata","lastNotice","type","readActions","viewPanel","onClick","onViewPanelClick","isPanelViewed","viewQueryAction","queryView","openQueryView","editActions","editPanel","onEditPanelClick","duplicatePanel","onDuplicatePanelClick","transform","deletePanel","onDeletePanelClick","moveAction","movePanel","className","cursor","divider","OnHover","children","containerQueries","between","OverflowMenu","down","icon","direction","anchorPosition","setAnchorPosition","hasContent","Array","isArray","handleClick","event","currentTarget","getBoundingClientRect","handleClose","open","Boolean","showPanelActions","anchorReference","onClose","anchorOrigin","vertical","horizontal","padding"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,KAAK,EAAEC,GAAG,EAAEC,OAAO,EAAEC,gBAAgB,EAAEC,MAAM,QAAyB,gBAAgB;AAC/F,SAASC,cAAc,EAA8CC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AACtG,SAASC,WAAW,QAAQ,yBAAyB;AAErD,OAAOC,oBAAoB,iCAAiC;AAC5D,OAAOC,uBAAuB,gCAAgC;AAC9D,OAAOC,qBAAqB,8BAA8B;AA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,EAAEnE,KAAK,EAAEwE,IAAI,EAAEC,YAAY,KAAK,EAAE;IAC/C,MAAM,CAACC,gBAAgBC,kBAAkB,GAAGhH;IAE5C,0FAA0F;IAC1F,MAAMiH,2BAAanH,eAAe0G,aAAcU,MAAMC,OAAO,CAACX,aAAaA,SAASxC,IAAI,CAAClE;IACzF,IAAI,CAACmH,YAAY;QACf,OAAO;IACT;IAEA,MAAMG,cAAc,CAACC;QACnBL,kBAAkBK,MAAMC,aAAa,CAACC,qBAAqB;IAC7D;IAEA,MAAMC,cAAc;QAClBR,kBAAkBrD;IACpB;IAEA,MAAM8D,OAAOC,QAAQX;IACrB,MAAM/D,KAAKyE,OAAO,iBAAiB9D;IAEnC,qBACE;;0BACE,KAACxC;gBACCiF,WAAU;gBACVhD,oBAAkBJ;gBAClBoC,SAASgC;gBACTlE,cAAYpC,gBAAgB6G,gBAAgB,CAACtF;gBAC7Cc,MAAK;0BAEJ0D,sBAAQ,KAACpG;oBAASgB,UAAS;;;0BAE9B,KAAC9B;gBACCqD,IAAIA;gBACJyE,MAAMA;gBACNG,iBAAgB;gBAChBb,gBAAgBA;gBAChBc,SAASL;gBACTM,cAAc;oBACZC,UAAU;oBACVC,YAAY;gBACd;0BAEA,cAAA,KAACvI;oBAAMqH,WAAWA;oBAAWjF,YAAW;oBAASyB,IAAI;wBAAE2E,SAAS;oBAAE;oBAAG7C,SAASoC;8BAC3EhB;;;;;AAKX"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PanelHeader.d.ts","sourceRoot":"","sources":["../../../src/components/Panel/PanelHeader.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAc,eAAe,EAA8B,MAAM,eAAe,CAAC;AAExF,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAqD,MAAM,2BAA2B,CAAC;AACrH,OAAO,EAAE,YAAY,EAAE,SAAS,EAAU,MAAM,OAAO,CAAC;AA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,EACrB,SAAS,EACT,kBAAkB,EAClB,SAAS,EACT,GAAG,IAAI,EACR,EAAE,gBAAgB,GAAG,YAAY,CAmHjC"}
|
|
@@ -33,7 +33,7 @@ export function PanelHeader({ id, title: rawTitle, description: rawDescription,
|
|
|
33
33
|
});
|
|
34
34
|
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
35
35
|
children: [
|
|
36
|
-
/*#__PURE__*/ _jsx(CardHeader, {
|
|
36
|
+
title ? /*#__PURE__*/ _jsx(CardHeader, {
|
|
37
37
|
id: id,
|
|
38
38
|
component: "header",
|
|
39
39
|
"aria-labelledby": titleElementId,
|
|
@@ -89,6 +89,33 @@ export function PanelHeader({ id, title: rawTitle, description: rawDescription,
|
|
|
89
89
|
}
|
|
90
90
|
}), sx),
|
|
91
91
|
...rest
|
|
92
|
+
}) : /*#__PURE__*/ _jsx(Stack, {
|
|
93
|
+
id: id,
|
|
94
|
+
component: "header",
|
|
95
|
+
"aria-describedby": descriptionTooltipId,
|
|
96
|
+
sx: combineSx({
|
|
97
|
+
position: 'absolute',
|
|
98
|
+
right: 0,
|
|
99
|
+
top: 0,
|
|
100
|
+
zIndex: 5,
|
|
101
|
+
containerType: 'inline-size',
|
|
102
|
+
containerName: HEADER_ACTIONS_CONTAINER_NAME
|
|
103
|
+
}, sx),
|
|
104
|
+
...rest,
|
|
105
|
+
children: /*#__PURE__*/ _jsx(PanelActions, {
|
|
106
|
+
title: title,
|
|
107
|
+
description: description,
|
|
108
|
+
descriptionTooltipId: descriptionTooltipId,
|
|
109
|
+
links: links,
|
|
110
|
+
readHandlers: readHandlers,
|
|
111
|
+
editHandlers: editHandlers,
|
|
112
|
+
viewQueriesHandler: viewQueriesHandler,
|
|
113
|
+
extra: extra,
|
|
114
|
+
queryResults: queryResults,
|
|
115
|
+
pluginActions: pluginActions,
|
|
116
|
+
itemActions: actionButtons,
|
|
117
|
+
showIcons: showIcons
|
|
118
|
+
})
|
|
92
119
|
}),
|
|
93
120
|
confirmDialog
|
|
94
121
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Panel/PanelHeader.tsx"],"sourcesContent":["// Copyright 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 { CardHeader, CardHeaderProps, Stack, Typography, Tooltip } from '@mui/material';\nimport { combineSx } from '@perses-dev/components';\nimport { Link } from '@perses-dev/core';\nimport { ItemAction, QueryData, useAllVariableValues, useReplaceVariablesInString } from '@perses-dev/plugin-system';\nimport { ReactElement, ReactNode, useRef } from 'react';\nimport { HEADER_ACTIONS_CONTAINER_NAME } from '../../constants';\nimport { PanelActions, PanelActionsProps } from './PanelActions';\nimport { PanelOptions } from './Panel';\nimport { useSelectionItemActions } from './useSelectionItemActions';\n\ntype OmittedProps = 'children' | 'action' | 'title' | 'disableTypography';\n\nexport interface PanelHeaderProps extends Omit<CardHeaderProps, OmittedProps> {\n id: string;\n title?: string;\n description?: string;\n links?: Link[];\n extra?: ReactNode;\n queryResults: QueryData[];\n viewQueriesHandler?: PanelActionsProps['viewQueriesHandler'];\n readHandlers?: PanelActionsProps['readHandlers'];\n editHandlers?: PanelActionsProps['editHandlers'];\n pluginActions?: ReactNode[];\n itemActionsListConfig?: ItemAction[];\n showIcons: PanelOptions['showIcons'];\n dimension?: { width: number };\n}\n\nexport function PanelHeader({\n id,\n title: rawTitle,\n description: rawDescription,\n links,\n queryResults,\n readHandlers,\n editHandlers,\n sx,\n extra,\n pluginActions,\n itemActionsListConfig,\n showIcons,\n viewQueriesHandler,\n dimension,\n ...rest\n}: PanelHeaderProps): ReactElement {\n const titleElementId = `${id}-title`;\n const descriptionTooltipId = `${id}-description`;\n\n const title = useReplaceVariablesInString(rawTitle)
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Panel/PanelHeader.tsx"],"sourcesContent":["// Copyright 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 { CardHeader, CardHeaderProps, Stack, Typography, Tooltip } from '@mui/material';\nimport { combineSx } from '@perses-dev/components';\nimport { Link } from '@perses-dev/core';\nimport { ItemAction, QueryData, useAllVariableValues, useReplaceVariablesInString } from '@perses-dev/plugin-system';\nimport { ReactElement, ReactNode, useRef } from 'react';\nimport { HEADER_ACTIONS_CONTAINER_NAME } from '../../constants';\nimport { PanelActions, PanelActionsProps } from './PanelActions';\nimport { PanelOptions } from './Panel';\nimport { useSelectionItemActions } from './useSelectionItemActions';\n\ntype OmittedProps = 'children' | 'action' | 'title' | 'disableTypography';\n\nexport interface PanelHeaderProps extends Omit<CardHeaderProps, OmittedProps> {\n id: string;\n title?: string;\n description?: string;\n links?: Link[];\n extra?: ReactNode;\n queryResults: QueryData[];\n viewQueriesHandler?: PanelActionsProps['viewQueriesHandler'];\n readHandlers?: PanelActionsProps['readHandlers'];\n editHandlers?: PanelActionsProps['editHandlers'];\n pluginActions?: ReactNode[];\n itemActionsListConfig?: ItemAction[];\n showIcons: PanelOptions['showIcons'];\n dimension?: { width: number };\n}\n\nexport function PanelHeader({\n id,\n title: rawTitle,\n description: rawDescription,\n links,\n queryResults,\n readHandlers,\n editHandlers,\n sx,\n extra,\n pluginActions,\n itemActionsListConfig,\n showIcons,\n viewQueriesHandler,\n dimension,\n ...rest\n}: PanelHeaderProps): ReactElement {\n const titleElementId = `${id}-title`;\n const descriptionTooltipId = `${id}-description`;\n\n const title = useReplaceVariablesInString(rawTitle);\n const description = useReplaceVariablesInString(rawDescription);\n const variableState = useAllVariableValues();\n\n const textRef = useRef<HTMLDivElement>(null);\n\n const isEllipsisActive =\n textRef.current && dimension?.width ? textRef.current.scrollWidth > textRef.current.clientWidth : false;\n\n const { actionButtons, confirmDialog } = useSelectionItemActions({\n actions: itemActionsListConfig,\n variableState,\n disabledWithEmptySelection: true,\n });\n\n return (\n <>\n {title ? (\n <CardHeader\n id={id}\n component=\"header\"\n aria-labelledby={titleElementId}\n aria-describedby={descriptionTooltipId}\n disableTypography\n title={\n <Stack direction=\"row\" alignItems=\"center\" height=\"var(--panel-header-height, 30px)\">\n <Tooltip title={title} disableHoverListener={!isEllipsisActive}>\n <Typography\n id={titleElementId}\n variant=\"subtitle1\"\n ref={textRef}\n sx={{\n // `minHeight` guarantees that the header has the correct height\n // when there is no title (i.e. in the preview)\n lineHeight: '24px',\n minHeight: '26px',\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n }}\n >\n {title}\n </Typography>\n </Tooltip>\n <PanelActions\n title={title}\n description={description}\n descriptionTooltipId={descriptionTooltipId}\n links={links}\n readHandlers={readHandlers}\n editHandlers={editHandlers}\n viewQueriesHandler={viewQueriesHandler}\n extra={extra}\n queryResults={queryResults}\n pluginActions={pluginActions}\n itemActions={actionButtons}\n showIcons={showIcons}\n />\n </Stack>\n }\n sx={combineSx(\n (theme) => ({\n containerType: 'inline-size',\n containerName: HEADER_ACTIONS_CONTAINER_NAME,\n padding: theme.spacing(1),\n borderBottom: `solid 1px ${theme.palette.divider}`,\n '.MuiCardHeader-content': {\n overflow: 'hidden',\n },\n }),\n sx\n )}\n {...rest}\n />\n ) : (\n <Stack\n id={id}\n component=\"header\"\n aria-describedby={descriptionTooltipId}\n sx={combineSx(\n {\n position: 'absolute',\n right: 0,\n top: 0,\n zIndex: 5,\n containerType: 'inline-size',\n containerName: HEADER_ACTIONS_CONTAINER_NAME,\n },\n sx\n )}\n {...rest}\n >\n <PanelActions\n title={title}\n description={description}\n descriptionTooltipId={descriptionTooltipId}\n links={links}\n readHandlers={readHandlers}\n editHandlers={editHandlers}\n viewQueriesHandler={viewQueriesHandler}\n extra={extra}\n queryResults={queryResults}\n pluginActions={pluginActions}\n itemActions={actionButtons}\n showIcons={showIcons}\n />\n </Stack>\n )}\n {confirmDialog}\n </>\n );\n}\n"],"names":["CardHeader","Stack","Typography","Tooltip","combineSx","useAllVariableValues","useReplaceVariablesInString","useRef","HEADER_ACTIONS_CONTAINER_NAME","PanelActions","useSelectionItemActions","PanelHeader","id","title","rawTitle","description","rawDescription","links","queryResults","readHandlers","editHandlers","sx","extra","pluginActions","itemActionsListConfig","showIcons","viewQueriesHandler","dimension","rest","titleElementId","descriptionTooltipId","variableState","textRef","isEllipsisActive","current","width","scrollWidth","clientWidth","actionButtons","confirmDialog","actions","disabledWithEmptySelection","component","aria-labelledby","aria-describedby","disableTypography","direction","alignItems","height","disableHoverListener","variant","ref","lineHeight","minHeight","whiteSpace","overflow","textOverflow","itemActions","theme","containerType","containerName","padding","spacing","borderBottom","palette","divider","position","right","top","zIndex"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,UAAU,EAAmBC,KAAK,EAAEC,UAAU,EAAEC,OAAO,QAAQ,gBAAgB;AACxF,SAASC,SAAS,QAAQ,yBAAyB;AAEnD,SAAgCC,oBAAoB,EAAEC,2BAA2B,QAAQ,4BAA4B;AACrH,SAAkCC,MAAM,QAAQ,QAAQ;AACxD,SAASC,6BAA6B,QAAQ,kBAAkB;AAChE,SAASC,YAAY,QAA2B,iBAAiB;AAEjE,SAASC,uBAAuB,QAAQ,4BAA4B;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4BACdM,oBAAoBA;4BACpBJ,OAAOA;4BACPJ,cAAcA;4BACdK,eAAeA;4BACfkC,aAAanB;4BACbb,WAAWA;;;;gBAIjBJ,IAAIjB,UACF,CAACsD,QAAW,CAAA;wBACVC,eAAe;wBACfC,eAAepD;wBACfqD,SAASH,MAAMI,OAAO,CAAC;wBACvBC,cAAc,CAAC,UAAU,EAAEL,MAAMM,OAAO,CAACC,OAAO,EAAE;wBAClD,0BAA0B;4BACxBV,UAAU;wBACZ;oBACF,CAAA,GACAlC;gBAED,GAAGO,IAAI;+BAGV,KAAC3B;gBACCW,IAAIA;gBACJ8B,WAAU;gBACVE,oBAAkBd;gBAClBT,IAAIjB,UACF;oBACE8D,UAAU;oBACVC,OAAO;oBACPC,KAAK;oBACLC,QAAQ;oBACRV,eAAe;oBACfC,eAAepD;gBACjB,GACAa;gBAED,GAAGO,IAAI;0BAER,cAAA,KAACnB;oBACCI,OAAOA;oBACPE,aAAaA;oBACbe,sBAAsBA;oBACtBb,OAAOA;oBACPE,cAAcA;oBACdC,cAAcA;oBACdM,oBAAoBA;oBACpBJ,OAAOA;oBACPJ,cAAcA;oBACdK,eAAeA;oBACfkC,aAAanB;oBACbb,WAAWA;;;YAIhBc;;;AAGP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PanelDrawer.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/PanelDrawer.tsx"],"names":[],"mappings":"AA2BA,OAAO,EAAE,YAAY,EAA6C,MAAM,OAAO,CAAC;AAOhF;;GAEG;AACH,eAAO,MAAM,WAAW,QAAO,
|
|
1
|
+
{"version":3,"file":"PanelDrawer.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/PanelDrawer.tsx"],"names":[],"mappings":"AA2BA,OAAO,EAAE,YAAY,EAA6C,MAAM,OAAO,CAAC;AAOhF;;GAEG;AACH,eAAO,MAAM,WAAW,QAAO,YAwE9B,CAAC"}
|
|
@@ -26,12 +26,13 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
26
26
|
import { useState, useMemo, useCallback } from 'react';
|
|
27
27
|
import { Drawer, ErrorAlert, ErrorBoundary } from '@perses-dev/components';
|
|
28
28
|
import { useVariableValues, VariableContext } from '@perses-dev/plugin-system';
|
|
29
|
-
import { usePanelEditor } from '../../context';
|
|
29
|
+
import { usePanelEditor, usePanelKey } from '../../context';
|
|
30
30
|
import { PanelEditorForm } from './PanelEditorForm';
|
|
31
31
|
/**
|
|
32
32
|
* The Add/Edit panel drawer for editing a panel's options.
|
|
33
33
|
*/ export const PanelDrawer = ()=>{
|
|
34
34
|
const panelEditor = usePanelEditor();
|
|
35
|
+
const panelKey = usePanelKey(panelEditor?.panelGroupItemId);
|
|
35
36
|
// When the user clicks close, start closing but don't call the store yet to keep values stable during animtation
|
|
36
37
|
const [isClosing, setIsClosing] = useState(false);
|
|
37
38
|
// Drawer is open if we have a model and we're not transitioning out
|
|
@@ -64,13 +65,16 @@ import { PanelEditorForm } from './PanelEditorForm';
|
|
|
64
65
|
return /*#__PURE__*/ _jsx(Drawer, {
|
|
65
66
|
isOpen: isOpen,
|
|
66
67
|
onClose: handleClickOut,
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
slotProps: {
|
|
69
|
+
transition: {
|
|
70
|
+
onExited: handleExited
|
|
71
|
+
}
|
|
69
72
|
},
|
|
70
73
|
"data-testid": "panel-editor",
|
|
71
74
|
children: panelEditor && /*#__PURE__*/ _jsx(ErrorBoundary, {
|
|
72
75
|
FallbackComponent: ErrorAlert,
|
|
73
76
|
children: /*#__PURE__*/ _jsx(PanelEditorForm, {
|
|
77
|
+
panelKey: panelKey,
|
|
74
78
|
initialAction: panelEditor.mode,
|
|
75
79
|
initialValues: panelEditor.initialValues,
|
|
76
80
|
onSave: handleSave,
|
|
@@ -82,7 +86,8 @@ import { PanelEditorForm } from './PanelEditorForm';
|
|
|
82
86
|
handleExited,
|
|
83
87
|
handleSave,
|
|
84
88
|
isOpen,
|
|
85
|
-
panelEditor
|
|
89
|
+
panelEditor,
|
|
90
|
+
panelKey
|
|
86
91
|
]);
|
|
87
92
|
// If the panel editor is using a repeat variable, we need to wrap the drawer in a VariableContext.Provider
|
|
88
93
|
if (panelEditor?.panelGroupItemId?.repeatVariable) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/PanelDrawer/PanelDrawer.tsx"],"sourcesContent":["// Copyright 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\n/* eslint-disable @typescript-eslint/no-empty-function */\n// Copyright 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 { ReactElement, useState, useMemo, ReactNode, useCallback } from 'react';\nimport { Drawer, ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport { PanelEditorValues } from '@perses-dev/core';\nimport { useVariableValues, VariableContext } from '@perses-dev/plugin-system';\nimport { usePanelEditor } from '../../context';\nimport { PanelEditorForm } from './PanelEditorForm';\n\n/**\n * The Add/Edit panel drawer for editing a panel's options.\n */\nexport const PanelDrawer = (): ReactElement => {\n const panelEditor = usePanelEditor();\n\n // When the user clicks close, start closing but don't call the store yet to keep values stable during animtation\n const [isClosing, setIsClosing] = useState(false);\n\n // Drawer is open if we have a model and we're not transitioning out\n const isOpen = panelEditor !== undefined && !isClosing;\n\n const handleSave = useCallback(\n (values: PanelEditorValues) => {\n // This shouldn't happen since we don't render the submit button until we have a model, but check to make TS happy\n if (panelEditor === undefined || values === undefined) {\n throw new Error('Cannot apply changes');\n }\n panelEditor.applyChanges(values);\n setIsClosing(true);\n },\n [panelEditor]\n );\n\n const handleClose = (): void => {\n setIsClosing(true);\n };\n\n // Don't call closeDrawer on the store until the Drawer has completely transitioned out and reset close state\n const handleExited = useCallback(() => {\n panelEditor?.close();\n setIsClosing(false);\n }, [panelEditor]);\n\n // Disables closing on click out. This is a quick-win solution to avoid losing draft changes.\n // -> TODO find a way to enable closing by clicking-out in edit view, with a discard confirmation modal popping up\n const handleClickOut = (): void => {\n /* do nothing */\n };\n\n const drawer = useMemo(() => {\n return (\n <Drawer\n isOpen={isOpen}\n onClose={handleClickOut}\n
|
|
1
|
+
{"version":3,"sources":["../../../src/components/PanelDrawer/PanelDrawer.tsx"],"sourcesContent":["// Copyright 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\n/* eslint-disable @typescript-eslint/no-empty-function */\n// Copyright 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 { ReactElement, useState, useMemo, ReactNode, useCallback } from 'react';\nimport { Drawer, ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport { PanelEditorValues } from '@perses-dev/core';\nimport { useVariableValues, VariableContext } from '@perses-dev/plugin-system';\nimport { usePanelEditor, usePanelKey } from '../../context';\nimport { PanelEditorForm } from './PanelEditorForm';\n\n/**\n * The Add/Edit panel drawer for editing a panel's options.\n */\nexport const PanelDrawer = (): ReactElement => {\n const panelEditor = usePanelEditor();\n const panelKey = usePanelKey(panelEditor?.panelGroupItemId);\n\n // When the user clicks close, start closing but don't call the store yet to keep values stable during animtation\n const [isClosing, setIsClosing] = useState(false);\n\n // Drawer is open if we have a model and we're not transitioning out\n const isOpen = panelEditor !== undefined && !isClosing;\n\n const handleSave = useCallback(\n (values: PanelEditorValues) => {\n // This shouldn't happen since we don't render the submit button until we have a model, but check to make TS happy\n if (panelEditor === undefined || values === undefined) {\n throw new Error('Cannot apply changes');\n }\n panelEditor.applyChanges(values);\n setIsClosing(true);\n },\n [panelEditor]\n );\n\n const handleClose = (): void => {\n setIsClosing(true);\n };\n\n // Don't call closeDrawer on the store until the Drawer has completely transitioned out and reset close state\n const handleExited = useCallback(() => {\n panelEditor?.close();\n setIsClosing(false);\n }, [panelEditor]);\n\n // Disables closing on click out. This is a quick-win solution to avoid losing draft changes.\n // -> TODO find a way to enable closing by clicking-out in edit view, with a discard confirmation modal popping up\n const handleClickOut = (): void => {\n /* do nothing */\n };\n\n const drawer = useMemo(() => {\n return (\n <Drawer\n isOpen={isOpen}\n onClose={handleClickOut}\n slotProps={{ transition: { onExited: handleExited } }}\n data-testid=\"panel-editor\"\n >\n {/* When the drawer is opened, we should have panel editor state (this also ensures the form state gets reset between opens) */}\n {panelEditor && (\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <PanelEditorForm\n panelKey={panelKey}\n initialAction={panelEditor.mode}\n initialValues={panelEditor.initialValues}\n onSave={handleSave}\n onClose={handleClose}\n />\n </ErrorBoundary>\n )}\n </Drawer>\n );\n }, [handleExited, handleSave, isOpen, panelEditor, panelKey]);\n\n // If the panel editor is using a repeat variable, we need to wrap the drawer in a VariableContext.Provider\n if (panelEditor?.panelGroupItemId?.repeatVariable) {\n return (\n <RepeatVariableWrapper repeatVariable={panelEditor.panelGroupItemId.repeatVariable}>\n {drawer}\n </RepeatVariableWrapper>\n );\n }\n\n return drawer;\n};\n\n// Wraps the drawer in a VariableContext.Provider to provide the repeat variable value\n// This is necessary for previewing panels that use repeat variables and query editor\nfunction RepeatVariableWrapper({\n repeatVariable,\n children,\n}: {\n repeatVariable: [string, string];\n children: ReactNode;\n}): ReactElement {\n const variables = useVariableValues();\n\n return (\n <VariableContext.Provider\n value={{ state: { ...variables, [repeatVariable[0]]: { value: repeatVariable[1], loading: false } } }}\n >\n {children}\n </VariableContext.Provider>\n );\n}\n"],"names":["useState","useMemo","useCallback","Drawer","ErrorAlert","ErrorBoundary","useVariableValues","VariableContext","usePanelEditor","usePanelKey","PanelEditorForm","PanelDrawer","panelEditor","panelKey","panelGroupItemId","isClosing","setIsClosing","isOpen","undefined","handleSave","values","Error","applyChanges","handleClose","handleExited","close","handleClickOut","drawer","onClose","slotProps","transition","onExited","data-testid","FallbackComponent","initialAction","mode","initialValues","onSave","repeatVariable","RepeatVariableWrapper","children","variables","Provider","value","state","loading"],"mappings":"AAAA,+BAA+B;AAC/B,oEAAoE;AACpE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,sEAAsE;AACtE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,uDAAuD,GACvD,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAAuBA,QAAQ,EAAEC,OAAO,EAAaC,WAAW,QAAQ,QAAQ;AAChF,SAASC,MAAM,EAA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1B,YAAYE,gBAAgB,CAACwB,cAAc;sBAC/EX;;IAGP;IAEA,OAAOA;AACT,EAAE;AAEF,sFAAsF;AACtF,qFAAqF;AACrF,SAASY,sBAAsB,EAC7BD,cAAc,EACdE,QAAQ,EAIT;IACC,MAAMC,YAAYnC;IAElB,qBACE,KAACC,gBAAgBmC,QAAQ;QACvBC,OAAO;YAAEC,OAAO;gBAAE,GAAGH,SAAS;gBAAE,CAACH,cAAc,CAAC,EAAE,CAAC,EAAE;oBAAEK,OAAOL,cAAc,CAAC,EAAE;oBAAEO,SAAS;gBAAM;YAAE;QAAE;kBAEnGL;;AAGP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PanelEditorForm.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/PanelEditorForm.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAoC,MAAM,OAAO,CAAC;AAEvE,OAAO,EAAE,MAAM,EAAmB,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAgB9E,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,iBAAiB,CAAC;IACjC,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC5C,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,YAAY,
|
|
1
|
+
{"version":3,"file":"PanelEditorForm.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/PanelEditorForm.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAoC,MAAM,OAAO,CAAC;AAEvE,OAAO,EAAE,MAAM,EAAmB,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAgB9E,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,iBAAiB,CAAC;IACjC,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC5C,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,YAAY,CA+OzE;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,sBAAsB,CAAC"}
|
|
@@ -22,7 +22,7 @@ import { PanelEditorProvider } from '../../context/PanelEditorProvider/PanelEdit
|
|
|
22
22
|
import { usePanelEditor } from './usePanelEditor';
|
|
23
23
|
import { PanelQueriesSharedControls } from './PanelQueriesSharedControls';
|
|
24
24
|
export function PanelEditorForm(props) {
|
|
25
|
-
const { initialValues, initialAction, onSave, onClose } = props;
|
|
25
|
+
const { initialValues, initialAction, panelKey, onSave, onClose } = props;
|
|
26
26
|
const panelGroups = useListPanelGroups();
|
|
27
27
|
const { panelDefinition, setName, setDescription, setLinks, setQueries, setPlugin, setPanelDefinition } = usePanelEditor(initialValues.panelDefinition);
|
|
28
28
|
const { plugin } = panelDefinition.spec;
|
|
@@ -136,11 +136,26 @@ export function PanelEditorForm(props) {
|
|
|
136
136
|
borderBottom: (theme)=>`1px solid ${theme.palette.divider}`
|
|
137
137
|
},
|
|
138
138
|
children: [
|
|
139
|
-
/*#__PURE__*/ _jsxs(
|
|
140
|
-
|
|
139
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
140
|
+
direction: "row",
|
|
141
|
+
spacing: 1,
|
|
142
|
+
alignItems: "center",
|
|
141
143
|
children: [
|
|
142
|
-
|
|
143
|
-
|
|
144
|
+
/*#__PURE__*/ _jsxs(Typography, {
|
|
145
|
+
variant: "h2",
|
|
146
|
+
children: [
|
|
147
|
+
titleAction,
|
|
148
|
+
" Panel"
|
|
149
|
+
]
|
|
150
|
+
}),
|
|
151
|
+
panelKey && /*#__PURE__*/ _jsxs(Typography, {
|
|
152
|
+
variant: "subtitle1",
|
|
153
|
+
children: [
|
|
154
|
+
"(ID: ",
|
|
155
|
+
panelKey,
|
|
156
|
+
")"
|
|
157
|
+
]
|
|
158
|
+
})
|
|
144
159
|
]
|
|
145
160
|
}),
|
|
146
161
|
/*#__PURE__*/ _jsxs(Stack, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/PanelDrawer/PanelEditorForm.tsx"],"sourcesContent":["// Copyright 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 { ReactElement, useCallback, useEffect, useState } from 'react';\nimport { Box, Button, Grid, MenuItem, Stack, TextField, Typography } from '@mui/material';\nimport { Action, PanelDefinition, PanelEditorValues } from '@perses-dev/core';\nimport { DiscardChangesConfirmationDialog, ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport {\n PluginKindSelect,\n usePluginEditor,\n getTitleAction,\n getSubmitText,\n useValidationSchemas,\n} from '@perses-dev/plugin-system';\nimport { Controller, FormProvider, SubmitHandler, useForm, useWatch } from 'react-hook-form';\nimport { zodResolver } from '@hookform/resolvers/zod';\nimport { useListPanelGroups } from '../../context';\nimport { PanelEditorProvider } from '../../context/PanelEditorProvider/PanelEditorProvider';\nimport { usePanelEditor } from './usePanelEditor';\nimport { PanelQueriesSharedControls } from './PanelQueriesSharedControls';\n\nexport interface PanelEditorFormProps {\n initialValues: PanelEditorValues;\n initialAction: Action;\n onSave: (values: PanelEditorValues) => void;\n onClose: () => void;\n}\n\nexport function PanelEditorForm(props: PanelEditorFormProps): ReactElement {\n const { initialValues, initialAction, onSave, onClose } = props;\n const panelGroups = useListPanelGroups();\n const { panelDefinition, setName, setDescription, setLinks, setQueries, setPlugin, setPanelDefinition } =\n usePanelEditor(initialValues.panelDefinition);\n const { plugin } = panelDefinition.spec;\n const [isDiscardDialogOpened, setDiscardDialogOpened] = useState<boolean>(false);\n\n const { panelEditorSchema } = useValidationSchemas();\n const form = useForm<PanelEditorValues>({\n resolver: zodResolver(panelEditorSchema),\n mode: 'onBlur',\n defaultValues: initialValues,\n });\n\n // Use common plugin editor logic even though we've split the inputs up in this form\n const pluginEditor = usePluginEditor({\n pluginTypes: ['Panel'],\n value: { selection: { kind: plugin.kind, type: 'Panel' }, spec: plugin.spec },\n onChange: (plugin) => {\n form.setValue('panelDefinition.spec.plugin', { kind: plugin.selection.kind, spec: plugin.spec });\n setPlugin({\n kind: plugin.selection.kind,\n spec: plugin.spec,\n });\n },\n onHideQueryEditorChange: (isHidden) => {\n setQueries(undefined, isHidden);\n },\n });\n\n const titleAction = getTitleAction(initialAction, true);\n const submitText = getSubmitText(initialAction, true);\n\n const links = useWatch({ control: form.control, name: 'panelDefinition.spec.links' });\n useEffect(() => {\n setLinks(links);\n }, [setLinks, links]);\n\n const processForm: SubmitHandler<PanelEditorValues> = useCallback(\n (data) => {\n onSave(data);\n },\n [onSave]\n );\n\n // When user click on cancel, several possibilities:\n // - create action: ask for discard approval\n // - update action: ask for discard approval if changed\n // - read action: don´t ask for discard approval\n function handleCancel(): void {\n const currentValues = form.getValues();\n\n // Normalize display: if both name and description are undefined, set display to undefined\n const normalizeDisplay = (values: PanelEditorValues): PanelEditorValues => {\n if (\n values.panelDefinition.spec.display?.name === undefined &&\n values.panelDefinition.spec.display?.description === undefined\n ) {\n values.panelDefinition.spec.display = undefined;\n }\n return values;\n };\n\n const normalizedInitial = normalizeDisplay(JSON.parse(JSON.stringify(initialValues)));\n const normalizedCurrent = normalizeDisplay(JSON.parse(JSON.stringify(currentValues)));\n\n if (JSON.stringify(normalizedInitial) !== JSON.stringify(normalizedCurrent)) {\n setDiscardDialogOpened(true);\n } else {\n onClose();\n }\n }\n\n const handlePanelDefinitionChange = (nextPanelDefStr: string): void => {\n const nextPanelDef: PanelDefinition = JSON.parse(nextPanelDefStr);\n const { kind: pluginKind, spec: pluginSpec } = nextPanelDef.spec.plugin;\n // if panel plugin kind and spec are modified, then need to save current spec\n if (\n panelDefinition.spec.plugin.kind !== pluginKind &&\n JSON.stringify(panelDefinition.spec.plugin.spec) !== JSON.stringify(pluginSpec)\n ) {\n pluginEditor.rememberCurrentSpecState();\n }\n setPanelDefinition(nextPanelDef);\n };\n\n const watchedName = useWatch({ control: form.control, name: 'panelDefinition.spec.display.name' });\n const watchedDescription = useWatch({ control: form.control, name: 'panelDefinition.spec.display.description' });\n const watchedPluginKind = useWatch({ control: form.control, name: 'panelDefinition.spec.plugin.kind' });\n\n const handleSubmit = useCallback(() => {\n form.handleSubmit(processForm)();\n }, [form, processForm]);\n\n return (\n <FormProvider {...form}>\n <PanelEditorProvider>\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n padding: (theme) => theme.spacing(1, 2),\n borderBottom: (theme) => `1px solid ${theme.palette.divider}`,\n }}\n >\n <Typography variant=\"h2\">{titleAction} Panel</Typography>\n <Stack direction=\"row\" spacing={1} marginLeft=\"auto\">\n <Button variant=\"contained\" disabled={!form.formState.isValid} onClick={handleSubmit}>\n {submitText}\n </Button>\n <Button color=\"secondary\" variant=\"outlined\" onClick={handleCancel}>\n Cancel\n </Button>\n </Stack>\n </Box>\n <Box id={panelEditorFormId} sx={{ flex: 1, overflowY: 'scroll', padding: (theme) => theme.spacing(2) }}>\n <Grid container spacing={2}>\n <Grid item xs={8}>\n <Controller\n control={form.control}\n name=\"panelDefinition.spec.display.name\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"Name\"\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={watchedName ?? ''}\n onChange={(event) => {\n field.onChange(event);\n setName(event.target.value);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={4}>\n <Controller\n control={form.control}\n name=\"groupId\"\n render={({ field, fieldState }) => (\n <TextField\n select\n {...field}\n required\n fullWidth\n label=\"Group\"\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n onChange={(event) => {\n field.onChange(event);\n }}\n >\n {panelGroups.map((panelGroup, index) => (\n <MenuItem key={panelGroup.id} value={panelGroup.id}>\n {panelGroup.title ?? `Group ${index + 1}`}\n </MenuItem>\n ))}\n </TextField>\n )}\n />\n </Grid>\n <Grid item xs={8}>\n <Controller\n control={form.control}\n name=\"panelDefinition.spec.display.description\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"Description\"\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={watchedDescription ?? ''}\n onChange={(event) => {\n field.onChange(event);\n setDescription(event.target.value);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={4}>\n <Controller\n control={form.control}\n name=\"panelDefinition.spec.plugin.kind\"\n render={({ field, fieldState }) => (\n <PluginKindSelect\n {...field}\n pluginTypes={['Panel']}\n required\n fullWidth\n label=\"Type\"\n disabled={pluginEditor.isLoading}\n error={!!pluginEditor.error || !!fieldState.error}\n helperText={pluginEditor.error?.message ?? fieldState.error?.message}\n value={{ type: 'Panel', kind: watchedPluginKind }}\n onChange={(event) => {\n field.onChange(event.kind);\n pluginEditor.onSelectionChange(event);\n }}\n />\n )}\n />\n </Grid>\n\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <PanelQueriesSharedControls\n control={form.control}\n plugin={plugin}\n panelDefinition={panelDefinition}\n onQueriesChange={(q) => setQueries(q)}\n onPluginSpecChange={(spec) => {\n pluginEditor.onSpecChange(spec);\n }}\n onJSONChange={handlePanelDefinitionChange}\n />\n </ErrorBoundary>\n </Grid>\n </Box>\n <DiscardChangesConfirmationDialog\n description=\"You have unapplied changes in this panel. Are you sure you want to discard these changes? Changes cannot be recovered.\"\n isOpen={isDiscardDialogOpened}\n onCancel={() => {\n setDiscardDialogOpened(false);\n }}\n onDiscardChanges={() => {\n setDiscardDialogOpened(false);\n onClose();\n }}\n />\n </PanelEditorProvider>\n </FormProvider>\n );\n}\n\n/**\n * The `id` attribute added to the `PanelEditorForm` component, allowing submit buttons to live outside the form.\n */\nexport const panelEditorFormId = 'panel-editor-form';\n"],"names":["useCallback","useEffect","useState","Box","Button","Grid","MenuItem","Stack","TextField","Typography","DiscardChangesConfirmationDialog","ErrorAlert","ErrorBoundary","PluginKindSelect","usePluginEditor","getTitleAction","getSubmitText","useValidationSchemas","Controller","FormProvider","useForm","useWatch","zodResolver","useListPanelGroups","PanelEditorProvider","usePanelEditor","PanelQueriesSharedControls","PanelEditorForm","props","initialValues","initialAction","onSave","onClose","panelGroups","panelDefinition","setName","setDescription","setLinks","setQueries","setPlugin","setPanelDefinition","plugin","spec","isDiscardDialogOpened","setDiscardDialogOpened","panelEditorSchema","form","resolver","mode","defaultValues","pluginEditor","pluginTypes","value","selection","kind","type","onChange","setValue","onHideQueryEditorChange","isHidden","undefined","titleAction","submitText","links","control","name","processForm","data","handleCancel","currentValues","getValues","normalizeDisplay","values","display","description","normalizedInitial","JSON","parse","stringify","normalizedCurrent","handlePanelDefinitionChange","nextPanelDefStr","nextPanelDef","pluginKind","pluginSpec","rememberCurrentSpecState","watchedName","watchedDescription","watchedPluginKind","handleSubmit","sx","alignItems","padding","theme","spacing","borderBottom","palette","divider","variant","direction","marginLeft","disabled","formState","isValid","onClick","color","id","panelEditorFormId","flex","overflowY","container","item","xs","render","field","fieldState","fullWidth","label","error","helperText","message","event","target","select","required","map","panelGroup","index","title","isLoading","onSelectionChange","FallbackComponent","onQueriesChange","q","onPluginSpecChange","onSpecChange","onJSONChange","isOpen","onCancel","onDiscardChanges"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAAuBA,WAAW,EAAEC,SAAS,EAAEC,QAAQ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;wCACnBQ,aAAaqF,YAAY,CAAC7F;oCAC5B;oCACA8F,cAAcxD;;;;;;8BAKtB,KAACtE;oBACCgE,aAAY;oBACZ+D,QAAQ9F;oBACR+F,UAAU;wBACR9F,uBAAuB;oBACzB;oBACA+F,kBAAkB;wBAChB/F,uBAAuB;wBACvBZ;oBACF;;;;;AAKV;AAEA;;CAEC,GACD,OAAO,MAAM2E,oBAAoB,oBAAoB"}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/PanelDrawer/PanelEditorForm.tsx"],"sourcesContent":["// Copyright 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 { ReactElement, useCallback, useEffect, useState } from 'react';\nimport { Box, Button, Grid, MenuItem, Stack, TextField, Typography } from '@mui/material';\nimport { Action, PanelDefinition, PanelEditorValues } from '@perses-dev/core';\nimport { DiscardChangesConfirmationDialog, ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport {\n PluginKindSelect,\n usePluginEditor,\n getTitleAction,\n getSubmitText,\n useValidationSchemas,\n} from '@perses-dev/plugin-system';\nimport { Controller, FormProvider, SubmitHandler, useForm, useWatch } from 'react-hook-form';\nimport { zodResolver } from '@hookform/resolvers/zod';\nimport { useListPanelGroups } from '../../context';\nimport { PanelEditorProvider } from '../../context/PanelEditorProvider/PanelEditorProvider';\nimport { usePanelEditor } from './usePanelEditor';\nimport { PanelQueriesSharedControls } from './PanelQueriesSharedControls';\n\nexport interface PanelEditorFormProps {\n initialValues: PanelEditorValues;\n initialAction: Action;\n panelKey?: string;\n onSave: (values: PanelEditorValues) => void;\n onClose: () => void;\n}\n\nexport function PanelEditorForm(props: PanelEditorFormProps): ReactElement {\n const { initialValues, initialAction, panelKey, onSave, onClose } = props;\n const panelGroups = useListPanelGroups();\n const { panelDefinition, setName, setDescription, setLinks, setQueries, setPlugin, setPanelDefinition } =\n usePanelEditor(initialValues.panelDefinition);\n const { plugin } = panelDefinition.spec;\n const [isDiscardDialogOpened, setDiscardDialogOpened] = useState<boolean>(false);\n\n const { panelEditorSchema } = useValidationSchemas();\n const form = useForm<PanelEditorValues>({\n resolver: zodResolver(panelEditorSchema),\n mode: 'onBlur',\n defaultValues: initialValues,\n });\n\n // Use common plugin editor logic even though we've split the inputs up in this form\n const pluginEditor = usePluginEditor({\n pluginTypes: ['Panel'],\n value: { selection: { kind: plugin.kind, type: 'Panel' }, spec: plugin.spec },\n onChange: (plugin) => {\n form.setValue('panelDefinition.spec.plugin', { kind: plugin.selection.kind, spec: plugin.spec });\n setPlugin({\n kind: plugin.selection.kind,\n spec: plugin.spec,\n });\n },\n onHideQueryEditorChange: (isHidden) => {\n setQueries(undefined, isHidden);\n },\n });\n\n const titleAction = getTitleAction(initialAction, true);\n const submitText = getSubmitText(initialAction, true);\n\n const links = useWatch({ control: form.control, name: 'panelDefinition.spec.links' });\n useEffect(() => {\n setLinks(links);\n }, [setLinks, links]);\n\n const processForm: SubmitHandler<PanelEditorValues> = useCallback(\n (data) => {\n onSave(data);\n },\n [onSave]\n );\n\n // When user click on cancel, several possibilities:\n // - create action: ask for discard approval\n // - update action: ask for discard approval if changed\n // - read action: don´t ask for discard approval\n function handleCancel(): void {\n const currentValues = form.getValues();\n\n // Normalize display: if both name and description are undefined, set display to undefined\n const normalizeDisplay = (values: PanelEditorValues): PanelEditorValues => {\n if (\n values.panelDefinition.spec.display?.name === undefined &&\n values.panelDefinition.spec.display?.description === undefined\n ) {\n values.panelDefinition.spec.display = undefined;\n }\n return values;\n };\n\n const normalizedInitial = normalizeDisplay(JSON.parse(JSON.stringify(initialValues)));\n const normalizedCurrent = normalizeDisplay(JSON.parse(JSON.stringify(currentValues)));\n\n if (JSON.stringify(normalizedInitial) !== JSON.stringify(normalizedCurrent)) {\n setDiscardDialogOpened(true);\n } else {\n onClose();\n }\n }\n\n const handlePanelDefinitionChange = (nextPanelDefStr: string): void => {\n const nextPanelDef: PanelDefinition = JSON.parse(nextPanelDefStr);\n const { kind: pluginKind, spec: pluginSpec } = nextPanelDef.spec.plugin;\n // if panel plugin kind and spec are modified, then need to save current spec\n if (\n panelDefinition.spec.plugin.kind !== pluginKind &&\n JSON.stringify(panelDefinition.spec.plugin.spec) !== JSON.stringify(pluginSpec)\n ) {\n pluginEditor.rememberCurrentSpecState();\n }\n setPanelDefinition(nextPanelDef);\n };\n\n const watchedName = useWatch({ control: form.control, name: 'panelDefinition.spec.display.name' });\n const watchedDescription = useWatch({ control: form.control, name: 'panelDefinition.spec.display.description' });\n const watchedPluginKind = useWatch({ control: form.control, name: 'panelDefinition.spec.plugin.kind' });\n\n const handleSubmit = useCallback(() => {\n form.handleSubmit(processForm)();\n }, [form, processForm]);\n\n return (\n <FormProvider {...form}>\n <PanelEditorProvider>\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n padding: (theme) => theme.spacing(1, 2),\n borderBottom: (theme) => `1px solid ${theme.palette.divider}`,\n }}\n >\n <Stack direction=\"row\" spacing={1} alignItems=\"center\">\n <Typography variant=\"h2\">{titleAction} Panel</Typography>\n {panelKey && <Typography variant=\"subtitle1\">(ID: {panelKey})</Typography>}\n </Stack>\n <Stack direction=\"row\" spacing={1} marginLeft=\"auto\">\n <Button variant=\"contained\" disabled={!form.formState.isValid} onClick={handleSubmit}>\n {submitText}\n </Button>\n <Button color=\"secondary\" variant=\"outlined\" onClick={handleCancel}>\n Cancel\n </Button>\n </Stack>\n </Box>\n <Box id={panelEditorFormId} sx={{ flex: 1, overflowY: 'scroll', padding: (theme) => theme.spacing(2) }}>\n <Grid container spacing={2}>\n <Grid item xs={8}>\n <Controller\n control={form.control}\n name=\"panelDefinition.spec.display.name\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"Name\"\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={watchedName ?? ''}\n onChange={(event) => {\n field.onChange(event);\n setName(event.target.value);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={4}>\n <Controller\n control={form.control}\n name=\"groupId\"\n render={({ field, fieldState }) => (\n <TextField\n select\n {...field}\n required\n fullWidth\n label=\"Group\"\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n onChange={(event) => {\n field.onChange(event);\n }}\n >\n {panelGroups.map((panelGroup, index) => (\n <MenuItem key={panelGroup.id} value={panelGroup.id}>\n {panelGroup.title ?? `Group ${index + 1}`}\n </MenuItem>\n ))}\n </TextField>\n )}\n />\n </Grid>\n <Grid item xs={8}>\n <Controller\n control={form.control}\n name=\"panelDefinition.spec.display.description\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"Description\"\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={watchedDescription ?? ''}\n onChange={(event) => {\n field.onChange(event);\n setDescription(event.target.value);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={4}>\n <Controller\n control={form.control}\n name=\"panelDefinition.spec.plugin.kind\"\n render={({ field, fieldState }) => (\n <PluginKindSelect\n {...field}\n pluginTypes={['Panel']}\n required\n fullWidth\n label=\"Type\"\n disabled={pluginEditor.isLoading}\n error={!!pluginEditor.error || !!fieldState.error}\n helperText={pluginEditor.error?.message ?? fieldState.error?.message}\n value={{ type: 'Panel', kind: watchedPluginKind }}\n onChange={(event) => {\n field.onChange(event.kind);\n pluginEditor.onSelectionChange(event);\n }}\n />\n )}\n />\n </Grid>\n\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <PanelQueriesSharedControls\n control={form.control}\n plugin={plugin}\n panelDefinition={panelDefinition}\n onQueriesChange={(q) => setQueries(q)}\n onPluginSpecChange={(spec) => {\n pluginEditor.onSpecChange(spec);\n }}\n onJSONChange={handlePanelDefinitionChange}\n />\n </ErrorBoundary>\n </Grid>\n </Box>\n <DiscardChangesConfirmationDialog\n description=\"You have unapplied changes in this panel. Are you sure you want to discard these changes? Changes cannot be recovered.\"\n isOpen={isDiscardDialogOpened}\n onCancel={() => {\n setDiscardDialogOpened(false);\n }}\n onDiscardChanges={() => {\n setDiscardDialogOpened(false);\n onClose();\n }}\n />\n </PanelEditorProvider>\n </FormProvider>\n );\n}\n\n/**\n * The `id` attribute added to the `PanelEditorForm` component, allowing submit buttons to live outside the form.\n */\nexport const panelEditorFormId = 'panel-editor-form';\n"],"names":["useCallback","useEffect","useState","Box","Button","Grid","MenuItem","Stack","TextField","Typography","DiscardChangesConfirmationDialog","ErrorAlert","ErrorBoundary","PluginKindSelect","usePluginEditor","getTitleAction","getSubmitText","useValidationSchemas","Controller","FormProvider","useForm","useWatch","zodResolver","useListPanelGroups","PanelEditorProvider","usePanelEditor","PanelQueriesSharedControls","PanelEditorForm","props","initialValues","initialAction","panelKey","onSave","onClose","panelGroups","panelDefinition","setName","setDescription","setLinks","setQueries","setPlugin","setPanelDefinition","plugin","spec","isDiscardDialogOpened","setDiscardDialogOpened","panelEditorSchema","form","resolver","mode","defaultValues","pluginEditor","pluginTypes","value","selection","kind","type","onChange","setValue","onHideQueryEditorChange","isHidden","undefined","titleAction","submitText","links","control","name","processForm","data","handleCancel","currentValues","getValues","normalizeDisplay","values","display","description","normalizedInitial","JSON","parse","stringify","normalizedCurrent","handlePanelDefinitionChange","nextPanelDefStr","nextPanelDef","pluginKind","pluginSpec","rememberCurrentSpecState","watchedName","watchedDescription","watchedPluginKind","handleSubmit","sx","alignItems","padding","theme","spacing","borderBottom","palette","divider","direction","variant","marginLeft","disabled","formState","isValid","onClick","color","id","panelEditorFormId","flex","overflowY","container","item","xs","render","field","fieldState","fullWidth","label","error","helperText","message","event","target","select","required","map","panelGroup","index","title","isLoading","onSelectionChange","FallbackComponent","onQueriesChange","q","onPluginSpecChange","onSpecChange","onJSONChange","isOpen","onCancel","onDiscardChanges"],"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,WAAWL,WAAWG,KAAK,EAAEE;4CAC7DpE,OAAO;gDAAEG,MAAM;gDAASD,MAAMkC;4CAAkB;4CAChDhC,UAAU,CAACiE;gDACTP,MAAM1D,QAAQ,CAACiE,MAAMnE,IAAI;gDACzBJ,aAAagF,iBAAiB,CAACT;4CACjC;;;;0CAMR,KAAC9G;gCAAcwH,mBAAmBzH;0CAChC,cAAA,KAACe;oCACCuC,SAASlB,KAAKkB,OAAO;oCACrBvB,QAAQA;oCACRP,iBAAiBA;oCACjBkG,iBAAiB,CAACC,IAAM/F,WAAW+F;oCACnCC,oBAAoB,CAAC5F;wCACnBQ,aAAaqF,YAAY,CAAC7F;oCAC5B;oCACA8F,cAAcxD;;;;;;8BAKtB,KAACvE;oBACCiE,aAAY;oBACZ+D,QAAQ9F;oBACR+F,UAAU;wBACR9F,uBAAuB;oBACzB;oBACA+F,kBAAkB;wBAChB/F,uBAAuB;wBACvBZ;oBACF;;;;;AAKV;AAEA;;CAEC,GACD,OAAO,MAAM2E,oBAAoB,oBAAoB"}
|
|
@@ -25,12 +25,12 @@ export declare const ARIA_LABEL_TEXT: {
|
|
|
25
25
|
editGroup: (groupName: string) => string;
|
|
26
26
|
moveGroupDown: (groupName: string) => string;
|
|
27
27
|
moveGroupUp: (groupName: string) => string;
|
|
28
|
-
viewPanel: (panelName
|
|
29
|
-
editPanel: (panelName
|
|
30
|
-
duplicatePanel: (panelName
|
|
31
|
-
deletePanel: (panelName
|
|
32
|
-
showPanelActions: (panelName
|
|
33
|
-
movePanel: (panelName
|
|
34
|
-
openQueryView: (panelName
|
|
28
|
+
viewPanel: (panelName?: string) => string;
|
|
29
|
+
editPanel: (panelName?: string) => string;
|
|
30
|
+
duplicatePanel: (panelName?: string) => string;
|
|
31
|
+
deletePanel: (panelName?: string) => string;
|
|
32
|
+
showPanelActions: (panelName?: string) => string;
|
|
33
|
+
movePanel: (panelName?: string) => string;
|
|
34
|
+
openQueryView: (panelName?: string) => string;
|
|
35
35
|
};
|
|
36
36
|
//# sourceMappingURL=user-interface-text.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-interface-text.d.ts","sourceRoot":"","sources":["../../src/constants/user-interface-text.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;CAwBxB,CAAC;AAEF,eAAO,MAAM,eAAe;iCAEG,MAAM,KAAG,MAAM;6BACnB,MAAM,KAAG,MAAM;2BACjB,MAAM,KAAG,MAAM;+BACX,MAAM,KAAG,MAAM;6BACjB,MAAM,KAAG,MAAM;
|
|
1
|
+
{"version":3,"file":"user-interface-text.d.ts","sourceRoot":"","sources":["../../src/constants/user-interface-text.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;CAwBxB,CAAC;AAEF,eAAO,MAAM,eAAe;iCAEG,MAAM,KAAG,MAAM;6BACnB,MAAM,KAAG,MAAM;2BACjB,MAAM,KAAG,MAAM;+BACX,MAAM,KAAG,MAAM;6BACjB,MAAM,KAAG,MAAM;4BAEhB,MAAM,KAAG,MAAM;4BAEf,MAAM,KAAG,MAAM;iCACV,MAAM,KAAG,MAAM;8BAClB,MAAM,KAAG,MAAM;mCACV,MAAM,KAAG,MAAM;4BAEtB,MAAM,KAAG,MAAM;gCACX,MAAM,KAAG,MAAM;CAE5C,CAAC"}
|
|
@@ -43,13 +43,13 @@ export const ARIA_LABEL_TEXT = {
|
|
|
43
43
|
moveGroupDown: (groupName)=>`move group ${groupName} down`,
|
|
44
44
|
moveGroupUp: (groupName)=>`move group ${groupName} up`,
|
|
45
45
|
// Panel buttons
|
|
46
|
-
viewPanel: (panelName)
|
|
47
|
-
editPanel: (panelName)
|
|
48
|
-
duplicatePanel: (panelName)
|
|
49
|
-
deletePanel: (panelName)
|
|
50
|
-
showPanelActions: (panelName)
|
|
51
|
-
movePanel: (panelName)
|
|
52
|
-
openQueryView: (panelName)
|
|
46
|
+
viewPanel: (panelName)=>panelName ? `toggle panel ${panelName} view mode` : 'toggle panel view mode',
|
|
47
|
+
editPanel: (panelName)=>panelName ? `edit panel ${panelName}` : 'edit panel',
|
|
48
|
+
duplicatePanel: (panelName)=>panelName ? `duplicate panel ${panelName}` : 'duplicate panel',
|
|
49
|
+
deletePanel: (panelName)=>panelName ? `delete panel ${panelName}` : 'delete panel',
|
|
50
|
+
showPanelActions: (panelName)=>panelName ? `show panel actions for ${panelName}` : 'show panel actions',
|
|
51
|
+
movePanel: (panelName)=>panelName ? `move panel ${panelName}` : 'move panel',
|
|
52
|
+
openQueryView: (panelName)=>panelName ? `open query view for panel ${panelName}` : 'open query view for panel'
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
//# sourceMappingURL=user-interface-text.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/constants/user-interface-text.ts"],"sourcesContent":["// Copyright 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 const TOOLTIP_TEXT = {\n // Toolbar buttons\n addPanel: 'Add panel',\n addGroup: 'Add panel group',\n editDatasources: 'Edit datasources',\n editJson: 'Edit JSON',\n editVariables: 'Edit variables',\n viewJson: 'View JSON',\n // Group buttons\n addPanelToGroup: 'Add panel to group',\n deleteGroup: 'Delete group',\n editGroup: 'Edit group',\n moveGroupDown: 'Move group down',\n moveGroupUp: 'Move group up',\n // Panel buttons\n viewPanel: 'Toggle View Mode',\n editPanel: 'Edit',\n duplicatePanel: 'Duplicate',\n deletePanel: 'Delete',\n movePanel: 'Move',\n // Variable editor buttons\n refreshVariableValues: 'Refresh values',\n copyVariableValues: 'Copy values to clipboard',\n queryView: 'Open query view',\n};\n\nexport const ARIA_LABEL_TEXT = {\n // Group buttons\n addPanelToGroup: (groupName: string): string => `add panel to group ${groupName}`,\n deleteGroup: (groupName: string): string => `delete group ${groupName}`,\n editGroup: (groupName: string): string => `edit group ${groupName}`,\n moveGroupDown: (groupName: string): string => `move group ${groupName} down`,\n moveGroupUp: (groupName: string): string => `move group ${groupName} up`,\n // Panel buttons\n viewPanel: (panelName
|
|
1
|
+
{"version":3,"sources":["../../src/constants/user-interface-text.ts"],"sourcesContent":["// Copyright 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 const TOOLTIP_TEXT = {\n // Toolbar buttons\n addPanel: 'Add panel',\n addGroup: 'Add panel group',\n editDatasources: 'Edit datasources',\n editJson: 'Edit JSON',\n editVariables: 'Edit variables',\n viewJson: 'View JSON',\n // Group buttons\n addPanelToGroup: 'Add panel to group',\n deleteGroup: 'Delete group',\n editGroup: 'Edit group',\n moveGroupDown: 'Move group down',\n moveGroupUp: 'Move group up',\n // Panel buttons\n viewPanel: 'Toggle View Mode',\n editPanel: 'Edit',\n duplicatePanel: 'Duplicate',\n deletePanel: 'Delete',\n movePanel: 'Move',\n // Variable editor buttons\n refreshVariableValues: 'Refresh values',\n copyVariableValues: 'Copy values to clipboard',\n queryView: 'Open query view',\n};\n\nexport const ARIA_LABEL_TEXT = {\n // Group buttons\n addPanelToGroup: (groupName: string): string => `add panel to group ${groupName}`,\n deleteGroup: (groupName: string): string => `delete group ${groupName}`,\n editGroup: (groupName: string): string => `edit group ${groupName}`,\n moveGroupDown: (groupName: string): string => `move group ${groupName} down`,\n moveGroupUp: (groupName: string): string => `move group ${groupName} up`,\n // Panel buttons\n viewPanel: (panelName?: string): string =>\n panelName ? `toggle panel ${panelName} view mode` : 'toggle panel view mode',\n editPanel: (panelName?: string): string => (panelName ? `edit panel ${panelName}` : 'edit panel'),\n duplicatePanel: (panelName?: string): string => (panelName ? `duplicate panel ${panelName}` : 'duplicate panel'),\n deletePanel: (panelName?: string): string => (panelName ? `delete panel ${panelName}` : 'delete panel'),\n showPanelActions: (panelName?: string): string =>\n panelName ? `show panel actions for ${panelName}` : 'show panel actions',\n movePanel: (panelName?: string): string => (panelName ? `move panel ${panelName}` : 'move panel'),\n openQueryView: (panelName?: string): string =>\n panelName ? `open query view for panel ${panelName}` : 'open query view for panel',\n};\n"],"names":["TOOLTIP_TEXT","addPanel","addGroup","editDatasources","editJson","editVariables","viewJson","addPanelToGroup","deleteGroup","editGroup","moveGroupDown","moveGroupUp","viewPanel","editPanel","duplicatePanel","deletePanel","movePanel","refreshVariableValues","copyVariableValues","queryView","ARIA_LABEL_TEXT","groupName","panelName","showPanelActions","openQueryView"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,MAAMA,eAAe;IAC1B,kBAAkB;IAClBC,UAAU;IACVC,UAAU;IACVC,iBAAiB;IACjBC,UAAU;IACVC,eAAe;IACfC,UAAU;IACV,gBAAgB;IAChBC,iBAAiB;IACjBC,aAAa;IACbC,WAAW;IACXC,eAAe;IACfC,aAAa;IACb,gBAAgB;IAChBC,WAAW;IACXC,WAAW;IACXC,gBAAgB;IAChBC,aAAa;IACbC,WAAW;IACX,0BAA0B;IAC1BC,uBAAuB;IACvBC,oBAAoB;IACpBC,WAAW;AACb,EAAE;AAEF,OAAO,MAAMC,kBAAkB;IAC7B,gBAAgB;IAChBb,iBAAiB,CAACc,YAA8B,CAAC,mBAAmB,EAAEA,WAAW;IACjFb,aAAa,CAACa,YAA8B,CAAC,aAAa,EAAEA,WAAW;IACvEZ,WAAW,CAACY,YAA8B,CAAC,WAAW,EAAEA,WAAW;IACnEX,eAAe,CAACW,YAA8B,CAAC,WAAW,EAAEA,UAAU,KAAK,CAAC;IAC5EV,aAAa,CAACU,YAA8B,CAAC,WAAW,EAAEA,UAAU,GAAG,CAAC;IACxE,gBAAgB;IAChBT,WAAW,CAACU,YACVA,YAAY,CAAC,aAAa,EAAEA,UAAU,UAAU,CAAC,GAAG;IACtDT,WAAW,CAACS,YAAgCA,YAAY,CAAC,WAAW,EAAEA,WAAW,GAAG;IACpFR,gBAAgB,CAACQ,YAAgCA,YAAY,CAAC,gBAAgB,EAAEA,WAAW,GAAG;IAC9FP,aAAa,CAACO,YAAgCA,YAAY,CAAC,aAAa,EAAEA,WAAW,GAAG;IACxFC,kBAAkB,CAACD,YACjBA,YAAY,CAAC,uBAAuB,EAAEA,WAAW,GAAG;IACtDN,WAAW,CAACM,YAAgCA,YAAY,CAAC,WAAW,EAAEA,WAAW,GAAG;IACpFE,eAAe,CAACF,YACdA,YAAY,CAAC,0BAA0B,EAAEA,WAAW,GAAG;AAC3D,EAAE"}
|
|
@@ -55,6 +55,7 @@ export declare function useDeletePanelGroupDialog(): {
|
|
|
55
55
|
openDeletePanelGroupDialog: (panelGroupId: PanelGroupId) => void;
|
|
56
56
|
deletePanelGroup: (panelGroupId: PanelGroupId) => void;
|
|
57
57
|
};
|
|
58
|
+
export declare function usePanelKey(panelGroupItemId?: PanelGroupItemId): string | undefined;
|
|
58
59
|
/**
|
|
59
60
|
* Gets an individual panel in the store. Throws if the panel can't be found.
|
|
60
61
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dashboard-provider-api.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/dashboard-provider-api.ts"],"names":[],"mappings":"AAcA,OAAO,EACL,iBA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AWD;;GAEG;AACH,wBAAgB,YAAY,IAAI;IAC9B,YAAY,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;IAC7C,YAAY,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;IAC7C,WAAW,EAAE,cAAc,CAAC,WAAW,CAAC,CAAC,kBAAkB,CAAC,CAAC;CAC9D,CAEA;AAKD;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,gBAAgB,GAAG,SAAS,CAEhE;AAmBD,wBAAgB,gCAAgC,IAAI;IAClD,kCAAkC,EAAE,MAAM,IAAI,CAAC;IAC/C,iCAAiC,EAAE,CAAC,6BAA6B,EAAE,kCAAkC,KAAK,IAAI,CAAC;IAC/G,6BAA6B,EAAE,kCAAkC,GAAG,SAAS,CAAC;CAC/E,CAEA;AAqBD,wBAAgB,mCAAmC,IAAI;IACrD,gCAAgC,EAAE,qCAAqC,GAAG,SAAS,CAAC;IACpF,qCAAqC,EAAE,MAAM,IAAI,CAAC;IAClD,oCAAoC,EAAE,CACpC,gCAAgC,EAAE,qCAAqC,KACpE,IAAI,CAAC;CACX,CAEA;AAWD;;GAEG;AACH,wBAAgB,iBAAiB,IAAI;IACnC,kBAAkB,EAAE,MAAM,IAAI,CAAC;IAC/B,mBAAmB,EAAE,MAAM,IAAI,CAAC;IAChC,cAAc,EAAE,mBAAmB,GAAG,SAAS,CAAC;CACjD,CAEA"}
|
|
1
|
+
{"version":3,"file":"dashboard-provider-api.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/dashboard-provider-api.ts"],"names":[],"mappings":"AAcA,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,0BAA0B,EAC1B,eAAe,EACf,YAAY,EACZ,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAA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AAC,WAAW,CAAC,CAAC,kBAAkB,CAAC,CAAC;CAC9D,CAEA;AAKD;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,gBAAgB,GAAG,SAAS,CAEhE;AAmBD,wBAAgB,gCAAgC,IAAI;IAClD,kCAAkC,EAAE,MAAM,IAAI,CAAC;IAC/C,iCAAiC,EAAE,CAAC,6BAA6B,EAAE,kCAAkC,KAAK,IAAI,CAAC;IAC/G,6BAA6B,EAAE,kCAAkC,GAAG,SAAS,CAAC;CAC/E,CAEA;AAqBD,wBAAgB,mCAAmC,IAAI;IACrD,gCAAgC,EAAE,qCAAqC,GAAG,SAAS,CAAC;IACpF,qCAAqC,EAAE,MAAM,IAAI,CAAC;IAClD,oCAAoC,EAAE,CACpC,gCAAgC,EAAE,qCAAqC,KACpE,IAAI,CAAC;CACX,CAEA;AAWD;;GAEG;AACH,wBAAgB,iBAAiB,IAAI;IACnC,kBAAkB,EAAE,MAAM,IAAI,CAAC;IAC/B,mBAAmB,EAAE,MAAM,IAAI,CAAC;IAChC,cAAc,EAAE,mBAAmB,GAAG,SAAS,CAAC;CACjD,CAEA"}
|
|
@@ -134,6 +134,17 @@ const selectDeletePanelGroupDialog = ({ deletePanelGroupDialog, openDeletePanelG
|
|
|
134
134
|
closeDeletePanelGroupDialog: ()=>closeDeletePanelGroupDialog()
|
|
135
135
|
};
|
|
136
136
|
}
|
|
137
|
+
export function usePanelKey(panelGroupItemId) {
|
|
138
|
+
const panelKey = useDashboardStore(useCallback((store)=>{
|
|
139
|
+
if (panelGroupItemId === undefined) {
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
142
|
+
return store.panelGroups[panelGroupItemId.panelGroupId]?.itemPanelKeys[panelGroupItemId.panelGroupItemLayoutId];
|
|
143
|
+
}, [
|
|
144
|
+
panelGroupItemId
|
|
145
|
+
]));
|
|
146
|
+
return panelKey;
|
|
147
|
+
}
|
|
137
148
|
/**
|
|
138
149
|
* Gets an individual panel in the store. Throws if the panel can't be found.
|
|
139
150
|
*/ export function usePanel(panelGroupItemId) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/context/DashboardProvider/dashboard-provider-api.ts"],"sourcesContent":["// Copyright 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 { useCallback, useMemo } from 'react';\nimport {\n DashboardResource,\n DurationString,\n EphemeralDashboardResource,\n PanelDefinition,\n PanelGroupId,\n PanelGroupDefinition,\n PanelGroupItemId,\n PanelGroupItemLayout,\n} from '@perses-dev/core';\nimport { DashboardStoreState, useDashboardStore } from './DashboardProvider';\nimport { DeletePanelGroupDialogState } from './delete-panel-group-slice';\nimport { PanelGroupEditor } from './panel-group-editor-slice';\nimport { PanelEditorState } from './panel-editor-slice';\nimport { DeletePanelDialogState } from './delete-panel-slice';\nimport { SaveChangesConfirmationDialogState } from './save-changes-dialog-slice';\nimport { DiscardChangesConfirmationDialogState } from './discard-changes-dialog-slice';\nimport { EditJsonDialogState } from './edit-json-dialog-slice';\nimport { ViewPanelSlice } from './view-panel-slice';\n\nconst selectEditMode: ({ isEditMode, setEditMode }: DashboardStoreState) => {\n setEditMode: (isEditMode: boolean) => void;\n isEditMode: boolean;\n} = ({ isEditMode, setEditMode }: DashboardStoreState) => ({ isEditMode, setEditMode });\nexport function useEditMode(): { setEditMode: (isEditMode: boolean) => void; isEditMode: boolean } {\n return useDashboardStore(selectEditMode);\n}\n\nconst selectDashboardActions: ({ setDashboard, openAddPanelGroup, openAddPanel }: DashboardStoreState) => {\n openAddPanelGroup: () => void;\n openAddPanel: (panelGroupId?: PanelGroupId) => void;\n setDashboard: (dashboard: DashboardResource | EphemeralDashboardResource) => void;\n} = ({ setDashboard, openAddPanelGroup, openAddPanel }: DashboardStoreState) => ({\n setDashboard,\n openAddPanelGroup,\n openAddPanel,\n});\n/**\n * Returns actions that can be performed on the current dashboard.\n */\nexport function useDashboardActions(): {\n openAddPanelGroup: () => void;\n openAddPanel: () => void;\n setDashboard: (dashboard: DashboardResource | EphemeralDashboardResource) => void;\n} {\n const { setDashboard, openAddPanelGroup, openAddPanel } = useDashboardStore(selectDashboardActions);\n return {\n setDashboard,\n openAddPanelGroup: () => openAddPanelGroup(),\n openAddPanel: () => openAddPanel(),\n };\n}\n\nconst selectPanelGroupOrder = (state: DashboardStoreState): number[] => state.panelGroupOrder;\n/**\n * Returns an array of PanelGroupIds in the order they appear in the dashboard.\n */\nexport function usePanelGroupIds(): number[] {\n return useDashboardStore(selectPanelGroupOrder);\n}\n\nconst selectPanelGroups: (state: DashboardStoreState) => Record<number, PanelGroupDefinition> = (\n state: DashboardStoreState\n) => state.panelGroups;\n/**\n * Returns an array of PanelGroupDefinitions in the order they appear in the dashboard.\n */\nexport function useListPanelGroups(): PanelGroupDefinition[] {\n const panelGroupIds = usePanelGroupIds();\n const panelGroups = useDashboardStore(selectPanelGroups);\n return useMemo(() => {\n return panelGroupIds.map((id) => {\n const group = panelGroups[id];\n if (group === undefined) {\n throw new Error(`Invalid panel group Id found ${id}`);\n }\n return group;\n });\n }, [panelGroupIds, panelGroups]);\n}\n\n/**\n * Gets a specific panel group by its id. Throws if the panel group does not exist.\n */\nexport function usePanelGroup(panelGroupId: PanelGroupId): PanelGroupDefinition {\n const panelGroup = useDashboardStore(useCallback((state) => state.panelGroups[panelGroupId], [panelGroupId]));\n if (panelGroup === undefined) {\n throw new Error(`Panel group with Id ${panelGroupId} was not found`);\n }\n return panelGroup;\n}\n\nconst selectPanelGroupActions: ({\n openEditPanelGroup,\n deletePanelGroup,\n openAddPanel,\n updatePanelGroupLayouts,\n}: DashboardStoreState) => {\n updatePanelGroupLayouts: (panelGroupId: PanelGroupId, itemLayouts: PanelGroupDefinition['itemLayouts']) => void;\n openEditPanelGroup: (panelGroupId: PanelGroupId) => void;\n openAddPanel: (panelGroupId?: PanelGroupId) => void;\n deletePanelGroup: (panelGroupId: PanelGroupId) => void;\n} = ({ openEditPanelGroup, deletePanelGroup, openAddPanel, updatePanelGroupLayouts }: DashboardStoreState) => ({\n openEditPanelGroup,\n deletePanelGroup,\n openAddPanel,\n updatePanelGroupLayouts,\n});\n/**\n * Returns actions that can be performed on the given panel group.\n */\nexport function usePanelGroupActions(panelGroupId: PanelGroupId): {\n updatePanelGroupLayouts: (itemLayouts: PanelGroupItemLayout[]) => void;\n openEditPanelGroup: () => void;\n openAddPanel: () => void;\n moveDown: (() => void) | undefined;\n deletePanelGroup: () => void;\n moveUp: (() => void) | undefined;\n} {\n const { moveUp, moveDown } = useMovePanelGroup(panelGroupId);\n const { openEditPanelGroup, deletePanelGroup, openAddPanel, updatePanelGroupLayouts } =\n useDashboardStore(selectPanelGroupActions);\n\n return {\n openEditPanelGroup: () => openEditPanelGroup(panelGroupId),\n deletePanelGroup: () => deletePanelGroup(panelGroupId),\n openAddPanel: () => openAddPanel(panelGroupId),\n moveUp,\n moveDown,\n updatePanelGroupLayouts: (itemLayouts: PanelGroupItemLayout[]) =>\n updatePanelGroupLayouts(panelGroupId, itemLayouts),\n };\n}\n\nconst selectSwapPanelGroups: (state: DashboardStoreState) => (xIndex: number, yIndex: number) => void = (\n state: DashboardStoreState\n) => state.swapPanelGroups;\nconst selectPanelGroupsLength: (state: DashboardStoreState) => number = (state: DashboardStoreState) =>\n state.panelGroupOrder.length;\n/**\n * Returns functions for moving a panel group up or down. A function will be undefined if the panel group can't be\n * moved in that direction.\n */\nfunction useMovePanelGroup(panelGroupId: PanelGroupId): {\n moveDown: (() => void) | undefined;\n moveUp: (() => void) | undefined;\n} {\n const currentIndex = useDashboardStore(\n useCallback((store) => store.panelGroupOrder.findIndex((id) => id === panelGroupId), [panelGroupId])\n );\n const panelGroupsLength = useDashboardStore(selectPanelGroupsLength);\n const swapPanelGroups = useDashboardStore(selectSwapPanelGroups);\n\n if (currentIndex < 0) {\n throw new Error(`Could not find panel group with Id ${panelGroupId} in order array`);\n }\n\n const moveUp: () => void = () => swapPanelGroups(currentIndex, currentIndex - 1);\n const moveDown: () => void = () => swapPanelGroups(currentIndex, currentIndex + 1);\n return {\n moveUp: currentIndex > 0 ? moveUp : undefined,\n moveDown: currentIndex < panelGroupsLength - 1 ? moveDown : undefined,\n };\n}\n\nconst selectPanelGroupEditor: (state: DashboardStoreState) => PanelGroupEditor | undefined = (\n state: DashboardStoreState\n) => state.panelGroupEditor;\n/**\n * Gets the Panel Group editor state.\n */\nexport function usePanelGroupEditor(): PanelGroupEditor | undefined {\n return useDashboardStore(selectPanelGroupEditor);\n}\n\nconst selectDeletePanelGroupDialog: ({\n deletePanelGroupDialog,\n openDeletePanelGroupDialog,\n closeDeletePanelGroupDialog,\n deletePanelGroup,\n}: DashboardStoreState) => {\n deletePanelGroupDialog: DeletePanelGroupDialogState | undefined;\n closeDeletePanelGroupDialog: () => void;\n openDeletePanelGroupDialog: (panelGroupId: PanelGroupId) => void;\n deletePanelGroup: (panelGroupId: PanelGroupId) => void;\n} = ({\n deletePanelGroupDialog,\n openDeletePanelGroupDialog,\n closeDeletePanelGroupDialog,\n deletePanelGroup,\n}: DashboardStoreState) => ({\n deletePanelGroupDialog,\n openDeletePanelGroupDialog,\n closeDeletePanelGroupDialog,\n deletePanelGroup,\n});\n/**\n * Gets the Delete Panel Group dialog state.\n */\nexport function useDeletePanelGroupDialog(): {\n deletePanelGroupDialog: DeletePanelGroupDialogState | undefined;\n closeDeletePanelGroupDialog: () => void;\n openDeletePanelGroupDialog: (panelGroupId: PanelGroupId) => void;\n deletePanelGroup: (panelGroupId: PanelGroupId) => void;\n} {\n const { deletePanelGroupDialog, openDeletePanelGroupDialog, closeDeletePanelGroupDialog, deletePanelGroup } =\n useDashboardStore(selectDeletePanelGroupDialog);\n return {\n deletePanelGroupDialog,\n deletePanelGroup,\n openDeletePanelGroupDialog,\n closeDeletePanelGroupDialog: () => closeDeletePanelGroupDialog(),\n };\n}\n\n/**\n * Gets an individual panel in the store. Throws if the panel can't be found.\n */\nexport function usePanel(panelGroupItemId: PanelGroupItemId): PanelDefinition {\n const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;\n const panel = useDashboardStore(\n useCallback(\n (store) => {\n const panelKey = store.panelGroups[panelGroupId]?.itemPanelKeys[panelGroupLayoutId];\n if (panelKey === undefined) return;\n return store.panels[panelKey];\n },\n [panelGroupId, panelGroupLayoutId]\n )\n );\n\n if (panel === undefined) {\n throw new Error(`Could not find panel for Id ${panelGroupItemId}`);\n }\n return panel;\n}\n\nconst selectPanelActions: ({\n openEditPanel,\n openDeletePanelDialog,\n duplicatePanel,\n setViewPanel,\n}: DashboardStoreState) => {\n openDeletePanelDialog: (panelGroupItemId: PanelGroupItemId) => void;\n duplicatePanel: (panelGroupItemId: PanelGroupItemId) => void;\n openEditPanel: (panelGroupItemId: PanelGroupItemId) => void;\n setViewPanel: (panelGroupItemId?: PanelGroupItemId) => void;\n} = ({ openEditPanel, openDeletePanelDialog, duplicatePanel, setViewPanel }: DashboardStoreState) => ({\n openEditPanel,\n openDeletePanelDialog,\n duplicatePanel,\n setViewPanel,\n});\n\n/**\n * Returns actions that can be performed on the given Panel.\n */\nexport function usePanelActions(panelGroupItemId: PanelGroupItemId): {\n openDeletePanelDialog: () => void;\n duplicatePanel: () => void;\n openEditPanel: () => void;\n viewPanel: (panelGroupItemId?: PanelGroupItemId) => void;\n} {\n const { openEditPanel, openDeletePanelDialog, duplicatePanel, setViewPanel } = useDashboardStore(selectPanelActions);\n return {\n openEditPanel: () => openEditPanel(panelGroupItemId),\n openDeletePanelDialog: () => openDeletePanelDialog(panelGroupItemId),\n duplicatePanel: () => duplicatePanel(panelGroupItemId),\n viewPanel: (panelGroupItemId?: PanelGroupItemId) => setViewPanel(panelGroupItemId),\n };\n}\n\nconst selectPanelEditor: (state: DashboardStoreState) => PanelEditorState | undefined = (state: DashboardStoreState) =>\n state.panelEditor;\n/**\n * Gets the state for the Panel Editor.\n */\nexport function usePanelEditor(): PanelEditorState | undefined {\n return useDashboardStore(selectPanelEditor);\n}\n\nconst selectDeletePanelDialog: ({ deletePanelDialog, deletePanel, closeDeletePanelDialog }: DashboardStoreState) => {\n deletePanelDialog: DeletePanelDialogState | undefined;\n closeDeletePanelDialog: () => void;\n deletePanel: (panelGroupItemId: PanelGroupItemId) => void;\n} = ({ deletePanelDialog, deletePanel, closeDeletePanelDialog }: DashboardStoreState) => ({\n deletePanelDialog,\n deletePanel,\n closeDeletePanelDialog,\n});\n\n/**\n * Gets the state for the Delete Panel dialog.\n */\nexport function useDeletePanelDialog(): {\n deletePanelDialog: DeletePanelDialogState | undefined;\n closeDeletePanelDialog: () => void;\n deletePanel: (panelGroupItemId: PanelGroupItemId) => void;\n} {\n // TODO: Refactor similar to other dialogs/editors so these are on the editor state itself\n return useDashboardStore(selectDeletePanelDialog);\n}\n\nconst selectDashboardDuration: (state: DashboardStoreState) => DurationString = (state: DashboardStoreState) =>\n state.duration;\nexport function useDashboardDuration(): DurationString {\n return useDashboardStore(selectDashboardDuration);\n}\n\nconst selectViewPanel: (state: DashboardStoreState) => {\n setViewPanel: DashboardStoreState['setViewPanel'];\n getViewPanel: DashboardStoreState['getViewPanel'];\n viewPanelId: DashboardStoreState['viewPanel']['panelGroupItemId'];\n} = (state: DashboardStoreState) => ({\n setViewPanel: state.setViewPanel,\n getViewPanel: state.getViewPanel,\n viewPanelId: state.getViewPanel(),\n});\n/**\n * Returns actions related to the ViewPanel.\n */\nexport function useViewPanel(): {\n setViewPanel: ViewPanelSlice['setViewPanel'];\n getViewPanel: ViewPanelSlice['getViewPanel'];\n viewPanelId: ViewPanelSlice['viewPanel']['panelGroupItemId'];\n} {\n return useDashboardStore(selectViewPanel);\n}\n\nconst selectViewPanelGroup: (state: DashboardStoreState) => PanelGroupItemId | undefined = (\n state: DashboardStoreState\n) => state.getViewPanel();\n/**\n * Gets the Panel Group for the view panel.\n */\nexport function useViewPanelGroup(): PanelGroupItemId | undefined {\n return useDashboardStore(selectViewPanelGroup);\n}\n\nconst selectSaveChangesConfirmationDialog: ({\n saveChangesConfirmationDialog,\n openSaveChangesConfirmationDialog,\n closeSaveChangesConfirmationDialog,\n}: DashboardStoreState) => {\n closeSaveChangesConfirmationDialog: () => void;\n openSaveChangesConfirmationDialog: (saveChangesConfirmationDialog: SaveChangesConfirmationDialogState) => void;\n saveChangesConfirmationDialog: SaveChangesConfirmationDialogState | undefined;\n} = ({\n saveChangesConfirmationDialog,\n openSaveChangesConfirmationDialog,\n closeSaveChangesConfirmationDialog,\n}: DashboardStoreState) => ({\n saveChangesConfirmationDialog,\n openSaveChangesConfirmationDialog,\n closeSaveChangesConfirmationDialog,\n});\nexport function useSaveChangesConfirmationDialog(): {\n closeSaveChangesConfirmationDialog: () => void;\n openSaveChangesConfirmationDialog: (saveChangesConfirmationDialog: SaveChangesConfirmationDialogState) => void;\n saveChangesConfirmationDialog: SaveChangesConfirmationDialogState | undefined;\n} {\n return useDashboardStore(selectSaveChangesConfirmationDialog);\n}\n\nconst selectDiscardChangesConfirmationDialog: ({\n discardChangesConfirmationDialog,\n openDiscardChangesConfirmationDialog,\n closeDiscardChangesConfirmationDialog,\n}: DashboardStoreState) => {\n discardChangesConfirmationDialog: DiscardChangesConfirmationDialogState | undefined;\n closeDiscardChangesConfirmationDialog: () => void;\n openDiscardChangesConfirmationDialog: (\n discardChangesConfirmationDialog: DiscardChangesConfirmationDialogState\n ) => void;\n} = ({\n discardChangesConfirmationDialog,\n openDiscardChangesConfirmationDialog,\n closeDiscardChangesConfirmationDialog,\n}: DashboardStoreState) => ({\n discardChangesConfirmationDialog,\n openDiscardChangesConfirmationDialog,\n closeDiscardChangesConfirmationDialog,\n});\nexport function useDiscardChangesConfirmationDialog(): {\n discardChangesConfirmationDialog: DiscardChangesConfirmationDialogState | undefined;\n closeDiscardChangesConfirmationDialog: () => void;\n openDiscardChangesConfirmationDialog: (\n discardChangesConfirmationDialog: DiscardChangesConfirmationDialogState\n ) => void;\n} {\n return useDashboardStore(selectDiscardChangesConfirmationDialog);\n}\n\nconst selectEditJsonDialog: ({ editJsonDialog, openEditJsonDialog, closeEditJsonDialog }: DashboardStoreState) => {\n openEditJsonDialog: () => void;\n closeEditJsonDialog: () => void;\n editJsonDialog: EditJsonDialogState | undefined;\n} = ({ editJsonDialog, openEditJsonDialog, closeEditJsonDialog }: DashboardStoreState) => ({\n editJsonDialog,\n openEditJsonDialog,\n closeEditJsonDialog,\n});\n/**\n * Gets the state for the edit JSON dialog.\n */\nexport function useEditJsonDialog(): {\n openEditJsonDialog: () => void;\n closeEditJsonDialog: () => void;\n editJsonDialog: EditJsonDialogState | undefined;\n} {\n return useDashboardStore(selectEditJsonDialog);\n}\n"],"names":["useCallback","useMemo","useDashboardStore","selectEditMode","isEditMode","setEditMode","useEditMode","selectDashboardActions","setDashboard","openAddPanelGroup","openAddPanel","useDashboardActions","selectPanelGroupOrder","state","panelGroupOrder","usePanelGroupIds","selectPanelGroups","panelGroups","useListPanelGroups","panelGroupIds","map","id","group","undefined","Error","usePanelGroup","panelGroupId","panelGroup","selectPanelGroupActions","openEditPanelGroup","deletePanelGroup","updatePanelGroupLayouts","usePanelGroupActions","moveUp","moveDown","useMovePanelGroup","itemLayouts","selectSwapPanelGroups","swapPanelGroups","selectPanelGroupsLength","length","currentIndex","store","findIndex","panelGroupsLength","selectPanelGroupEditor","panelGroupEditor","usePanelGroupEditor","selectDeletePanelGroupDialog","deletePanelGroupDialog","openDeletePanelGroupDialog","closeDeletePanelGroupDialog","useDeletePanelGroupDialog","usePanel","panelGroupItemId","panelGroupItemLayoutId","panelGroupLayoutId","panel","panelKey","itemPanelKeys","panels","selectPanelActions","openEditPanel","openDeletePanelDialog","duplicatePanel","setViewPanel","usePanelActions","viewPanel","selectPanelEditor","panelEditor","usePanelEditor","selectDeletePanelDialog","deletePanelDialog","deletePanel","closeDeletePanelDialog","useDeletePanelDialog","selectDashboardDuration","duration","useDashboardDuration","selectViewPanel","getViewPanel","viewPanelId","useViewPanel","selectViewPanelGroup","useViewPanelGroup","selectSaveChangesConfirmationDialog","saveChangesConfirmationDialog","openSaveChangesConfirmationDialog","closeSaveChangesConfirmationDialog","useSaveChangesConfirmationDialog","selectDiscardChangesConfirmationDialog","discardChangesConfirmationDialog","openDiscardChangesConfirmationDialog","closeDiscardChangesConfirmationDialog","useDiscardChangesConfirmationDialog","selectEditJsonDialog","editJsonDialog","openEditJsonDialog","closeEditJsonDialog","useEditJsonDialog"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,WAAW,EAAEC,OAAO,QAAQ,QAAQ;AAW7C,SAA8BC,iBAAiB,QAAQ,sBAAsB;AAU7E,MAAMC,iBAGF,CAAC,EAAEC,UAAU,EAAEC,WAAW,EAAuB,GAAM,CAAA;QAAED;QAAYC;IAAY,CAAA;AACrF,OAAO,SAASC;IACd,OAAOJ,kBAAkBC;AAC3B;AAEA,MAAMI,yBAIF,CAAC,EAAEC,YAAY,EAAEC,iBAAiB,EAAEC,YAAY,EAAuB,GAAM,CAAA;QAC/EF;QACAC;QACAC;IACF,CAAA;AACA;;CAEC,GACD,OAAO,SAASC;IAKd,MAAM,EAAEH,YAAY,EAAEC,iBAAiB,EAAEC,YAAY,EAAE,GAAGR,kBAAkBK;IAC5E,OAAO;QACLC;QACAC,mBAAmB,IAAMA;QACzBC,cAAc,IAAMA;IACtB;AACF;AAEA,MAAME,wBAAwB,CAACC,QAAyCA,MAAMC,eAAe;AAC7F;;CAEC,GACD,OAAO,SAASC;IACd,OAAOb,kBAAkBU;AAC3B;AAE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,CAAA;AACA;;CAEC,GACD,OAAO,SAASE;IAKd,OAAOhF,kBAAkB6E;AAC3B;AAEA,MAAMI,uBAAqF,CACzFtE,QACGA,MAAMmE,YAAY;AACvB;;CAEC,GACD,OAAO,SAASI;IACd,OAAOlF,kBAAkBiF;AAC3B;AAEA,MAAME,sCAQF,CAAC,EACHC,6BAA6B,EAC7BC,iCAAiC,EACjCC,kCAAkC,EACd,GAAM,CAAA;QAC1BF;QACAC;QACAC;IACF,CAAA;AACA,OAAO,SAASC;IAKd,OAAOvF,kBAAkBmF;AAC3B;AAEA,MAAMK,yCAUF,CAAC,EACHC,gCAAgC,EAChCC,oCAAoC,EACpCC,qCAAqC,EACjB,GAAM,CAAA;QAC1BF;QACAC;QACAC;IACF,CAAA;AACA,OAAO,SAASC;IAOd,OAAO5F,kBAAkBwF;AAC3B;AAEA,MAAMK,uBAIF,CAAC,EAAEC,cAAc,EAAEC,kBAAkB,EAAEC,mBAAmB,EAAuB,GAAM,CAAA;QACzFF;QACAC;QACAC;IACF,CAAA;AACA;;CAEC,GACD,OAAO,SAASC;IAKd,OAAOjG,kBAAkB6F;AAC3B"}
|
|
1
|
+
{"version":3,"sources":["../../../src/context/DashboardProvider/dashboard-provider-api.ts"],"sourcesContent":["// Copyright 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 { useCallback, useMemo } from 'react';\nimport {\n DashboardResource,\n DurationString,\n EphemeralDashboardResource,\n PanelDefinition,\n PanelGroupId,\n PanelGroupDefinition,\n PanelGroupItemId,\n PanelGroupItemLayout,\n} from '@perses-dev/core';\nimport { DashboardStoreState, useDashboardStore } from './DashboardProvider';\nimport { DeletePanelGroupDialogState } from './delete-panel-group-slice';\nimport { PanelGroupEditor } from './panel-group-editor-slice';\nimport { PanelEditorState } from './panel-editor-slice';\nimport { DeletePanelDialogState } from './delete-panel-slice';\nimport { SaveChangesConfirmationDialogState } from './save-changes-dialog-slice';\nimport { DiscardChangesConfirmationDialogState } from './discard-changes-dialog-slice';\nimport { EditJsonDialogState } from './edit-json-dialog-slice';\nimport { ViewPanelSlice } from './view-panel-slice';\n\nconst selectEditMode: ({ isEditMode, setEditMode }: DashboardStoreState) => {\n setEditMode: (isEditMode: boolean) => void;\n isEditMode: boolean;\n} = ({ isEditMode, setEditMode }: DashboardStoreState) => ({ isEditMode, setEditMode });\nexport function useEditMode(): { setEditMode: (isEditMode: boolean) => void; isEditMode: boolean } {\n return useDashboardStore(selectEditMode);\n}\n\nconst selectDashboardActions: ({ setDashboard, openAddPanelGroup, openAddPanel }: DashboardStoreState) => {\n openAddPanelGroup: () => void;\n openAddPanel: (panelGroupId?: PanelGroupId) => void;\n setDashboard: (dashboard: DashboardResource | EphemeralDashboardResource) => void;\n} = ({ setDashboard, openAddPanelGroup, openAddPanel }: DashboardStoreState) => ({\n setDashboard,\n openAddPanelGroup,\n openAddPanel,\n});\n/**\n * Returns actions that can be performed on the current dashboard.\n */\nexport function useDashboardActions(): {\n openAddPanelGroup: () => void;\n openAddPanel: () => void;\n setDashboard: (dashboard: DashboardResource | EphemeralDashboardResource) => void;\n} {\n const { setDashboard, openAddPanelGroup, openAddPanel } = useDashboardStore(selectDashboardActions);\n return {\n setDashboard,\n openAddPanelGroup: () => openAddPanelGroup(),\n openAddPanel: () => openAddPanel(),\n };\n}\n\nconst selectPanelGroupOrder = (state: DashboardStoreState): number[] => state.panelGroupOrder;\n/**\n * Returns an array of PanelGroupIds in the order they appear in the dashboard.\n */\nexport function usePanelGroupIds(): number[] {\n return useDashboardStore(selectPanelGroupOrder);\n}\n\nconst selectPanelGroups: (state: DashboardStoreState) => Record<number, PanelGroupDefinition> = (\n state: DashboardStoreState\n) => state.panelGroups;\n/**\n * Returns an array of PanelGroupDefinitions in the order they appear in the dashboard.\n */\nexport function useListPanelGroups(): PanelGroupDefinition[] {\n const panelGroupIds = usePanelGroupIds();\n const panelGroups = useDashboardStore(selectPanelGroups);\n return useMemo(() => {\n return panelGroupIds.map((id) => {\n const group = panelGroups[id];\n if (group === undefined) {\n throw new Error(`Invalid panel group Id found ${id}`);\n }\n return group;\n });\n }, [panelGroupIds, panelGroups]);\n}\n\n/**\n * Gets a specific panel group by its id. Throws if the panel group does not exist.\n */\nexport function usePanelGroup(panelGroupId: PanelGroupId): PanelGroupDefinition {\n const panelGroup = useDashboardStore(useCallback((state) => state.panelGroups[panelGroupId], [panelGroupId]));\n if (panelGroup === undefined) {\n throw new Error(`Panel group with Id ${panelGroupId} was not found`);\n }\n return panelGroup;\n}\n\nconst selectPanelGroupActions: ({\n openEditPanelGroup,\n deletePanelGroup,\n openAddPanel,\n updatePanelGroupLayouts,\n}: DashboardStoreState) => {\n updatePanelGroupLayouts: (panelGroupId: PanelGroupId, itemLayouts: PanelGroupDefinition['itemLayouts']) => void;\n openEditPanelGroup: (panelGroupId: PanelGroupId) => void;\n openAddPanel: (panelGroupId?: PanelGroupId) => void;\n deletePanelGroup: (panelGroupId: PanelGroupId) => void;\n} = ({ openEditPanelGroup, deletePanelGroup, openAddPanel, updatePanelGroupLayouts }: DashboardStoreState) => ({\n openEditPanelGroup,\n deletePanelGroup,\n openAddPanel,\n updatePanelGroupLayouts,\n});\n/**\n * Returns actions that can be performed on the given panel group.\n */\nexport function usePanelGroupActions(panelGroupId: PanelGroupId): {\n updatePanelGroupLayouts: (itemLayouts: PanelGroupItemLayout[]) => void;\n openEditPanelGroup: () => void;\n openAddPanel: () => void;\n moveDown: (() => void) | undefined;\n deletePanelGroup: () => void;\n moveUp: (() => void) | undefined;\n} {\n const { moveUp, moveDown } = useMovePanelGroup(panelGroupId);\n const { openEditPanelGroup, deletePanelGroup, openAddPanel, updatePanelGroupLayouts } =\n useDashboardStore(selectPanelGroupActions);\n\n return {\n openEditPanelGroup: () => openEditPanelGroup(panelGroupId),\n deletePanelGroup: () => deletePanelGroup(panelGroupId),\n openAddPanel: () => openAddPanel(panelGroupId),\n moveUp,\n moveDown,\n updatePanelGroupLayouts: (itemLayouts: PanelGroupItemLayout[]) =>\n updatePanelGroupLayouts(panelGroupId, itemLayouts),\n };\n}\n\nconst selectSwapPanelGroups: (state: DashboardStoreState) => (xIndex: number, yIndex: number) => void = (\n state: DashboardStoreState\n) => state.swapPanelGroups;\nconst selectPanelGroupsLength: (state: DashboardStoreState) => number = (state: DashboardStoreState) =>\n state.panelGroupOrder.length;\n/**\n * Returns functions for moving a panel group up or down. A function will be undefined if the panel group can't be\n * moved in that direction.\n */\nfunction useMovePanelGroup(panelGroupId: PanelGroupId): {\n moveDown: (() => void) | undefined;\n moveUp: (() => void) | undefined;\n} {\n const currentIndex = useDashboardStore(\n useCallback((store) => store.panelGroupOrder.findIndex((id) => id === panelGroupId), [panelGroupId])\n );\n const panelGroupsLength = useDashboardStore(selectPanelGroupsLength);\n const swapPanelGroups = useDashboardStore(selectSwapPanelGroups);\n\n if (currentIndex < 0) {\n throw new Error(`Could not find panel group with Id ${panelGroupId} in order array`);\n }\n\n const moveUp: () => void = () => swapPanelGroups(currentIndex, currentIndex - 1);\n const moveDown: () => void = () => swapPanelGroups(currentIndex, currentIndex + 1);\n return {\n moveUp: currentIndex > 0 ? moveUp : undefined,\n moveDown: currentIndex < panelGroupsLength - 1 ? moveDown : undefined,\n };\n}\n\nconst selectPanelGroupEditor: (state: DashboardStoreState) => PanelGroupEditor | undefined = (\n state: DashboardStoreState\n) => state.panelGroupEditor;\n/**\n * Gets the Panel Group editor state.\n */\nexport function usePanelGroupEditor(): PanelGroupEditor | undefined {\n return useDashboardStore(selectPanelGroupEditor);\n}\n\nconst selectDeletePanelGroupDialog: ({\n deletePanelGroupDialog,\n openDeletePanelGroupDialog,\n closeDeletePanelGroupDialog,\n deletePanelGroup,\n}: DashboardStoreState) => {\n deletePanelGroupDialog: DeletePanelGroupDialogState | undefined;\n closeDeletePanelGroupDialog: () => void;\n openDeletePanelGroupDialog: (panelGroupId: PanelGroupId) => void;\n deletePanelGroup: (panelGroupId: PanelGroupId) => void;\n} = ({\n deletePanelGroupDialog,\n openDeletePanelGroupDialog,\n closeDeletePanelGroupDialog,\n deletePanelGroup,\n}: DashboardStoreState) => ({\n deletePanelGroupDialog,\n openDeletePanelGroupDialog,\n closeDeletePanelGroupDialog,\n deletePanelGroup,\n});\n/**\n * Gets the Delete Panel Group dialog state.\n */\nexport function useDeletePanelGroupDialog(): {\n deletePanelGroupDialog: DeletePanelGroupDialogState | undefined;\n closeDeletePanelGroupDialog: () => void;\n openDeletePanelGroupDialog: (panelGroupId: PanelGroupId) => void;\n deletePanelGroup: (panelGroupId: PanelGroupId) => void;\n} {\n const { deletePanelGroupDialog, openDeletePanelGroupDialog, closeDeletePanelGroupDialog, deletePanelGroup } =\n useDashboardStore(selectDeletePanelGroupDialog);\n return {\n deletePanelGroupDialog,\n deletePanelGroup,\n openDeletePanelGroupDialog,\n closeDeletePanelGroupDialog: () => closeDeletePanelGroupDialog(),\n };\n}\n\nexport function usePanelKey(panelGroupItemId?: PanelGroupItemId): string | undefined {\n const panelKey = useDashboardStore(\n useCallback(\n (store) => {\n if (panelGroupItemId === undefined) {\n return undefined;\n }\n\n return store.panelGroups[panelGroupItemId.panelGroupId]?.itemPanelKeys[panelGroupItemId.panelGroupItemLayoutId];\n },\n [panelGroupItemId]\n )\n );\n return panelKey;\n}\n\n/**\n * Gets an individual panel in the store. Throws if the panel can't be found.\n */\nexport function usePanel(panelGroupItemId: PanelGroupItemId): PanelDefinition {\n const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;\n const panel = useDashboardStore(\n useCallback(\n (store) => {\n const panelKey = store.panelGroups[panelGroupId]?.itemPanelKeys[panelGroupLayoutId];\n if (panelKey === undefined) return;\n return store.panels[panelKey];\n },\n [panelGroupId, panelGroupLayoutId]\n )\n );\n\n if (panel === undefined) {\n throw new Error(`Could not find panel for Id ${panelGroupItemId}`);\n }\n return panel;\n}\n\nconst selectPanelActions: ({\n openEditPanel,\n openDeletePanelDialog,\n duplicatePanel,\n setViewPanel,\n}: DashboardStoreState) => {\n openDeletePanelDialog: (panelGroupItemId: PanelGroupItemId) => void;\n duplicatePanel: (panelGroupItemId: PanelGroupItemId) => void;\n openEditPanel: (panelGroupItemId: PanelGroupItemId) => void;\n setViewPanel: (panelGroupItemId?: PanelGroupItemId) => void;\n} = ({ openEditPanel, openDeletePanelDialog, duplicatePanel, setViewPanel }: DashboardStoreState) => ({\n openEditPanel,\n openDeletePanelDialog,\n duplicatePanel,\n setViewPanel,\n});\n\n/**\n * Returns actions that can be performed on the given Panel.\n */\nexport function usePanelActions(panelGroupItemId: PanelGroupItemId): {\n openDeletePanelDialog: () => void;\n duplicatePanel: () => void;\n openEditPanel: () => void;\n viewPanel: (panelGroupItemId?: PanelGroupItemId) => void;\n} {\n const { openEditPanel, openDeletePanelDialog, duplicatePanel, setViewPanel } = useDashboardStore(selectPanelActions);\n return {\n openEditPanel: () => openEditPanel(panelGroupItemId),\n openDeletePanelDialog: () => openDeletePanelDialog(panelGroupItemId),\n duplicatePanel: () => duplicatePanel(panelGroupItemId),\n viewPanel: (panelGroupItemId?: PanelGroupItemId) => setViewPanel(panelGroupItemId),\n };\n}\n\nconst selectPanelEditor: (state: DashboardStoreState) => PanelEditorState | undefined = (state: DashboardStoreState) =>\n state.panelEditor;\n/**\n * Gets the state for the Panel Editor.\n */\nexport function usePanelEditor(): PanelEditorState | undefined {\n return useDashboardStore(selectPanelEditor);\n}\n\nconst selectDeletePanelDialog: ({ deletePanelDialog, deletePanel, closeDeletePanelDialog }: DashboardStoreState) => {\n deletePanelDialog: DeletePanelDialogState | undefined;\n closeDeletePanelDialog: () => void;\n deletePanel: (panelGroupItemId: PanelGroupItemId) => void;\n} = ({ deletePanelDialog, deletePanel, closeDeletePanelDialog }: DashboardStoreState) => ({\n deletePanelDialog,\n deletePanel,\n closeDeletePanelDialog,\n});\n\n/**\n * Gets the state for the Delete Panel dialog.\n */\nexport function useDeletePanelDialog(): {\n deletePanelDialog: DeletePanelDialogState | undefined;\n closeDeletePanelDialog: () => void;\n deletePanel: (panelGroupItemId: PanelGroupItemId) => void;\n} {\n // TODO: Refactor similar to other dialogs/editors so these are on the editor state itself\n return useDashboardStore(selectDeletePanelDialog);\n}\n\nconst selectDashboardDuration: (state: DashboardStoreState) => DurationString = (state: DashboardStoreState) =>\n state.duration;\nexport function useDashboardDuration(): DurationString {\n return useDashboardStore(selectDashboardDuration);\n}\n\nconst selectViewPanel: (state: DashboardStoreState) => {\n setViewPanel: DashboardStoreState['setViewPanel'];\n getViewPanel: DashboardStoreState['getViewPanel'];\n viewPanelId: DashboardStoreState['viewPanel']['panelGroupItemId'];\n} = (state: DashboardStoreState) => ({\n setViewPanel: state.setViewPanel,\n getViewPanel: state.getViewPanel,\n viewPanelId: state.getViewPanel(),\n});\n/**\n * Returns actions related to the ViewPanel.\n */\nexport function useViewPanel(): {\n setViewPanel: ViewPanelSlice['setViewPanel'];\n getViewPanel: ViewPanelSlice['getViewPanel'];\n viewPanelId: ViewPanelSlice['viewPanel']['panelGroupItemId'];\n} {\n return useDashboardStore(selectViewPanel);\n}\n\nconst selectViewPanelGroup: (state: DashboardStoreState) => PanelGroupItemId | undefined = (\n state: DashboardStoreState\n) => state.getViewPanel();\n/**\n * Gets the Panel Group for the view panel.\n */\nexport function useViewPanelGroup(): PanelGroupItemId | undefined {\n return useDashboardStore(selectViewPanelGroup);\n}\n\nconst selectSaveChangesConfirmationDialog: ({\n saveChangesConfirmationDialog,\n openSaveChangesConfirmationDialog,\n closeSaveChangesConfirmationDialog,\n}: DashboardStoreState) => {\n closeSaveChangesConfirmationDialog: () => void;\n openSaveChangesConfirmationDialog: (saveChangesConfirmationDialog: SaveChangesConfirmationDialogState) => void;\n saveChangesConfirmationDialog: SaveChangesConfirmationDialogState | undefined;\n} = ({\n saveChangesConfirmationDialog,\n openSaveChangesConfirmationDialog,\n closeSaveChangesConfirmationDialog,\n}: DashboardStoreState) => ({\n saveChangesConfirmationDialog,\n openSaveChangesConfirmationDialog,\n closeSaveChangesConfirmationDialog,\n});\nexport function useSaveChangesConfirmationDialog(): {\n closeSaveChangesConfirmationDialog: () => void;\n openSaveChangesConfirmationDialog: (saveChangesConfirmationDialog: SaveChangesConfirmationDialogState) => void;\n saveChangesConfirmationDialog: SaveChangesConfirmationDialogState | undefined;\n} {\n return useDashboardStore(selectSaveChangesConfirmationDialog);\n}\n\nconst selectDiscardChangesConfirmationDialog: ({\n discardChangesConfirmationDialog,\n openDiscardChangesConfirmationDialog,\n closeDiscardChangesConfirmationDialog,\n}: DashboardStoreState) => {\n discardChangesConfirmationDialog: DiscardChangesConfirmationDialogState | undefined;\n closeDiscardChangesConfirmationDialog: () => void;\n openDiscardChangesConfirmationDialog: (\n discardChangesConfirmationDialog: DiscardChangesConfirmationDialogState\n ) => void;\n} = ({\n discardChangesConfirmationDialog,\n openDiscardChangesConfirmationDialog,\n closeDiscardChangesConfirmationDialog,\n}: DashboardStoreState) => ({\n discardChangesConfirmationDialog,\n openDiscardChangesConfirmationDialog,\n closeDiscardChangesConfirmationDialog,\n});\nexport function useDiscardChangesConfirmationDialog(): {\n discardChangesConfirmationDialog: DiscardChangesConfirmationDialogState | undefined;\n closeDiscardChangesConfirmationDialog: () => void;\n openDiscardChangesConfirmationDialog: (\n discardChangesConfirmationDialog: DiscardChangesConfirmationDialogState\n ) => void;\n} {\n return useDashboardStore(selectDiscardChangesConfirmationDialog);\n}\n\nconst selectEditJsonDialog: ({ editJsonDialog, openEditJsonDialog, closeEditJsonDialog }: DashboardStoreState) => {\n openEditJsonDialog: () => void;\n closeEditJsonDialog: () => void;\n editJsonDialog: EditJsonDialogState | undefined;\n} = ({ editJsonDialog, openEditJsonDialog, closeEditJsonDialog }: DashboardStoreState) => ({\n editJsonDialog,\n openEditJsonDialog,\n closeEditJsonDialog,\n});\n/**\n * Gets the state for the edit JSON dialog.\n */\nexport function useEditJsonDialog(): {\n openEditJsonDialog: () => void;\n closeEditJsonDialog: () => void;\n editJsonDialog: EditJsonDialogState | undefined;\n} {\n return useDashboardStore(selectEditJsonDialog);\n}\n"],"names":["useCallback","useMemo","useDashboardStore","selectEditMode","isEditMode","setEditMode","useEditMode","selectDashboardActions","setDashboard","openAddPanelGroup","openAddPanel","useDashboardActions","selectPanelGroupOrder","state","panelGroupOrder","usePanelGroupIds","selectPanelGroups","panelGroups","useListPanelGroups","panelGroupIds","map","id","group","undefined","Error","usePanelGroup","panelGroupId","panelGroup","selectPanelGroupActions","openEditPanelGroup","deletePanelGroup","updatePanelGroupLayouts","usePanelGroupActions","moveUp","moveDown","useMovePanelGroup","itemLayouts","selectSwapPanelGroups","swapPanelGroups","selectPanelGroupsLength","length","currentIndex","store","findIndex","panelGroupsLength","selectPanelGroupEditor","panelGroupEditor","usePanelGroupEditor","selectDeletePanelGroupDialog","deletePanelGroupDialog","openDeletePanelGroupDialog","closeDeletePanelGroupDialog","useDeletePanelGroupDialog","usePanelKey","panelGroupItemId","panelKey","itemPanelKeys","panelGroupItemLayoutId","usePanel","panelGroupLayoutId","panel","panels","selectPanelActions","openEditPanel","openDeletePanelDialog","duplicatePanel","setViewPanel","usePanelActions","viewPanel","selectPanelEditor","panelEditor","usePanelEditor","selectDeletePanelDialog","deletePanelDialog","deletePanel","closeDeletePanelDialog","useDeletePanelDialog","selectDashboardDuration","duration","useDashboardDuration","selectViewPanel","getViewPanel","viewPanelId","useViewPanel","selectViewPanelGroup","useViewPanelGroup","selectSaveChangesConfirmationDialog","saveChangesConfirmationDialog","openSaveChangesConfirmationDialog","closeSaveChangesConfirmationDialog","useSaveChangesConfirmationDialog","selectDiscardChangesConfirmationDialog","discardChangesConfirmationDialog","openDiscardChangesConfirmationDialog","closeDiscardChangesConfirmationDialog","useDiscardChangesConfirmationDialog","selectEditJsonDialog","editJsonDialog","openEditJsonDialog","closeEditJsonDialog","useEditJsonDialog"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,WAAW,EAAEC,OAAO,QAAQ,QAAQ;AAW7C,SAA8BC,iBAAiB,QAAQ,sBAAsB;AAU7E,MAAMC,iBAGF,CAAC,EAAEC,UAAU,EAAEC,WAAW,EAAuB,GAAM,CAAA;QAAED;QAAYC;IAAY,CAAA;AACrF,OAAO,SAASC;IACd,OAAOJ,kBAAkBC;AAC3B;AAEA,MAAMI,yBAIF,CAAC,EAAEC,YAAY,EAAEC,iBAAiB,EAAEC,YAAY,EAAuB,GAAM,CAAA;QAC/EF;QACAC;QACAC;IACF,CAAA;AACA;;CAEC,GACD,OAAO,SAASC;IAKd,MAAM,EAAEH,YAAY,EAAEC,iBAAiB,EAAEC,YAAY,EAAE,GAAGR,kBAAkBK;IAC5E,OAAO;QACLC;QACAC,mBAAmB,IAAMA;QACzBC,cAAc,IAAMA;IACtB;AACF;AAEA,MAAME,wBAAwB,CAACC,QAAyCA,MAAMC,eAAe;AAC7F;;CAEC,GACD,OAAO,SAASC;IACd,OAAOb,kBAAkBU;AAC3B;AAEA,MAAMI,oBAA0F,CAC9FH,QACGA,MAAMI,WAAW;AACtB;;CAEC,GACD,OAAO,SAASC;IACd,MAAMC,gBAAgBJ;IACtB,MAAME,cAAcf,kBAAkBc;IACtC,OAAOf,QAAQ;QACb,OAAOkB,cAAcC,GAAG,CAAC,CAACC;YACxB,MAAMC,QAAQL,WAAW,CAACI,GAAG;YAC7B,IAAIC,UAAUC,WAAW;gBACvB,MAAM,IAAIC,MAAM,CAAC,6BAA6B,EAAEH,IAAI;YACtD;YACA,OAAOC;QACT;IACF,GAAG;QAAC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AMI,uBAAqF,CACzFvE,QACGA,MAAMoE,YAAY;AACvB;;CAEC,GACD,OAAO,SAASI;IACd,OAAOnF,kBAAkBkF;AAC3B;AAEA,MAAME,sCAQF,CAAC,EACHC,6BAA6B,EAC7BC,iCAAiC,EACjCC,kCAAkC,EACd,GAAM,CAAA;QAC1BF;QACAC;QACAC;IACF,CAAA;AACA,OAAO,SAASC;IAKd,OAAOxF,kBAAkBoF;AAC3B;AAEA,MAAMK,yCAUF,CAAC,EACHC,gCAAgC,EAChCC,oCAAoC,EACpCC,qCAAqC,EACjB,GAAM,CAAA;QAC1BF;QACAC;QACAC;IACF,CAAA;AACA,OAAO,SAASC;IAOd,OAAO7F,kBAAkByF;AAC3B;AAEA,MAAMK,uBAIF,CAAC,EAAEC,cAAc,EAAEC,kBAAkB,EAAEC,mBAAmB,EAAuB,GAAM,CAAA;QACzFF;QACAC;QACAC;IACF,CAAA;AACA;;CAEC,GACD,OAAO,SAASC;IAKd,OAAOlG,kBAAkB8F;AAC3B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@perses-dev/dashboards",
|
|
3
|
-
"version": "0.53.0
|
|
3
|
+
"version": "0.53.0",
|
|
4
4
|
"description": "The dashboards feature in Perses",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/perses/perses/blob/main/README.md",
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"lint:fix": "eslint --fix src --ext .ts,.tsx"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@perses-dev/components": "0.53.0
|
|
33
|
-
"@perses-dev/core": "0.53.0-rc.
|
|
34
|
-
"@perses-dev/plugin-system": "0.53.0
|
|
32
|
+
"@perses-dev/components": "0.53.0",
|
|
33
|
+
"@perses-dev/core": "0.53.0-rc.2",
|
|
34
|
+
"@perses-dev/plugin-system": "0.53.0",
|
|
35
35
|
"@types/react-grid-layout": "^1.3.2",
|
|
36
36
|
"date-fns": "^4.1.0",
|
|
37
37
|
"immer": "^10.1.1",
|
|
@@ -58,4 +58,4 @@
|
|
|
58
58
|
"files": [
|
|
59
59
|
"dist"
|
|
60
60
|
]
|
|
61
|
-
}
|
|
61
|
+
}
|