@perses-dev/dashboards 0.9.0 → 0.10.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 +7 -11
- package/dist/cjs/components/DashboardToolbar.js +4 -4
- package/dist/cjs/components/GridLayout/GridItemContent.js +13 -13
- package/dist/cjs/components/GridLayout/GridLayout.js +24 -21
- package/dist/cjs/components/GridLayout/GridTitle.js +27 -5
- package/dist/cjs/components/Panel/DeletePanelDialog.js +91 -0
- package/dist/cjs/components/Panel/Panel.js +16 -5
- package/dist/cjs/components/Panel/Panel.test.js +12 -4
- package/dist/cjs/components/Panel/PanelContent.js +3 -2
- package/dist/cjs/components/PanelDrawer/PanelDrawer.js +13 -12
- package/dist/cjs/components/PanelDrawer/PanelDrawer.test.js +8 -12
- package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +77 -35
- package/dist/cjs/components/PanelDrawer/PanelPreview.js +48 -0
- package/dist/cjs/components/PanelGroupDialog/DeletePanelGroupDialog.js +86 -0
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +12 -19
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.test.js +10 -31
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +2 -2
- package/dist/cjs/components/Variables/Variable.js +19 -11
- package/dist/cjs/components/Variables/VariableEditor.js +207 -0
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +236 -0
- package/dist/cjs/components/Variables/VariableEditorForm/index.js +28 -0
- package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +88 -0
- package/dist/cjs/components/Variables/VariableList.js +50 -69
- package/dist/cjs/components/Variables/index.js +1 -0
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +70 -0
- package/dist/cjs/context/DashboardProvider/common.js +18 -0
- package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +71 -0
- package/dist/cjs/context/DashboardProvider/index.js +29 -0
- package/dist/cjs/context/DashboardProvider/layout-slice.js +200 -0
- package/dist/cjs/context/DashboardProvider/panel-editing-slice.js +156 -0
- package/dist/{context/DashboardAppSlice.js → cjs/context/DashboardProvider/panel-group-slice.js} +18 -25
- package/dist/cjs/context/DatasourceStoreProvider.js +109 -7
- package/dist/cjs/context/TemplateVariableProvider.js +8 -1
- package/dist/cjs/context/index.js +0 -2
- package/dist/cjs/test/testDashboard.js +13 -1
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +6 -7
- package/dist/cjs/views/ViewDashboard/tests/panelGroups.test.js +165 -0
- package/dist/components/Dashboard.d.ts +1 -4
- package/dist/components/Dashboard.d.ts.map +1 -1
- package/dist/components/Dashboard.js +8 -12
- package/dist/components/Dashboard.js.map +1 -1
- package/dist/components/DashboardToolbar.d.ts.map +1 -1
- package/dist/components/DashboardToolbar.js +5 -5
- package/dist/components/DashboardToolbar.js.map +1 -1
- package/dist/components/GridLayout/GridItemContent.d.ts +3 -3
- package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
- package/dist/components/GridLayout/GridItemContent.js +14 -14
- 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 +24 -21
- 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 +28 -6
- package/dist/components/GridLayout/GridTitle.js.map +1 -1
- package/dist/components/Panel/DeletePanelDialog.d.ts +5 -0
- package/dist/components/Panel/DeletePanelDialog.d.ts.map +1 -0
- package/dist/components/Panel/DeletePanelDialog.js +80 -0
- package/dist/components/Panel/DeletePanelDialog.js.map +1 -0
- package/dist/components/Panel/Panel.d.ts +1 -1
- package/dist/components/Panel/Panel.d.ts.map +1 -1
- package/dist/components/Panel/Panel.js +17 -6
- package/dist/components/Panel/Panel.js.map +1 -1
- package/dist/components/Panel/Panel.test.js +7 -4
- package/dist/components/Panel/Panel.test.js.map +1 -1
- package/dist/components/Panel/PanelContent.d.ts +4 -1
- package/dist/components/Panel/PanelContent.d.ts.map +1 -1
- package/dist/components/Panel/PanelContent.js +3 -2
- package/dist/components/Panel/PanelContent.js.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.js +14 -13
- package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.test.js +8 -12
- package/dist/components/PanelDrawer/PanelDrawer.test.js.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts +3 -3
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.js +78 -36
- package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.d.ts +4 -0
- package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -0
- package/dist/components/PanelDrawer/PanelPreview.js +42 -0
- package/dist/components/PanelDrawer/PanelPreview.js.map +1 -0
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.d.ts +4 -0
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -0
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.js +75 -0
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.js.map +1 -0
- package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js +13 -20
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js +10 -31
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js +3 -3
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
- package/dist/components/Variables/Variable.js +21 -13
- package/dist/components/Variables/Variable.js.map +1 -1
- package/dist/components/Variables/VariableEditor.d.ts +8 -0
- package/dist/components/Variables/VariableEditor.d.ts.map +1 -0
- package/dist/components/Variables/VariableEditor.js +196 -0
- package/dist/components/Variables/VariableEditor.js.map +1 -0
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +8 -0
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -0
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +225 -0
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -0
- package/dist/components/Variables/VariableEditorForm/index.d.ts +2 -0
- package/dist/components/Variables/VariableEditorForm/index.d.ts.map +1 -0
- package/dist/components/Variables/VariableEditorForm/index.js +15 -0
- package/dist/components/Variables/VariableEditorForm/index.js.map +1 -0
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +21 -0
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -0
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +76 -0
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -0
- package/dist/components/Variables/VariableList.d.ts.map +1 -1
- package/dist/components/Variables/VariableList.js +48 -72
- package/dist/components/Variables/VariableList.js.map +1 -1
- package/dist/components/Variables/index.d.ts +1 -0
- package/dist/components/Variables/index.d.ts.map +1 -1
- package/dist/components/Variables/index.js +1 -0
- package/dist/components/Variables/index.js.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.d.ts +23 -0
- package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -0
- package/dist/context/DashboardProvider/DashboardProvider.js +52 -0
- package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -0
- package/dist/context/DashboardProvider/common.d.ts +5 -0
- package/dist/context/DashboardProvider/common.d.ts.map +1 -0
- package/dist/context/DashboardProvider/common.js +17 -0
- package/dist/context/DashboardProvider/common.js.map +1 -0
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +32 -0
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -0
- package/dist/context/DashboardProvider/dashboard-provider-api.js +56 -0
- package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -0
- package/dist/context/DashboardProvider/index.d.ts +3 -0
- package/dist/context/DashboardProvider/index.d.ts.map +1 -0
- package/dist/context/DashboardProvider/index.js +16 -0
- package/dist/context/DashboardProvider/index.js.map +1 -0
- package/dist/context/DashboardProvider/layout-slice.d.ts +57 -0
- package/dist/context/DashboardProvider/layout-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/layout-slice.js +196 -0
- package/dist/context/DashboardProvider/layout-slice.js.map +1 -0
- package/dist/context/DashboardProvider/panel-editing-slice.d.ts +70 -0
- package/dist/context/DashboardProvider/panel-editing-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/panel-editing-slice.js +152 -0
- package/dist/context/DashboardProvider/panel-editing-slice.js.map +1 -0
- package/dist/context/DashboardProvider/panel-group-slice.d.ts +15 -0
- package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/panel-group-slice.js +32 -0
- package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -0
- package/dist/context/DatasourceStoreProvider.d.ts +10 -2
- package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
- package/dist/context/DatasourceStoreProvider.js +111 -9
- package/dist/context/DatasourceStoreProvider.js.map +1 -1
- package/dist/context/TemplateVariableProvider.d.ts +2 -0
- package/dist/context/TemplateVariableProvider.d.ts.map +1 -1
- package/dist/context/TemplateVariableProvider.js +8 -1
- package/dist/context/TemplateVariableProvider.js.map +1 -1
- package/dist/context/index.d.ts +0 -2
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +0 -2
- package/dist/context/index.js.map +1 -1
- package/dist/test/plugin-registry.d.ts +2 -2
- package/dist/test/plugin-registry.d.ts.map +1 -1
- package/dist/test/plugin-registry.js.map +1 -1
- package/dist/test/testDashboard.d.ts.map +1 -1
- package/dist/test/testDashboard.js +13 -1
- package/dist/test/testDashboard.js.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.js +6 -7
- package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
- package/dist/views/ViewDashboard/tests/panelGroups.test.d.ts +2 -0
- package/dist/views/ViewDashboard/tests/panelGroups.test.d.ts.map +1 -0
- package/dist/views/ViewDashboard/tests/panelGroups.test.js +158 -0
- package/dist/views/ViewDashboard/tests/panelGroups.test.js.map +1 -0
- package/package.json +4 -4
- package/dist/cjs/components/PanelDrawer/PanelSpecEditor.js +0 -40
- package/dist/cjs/components/PanelDrawer/PanelTypeSelect.js +0 -38
- package/dist/cjs/components/PanelDrawer/panel-editor-model.js +0 -140
- package/dist/cjs/context/DashboardAppSlice.js +0 -57
- package/dist/cjs/context/DashboardProvider.js +0 -128
- package/dist/cjs/context/LayoutsSlice.js +0 -55
- package/dist/components/PanelDrawer/PanelSpecEditor.d.ts +0 -7
- package/dist/components/PanelDrawer/PanelSpecEditor.d.ts.map +0 -1
- package/dist/components/PanelDrawer/PanelSpecEditor.js +0 -34
- package/dist/components/PanelDrawer/PanelSpecEditor.js.map +0 -1
- package/dist/components/PanelDrawer/PanelTypeSelect.d.ts +0 -8
- package/dist/components/PanelDrawer/PanelTypeSelect.d.ts.map +0 -1
- package/dist/components/PanelDrawer/PanelTypeSelect.js +0 -34
- package/dist/components/PanelDrawer/PanelTypeSelect.js.map +0 -1
- package/dist/components/PanelDrawer/panel-editor-model.d.ts +0 -27
- package/dist/components/PanelDrawer/panel-editor-model.d.ts.map +0 -1
- package/dist/components/PanelDrawer/panel-editor-model.js +0 -133
- package/dist/components/PanelDrawer/panel-editor-model.js.map +0 -1
- package/dist/context/DashboardAppSlice.d.ts +0 -26
- package/dist/context/DashboardAppSlice.d.ts.map +0 -1
- package/dist/context/DashboardAppSlice.js.map +0 -1
- package/dist/context/DashboardProvider.d.ts +0 -36
- package/dist/context/DashboardProvider.d.ts.map +0 -1
- package/dist/context/DashboardProvider.js +0 -107
- package/dist/context/DashboardProvider.js.map +0 -1
- package/dist/context/LayoutsSlice.d.ts +0 -12
- package/dist/context/LayoutsSlice.d.ts.map +0 -1
- package/dist/context/LayoutsSlice.js +0 -43
- package/dist/context/LayoutsSlice.js.map +0 -1
|
@@ -13,24 +13,20 @@
|
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import { Box } from '@mui/material';
|
|
15
15
|
import { ErrorBoundary, ErrorAlert } from '@perses-dev/components';
|
|
16
|
-
import {
|
|
16
|
+
import { useLayouts } from '../context';
|
|
17
|
+
import { GridLayout } from './GridLayout';
|
|
17
18
|
/**
|
|
18
19
|
* Renders a Dashboard for the provided Dashboard spec.
|
|
19
20
|
*/ export function Dashboard(props) {
|
|
20
|
-
const {
|
|
21
|
+
const { layouts } = useLayouts();
|
|
21
22
|
return /*#__PURE__*/ _jsx(Box, {
|
|
22
|
-
...
|
|
23
|
+
...props,
|
|
23
24
|
children: /*#__PURE__*/ _jsx(ErrorBoundary, {
|
|
24
25
|
FallbackComponent: ErrorAlert,
|
|
25
|
-
children:
|
|
26
|
-
groupIndex:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
content: definition.content,
|
|
30
|
-
spec: spec,
|
|
31
|
-
groupIndex: groupIndex
|
|
32
|
-
})
|
|
33
|
-
}, `${JSON.stringify(spec.layouts)} ${idx}`))
|
|
26
|
+
children: layouts.map((layout, groupIndex)=>/*#__PURE__*/ _jsx(GridLayout, {
|
|
27
|
+
groupIndex: groupIndex,
|
|
28
|
+
groupDefinition: layout
|
|
29
|
+
}, layout.id))
|
|
34
30
|
})
|
|
35
31
|
});
|
|
36
32
|
}
|
|
@@ -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 { useLayouts } 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 { layouts } = useLayouts();\n return (\n <Box {...props}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n {layouts.map((layout, groupIndex) => (\n <GridLayout key={layout.id} groupIndex={groupIndex} groupDefinition={layout} />\n ))}\n </ErrorBoundary>\n </Box>\n );\n}\n"],"names":["Box","ErrorBoundary","ErrorAlert","useLayouts","GridLayout","Dashboard","props","layouts","FallbackComponent","map","layout","groupIndex","groupDefinition","id"],"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,UAAU,QAAQ,YAAY,CAAC;AACxC,SAASC,UAAU,QAAQ,cAAc,CAAC;AAI1C;;CAEC,GACD,OAAO,SAASC,SAAS,CAACC,KAAqB,EAAE;IAC/C,MAAM,EAAEC,OAAO,CAAA,EAAE,GAAGJ,UAAU,EAAE,AAAC;IACjC,qBACE,KAACH,GAAG;QAAE,GAAGM,KAAK;kBACZ,cAAA,KAACL,aAAa;YAACO,iBAAiB,EAAEN,UAAU;sBACzCK,OAAO,CAACE,GAAG,CAAC,CAACC,MAAM,EAAEC,UAAU,iBAC9B,KAACP,UAAU;oBAAiBO,UAAU,EAAEA,UAAU;oBAAEC,eAAe,EAAEF,MAAM;mBAA1DA,MAAM,CAACG,EAAE,CAAqD,AAChF,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,gBA6E5D,CAAC"}
|
|
@@ -16,12 +16,13 @@ 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 { usePanelGroupDialog, useEditMode, usePanels } 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 {
|
|
24
|
+
const { openPanelGroupDialog } = usePanelGroupDialog();
|
|
25
|
+
const { addPanel } = usePanels();
|
|
25
26
|
const onEditButtonClick = ()=>{
|
|
26
27
|
setEditMode(true);
|
|
27
28
|
};
|
|
@@ -72,6 +73,7 @@ export const DashboardToolbar = (props)=>{
|
|
|
72
73
|
sx: {
|
|
73
74
|
display: 'flex',
|
|
74
75
|
width: '100%',
|
|
76
|
+
alignItems: 'flex-start',
|
|
75
77
|
padding: (theme)=>theme.spacing(2)
|
|
76
78
|
},
|
|
77
79
|
children: [
|
|
@@ -93,9 +95,7 @@ export const DashboardToolbar = (props)=>{
|
|
|
93
95
|
}),
|
|
94
96
|
/*#__PURE__*/ _jsx(Button, {
|
|
95
97
|
startIcon: /*#__PURE__*/ _jsx(AddPanelIcon, {}),
|
|
96
|
-
onClick: ()=>
|
|
97
|
-
groupIndex: 0
|
|
98
|
-
}),
|
|
98
|
+
onClick: ()=>addPanel(0),
|
|
99
99
|
children: "Add Panel"
|
|
100
100
|
}),
|
|
101
101
|
/*#__PURE__*/ _jsx(TimeRangeControls, {})
|
|
@@ -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 } 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 { usePanelGroupDialog, useEditMode, usePanels } 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 { openPanelGroupDialog } = usePanelGroupDialog();\n const { addPanel } = usePanels();\n\n const onEditButtonClick = () => {\n setEditMode(true);\n };\n\n const onCancelButtonClick = () => {\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\">Save</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={() => openPanelGroupDialog()}>\n Add Panel Group\n </Button>\n <Button startIcon={<AddPanelIcon />} onClick={() => addPanel(0)}>\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 <Button\n variant=\"outlined\"\n startIcon={<PencilIcon />}\n onClick={onEditButtonClick}\n sx={{ marginLeft: 'auto' }}\n >\n Edit\n </Button>\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","PencilIcon","AddPanelGroupIcon","AddPanelIcon","ErrorBoundary","ErrorAlert","usePanelGroupDialog","useEditMode","usePanels","TemplateVariableList","TimeRangeControls","DashboardToolbar","props","dashboardName","isEditMode","setEditMode","openPanelGroupDialog","addPanel","onEditButtonClick","onCancelButtonClick","spacing","sx","backgroundColor","theme","palette","primary","light","padding","display","variant","direction","marginLeft","onClick","width","alignItems","FallbackComponent","startIcon","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CACT,KAACP,iBAAiB,KAAG;;0BACf;;kBACJ;;UACA,iBAER,MAACZ,KAAK;YAACsB,OAAO,EAAE,CAAC;YAAEO,OAAO,EAAE,CAAC;;8BAC3B,MAAC3B,GAAG;oBAACqB,EAAE,EAAE;wBAAEO,OAAO,EAAE,MAAM;wBAAEK,KAAK,EAAE,MAAM;qBAAE;;sCACzC,KAACpC,UAAU;4BAACgC,OAAO,EAAC,IAAI;sCAAEhB,aAAa;0BAAc;sCACrD,MAACf,KAAK;4BAACgC,SAAS,EAAC,KAAK;4BAACV,OAAO,EAAE,CAAC;4BAAEC,EAAE,EAAE;gCAAEU,UAAU,EAAE,MAAM;6BAAE;;8CAC3D,KAACrB,iBAAiB,KAAG;8CACrB,KAACX,MAAM;oCACL8B,OAAO,EAAC,UAAU;oCAClBO,SAAS,gBAAE,KAACnC,UAAU,KAAG;oCACzB+B,OAAO,EAAEd,iBAAiB;oCAC1BG,EAAE,EAAE;wCAAEU,UAAU,EAAE,MAAM;qCAAE;8CAC3B,MAED;kCAAS;;0BACH;;kBACJ;8BACN,KAAC/B,GAAG;oBAACqC,QAAQ,EAAE,CAAC;8BACd,cAAA,KAACjC,aAAa;wBAAC+B,iBAAiB,EAAE9B,UAAU;kCAC1C,cAAA,KAACI,oBAAoB,KAAG;sBACV;kBACZ;;UACA,AACT;MACA,CACH;AACJ,CAAC,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
2
|
+
import { GridItemDefinition } from '@perses-dev/core';
|
|
3
3
|
export interface GridItemContentProps {
|
|
4
|
-
spec: DashboardSpec;
|
|
5
|
-
content: GridItemDefinition['content'];
|
|
6
4
|
groupIndex: number;
|
|
5
|
+
itemIndex: number;
|
|
6
|
+
content: GridItemDefinition['content'];
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* 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":";
|
|
1
|
+
{"version":3,"file":"GridItemContent.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridItemContent.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAsB,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAI1E,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,kBAAkB,CAAC,SAAS,CAAC,CAAC;CACxC;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,eAW1D"}
|
|
@@ -11,25 +11,25 @@
|
|
|
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 {
|
|
14
|
+
import { getPanelKeyFromRef } from '@perses-dev/core';
|
|
15
|
+
import { usePanels } from '../../context';
|
|
16
16
|
import { Panel } from '../Panel/Panel';
|
|
17
17
|
/**
|
|
18
18
|
* Resolves the reference to panel content in a GridItemDefinition and renders the panel.
|
|
19
19
|
*/ export function GridItemContent(props) {
|
|
20
|
-
const { content ,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
});
|
|
28
|
-
} catch (err) {
|
|
29
|
-
return /*#__PURE__*/ _jsx(ErrorAlert, {
|
|
30
|
-
error: err
|
|
31
|
-
});
|
|
20
|
+
const { content , groupIndex , itemIndex } = props;
|
|
21
|
+
// Find the panel referenced in content in the store
|
|
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`);
|
|
32
27
|
}
|
|
28
|
+
return /*#__PURE__*/ _jsx(Panel, {
|
|
29
|
+
definition: panelDefinition,
|
|
30
|
+
groupIndex: groupIndex,
|
|
31
|
+
itemIndex: itemIndex
|
|
32
|
+
});
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
//# sourceMappingURL=GridItemContent.js.map
|
|
@@ -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 { getPanelKeyFromRef, GridItemDefinition } from '@perses-dev/core';\nimport { usePanels } from '../../context';\nimport { Panel } from '../Panel/Panel';\n\nexport interface GridItemContentProps {\n groupIndex: number;\n itemIndex: number;\n content: GridItemDefinition['content'];\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 { content, groupIndex, itemIndex } = props;\n\n // Find the panel referenced in content in the store\n const { panels } = usePanels();\n const panelKey = getPanelKeyFromRef(content);\n const panelDefinition = panels[panelKey];\n if (panelDefinition === undefined) {\n throw new Error(`Panel with key '${panelKey}' was not found`);\n }\n return <Panel definition={panelDefinition} groupIndex={groupIndex} itemIndex={itemIndex} />;\n}\n"],"names":["getPanelKeyFromRef","usePanels","Panel","GridItemContent","props","content","groupIndex","itemIndex","panels","panelKey","panelDefinition","undefined","Error","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,SAASA,kBAAkB,QAA4B,kBAAkB,CAAC;AAC1E,SAASC,SAAS,QAAQ,eAAe,CAAC;AAC1C,SAASC,KAAK,QAAQ,gBAAgB,CAAC;AAQvC;;CAEC,GACD,OAAO,SAASC,eAAe,CAACC,KAA2B,EAAE;IAC3D,MAAM,EAAEC,OAAO,CAAA,EAAEC,UAAU,CAAA,EAAEC,SAAS,CAAA,EAAE,GAAGH,KAAK,AAAC;IAEjD,oDAAoD;IACpD,MAAM,EAAEI,MAAM,CAAA,EAAE,GAAGP,SAAS,EAAE,AAAC;IAC/B,MAAMQ,QAAQ,GAAGT,kBAAkB,CAACK,OAAO,CAAC,AAAC;IAC7C,MAAMK,eAAe,GAAGF,MAAM,CAACC,QAAQ,CAAC,AAAC;IACzC,IAAIC,eAAe,KAAKC,SAAS,EAAE;QACjC,MAAM,IAAIC,KAAK,CAAC,CAAC,gBAAgB,EAAEH,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAC;IAChE,CAAC;IACD,qBAAO,KAACP,KAAK;QAACW,UAAU,EAAEH,eAAe;QAAEJ,UAAU,EAAEA,UAAU;QAAEC,SAAS,EAAEA,SAAS;MAAI,CAAC;AAC9F,CAAC"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { BoxProps } from '@mui/material';
|
|
3
|
-
import {
|
|
3
|
+
import { PanelGroupDefinition } from '../../context/DashboardProvider/layout-slice';
|
|
4
4
|
export interface GridLayoutProps extends BoxProps {
|
|
5
5
|
groupIndex: number;
|
|
6
|
-
|
|
7
|
-
renderGridItemContent: (definition: GridItemDefinition, groupIndex: number) => React.ReactNode;
|
|
6
|
+
groupDefinition: PanelGroupDefinition;
|
|
8
7
|
}
|
|
9
8
|
/**
|
|
10
9
|
* 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;AAItE,OAAO,EAAE,oBAAoB,EAAE,MAAM,8CAA8C,CAAC;AAMpF,MAAM,WAAW,eAAgB,SAAQ,QAAQ;IAC/C,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,oBAAoB,CAAC;CACvC;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,eA4ChD"}
|
|
@@ -14,31 +14,19 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
14
14
|
import { useState } from 'react';
|
|
15
15
|
import { Responsive, WidthProvider } from 'react-grid-layout';
|
|
16
16
|
import { Box, Collapse, GlobalStyles } from '@mui/material';
|
|
17
|
+
import { ErrorAlert, ErrorBoundary } from '@perses-dev/components';
|
|
17
18
|
import { styles } from '../../css/styles';
|
|
18
19
|
import { useEditMode } from '../../context';
|
|
19
20
|
import { GridTitle } from './GridTitle';
|
|
21
|
+
import { GridItemContent } from './GridItemContent';
|
|
20
22
|
const ResponsiveGridLayout = WidthProvider(Responsive);
|
|
21
23
|
/**
|
|
22
24
|
* Layout component that arranges children in a Grid based on the definition.
|
|
23
25
|
*/ export function GridLayout(props) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const [isOpen, setIsOpen] = useState((ref2 = (ref = spec.display) === null || ref === void 0 ? void 0 : (ref1 = ref.collapse) === null || ref1 === void 0 ? void 0 : ref1.open) !== null && ref2 !== void 0 ? ref2 : true);
|
|
26
|
+
const { groupIndex , groupDefinition , ...others } = props;
|
|
27
|
+
var ref;
|
|
28
|
+
const [isOpen, setIsOpen] = useState((ref = !groupDefinition.isCollapsed) !== null && ref !== void 0 ? ref : true);
|
|
28
29
|
const { isEditMode } = useEditMode();
|
|
29
|
-
const gridItems = [];
|
|
30
|
-
spec.items.forEach((item, idx)=>{
|
|
31
|
-
const { x , y , width: w , height: h } = item;
|
|
32
|
-
gridItems.push(/*#__PURE__*/ _jsx("div", {
|
|
33
|
-
"data-grid": {
|
|
34
|
-
x,
|
|
35
|
-
y,
|
|
36
|
-
w,
|
|
37
|
-
h
|
|
38
|
-
},
|
|
39
|
-
children: renderGridItemContent(item, groupIndex)
|
|
40
|
-
}, idx));
|
|
41
|
-
});
|
|
42
30
|
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
43
31
|
children: [
|
|
44
32
|
/*#__PURE__*/ _jsx(GlobalStyles, {
|
|
@@ -53,10 +41,10 @@ const ResponsiveGridLayout = WidthProvider(Responsive);
|
|
|
53
41
|
}
|
|
54
42
|
},
|
|
55
43
|
children: [
|
|
56
|
-
|
|
44
|
+
groupDefinition.title !== undefined && /*#__PURE__*/ _jsx(GridTitle, {
|
|
57
45
|
groupIndex: groupIndex,
|
|
58
|
-
title:
|
|
59
|
-
collapse:
|
|
46
|
+
title: groupDefinition.title,
|
|
47
|
+
collapse: groupDefinition.isCollapsed === undefined ? undefined : {
|
|
60
48
|
isOpen,
|
|
61
49
|
onToggleOpen: ()=>setIsOpen((current)=>!current)
|
|
62
50
|
}
|
|
@@ -87,7 +75,22 @@ const ResponsiveGridLayout = WidthProvider(Responsive);
|
|
|
87
75
|
],
|
|
88
76
|
isDraggable: isEditMode,
|
|
89
77
|
isResizable: isEditMode,
|
|
90
|
-
children:
|
|
78
|
+
children: groupDefinition.items.map(({ x , y , width , height , content }, itemIndex)=>/*#__PURE__*/ _jsx("div", {
|
|
79
|
+
"data-grid": {
|
|
80
|
+
x,
|
|
81
|
+
y,
|
|
82
|
+
w: width,
|
|
83
|
+
h: height
|
|
84
|
+
},
|
|
85
|
+
children: /*#__PURE__*/ _jsx(ErrorBoundary, {
|
|
86
|
+
FallbackComponent: ErrorAlert,
|
|
87
|
+
children: /*#__PURE__*/ _jsx(GridItemContent, {
|
|
88
|
+
groupIndex: groupIndex,
|
|
89
|
+
itemIndex: itemIndex,
|
|
90
|
+
content: content
|
|
91
|
+
})
|
|
92
|
+
})
|
|
93
|
+
}, itemIndex))
|
|
91
94
|
})
|
|
92
95
|
})
|
|
93
96
|
]
|
|
@@ -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 {
|
|
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 } from '../../context';\nimport { PanelGroupDefinition } from '../../context/DashboardProvider/layout-slice';\nimport { GridTitle } from './GridTitle';\nimport { GridItemContent } from './GridItemContent';\n\nconst ResponsiveGridLayout = WidthProvider(Responsive);\n\nexport interface GridLayoutProps extends BoxProps {\n groupIndex: number;\n groupDefinition: PanelGroupDefinition;\n}\n\n/**\n * Layout component that arranges children in a Grid based on the definition.\n */\nexport function GridLayout(props: GridLayoutProps) {\n const { groupIndex, groupDefinition, ...others } = props;\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 groupIndex={groupIndex}\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, content }, itemIndex) => (\n <div key={itemIndex} data-grid={{ x, y, w: width, h: height }}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <GridItemContent groupIndex={groupIndex} itemIndex={itemIndex} content={content} />\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","GridTitle","GridItemContent","ResponsiveGridLayout","GridLayout","props","groupIndex","groupDefinition","others","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","map","x","y","width","height","content","itemIndex","div","data-grid","w","h","FallbackComponent"],"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;AACjC;AAAA,SAASA,QAAQ,QAAQ,OAAO,CAAC;AACjC,SAASC,UAAU,EAAEC,aAAa,QAAQ,mBAAmB,CAAC;AAC9D,SAASC,GAAG,EAAYC,QAAQ,EAAEC,YAAY,QAAQ,eAAe,CAAC;AACtE,SAASC,UAAU,EAAEC,aAAa,QAAQ,wBAAwB,CAAC;AACnE,SAASC,MAAM,QAAQ,kBAAkB,CAAC;AAC1C,SAASC,WAAW,QAAQ,eAAe,CAAC;AAE5C,SAASC,SAAS,QAAQ,aAAa,CAAC;AACxC,SAASC,eAAe,QAAQ,mBAAmB,CAAC;AAEpD,MAAMC,oBAAoB,GAAGV,aAAa,CAACD,UAAU,CAAC,AAAC;AAOvD;;CAEC,GACD,OAAO,SAASY,UAAU,CA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;gCAAEL,EAAE,EAAE,EAAE;gCAAEC,EAAE,EAAE,EAAE;gCAAEC,EAAE,EAAE,EAAE;gCAAEC,EAAE,EAAE,EAAE;gCAAEC,GAAG,EAAE,CAAC;6BAAE;4BAChDE,SAAS,EAAE,EAAE;4BACbC,eAAe,EAAE,cAAc;4BAC/BC,aAAa,EAAE;gCAAC,IAAI;6BAAC;4BACrBC,WAAW,EAAExB,UAAU;4BACvByB,WAAW,EAAEzB,UAAU;sCAEtBL,eAAe,CAAC+B,KAAK,CAACC,GAAG,CAAC,CAAC,EAAEC,CAAC,CAAA,EAAEC,CAAC,CAAA,EAAEC,KAAK,CAAA,EAAEC,MAAM,CAAA,EAAEC,OAAO,CAAA,EAAE,EAAEC,SAAS,iBACrE,KAACC,KAAG;oCAAiBC,WAAS,EAAE;wCAAEP,CAAC;wCAAEC,CAAC;wCAAEO,CAAC,EAAEN,KAAK;wCAAEO,CAAC,EAAEN,MAAM;qCAAE;8CAC3D,cAAA,KAAC7C,aAAa;wCAACoD,iBAAiB,EAAErD,UAAU;kDAC1C,cAAA,KAACK,eAAe;4CAACI,UAAU,EAAEA,UAAU;4CAAEuC,SAAS,EAAEA,SAAS;4CAAED,OAAO,EAAEA,OAAO;0CAAI;sCACrE;mCAHRC,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":";AAyBA,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,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,eAmE9C"}
|
|
@@ -11,21 +11,26 @@
|
|
|
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 { useState } from 'react';
|
|
14
15
|
import { Box, IconButton, Stack, Typography } from '@mui/material';
|
|
15
16
|
import ExpandedIcon from 'mdi-material-ui/ChevronUp';
|
|
16
17
|
import CollapsedIcon from 'mdi-material-ui/ChevronDown';
|
|
17
18
|
import AddIcon from 'mdi-material-ui/Plus';
|
|
18
19
|
import PencilIcon from 'mdi-material-ui/PencilOutline';
|
|
19
|
-
import
|
|
20
|
-
import
|
|
20
|
+
import ArrowUpIcon from 'mdi-material-ui/ArrowUp';
|
|
21
|
+
import ArrowDownIcon from 'mdi-material-ui/ArrowDown';
|
|
22
|
+
import DeleteIcon from 'mdi-material-ui/DeleteOutline';
|
|
23
|
+
import { usePanelGroupDialog, useEditMode, useLayouts, usePanels } from '../../context';
|
|
21
24
|
/**
|
|
22
25
|
* Renders the title for a Grid section, optionally also supporting expanding
|
|
23
26
|
* and collapsing
|
|
24
27
|
*/ export function GridTitle(props) {
|
|
25
28
|
const { groupIndex , title , collapse } = props;
|
|
26
29
|
const [isHovered, setIsHovered] = useState(false);
|
|
27
|
-
const {
|
|
30
|
+
const { openPanelGroupDialog , openDeletePanelGroupDialog } = usePanelGroupDialog();
|
|
31
|
+
const { addPanel } = usePanels();
|
|
28
32
|
const { isEditMode } = useEditMode();
|
|
33
|
+
const { layouts , swapPanelGroups } = useLayouts();
|
|
29
34
|
const text = /*#__PURE__*/ _jsx(Typography, {
|
|
30
35
|
variant: "h2",
|
|
31
36
|
sx: {
|
|
@@ -57,14 +62,31 @@ import { useDashboardApp, useEditMode } from '../../context';
|
|
|
57
62
|
},
|
|
58
63
|
children: [
|
|
59
64
|
/*#__PURE__*/ _jsx(IconButton, {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}),
|
|
65
|
+
"aria-label": "add panel to group",
|
|
66
|
+
onClick: ()=>addPanel(groupIndex),
|
|
63
67
|
children: /*#__PURE__*/ _jsx(AddIcon, {})
|
|
64
68
|
}),
|
|
65
69
|
/*#__PURE__*/ _jsx(IconButton, {
|
|
70
|
+
"aria-label": "edit group",
|
|
66
71
|
onClick: ()=>openPanelGroupDialog(groupIndex),
|
|
67
72
|
children: /*#__PURE__*/ _jsx(PencilIcon, {})
|
|
73
|
+
}),
|
|
74
|
+
/*#__PURE__*/ _jsx(IconButton, {
|
|
75
|
+
"aria-label": "delete group",
|
|
76
|
+
onClick: ()=>openDeletePanelGroupDialog(groupIndex),
|
|
77
|
+
children: /*#__PURE__*/ _jsx(DeleteIcon, {})
|
|
78
|
+
}),
|
|
79
|
+
/*#__PURE__*/ _jsx(IconButton, {
|
|
80
|
+
"aria-label": "move group down",
|
|
81
|
+
disabled: groupIndex === layouts.length - 1,
|
|
82
|
+
onClick: ()=>swapPanelGroups(groupIndex, groupIndex + 1),
|
|
83
|
+
children: /*#__PURE__*/ _jsx(ArrowDownIcon, {})
|
|
84
|
+
}),
|
|
85
|
+
/*#__PURE__*/ _jsx(IconButton, {
|
|
86
|
+
"aria-label": "move group up",
|
|
87
|
+
disabled: groupIndex === 0,
|
|
88
|
+
onClick: ()=>swapPanelGroups(groupIndex, groupIndex - 1),
|
|
89
|
+
children: /*#__PURE__*/ _jsx(ArrowUpIcon, {})
|
|
68
90
|
})
|
|
69
91
|
]
|
|
70
92
|
})
|
|
@@ -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 { 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
|
|
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';\n\nimport { usePanelGroupDialog, useEditMode, useLayouts, usePanels } from '../../context';\n\nexport interface GridTitleProps {\n groupIndex: number;\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 { groupIndex, title, collapse } = props;\n\n const [isHovered, setIsHovered] = useState(false);\n const { openPanelGroupDialog, openDeletePanelGroupDialog } = usePanelGroupDialog();\n const { addPanel } = usePanels();\n const { isEditMode } = useEditMode();\n const { layouts, swapPanelGroups } = useLayouts();\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={() => addPanel(groupIndex)}>\n <AddIcon />\n </IconButton>\n <IconButton aria-label=\"edit group\" onClick={() => openPanelGroupDialog(groupIndex)}>\n <PencilIcon />\n </IconButton>\n <IconButton aria-label=\"delete group\" onClick={() => openDeletePanelGroupDialog(groupIndex)}>\n <DeleteIcon />\n </IconButton>\n <IconButton\n aria-label=\"move group down\"\n disabled={groupIndex === layouts.length - 1}\n onClick={() => swapPanelGroups(groupIndex, groupIndex + 1)}\n >\n <ArrowDownIcon />\n </IconButton>\n <IconButton\n aria-label=\"move group up\"\n disabled={groupIndex === 0}\n onClick={() => swapPanelGroups(groupIndex, groupIndex - 1)}\n >\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","usePanelGroupDialog","useEditMode","useLayouts","usePanels","GridTitle","props","groupIndex","title","collapse","isHovered","setIsHovered","openPanelGroupDialog","openDeletePanelGroupDialog","addPanel","isEditMode","layouts","swapPanelGroups","text","variant","sx","marginLeft","undefined","display","justifyContent","alignItems","padding","theme","spacing","backgroundColor","palette","background","default","onMouseEnter","onMouseLeave","onClick","onToggleOpen","isOpen","direction","aria-label","disabled","length"],"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;AAEvD,SAASC,mBAAmB,EAAEC,WAAW,EAAEC,UAAU,EAAEC,SAAS,QAAQ,eAAe,CAAC;AAWxF;;;CAGC,GACD,OAAO,SAASC,SAAS,CAACC,KAAqB,EAAE;IAC/C,MAAM,EAAEC,UAAU,CAAA,EAAEC,KAAK,CAAA,EAAEC,QAAQ,CAAA,EAAE,GAAGH,KAAK,AAAC;IAE9C,MAAM,CAACI,SAAS,EAAEC,YAAY,CAAC,GAAGtB,QAAQ,CAAC,KAAK,CAAC,AAAC;IAClD,MAAM,EAAEuB,oBAAoB,CAAA,EAAEC,0BAA0B,CAAA,EAAE,GAAGZ,mBAAmB,EAAE,AAAC;IACnF,MAAM,EAAEa,QAAQ,CAAA,EAAE,GAAGV,SAAS,EAAE,A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AY;4BAACJ,OAAO,EAAE,IAAMvB,oBAAoB,CAACL,UAAU,CAAC;sCACjF,cAAA,KAACV,UAAU,KAAG;0BACH;sCACb,KAACN,UAAU;4BAACgD,YAAU,EAAC,cAAc;4BAACJ,OAAO,EAAE,IAAMtB,0BAA0B,CAACN,UAAU,CAAC;sCACzF,cAAA,KAACP,UAAU,KAAG;0BACH;sCACb,KAACT,UAAU;4BACTgD,YAAU,EAAC,iBAAiB;4BAC5BC,QAAQ,EAAEjC,UAAU,KAAKS,OAAO,CAACyB,MAAM,GAAG,CAAC;4BAC3CN,OAAO,EAAE,IAAMlB,eAAe,CAACV,UAAU,EAAEA,UAAU,GAAG,CAAC,CAAC;sCAE1D,cAAA,KAACR,aAAa,KAAG;0BACN;sCACb,KAACR,UAAU;4BACTgD,YAAU,EAAC,eAAe;4BAC1BC,QAAQ,EAAEjC,UAAU,KAAK,CAAC;4BAC1B4B,OAAO,EAAE,IAAMlB,eAAe,CAACV,UAAU,EAAEA,UAAU,GAAG,CAAC,CAAC;sCAE1D,cAAA,KAACT,WAAW,KAAG;0BACJ;;kBACP,AACT;;UACA,GAEH,+DAA+D;QAC/DoB,IAAI,AACL;MACG,CACN;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeletePanelDialog.d.ts","sourceRoot":"","sources":["../../../src/components/Panel/DeletePanelDialog.tsx"],"names":[],"mappings":";AAiBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qDAAqD,CAAC;AAExF,QAAA,MAAM,iBAAiB,mBAoBtB,CAAC;AA+BF,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@mui/material';
|
|
15
|
+
import CloseIcon from 'mdi-material-ui/Close';
|
|
16
|
+
import { usePanels, useLayouts } from '../../context';
|
|
17
|
+
const DeletePanelDialog = ()=>{
|
|
18
|
+
const { deletePanelDialog , closeDeletePanelDialog } = usePanels();
|
|
19
|
+
return /*#__PURE__*/ _jsxs(Dialog, {
|
|
20
|
+
open: deletePanelDialog !== undefined,
|
|
21
|
+
children: [
|
|
22
|
+
/*#__PURE__*/ _jsx(DialogTitle, {
|
|
23
|
+
children: "Delete Panel"
|
|
24
|
+
}),
|
|
25
|
+
/*#__PURE__*/ _jsx(IconButton, {
|
|
26
|
+
"aria-label": "Close",
|
|
27
|
+
onClick: ()=>closeDeletePanelDialog(),
|
|
28
|
+
sx: (theme)=>({
|
|
29
|
+
position: 'absolute',
|
|
30
|
+
top: theme.spacing(0.5),
|
|
31
|
+
right: theme.spacing(0.5)
|
|
32
|
+
}),
|
|
33
|
+
children: /*#__PURE__*/ _jsx(CloseIcon, {})
|
|
34
|
+
}),
|
|
35
|
+
deletePanelDialog && /*#__PURE__*/ _jsx(DeletePanelForm, {
|
|
36
|
+
deletePanelDialog: deletePanelDialog
|
|
37
|
+
})
|
|
38
|
+
]
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
const DeletePanelForm = ({ deletePanelDialog })=>{
|
|
42
|
+
var ref;
|
|
43
|
+
const { layouts } = useLayouts();
|
|
44
|
+
const { deletePanels , closeDeletePanelDialog } = usePanels();
|
|
45
|
+
const handleDelete = (e)=>{
|
|
46
|
+
e.preventDefault();
|
|
47
|
+
const { layoutItem } = deletePanelDialog;
|
|
48
|
+
deletePanels([
|
|
49
|
+
layoutItem
|
|
50
|
+
]);
|
|
51
|
+
closeDeletePanelDialog();
|
|
52
|
+
};
|
|
53
|
+
return /*#__PURE__*/ _jsxs("form", {
|
|
54
|
+
onSubmit: handleDelete,
|
|
55
|
+
children: [
|
|
56
|
+
/*#__PURE__*/ _jsx(DialogContent, {
|
|
57
|
+
sx: {
|
|
58
|
+
width: '500px'
|
|
59
|
+
},
|
|
60
|
+
children: `Are you sure you want to delete ${deletePanelDialog.panelName} from ${(ref = layouts[deletePanelDialog.layoutItem.groupIndex]) === null || ref === void 0 ? void 0 : ref.title}? This action cannot be undone.`
|
|
61
|
+
}),
|
|
62
|
+
/*#__PURE__*/ _jsxs(DialogActions, {
|
|
63
|
+
children: [
|
|
64
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
65
|
+
variant: "contained",
|
|
66
|
+
type: "submit",
|
|
67
|
+
children: "Delete"
|
|
68
|
+
}),
|
|
69
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
70
|
+
onClick: ()=>closeDeletePanelDialog(),
|
|
71
|
+
children: "Cancel"
|
|
72
|
+
})
|
|
73
|
+
]
|
|
74
|
+
})
|
|
75
|
+
]
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
export default DeletePanelDialog;
|
|
79
|
+
|
|
80
|
+
//# sourceMappingURL=DeletePanelDialog.js.map
|
|
@@ -0,0 +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 { usePanels, useLayouts } from '../../context';\nimport { DeletePanelDialog } from '../../context/DashboardProvider/panel-editing-slice';\n\nconst DeletePanelDialog = () => {\n const { deletePanelDialog, closeDeletePanelDialog } = usePanels();\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 { layouts } = useLayouts();\n const { deletePanels, closeDeletePanelDialog } = usePanels();\n\n const handleDelete = (e: FormEvent) => {\n e.preventDefault();\n const { layoutItem } = deletePanelDialog;\n deletePanels([layoutItem]);\n closeDeletePanelDialog();\n };\n return (\n <form onSubmit={handleDelete}>\n <DialogContent sx={{ width: '500px' }}>{`Are you sure you want to delete ${deletePanelDialog.panelName} from ${\n layouts[deletePanelDialog.layoutItem.groupIndex]?.title\n }? This action cannot be undone.`}</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","usePanels","useLayouts","DeletePanelDialog","deletePanelDialog","closeDeletePanelDialog","open","undefined","aria-label","onClick","sx","theme","position","top","spacing","right","DeletePanelForm","layouts","deletePanels","handleDelete","e","preventDefault","layoutItem","form","onSubmit","width","panelName","groupIndex","title","variant","type"],"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;AACA,SAASA,UAAU,EAAEC,MAAM,EAAEC,WAAW,EAAEC,aAAa,EAAEC,aAAa,EAAEC,MAAM,QAAQ,eAAe,CAAC;AACtG,OAAOC,SAAS,MAAM,uBAAuB,CAAC;AAC9C,SAASC,SAAS,EAAEC,UAAU,QAAQ,eAAe,CAAC;AAGtD,MAAMC,iBAAiB,GAAG,IAAM;IAC9B,MAAM,EAAEC,iBAAiB,CAAA,EAAEC,sBAAsB,CAAA,EAAE,GAAGJ,SAAS,EAAE,AAAC;IAElE,qBACE,MAACN,MAAM;QAACW,IAAI,EAAEF,iBAAiB,KAAKG,SAAS;;0BAC3C,KAACX,WAAW;0BAAC,cAAY;cAAc;0BACvC,KAACF,UAAU;gBACTc,YAAU,EAAC,OAAO;gBAClBC,OAAO,EAAE,IAAMJ,sBAAsB,EAAE;gBACvCK,EAAE,EAAE,CAACC,KAAK,GAAM,CAAA;wBACdC,QAAQ,EAAE,UAAU;wBACpBC,GAAG,EAAEF,KAAK,CAACG,OAAO,CAAC,GAAG,CAAC;wBACvBC,KAAK,EAAEJ,KAAK,CAACG,OAAO,CAAC,GAAG,CAAC;qBAC1B,CAAA,AAAC;0BAEF,cAAA,KAACd,SAAS,KAAG;cACF;YACZI,iBAAiB,kBAAI,KAACY,eAAe;gBAACZ,iBAAiB,EAAEA,iBAAiB;cAAI;;MACxE,CACT;AACJ,CAAC,AAAC;AAMF,MAAMY,eAAe,GAAG,CAAC,EAAEZ,iBAAiB,CAAA,EAAwB,GAAK;QAajEa,GAAgD;IAZtD,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C;
|
|
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;AAQvB,MAAM,WAAW,UAAW,SAAQ,SAAS;IAC3C,UAAU,EAAE,eAAe,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,eAwItC"}
|