@perses-dev/dashboards 0.10.0 → 0.11.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/Dashboard.js +4 -5
- package/dist/cjs/components/DashboardToolbar.js +11 -5
- package/dist/cjs/components/GridLayout/GridItemContent.js +3 -11
- package/dist/cjs/components/GridLayout/GridLayout.js +8 -6
- package/dist/cjs/components/GridLayout/GridTitle.js +9 -11
- package/dist/cjs/components/Panel/DeletePanelDialog.js +12 -8
- package/dist/cjs/components/Panel/Panel.js +4 -13
- package/dist/cjs/components/Panel/Panel.test.js +4 -3
- package/dist/cjs/components/PanelDrawer/PanelDrawer.js +1 -1
- package/dist/cjs/components/PanelDrawer/PanelDrawer.test.js +3 -3
- package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +21 -15
- package/dist/cjs/components/PanelDrawer/PanelPreview.js +9 -3
- package/dist/cjs/components/PanelGroupDialog/DeletePanelGroupDialog.js +13 -11
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +70 -111
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.test.js +22 -16
- package/dist/cjs/components/PanelGroupDialog/PanelGroupEditorForm.js +92 -0
- package/dist/cjs/components/PanelGroupDialog/index.js +29 -0
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +8 -11
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.test.js +20 -13
- package/dist/cjs/components/Variables/Variable.js +1 -0
- package/dist/cjs/components/Variables/VariableEditor.js +33 -0
- package/dist/cjs/components/Variables/VariableList.js +0 -1
- package/dist/cjs/components/index.js +1 -0
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +20 -8
- package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +122 -29
- package/dist/cjs/context/DashboardProvider/{panel-editing-slice.js → panel-editor-slice.js} +32 -13
- package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +102 -0
- package/dist/cjs/context/DashboardProvider/panel-group-slice.js +187 -17
- package/dist/cjs/context/TimeRangeProvider.js +20 -44
- package/dist/cjs/context/index.js +1 -1
- package/dist/cjs/context/useDashboardSpec.js +61 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/test/render.js +25 -5
- package/dist/cjs/test/setup-tests.js +4 -1
- package/dist/cjs/test/testDashboard.js +11 -10
- package/dist/cjs/utils/index.js +28 -0
- package/dist/cjs/utils/time-range-params.js +145 -0
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +2 -4
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +5 -22
- package/dist/cjs/views/ViewDashboard/tests/panelGroups.test.js +42 -93
- package/dist/components/Dashboard.js +5 -6
- package/dist/components/Dashboard.js.map +1 -1
- package/dist/components/DashboardToolbar.d.ts.map +1 -1
- package/dist/components/DashboardToolbar.js +13 -7
- package/dist/components/DashboardToolbar.js.map +1 -1
- package/dist/components/GridLayout/GridItemContent.d.ts +2 -4
- package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
- package/dist/components/GridLayout/GridItemContent.js +4 -12
- package/dist/components/GridLayout/GridItemContent.js.map +1 -1
- package/dist/components/GridLayout/GridLayout.d.ts +2 -3
- package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
- package/dist/components/GridLayout/GridLayout.js +9 -7
- package/dist/components/GridLayout/GridLayout.js.map +1 -1
- package/dist/components/GridLayout/GridTitle.d.ts +2 -1
- package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
- package/dist/components/GridLayout/GridTitle.js +10 -12
- package/dist/components/GridLayout/GridTitle.js.map +1 -1
- package/dist/components/Panel/DeletePanelDialog.d.ts +1 -1
- package/dist/components/Panel/DeletePanelDialog.d.ts.map +1 -1
- package/dist/components/Panel/DeletePanelDialog.js +13 -9
- package/dist/components/Panel/DeletePanelDialog.js.map +1 -1
- package/dist/components/Panel/Panel.d.ts +2 -2
- package/dist/components/Panel/Panel.d.ts.map +1 -1
- package/dist/components/Panel/Panel.js +5 -14
- package/dist/components/Panel/Panel.js.map +1 -1
- package/dist/components/Panel/Panel.test.d.ts +1 -1
- package/dist/components/Panel/Panel.test.d.ts.map +1 -1
- package/dist/components/Panel/Panel.test.js +4 -3
- package/dist/components/Panel/Panel.test.js.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.js +2 -2
- package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.test.js +3 -3
- package/dist/components/PanelDrawer/PanelDrawer.test.js.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.js +22 -16
- package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.d.ts +2 -2
- package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.js +9 -3
- package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.d.ts +1 -2
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -1
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.js +13 -11
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts +4 -2
- package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js +73 -112
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js +21 -15
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts +12 -0
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts.map +1 -0
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js +82 -0
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js.map +1 -0
- package/dist/components/PanelGroupDialog/index.d.ts +3 -0
- package/dist/components/PanelGroupDialog/index.d.ts.map +1 -0
- package/dist/components/PanelGroupDialog/index.js +16 -0
- package/dist/components/PanelGroupDialog/index.js.map +1 -0
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js +11 -14
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.test.js +21 -14
- package/dist/components/TimeRangeControls/TimeRangeControls.test.js.map +1 -1
- package/dist/components/Variables/Variable.js +1 -0
- package/dist/components/Variables/Variable.js.map +1 -1
- package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditor.js +33 -0
- package/dist/components/Variables/VariableEditor.js.map +1 -1
- package/dist/components/Variables/VariableList.js +0 -1
- package/dist/components/Variables/VariableList.js.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -0
- package/dist/components/index.js.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.d.ts +7 -5
- package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.js +19 -7
- package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +64 -22
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.js +133 -26
- package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
- package/dist/context/DashboardProvider/index.d.ts +2 -0
- package/dist/context/DashboardProvider/index.d.ts.map +1 -1
- package/dist/context/DashboardProvider/index.js.map +1 -1
- package/dist/context/DashboardProvider/{panel-editing-slice.d.ts → panel-editor-slice.d.ts} +28 -13
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/{panel-editing-slice.js → panel-editor-slice.js} +33 -14
- package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -0
- package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts +40 -0
- package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/panel-group-editor-slice.js +96 -0
- package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -0
- package/dist/context/DashboardProvider/panel-group-slice.d.ts +75 -10
- package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-group-slice.js +189 -17
- package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
- package/dist/context/TimeRangeProvider.d.ts +9 -2
- package/dist/context/TimeRangeProvider.d.ts.map +1 -1
- package/dist/context/TimeRangeProvider.js +15 -43
- package/dist/context/TimeRangeProvider.js.map +1 -1
- package/dist/context/index.d.ts +1 -1
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +1 -1
- package/dist/context/index.js.map +1 -1
- package/dist/context/useDashboardSpec.d.ts +3 -0
- package/dist/context/useDashboardSpec.d.ts.map +1 -0
- package/dist/context/useDashboardSpec.js +55 -0
- package/dist/context/useDashboardSpec.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/test/render.d.ts +2 -1
- package/dist/test/render.d.ts.map +1 -1
- package/dist/test/render.js +25 -5
- package/dist/test/render.js.map +1 -1
- package/dist/test/setup-tests.d.ts.map +1 -1
- package/dist/test/setup-tests.js +4 -0
- package/dist/test/setup-tests.js.map +1 -1
- package/dist/test/testDashboard.d.ts.map +1 -1
- package/dist/test/testDashboard.js +11 -10
- package/dist/test/testDashboard.js.map +1 -1
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +15 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/time-range-params.d.ts +25 -0
- package/dist/utils/time-range-params.d.ts.map +1 -0
- package/dist/utils/time-range-params.js +137 -0
- package/dist/utils/time-range-params.js.map +1 -0
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.js +1 -3
- package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.js +5 -22
- package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
- package/dist/views/ViewDashboard/tests/panelGroups.test.js +45 -96
- package/dist/views/ViewDashboard/tests/panelGroups.test.js.map +1 -1
- package/package.json +5 -4
- package/dist/cjs/context/DashboardProvider/layout-slice.js +0 -200
- package/dist/cjs/context/QueryStringProvider.js +0 -89
- package/dist/context/DashboardProvider/layout-slice.d.ts +0 -57
- package/dist/context/DashboardProvider/layout-slice.d.ts.map +0 -1
- package/dist/context/DashboardProvider/layout-slice.js +0 -196
- package/dist/context/DashboardProvider/layout-slice.js.map +0 -1
- package/dist/context/DashboardProvider/panel-editing-slice.d.ts.map +0 -1
- package/dist/context/DashboardProvider/panel-editing-slice.js.map +0 -1
- package/dist/context/QueryStringProvider.d.ts +0 -13
- package/dist/context/QueryStringProvider.d.ts.map +0 -1
- package/dist/context/QueryStringProvider.js +0 -40
- package/dist/context/QueryStringProvider.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/Dashboard.tsx"],"sourcesContent":["// Copyright 2022 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 { Box, BoxProps } from '@mui/material';\nimport { ErrorBoundary, ErrorAlert } from '@perses-dev/components';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/components/Dashboard.tsx"],"sourcesContent":["// Copyright 2022 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 { Box, BoxProps } from '@mui/material';\nimport { ErrorBoundary, ErrorAlert } from '@perses-dev/components';\nimport { usePanelGroupIds } from '../context';\nimport { GridLayout } from './GridLayout';\n\nexport type DashboardProps = BoxProps;\n\n/**\n * Renders a Dashboard for the provided Dashboard spec.\n */\nexport function Dashboard(props: DashboardProps) {\n const panelGroupIds = usePanelGroupIds();\n return (\n <Box {...props}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n {panelGroupIds.map((panelGroupId) => (\n <GridLayout key={panelGroupId} panelGroupId={panelGroupId} />\n ))}\n </ErrorBoundary>\n </Box>\n );\n}\n"],"names":["Box","ErrorBoundary","ErrorAlert","usePanelGroupIds","GridLayout","Dashboard","props","panelGroupIds","FallbackComponent","map","panelGroupId"],"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;AAAA,SAASA,GAAG,QAAkB,eAAe,CAAC;AAC9C,SAASC,aAAa,EAAEC,UAAU,QAAQ,wBAAwB,CAAC;AACnE,SAASC,gBAAgB,QAAQ,YAAY,CAAC;AAC9C,SAASC,UAAU,QAAQ,cAAc,CAAC;AAI1C;;CAEC,GACD,OAAO,SAASC,SAAS,CAACC,KAAqB,EAAE;IAC/C,MAAMC,aAAa,GAAGJ,gBAAgB,EAAE,AAAC;IACzC,qBACE,KAACH,GAAG;QAAE,GAAGM,KAAK;kBACZ,cAAA,KAACL,aAAa;YAACO,iBAAiB,EAAEN,UAAU;sBACzCK,aAAa,CAACE,GAAG,CAAC,CAACC,YAAY,iBAC9B,KAACN,UAAU;oBAAoBM,YAAY,EAAEA,YAAY;mBAAxCA,YAAY,CAAgC,AAC9D,CAAC;UACY;MACZ,CACN;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DashboardToolbar.d.ts","sourceRoot":"","sources":["../../src/components/DashboardToolbar.tsx"],"names":[],"mappings":";AAqBA,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,gBAAgB,UAAW,qBAAqB,
|
|
1
|
+
{"version":3,"file":"DashboardToolbar.d.ts","sourceRoot":"","sources":["../../src/components/DashboardToolbar.tsx"],"names":[],"mappings":";AAqBA,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,gBAAgB,UAAW,qBAAqB,gBAuF5D,CAAC"}
|
|
@@ -11,22 +11,27 @@
|
|
|
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, Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
|
-
import { Typography, Stack, Button, Box } from '@mui/material';
|
|
14
|
+
import { Typography, Stack, Button, Box, useTheme, useMediaQuery } from '@mui/material';
|
|
15
15
|
import PencilIcon from 'mdi-material-ui/PencilOutline';
|
|
16
16
|
import AddPanelGroupIcon from 'mdi-material-ui/PlusBoxOutline';
|
|
17
17
|
import AddPanelIcon from 'mdi-material-ui/ChartBoxPlusOutline';
|
|
18
18
|
import { ErrorBoundary, ErrorAlert } from '@perses-dev/components';
|
|
19
|
-
import {
|
|
19
|
+
import { useDashboardActions, useEditMode } from '../context';
|
|
20
20
|
import { TemplateVariableList, TimeRangeControls } from '../components';
|
|
21
21
|
export const DashboardToolbar = (props)=>{
|
|
22
22
|
const { dashboardName } = props;
|
|
23
23
|
const { isEditMode , setEditMode } = useEditMode();
|
|
24
|
-
const {
|
|
25
|
-
const
|
|
24
|
+
const { openAddPanelGroup , openAddPanel , reset , save } = useDashboardActions();
|
|
25
|
+
const isLaptopSize = useMediaQuery(useTheme().breakpoints.up('sm'));
|
|
26
26
|
const onEditButtonClick = ()=>{
|
|
27
27
|
setEditMode(true);
|
|
28
28
|
};
|
|
29
29
|
const onCancelButtonClick = ()=>{
|
|
30
|
+
reset();
|
|
31
|
+
setEditMode(false);
|
|
32
|
+
};
|
|
33
|
+
const onSave = ()=>{
|
|
34
|
+
save();
|
|
30
35
|
setEditMode(false);
|
|
31
36
|
};
|
|
32
37
|
return /*#__PURE__*/ _jsx(_Fragment, {
|
|
@@ -57,6 +62,7 @@ export const DashboardToolbar = (props)=>{
|
|
|
57
62
|
children: [
|
|
58
63
|
/*#__PURE__*/ _jsx(Button, {
|
|
59
64
|
variant: "contained",
|
|
65
|
+
onClick: onSave,
|
|
60
66
|
children: "Save"
|
|
61
67
|
}),
|
|
62
68
|
/*#__PURE__*/ _jsx(Button, {
|
|
@@ -90,12 +96,12 @@ export const DashboardToolbar = (props)=>{
|
|
|
90
96
|
children: [
|
|
91
97
|
/*#__PURE__*/ _jsx(Button, {
|
|
92
98
|
startIcon: /*#__PURE__*/ _jsx(AddPanelGroupIcon, {}),
|
|
93
|
-
onClick:
|
|
99
|
+
onClick: openAddPanelGroup,
|
|
94
100
|
children: "Add Panel Group"
|
|
95
101
|
}),
|
|
96
102
|
/*#__PURE__*/ _jsx(Button, {
|
|
97
103
|
startIcon: /*#__PURE__*/ _jsx(AddPanelIcon, {}),
|
|
98
|
-
onClick:
|
|
104
|
+
onClick: openAddPanel,
|
|
99
105
|
children: "Add Panel"
|
|
100
106
|
}),
|
|
101
107
|
/*#__PURE__*/ _jsx(TimeRangeControls, {})
|
|
@@ -126,7 +132,7 @@ export const DashboardToolbar = (props)=>{
|
|
|
126
132
|
},
|
|
127
133
|
children: [
|
|
128
134
|
/*#__PURE__*/ _jsx(TimeRangeControls, {}),
|
|
129
|
-
/*#__PURE__*/ _jsx(Button, {
|
|
135
|
+
isLaptopSize && /*#__PURE__*/ _jsx(Button, {
|
|
130
136
|
variant: "outlined",
|
|
131
137
|
startIcon: /*#__PURE__*/ _jsx(PencilIcon, {}),
|
|
132
138
|
onClick: onEditButtonClick,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/DashboardToolbar.tsx"],"sourcesContent":["// Copyright 2022 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 { Typography, Stack, Button, Box } from '@mui/material';\nimport PencilIcon from 'mdi-material-ui/PencilOutline';\nimport AddPanelGroupIcon from 'mdi-material-ui/PlusBoxOutline';\nimport AddPanelIcon from 'mdi-material-ui/ChartBoxPlusOutline';\nimport { ErrorBoundary, ErrorAlert } from '@perses-dev/components';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/components/DashboardToolbar.tsx"],"sourcesContent":["// Copyright 2022 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 { Typography, Stack, Button, Box, useTheme, useMediaQuery } from '@mui/material';\nimport PencilIcon from 'mdi-material-ui/PencilOutline';\nimport AddPanelGroupIcon from 'mdi-material-ui/PlusBoxOutline';\nimport AddPanelIcon from 'mdi-material-ui/ChartBoxPlusOutline';\nimport { ErrorBoundary, ErrorAlert } from '@perses-dev/components';\nimport { useDashboardActions, useEditMode } from '../context';\nimport { TemplateVariableList, TimeRangeControls } from '../components';\n\nexport interface DashboardToolbarProps {\n dashboardName: string;\n}\n\nexport const DashboardToolbar = (props: DashboardToolbarProps) => {\n const { dashboardName } = props;\n\n const { isEditMode, setEditMode } = useEditMode();\n const { openAddPanelGroup, openAddPanel, reset, save } = useDashboardActions();\n const isLaptopSize = useMediaQuery(useTheme().breakpoints.up('sm'));\n\n const onEditButtonClick = () => {\n setEditMode(true);\n };\n\n const onCancelButtonClick = () => {\n reset();\n setEditMode(false);\n };\n\n const onSave = () => {\n save();\n setEditMode(false);\n };\n\n return (\n <>\n {isEditMode ? (\n <Stack spacing={2}>\n <Box sx={{ backgroundColor: (theme) => theme.palette.primary.light + '20' }}>\n <Box padding={2} display=\"flex\">\n <Typography variant=\"h2\">Edit {dashboardName}</Typography>\n <Stack direction=\"row\" spacing={1} sx={{ marginLeft: 'auto' }}>\n <Button variant=\"contained\" onClick={onSave}>\n Save\n </Button>\n <Button variant=\"outlined\" onClick={onCancelButtonClick}>\n Cancel\n </Button>\n </Stack>\n </Box>\n </Box>\n <Box\n sx={{\n display: 'flex',\n width: '100%',\n alignItems: 'flex-start',\n padding: (theme) => theme.spacing(2),\n }}\n >\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <TemplateVariableList />\n </ErrorBoundary>\n <Stack direction={'row'} spacing={1} sx={{ marginLeft: 'auto' }}>\n <Button startIcon={<AddPanelGroupIcon />} onClick={openAddPanelGroup}>\n Add Panel Group\n </Button>\n <Button startIcon={<AddPanelIcon />} onClick={openAddPanel}>\n Add Panel\n </Button>\n <TimeRangeControls />\n </Stack>\n </Box>\n </Stack>\n ) : (\n <Stack spacing={2} padding={2}>\n <Box sx={{ display: 'flex', width: '100%' }}>\n <Typography variant=\"h2\">{dashboardName}</Typography>\n <Stack direction=\"row\" spacing={2} sx={{ marginLeft: 'auto' }}>\n <TimeRangeControls />\n {isLaptopSize && (\n <Button\n variant=\"outlined\"\n startIcon={<PencilIcon />}\n onClick={onEditButtonClick}\n sx={{ marginLeft: 'auto' }}\n >\n Edit\n </Button>\n )}\n </Stack>\n </Box>\n <Box paddingY={2}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <TemplateVariableList />\n </ErrorBoundary>\n </Box>\n </Stack>\n )}\n </>\n );\n};\n"],"names":["Typography","Stack","Button","Box","useTheme","useMediaQuery","PencilIcon","AddPanelGroupIcon","AddPanelIcon","ErrorBoundary","ErrorAlert","useDashboardActions","useEditMode","TemplateVariableList","TimeRangeControls","DashboardToolbar","props","dashboardName","isEditMode","setEditMode","openAddPanelGroup","openAddPanel","reset","save","isLaptopSize","breakpoints","up","onEditButtonClick","onCancelButtonClick","onSave","spacing","sx","backgroundColor","theme","palette","primary","light","padding","display","variant","direction","marginLeft","onClick","width","alignItems","FallbackComponent","startIcon","paddingY"],"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;AAAA,SAASA,UAAU,EAAEC,KAAK,EAAEC,MAAM,EAAEC,GAAG,EAAEC,QAAQ,EAAEC,aAAa,QAAQ,eAAe,CAAC;AACxF,OAAOC,UAAU,MAAM,+BAA+B,CAAC;AACvD,OAAOC,iBAAiB,MAAM,gCAAgC,CAAC;AAC/D,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;oBAAC4B,EAAE,EAAE;wBAAEO,OAAO,EAAE,MAAM;wBAAEK,KAAK,EAAE,MAAM;qBAAE;;sCACzC,KAAC3C,UAAU;4BAACuC,OAAO,EAAC,IAAI;sCAAEtB,aAAa;0BAAc;sCACrD,MAAChB,KAAK;4BAACuC,SAAS,EAAC,KAAK;4BAACV,OAAO,EAAE,CAAC;4BAAEC,EAAE,EAAE;gCAAEU,UAAU,EAAE,MAAM;6BAAE;;8CAC3D,KAAC3B,iBAAiB,KAAG;gCACpBU,YAAY,kBACX,KAACtB,MAAM;oCACLqC,OAAO,EAAC,UAAU;oCAClBO,SAAS,gBAAE,KAACxC,UAAU,KAAG;oCACzBoC,OAAO,EAAEf,iBAAiB;oCAC1BI,EAAE,EAAE;wCAAEU,UAAU,EAAE,MAAM;qCAAE;8CAC3B,MAED;kCAAS,AACV;;0BACK;;kBACJ;8BACN,KAACtC,GAAG;oBAAC4C,QAAQ,EAAE,CAAC;8BACd,cAAA,KAACtC,aAAa;wBAACoC,iBAAiB,EAAEnC,UAAU;kCAC1C,cAAA,KAACG,oBAAoB,KAAG;sBACV;kBACZ;;UACA,AACT;MACA,CACH;AACJ,CAAC,CAAC"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
2
|
+
import { LayoutItem } from '../../context';
|
|
3
3
|
export interface GridItemContentProps {
|
|
4
|
-
|
|
5
|
-
itemIndex: number;
|
|
6
|
-
content: GridItemDefinition['content'];
|
|
4
|
+
panelGroupItemId: LayoutItem;
|
|
7
5
|
}
|
|
8
6
|
/**
|
|
9
7
|
* Resolves the reference to panel content in a GridItemDefinition and renders the panel.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GridItemContent.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridItemContent.tsx"],"names":[],"mappings":";AAaA,OAAO,
|
|
1
|
+
{"version":3,"file":"GridItemContent.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridItemContent.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,UAAU,EAAY,MAAM,eAAe,CAAC;AAGrD,MAAM,WAAW,oBAAoB;IACnC,gBAAgB,EAAE,UAAU,CAAC;CAC9B;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,eAI1D"}
|
|
@@ -11,24 +11,16 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
-
import {
|
|
15
|
-
import { usePanels } from '../../context';
|
|
14
|
+
import { usePanel } from '../../context';
|
|
16
15
|
import { Panel } from '../Panel/Panel';
|
|
17
16
|
/**
|
|
18
17
|
* Resolves the reference to panel content in a GridItemDefinition and renders the panel.
|
|
19
18
|
*/ export function GridItemContent(props) {
|
|
20
|
-
const {
|
|
21
|
-
|
|
22
|
-
const { panels } = usePanels();
|
|
23
|
-
const panelKey = getPanelKeyFromRef(content);
|
|
24
|
-
const panelDefinition = panels[panelKey];
|
|
25
|
-
if (panelDefinition === undefined) {
|
|
26
|
-
throw new Error(`Panel with key '${panelKey}' was not found`);
|
|
27
|
-
}
|
|
19
|
+
const { panelGroupItemId } = props;
|
|
20
|
+
const panelDefinition = usePanel(panelGroupItemId);
|
|
28
21
|
return /*#__PURE__*/ _jsx(Panel, {
|
|
29
22
|
definition: panelDefinition,
|
|
30
|
-
|
|
31
|
-
itemIndex: itemIndex
|
|
23
|
+
panelGroupItemId: panelGroupItemId
|
|
32
24
|
});
|
|
33
25
|
}
|
|
34
26
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/GridLayout/GridItemContent.tsx"],"sourcesContent":["// Copyright 2022 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 {
|
|
1
|
+
{"version":3,"sources":["../../../src/components/GridLayout/GridItemContent.tsx"],"sourcesContent":["// Copyright 2022 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 { LayoutItem, usePanel } from '../../context';\nimport { Panel } from '../Panel/Panel';\n\nexport interface GridItemContentProps {\n panelGroupItemId: LayoutItem;\n}\n\n/**\n * Resolves the reference to panel content in a GridItemDefinition and renders the panel.\n */\nexport function GridItemContent(props: GridItemContentProps) {\n const { panelGroupItemId } = props;\n const panelDefinition = usePanel(panelGroupItemId);\n return <Panel definition={panelDefinition} panelGroupItemId={panelGroupItemId} />;\n}\n"],"names":["usePanel","Panel","GridItemContent","props","panelGroupItemId","panelDefinition","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;AAAA,SAAqBA,QAAQ,QAAQ,eAAe,CAAC;AACrD,SAASC,KAAK,QAAQ,gBAAgB,CAAC;AAMvC;;CAEC,GACD,OAAO,SAASC,eAAe,CAACC,KAA2B,EAAE;IAC3D,MAAM,EAAEC,gBAAgB,CAAA,EAAE,GAAGD,KAAK,AAAC;IACnC,MAAME,eAAe,GAAGL,QAAQ,CAACI,gBAAgB,CAAC,AAAC;IACnD,qBAAO,KAACH,KAAK;QAACK,UAAU,EAAED,eAAe;QAAED,gBAAgB,EAAEA,gBAAgB;MAAI,CAAC;AACpF,CAAC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { BoxProps } from '@mui/material';
|
|
3
|
-
import {
|
|
3
|
+
import { PanelGroupId } from '../../context';
|
|
4
4
|
export interface GridLayoutProps extends BoxProps {
|
|
5
|
-
|
|
6
|
-
groupDefinition: PanelGroupDefinition;
|
|
5
|
+
panelGroupId: PanelGroupId;
|
|
7
6
|
}
|
|
8
7
|
/**
|
|
9
8
|
* Layout component that arranges children in a Grid based on the definition.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GridLayout.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridLayout.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAO,QAAQ,EAA0B,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"GridLayout.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridLayout.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAO,QAAQ,EAA0B,MAAM,eAAe,CAAC;AAGtE,OAAO,EAA8B,YAAY,EAAE,MAAM,eAAe,CAAC;AAMzE,MAAM,WAAW,eAAgB,SAAQ,QAAQ;IAC/C,YAAY,EAAE,YAAY,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,eA6ChD"}
|
|
@@ -16,14 +16,15 @@ import { Responsive, WidthProvider } from 'react-grid-layout';
|
|
|
16
16
|
import { Box, Collapse, GlobalStyles } from '@mui/material';
|
|
17
17
|
import { ErrorAlert, ErrorBoundary } from '@perses-dev/components';
|
|
18
18
|
import { styles } from '../../css/styles';
|
|
19
|
-
import { useEditMode } from '../../context';
|
|
19
|
+
import { useEditMode, usePanelGroup } from '../../context';
|
|
20
20
|
import { GridTitle } from './GridTitle';
|
|
21
21
|
import { GridItemContent } from './GridItemContent';
|
|
22
22
|
const ResponsiveGridLayout = WidthProvider(Responsive);
|
|
23
23
|
/**
|
|
24
24
|
* Layout component that arranges children in a Grid based on the definition.
|
|
25
25
|
*/ export function GridLayout(props) {
|
|
26
|
-
const {
|
|
26
|
+
const { panelGroupId , ...others } = props;
|
|
27
|
+
const groupDefinition = usePanelGroup(panelGroupId);
|
|
27
28
|
var ref;
|
|
28
29
|
const [isOpen, setIsOpen] = useState((ref = !groupDefinition.isCollapsed) !== null && ref !== void 0 ? ref : true);
|
|
29
30
|
const { isEditMode } = useEditMode();
|
|
@@ -42,7 +43,7 @@ const ResponsiveGridLayout = WidthProvider(Responsive);
|
|
|
42
43
|
},
|
|
43
44
|
children: [
|
|
44
45
|
groupDefinition.title !== undefined && /*#__PURE__*/ _jsx(GridTitle, {
|
|
45
|
-
|
|
46
|
+
panelGroupId: panelGroupId,
|
|
46
47
|
title: groupDefinition.title,
|
|
47
48
|
collapse: groupDefinition.isCollapsed === undefined ? undefined : {
|
|
48
49
|
isOpen,
|
|
@@ -75,7 +76,7 @@ const ResponsiveGridLayout = WidthProvider(Responsive);
|
|
|
75
76
|
],
|
|
76
77
|
isDraggable: isEditMode,
|
|
77
78
|
isResizable: isEditMode,
|
|
78
|
-
children: groupDefinition.items.map(({ x , y , width , height
|
|
79
|
+
children: groupDefinition.items.map(({ x , y , width , height }, itemIndex)=>/*#__PURE__*/ _jsx("div", {
|
|
79
80
|
"data-grid": {
|
|
80
81
|
x,
|
|
81
82
|
y,
|
|
@@ -85,9 +86,10 @@ const ResponsiveGridLayout = WidthProvider(Responsive);
|
|
|
85
86
|
children: /*#__PURE__*/ _jsx(ErrorBoundary, {
|
|
86
87
|
FallbackComponent: ErrorAlert,
|
|
87
88
|
children: /*#__PURE__*/ _jsx(GridItemContent, {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
panelGroupItemId: {
|
|
90
|
+
panelGroupId,
|
|
91
|
+
itemIndex
|
|
92
|
+
}
|
|
91
93
|
})
|
|
92
94
|
})
|
|
93
95
|
}, itemIndex))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/GridLayout/GridLayout.tsx"],"sourcesContent":["// Copyright 2022 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.\nimport { useState } from 'react';\nimport { Responsive, WidthProvider } from 'react-grid-layout';\nimport { Box, BoxProps, Collapse, GlobalStyles } from '@mui/material';\nimport { ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport { styles } from '../../css/styles';\nimport { useEditMode
|
|
1
|
+
{"version":3,"sources":["../../../src/components/GridLayout/GridLayout.tsx"],"sourcesContent":["// Copyright 2022 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.\nimport { useState } from 'react';\nimport { Responsive, WidthProvider } from 'react-grid-layout';\nimport { Box, BoxProps, Collapse, GlobalStyles } from '@mui/material';\nimport { ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport { styles } from '../../css/styles';\nimport { useEditMode, usePanelGroup, PanelGroupId } from '../../context';\nimport { GridTitle } from './GridTitle';\nimport { GridItemContent } from './GridItemContent';\n\nconst ResponsiveGridLayout = WidthProvider(Responsive);\n\nexport interface GridLayoutProps extends BoxProps {\n panelGroupId: PanelGroupId;\n}\n\n/**\n * Layout component that arranges children in a Grid based on the definition.\n */\nexport function GridLayout(props: GridLayoutProps) {\n const { panelGroupId, ...others } = props;\n const groupDefinition = usePanelGroup(panelGroupId);\n\n const [isOpen, setIsOpen] = useState(!groupDefinition.isCollapsed ?? true);\n const { isEditMode } = useEditMode();\n\n return (\n <>\n <GlobalStyles styles={styles} />\n <Box {...others} component=\"section\" sx={{ '& + &': { marginTop: (theme) => theme.spacing(1) } }}>\n {groupDefinition.title !== undefined && (\n <GridTitle\n panelGroupId={panelGroupId}\n title={groupDefinition.title}\n collapse={\n groupDefinition.isCollapsed === undefined\n ? undefined\n : { isOpen, onToggleOpen: () => setIsOpen((current) => !current) }\n }\n />\n )}\n <Collapse in={isOpen} unmountOnExit>\n <ResponsiveGridLayout\n className=\"layout\"\n breakpoints={{ lg: 1200, md: 996, sm: 768, xs: 480, xxs: 0 }}\n cols={{ lg: 24, md: 24, sm: 24, xs: 24, xxs: 2 }}\n rowHeight={30}\n draggableHandle={'.drag-handle'}\n resizeHandles={['se']}\n isDraggable={isEditMode}\n isResizable={isEditMode}\n >\n {groupDefinition.items.map(({ x, y, width, height }, itemIndex) => (\n <div key={itemIndex} data-grid={{ x, y, w: width, h: height }}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <GridItemContent panelGroupItemId={{ panelGroupId, itemIndex }} />\n </ErrorBoundary>\n </div>\n ))}\n </ResponsiveGridLayout>\n </Collapse>\n </Box>\n </>\n );\n}\n"],"names":["useState","Responsive","WidthProvider","Box","Collapse","GlobalStyles","ErrorAlert","ErrorBoundary","styles","useEditMode","usePanelGroup","GridTitle","GridItemContent","ResponsiveGridLayout","GridLayout","props","panelGroupId","others","groupDefinition","isOpen","setIsOpen","isCollapsed","isEditMode","component","sx","marginTop","theme","spacing","title","undefined","collapse","onToggleOpen","current","in","unmountOnExit","className","breakpoints","lg","md","sm","xs","xxs","cols","rowHeight","draggableHandle","resizeHandles","isDraggable","isResizable","items","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,EAAE;wCAAEN,CAAC;wCAAEC,CAAC;wCAAEM,CAAC,EAAEL,KAAK;wCAAEM,CAAC,EAAEL,MAAM;qCAAE;8CAC3D,cAAA,KAAC9C,aAAa;wCAACoD,iBAAiB,EAAErD,UAAU;kDAC1C,cAAA,KAACM,eAAe;4CAACgD,gBAAgB,EAAE;gDAAE5C,YAAY;gDAAEsC,SAAS;6CAAE;0CAAI;sCACpD;mCAHRA,SAAS,CAIb,AACP,CAAC;0BACmB;sBACd;;cACP;;MACL,CACH;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GridTitle.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridTitle.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"GridTitle.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridTitle.tsx"],"names":[],"mappings":";AAsBA,OAAO,EAAqC,YAAY,EAAE,MAAM,eAAe,CAAC;AAEhF,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,YAAY,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE;QACT,MAAM,EAAE,OAAO,CAAC;QAChB,YAAY,EAAE,MAAM,IAAI,CAAC;KAC1B,CAAC;CACH;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,eAyD9C"}
|
|
@@ -20,17 +20,15 @@ import PencilIcon from 'mdi-material-ui/PencilOutline';
|
|
|
20
20
|
import ArrowUpIcon from 'mdi-material-ui/ArrowUp';
|
|
21
21
|
import ArrowDownIcon from 'mdi-material-ui/ArrowDown';
|
|
22
22
|
import DeleteIcon from 'mdi-material-ui/DeleteOutline';
|
|
23
|
-
import {
|
|
23
|
+
import { usePanelGroupActions, useEditMode } from '../../context';
|
|
24
24
|
/**
|
|
25
25
|
* Renders the title for a Grid section, optionally also supporting expanding
|
|
26
26
|
* and collapsing
|
|
27
27
|
*/ export function GridTitle(props) {
|
|
28
|
-
const {
|
|
28
|
+
const { panelGroupId , title , collapse } = props;
|
|
29
29
|
const [isHovered, setIsHovered] = useState(false);
|
|
30
|
-
const {
|
|
31
|
-
const { addPanel } = usePanels();
|
|
30
|
+
const { openAddPanel , openEditPanelGroup , deletePanelGroup , moveUp , moveDown } = usePanelGroupActions(panelGroupId);
|
|
32
31
|
const { isEditMode } = useEditMode();
|
|
33
|
-
const { layouts , swapPanelGroups } = useLayouts();
|
|
34
32
|
const text = /*#__PURE__*/ _jsx(Typography, {
|
|
35
33
|
variant: "h2",
|
|
36
34
|
sx: {
|
|
@@ -63,29 +61,29 @@ import { usePanelGroupDialog, useEditMode, useLayouts, usePanels } from '../../c
|
|
|
63
61
|
children: [
|
|
64
62
|
/*#__PURE__*/ _jsx(IconButton, {
|
|
65
63
|
"aria-label": "add panel to group",
|
|
66
|
-
onClick:
|
|
64
|
+
onClick: openAddPanel,
|
|
67
65
|
children: /*#__PURE__*/ _jsx(AddIcon, {})
|
|
68
66
|
}),
|
|
69
67
|
/*#__PURE__*/ _jsx(IconButton, {
|
|
70
68
|
"aria-label": "edit group",
|
|
71
|
-
onClick:
|
|
69
|
+
onClick: openEditPanelGroup,
|
|
72
70
|
children: /*#__PURE__*/ _jsx(PencilIcon, {})
|
|
73
71
|
}),
|
|
74
72
|
/*#__PURE__*/ _jsx(IconButton, {
|
|
75
73
|
"aria-label": "delete group",
|
|
76
|
-
onClick:
|
|
74
|
+
onClick: deletePanelGroup,
|
|
77
75
|
children: /*#__PURE__*/ _jsx(DeleteIcon, {})
|
|
78
76
|
}),
|
|
79
77
|
/*#__PURE__*/ _jsx(IconButton, {
|
|
80
78
|
"aria-label": "move group down",
|
|
81
|
-
disabled:
|
|
82
|
-
onClick:
|
|
79
|
+
disabled: moveDown === undefined,
|
|
80
|
+
onClick: moveDown,
|
|
83
81
|
children: /*#__PURE__*/ _jsx(ArrowDownIcon, {})
|
|
84
82
|
}),
|
|
85
83
|
/*#__PURE__*/ _jsx(IconButton, {
|
|
86
84
|
"aria-label": "move group up",
|
|
87
|
-
disabled:
|
|
88
|
-
onClick:
|
|
85
|
+
disabled: moveUp === undefined,
|
|
86
|
+
onClick: moveUp,
|
|
89
87
|
children: /*#__PURE__*/ _jsx(ArrowUpIcon, {})
|
|
90
88
|
})
|
|
91
89
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/GridLayout/GridTitle.tsx"],"sourcesContent":["// Copyright 2022 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, IconButton, Stack, Typography } from '@mui/material';\nimport ExpandedIcon from 'mdi-material-ui/ChevronUp';\nimport CollapsedIcon from 'mdi-material-ui/ChevronDown';\nimport AddIcon from 'mdi-material-ui/Plus';\nimport PencilIcon from 'mdi-material-ui/PencilOutline';\nimport ArrowUpIcon from 'mdi-material-ui/ArrowUp';\nimport ArrowDownIcon from 'mdi-material-ui/ArrowDown';\nimport DeleteIcon from 'mdi-material-ui/DeleteOutline';\
|
|
1
|
+
{"version":3,"sources":["../../../src/components/GridLayout/GridTitle.tsx"],"sourcesContent":["// Copyright 2022 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, IconButton, Stack, Typography } from '@mui/material';\nimport ExpandedIcon from 'mdi-material-ui/ChevronUp';\nimport CollapsedIcon from 'mdi-material-ui/ChevronDown';\nimport AddIcon from 'mdi-material-ui/Plus';\nimport PencilIcon from 'mdi-material-ui/PencilOutline';\nimport ArrowUpIcon from 'mdi-material-ui/ArrowUp';\nimport ArrowDownIcon from 'mdi-material-ui/ArrowDown';\nimport DeleteIcon from 'mdi-material-ui/DeleteOutline';\nimport { usePanelGroupActions, useEditMode, PanelGroupId } from '../../context';\n\nexport interface GridTitleProps {\n panelGroupId: PanelGroupId;\n title: string;\n collapse?: {\n isOpen: boolean;\n onToggleOpen: () => void;\n };\n}\n\n/**\n * Renders the title for a Grid section, optionally also supporting expanding\n * and collapsing\n */\nexport function GridTitle(props: GridTitleProps) {\n const { panelGroupId, title, collapse } = props;\n\n const [isHovered, setIsHovered] = useState(false);\n const { openAddPanel, openEditPanelGroup, deletePanelGroup, moveUp, moveDown } = usePanelGroupActions(panelGroupId);\n const { isEditMode } = useEditMode();\n\n const text = (\n <Typography variant=\"h2\" sx={{ marginLeft: collapse !== undefined ? 1 : undefined }}>\n {title}\n </Typography>\n );\n\n return (\n <Box\n sx={{\n display: 'flex',\n justifyContent: 'start',\n alignItems: 'center',\n padding: (theme) => theme.spacing(1),\n backgroundColor: (theme) => theme.palette.background.default,\n }}\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => setIsHovered(false)}\n >\n {collapse ? (\n <>\n <IconButton onClick={collapse.onToggleOpen}>\n {collapse.isOpen ? <ExpandedIcon /> : <CollapsedIcon />}\n </IconButton>\n {text}\n {isEditMode && isHovered && (\n <Stack direction=\"row\" sx={{ marginLeft: 'auto' }}>\n <IconButton aria-label=\"add panel to group\" onClick={openAddPanel}>\n <AddIcon />\n </IconButton>\n <IconButton aria-label=\"edit group\" onClick={openEditPanelGroup}>\n <PencilIcon />\n </IconButton>\n <IconButton aria-label=\"delete group\" onClick={deletePanelGroup}>\n <DeleteIcon />\n </IconButton>\n <IconButton aria-label=\"move group down\" disabled={moveDown === undefined} onClick={moveDown}>\n <ArrowDownIcon />\n </IconButton>\n <IconButton aria-label=\"move group up\" disabled={moveUp === undefined} onClick={moveUp}>\n <ArrowUpIcon />\n </IconButton>\n </Stack>\n )}\n </>\n ) : (\n // If we don't need expand/collapse, just render the title text\n text\n )}\n </Box>\n );\n}\n"],"names":["useState","Box","IconButton","Stack","Typography","ExpandedIcon","CollapsedIcon","AddIcon","PencilIcon","ArrowUpIcon","ArrowDownIcon","DeleteIcon","usePanelGroupActions","useEditMode","GridTitle","props","panelGroupId","title","collapse","isHovered","setIsHovered","openAddPanel","openEditPanelGroup","deletePanelGroup","moveUp","moveDown","isEditMode","text","variant","sx","marginLeft","undefined","display","justifyContent","alignItems","padding","theme","spacing","backgroundColor","palette","background","default","onMouseEnter","onMouseLeave","onClick","onToggleOpen","isOpen","direction","aria-label","disabled"],"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;AAAA,SAASA,QAAQ,QAAQ,OAAO,CAAC;AACjC,SAASC,GAAG,EAAEC,UAAU,EAAEC,KAAK,EAAEC,UAAU,QAAQ,eAAe,CAAC;AACnE,OAAOC,YAAY,MAAM,2BAA2B,CAAC;AACrD,OAAOC,aAAa,MAAM,6BAA6B,CAAC;AACxD,OAAOC,OAAO,MAAM,sBAAsB,CAAC;AAC3C,OAAOC,UAAU,MAAM,+BAA+B,CAAC;AACvD,OAAOC,WAAW,MAAM,yBAAyB,CAAC;AAClD,OAAOC,aAAa,MAAM,2BAA2B,CAAC;AACtD,OAAOC,UAAU,MAAM,+BAA+B,CAAC;AACvD,SAASC,oBAAoB,EAAEC,WAAW,QAAsB,eAAe,CAAC;AAWhF;;;CAGC,GACD,OAAO,SAASC,SAAS,CAACC,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BAAC4C,SAAS,EAAC,KAAK;oBAAClB,EAAE,EAAE;wBAAEC,UAAU,EAAE,MAAM;qBAAE;;sCAC/C,KAAC5B,UAAU;4BAAC8C,YAAU,EAAC,oBAAoB;4BAACJ,OAAO,EAAEvB,YAAY;sCAC/D,cAAA,KAACd,OAAO,KAAG;0BACA;sCACb,KAACL,UAAU;4BAAC8C,YAAU,EAAC,YAAY;4BAACJ,OAAO,EAAEtB,kBAAkB;sCAC7D,cAAA,KAACd,UAAU,KAAG;0BACH;sCACb,KAACN,UAAU;4BAAC8C,YAAU,EAAC,cAAc;4BAACJ,OAAO,EAAErB,gBAAgB;sCAC7D,cAAA,KAACZ,UAAU,KAAG;0BACH;sCACb,KAACT,UAAU;4BAAC8C,YAAU,EAAC,iBAAiB;4BAACC,QAAQ,EAAExB,QAAQ,KAAKM,SAAS;4BAAEa,OAAO,EAAEnB,QAAQ;sCAC1F,cAAA,KAACf,aAAa,KAAG;0BACN;sCACb,KAACR,UAAU;4BAAC8C,YAAU,EAAC,eAAe;4BAACC,QAAQ,EAAEzB,MAAM,KAAKO,SAAS;4BAAEa,OAAO,EAAEpB,MAAM;sCACpF,cAAA,KAACf,WAAW,KAAG;0BACJ;;kBACP,AACT;;UACA,GAEH,+DAA+D;QAC/DkB,IAAI,AACL;MACG,CACN;AACJ,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { DeletePanelDialog } from '../../context/DashboardProvider/panel-
|
|
2
|
+
import { DeletePanelDialog } from '../../context/DashboardProvider/panel-editor-slice';
|
|
3
3
|
declare const DeletePanelDialog: () => JSX.Element;
|
|
4
4
|
export default DeletePanelDialog;
|
|
5
5
|
//# sourceMappingURL=DeletePanelDialog.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeletePanelDialog.d.ts","sourceRoot":"","sources":["../../../src/components/Panel/DeletePanelDialog.tsx"],"names":[],"mappings":";AAiBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"DeletePanelDialog.d.ts","sourceRoot":"","sources":["../../../src/components/Panel/DeletePanelDialog.tsx"],"names":[],"mappings":";AAiBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oDAAoD,CAAC;AAEvF,QAAA,MAAM,iBAAiB,mBAoBtB,CAAC;AA+BF,eAAe,iBAAiB,CAAC"}
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
14
|
import { IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@mui/material';
|
|
15
15
|
import CloseIcon from 'mdi-material-ui/Close';
|
|
16
|
-
import {
|
|
16
|
+
import { useDeletePanelDialog } from '../../context';
|
|
17
17
|
const DeletePanelDialog = ()=>{
|
|
18
|
-
const { deletePanelDialog , closeDeletePanelDialog } =
|
|
18
|
+
const { deletePanelDialog , closeDeletePanelDialog } = useDeletePanelDialog();
|
|
19
19
|
return /*#__PURE__*/ _jsxs(Dialog, {
|
|
20
20
|
open: deletePanelDialog !== undefined,
|
|
21
21
|
children: [
|
|
@@ -39,25 +39,29 @@ const DeletePanelDialog = ()=>{
|
|
|
39
39
|
});
|
|
40
40
|
};
|
|
41
41
|
const DeletePanelForm = ({ deletePanelDialog })=>{
|
|
42
|
-
|
|
43
|
-
const { layouts } = useLayouts();
|
|
44
|
-
const { deletePanels , closeDeletePanelDialog } = usePanels();
|
|
42
|
+
const { deletePanels , closeDeletePanelDialog } = useDeletePanelDialog();
|
|
45
43
|
const handleDelete = (e)=>{
|
|
46
44
|
e.preventDefault();
|
|
47
|
-
const {
|
|
45
|
+
const { panelGroupItemId } = deletePanelDialog;
|
|
48
46
|
deletePanels([
|
|
49
|
-
|
|
47
|
+
panelGroupItemId
|
|
50
48
|
]);
|
|
51
49
|
closeDeletePanelDialog();
|
|
52
50
|
};
|
|
53
51
|
return /*#__PURE__*/ _jsxs("form", {
|
|
54
52
|
onSubmit: handleDelete,
|
|
55
53
|
children: [
|
|
56
|
-
/*#__PURE__*/
|
|
54
|
+
/*#__PURE__*/ _jsxs(DialogContent, {
|
|
57
55
|
sx: {
|
|
58
56
|
width: '500px'
|
|
59
57
|
},
|
|
60
|
-
children:
|
|
58
|
+
children: [
|
|
59
|
+
"Are you sure you want to delete ",
|
|
60
|
+
deletePanelDialog.panelName,
|
|
61
|
+
" from ",
|
|
62
|
+
deletePanelDialog.panelGroupName,
|
|
63
|
+
"? This action cannot be undone."
|
|
64
|
+
]
|
|
61
65
|
}),
|
|
62
66
|
/*#__PURE__*/ _jsxs(DialogActions, {
|
|
63
67
|
children: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Panel/DeletePanelDialog.tsx"],"sourcesContent":["// Copyright 2022 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 { FormEvent } from 'react';\nimport { IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@mui/material';\nimport CloseIcon from 'mdi-material-ui/Close';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Panel/DeletePanelDialog.tsx"],"sourcesContent":["// Copyright 2022 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 { FormEvent } from 'react';\nimport { IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@mui/material';\nimport CloseIcon from 'mdi-material-ui/Close';\nimport { useDeletePanelDialog } from '../../context';\nimport { DeletePanelDialog } from '../../context/DashboardProvider/panel-editor-slice';\n\nconst DeletePanelDialog = () => {\n const { deletePanelDialog, closeDeletePanelDialog } = useDeletePanelDialog();\n\n return (\n <Dialog open={deletePanelDialog !== undefined}>\n <DialogTitle>Delete Panel</DialogTitle>\n <IconButton\n aria-label=\"Close\"\n onClick={() => closeDeletePanelDialog()}\n sx={(theme) => ({\n position: 'absolute',\n top: theme.spacing(0.5),\n right: theme.spacing(0.5),\n })}\n >\n <CloseIcon />\n </IconButton>\n {deletePanelDialog && <DeletePanelForm deletePanelDialog={deletePanelDialog} />}\n </Dialog>\n );\n};\n\ninterface DeletePanelFormProps {\n deletePanelDialog: DeletePanelDialog;\n}\n\nconst DeletePanelForm = ({ deletePanelDialog }: DeletePanelFormProps) => {\n const { deletePanels, closeDeletePanelDialog } = useDeletePanelDialog();\n\n const handleDelete = (e: FormEvent) => {\n e.preventDefault();\n const { panelGroupItemId } = deletePanelDialog;\n deletePanels([panelGroupItemId]);\n closeDeletePanelDialog();\n };\n return (\n <form onSubmit={handleDelete}>\n <DialogContent sx={{ width: '500px' }}>\n Are you sure you want to delete {deletePanelDialog.panelName} from {deletePanelDialog.panelGroupName}? This\n action cannot be undone.\n </DialogContent>\n <DialogActions>\n <Button variant=\"contained\" type=\"submit\">\n Delete\n </Button>\n <Button onClick={() => closeDeletePanelDialog()}>Cancel</Button>\n </DialogActions>\n </form>\n );\n};\n\nexport default DeletePanelDialog;\n"],"names":["IconButton","Dialog","DialogTitle","DialogContent","DialogActions","Button","CloseIcon","useDeletePanelDialog","DeletePanelDialog","deletePanelDialog","closeDeletePanelDialog","open","undefined","aria-label","onClick","sx","theme","position","top","spacing","right","DeletePanelForm","deletePanels","handleDelete","e","preventDefault","panelGroupItemId","form","onSubmit","width","panelName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CAACC,CAAY,GAAK;QACrCA,CAAC,CAACC,cAAc,EAAE,CAAC;QACnB,MAAM,EAAEC,gBAAgB,CAAA,EAAE,GAAGjB,iBAAiB,AAAC;QAC/Ca,YAAY,CAAC;YAACI,gBAAgB;SAAC,CAAC,CAAC;QACjChB,sBAAsB,EAAE,CAAC;IAC3B,CAAC,AAAC;IACF,qBACE,MAACiB,MAAI;QAACC,QAAQ,EAAEL,YAAY;;0BAC1B,MAACpB,aAAa;gBAACY,EAAE,EAAE;oBAAEc,KAAK,EAAE,OAAO;iBAAE;;oBAAE,kCACL;oBAACpB,iBAAiB,CAACqB,SAAS;oBAAC,QAAM;oBAACrB,iBAAiB,CAACsB,cAAc;oBAAC,iCAEvG;;cAAgB;0BAChB,MAAC3B,aAAa;;kCACZ,KAACC,MAAM;wBAAC2B,OAAO,EAAC,WAAW;wBAACC,IAAI,EAAC,QAAQ;kCAAC,QAE1C;sBAAS;kCACT,KAAC5B,MAAM;wBAACS,OAAO,EAAE,IAAMJ,sBAAsB,EAAE;kCAAE,QAAM;sBAAS;;cAClD;;MACX,CACP;AACJ,CAAC,AAAC;AAEF,eAAeF,iBAAiB,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { PanelDefinition } from '@perses-dev/core';
|
|
3
3
|
import { CardProps } from '@mui/material';
|
|
4
|
+
import { LayoutItem } from '../../context';
|
|
4
5
|
export interface PanelProps extends CardProps {
|
|
5
6
|
definition: PanelDefinition;
|
|
6
|
-
|
|
7
|
-
itemIndex: number;
|
|
7
|
+
panelGroupItemId: LayoutItem;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* Renders a PanelDefinition's content inside of a Card.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Panel.d.ts","sourceRoot":"","sources":["../../../src/components/Panel/Panel.tsx"],"names":[],"mappings":";AAiBA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAGL,SAAS,EAOV,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"Panel.d.ts","sourceRoot":"","sources":["../../../src/components/Panel/Panel.tsx"],"names":[],"mappings":";AAiBA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAGL,SAAS,EAOV,MAAM,eAAe,CAAC;AAKvB,OAAO,EAAe,UAAU,EAAmB,MAAM,eAAe,CAAC;AAGzE,MAAM,WAAW,UAAW,SAAQ,SAAS;IAC3C,UAAU,EAAE,eAAe,CAAC;IAC5B,gBAAgB,EAAE,UAAU,CAAC;CAC9B;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,eAgItC"}
|
|
@@ -20,12 +20,12 @@ import InformationOutlineIcon from 'mdi-material-ui/InformationOutline';
|
|
|
20
20
|
import PencilIcon from 'mdi-material-ui/Pencil';
|
|
21
21
|
import DeleteIcon from 'mdi-material-ui/DeleteOutline';
|
|
22
22
|
import DragIcon from 'mdi-material-ui/DragVertical';
|
|
23
|
-
import {
|
|
23
|
+
import { useEditMode, usePanelActions } from '../../context';
|
|
24
24
|
import { PanelContent } from './PanelContent';
|
|
25
25
|
/**
|
|
26
26
|
* Renders a PanelDefinition's content inside of a Card.
|
|
27
27
|
*/ export function Panel(props) {
|
|
28
|
-
const { definition ,
|
|
28
|
+
const { definition , panelGroupItemId , ...others } = props;
|
|
29
29
|
const [contentElement, setContentElement] = useState(null);
|
|
30
30
|
const [isHovered, setIsHovered] = useState(false);
|
|
31
31
|
const { width , height } = useResizeObserver({
|
|
@@ -49,13 +49,7 @@ import { PanelContent } from './PanelContent';
|
|
|
49
49
|
// TODO: adjust padding for small panels, consistent way to determine isLargePanel here and in StatChart
|
|
50
50
|
const panelPadding = 1.5;
|
|
51
51
|
const { isEditMode } = useEditMode();
|
|
52
|
-
const {
|
|
53
|
-
const handleEditButtonClick = ()=>{
|
|
54
|
-
editPanel({
|
|
55
|
-
groupIndex,
|
|
56
|
-
itemIndex
|
|
57
|
-
});
|
|
58
|
-
};
|
|
52
|
+
const { openEditPanel , openDeletePanelDialog } = usePanelActions(panelGroupItemId);
|
|
59
53
|
return /*#__PURE__*/ _jsxs(Card, {
|
|
60
54
|
ref: ref,
|
|
61
55
|
sx: {
|
|
@@ -115,16 +109,13 @@ import { PanelContent } from './PanelContent';
|
|
|
115
109
|
/*#__PURE__*/ _jsx(IconButton, {
|
|
116
110
|
"aria-label": "edit panel",
|
|
117
111
|
size: "small",
|
|
118
|
-
onClick:
|
|
112
|
+
onClick: openEditPanel,
|
|
119
113
|
children: /*#__PURE__*/ _jsx(PencilIcon, {})
|
|
120
114
|
}),
|
|
121
115
|
/*#__PURE__*/ _jsx(IconButton, {
|
|
122
116
|
"aria-label": "delete panel",
|
|
123
117
|
size: "small",
|
|
124
|
-
onClick:
|
|
125
|
-
groupIndex,
|
|
126
|
-
itemIndex
|
|
127
|
-
}),
|
|
118
|
+
onClick: openDeletePanelDialog,
|
|
128
119
|
children: /*#__PURE__*/ _jsx(DeleteIcon, {})
|
|
129
120
|
}),
|
|
130
121
|
/*#__PURE__*/ _jsx(IconButton, {
|