11import 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" } )` ,
0 commit comments