Skip to content

Commit 7a19c36

Browse files
authored
Merge pull request #77 from KelvinTegelaar/main
[pull] main from KelvinTegelaar:main
2 parents 4df740f + 1379b8c commit 7a19c36

File tree

5 files changed

+86
-33
lines changed

5 files changed

+86
-33
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cipp",
3-
"version": "8.5.0",
3+
"version": "8.5.1",
44
"author": "CIPP Contributors",
55
"homepage": "https://cipp.app/",
66
"bugs": {
@@ -112,4 +112,4 @@
112112
"eslint": "9.35.0",
113113
"eslint-config-next": "15.5.2"
114114
}
115-
}
115+
}

public/version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"version": "8.5.0"
2+
"version": "8.5.1"
33
}

src/components/CippComponents/CippAutopilotProfileDrawer.jsx

Lines changed: 59 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import React, { useState } from "react";
1+
import React, { useState, useEffect } from "react";
22
import { Divider, Button } from "@mui/material";
33
import { Grid } from "@mui/system";
4-
import { useForm } from "react-hook-form";
4+
import { useForm, useWatch, useFormState } from "react-hook-form";
55
import { AccountCircle } from "@mui/icons-material";
66
import { CippOffCanvas } from "./CippOffCanvas";
77
import CippFormComponent from "./CippFormComponent";
@@ -23,9 +23,9 @@ export const CippAutopilotProfileDrawer = ({
2323
Description: "",
2424
DeviceNameTemplate: "",
2525
languages: null,
26-
CollectHash: true,
26+
CollectHash: false,
2727
Assignto: true,
28-
DeploymentMode: true,
28+
DeploymentMode: false,
2929
HideTerms: true,
3030
HidePrivacy: true,
3131
HideChangeAccount: true,
@@ -37,15 +37,36 @@ export const CippAutopilotProfileDrawer = ({
3737

3838
const createProfile = ApiPostCall({
3939
urlFromData: true,
40-
relatedQueryKeys: ["Autopilot Profiles"],
40+
relatedQueryKeys: ["Autopilot Profiles*"],
4141
});
4242

43+
// Watch the deployment mode to conditionally disable white glove
44+
const deploymentMode = useWatch({
45+
control: formControl.control,
46+
name: "DeploymentMode",
47+
});
48+
49+
// Watch form state for validation
50+
const { isValid, isDirty } = useFormState({
51+
control: formControl.control,
52+
});
53+
54+
// Automatically disable white glove when self-deploying mode (shared) is enabled
55+
useEffect(() => {
56+
if (deploymentMode === true) {
57+
// Self-deploying mode is enabled (shared mode), disable white glove
58+
formControl.setValue("allowWhiteglove", false);
59+
}
60+
}, [deploymentMode, formControl]);
61+
4362
const handleSubmit = () => {
4463
const formData = formControl.getValues();
64+
// Always set HideChangeAccount to true regardless of form state
65+
formData.HideChangeAccount = true;
4566
createProfile.mutate({
4667
url: "/api/AddAutopilotConfig",
4768
data: formData,
48-
relatedQueryKeys: ["Autopilot Profiles"],
69+
relatedQueryKeys: ["Autopilot Profiles*"],
4970
});
5071
};
5172

@@ -69,22 +90,32 @@ export const CippAutopilotProfileDrawer = ({
6990
onClose={handleCloseDrawer}
7091
size="lg"
7192
footer={
72-
<div style={{ display: "flex", gap: "8px", justifyContent: "flex-start" }}>
73-
<Button
74-
variant="contained"
75-
color="primary"
76-
onClick={handleSubmit}
77-
disabled={createProfile.isLoading}
93+
<div>
94+
<CippApiResults apiObject={createProfile} />
95+
<div
96+
style={{
97+
display: "flex",
98+
gap: "8px",
99+
justifyContent: "flex-start",
100+
marginTop: "16px",
101+
}}
78102
>
79-
{createProfile.isLoading
80-
? "Creating..."
81-
: createProfile.isSuccess
82-
? "Create Another"
83-
: "Create Profile"}
84-
</Button>
85-
<Button variant="outlined" onClick={handleCloseDrawer}>
86-
Close
87-
</Button>
103+
<Button
104+
variant="contained"
105+
color="primary"
106+
onClick={handleSubmit}
107+
disabled={createProfile.isLoading || !isValid}
108+
>
109+
{createProfile.isLoading
110+
? "Creating..."
111+
: createProfile.isSuccess
112+
? "Create Another"
113+
: "Create Profile"}
114+
</Button>
115+
<Button variant="outlined" onClick={handleCloseDrawer}>
116+
Close
117+
</Button>
118+
</div>
88119
</div>
89120
}
90121
>
@@ -114,6 +145,7 @@ export const CippAutopilotProfileDrawer = ({
114145
name="DisplayName"
115146
formControl={formControl}
116147
validators={{ required: "Display Name is required" }}
148+
required={true}
117149
/>
118150
</Grid>
119151

@@ -202,6 +234,12 @@ export const CippAutopilotProfileDrawer = ({
202234
label="Allow White Glove OOBE"
203235
name="allowWhiteglove"
204236
formControl={formControl}
237+
disabled={deploymentMode === true}
238+
helperText={
239+
deploymentMode === true
240+
? "White Glove is not supported with Self-deploying mode (shared devices)"
241+
: undefined
242+
}
205243
/>
206244
<CippFormComponent
207245
type="switch"
@@ -210,8 +248,6 @@ export const CippAutopilotProfileDrawer = ({
210248
formControl={formControl}
211249
/>
212250
</Grid>
213-
214-
<CippApiResults apiObject={createProfile} />
215251
</Grid>
216252
</CippOffCanvas>
217253
</>

src/pages/_app.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
AutoStories,
2828
Gavel,
2929
Celebration,
30+
ClearAll as ClearAllIcon,
3031
} from "@mui/icons-material";
3132
import { SvgIcon } from "@mui/material";
3233
import discordIcon from "../../public/discord-mark-blue.svg";
@@ -196,6 +197,29 @@ const App = (props) => {
196197
},
197198
]
198199
: []), // toRemove
200+
{
201+
// add clear cache action that removes the persisted query cache from local storage and reloads the page
202+
id: "clearCache",
203+
icon: <ClearAllIcon />,
204+
name: "Clear Cache and Reload",
205+
onClick: () => {
206+
// Clear the TanStack Query cache
207+
queryClient.clear();
208+
209+
// Remove persisted cache from localStorage
210+
if (typeof window !== "undefined") {
211+
// Remove the persisted query cache keys
212+
Object.keys(localStorage).forEach((key) => {
213+
if (key.startsWith("REACT_QUERY_OFFLINE_CACHE")) {
214+
localStorage.removeItem(key);
215+
}
216+
});
217+
}
218+
219+
// Force refresh the page to bypass browser cache and reload JavaScript
220+
window.location.reload(true);
221+
},
222+
},
199223
{
200224
id: "license",
201225
icon: <Gavel />,

src/utils/get-cipp-filter-variant.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,4 @@ export const getCippFilterVariant = (providedColumnKeys, arg) => {
115115
filterFn: "betweenInclusive",
116116
};
117117
}
118-
119-
// Default fallback for any remaining cases - use text filter to avoid localeCompare issues
120-
return {
121-
filterVariant: "text",
122-
sortingFn: "alphanumeric",
123-
filterFn: "includes",
124-
};
125118
};

0 commit comments

Comments
 (0)