Skip to content

Commit 9c6dbd0

Browse files
authored
Merge pull request #680 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents bcc11cd + bac437a commit 9c6dbd0

File tree

5 files changed

+71
-18
lines changed

5 files changed

+71
-18
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cipp",
3-
"version": "8.8.1",
3+
"version": "8.8.2",
44
"author": "CIPP Contributors",
55
"homepage": "https://cipp.app/",
66
"bugs": {

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.8.1"
2+
"version": "8.8.2"
33
}

src/components/CippComponents/CippRestoreBackupDrawer.jsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { ApiPostCall } from "../../api/ApiCall";
1313
export const CippRestoreBackupDrawer = ({
1414
buttonText = "Restore Backup",
1515
backupName = null,
16+
backupData = null,
1617
requiredPermissions = [],
1718
PermissionButton = Button,
1819
...props
@@ -85,7 +86,12 @@ export const CippRestoreBackupDrawer = ({
8586
const values = formControl.getValues();
8687
const startDate = new Date();
8788
const unixTime = Math.floor(startDate.getTime() / 1000) - 45;
88-
const tenantFilterValue = tenantFilter;
89+
90+
// If in AllTenants context, use the tenant from the backup data
91+
let tenantFilterValue = tenantFilter;
92+
if (tenantFilter === "AllTenants" && backupData?.tenantSource) {
93+
tenantFilterValue = backupData.tenantSource;
94+
}
8995

9096
const shippedValues = {
9197
TenantFilter: tenantFilterValue,
@@ -202,7 +208,12 @@ export const CippRestoreBackupDrawer = ({
202208
queryKey: `BackupList-${tenantFilter}-autocomplete`,
203209
labelField: (option) => {
204210
const match = option.BackupName.match(/.*_(\d{4}-\d{2}-\d{2})-(\d{2})(\d{2})/);
205-
return match ? `${match[1]} @ ${match[2]}:${match[3]}` : option.BackupName;
211+
const dateTime = match
212+
? `${match[1]} @ ${match[2]}:${match[3]}`
213+
: option.BackupName;
214+
const tenantDisplay =
215+
tenantFilter === "AllTenants" ? ` (${option.TenantFilter})` : "";
216+
return `${dateTime}${tenantDisplay}`;
206217
},
207218
valueField: "BackupName",
208219
data: {

src/layouts/HeaderedTabbedLayout.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export const HeaderedTabbedLayout = (props) => {
115115
!mdDown && {
116116
flexGrow: 1,
117117
overflow: "auto",
118-
height: "calc(100vh - 30px)",
118+
height: "calc(100vh - 350px)",
119119
}
120120
}
121121
>

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

Lines changed: 55 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { Layout as DashboardLayout } from "/src/layouts/index.js";
22
import { HeaderedTabbedLayout } from "/src/layouts/HeaderedTabbedLayout";
3+
import { useState } from "react";
4+
import { useForm, useWatch } from "react-hook-form";
35
import {
46
Button,
57
Box,
@@ -31,6 +33,7 @@ import { CippBackupScheduleDrawer } from "/src/components/CippComponents/CippBac
3133
import { CippRestoreBackupDrawer } from "/src/components/CippComponents/CippRestoreBackupDrawer";
3234
import { CippApiDialog } from "/src/components/CippComponents/CippApiDialog";
3335
import { CippTimeAgo } from "/src/components/CippComponents/CippTimeAgo";
36+
import { CippFormTenantSelector } from "/src/components/CippComponents/CippFormTenantSelector";
3437
import { useDialog } from "/src/hooks/use-dialog";
3538
import ReactTimeAgo from "react-time-ago";
3639
import tabOptions from "./tabOptions.json";
@@ -42,6 +45,8 @@ const Page = () => {
4245
const { templateId } = router.query;
4346
const settings = useSettings();
4447
const removeDialog = useDialog();
48+
const tenantFilterForm = useForm({ defaultValues: { tenantFilter: null } });
49+
const backupTenantFilter = useWatch({ control: tenantFilterForm.control, name: "tenantFilter" });
4550
// Prioritize URL query parameter, then fall back to settings
4651
const currentTenant = router.query.tenantFilter || settings.currentTenant;
4752

@@ -79,19 +84,28 @@ const Page = () => {
7984
return ["Configuration"];
8085
};
8186

82-
const backupDisplayItems = filteredBackupData.map((backup, index) => ({
87+
// Filter backup data by selected tenant if in AllTenants view
88+
const tenantFilteredBackupData =
89+
settings.currentTenant === "AllTenants" &&
90+
backupTenantFilter &&
91+
backupTenantFilter !== "AllTenants"
92+
? filteredBackupData.filter((backup) => backup.TenantFilter === backupTenantFilter)
93+
: filteredBackupData;
94+
95+
const backupDisplayItems = tenantFilteredBackupData.map((backup, index) => ({
8396
id: backup.RowKey || index,
8497
name: backup.BackupName || "Unnamed Backup",
8598
timestamp: backup.Timestamp,
86-
tenantSource: backup.BackupName?.includes("AllTenants")
87-
? "All Tenants"
88-
: backup.BackupName?.replace("CIPP Backup - ", "") || settings.currentTenant,
99+
tenantSource: backup.TenantFilter || settings.currentTenant,
89100
tags: generateBackupTags(backup),
90101
}));
91102

92103
// Process existing backup configuration, find tenantFilter. by comparing settings.currentTenant with Tenant.value
93104
const currentConfig = Array.isArray(existingBackupConfig.data)
94-
? existingBackupConfig.data.find((tenant) => tenant.Tenant.value === settings.currentTenant)
105+
? existingBackupConfig.data.find(
106+
(tenant) =>
107+
tenant.Tenant.value === settings.currentTenant || tenant.Tenant.value === "AllTenants"
108+
)
95109
: null;
96110
const hasExistingConfig = currentConfig && currentConfig.Parameters?.ScheduledBackupValues;
97111

@@ -281,13 +295,33 @@ const Page = () => {
281295

282296
<Grid size={{ md: 6, xs: 12 }}>
283297
{/* Backup History */}
284-
<Card sx={{ height: "100%" }}>
285-
<CardContent>
286-
<Stack spacing={3}>
287-
<Typography variant="h6" sx={{ display: "flex", alignItems: "center", gap: 1 }}>
288-
<History color="primary" />
289-
Backup History
290-
</Typography>
298+
<Card sx={{ height: "100%", display: "flex", flexDirection: "column" }}>
299+
<CardContent sx={{ flex: 1, display: "flex", flexDirection: "column" }}>
300+
<Stack
301+
spacing={3}
302+
sx={{ height: "100%", display: "flex", flexDirection: "column" }}
303+
>
304+
<Box
305+
sx={{ display: "flex", justifyContent: "space-between", alignItems: "center" }}
306+
>
307+
<Typography variant="h6" sx={{ display: "flex", alignItems: "center", gap: 1 }}>
308+
<History color="primary" />
309+
Backup History
310+
</Typography>
311+
{settings.currentTenant === "AllTenants" && (
312+
<Box sx={{ minWidth: 250 }}>
313+
<CippFormTenantSelector
314+
formControl={tenantFilterForm}
315+
componentType="select"
316+
name="tenantFilter"
317+
type="single"
318+
required={false}
319+
disableClearable={false}
320+
allTenants={true}
321+
/>
322+
</Box>
323+
)}
324+
</Box>
291325

292326
<Typography variant="body2" color="text.secondary">
293327
{settings.currentTenant === "AllTenants"
@@ -307,7 +341,7 @@ const Page = () => {
307341
<Skeleton variant="rectangular" width="100%" height={200} />
308342
</Stack>
309343
) : (
310-
<Box sx={{ maxHeight: "400px", overflowY: "auto" }}>
344+
<Box sx={{ maxHeight: "calc(100vh - 525px)", overflowY: "auto" }}>
311345
<Stack spacing={2}>
312346
{backupDisplayItems.map((backup) => (
313347
<Card key={backup.id} variant="outlined">
@@ -334,6 +368,14 @@ const Page = () => {
334368
<Typography variant="body2" color="text.secondary">
335369
<ReactTimeAgo date={backup.timestamp} />
336370
</Typography>
371+
{settings.currentTenant === "AllTenants" && (
372+
<Chip
373+
label={`Tenant: ${backup.tenantSource}`}
374+
size="small"
375+
sx={{ mt: 1 }}
376+
variant="outlined"
377+
/>
378+
)}
337379
</Box>
338380
<Stack direction="row" spacing={1} sx={{ flexShrink: 0 }}>
339381
<CippRestoreBackupDrawer

0 commit comments

Comments
 (0)