Skip to content

Commit f8cde3f

Browse files
Merge pull request #4347 from kris6673/edit-group
Feat: Enhance group editing and add hide/show M365 group in outlook
2 parents 60cc854 + 481ffe0 commit f8cde3f

File tree

1 file changed

+44
-2
lines changed
  • src/pages/identity/administration/groups

1 file changed

+44
-2
lines changed

src/pages/identity/administration/groups/edit.jsx

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const EditGroup = () => {
1818
const [groupIdReady, setGroupIdReady] = useState(false);
1919
const [showMembershipTable, setShowMembershipTable] = useState(false);
2020
const [combinedData, setCombinedData] = useState([]);
21+
const [initialValues, setInitialValues] = useState({});
2122
const tenantFilter = useSettings().currentTenant;
2223

2324
const groupInfo = ApiGetCall({
@@ -65,13 +66,14 @@ const EditGroup = () => {
6566
];
6667
setCombinedData(combinedData);
6768

68-
// Reset the form with all values
69-
formControl.reset({
69+
// Create initial values object
70+
const formValues = {
7071
tenantFilter: tenantFilter,
7172
mail: group.mail,
7273
mailNickname: group.mailNickname || "",
7374
allowExternal: groupInfo?.data?.allowExternal,
7475
sendCopies: groupInfo?.data?.sendCopies,
76+
hideFromOutlookClients: groupInfo?.data?.hideFromOutlookClients,
7577
displayName: group.displayName,
7678
description: group.description || "",
7779
membershipRules: group.membershipRule || "",
@@ -103,11 +105,37 @@ const EditGroup = () => {
103105
RemoveOwner: [],
104106
AddContact: [],
105107
RemoveContact: [],
108+
};
109+
110+
// Store initial values for comparison
111+
setInitialValues({
112+
allowExternal: groupInfo?.data?.allowExternal,
113+
sendCopies: groupInfo?.data?.sendCopies,
114+
hideFromOutlookClients: groupInfo?.data?.hideFromOutlookClients,
106115
});
116+
117+
// Reset the form with all values
118+
formControl.reset(formValues);
107119
}
108120
}
109121
}, [groupInfo.isSuccess, router.query, groupInfo.isFetching]);
110122

123+
// Custom data formatter to only send changed values
124+
const customDataFormatter = (formData) => {
125+
const cleanedData = { ...formData };
126+
127+
// Properties that should only be sent if they've changed from initial values
128+
const changeDetectionProperties = ["allowExternal", "sendCopies", "hideFromOutlookClients"];
129+
130+
changeDetectionProperties.forEach((property) => {
131+
if (formData[property] === initialValues[property]) {
132+
delete cleanedData[property];
133+
}
134+
});
135+
136+
return cleanedData;
137+
};
138+
111139
return (
112140
<>
113141
<CippFormPage
@@ -117,6 +145,7 @@ const EditGroup = () => {
117145
formPageType="Edit"
118146
backButtonTitle="Group Overview"
119147
postUrl="/api/EditGroup"
148+
customDataformatter={customDataFormatter}
120149
titleButton={
121150
<>
122151
<Button
@@ -331,6 +360,19 @@ const EditGroup = () => {
331360
/>
332361
</Grid>
333362
)}
363+
364+
{groupType === "Microsoft 365" && (
365+
<Grid size={{ xs: 12 }}>
366+
<CippFormComponent
367+
type="switch"
368+
label="Hide group mailbox from Outlook"
369+
name="hideFromOutlookClients"
370+
formControl={formControl}
371+
isFetching={groupInfo.isFetching}
372+
disabled={groupInfo.isFetching}
373+
/>
374+
</Grid>
375+
)}
334376
</Grid>
335377
</Box>
336378
)}

0 commit comments

Comments
 (0)