@@ -18,6 +18,7 @@ const EditGroup = () => {
18
18
const [ groupIdReady , setGroupIdReady ] = useState ( false ) ;
19
19
const [ showMembershipTable , setShowMembershipTable ] = useState ( false ) ;
20
20
const [ combinedData , setCombinedData ] = useState ( [ ] ) ;
21
+ const [ initialValues , setInitialValues ] = useState ( { } ) ;
21
22
const tenantFilter = useSettings ( ) . currentTenant ;
22
23
23
24
const groupInfo = ApiGetCall ( {
@@ -65,13 +66,14 @@ const EditGroup = () => {
65
66
] ;
66
67
setCombinedData ( combinedData ) ;
67
68
68
- // Reset the form with all values
69
- formControl . reset ( {
69
+ // Create initial values object
70
+ const formValues = {
70
71
tenantFilter : tenantFilter ,
71
72
mail : group . mail ,
72
73
mailNickname : group . mailNickname || "" ,
73
74
allowExternal : groupInfo ?. data ?. allowExternal ,
74
75
sendCopies : groupInfo ?. data ?. sendCopies ,
76
+ hideFromOutlookClients : groupInfo ?. data ?. hideFromOutlookClients ,
75
77
displayName : group . displayName ,
76
78
description : group . description || "" ,
77
79
membershipRules : group . membershipRule || "" ,
@@ -103,11 +105,37 @@ const EditGroup = () => {
103
105
RemoveOwner : [ ] ,
104
106
AddContact : [ ] ,
105
107
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 ,
106
115
} ) ;
116
+
117
+ // Reset the form with all values
118
+ formControl . reset ( formValues ) ;
107
119
}
108
120
}
109
121
} , [ groupInfo . isSuccess , router . query , groupInfo . isFetching ] ) ;
110
122
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
+
111
139
return (
112
140
< >
113
141
< CippFormPage
@@ -117,6 +145,7 @@ const EditGroup = () => {
117
145
formPageType = "Edit"
118
146
backButtonTitle = "Group Overview"
119
147
postUrl = "/api/EditGroup"
148
+ customDataformatter = { customDataFormatter }
120
149
titleButton = {
121
150
< >
122
151
< Button
@@ -331,6 +360,19 @@ const EditGroup = () => {
331
360
/>
332
361
</ Grid >
333
362
) }
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
+ ) }
334
376
</ Grid >
335
377
</ Box >
336
378
) }
0 commit comments