Skip to content

Commit 7079de8

Browse files
authored
Merge pull request #688 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents 0b69849 + 9c2c564 commit 7079de8

File tree

4 files changed

+57
-4
lines changed

4 files changed

+57
-4
lines changed

src/components/CippComponents/CippOffCanvas.jsx

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { getCippTranslation } from "../../utils/get-cipp-translation";
44
import { getCippFormatting } from "../../utils/get-cipp-formatting";
55
import { useMediaQuery, Grid } from "@mui/system";
66
import CloseIcon from "@mui/icons-material/Close";
7+
import KeyboardArrowUpIcon from "@mui/icons-material/KeyboardArrowUp";
8+
import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown";
79

810
export const CippOffCanvas = (props) => {
911
const {
@@ -17,6 +19,10 @@ export const CippOffCanvas = (props) => {
1719
children,
1820
size = "sm",
1921
footer,
22+
onNavigateUp,
23+
onNavigateDown,
24+
canNavigateUp = false,
25+
canNavigateDown = false,
2026
} = props;
2127

2228
const mdDown = useMediaQuery((theme) => theme.breakpoints.down("md"));
@@ -84,9 +90,31 @@ export const CippOffCanvas = (props) => {
8490
sx={{ display: "flex", justifyContent: "space-between", alignItems: "center", p: 1.5 }}
8591
>
8692
<Typography variant="h5">{title}</Typography>
87-
<IconButton onClick={onClose}>
88-
<CloseIcon />
89-
</IconButton>
93+
<Box sx={{ display: "flex", gap: 0.5 }}>
94+
{(canNavigateUp || canNavigateDown) && (
95+
<>
96+
<IconButton
97+
onClick={onNavigateUp}
98+
disabled={!canNavigateUp}
99+
size="small"
100+
title="Previous row"
101+
>
102+
<KeyboardArrowUpIcon />
103+
</IconButton>
104+
<IconButton
105+
onClick={onNavigateDown}
106+
disabled={!canNavigateDown}
107+
size="small"
108+
title="Next row"
109+
>
110+
<KeyboardArrowDownIcon />
111+
</IconButton>
112+
</>
113+
)}
114+
<IconButton onClick={onClose}>
115+
<CloseIcon />
116+
</IconButton>
117+
</Box>
90118
</Box>
91119
<Divider />
92120
<Box

src/components/CippTable/CippDataTable.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ export const CippDataTable = (props) => {
115115
const [usedColumns, setUsedColumns] = useState([]);
116116
const [offcanvasVisible, setOffcanvasVisible] = useState(false);
117117
const [offCanvasData, setOffCanvasData] = useState({});
118+
const [offCanvasRowIndex, setOffCanvasRowIndex] = useState(0);
118119
const [customComponentData, setCustomComponentData] = useState({});
119120
const [customComponentVisible, setCustomComponentVisible] = useState(false);
120121
const [actionData, setActionData] = useState({ data: {}, action: {}, ready: false });
@@ -292,6 +293,7 @@ export const CippDataTable = (props) => {
292293
? ({ row }) => ({
293294
onClick: () => {
294295
setOffCanvasData(row.original);
296+
setOffCanvasRowIndex(row.index);
295297
setOffcanvasVisible(true);
296298
},
297299
sx: {
@@ -453,6 +455,7 @@ export const CippDataTable = (props) => {
453455
onClick={() => {
454456
closeMenu();
455457
setOffCanvasData(row.original);
458+
setOffCanvasRowIndex(row.index);
456459
setOffcanvasVisible(true);
457460
}}
458461
>
@@ -468,6 +471,7 @@ export const CippDataTable = (props) => {
468471
onClick={() => {
469472
closeMenu();
470473
setOffCanvasData(row.original);
474+
setOffCanvasRowIndex(row.index);
471475
setOffcanvasVisible(true);
472476
}}
473477
>
@@ -758,8 +762,27 @@ export const CippDataTable = (props) => {
758762
extendedData={offCanvasData}
759763
extendedInfoFields={offCanvas?.extendedInfoFields}
760764
actions={actions}
761-
children={offCanvas?.children}
765+
title={offCanvasData?.Name || offCanvas?.title || "Extended Info"}
766+
children={
767+
offCanvas?.children ? (row) => offCanvas.children(row, offCanvasRowIndex) : undefined
768+
}
762769
customComponent={offCanvas?.customComponent}
770+
onNavigateUp={() => {
771+
const newIndex = offCanvasRowIndex - 1;
772+
if (newIndex >= 0 && memoizedData && memoizedData[newIndex]) {
773+
setOffCanvasRowIndex(newIndex);
774+
setOffCanvasData(memoizedData[newIndex]);
775+
}
776+
}}
777+
onNavigateDown={() => {
778+
const newIndex = offCanvasRowIndex + 1;
779+
if (memoizedData && newIndex < memoizedData.length) {
780+
setOffCanvasRowIndex(newIndex);
781+
setOffCanvasData(memoizedData[newIndex]);
782+
}
783+
}}
784+
canNavigateUp={offCanvasRowIndex > 0}
785+
canNavigateDown={memoizedData && offCanvasRowIndex < memoizedData.length - 1}
763786
{...offCanvas}
764787
/>
765788
{/* Render custom component */}

src/pages/dashboardv2/devices/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import React from "react";
12
import {
23
Container,
34
Typography,

src/pages/dashboardv2/identity/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import React from "react";
12
import {
23
Container,
34
Typography,

0 commit comments

Comments
 (0)