@perses-dev/dashboards 0.44.0 → 0.45.0-rc0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/DashboardStickyToolbar/DashboardStickyToolbar.js +2 -2
- package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +3 -3
- package/dist/cjs/components/DownloadButton/DownloadButton.js +1 -2
- package/dist/cjs/components/EditJsonButton/EditJsonButton.js +1 -2
- package/dist/cjs/components/GridLayout/GridItemContent.js +1 -2
- package/dist/cjs/components/GridLayout/GridLayout.js +1 -1
- package/dist/cjs/components/GridLayout/GridTitle.js +0 -1
- package/dist/cjs/components/Panel/Panel.js +1 -0
- package/dist/cjs/components/Panel/PanelHeader.js +5 -1
- package/dist/cjs/components/Panel/PanelLinks.js +137 -0
- package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +32 -8
- package/dist/cjs/components/PanelDrawer/PanelPreview.js +1 -2
- package/dist/cjs/components/PanelDrawer/usePanelEditor.js +9 -6
- package/dist/cjs/components/index.js +0 -2
- package/dist/cjs/constants/user-interface-text.js +0 -2
- package/dist/cjs/context/DatasourceStoreProvider.js +3 -1
- package/dist/cjs/utils/index.js +0 -1
- package/dist/cjs/validation/panel.js +12 -2
- package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js +1 -1
- package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js.map +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.js +2 -2
- package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
- package/dist/components/DownloadButton/DownloadButton.d.ts.map +1 -1
- package/dist/components/DownloadButton/DownloadButton.js +1 -2
- package/dist/components/DownloadButton/DownloadButton.js.map +1 -1
- package/dist/components/EditJsonButton/EditJsonButton.d.ts.map +1 -1
- package/dist/components/EditJsonButton/EditJsonButton.js +1 -2
- package/dist/components/EditJsonButton/EditJsonButton.js.map +1 -1
- package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
- package/dist/components/GridLayout/GridItemContent.js +1 -2
- package/dist/components/GridLayout/GridItemContent.js.map +1 -1
- package/dist/components/GridLayout/GridLayout.js +1 -1
- package/dist/components/GridLayout/GridLayout.js.map +1 -1
- package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
- package/dist/components/GridLayout/GridTitle.js +0 -1
- package/dist/components/GridLayout/GridTitle.js.map +1 -1
- package/dist/components/Panel/Panel.d.ts.map +1 -1
- package/dist/components/Panel/Panel.js +1 -0
- package/dist/components/Panel/Panel.js.map +1 -1
- package/dist/components/Panel/PanelHeader.d.ts +5 -3
- package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
- package/dist/components/Panel/PanelHeader.js +8 -4
- package/dist/components/Panel/PanelHeader.js.map +1 -1
- package/dist/components/Panel/PanelLinks.d.ts +5 -0
- package/dist/components/Panel/PanelLinks.d.ts.map +1 -0
- package/dist/components/Panel/PanelLinks.js +124 -0
- package/dist/components/Panel/PanelLinks.js.map +1 -0
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.js +34 -10
- package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.js +1 -2
- package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
- package/dist/components/PanelDrawer/usePanelEditor.d.ts +1 -0
- package/dist/components/PanelDrawer/usePanelEditor.d.ts.map +1 -1
- package/dist/components/PanelDrawer/usePanelEditor.js +9 -6
- package/dist/components/PanelDrawer/usePanelEditor.js.map +1 -1
- package/dist/components/index.d.ts +0 -2
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +0 -2
- package/dist/components/index.js.map +1 -1
- package/dist/constants/user-interface-text.d.ts +0 -2
- package/dist/constants/user-interface-text.d.ts.map +1 -1
- package/dist/constants/user-interface-text.js +0 -2
- package/dist/constants/user-interface-text.js.map +1 -1
- package/dist/context/DatasourceStoreProvider.js +3 -1
- package/dist/context/DatasourceStoreProvider.js.map +1 -1
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +0 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/validation/panel.d.ts +51 -3
- package/dist/validation/panel.d.ts.map +1 -1
- package/dist/validation/panel.js +12 -2
- package/dist/validation/panel.js.map +1 -1
- package/package.json +6 -6
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +0 -216
- package/dist/cjs/components/TimeRangeControls/index.js +0 -30
- package/dist/cjs/components/ToolbarIconButton/ToolbarIconButton.js +0 -40
- package/dist/cjs/components/ToolbarIconButton/index.js +0 -30
- package/dist/cjs/utils/time.js +0 -29
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts +0 -13
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +0 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js +0 -192
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +0 -1
- package/dist/components/TimeRangeControls/index.d.ts +0 -2
- package/dist/components/TimeRangeControls/index.d.ts.map +0 -1
- package/dist/components/TimeRangeControls/index.js +0 -15
- package/dist/components/TimeRangeControls/index.js.map +0 -1
- package/dist/components/ToolbarIconButton/ToolbarIconButton.d.ts +0 -6
- package/dist/components/ToolbarIconButton/ToolbarIconButton.d.ts.map +0 -1
- package/dist/components/ToolbarIconButton/ToolbarIconButton.js +0 -32
- package/dist/components/ToolbarIconButton/ToolbarIconButton.js.map +0 -1
- package/dist/components/ToolbarIconButton/index.d.ts +0 -2
- package/dist/components/ToolbarIconButton/index.d.ts.map +0 -1
- package/dist/components/ToolbarIconButton/index.js +0 -15
- package/dist/components/ToolbarIconButton/index.js.map +0 -1
- package/dist/utils/time.d.ts +0 -5
- package/dist/utils/time.d.ts.map +0 -1
- package/dist/utils/time.js +0 -23
- package/dist/utils/time.js.map +0 -1
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// Copyright 2024 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
|
+
import { IconButton, Link as LinkComponent, Menu, MenuItem } from '@mui/material';
|
|
15
|
+
import LaunchIcon from 'mdi-material-ui/Launch';
|
|
16
|
+
import { useState } from 'react';
|
|
17
|
+
import { InfoTooltip } from '@perses-dev/components';
|
|
18
|
+
import { useReplaceVariablesInString } from '@perses-dev/plugin-system';
|
|
19
|
+
export function PanelLinks({ links }) {
|
|
20
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
|
21
|
+
const isMenuOpened = Boolean(anchorEl);
|
|
22
|
+
const handleOpenMenu = (event)=>{
|
|
23
|
+
setAnchorEl(event.currentTarget);
|
|
24
|
+
};
|
|
25
|
+
const handleClose = ()=>{
|
|
26
|
+
setAnchorEl(null);
|
|
27
|
+
};
|
|
28
|
+
// If there is only one link, show it directly
|
|
29
|
+
if (links.length === 1 && links[0]) {
|
|
30
|
+
const link = links[0];
|
|
31
|
+
return /*#__PURE__*/ _jsx(LinkButton, {
|
|
32
|
+
link: link
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
// Else we show a menu with a list of all links
|
|
36
|
+
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
37
|
+
children: [
|
|
38
|
+
/*#__PURE__*/ _jsx(InfoTooltip, {
|
|
39
|
+
description: `${links.length} links`,
|
|
40
|
+
enterDelay: 100,
|
|
41
|
+
children: /*#__PURE__*/ _jsx(IconButton, {
|
|
42
|
+
"aria-label": "Panel links",
|
|
43
|
+
size: "small",
|
|
44
|
+
onClick: handleOpenMenu,
|
|
45
|
+
sx: (theme)=>({
|
|
46
|
+
borderRadius: theme.shape.borderRadius,
|
|
47
|
+
padding: '4px'
|
|
48
|
+
}),
|
|
49
|
+
children: /*#__PURE__*/ _jsx(LaunchIcon, {
|
|
50
|
+
"aria-describedby": "links-icon",
|
|
51
|
+
fontSize: "inherit",
|
|
52
|
+
sx: {
|
|
53
|
+
color: (theme)=>theme.palette.text.secondary
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
})
|
|
57
|
+
}),
|
|
58
|
+
/*#__PURE__*/ _jsx(Menu, {
|
|
59
|
+
anchorEl: anchorEl,
|
|
60
|
+
open: isMenuOpened,
|
|
61
|
+
onClose: handleClose,
|
|
62
|
+
MenuListProps: {
|
|
63
|
+
'aria-labelledby': 'panel-links'
|
|
64
|
+
},
|
|
65
|
+
children: links.map((link)=>/*#__PURE__*/ _jsx(LinkMenuItem, {
|
|
66
|
+
link: link
|
|
67
|
+
}, link.url))
|
|
68
|
+
})
|
|
69
|
+
]
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
function LinkButton({ link }) {
|
|
73
|
+
const { url, name, tooltip, targetBlank } = useLink(link);
|
|
74
|
+
return /*#__PURE__*/ _jsx(InfoTooltip, {
|
|
75
|
+
description: tooltip !== null && tooltip !== void 0 ? tooltip : url,
|
|
76
|
+
enterDelay: 100,
|
|
77
|
+
children: /*#__PURE__*/ _jsx(IconButton, {
|
|
78
|
+
"aria-label": name !== null && name !== void 0 ? name : url,
|
|
79
|
+
size: "small",
|
|
80
|
+
href: url,
|
|
81
|
+
target: targetBlank ? '_blank' : '_self',
|
|
82
|
+
sx: (theme)=>({
|
|
83
|
+
borderRadius: theme.shape.borderRadius,
|
|
84
|
+
padding: '4px'
|
|
85
|
+
}),
|
|
86
|
+
children: /*#__PURE__*/ _jsx(LaunchIcon, {
|
|
87
|
+
fontSize: "inherit",
|
|
88
|
+
sx: {
|
|
89
|
+
color: (theme)=>theme.palette.text.secondary
|
|
90
|
+
}
|
|
91
|
+
})
|
|
92
|
+
})
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
function LinkMenuItem({ link }) {
|
|
96
|
+
const { url, name, tooltip, targetBlank } = useLink(link);
|
|
97
|
+
return /*#__PURE__*/ _jsx(InfoTooltip, {
|
|
98
|
+
description: tooltip !== null && tooltip !== void 0 ? tooltip : url,
|
|
99
|
+
enterDelay: 100,
|
|
100
|
+
children: /*#__PURE__*/ _jsx(MenuItem, {
|
|
101
|
+
component: LinkComponent,
|
|
102
|
+
href: url,
|
|
103
|
+
target: targetBlank ? '_blank' : '_self',
|
|
104
|
+
children: name !== null && name !== void 0 ? name : url
|
|
105
|
+
})
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function useLink(link) {
|
|
109
|
+
var _useReplaceVariablesInString;
|
|
110
|
+
const url = (_useReplaceVariablesInString = useReplaceVariablesInString(link.url)) !== null && _useReplaceVariablesInString !== void 0 ? _useReplaceVariablesInString : link.url;
|
|
111
|
+
const name = useReplaceVariablesInString(link.name);
|
|
112
|
+
const tooltip = useReplaceVariablesInString(link.tooltip);
|
|
113
|
+
if (link.renderVariables === false) {
|
|
114
|
+
return link;
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
...link,
|
|
118
|
+
url,
|
|
119
|
+
name,
|
|
120
|
+
tooltip
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
//# sourceMappingURL=PanelLinks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Panel/PanelLinks.tsx"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { IconButton, Link as LinkComponent, Menu, MenuItem, Theme } from '@mui/material';\nimport LaunchIcon from 'mdi-material-ui/Launch';\nimport { Link } from '@perses-dev/core';\nimport { MouseEvent, useState } from 'react';\nimport { InfoTooltip } from '@perses-dev/components';\nimport { useReplaceVariablesInString } from '@perses-dev/plugin-system';\n\nexport function PanelLinks({ links }: { links: Link[] }) {\n const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);\n const isMenuOpened = Boolean(anchorEl);\n const handleOpenMenu = (event: MouseEvent<HTMLButtonElement>) => {\n setAnchorEl(event.currentTarget);\n };\n const handleClose = () => {\n setAnchorEl(null);\n };\n\n // If there is only one link, show it directly\n if (links.length === 1 && links[0]) {\n const link = links[0];\n return <LinkButton link={link} />;\n }\n\n // Else we show a menu with a list of all links\n return (\n <>\n <InfoTooltip description={`${links.length} links`} enterDelay={100}>\n <IconButton\n aria-label=\"Panel links\"\n size=\"small\"\n onClick={handleOpenMenu}\n sx={(theme) => ({ borderRadius: theme.shape.borderRadius, padding: '4px' })}\n >\n <LaunchIcon\n aria-describedby=\"links-icon\"\n fontSize=\"inherit\"\n sx={{ color: (theme) => theme.palette.text.secondary }}\n />\n </IconButton>\n </InfoTooltip>\n\n <Menu\n anchorEl={anchorEl}\n open={isMenuOpened}\n onClose={handleClose}\n MenuListProps={{\n 'aria-labelledby': 'panel-links',\n }}\n >\n {links.map((link: Link) => (\n <LinkMenuItem key={link.url} link={link} />\n ))}\n </Menu>\n </>\n );\n}\n\nfunction LinkButton({ link }: { link: Link }) {\n const { url, name, tooltip, targetBlank } = useLink(link);\n\n return (\n <InfoTooltip description={tooltip ?? url} enterDelay={100}>\n <IconButton\n aria-label={name ?? url}\n size=\"small\"\n href={url}\n target={targetBlank ? '_blank' : '_self'}\n sx={(theme) => ({ borderRadius: theme.shape.borderRadius, padding: '4px' })}\n >\n <LaunchIcon fontSize=\"inherit\" sx={{ color: (theme: Theme) => theme.palette.text.secondary }} />\n </IconButton>\n </InfoTooltip>\n );\n}\n\nfunction LinkMenuItem({ link }: { link: Link }) {\n const { url, name, tooltip, targetBlank } = useLink(link);\n\n return (\n <InfoTooltip description={tooltip ?? url} enterDelay={100}>\n <MenuItem component={LinkComponent} href={url} target={targetBlank ? '_blank' : '_self'}>\n {name ?? url}\n </MenuItem>\n </InfoTooltip>\n );\n}\n\nfunction useLink(link: Link): Link {\n const url = useReplaceVariablesInString(link.url) ?? link.url;\n const name = useReplaceVariablesInString(link.name);\n const tooltip = useReplaceVariablesInString(link.tooltip);\n\n if (link.renderVariables === false) {\n return link;\n }\n\n return { ...link, url, name, tooltip };\n}\n"],"names":["IconButton","Link","LinkComponent","Menu","MenuItem","LaunchIcon","useState","InfoTooltip","useReplaceVariablesInString","PanelLinks","links","anchorEl","setAnchorEl","isMenuOpened","Boolean","handleOpenMenu","event","currentTarget","handleClose","length","link","LinkButton","description","enterDelay","aria-label","size","onClick","sx","theme","borderRadius","shape","padding","aria-describedby","fontSize","color","palette","text","secondary","open","onClose","MenuListProps","map","LinkMenuItem","url","name","tooltip","targetBlank","useLink","href","target","component","renderVariables"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,UAAU,EAAEC,QAAQC,aAAa,EAAEC,IAAI,EAAEC,QAAQ,QAAe,gBAAgB;AACzF,OAAOC,gBAAgB,yBAAyB;AAEhD,SAAqBC,QAA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,EAAE,MAAM,EAAmB,MAAM,kBAAkB,CAAC;AAY3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oDAAoD,CAAC;AAKvF,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,
|
|
1
|
+
{"version":3,"file":"PanelEditorForm.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/PanelEditorForm.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAE,MAAM,EAAmB,MAAM,kBAAkB,CAAC;AAY3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oDAAoD,CAAC;AAKvF,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,2CAiO1D;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,sBAAsB,CAAC"}
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
-
import { useState } from 'react';
|
|
14
|
+
import { useEffect, useState } from 'react';
|
|
15
15
|
import { Box, Button, Grid, MenuItem, Stack, TextField, Typography } from '@mui/material';
|
|
16
16
|
import { DiscardChangesConfirmationDialog, ErrorAlert, ErrorBoundary } from '@perses-dev/components';
|
|
17
17
|
import { PluginKindSelect, usePluginEditor, PanelSpecEditor, getTitleAction, getSubmitText } from '@perses-dev/plugin-system';
|
|
18
|
-
import { Controller, FormProvider, useForm } from 'react-hook-form';
|
|
18
|
+
import { Controller, FormProvider, useForm, useWatch } from 'react-hook-form';
|
|
19
19
|
import { zodResolver } from '@hookform/resolvers/zod';
|
|
20
20
|
import { useListPanelGroups } from '../../context';
|
|
21
21
|
import { panelEditorValidationSchema } from '../../validation';
|
|
@@ -25,18 +25,26 @@ export function PanelEditorForm(props) {
|
|
|
25
25
|
const { initialValues: { panelDefinition: initialPanelDef, groupId: initialGroupId }, initialAction, onSave, onClose } = props;
|
|
26
26
|
const panelGroups = useListPanelGroups();
|
|
27
27
|
const [groupId, setGroupId] = useState(initialGroupId);
|
|
28
|
-
const { panelDefinition, setName, setDescription, setQueries, setPlugin, setPanelDefinition } = usePanelEditor(initialPanelDef);
|
|
28
|
+
const { panelDefinition, setName, setDescription, setLinks, setQueries, setPlugin, setPanelDefinition } = usePanelEditor(initialPanelDef);
|
|
29
29
|
const { plugin } = panelDefinition.spec;
|
|
30
30
|
const [isDiscardDialogOpened, setDiscardDialogOpened] = useState(false);
|
|
31
31
|
// Use common plugin editor logic even though we've split the inputs up in this form
|
|
32
32
|
const pluginEditor = usePluginEditor({
|
|
33
|
-
|
|
33
|
+
pluginTypes: [
|
|
34
|
+
'Panel'
|
|
35
|
+
],
|
|
34
36
|
value: {
|
|
35
|
-
|
|
37
|
+
selection: {
|
|
38
|
+
kind: plugin.kind,
|
|
39
|
+
type: 'Panel'
|
|
40
|
+
},
|
|
36
41
|
spec: plugin.spec
|
|
37
42
|
},
|
|
38
43
|
onChange: (plugin)=>{
|
|
39
|
-
setPlugin(
|
|
44
|
+
setPlugin({
|
|
45
|
+
kind: plugin.selection.kind,
|
|
46
|
+
spec: plugin.spec
|
|
47
|
+
});
|
|
40
48
|
},
|
|
41
49
|
onHideQueryEditorChange: (isHidden)=>{
|
|
42
50
|
setQueries(undefined, isHidden);
|
|
@@ -51,9 +59,23 @@ export function PanelEditorForm(props) {
|
|
|
51
59
|
name: initialPanelDef.spec.display.name,
|
|
52
60
|
groupId: initialGroupId,
|
|
53
61
|
description: initialPanelDef.spec.display.description,
|
|
54
|
-
|
|
62
|
+
selection: pluginEditor.pendingSelection ? pluginEditor.pendingSelection : {
|
|
63
|
+
type: 'Panel',
|
|
64
|
+
kind: plugin.kind
|
|
65
|
+
},
|
|
66
|
+
links: initialPanelDef.spec.links
|
|
55
67
|
}
|
|
56
68
|
});
|
|
69
|
+
const links = useWatch({
|
|
70
|
+
control: form.control,
|
|
71
|
+
name: 'links'
|
|
72
|
+
});
|
|
73
|
+
useEffect(()=>{
|
|
74
|
+
setLinks(links);
|
|
75
|
+
}, [
|
|
76
|
+
setLinks,
|
|
77
|
+
links
|
|
78
|
+
]);
|
|
57
79
|
const processForm = ()=>{
|
|
58
80
|
const values = {
|
|
59
81
|
groupId,
|
|
@@ -214,13 +236,15 @@ export function PanelEditorForm(props) {
|
|
|
214
236
|
item: true,
|
|
215
237
|
xs: 4,
|
|
216
238
|
children: /*#__PURE__*/ _jsx(Controller, {
|
|
217
|
-
name: "
|
|
239
|
+
name: "selection",
|
|
218
240
|
render: ({ field, fieldState })=>/*#__PURE__*/ {
|
|
219
241
|
var _pluginEditor_error, _fieldState_error;
|
|
220
242
|
var _pluginEditor_error_message;
|
|
221
243
|
return _jsx(PluginKindSelect, {
|
|
222
244
|
...field,
|
|
223
|
-
|
|
245
|
+
pluginTypes: [
|
|
246
|
+
'Panel'
|
|
247
|
+
],
|
|
224
248
|
required: true,
|
|
225
249
|
fullWidth: true,
|
|
226
250
|
label: "Type",
|
|
@@ -229,7 +253,7 @@ export function PanelEditorForm(props) {
|
|
|
229
253
|
helperText: (_pluginEditor_error_message = (_pluginEditor_error = pluginEditor.error) === null || _pluginEditor_error === void 0 ? void 0 : _pluginEditor_error.message) !== null && _pluginEditor_error_message !== void 0 ? _pluginEditor_error_message : (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
|
|
230
254
|
onChange: (event)=>{
|
|
231
255
|
field.onChange(event);
|
|
232
|
-
pluginEditor.
|
|
256
|
+
pluginEditor.onSelectionChange(event);
|
|
233
257
|
}
|
|
234
258
|
});
|
|
235
259
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/PanelDrawer/PanelEditorForm.tsx"],"sourcesContent":["// Copyright 2023 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 { useState } from 'react';\nimport { Box, Button, Grid, MenuItem, Stack, TextField, Typography } from '@mui/material';\nimport { Action, PanelDefinition } from '@perses-dev/core';\nimport { DiscardChangesConfirmationDialog, ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport {\n PluginKindSelect,\n usePluginEditor,\n PanelSpecEditor,\n getTitleAction,\n getSubmitText,\n} from '@perses-dev/plugin-system';\nimport { Controller, FormProvider, SubmitHandler, useForm } from 'react-hook-form';\nimport { zodResolver } from '@hookform/resolvers/zod';\nimport { useListPanelGroups } from '../../context';\nimport { PanelEditorValues } from '../../context/DashboardProvider/panel-editor-slice';\nimport { panelEditorValidationSchema, PanelEditorValidationType } from '../../validation';\nimport { PanelPreview } from './PanelPreview';\nimport { usePanelEditor } from './usePanelEditor';\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) {\n const {\n initialValues: { panelDefinition: initialPanelDef, groupId: initialGroupId },\n initialAction,\n onSave,\n onClose,\n } = props;\n const panelGroups = useListPanelGroups();\n const [groupId, setGroupId] = useState(initialGroupId);\n const { panelDefinition, setName, setDescription, setQueries, setPlugin, setPanelDefinition } =\n usePanelEditor(initialPanelDef);\n const { plugin } = panelDefinition.spec;\n const [isDiscardDialogOpened, setDiscardDialogOpened] = useState<boolean>(false);\n\n // Use common plugin editor logic even though we've split the inputs up in this form\n const pluginEditor = usePluginEditor({\n pluginType: 'Panel',\n value: { kind: plugin.kind, spec: plugin.spec },\n onChange: (plugin) => {\n setPlugin(plugin);\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 form = useForm<PanelEditorValidationType>({\n resolver: zodResolver(panelEditorValidationSchema),\n mode: 'onBlur',\n defaultValues: {\n name: initialPanelDef.spec.display.name,\n groupId: initialGroupId,\n description: initialPanelDef.spec.display.description,\n type: pluginEditor.pendingKind ? pluginEditor.pendingKind : plugin.kind,\n },\n });\n\n const processForm: SubmitHandler<PanelEditorValidationType> = () => {\n const values: PanelEditorValues = { groupId, panelDefinition };\n onSave(values);\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() {\n if (\n JSON.stringify({ groupId: initialGroupId, panelDefinition: initialPanelDef }) !==\n JSON.stringify({ groupId, panelDefinition })\n ) {\n setDiscardDialogOpened(true);\n } else {\n onClose();\n }\n }\n\n const handlePanelDefinitionChange = (nextPanelDefStr: string) => {\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 return (\n <FormProvider {...form}>\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={form.handleSubmit(processForm)}>\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 name=\"name\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n required\n fullWidth\n label=\"Name\"\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\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 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 setGroupId(+event.target.value);\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 name=\"description\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"Description\"\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\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 name=\"type\"\n render={({ field, fieldState }) => (\n <PluginKindSelect\n {...field}\n pluginType=\"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 onChange={(event) => {\n field.onChange(event);\n pluginEditor.onKindChange(event);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={12}>\n <Typography variant=\"h4\" marginBottom={1}>\n Preview\n </Typography>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <PanelPreview panelDefinition={panelDefinition} />\n </ErrorBoundary>\n </Grid>\n <Grid item xs={12}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <PanelSpecEditor\n panelDefinition={panelDefinition}\n onJSONChange={handlePanelDefinitionChange}\n onQueriesChange={(queries) => {\n setQueries(queries);\n }}\n onPluginSpecChange={(spec) => {\n pluginEditor.onSpecChange(spec);\n }}\n />\n </ErrorBoundary>\n </Grid>\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 </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":["useState","Box","Button","Grid","MenuItem","Stack","TextField","Typography","DiscardChangesConfirmationDialog","ErrorAlert","ErrorBoundary","PluginKindSelect","usePluginEditor","PanelSpecEditor","getTitleAction","getSubmitText","Controller","FormProvider","useForm","zodResolver","useListPanelGroups","panelEditorValidationSchema","PanelPreview","usePanelEditor","PanelEditorForm","props","initialValues","panelDefinition","initialPanelDef","groupId","initialGroupId","initialAction","onSave","onClose","panelGroups","setGroupId","setName","setDescription","setQueries","setPlugin","setPanelDefinition","plugin","spec","isDiscardDialogOpened","setDiscardDialogOpened","pluginEditor","pluginType","value","kind","onChange","onHideQueryEditorChange","isHidden","undefined","titleAction","submitText","form","resolver","mode","defaultValues","name","display","description","type","pendingKind","processForm","values","handleCancel","JSON","stringify","handlePanelDefinitionChange","nextPanelDefStr","nextPanelDef","parse","pluginKind","pluginSpec","rememberCurrentSpecState","sx","alignItems","padding","theme","spacing","borderBottom","palette","divider","variant","direction","marginLeft","disabled","formState","isValid","onClick","handleSubmit","color","id","panelEditorFormId","flex","overflowY","container","item","xs","render","field","fieldState","required","fullWidth","label","error","helperText","message","event","target","select","map","panelGroup","index","title","isLoading","onKindChange","marginBottom","FallbackComponent","onJSONChange","onQueriesChange","queries","onPluginSpecChange","onSpecChange","isOpen","onCancel","onDiscardChanges"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,QAAQ,QAAQ,QAAQ;AACjC,SAASC,GAAG,EAAEC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,KAAK,EAAEC,SAAS,EAAEC,UAAU,QAAQ,gBAAgB;AAE1F,SAASC,gCAAgC,EAAEC,UAAU,EAAEC,aAAa,QAAQ,yBAAyB;AACrG,SACEC,gBAAgB,EAChBC,eAAe,EACfC,eAAe,EACfC,cAAc,EACdC,aAAa,QACR,4BAA4B;AACnC,SAASC,UAAU,EAAEC,YAAY,EAAiBC,OAAO,QAAQ,kBAAkB;AACnF,SAASC,WAAW,QAAQ,0BAA0B;AACtD,SAASC,kBAAkB,QAAQ,gBAAgB;AAEnD,SAASC,2BAA2B,QAAmC,mBAAmB;AAC1F,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,cAAc,QAAQ,mBAAmB;AASlD,OAAO,SAASC,gBAAgBC,KAA2B;IACzD,MAAM,EACJC,eAAe,EAAEC,iBAAiBC,eAAe,EAAEC,SAASC,cAAc,EAAE,EAC5EC,aAAa,EACbC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C;wCAChBpF,WAAWoF;oCACb;oCACAC,oBAAoB,CAACjF;wCACnBG,aAAa+E,YAAY,CAAClF;oCAC5B;;;;;;;0BAMV,KAAClC;gBACCqD,aAAY;gBACZgE,QAAQlF;gBACRmF,UAAU;oBACRlF,uBAAuB;gBACzB;gBACAmF,kBAAkB;oBAChBnF,uBAAuB;oBACvBX;gBACF;;;;AAIR;AAEA;;CAEC,GACD,OAAO,MAAM6D,oBAAoB,oBAAoB"}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/PanelDrawer/PanelEditorForm.tsx"],"sourcesContent":["// Copyright 2023 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 { useEffect, useState } from 'react';\nimport { Box, Button, Grid, MenuItem, Stack, TextField, Typography } from '@mui/material';\nimport { Action, PanelDefinition } from '@perses-dev/core';\nimport { DiscardChangesConfirmationDialog, ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport {\n PluginKindSelect,\n usePluginEditor,\n PanelSpecEditor,\n getTitleAction,\n getSubmitText,\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 { PanelEditorValues } from '../../context/DashboardProvider/panel-editor-slice';\nimport { panelEditorValidationSchema, PanelEditorValidationType } from '../../validation';\nimport { PanelPreview } from './PanelPreview';\nimport { usePanelEditor } from './usePanelEditor';\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) {\n const {\n initialValues: { panelDefinition: initialPanelDef, groupId: initialGroupId },\n initialAction,\n onSave,\n onClose,\n } = props;\n const panelGroups = useListPanelGroups();\n const [groupId, setGroupId] = useState(initialGroupId);\n const { panelDefinition, setName, setDescription, setLinks, setQueries, setPlugin, setPanelDefinition } =\n usePanelEditor(initialPanelDef);\n const { plugin } = panelDefinition.spec;\n const [isDiscardDialogOpened, setDiscardDialogOpened] = useState<boolean>(false);\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 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 form = useForm<PanelEditorValidationType>({\n resolver: zodResolver(panelEditorValidationSchema),\n mode: 'onBlur',\n defaultValues: {\n name: initialPanelDef.spec.display.name,\n groupId: initialGroupId,\n description: initialPanelDef.spec.display.description,\n selection: pluginEditor.pendingSelection ? pluginEditor.pendingSelection : { type: 'Panel', kind: plugin.kind },\n links: initialPanelDef.spec.links,\n },\n });\n\n const links = useWatch({ control: form.control, name: 'links' });\n useEffect(() => {\n setLinks(links);\n }, [setLinks, links]);\n\n const processForm: SubmitHandler<PanelEditorValidationType> = () => {\n const values: PanelEditorValues = { groupId, panelDefinition };\n onSave(values);\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() {\n if (\n JSON.stringify({ groupId: initialGroupId, panelDefinition: initialPanelDef }) !==\n JSON.stringify({ groupId, panelDefinition })\n ) {\n setDiscardDialogOpened(true);\n } else {\n onClose();\n }\n }\n\n const handlePanelDefinitionChange = (nextPanelDefStr: string) => {\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 return (\n <FormProvider {...form}>\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={form.handleSubmit(processForm)}>\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 name=\"name\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n required\n fullWidth\n label=\"Name\"\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\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 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 setGroupId(+event.target.value);\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 name=\"description\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"Description\"\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\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 name=\"selection\"\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 onChange={(event) => {\n field.onChange(event);\n pluginEditor.onSelectionChange(event);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={12}>\n <Typography variant=\"h4\" marginBottom={1}>\n Preview\n </Typography>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <PanelPreview panelDefinition={panelDefinition} />\n </ErrorBoundary>\n </Grid>\n <Grid item xs={12}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <PanelSpecEditor\n panelDefinition={panelDefinition}\n onJSONChange={handlePanelDefinitionChange}\n onQueriesChange={(queries) => {\n setQueries(queries);\n }}\n onPluginSpecChange={(spec) => {\n pluginEditor.onSpecChange(spec);\n }}\n />\n </ErrorBoundary>\n </Grid>\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 </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":["useEffect","useState","Box","Button","Grid","MenuItem","Stack","TextField","Typography","DiscardChangesConfirmationDialog","ErrorAlert","ErrorBoundary","PluginKindSelect","usePluginEditor","PanelSpecEditor","getTitleAction","getSubmitText","Controller","FormProvider","useForm","useWatch","zodResolver","useListPanelGroups","panelEditorValidationSchema","PanelPreview","usePanelEditor","PanelEditorForm","props","initialValues","panelDefinition","initialPanelDef","groupId","initialGroupId","initialAction","onSave","onClose","panelGroups","setGroupId","setName","setDescription","setLinks","setQueries","setPlugin","setPanelDefinition","plugin","spec","isDiscardDialogOpened","setDiscardDialogOpened","pluginEditor","pluginTypes","value","selection","kind","type","onChange","onHideQueryEditorChange","isHidden","undefined","titleAction","submitText","form","resolver","mode","defaultValues","name","display","description","pendingSelection","links","control","processForm","values","handleCancel","JSON","stringify","handlePanelDefinitionChange","nextPanelDefStr","nextPanelDef","parse","pluginKind","pluginSpec","rememberCurrentSpecState","sx","alignItems","padding","theme","spacing","borderBottom","palette","divider","variant","direction","marginLeft","disabled","formState","isValid","onClick","handleSubmit","color","id","panelEditorFormId","flex","overflowY","container","item","xs","render","field","fieldState","required","fullWidth","label","error","helperText","message","event","target","select","map","panelGroup","index","title","isLoading","onSelectionChange","marginBottom","FallbackComponent","onJSONChange","onQueriesChange","queries","onPluginSpecChange","onSpecChange","isOpen","onCancel","onDiscardChanges"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAC5C,SAASC,GAAG,EAAEC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,KAAK,EAAEC,SAAS,EAAEC,UAAU,QAAQ,gBAAgB;AAE1F,SAASC,gCAAgC,EAAEC,UAAU,EAAEC,aAAa,QAAQ,yBAAyB;AACrG,SACEC,gBAAgB,EAChBC,eAAe,EACfC,eAAe,EACfC,cAAc,EACdC,aAAa,QACR,4BAA4B;AAC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,QAAQ;wCACRC,SAAS;wCACTC,OAAM;wCACNlB,UAAU7C,aAAa0E,SAAS;wCAChCV,OAAO,CAAC,CAAChE,aAAagE,KAAK,IAAI,CAAC,CAACJ,WAAWI,KAAK;wCACjDC,YAAYjE,CAAAA,+BAAAA,sBAAAA,aAAagE,KAAK,cAAlBhE,0CAAAA,oBAAoBkE,OAAO,cAA3BlE,yCAAAA,+BAA+B4D,oBAAAA,WAAWI,KAAK,cAAhBJ,wCAAAA,kBAAkBM,OAAO;wCACpE5D,UAAU,CAAC6D;4CACTR,MAAMrD,QAAQ,CAAC6D;4CACfnE,aAAa2E,iBAAiB,CAACR;wCACjC;;gCACD;;;sCAIP,MAAC/G;4BAAKoG,IAAI;4BAACC,IAAI;;8CACb,KAACjG;oCAAWkF,SAAQ;oCAAKkC,cAAc;8CAAG;;8CAG1C,KAACjH;oCAAckH,mBAAmBnH;8CAChC,cAAA,KAACc;wCAAaK,iBAAiBA;;;;;sCAGnC,KAACzB;4BAAKoG,IAAI;4BAACC,IAAI;sCACb,cAAA,KAAC9F;gCAAckH,mBAAmBnH;0CAChC,cAAA,KAACI;oCACCe,iBAAiBA;oCACjBiG,cAAcnD;oCACdoD,iBAAiB,CAACC;wCAChBvF,WAAWuF;oCACb;oCACAC,oBAAoB,CAACpF;wCACnBG,aAAakF,YAAY,CAACrF;oCAC5B;;;;;;;0BAMV,KAACpC;gBACCyD,aAAY;gBACZiE,QAAQrF;gBACRsF,UAAU;oBACRrF,uBAAuB;gBACzB;gBACAsF,kBAAkB;oBAChBtF,uBAAuB;oBACvBZ;gBACF;;;;AAIR;AAEA;;CAEC,GACD,OAAO,MAAMiE,oBAAoB,oBAAoB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PanelPreview.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/PanelPreview.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"PanelPreview.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/PanelPreview.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAMlD,wBAAgB,YAAY,CAAC,EAAE,eAAe,EAAE,EAAE,IAAI,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,kDA+B3F"}
|
|
@@ -13,9 +13,8 @@
|
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import { useRef } from 'react';
|
|
15
15
|
import { Box } from '@mui/material';
|
|
16
|
-
import { DataQueriesProvider } from '@perses-dev/plugin-system';
|
|
16
|
+
import { DataQueriesProvider, useSuggestedStepMs } from '@perses-dev/plugin-system';
|
|
17
17
|
import { Panel } from '../Panel';
|
|
18
|
-
import { useSuggestedStepMs } from '../../utils';
|
|
19
18
|
const PANEL_PREVIEW_HEIGHT = 300;
|
|
20
19
|
const PANEL_PREVIEW_DEFAULT_WIDTH = 840;
|
|
21
20
|
export function PanelPreview({ panelDefinition }) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/PanelDrawer/PanelPreview.tsx"],"sourcesContent":["// Copyright 2023 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 { useRef } from 'react';\nimport { Box } from '@mui/material';\nimport { DataQueriesProvider } from '@perses-dev/plugin-system';\nimport { PanelEditorValues } from '../../context';\nimport { Panel } from '../Panel';\
|
|
1
|
+
{"version":3,"sources":["../../../src/components/PanelDrawer/PanelPreview.tsx"],"sourcesContent":["// Copyright 2023 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 { useRef } from 'react';\nimport { Box } from '@mui/material';\nimport { DataQueriesProvider, useSuggestedStepMs } from '@perses-dev/plugin-system';\nimport { PanelEditorValues } from '../../context';\nimport { Panel } from '../Panel';\n\nconst PANEL_PREVIEW_HEIGHT = 300;\nconst PANEL_PREVIEW_DEFAULT_WIDTH = 840;\n\nexport function PanelPreview({ panelDefinition }: Pick<PanelEditorValues, 'panelDefinition'>) {\n const boxRef = useRef<HTMLDivElement>(null);\n let width = PANEL_PREVIEW_DEFAULT_WIDTH;\n if (boxRef.current !== null) {\n width = boxRef.current.getBoundingClientRect().width;\n }\n const suggestedStepMs = useSuggestedStepMs(width);\n\n if (panelDefinition.spec.plugin.kind === '') {\n return null;\n }\n\n const queries = panelDefinition.spec.queries ?? [];\n\n // map TimeSeriesQueryDefinition to Definition<UnknownSpec>\n const definitions = queries.length\n ? queries.map((query) => {\n return {\n kind: query.spec.plugin.kind,\n spec: query.spec.plugin.spec,\n };\n })\n : [];\n\n return (\n <Box ref={boxRef} height={PANEL_PREVIEW_HEIGHT}>\n <DataQueriesProvider definitions={definitions} options={{ suggestedStepMs }}>\n <Panel definition={panelDefinition} />\n </DataQueriesProvider>\n </Box>\n );\n}\n"],"names":["useRef","Box","DataQueriesProvider","useSuggestedStepMs","Panel","PANEL_PREVIEW_HEIGHT","PANEL_PREVIEW_DEFAULT_WIDTH","PanelPreview","panelDefinition","boxRef","width","current","getBoundingClientRect","suggestedStepMs","spec","plugin","kind","queries","definitions","length","map","query","ref","height","options","definition"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,MAAM,QAAQ,QAAQ;AAC/B,SAASC,GAAG,QAAQ,gBAAgB;AACpC,SAASC,mBAAmB,EAAEC,kBAAkB,QAAQ,4BAA4B;AAEpF,SAASC,KAAK,QAAQ,WAAW;AAEjC,MAAMC,uBAAuB;AAC7B,MAAMC,8BAA8B;AAEpC,OAAO,SAASC,aAAa,EAAEC,eAAe,EAA8C;IAC1F,MAAMC,SAAST,OAAuB;IACtC,IAAIU,QAAQJ;IACZ,IAAIG,OAAOE,OAAO,KAAK,MAAM;QAC3BD,QAAQD,OAAOE,OAAO,CAACC,qBAAqB,GAAGF,KAAK;IACtD;IACA,MAAMG,kBAAkBV,mBAAmBO;IAE3C,IAAIF,gBAAgBM,IAAI,CAACC,MAAM,CAACC,IAAI,KAAK,IAAI;QAC3C,OAAO;IACT;QAEgBR;IAAhB,MAAMS,UAAUT,CAAAA,gCAAAA,gBAAgBM,IAAI,CAACG,OAAO,cAA5BT,2CAAAA,gCAAgC,EAAE;IAElD,2DAA2D;IAC3D,MAAMU,cAAcD,QAAQE,MAAM,GAC9BF,QAAQG,GAAG,CAAC,CAACC;QACX,OAAO;YACLL,MAAMK,MAAMP,IAAI,CAACC,MAAM,CAACC,IAAI;YAC5BF,MAAMO,MAAMP,IAAI,CAACC,MAAM,CAACD,IAAI;QAC9B;IACF,KACA,EAAE;IAEN,qBACE,KAACb;QAAIqB,KAAKb;QAAQc,QAAQlB;kBACxB,cAAA,KAACH;YAAoBgB,aAAaA;YAAaM,SAAS;gBAAEX;YAAgB;sBACxE,cAAA,KAACT;gBAAMqB,YAAYjB;;;;AAI3B"}
|
|
@@ -8,6 +8,7 @@ export declare const usePanelEditor: (panelDefinition: PanelDefinition) => {
|
|
|
8
8
|
panelDefinition: PanelDefinition<import("@perses-dev/core").UnknownSpec>;
|
|
9
9
|
setName: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
10
10
|
setDescription: import("react").Dispatch<import("react").SetStateAction<string | undefined>>;
|
|
11
|
+
setLinks: import("react").Dispatch<import("react").SetStateAction<import("@perses-dev/core").Link[] | undefined>>;
|
|
11
12
|
setQueries: (queries?: QueryDefinition[], hideQueryEditor?: boolean) => void;
|
|
12
13
|
setPlugin: import("react").Dispatch<import("react").SetStateAction<import("@perses-dev/core").Definition<import("@perses-dev/core").UnknownSpec>>>;
|
|
13
14
|
setPanelDefinition: (panelDefinition: PanelDefinition) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePanelEditor.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/usePanelEditor.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEpE;;;GAGG;AACH,eAAO,MAAM,cAAc,oBAAqB,eAAe
|
|
1
|
+
{"version":3,"file":"usePanelEditor.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/usePanelEditor.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEpE;;;GAGG;AACH,eAAO,MAAM,cAAc,oBAAqB,eAAe;;;;;2BAgBhD,eAAe,EAAE,oBAAoB,OAAO;;0CAarC,eAAe;CA+BpC,CAAC"}
|
|
@@ -15,9 +15,10 @@ import { useCallback, useMemo, useState } from 'react';
|
|
|
15
15
|
* UsePanelEditor is used in PanelEditorForm
|
|
16
16
|
* This hook stores the states of panel definition and returns the onChange handlers for each state
|
|
17
17
|
*/ export const usePanelEditor = (panelDefinition)=>{
|
|
18
|
-
const { display, plugin: pluginDefinition, queries: initialQueries } = panelDefinition.spec;
|
|
18
|
+
const { display, plugin: pluginDefinition, queries: initialQueries, links: initialLinks } = panelDefinition.spec;
|
|
19
19
|
const [name, setName] = useState(display.name);
|
|
20
20
|
const [description, setDescription] = useState(display.description);
|
|
21
|
+
const [links, setLinks] = useState(initialLinks);
|
|
21
22
|
const [plugin, setPlugin] = useState(pluginDefinition);
|
|
22
23
|
// need to keep track of prevQueries if switching from a panel with no queries (ex: markdown) to one with queries
|
|
23
24
|
const [prevQueries, setPrevQueries] = useState(initialQueries);
|
|
@@ -40,14 +41,16 @@ import { useCallback, useMemo, useState } from 'react';
|
|
|
40
41
|
]);
|
|
41
42
|
// reset panel definition
|
|
42
43
|
const setPanelDefinition = useCallback((panelDefinition)=>{
|
|
43
|
-
const { display, plugin, queries } = panelDefinition.spec;
|
|
44
|
+
const { display, plugin, queries, links } = panelDefinition.spec;
|
|
44
45
|
setName(display.name);
|
|
45
46
|
setDescription(display.description);
|
|
47
|
+
setLinks(links);
|
|
46
48
|
setPlugin(plugin);
|
|
47
49
|
setQueries(queries);
|
|
48
50
|
}, [
|
|
49
51
|
setName,
|
|
50
52
|
setDescription,
|
|
53
|
+
setLinks,
|
|
51
54
|
setPlugin,
|
|
52
55
|
setQueries
|
|
53
56
|
]);
|
|
@@ -60,23 +63,23 @@ import { useCallback, useMemo, useState } from 'react';
|
|
|
60
63
|
description
|
|
61
64
|
},
|
|
62
65
|
plugin,
|
|
63
|
-
queries: currentQueries
|
|
66
|
+
queries: currentQueries,
|
|
67
|
+
links
|
|
64
68
|
}
|
|
65
69
|
},
|
|
66
70
|
setName,
|
|
67
71
|
setDescription,
|
|
72
|
+
setLinks,
|
|
68
73
|
setQueries,
|
|
69
74
|
setPlugin,
|
|
70
75
|
setPanelDefinition
|
|
71
76
|
}), [
|
|
72
77
|
name,
|
|
73
78
|
description,
|
|
79
|
+
links,
|
|
74
80
|
plugin,
|
|
75
81
|
currentQueries,
|
|
76
|
-
setName,
|
|
77
|
-
setDescription,
|
|
78
82
|
setQueries,
|
|
79
|
-
setPlugin,
|
|
80
83
|
setPanelDefinition
|
|
81
84
|
]);
|
|
82
85
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/PanelDrawer/usePanelEditor.tsx"],"sourcesContent":["// Copyright 2023 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, useState } from 'react';\nimport { PanelDefinition, QueryDefinition } from '@perses-dev/core';\n\n/**\n * UsePanelEditor is used in PanelEditorForm\n * This hook stores the states of panel definition and returns the onChange handlers for each state\n */\nexport const usePanelEditor = (panelDefinition: PanelDefinition) => {\n const { display, plugin: pluginDefinition, queries: initialQueries } = panelDefinition.spec;\n const [name, setName] = useState(display.name);\n const [description, setDescription] = useState(display.description);\n const [plugin, setPlugin] = useState(pluginDefinition);\n\n // need to keep track of prevQueries if switching from a panel with no queries (ex: markdown) to one with queries\n const [prevQueries, setPrevQueries] = useState(initialQueries);\n const [currentQueries, setCurrentQueries] = useState(initialQueries);\n\n /**\n * If hideQueryEditor is true, set panelDefinition.spec.queries to undefined.\n * If hideQueryEditor is false and query is undefined, set panelDefinition.spec.queries to previous queries.\n */\n const setQueries = useCallback(\n (queries?: QueryDefinition[], hideQueryEditor?: boolean) => {\n if (hideQueryEditor) {\n setPrevQueries(currentQueries);\n setCurrentQueries(undefined);\n } else {\n setCurrentQueries(queries === undefined ? prevQueries : queries);\n }\n },\n [setCurrentQueries, currentQueries, setPrevQueries, prevQueries]\n );\n\n // reset panel definition\n const setPanelDefinition = useCallback(\n (panelDefinition: PanelDefinition) => {\n const { display, plugin, queries } = panelDefinition.spec;\n setName(display.name);\n setDescription(display.description);\n setPlugin(plugin);\n setQueries(queries);\n },\n [setName, setDescription, setPlugin, setQueries]\n );\n\n return useMemo(\n () => ({\n panelDefinition: {\n kind: 'Panel',\n spec: {\n display: { name, description },\n plugin,\n queries: currentQueries,\n },\n } as PanelDefinition,\n setName,\n setDescription,\n setQueries,\n setPlugin,\n setPanelDefinition,\n }),\n [name, description, plugin, currentQueries,
|
|
1
|
+
{"version":3,"sources":["../../../src/components/PanelDrawer/usePanelEditor.tsx"],"sourcesContent":["// Copyright 2023 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, useState } from 'react';\nimport { PanelDefinition, QueryDefinition } from '@perses-dev/core';\n\n/**\n * UsePanelEditor is used in PanelEditorForm\n * This hook stores the states of panel definition and returns the onChange handlers for each state\n */\nexport const usePanelEditor = (panelDefinition: PanelDefinition) => {\n const { display, plugin: pluginDefinition, queries: initialQueries, links: initialLinks } = panelDefinition.spec;\n const [name, setName] = useState(display.name);\n const [description, setDescription] = useState(display.description);\n const [links, setLinks] = useState(initialLinks);\n const [plugin, setPlugin] = useState(pluginDefinition);\n\n // need to keep track of prevQueries if switching from a panel with no queries (ex: markdown) to one with queries\n const [prevQueries, setPrevQueries] = useState(initialQueries);\n const [currentQueries, setCurrentQueries] = useState(initialQueries);\n\n /**\n * If hideQueryEditor is true, set panelDefinition.spec.queries to undefined.\n * If hideQueryEditor is false and query is undefined, set panelDefinition.spec.queries to previous queries.\n */\n const setQueries = useCallback(\n (queries?: QueryDefinition[], hideQueryEditor?: boolean) => {\n if (hideQueryEditor) {\n setPrevQueries(currentQueries);\n setCurrentQueries(undefined);\n } else {\n setCurrentQueries(queries === undefined ? prevQueries : queries);\n }\n },\n [setCurrentQueries, currentQueries, setPrevQueries, prevQueries]\n );\n\n // reset panel definition\n const setPanelDefinition = useCallback(\n (panelDefinition: PanelDefinition) => {\n const { display, plugin, queries, links } = panelDefinition.spec;\n setName(display.name);\n setDescription(display.description);\n setLinks(links);\n setPlugin(plugin);\n setQueries(queries);\n },\n [setName, setDescription, setLinks, setPlugin, setQueries]\n );\n\n return useMemo(\n () => ({\n panelDefinition: {\n kind: 'Panel',\n spec: {\n display: { name, description },\n plugin,\n queries: currentQueries,\n links,\n },\n } as PanelDefinition,\n setName,\n setDescription,\n setLinks,\n setQueries,\n setPlugin,\n setPanelDefinition,\n }),\n [name, description, links, plugin, currentQueries, setQueries, setPanelDefinition]\n );\n};\n"],"names":["useCallback","useMemo","useState","usePanelEditor","panelDefinition","display","plugin","pluginDefinition","queries","initialQueries","links","initialLinks","spec","name","setName","description","setDescription","setLinks","setPlugin","prevQueries","setPrevQueries","currentQueries","setCurrentQueries","setQueries","hideQueryEditor","undefined","setPanelDefinition","kind"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AAGvD;;;CAGC,GACD,OAAO,MAAMC,iBAAiB,CAACC;IAC7B,MAAM,EAAEC,OAAO,EAAEC,QAAQC,gBAAgB,EAAEC,SAASC,cAAc,EAAEC,OAAOC,YAAY,EAAE,GAAGP,gBAAgBQ,IAAI;IAChH,MAAM,CAACC,MAAMC,QAAQ,GAAGZ,SAASG,QAAQQ,IAAI;IAC7C,MAAM,CAACE,aAAaC,eAAe,GAAGd,SAASG,QAAQU,WAAW;IAClE,MAAM,CAACL,OAAOO,SAAS,GAAGf,SAASS;IACnC,MAAM,CAACL,QAAQY,UAAU,GAAGhB,SAASK;IAErC,iHAAiH;IACjH,MAAM,CAACY,aAAaC,eAAe,GAAGlB,SAASO;IAC/C,MAAM,CAACY,gBAAgBC,kBAAkB,GAAGpB,SAASO;IAErD;;;GAGC,GACD,MAAMc,aAAavB,YACjB,CAACQ,SAA6BgB;QAC5B,IAAIA,iBAAiB;YACnBJ,eAAeC;YACfC,kBAAkBG;QACpB,OAAO;YACLH,kBAAkBd,YAAYiB,YAAYN,cAAcX;QAC1D;IACF,GACA;QAACc;QAAmBD;QAAgBD;QAAgBD;KAAY;IAGlE,yBAAyB;IACzB,MAAMO,qBAAqB1B,YACzB,CAACI;QACC,MAAM,EAAEC,OAAO,EAAEC,MAAM,EAAEE,OAAO,EAAEE,KAAK,EAAE,GAAGN,gBAAgBQ,IAAI;QAChEE,QAAQT,QAAQQ,IAAI;QACpBG,eAAeX,QAAQU,WAAW;QAClCE,SAASP;QACTQ,UAAUZ;QACViB,WAAWf;IACb,GACA;QAACM;QAASE;QAAgBC;QAAUC;QAAWK;KAAW;IAG5D,OAAOtB,QACL,IAAO,CAAA;YACLG,iBAAiB;gBACfuB,MAAM;gBACNf,MAAM;oBACJP,SAAS;wBAAEQ;wBAAME;oBAAY;oBAC7BT;oBACAE,SAASa;oBACTX;gBACF;YACF;YACAI;YACAE;YACAC;YACAM;YACAL;YACAQ;QACF,CAAA,GACA;QAACb;QAAME;QAAaL;QAAOJ;QAAQe;QAAgBE;QAAYG;KAAmB;AAEtF,EAAE"}
|
|
@@ -18,7 +18,5 @@ export * from './PanelGroupDialog';
|
|
|
18
18
|
export * from './QuerySummaryTable';
|
|
19
19
|
export * from './SaveChangesConfirmationDialog';
|
|
20
20
|
export * from './SaveDashboardButton';
|
|
21
|
-
export * from './TimeRangeControls';
|
|
22
|
-
export * from './ToolbarIconButton';
|
|
23
21
|
export * from './Variables';
|
|
24
22
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAaA,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oCAAoC,CAAC;AACnD,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iCAAiC,CAAC;AAChD,cAAc,uBAAuB,CAAC;AACtC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAaA,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oCAAoC,CAAC;AACnD,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iCAAiC,CAAC;AAChD,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC"}
|
package/dist/components/index.js
CHANGED
|
@@ -30,8 +30,6 @@ export * from './PanelGroupDialog';
|
|
|
30
30
|
export * from './QuerySummaryTable';
|
|
31
31
|
export * from './SaveChangesConfirmationDialog';
|
|
32
32
|
export * from './SaveDashboardButton';
|
|
33
|
-
export * from './TimeRangeControls';
|
|
34
|
-
export * from './ToolbarIconButton';
|
|
35
33
|
export * from './Variables';
|
|
36
34
|
|
|
37
35
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './AddGroupButton';\nexport * from './AddPanelButton';\nexport * from './Dashboard';\nexport * from './DashboardToolbar';\nexport * from './DashboardStickyToolbar';\nexport * from './Datasources';\nexport * from './DeletePanelDialog';\nexport * from './DeletePanelGroupDialog';\nexport * from './DiscardChangesConfirmationDialog';\nexport * from './DownloadButton';\nexport * from './EditJsonButton';\nexport * from './EditJsonDialog';\nexport * from './EmptyDashboard';\nexport * from './GridLayout';\nexport * from './Panel';\nexport * from './PanelDrawer';\nexport * from './PanelGroupDialog';\nexport * from './QuerySummaryTable';\nexport * from './SaveChangesConfirmationDialog';\nexport * from './SaveDashboardButton';\nexport * from './
|
|
1
|
+
{"version":3,"sources":["../../src/components/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './AddGroupButton';\nexport * from './AddPanelButton';\nexport * from './Dashboard';\nexport * from './DashboardToolbar';\nexport * from './DashboardStickyToolbar';\nexport * from './Datasources';\nexport * from './DeletePanelDialog';\nexport * from './DeletePanelGroupDialog';\nexport * from './DiscardChangesConfirmationDialog';\nexport * from './DownloadButton';\nexport * from './EditJsonButton';\nexport * from './EditJsonDialog';\nexport * from './EmptyDashboard';\nexport * from './GridLayout';\nexport * from './Panel';\nexport * from './PanelDrawer';\nexport * from './PanelGroupDialog';\nexport * from './QuerySummaryTable';\nexport * from './SaveChangesConfirmationDialog';\nexport * from './SaveDashboardButton';\nexport * from './Variables';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,mBAAmB;AACjC,cAAc,mBAAmB;AACjC,cAAc,cAAc;AAC5B,cAAc,qBAAqB;AACnC,cAAc,2BAA2B;AACzC,cAAc,gBAAgB;AAC9B,cAAc,sBAAsB;AACpC,cAAc,2BAA2B;AACzC,cAAc,qCAAqC;AACnD,cAAc,mBAAmB;AACjC,cAAc,mBAAmB;AACjC,cAAc,mBAAmB;AACjC,cAAc,mBAAmB;AACjC,cAAc,eAAe;AAC7B,cAAc,UAAU;AACxB,cAAc,gBAAgB;AAC9B,cAAc,qBAAqB;AACnC,cAAc,sBAAsB;AACpC,cAAc,kCAAkC;AAChD,cAAc,wBAAwB;AACtC,cAAc,cAAc"}
|
|
@@ -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
|
|
1
|
+
{"version":3,"file":"user-interface-text.d.ts","sourceRoot":"","sources":["../../src/constants/user-interface-text.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;CAuBxB,CAAC;AAEF,eAAO,MAAM,eAAe;iCAEG,MAAM;6BACV,MAAM;2BACR,MAAM;+BACF,MAAM;6BACR,MAAM;2BAER,MAAM;gCACD,MAAM;6BACT,MAAM;2BACR,MAAM;CAC9B,CAAC"}
|
|
@@ -18,8 +18,6 @@ export const TOOLTIP_TEXT = {
|
|
|
18
18
|
editDatasources: 'Edit datasources',
|
|
19
19
|
editJson: 'Edit JSON',
|
|
20
20
|
editVariables: 'Edit variables',
|
|
21
|
-
refreshDashboard: 'Refresh dashboard',
|
|
22
|
-
refreshDashboardInterval: 'Auto refresh interval',
|
|
23
21
|
viewJson: 'View JSON',
|
|
24
22
|
// Group buttons
|
|
25
23
|
addPanelToGroup: 'Add panel to group',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/constants/user-interface-text.ts"],"sourcesContent":["// Copyright 2023 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 downloadDashboard: 'Download JSON',\n editDatasources: 'Edit datasources',\n editJson: 'Edit JSON',\n editVariables: 'Edit variables',\n
|
|
1
|
+
{"version":3,"sources":["../../src/constants/user-interface-text.ts"],"sourcesContent":["// Copyright 2023 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 downloadDashboard: 'Download JSON',\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 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};\n\nexport const ARIA_LABEL_TEXT = {\n // Group buttons\n addPanelToGroup: (groupName: string) => `add panel to group ${groupName}`,\n deleteGroup: (groupName: string) => `delete group ${groupName}`,\n editGroup: (groupName: string) => `edit group ${groupName}`,\n moveGroupDown: (groupName: string) => `move group ${groupName} down`,\n moveGroupUp: (groupName: string) => `move group ${groupName} up`,\n // Panel buttons\n editPanel: (panelName: string) => `edit panel ${panelName}`,\n duplicatePanel: (panelName: string) => `duplicate panel ${panelName}`,\n deletePanel: (panelName: string) => `delete panel ${panelName}`,\n movePanel: (panelName: string) => `move panel ${panelName}`,\n};\n"],"names":["TOOLTIP_TEXT","addPanel","addGroup","downloadDashboard","editDatasources","editJson","editVariables","viewJson","addPanelToGroup","deleteGroup","editGroup","moveGroupDown","moveGroupUp","editPanel","duplicatePanel","deletePanel","movePanel","refreshVariableValues","copyVariableValues","ARIA_LABEL_TEXT","groupName","panelName"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,MAAMA,eAAe;IAC1B,kBAAkB;IAClBC,UAAU;IACVC,UAAU;IACVC,mBAAmB;IACnBC,iBAAiB;IACjBC,UAAU;IACVC,eAAe;IACfC,UAAU;IACV,gBAAgB;IAChBC,iBAAiB;IACjBC,aAAa;IACbC,WAAW;IACXC,eAAe;IACfC,aAAa;IACb,gBAAgB;IAChBC,WAAW;IACXC,gBAAgB;IAChBC,aAAa;IACbC,WAAW;IACX,0BAA0B;IAC1BC,uBAAuB;IACvBC,oBAAoB;AACtB,EAAE;AAEF,OAAO,MAAMC,kBAAkB;IAC7B,gBAAgB;IAChBX,iBAAiB,CAACY,YAAsB,CAAC,mBAAmB,EAAEA,UAAU,CAAC;IACzEX,aAAa,CAACW,YAAsB,CAAC,aAAa,EAAEA,UAAU,CAAC;IAC/DV,WAAW,CAACU,YAAsB,CAAC,WAAW,EAAEA,UAAU,CAAC;IAC3DT,eAAe,CAACS,YAAsB,CAAC,WAAW,EAAEA,UAAU,KAAK,CAAC;IACpER,aAAa,CAACQ,YAAsB,CAAC,WAAW,EAAEA,UAAU,GAAG,CAAC;IAChE,gBAAgB;IAChBP,WAAW,CAACQ,YAAsB,CAAC,WAAW,EAAEA,UAAU,CAAC;IAC3DP,gBAAgB,CAACO,YAAsB,CAAC,gBAAgB,EAAEA,UAAU,CAAC;IACrEN,aAAa,CAACM,YAAsB,CAAC,aAAa,EAAEA,UAAU,CAAC;IAC/DL,WAAW,CAACK,YAAsB,CAAC,WAAW,EAAEA,UAAU,CAAC;AAC7D,EAAE"}
|
|
@@ -93,7 +93,9 @@ import { DatasourceStoreContext, usePluginRegistry } from '@perses-dev/plugin-sy
|
|
|
93
93
|
]);
|
|
94
94
|
const listDatasourceSelectItems = useEvent(async (datasourcePluginKind)=>{
|
|
95
95
|
const [pluginMetadata, datasources, globalDatasources] = await Promise.all([
|
|
96
|
-
listPluginMetadata(
|
|
96
|
+
listPluginMetadata([
|
|
97
|
+
'Datasource'
|
|
98
|
+
]),
|
|
97
99
|
project ? datasourceApi.listDatasources(project, datasourcePluginKind) : [],
|
|
98
100
|
datasourceApi.listGlobalDatasources(datasourcePluginKind)
|
|
99
101
|
]);
|