Skip to content

Commit 6328be6

Browse files
authored
Merge pull request #647 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents 81452c4 + 413b613 commit 6328be6

File tree

7 files changed

+1038
-660
lines changed

7 files changed

+1038
-660
lines changed

src/components/CippComponents/CippBreadcrumbNav.jsx

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,9 +457,43 @@ export const CippBreadcrumbNav = () => {
457457

458458
// Render based on mode
459459
if (mode === "hierarchical") {
460-
const breadcrumbs = buildHierarchicalBreadcrumbs();
460+
let breadcrumbs = buildHierarchicalBreadcrumbs();
461461

462-
// Don't show if no breadcrumbs found
462+
// Fallback: If no breadcrumbs found in navigation config, generate from URL path
463+
if (breadcrumbs.length === 0) {
464+
const pathSegments = router.pathname.split("/").filter((segment) => segment);
465+
466+
if (pathSegments.length > 0) {
467+
breadcrumbs = pathSegments.map((segment, index) => {
468+
// Build the path up to this segment
469+
const path = "/" + pathSegments.slice(0, index + 1).join("/");
470+
471+
// Format segment as title (replace hyphens with spaces, capitalize words)
472+
const title = segment
473+
.split("-")
474+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
475+
.join(" ");
476+
477+
return {
478+
title,
479+
path,
480+
type: "fallback",
481+
query: index === pathSegments.length - 1 ? { ...router.query } : {},
482+
};
483+
});
484+
485+
// If we have a current page title from document.title, use it for the last breadcrumb
486+
if (
487+
currentPageTitle &&
488+
currentPageTitle !== "CIPP" &&
489+
!currentPageTitle.toLowerCase().includes("loading")
490+
) {
491+
breadcrumbs[breadcrumbs.length - 1].title = currentPageTitle;
492+
}
493+
}
494+
}
495+
496+
// Don't show if still no breadcrumbs found
463497
if (breadcrumbs.length === 0) {
464498
return null;
465499
}

src/layouts/HeaderedTabbedLayout.jsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,18 @@ export const HeaderedTabbedLayout = (props) => {
8181
) : (
8282
subtitle && (
8383
<Stack alignItems="center" flexWrap="wrap" direction="row" spacing={2}>
84-
{subtitle.map((item, index) => (
85-
<Stack key={index} alignItems="center" direction="row" spacing={1}>
86-
<SvgIcon fontSize="small">{item.icon}</SvgIcon>
87-
<Typography color="text.secondary" variant="body2">
88-
{item.text}
89-
</Typography>
90-
</Stack>
91-
))}
84+
{subtitle.map((item, index) =>
85+
item.component ? (
86+
<Box key={index}>{item.component}</Box>
87+
) : (
88+
<Stack key={index} alignItems="center" direction="row" spacing={1}>
89+
<SvgIcon fontSize="small">{item.icon}</SvgIcon>
90+
<Typography color="text.secondary" variant="body2">
91+
{item.text}
92+
</Typography>
93+
</Stack>
94+
)
95+
)}
9296
</Stack>
9397
)
9498
)}

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

Lines changed: 935 additions & 640 deletions
Large diffs are not rendered by default.

src/pages/tenant/manage/driftManagementActions.js

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from "react";
2-
import { Sync, PlayArrow, PictureAsPdf } from "@mui/icons-material";
2+
import { Edit, Sync, PlayArrow, PictureAsPdf } from "@mui/icons-material";
33

44
/**
55
* Creates the standard drift management actions array
@@ -9,7 +9,14 @@ import { Sync, PlayArrow, PictureAsPdf } from "@mui/icons-material";
99
* @param {Function} options.onGenerateReport - Function to call when generate report is triggered (optional)
1010
* @returns {Array} Array of action objects
1111
*/
12-
export const createDriftManagementActions = ({ templateId, onRefresh, onGenerateReport, currentTenant }) => {
12+
export const createDriftManagementActions = ({
13+
templateId,
14+
templateType = "classic",
15+
showEditTemplate = false,
16+
onRefresh,
17+
onGenerateReport,
18+
currentTenant,
19+
}) => {
1320
const actions = [
1421
{
1522
label: "Refresh Data",
@@ -31,6 +38,27 @@ export const createDriftManagementActions = ({ templateId, onRefresh, onGenerate
3138

3239
// Add template-specific actions if templateId is available
3340
if (templateId) {
41+
// Conditionally add Edit Template action
42+
if (showEditTemplate) {
43+
actions.push({
44+
label: "Edit Template",
45+
icon: <Edit />,
46+
color: "info",
47+
noConfirm: true,
48+
customFunction: () => {
49+
// Use Next.js router for internal navigation
50+
import("next/router")
51+
.then(({ default: router }) => {
52+
router.push(`/tenant/standards/template?id=${templateId}&type=${templateType}`);
53+
})
54+
.catch(() => {
55+
// Fallback to window.location if router is not available
56+
window.location.href = `/tenant/standards/template?id=${templateId}&type=${templateType}`;
57+
});
58+
},
59+
});
60+
}
61+
3462
actions.push(
3563
{
3664
label: `Run Standard Now (${currentTenant || "Currently Selected Tenant"})`,

src/pages/tenant/manage/history.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ import {
3131
Info as InfoIcon,
3232
CheckCircle as SuccessIcon,
3333
ExpandMore,
34+
Sync,
3435
} from "@mui/icons-material";
3536
import tabOptions from "./tabOptions.json";
3637
import { useSettings } from "../../../hooks/use-settings";
37-
import { createDriftManagementActions } from "./driftManagementActions";
3838

3939
const Page = () => {
4040
const router = useRouter();
@@ -124,14 +124,17 @@ const Page = () => {
124124
setDaysToLoad((prev) => prev + 7);
125125
};
126126

127-
// Actions for the ActionsMenu
128-
const actions = createDriftManagementActions({
129-
templateId,
130-
onRefresh: () => {
131-
logsData.refetch();
127+
// Actions for the ActionsMenu - just refresh for history page
128+
const actions = [
129+
{
130+
label: "Refresh Data",
131+
icon: <Sync />,
132+
noConfirm: true,
133+
customFunction: () => {
134+
logsData.refetch();
135+
},
132136
},
133-
currentTenant: tenant,
134-
});
137+
];
135138

136139
const title = "View History";
137140
// Sort logs by date (newest first)

src/pages/tenant/manage/policies-deployed.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,8 @@ const PoliciesDeployedPage = () => {
353353

354354
const actions = createDriftManagementActions({
355355
templateId,
356+
templateType: currentTemplate?.type || "classic",
357+
showEditTemplate: true,
356358
onRefresh: () => {
357359
standardsApi.refetch();
358360
comparisonApi.refetch();

src/pages/tenant/standards/template.jsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import _ from "lodash";
1919
import { createDriftManagementActions } from "../manage/driftManagementActions";
2020
import { ActionsMenu } from "/src/components/actions-menu";
2121
import { useSettings } from "/src/hooks/use-settings";
22+
import { CippHead } from "../../../components/CippComponents/CippHead";
2223

2324
const Page = () => {
2425
const router = useRouter();
@@ -311,6 +312,17 @@ const Page = () => {
311312

312313
return (
313314
<Box sx={{ flexGrow: 1 }}>
315+
<CippHead
316+
title={
317+
editMode
318+
? isDriftMode
319+
? "Edit Drift Template"
320+
: "Edit Standards Template"
321+
: isDriftMode
322+
? "Add Drift Template"
323+
: "Add Standards Template"
324+
}
325+
/>
314326
<Container maxWidth={"xl"}>
315327
<Stack spacing={2}>
316328
<Stack

0 commit comments

Comments
 (0)