@perses-dev/dashboards 0.5.2 → 0.7.1

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.
Files changed (78) hide show
  1. package/dist/cjs/components/AddPanel/AddPanel.js +75 -0
  2. package/dist/cjs/components/DashboardToolbar.js +52 -0
  3. package/dist/cjs/components/GridLayout/GridLayout.js +13 -28
  4. package/dist/cjs/components/Panel/Panel.js +15 -1
  5. package/dist/cjs/components/Panel/Panel.test.js +20 -3
  6. package/dist/cjs/components/TimeRangeControls.js +77 -0
  7. package/dist/cjs/components/VariableAutocomplete.js +3 -3
  8. package/dist/cjs/components/{VariableOptionsDrawer/VariableOptionsDrawer.js → VariableList/VariableList.js} +10 -14
  9. package/dist/cjs/components/{VariableOptionsDrawer/VariableOptionsDrawer.test.js → VariableList/VariableList.test.js} +13 -8
  10. package/dist/cjs/components/VariableList/index.js +29 -0
  11. package/dist/cjs/components/index.js +3 -2
  12. package/dist/cjs/context/DashboardProvider.js +80 -0
  13. package/dist/cjs/context/TimeRangeStateProvider.js +23 -9
  14. package/dist/cjs/context/index.js +1 -0
  15. package/dist/cjs/css/styles.js +184 -0
  16. package/dist/cjs/test/testDashboard.js +219 -0
  17. package/dist/cjs/utils/functions.js +19 -0
  18. package/dist/cjs/views/DashboardApp.js +46 -0
  19. package/dist/cjs/views/ViewDashboard.js +4 -28
  20. package/dist/components/AddPanel/AddPanel.d.ts +8 -0
  21. package/dist/components/AddPanel/AddPanel.d.ts.map +1 -0
  22. package/dist/components/AddPanel/AddPanel.js +1 -0
  23. package/dist/components/DashboardToolbar.d.ts +7 -0
  24. package/dist/components/DashboardToolbar.d.ts.map +1 -0
  25. package/dist/components/DashboardToolbar.js +1 -0
  26. package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
  27. package/dist/components/GridLayout/GridLayout.js +1 -1
  28. package/dist/components/Panel/Panel.d.ts.map +1 -1
  29. package/dist/components/Panel/Panel.js +1 -1
  30. package/dist/components/Panel/Panel.test.js +1 -1
  31. package/dist/components/TimeRangeControls.d.ts +5 -0
  32. package/dist/components/TimeRangeControls.d.ts.map +1 -0
  33. package/dist/components/TimeRangeControls.js +1 -0
  34. package/dist/components/VariableAutocomplete.d.ts +5 -1
  35. package/dist/components/VariableAutocomplete.d.ts.map +1 -1
  36. package/dist/components/VariableAutocomplete.js +1 -1
  37. package/dist/components/VariableList/VariableList.d.ts +11 -0
  38. package/dist/components/VariableList/VariableList.d.ts.map +1 -0
  39. package/dist/components/VariableList/VariableList.js +1 -0
  40. package/dist/components/VariableList/VariableList.test.d.ts +2 -0
  41. package/dist/components/VariableList/VariableList.test.d.ts.map +1 -0
  42. package/dist/components/VariableList/VariableList.test.js +1 -0
  43. package/dist/components/VariableList/index.d.ts +2 -0
  44. package/dist/components/VariableList/index.d.ts.map +1 -0
  45. package/dist/components/VariableList/index.js +1 -0
  46. package/dist/components/index.d.ts +2 -1
  47. package/dist/components/index.d.ts.map +1 -1
  48. package/dist/components/index.js +1 -1
  49. package/dist/context/DashboardProvider.d.ts +45 -0
  50. package/dist/context/DashboardProvider.d.ts.map +1 -0
  51. package/dist/context/DashboardProvider.js +1 -0
  52. package/dist/context/TimeRangeStateProvider.d.ts +13 -2
  53. package/dist/context/TimeRangeStateProvider.d.ts.map +1 -1
  54. package/dist/context/TimeRangeStateProvider.js +1 -1
  55. package/dist/context/index.d.ts +1 -0
  56. package/dist/context/index.d.ts.map +1 -1
  57. package/dist/context/index.js +1 -1
  58. package/dist/css/styles.d.ts +172 -0
  59. package/dist/css/styles.d.ts.map +1 -0
  60. package/dist/css/styles.js +1 -0
  61. package/dist/test/testDashboard.d.ts +4 -0
  62. package/dist/test/testDashboard.d.ts.map +1 -0
  63. package/dist/test/testDashboard.js +1 -0
  64. package/dist/utils/functions.d.ts +2 -0
  65. package/dist/utils/functions.d.ts.map +1 -0
  66. package/dist/utils/functions.js +1 -0
  67. package/dist/views/DashboardApp.d.ts +4 -0
  68. package/dist/views/DashboardApp.d.ts.map +1 -0
  69. package/dist/views/DashboardApp.js +1 -0
  70. package/dist/views/ViewDashboard.d.ts.map +1 -1
  71. package/dist/views/ViewDashboard.js +1 -1
  72. package/package.json +13 -7
  73. package/dist/components/VariableOptionsDrawer/VariableOptionsDrawer.d.ts +0 -11
  74. package/dist/components/VariableOptionsDrawer/VariableOptionsDrawer.d.ts.map +0 -1
  75. package/dist/components/VariableOptionsDrawer/VariableOptionsDrawer.js +0 -1
  76. package/dist/components/VariableOptionsDrawer/VariableOptionsDrawer.test.d.ts +0 -2
  77. package/dist/components/VariableOptionsDrawer/VariableOptionsDrawer.test.d.ts.map +0 -1
  78. package/dist/components/VariableOptionsDrawer/VariableOptionsDrawer.test.js +0 -1
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const jsx_runtime_1 = require("react/jsx-runtime");
4
+ // Copyright 2022 The Perses Authors
5
+ // Licensed under the Apache License, Version 2.0 (the "License");
6
+ // you may not use this file except in compliance with the License.
7
+ // You may obtain a copy of the License at
8
+ //
9
+ // http://www.apache.org/licenses/LICENSE-2.0
10
+ //
11
+ // Unless required by applicable law or agreed to in writing, software
12
+ // distributed under the License is distributed on an "AS IS" BASIS,
13
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ // See the License for the specific language governing permissions and
15
+ // limitations under the License.
16
+ const material_1 = require("@mui/material");
17
+ const components_1 = require("@perses-dev/components");
18
+ const react_1 = require("react");
19
+ const context_1 = require("../../context");
20
+ const functions_1 = require("../../utils/functions");
21
+ const AddPanel = ({ isOpen, onClose }) => {
22
+ const { layouts, addItemToLayout } = (0, context_1.useLayouts)();
23
+ const { addPanel } = (0, context_1.usePanels)();
24
+ const [group, setGroup] = (0, react_1.useState)(0);
25
+ const [panelName, setPanelName] = (0, react_1.useState)('');
26
+ const [panelDescription, setPanelDescription] = (0, react_1.useState)('');
27
+ const onSelectGroupChange = (e) => {
28
+ setGroup(e.target.value);
29
+ };
30
+ const onPanelNameChange = (e) => {
31
+ setPanelName(e.target.value);
32
+ };
33
+ const onPanelDescriptionChange = (e) => {
34
+ setPanelDescription(e.target.value);
35
+ };
36
+ const onAddPanelClick = (e) => {
37
+ var _a;
38
+ e.preventDefault();
39
+ const panelKey = (0, functions_1.removeWhiteSpacesAndSpecialCharacters)(panelName);
40
+ addPanel(panelKey, {
41
+ kind: 'EmptyChart',
42
+ display: { name: panelName, description: panelDescription },
43
+ options: {},
44
+ });
45
+ // find maximum y so new panel is added to the end of the grid
46
+ let maxY = 0;
47
+ (_a = layouts[group]) === null || _a === void 0 ? void 0 : _a.spec.items.forEach((layout) => {
48
+ if (layout.y > maxY) {
49
+ maxY = layout.y;
50
+ }
51
+ });
52
+ addItemToLayout(group, {
53
+ x: 0,
54
+ y: maxY + 1,
55
+ width: 12,
56
+ height: 6,
57
+ content: { $ref: `#/spec/panels/${panelKey}` },
58
+ });
59
+ onClose();
60
+ };
61
+ return ((0, jsx_runtime_1.jsx)(components_1.Drawer, { isOpen: isOpen, onClose: onClose, children: (0, jsx_runtime_1.jsxs)("form", { onSubmit: onAddPanelClick, children: [(0, jsx_runtime_1.jsx)(AddPanelHeader, { onClose: onClose }), (0, jsx_runtime_1.jsxs)(material_1.Grid, { container: true, spacing: 2, children: [(0, jsx_runtime_1.jsx)(material_1.Grid, { item: true, xs: 4, children: (0, jsx_runtime_1.jsxs)(material_1.FormControl, { children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { id: "select-group", children: "Group" }), (0, jsx_runtime_1.jsx)(material_1.Select, { required: true, labelId: "select-group", label: "Group", value: group, onChange: onSelectGroupChange, children: layouts.map((layout, index) => {
62
+ var _a;
63
+ return ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: index, children: ((_a = layout.spec.display) === null || _a === void 0 ? void 0 : _a.title) || `Group ${index + 1}` }, index));
64
+ }) })] }) }), (0, jsx_runtime_1.jsx)(material_1.Grid, { item: true, xs: 8, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { spacing: 2, sx: { flexGrow: '1' }, children: [(0, jsx_runtime_1.jsx)(material_1.FormControl, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { required: true, label: "Panel Name", variant: "outlined", onChange: onPanelNameChange }) }), (0, jsx_runtime_1.jsx)(material_1.FormControl, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { label: "Description", variant: "outlined", onChange: onPanelDescriptionChange }) })] }) })] })] }) }));
65
+ };
66
+ const AddPanelHeader = ({ onClose }) => {
67
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
68
+ display: 'flex',
69
+ alignItems: 'center',
70
+ marginBottom: (theme) => theme.spacing(2),
71
+ paddingBottom: (theme) => theme.spacing(2),
72
+ borderBottom: (theme) => `1px solid ${theme.palette.grey[100]}`,
73
+ }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h5", children: "Add Panel" }), (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", spacing: 1, sx: { marginLeft: 'auto' }, children: [(0, jsx_runtime_1.jsx)(material_1.Button, { type: "submit", variant: "contained", children: "Add Panel" }), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "outlined", onClick: onClose, children: "Cancel" })] })] }));
74
+ };
75
+ exports.default = AddPanel;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.DashboardToolbar = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ // Copyright 2022 The Perses Authors
9
+ // Licensed under the Apache License, Version 2.0 (the "License");
10
+ // you may not use this file except in compliance with the License.
11
+ // You may obtain a copy of the License at
12
+ //
13
+ // http://www.apache.org/licenses/LICENSE-2.0
14
+ //
15
+ // Unless required by applicable law or agreed to in writing, software
16
+ // distributed under the License is distributed on an "AS IS" BASIS,
17
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ // See the License for the specific language governing permissions and
19
+ // limitations under the License.
20
+ const material_1 = require("@mui/material");
21
+ const PencilOutline_1 = __importDefault(require("mdi-material-ui/PencilOutline"));
22
+ const Plus_1 = __importDefault(require("mdi-material-ui/Plus"));
23
+ const context_1 = require("../context");
24
+ const components_1 = require("../components");
25
+ const DashboardToolbar = (props) => {
26
+ const { dashboardName, onAddPanel } = props;
27
+ const { isEditMode, setEditMode } = (0, context_1.useEditMode)();
28
+ const onEditButtonClick = () => {
29
+ setEditMode(true);
30
+ };
31
+ const onCancelButtonClick = () => {
32
+ setEditMode(false);
33
+ };
34
+ const { addLayout } = (0, context_1.useLayouts)();
35
+ const onAddGroup = () => {
36
+ const newLayout = {
37
+ kind: 'Grid',
38
+ spec: {
39
+ display: {
40
+ title: 'New Group',
41
+ collapse: {
42
+ open: true,
43
+ },
44
+ },
45
+ items: [],
46
+ },
47
+ };
48
+ addLayout(newLayout);
49
+ };
50
+ return ((0, jsx_runtime_1.jsx)(material_1.Toolbar, { disableGutters: true, sx: { display: 'block', padding: (theme) => theme.spacing(2, 0) }, children: isEditMode ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: 'flex', width: '100%' }, children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "h2", children: ["Edit ", dashboardName] }), (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", spacing: 1, sx: { marginLeft: 'auto' }, children: [(0, jsx_runtime_1.jsx)(components_1.TimeRangeControls, {}), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "outlined", onClick: onCancelButtonClick, children: "Cancel" }), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", children: "Save" })] })] }), (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: 'row', spacing: 1, sx: { display: 'flex', justifyContent: 'flex-end', width: '100%', padding: (theme) => theme.spacing(2, 0) }, children: [(0, jsx_runtime_1.jsx)(material_1.Button, { startIcon: (0, jsx_runtime_1.jsx)(Plus_1.default, {}), onClick: onAddGroup, children: "Add Group" }), (0, jsx_runtime_1.jsx)(material_1.Button, { startIcon: (0, jsx_runtime_1.jsx)(Plus_1.default, {}), onClick: onAddPanel, children: "Add Panel" })] })] })) : ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: 'flex', width: '100%' }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h2", children: dashboardName }), (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", spacing: 2, sx: { marginLeft: 'auto' }, children: [(0, jsx_runtime_1.jsx)(components_1.TimeRangeControls, {}), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", startIcon: (0, jsx_runtime_1.jsx)(PencilOutline_1.default, {}), onClick: onEditButtonClick, sx: { marginLeft: 'auto' }, children: "Edit" })] })] })) }));
51
+ };
52
+ exports.DashboardToolbar = DashboardToolbar;
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.GridLayout = void 0;
4
7
  const jsx_runtime_1 = require("react/jsx-runtime");
@@ -15,9 +18,12 @@ const jsx_runtime_1 = require("react/jsx-runtime");
15
18
  // See the License for the specific language governing permissions and
16
19
  // limitations under the License.
17
20
  const react_1 = require("react");
21
+ const react_grid_layout_1 = require("react-grid-layout");
18
22
  const material_1 = require("@mui/material");
23
+ const styles_1 = __importDefault(require("../../css/styles"));
24
+ const context_1 = require("../../context");
19
25
  const GridTitle_1 = require("./GridTitle");
20
- const COLUMNS = 24;
26
+ const ResponsiveGridLayout = (0, react_grid_layout_1.WidthProvider)(react_grid_layout_1.Responsive);
21
27
  /**
22
28
  * Layout component that arranges children in a Grid based on the definition.
23
29
  */
@@ -25,35 +31,14 @@ function GridLayout(props) {
25
31
  var _a, _b, _c;
26
32
  const { definition: { spec }, renderGridItemContent, ...others } = props;
27
33
  const [isOpen, setIsOpen] = (0, react_1.useState)((_c = (_b = (_a = spec.display) === null || _a === void 0 ? void 0 : _a.collapse) === null || _b === void 0 ? void 0 : _b.open) !== null && _c !== void 0 ? _c : true);
34
+ const { isEditMode } = (0, context_1.useEditMode)();
28
35
  const gridItems = [];
29
- let mobileRowStart = 1;
30
36
  spec.items.forEach((item, idx) => {
31
- // Try to maintain the chart's aspect ratio on mobile
32
- const widthScale = COLUMNS / item.width;
33
- const mobileRows = Math.floor(item.height * widthScale);
34
- gridItems.push((0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
35
- gridColumn: {
36
- xs: `1 / span ${COLUMNS}`,
37
- sm: `${item.x + 1} / span ${item.width}`,
38
- },
39
- gridRow: {
40
- xs: `${mobileRowStart} / span ${mobileRows}`,
41
- sm: `${item.y + 1} / span ${item.height}`,
42
- },
43
- }, children: renderGridItemContent(item) }, idx));
44
- mobileRowStart += mobileRows;
37
+ const { x, y, width: w, height: h } = item;
38
+ gridItems.push((0, jsx_runtime_1.jsx)("div", { "data-grid": { x, y, w, h }, children: renderGridItemContent(item) }, idx));
45
39
  });
46
- return ((0, jsx_runtime_1.jsxs)(material_1.Box, { ...others, component: "section", sx: { '& + &': { marginTop: (theme) => theme.spacing(1) } }, children: [spec.display !== undefined && ((0, jsx_runtime_1.jsx)(GridTitle_1.GridTitle, { title: spec.display.title, collapse: spec.display.collapse === undefined
47
- ? undefined
48
- : { isOpen, onToggleOpen: () => setIsOpen((current) => !current) } })), (0, jsx_runtime_1.jsx)(material_1.Collapse, { in: isOpen, unmountOnExit: true, children: (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
49
- display: 'grid',
50
- gridTemplateColumns: `repeat(${COLUMNS}, 1fr)`,
51
- gridAutoRows: {
52
- xs: 24,
53
- sm: 36,
54
- },
55
- columnGap: (theme) => theme.spacing(1),
56
- rowGap: (theme) => theme.spacing(1),
57
- }, children: gridItems }) })] }));
40
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.GlobalStyles, { styles: styles_1.default }), (0, jsx_runtime_1.jsxs)(material_1.Box, { ...others, component: "section", sx: { '& + &': { marginTop: (theme) => theme.spacing(1) } }, children: [spec.display !== undefined && ((0, jsx_runtime_1.jsx)(GridTitle_1.GridTitle, { title: spec.display.title, collapse: spec.display.collapse === undefined
41
+ ? undefined
42
+ : { isOpen, onToggleOpen: () => setIsOpen((current) => !current) } })), (0, jsx_runtime_1.jsx)(material_1.Collapse, { in: isOpen, unmountOnExit: true, children: (0, jsx_runtime_1.jsx)(ResponsiveGridLayout, { className: "layout", breakpoints: { lg: 1200, md: 996, sm: 768, xs: 480, xxs: 0 }, cols: { lg: 24, md: 24, sm: 24, xs: 24, xxs: 2 }, rowHeight: 30, draggableHandle: '.drag-handle', resizeHandles: ['se'], isDraggable: isEditMode, isResizable: isEditMode, children: gridItems }) })] })] }));
58
43
  }
59
44
  exports.GridLayout = GridLayout;
@@ -24,6 +24,10 @@ const plugin_system_1 = require("@perses-dev/plugin-system");
24
24
  const components_1 = require("@perses-dev/components");
25
25
  const material_1 = require("@mui/material");
26
26
  const InformationOutline_1 = __importDefault(require("mdi-material-ui/InformationOutline"));
27
+ const Pencil_1 = __importDefault(require("mdi-material-ui/Pencil"));
28
+ const DotsVertical_1 = __importDefault(require("mdi-material-ui/DotsVertical"));
29
+ const Drag_1 = __importDefault(require("mdi-material-ui/Drag"));
30
+ const context_1 = require("../../context");
27
31
  /**
28
32
  * Renders a PanelDefinition's content inside of a Card.
29
33
  */
@@ -43,6 +47,7 @@ function Panel(props) {
43
47
  });
44
48
  // TODO: adjust padding for small panels, consistent way to determine isLargePanel here and in StatChart
45
49
  const panelPadding = 1.5;
50
+ const { isEditMode } = (0, context_1.useEditMode)();
46
51
  return ((0, jsx_runtime_1.jsxs)(material_1.Card, { ref: ref, sx: {
47
52
  ...others.sx,
48
53
  width: '100%',
@@ -52,7 +57,12 @@ function Panel(props) {
52
57
  }, variant: "outlined", ...others, children: [(0, jsx_runtime_1.jsx)(material_1.CardHeader, { title: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
53
58
  display: 'flex',
54
59
  alignItems: 'center',
55
- }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { component: "h2", variant: "body2", fontWeight: (theme) => theme.typography.fontWeightMedium, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis", children: definition.display.name }), definition.display.description && ((0, jsx_runtime_1.jsx)(components_1.InfoTooltip, { id: "info-tooltip", description: definition.display.description, placement: components_1.TooltipPlacement.Right, children: (0, jsx_runtime_1.jsx)(InformationOutline_1.default, { "aria-describedby": "info-tooltip", "aria-hidden": false, sx: { fontSize: '1rem', position: 'relative', left: '4px', cursor: 'pointer' } }) }))] }), sx: {
60
+ minHeight: '24px',
61
+ }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { component: "h2", variant: "body2", fontWeight: (theme) => theme.typography.fontWeightMedium, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis", children: definition.display.name }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
62
+ display: 'flex',
63
+ alignItems: 'center',
64
+ marginLeft: 'auto',
65
+ }, children: [!isEditMode && definition.display.description && ((0, jsx_runtime_1.jsx)(components_1.InfoTooltip, { id: "info-tooltip", description: definition.display.description, placement: components_1.TooltipPlacement.Bottom, children: (0, jsx_runtime_1.jsx)(InformationOutline_1.default, { "aria-describedby": "info-tooltip", "aria-hidden": false, fontSize: "small", sx: { cursor: 'pointer' } }) })), isEditMode && ((0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", alignItems: "center", spacing: 0.5, children: [(0, jsx_runtime_1.jsx)(IconButton, { "aria-label": "drag handle", size: "small", children: (0, jsx_runtime_1.jsx)(Drag_1.default, { className: "drag-handle", sx: { cursor: 'grab' } }) }), (0, jsx_runtime_1.jsx)(IconButton, { "aria-label": "edit panel", size: "small", children: (0, jsx_runtime_1.jsx)(Pencil_1.default, {}) }), (0, jsx_runtime_1.jsx)(IconButton, { "aria-label": "more", size: "small", children: (0, jsx_runtime_1.jsx)(DotsVertical_1.default, {}) })] }))] })] }), sx: {
56
66
  display: 'block',
57
67
  padding: (theme) => theme.spacing(1, panelPadding),
58
68
  borderBottom: (theme) => `solid 1px ${theme.palette.divider}`,
@@ -68,3 +78,7 @@ function Panel(props) {
68
78
  }, ref: setContentElement, children: (0, jsx_runtime_1.jsx)(plugin_system_1.PluginBoundary, { loadingFallback: "Loading...", ErrorFallbackComponent: components_1.ErrorAlert, children: inView === true && (0, jsx_runtime_1.jsx)(plugin_system_1.PanelComponent, { definition: definition, contentDimensions: contentDimensions }) }) })] }));
69
79
  }
70
80
  exports.Panel = Panel;
81
+ const IconButton = (0, material_1.styled)(material_1.IconButton)(({ theme }) => ({
82
+ borderRadius: theme.shape.borderRadius,
83
+ padding: '4px',
84
+ }));
@@ -1,10 +1,15 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  const jsx_runtime_1 = require("react/jsx-runtime");
4
7
  const plugin_system_1 = require("@perses-dev/plugin-system");
5
8
  require("intersection-observer");
6
9
  const react_1 = require("@testing-library/react");
7
10
  const test_1 = require("../../test");
11
+ const testDashboard_1 = __importDefault(require("../../test/testDashboard"));
12
+ const context_1 = require("../../context");
8
13
  const Panel_1 = require("./Panel");
9
14
  const FAKE_PANEL_PLUGIN = {
10
15
  pluginType: 'Panel',
@@ -17,6 +22,7 @@ const FAKE_PANEL_PLUGIN = {
17
22
  };
18
23
  describe('Panel', () => {
19
24
  let props;
25
+ let initialState;
20
26
  beforeEach(() => {
21
27
  props = {
22
28
  definition: {
@@ -28,16 +34,27 @@ describe('Panel', () => {
28
34
  options: {},
29
35
  },
30
36
  };
37
+ initialState = {
38
+ isEditMode: false,
39
+ dashboardSpec: testDashboard_1.default.spec,
40
+ };
31
41
  });
32
42
  // Helper to render the panel with some context set
33
- const renderPanel = () => {
43
+ const renderPanel = (initialState) => {
34
44
  const { addMockPlugin, pluginRegistryProps } = (0, test_1.mockPluginRegistryProps)();
35
45
  addMockPlugin(FAKE_PANEL_PLUGIN);
36
- (0, test_1.renderWithContext)((0, jsx_runtime_1.jsx)(plugin_system_1.PluginRegistry, { ...pluginRegistryProps, children: (0, jsx_runtime_1.jsx)(Panel_1.Panel, { ...props }) }));
46
+ (0, test_1.renderWithContext)((0, jsx_runtime_1.jsx)(context_1.DashboardProvider, { initialState: initialState, children: (0, jsx_runtime_1.jsx)(plugin_system_1.PluginRegistry, { ...pluginRegistryProps, children: (0, jsx_runtime_1.jsx)(Panel_1.Panel, { ...props }) }) }));
37
47
  };
38
48
  it('should render name and info icon', async () => {
39
- renderPanel();
49
+ renderPanel(initialState);
40
50
  await react_1.screen.findByText('Fake Panel');
41
51
  react_1.screen.queryByLabelText('info-tooltip');
42
52
  });
53
+ it('should render edit icons when in edit mode', async () => {
54
+ initialState.isEditMode = true;
55
+ renderPanel(initialState);
56
+ await react_1.screen.queryByLabelText('drag handle');
57
+ react_1.screen.queryByLabelText('edit panel');
58
+ react_1.screen.queryByLabelText('more');
59
+ });
43
60
  });
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TimeRangeControls = exports.TIME_OPTIONS = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ // Copyright 2022 The Perses Authors
6
+ // Licensed under the Apache License, Version 2.0 (the "License");
7
+ // you may not use this file except in compliance with the License.
8
+ // You may obtain a copy of the License at
9
+ //
10
+ // http://www.apache.org/licenses/LICENSE-2.0
11
+ //
12
+ // Unless required by applicable law or agreed to in writing, software
13
+ // distributed under the License is distributed on an "AS IS" BASIS,
14
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ // See the License for the specific language governing permissions and
16
+ // limitations under the License.
17
+ const react_1 = require("react");
18
+ const material_1 = require("@mui/material");
19
+ const date_fns_1 = require("date-fns");
20
+ const components_1 = require("@perses-dev/components");
21
+ const core_1 = require("@perses-dev/core");
22
+ const plugin_system_1 = require("@perses-dev/plugin-system");
23
+ const TimeRangeStateProvider_1 = require("../context/TimeRangeStateProvider");
24
+ // TODO: add time shortcut if one does not match duration
25
+ exports.TIME_OPTIONS = [
26
+ { value: { pastDuration: '5m' }, display: 'Last 5 minutes' },
27
+ { value: { pastDuration: '15m' }, display: 'Last 15 minutes' },
28
+ { value: { pastDuration: '30m' }, display: 'Last 30 minutes' },
29
+ { value: { pastDuration: '1h' }, display: 'Last 1 hour' },
30
+ { value: { pastDuration: '6h' }, display: 'Last 6 hours' },
31
+ { value: { pastDuration: '12h' }, display: 'Last 12 hours' },
32
+ { value: { pastDuration: '24h' }, display: 'Last 1 day' },
33
+ { value: { pastDuration: '7d' }, display: 'Last 7 days' },
34
+ { value: { pastDuration: '14d' }, display: 'Last 14 days' },
35
+ ];
36
+ const FORM_CONTROL_LABEL = 'Time Range';
37
+ function TimeRangeControls() {
38
+ const { setTimeRange } = (0, TimeRangeStateProvider_1.useTimeRangeSetter)();
39
+ const { defaultDuration } = (0, plugin_system_1.useTimeRange)();
40
+ const defaultStart = (0, core_1.parseDurationString)(defaultDuration);
41
+ // TODO: default to URL param if populated
42
+ const [selectedTimeRange, setSelectedTimeRange] = (0, react_1.useState)({ pastDuration: defaultDuration });
43
+ const [absoluteTimeRange, setAbsoluteTime] = (0, react_1.useState)({
44
+ start: (0, date_fns_1.sub)(new Date(), { ...defaultStart }),
45
+ end: new Date(),
46
+ });
47
+ const [showCustomDateSelector, setShowCustomDateSelector] = (0, react_1.useState)(false);
48
+ const anchorEl = (0, react_1.useRef)();
49
+ return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", spacing: 1, children: [(0, jsx_runtime_1.jsx)(material_1.Popover, { anchorEl: anchorEl.current, anchorOrigin: {
50
+ vertical: 'bottom',
51
+ horizontal: 'center',
52
+ }, open: showCustomDateSelector, onClose: () => setShowCustomDateSelector(false), sx: (theme) => ({
53
+ padding: theme.spacing(2),
54
+ }), children: (0, jsx_runtime_1.jsx)(components_1.AbsoluteTimePicker, { initialTimeRange: absoluteTimeRange, onChange: (timeRange) => {
55
+ setTimeRange(timeRange);
56
+ if (!(0, core_1.isRelativeValue)(timeRange)) {
57
+ setAbsoluteTime({ start: timeRange.start, end: timeRange.end });
58
+ }
59
+ setSelectedTimeRange(timeRange);
60
+ setShowCustomDateSelector(false);
61
+ } }) }), (0, jsx_runtime_1.jsxs)(material_1.FormControl, { fullWidth: true, children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { children: FORM_CONTROL_LABEL }), (0, jsx_runtime_1.jsx)(material_1.Box, { ref: anchorEl, children: (0, jsx_runtime_1.jsx)(components_1.TimeRangeSelector, { inputLabel: FORM_CONTROL_LABEL, timeOptions: exports.TIME_OPTIONS, value: selectedTimeRange, onSelectChange: (event) => {
62
+ const duration = event.target.value;
63
+ const relativeTimeInput = {
64
+ pastDuration: duration,
65
+ end: new Date(),
66
+ };
67
+ // TODO: consolidate unnecessary state
68
+ setSelectedTimeRange(relativeTimeInput);
69
+ const convertedAbsoluteTime = (0, core_1.toAbsoluteTimeRange)(relativeTimeInput);
70
+ setTimeRange(convertedAbsoluteTime);
71
+ setAbsoluteTime(convertedAbsoluteTime);
72
+ setShowCustomDateSelector(false);
73
+ }, onCustomClick: () => {
74
+ setShowCustomDateSelector(true);
75
+ } }) })] })] }));
76
+ }
77
+ exports.TimeRangeControls = TimeRangeControls;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VariableAutocomplete = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- // Copyright 2021 The Perses Authors
5
+ // Copyright 2022 The Perses Authors
6
6
  // Licensed under the Apache License, Version 2.0 (the "License");
7
7
  // you may not use this file except in compliance with the License.
8
8
  // You may obtain a copy of the License at
@@ -22,7 +22,7 @@ const plugin_system_1 = require("@perses-dev/plugin-system");
22
22
  * appropriate plugin.
23
23
  */
24
24
  function VariableAutocomplete(props) {
25
- const { definition, state, onChange, onOptionsChange, TextFieldProps } = props;
25
+ const { definition, state, onChange, onOptionsChange, TextFieldProps, ...others } = props;
26
26
  const { value, options } = state;
27
27
  const allValue = 'all_value' in definition.selection ? definition.selection.all_value : undefined;
28
28
  const displayOptions = (0, react_1.useMemo)(() => {
@@ -58,6 +58,6 @@ function VariableAutocomplete(props) {
58
58
  }, getOptionLabel: (option) => (option === allValue ? 'All' : option), ChipProps: {
59
59
  color: 'default',
60
60
  variant: 'outlined',
61
- } }));
61
+ }, ...others }));
62
62
  }
63
63
  exports.VariableAutocomplete = VariableAutocomplete;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VariableOptionsDrawer = void 0;
3
+ exports.VariableList = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- // Copyright 2021 The Perses Authors
5
+ // Copyright 2022 The Perses Authors
6
6
  // Licensed under the Apache License, Version 2.0 (the "License");
7
7
  // you may not use this file except in compliance with the License.
8
8
  // You may obtain a copy of the License at
@@ -19,20 +19,14 @@ const components_1 = require("@perses-dev/components");
19
19
  const plugin_system_1 = require("@perses-dev/plugin-system");
20
20
  const context_1 = require("../../context");
21
21
  const VariableAutocomplete_1 = require("../VariableAutocomplete");
22
- const DRAWER_WIDTH = 296;
23
22
  /**
24
- * Dashboard options drawer that includes variable inputs.
23
+ * Displays the list of variable inputs for a dashboard.
25
24
  */
26
- function VariableOptionsDrawer(props) {
27
- const { variables, sx, ...others } = props;
25
+ function VariableList(props) {
26
+ const { variables, ...others } = props;
28
27
  const { variables: variablesState } = (0, plugin_system_1.useTemplateVariables)();
29
28
  const { setValue, setOptions } = (0, context_1.useTemplateVariablesSetters)();
30
- return ((0, jsx_runtime_1.jsxs)(material_1.Paper, { sx: (0, components_1.combineSx)({
31
- width: DRAWER_WIDTH,
32
- flexShrink: 0,
33
- padding: (theme) => theme.spacing(1, 2),
34
- borderLeft: (theme) => `1px solid ${theme.palette.divider}`,
35
- }, sx), square: true, elevation: 0, ...others, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { component: "h2", variant: "h6", children: "Variables" }), Object.entries(variables).map(([variableName, variableDef]) => {
29
+ return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: { xs: 'column', sm: 'row' }, alignItems: { sm: 'center' }, spacing: 2, ...others, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", sx: { fontWeight: (theme) => theme.typography.fontWeightMedium }, children: "Variables" }), Object.entries(variables).map(([variableName, variableDef]) => {
36
30
  if (variableDef.display.hide === true)
37
31
  return null;
38
32
  const variableState = variablesState[variableName];
@@ -40,7 +34,9 @@ function VariableOptionsDrawer(props) {
40
34
  const error = new Error(`Variable state for '${variableName}' not found`);
41
35
  return (0, jsx_runtime_1.jsx)(components_1.ErrorAlert, { error: error }, variableName);
42
36
  }
43
- return ((0, jsx_runtime_1.jsx)(plugin_system_1.PluginBoundary, { loadingFallback: "Loading...", ErrorFallbackComponent: components_1.ErrorAlert, children: (0, jsx_runtime_1.jsx)(VariableAutocomplete_1.VariableAutocomplete, { definition: variableDef, state: variableState, onChange: (value) => setValue(variableName, value), onOptionsChange: (options) => setOptions(variableName, options) }) }, variableName));
37
+ return ((0, jsx_runtime_1.jsx)(plugin_system_1.PluginBoundary, { loadingFallback: "Loading...", ErrorFallbackComponent: components_1.ErrorAlert, children: (0, jsx_runtime_1.jsx)(VariableAutocomplete_1.VariableAutocomplete, { definition: variableDef, state: variableState, onChange: (value) => setValue(variableName, value), onOptionsChange: (options) => setOptions(variableName, options), TextFieldProps: {
38
+ margin: 'none',
39
+ }, sx: { minWidth: 250 } }) }, variableName));
44
40
  })] }));
45
41
  }
46
- exports.VariableOptionsDrawer = VariableOptionsDrawer;
42
+ exports.VariableList = VariableList;
@@ -21,8 +21,8 @@ const user_event_1 = __importDefault(require("@testing-library/user-event"));
21
21
  const plugin_system_1 = require("@perses-dev/plugin-system");
22
22
  const test_1 = require("../../test");
23
23
  const context_1 = require("../../context");
24
- const VariableOptionsDrawer_1 = require("./VariableOptionsDrawer");
25
- describe('VariableOptionsDrawer', () => {
24
+ const VariableList_1 = require("./VariableList");
25
+ describe('VariableList', () => {
26
26
  const variables = {
27
27
  job: {
28
28
  display: {
@@ -55,27 +55,32 @@ describe('VariableOptionsDrawer', () => {
55
55
  const renderVariableOptionsDrawer = () => {
56
56
  const { addMockPlugin, pluginRegistryProps } = (0, test_1.mockPluginRegistryProps)();
57
57
  addMockPlugin(FAKE_PANEL_PLUGIN);
58
- (0, test_1.renderWithContext)((0, jsx_runtime_1.jsx)(plugin_system_1.PluginRegistry, { ...pluginRegistryProps, children: (0, jsx_runtime_1.jsx)(context_1.TemplateVariablesProvider, { variableDefinitions: variables, children: (0, jsx_runtime_1.jsx)(VariableOptionsDrawer_1.VariableOptionsDrawer, { variables: variables }) }) }));
58
+ (0, test_1.renderWithContext)((0, jsx_runtime_1.jsx)(plugin_system_1.PluginRegistry, { ...pluginRegistryProps, children: (0, jsx_runtime_1.jsx)(context_1.TemplateVariablesProvider, { variableDefinitions: variables, children: (0, jsx_runtime_1.jsx)(VariableList_1.VariableList, { variables: variables }) }) }));
59
59
  };
60
60
  it('should display Variables as the title', async () => {
61
61
  renderVariableOptionsDrawer();
62
- await react_1.screen.findByText('Variables');
62
+ const title = await react_1.screen.findByText('Variables');
63
+ expect(title).toBeInTheDocument();
63
64
  });
64
65
  describe('VariableAutocomplete', () => {
65
66
  it('should display correct variable', async () => {
66
67
  renderVariableOptionsDrawer();
67
- await react_1.screen.findByLabelText('Job');
68
+ const jobInput = await react_1.screen.findByLabelText('Job');
69
+ expect(jobInput).toBeInTheDocument();
68
70
  });
69
71
  it('should display correct default value', async () => {
70
72
  renderVariableOptionsDrawer();
71
- await react_1.screen.findByDisplayValue('node');
73
+ const jobValue = await react_1.screen.findByDisplayValue('node');
74
+ expect(jobValue).toBeInTheDocument();
72
75
  });
73
76
  it('should display correct options', async () => {
74
77
  renderVariableOptionsDrawer();
75
78
  const openButton = await react_1.screen.findByRole('button', { name: 'Open' });
76
79
  user_event_1.default.click(openButton);
77
- await react_1.screen.findByText('all');
78
- react_1.screen.getByText('node');
80
+ const option1 = await react_1.screen.findByText('all');
81
+ expect(option1).toBeInTheDocument();
82
+ const option2 = react_1.screen.getByText('node');
83
+ expect(option2).toBeInTheDocument();
79
84
  });
80
85
  });
81
86
  });
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ // Copyright 2022 The Perses Authors
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ var desc = Object.getOwnPropertyDescriptor(m, k);
17
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
18
+ desc = { enumerable: true, get: function() { return m[k]; } };
19
+ }
20
+ Object.defineProperty(o, k2, desc);
21
+ }) : (function(o, m, k, k2) {
22
+ if (k2 === undefined) k2 = k;
23
+ o[k2] = m[k];
24
+ }));
25
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ __exportStar(require("./VariableList"), exports);
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Copyright 2021 The Perses Authors
2
+ // Copyright 2022 The Perses Authors
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
5
5
  // You may obtain a copy of the License at
@@ -29,5 +29,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
29
29
  __exportStar(require("./Dashboard"), exports);
30
30
  __exportStar(require("./GridLayout"), exports);
31
31
  __exportStar(require("./Panel/Panel"), exports);
32
+ __exportStar(require("./TimeRangeControls"), exports);
32
33
  __exportStar(require("./VariableAutocomplete"), exports);
33
- __exportStar(require("./VariableOptionsDrawer/VariableOptionsDrawer"), exports);
34
+ __exportStar(require("./VariableList"), exports);
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.DashboardProvider = exports.useDashboard = exports.useEditMode = exports.useLayouts = exports.usePanels = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ // Copyright 2022 The Perses Authors
9
+ // Licensed under the Apache License, Version 2.0 (the "License");
10
+ // you may not use this file except in compliance with the License.
11
+ // You may obtain a copy of the License at
12
+ //
13
+ // http://www.apache.org/licenses/LICENSE-2.0
14
+ //
15
+ // Unless required by applicable law or agreed to in writing, software
16
+ // distributed under the License is distributed on an "AS IS" BASIS,
17
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ // See the License for the specific language governing permissions and
19
+ // limitations under the License.
20
+ const zustand_1 = __importDefault(require("zustand"));
21
+ const context_1 = __importDefault(require("zustand/context"));
22
+ const immer_1 = __importDefault(require("immer"));
23
+ const { Provider, useStore } = (0, context_1.default)();
24
+ function usePanels() {
25
+ const { panels, addPanel } = useStore(({ panels, addPanel }) => ({ panels, addPanel }));
26
+ return { panels, addPanel };
27
+ }
28
+ exports.usePanels = usePanels;
29
+ function useLayouts() {
30
+ const { layouts, setLayouts, addLayout, addItemToLayout } = useStore(({ layouts, setLayouts, addLayout, addItemToLayout }) => ({
31
+ layouts,
32
+ setLayouts,
33
+ addLayout,
34
+ addItemToLayout,
35
+ }));
36
+ return { layouts, setLayouts, addLayout, addItemToLayout };
37
+ }
38
+ exports.useLayouts = useLayouts;
39
+ function useEditMode() {
40
+ const { isEditMode, setEditMode } = useStore(({ isEditMode, setEditMode }) => ({ isEditMode, setEditMode }));
41
+ return { isEditMode, setEditMode };
42
+ }
43
+ exports.useEditMode = useEditMode;
44
+ function useDashboard() {
45
+ const selectDashboardSpec = (state) => {
46
+ return (0, immer_1.default)(state.dashboard, (draftState) => {
47
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
+ draftState.panels = state.panels;
49
+ draftState.layouts = state.layouts;
50
+ });
51
+ };
52
+ const dashboard = useStore(selectDashboardSpec);
53
+ return { dashboard };
54
+ }
55
+ exports.useDashboard = useDashboard;
56
+ function DashboardProvider(props) {
57
+ const { children, initialState: { dashboardSpec, isEditMode }, } = props;
58
+ const { layouts, panels } = dashboardSpec;
59
+ return ((0, jsx_runtime_1.jsx)(Provider, { createStore: () => (0, zustand_1.default)((set) => ({
60
+ layouts,
61
+ panels,
62
+ dashboard: dashboardSpec,
63
+ isEditMode: !!isEditMode,
64
+ setEditMode: (isEditMode) => set({ isEditMode }),
65
+ setLayouts: (layouts) => set({ layouts }),
66
+ addLayout: (layout) => set((0, immer_1.default)((state) => {
67
+ state.layouts.push(layout);
68
+ })),
69
+ addItemToLayout: (index, item) => set((0, immer_1.default)((state) => {
70
+ state.layouts[index].spec.items.push(item);
71
+ })),
72
+ setPanels: (panels) => set({ panels }),
73
+ addPanel: (name, panel) => {
74
+ set((0, immer_1.default)((state) => {
75
+ state.panels[name] = panel;
76
+ }, {}));
77
+ },
78
+ })), children: children }));
79
+ }
80
+ exports.DashboardProvider = DashboardProvider;