Skip to content

Commit 29176fe

Browse files
authored
Merge pull request #24 from KelvinTegelaar/main
[pull] main from KelvinTegelaar:main
2 parents 2983f04 + 6a3625a commit 29176fe

31 files changed

+3214
-1428
lines changed

cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"Rewst",
2727
"Sherweb",
2828
"Syncro",
29+
"TERRL",
2930
"Yubikey"
3031
],
3132
"ignoreWords": [

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cipp",
3-
"version": "7.1.3",
3+
"version": "8.0.2",
44
"author": "CIPP Contributors",
55
"homepage": "https://cipp.app/",
66
"bugs": {
@@ -95,6 +95,7 @@
9595
"react-redux": "9.2.0",
9696
"react-syntax-highlighter": "^15.6.1",
9797
"react-time-ago": "^7.3.3",
98+
"react-virtuoso": "^4.12.8",
9899
"react-window": "^1.8.10",
99100
"redux": "5.0.1",
100101
"redux-devtools-extension": "2.13.9",
@@ -111,4 +112,4 @@
111112
"eslint": "9.22.0",
112113
"eslint-config-next": "15.2.2"
113114
}
114-
}
115+
}

public/version.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"version": "8.0.1"
3-
}
2+
"version": "8.0.3"
3+
}

src/components/CippCards/CippBannerListCard.jsx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ export const CippBannerListCard = (props) => {
3939
</Box>
4040
</Stack>
4141
<Stack alignItems="center" direction="row" spacing={2}>
42-
<Skeleton variant="circular" width={24} height={24} />
4342
<Skeleton variant="text" width={60} />
43+
<Skeleton variant="circular" width={24} height={24} />
4444
</Stack>
4545
</Stack>
4646
</Card>
@@ -74,7 +74,16 @@ export const CippBannerListCard = (props) => {
7474
direction="row"
7575
flexWrap="wrap"
7676
justifyContent="space-between"
77-
sx={{ p: 3 }}
77+
sx={{
78+
p: 3,
79+
...(isCollapsible && {
80+
cursor: "pointer",
81+
"&:hover": {
82+
bgcolor: "action.hover",
83+
},
84+
}),
85+
}}
86+
onClick={isCollapsible ? () => handleExpand(item.id) : undefined}
7887
>
7988
{/* Left Side: cardLabelBox */}
8089
<Stack direction="row" spacing={2} alignItems="center">
@@ -127,8 +136,16 @@ export const CippBannerListCard = (props) => {
127136
<Typography variant="body2">{item.statusText}</Typography>
128137
</Stack>
129138
)}
139+
{item?.cardLabelBoxActions && (
140+
<Box onClick={(e) => e.stopPropagation()}>{item.cardLabelBoxActions}</Box>
141+
)}
130142
{isCollapsible && (
131-
<IconButton onClick={() => handleExpand(item.id)}>
143+
<IconButton
144+
onClick={(e) => {
145+
e.stopPropagation();
146+
handleExpand(item.id);
147+
}}
148+
>
132149
<SvgIcon
133150
fontSize="small"
134151
sx={{
@@ -190,6 +207,7 @@ CippBannerListCard.propTypes = {
190207
actionButton: PropTypes.element,
191208
isFetching: PropTypes.bool,
192209
children: PropTypes.node,
210+
cardLabelBoxActions: PropTypes.element,
193211
})
194212
).isRequired,
195213
isCollapsible: PropTypes.bool,
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
import { useState, useEffect } from "react";
2+
import { Typography, Box, Button, TextField, Chip, Stack } from "@mui/material";
3+
import { Add } from "@mui/icons-material";
4+
import { useWatch } from "react-hook-form";
5+
6+
const CippAliasDialog = ({ formHook }) => {
7+
const [newAlias, setNewAlias] = useState("");
8+
9+
// Initialize the form field if it doesn't exist
10+
useEffect(() => {
11+
// Set default empty array if AddedAliases doesn't exist in the form
12+
if (!formHook.getValues("AddedAliases")) {
13+
formHook.setValue("AddedAliases", []);
14+
}
15+
}, [formHook]);
16+
17+
// Use useWatch to subscribe to form field changes
18+
const aliasList = useWatch({
19+
control: formHook.control,
20+
name: "AddedAliases",
21+
defaultValue: [],
22+
});
23+
24+
const isPending = formHook.formState.isSubmitting;
25+
26+
const handleAddAlias = () => {
27+
if (newAlias.trim()) {
28+
const currentAliases = formHook.getValues("AddedAliases") || [];
29+
const newList = [...currentAliases, newAlias.trim()];
30+
formHook.setValue("AddedAliases", newList, { shouldValidate: true });
31+
setNewAlias("");
32+
}
33+
};
34+
35+
const handleDeleteAlias = (aliasToDelete) => {
36+
const currentAliases = formHook.getValues("AddedAliases") || [];
37+
const updatedList = currentAliases.filter((alias) => alias !== aliasToDelete);
38+
formHook.setValue("AddedAliases", updatedList, { shouldValidate: true });
39+
};
40+
41+
const handleKeyPress = (event) => {
42+
if (event.key === "Enter") {
43+
event.preventDefault();
44+
handleAddAlias();
45+
}
46+
};
47+
48+
return (
49+
<>
50+
<Stack spacing={3} sx={{ mt: 1 }}>
51+
<Typography variant="body2" color="text.secondary">
52+
Add proxy addresses (aliases) for this user. Enter each alias and click Add or press
53+
Enter.
54+
</Typography>
55+
<Box sx={{ display: "flex", gap: 1 }}>
56+
<TextField
57+
fullWidth
58+
value={newAlias}
59+
onChange={(e) => setNewAlias(e.target.value)}
60+
onKeyPress={handleKeyPress}
61+
placeholder="Enter an alias"
62+
variant="outlined"
63+
disabled={isPending}
64+
size="small"
65+
sx={{
66+
"& .MuiOutlinedInput-root": {
67+
fontFamily: "monospace",
68+
"& .MuiOutlinedInput-input": {
69+
px: 2,
70+
},
71+
},
72+
}}
73+
/>
74+
<Button
75+
onClick={handleAddAlias}
76+
variant="contained"
77+
disabled={!newAlias.trim() || isPending}
78+
startIcon={<Add />}
79+
size="small"
80+
>
81+
Add
82+
</Button>
83+
</Box>
84+
<Box
85+
sx={{
86+
display: "flex",
87+
flexWrap: "wrap",
88+
gap: 1,
89+
minHeight: "40px",
90+
p: 1,
91+
border: "1px dashed",
92+
borderColor: "divider",
93+
borderRadius: 1,
94+
alignItems: "center",
95+
justifyContent: "center",
96+
}}
97+
>
98+
{aliasList.length === 0 ? (
99+
<Typography
100+
variant="body2"
101+
color="text.secondary"
102+
sx={{
103+
px: 2,
104+
py: 1,
105+
textAlign: "center",
106+
width: "100%",
107+
}}
108+
>
109+
No aliases added yet
110+
</Typography>
111+
) : (
112+
aliasList.map((alias) => (
113+
<Chip
114+
key={alias}
115+
label={alias}
116+
onDelete={() => handleDeleteAlias(alias)}
117+
color="primary"
118+
variant="outlined"
119+
/>
120+
))
121+
)}
122+
</Box>
123+
</Stack>
124+
</>
125+
);
126+
};
127+
128+
export default CippAliasDialog;

0 commit comments

Comments
 (0)