Skip to content

Commit 2de5265

Browse files
authored
Merge pull request KelvinTegelaar#5112 from KelvinTegelaar/dev
Dev to hotfix
2 parents 2439a15 + ca896e2 commit 2de5265

File tree

11 files changed

+40
-19
lines changed

11 files changed

+40
-19
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.8.0",
3+
"version": "8.8.1",
44
"author": "CIPP Contributors",
55
"homepage": "https://cipp.app/",
66
"bugs": {
@@ -118,4 +118,4 @@
118118
"eslint": "9.35.0",
119119
"eslint-config-next": "15.5.2"
120120
}
121-
}
121+
}

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.8.0"
3-
}
2+
"version": "8.8.1"
3+
}

src/components/CippComponents/CippTenantSelector.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ export const CippTenantSelector = (props) => {
205205

206206
// This effect handles when the URL parameter changes externally
207207
useEffect(() => {
208-
if (!router.isReady || !tenantList.isSuccess) return;
208+
if (!router.isReady || !tenantList.isSuccess || !settings.isInitialized) return;
209209

210210
// Get the current tenant from URL or settings
211211
const urlTenant = router.query.tenantFilter || settings.currentTenant;
@@ -230,11 +230,11 @@ export const CippTenantSelector = (props) => {
230230
});
231231
}
232232
}
233-
}, [router.isReady, router.query.tenantFilter, tenantList.isSuccess, settings.currentTenant]);
233+
}, [router.isReady, router.query.tenantFilter, tenantList.isSuccess, settings.currentTenant, settings.isInitialized]);
234234

235235
// This effect ensures the tenant filter parameter is included in the URL when missing
236236
useEffect(() => {
237-
if (!router.isReady || !settings.currentTenant) return;
237+
if (!router.isReady || !settings.isInitialized || !settings.currentTenant) return;
238238

239239
// If the tenant parameter is missing from the URL but we have it in settings
240240
if (!router.query.tenantFilter && settings.currentTenant) {
@@ -248,7 +248,7 @@ export const CippTenantSelector = (props) => {
248248
{ shallow: true }
249249
);
250250
}
251-
}, [router.isReady, router.query, settings.currentTenant]);
251+
}, [router.isReady, router.query, settings.currentTenant, settings.isInitialized]);
252252

253253
useEffect(() => {
254254
if (tenant && currentTenant?.value && currentTenant?.value !== "AllTenants") {

src/contexts/settings-context.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,22 @@ export const SettingsProvider = (props) => {
132132

133133
const handleUpdate = useCallback((settings) => {
134134
setState((prevState) => {
135+
// Filter out null and undefined values to prevent resetting settings
136+
const filteredSettings = Object.entries(settings).reduce((acc, [key, value]) => {
137+
if (value !== null && value !== undefined) {
138+
acc[key] = value;
139+
}
140+
return acc;
141+
}, {});
142+
135143
storeSettings({
136144
...prevState,
137-
...settings,
145+
...filteredSettings,
138146
});
139147

140148
return {
141149
...prevState,
142-
...settings,
150+
...filteredSettings,
143151
};
144152
});
145153
}, []);

src/pages/_app.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ const App = (props) => {
367367
<SettingsConsumer>
368368
{(settings) => {
369369
if (!settings.isInitialized) {
370+
return null; // Don't render until settings are loaded
370371
}
371372
const theme = createTheme({
372373
colorPreset: "orange",

src/pages/tenant/manage/applied-standards.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ const Page = () => {
5858
const { templateId } = router.query;
5959
const [comparisonData, setComparisonData] = useState(null);
6060
const settings = useSettings();
61-
const currentTenant = settings?.currentTenant;
61+
// Prioritize URL query parameter, then fall back to settings
62+
const currentTenant = router.query.tenantFilter || settings?.currentTenant;
6263
const formControl = useForm({
6364
mode: "onBlur",
6465
defaultValues: {

src/pages/tenant/manage/configuration-backup.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,18 @@ const Page = () => {
4242
const { templateId } = router.query;
4343
const settings = useSettings();
4444
const removeDialog = useDialog();
45+
// Prioritize URL query parameter, then fall back to settings
46+
const currentTenant = router.query.tenantFilter || settings.currentTenant;
4547

4648
// API call to get backup files
4749
const backupList = ApiGetCall({
4850
url: "/api/ExecListBackup",
4951
data: {
50-
tenantFilter: settings.currentTenant,
52+
tenantFilter: currentTenant,
5153
Type: "Scheduled",
5254
NameOnly: true,
5355
},
54-
queryKey: `BackupList-${settings.currentTenant}`,
56+
queryKey: `BackupList-${currentTenant}`,
5557
});
5658

5759
// API call to get existing backup configuration/schedule
@@ -61,7 +63,7 @@ const Page = () => {
6163
showHidden: true,
6264
Type: "New-CIPPBackup",
6365
},
64-
queryKey: `BackupTasks-${settings.currentTenant}`,
66+
queryKey: `BackupTasks-${currentTenant}`,
6567
});
6668

6769
// Use the actual backup files as the backup data
@@ -380,7 +382,10 @@ const Page = () => {
380382
confirmText:
381383
"Are you sure you want to remove this backup schedule? This will stop automatic backups but won't delete existing backup files.",
382384
}}
383-
relatedQueryKeys={[`BackupTasks-${settings.currentTenant}`, `BackupList-${settings.currentTenant}`]}
385+
relatedQueryKeys={[
386+
`BackupTasks-${settings.currentTenant}`,
387+
`BackupList-${settings.currentTenant}`,
388+
]}
384389
onSuccess={() => {
385390
// Refresh both queries when a backup schedule is removed
386391
setTimeout(() => {

src/pages/tenant/manage/drift.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ const ManageDriftPage = () => {
3434
const router = useRouter();
3535
const { templateId } = router.query;
3636
const userSettingsDefaults = useSettings();
37-
const tenantFilter = userSettingsDefaults.currentTenant || "";
37+
// Prioritize URL query parameter, then fall back to settings
38+
const tenantFilter = router.query.tenantFilter || userSettingsDefaults.currentTenant || "";
3839
const [anchorEl, setAnchorEl] = useState({});
3940
const [bulkActionsAnchorEl, setBulkActionsAnchorEl] = useState(null);
4041
const createDialog = useDialog();

src/pages/tenant/manage/edit.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ const Page = () => {
2222
const router = useRouter();
2323
const { templateId } = router.query;
2424
const settings = useSettings();
25-
const currentTenant = settings.currentTenant;
25+
// Prioritize URL query parameter, then fall back to settings
26+
const currentTenant = router.query.tenantFilter || settings.currentTenant;
2627

2728
const formControl = useForm({
2829
mode: "onChange",

src/pages/tenant/manage/history.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ const Page = () => {
4040
const router = useRouter();
4141
const { templateId } = router.query;
4242
const [daysToLoad, setDaysToLoad] = useState(5);
43-
const tenant = useSettings().currentTenant;
43+
const userSettings = useSettings();
44+
// Prioritize URL query parameter, then fall back to settings
45+
const tenant = router.query.tenantFilter || userSettings.currentTenant;
4446
const [expandedMessages, setExpandedMessages] = useState(new Set());
4547

4648
// Toggle message expansion

0 commit comments

Comments
 (0)