@@ -114,6 +114,24 @@ const tabConfig = {
114114 } ,
115115 }
116116 } ,
117+ flow : {
118+ label : "Flow" ,
119+ query : "?tab=flow" ,
120+ secondary : {
121+ layout : {
122+ label : "Layout" ,
123+ query : "?tab=flow&sub=layout"
124+ } ,
125+ history : {
126+ label : "History" ,
127+ query : "?tab=flow&sub=history"
128+ } ,
129+ variables : {
130+ label : "Variables" ,
131+ query : "?tab=flow&sub=variables"
132+ } ,
133+ }
134+ } ,
117135 bpmn : {
118136 label : "BPMN" ,
119137 query : "?tab=bpmn" ,
@@ -168,7 +186,6 @@ const EditComponent = () => {
168186 /* ------------------------------- mapper data ------------------------------ */
169187 const { formProcessList : processListData , formPreviousData : previousData } =
170188 useSelector ( ( state ) => state . process ) ;
171-
172189 /* -------------------------------- user data and form access data ------------------------------- */
173190 const {
174191 formAccess = [ ] ,
@@ -180,6 +197,8 @@ const EditComponent = () => {
180197 // created a copy for access and submissin access
181198 const [ formAccessRoles , setFormAccessRoles ] = useState ( _cloneDeep ( formAccess ) ) ;
182199 const [ submissionAccessRoles , setSubmissionAccessRoles ] = useState ( _cloneDeep ( submissionAccess ) ) ;
200+ const [ formHistoryLoading , setFormHistoryLoading ] = useState ( false ) ;
201+ const [ flowHistoryLoading , setFlowHistoryLoading ] = useState ( false ) ;
183202 const { path, display } = useSelector ( ( state ) => state . form . form ) ;
184203
185204 const { authorizationDetails : formAuthorization } = useSelector (
@@ -437,7 +456,7 @@ const EditComponent = () => {
437456 }
438457 }
439458 ) ;
440- const [ paginationModel ] = useState ( { page : 0 , pageSize : 10 } ) ;
459+ const [ paginationModel , setPaginationModel ] = useState ( { page : 0 , pageSize : 10 } ) ;
441460
442461 const UploadActionType = {
443462 IMPORT : "import" ,
@@ -650,6 +669,7 @@ const EditComponent = () => {
650669 /* ------------------------- form history variables ------------------------- */
651670 const [ isNewVersionLoading , setIsNewVersionLoading ] = useState ( false ) ;
652671 const [ restoreFormDataLoading , setRestoreFormDataLoading ] = useState ( false ) ;
672+
653673 const {
654674 formHistoryData = { } ,
655675 restoredFormId,
@@ -739,9 +759,9 @@ useEffect(() => {
739759 if ( activeTab . primary === "form" && activeTab . secondary === "history" ) {
740760 handleFormHistory ( ) ;
741761 }
742- if ( activeTab . primary === "bpmn " && activeTab . secondary === "history" ) {
743- handleBpmnHistory ( ) ;
744- }
762+ // if (activeTab.primary === "flow " && activeTab.secondary === "history") {
763+ // handleBpmnHistory();
764+ // }
745765 } , [ activeTab . primary , activeTab . secondary , processListData ?. parentFormId ,
746766 paginationModel . pageSize ] ) ;
747767
@@ -1216,12 +1236,14 @@ const saveFormWithWorkflow = async () => {
12161236 // setShowHistoryModal(false);
12171237 // };
12181238 const fetchFormHistory = ( parentFormId , page , limit ) => {
1239+ setFormHistoryLoading ( true ) ;
12191240 parentFormId = parentFormId && typeof parentFormId === 'string' ? parentFormId : processListData ?. parentFormId ;
12201241 page = page ? page : paginationModel . page + 1 ;
12211242 limit = limit ? limit : paginationModel . pageSize ;
12221243 getFormHistory ( parentFormId , page , limit )
12231244 . then ( ( res ) => {
12241245 dispatch ( setFormHistories ( res . data ) ) ;
1246+ setFormHistoryLoading ( false ) ;
12251247 } )
12261248 . catch ( ( ) => {
12271249 setFormHistories ( [ ] ) ;
@@ -1241,19 +1263,28 @@ const saveFormWithWorkflow = async () => {
12411263
12421264 /* ------------------------- BPMN history handlers ------------------------- */
12431265 const handleBpmnHistory = ( ) => {
1244- setBpmnHistoryData ( { processHistory : [ ] , totalCount : 0 } ) ;
1245- if ( processData ?. parentProcessKey ) {
1246- fetchBpmnHistory ( processData . parentProcessKey , 1 , 4 ) ;
1266+ const parentKey = processData ?. parentProcessKey ;
1267+ if ( ! parentKey ) {
1268+ setFlowHistoryLoading ( false ) ;
1269+ return ;
12471270 }
1271+ setBpmnHistoryData ( { processHistory : [ ] , totalCount : 0 } ) ;
1272+ setFlowHistoryLoading ( true ) ;
1273+ fetchBpmnHistory ( parentKey , paginationModel . page + 1 , paginationModel . pageSize ) ;
12481274 } ;
12491275
1250- const fetchBpmnHistory = async ( parentProcessKey , page = 1 , limit = 4 ) => {
1276+ const fetchBpmnHistory = async ( parentProcessKey , page , limit ) => {
12511277 try {
12521278 const response = await getProcessHistory ( { parentProcessKey, page, limit } ) ;
1253- setBpmnHistoryData ( response . data ) ;
1279+ // setBpmnHistoryData(response.data);
1280+ // setFlowHistoryLoading(false);
1281+ const data = response ?. data || { processHistory : [ ] , totalCount : 0 } ;
1282+ setBpmnHistoryData ( data ) ;
12541283 } catch ( error ) {
12551284 console . error ( "Error fetching BPMN history:" , error ) ;
12561285 setBpmnHistoryData ( { processHistory : [ ] , totalCount : 0 } ) ;
1286+ } finally {
1287+ setFlowHistoryLoading ( false ) ;
12571288 }
12581289 } ;
12591290
@@ -1276,8 +1307,6 @@ const saveFormWithWorkflow = async () => {
12761307 }
12771308 } ;
12781309
1279-
1280-
12811310 const revertFormBtnAction = ( cloneId ) => {
12821311 dispatch ( setRestoreFormId ( cloneId ) ) ;
12831312 fetchRestoredFormData ( cloneId ) ;
@@ -1857,6 +1886,28 @@ const saveFormWithWorkflow = async () => {
18571886 openConfirmModal ( isPublished ? "unpublish" : "publish" ) ;
18581887 }
18591888 } ;
1889+ const handlePaginationModelChange = ( newPaginationModel ) => {
1890+ setPaginationModel ( newPaginationModel ) ;
1891+ if ( activeTab . primary === 'form' && activeTab . secondary === 'history' ) {
1892+ if ( processListData ?. parentFormId ) {
1893+ fetchFormHistory (
1894+ processListData . parentFormId ,
1895+ newPaginationModel . page + 1 ,
1896+ newPaginationModel . pageSize
1897+ ) ;
1898+ }
1899+ }
1900+ if ( activeTab . primary === 'flow' && activeTab . secondary === 'history' ) {
1901+ if ( processData ?. parentProcessKey ) {
1902+ setFlowHistoryLoading ( true ) ;
1903+ fetchBpmnHistory (
1904+ processData . parentProcessKey ,
1905+ newPaginationModel . page + 1 ,
1906+ newPaginationModel . pageSize
1907+ ) ;
1908+ }
1909+ }
1910+ } ;
18601911
18611912 // Render tab content based on active tab
18621913 const renderTabContent = ( ) => {
@@ -1872,10 +1923,10 @@ const saveFormWithWorkflow = async () => {
18721923 revertBtnAction = { revertFormBtnAction }
18731924 historyCount = { formHistoryData . totalCount }
18741925 disableAllRevertButton = { isPublished }
1875- loading = { false }
1926+ loading = { formHistoryLoading }
18761927 refreshBtnAction = { fetchFormHistory }
18771928 paginationModel = { paginationModel }
1878- handlePaginationModelChange = { ( ) => { } }
1929+ handlePaginationModelChange = { handlePaginationModelChange }
18791930 />
18801931 ) ;
18811932 }
@@ -1924,6 +1975,48 @@ const saveFormWithWorkflow = async () => {
19241975 ) }
19251976 </ div >
19261977 ) ;
1978+
1979+ case 'flow' :
1980+ if ( activeTab . secondary === 'history' && processData ?. parentProcessKey ) {
1981+ return (
1982+ < HistoryPage
1983+ revertBtnText = { t ( "Revert" ) }
1984+ allHistory = { bpmnHistoryData . processHistory }
1985+ categoryType = { CategoryType . WORKFLOW }
1986+ revertBtnAction = { ( processId ) => revertBpmnHistory ( processId ) }
1987+ historyCount = { bpmnHistoryData . totalCount }
1988+ disableAllRevertButton = { isPublished }
1989+ refreshBtnAction = { handleBpmnHistory }
1990+ paginationModel = { paginationModel }
1991+ handlePaginationModelChange = { handlePaginationModelChange }
1992+ loading = { flowHistoryLoading }
1993+ />
1994+ ) ;
1995+ }
1996+ return (
1997+ < FlowEdit
1998+ ref = { flowRef }
1999+ setWorkflowIsChanged = { setWorkflowIsChanged }
2000+ workflowIsChanged = { workflowIsChanged }
2001+ CategoryType = { CategoryType }
2002+ isPublished = { isPublished }
2003+ migration = { migration }
2004+ redirectUrl = { redirectUrl }
2005+ setMigration = { setMigration }
2006+ isMigrated = { processListData . isMigrated }
2007+ mapperId = { processListData . id }
2008+ layoutNotsaved = { formChangeState . changed }
2009+ handleCurrentLayout = { handleCurrentLayout }
2010+ isMigrationLoading = { isMigrationLoading }
2011+ setIsMigrationLoading = { setIsMigrationLoading }
2012+ handleUnpublishAndSaveChanges = { handleUnpublishAndSaveChanges }
2013+ isCreateRoute = { isCreateRoute }
2014+ currentBpmnXml = { currentBpmnXml }
2015+ setCurrentBpmnXml = { setCurrentBpmnXml }
2016+ activeTab = { activeTab }
2017+ allHistory = { bpmnHistoryData . processHistory }
2018+ />
2019+ ) ;
19272020 case 'bpmn' : {
19282021 // Determine which content to show
19292022 let variableContent = null ;
@@ -2085,6 +2178,11 @@ const saveFormWithWorkflow = async () => {
20852178 } else if ( key === 'history' ) {
20862179 if ( activeTab . primary === 'form' ) {
20872180 handleTabClick ( 'form' , 'history' ) ;
2181+ handleFormHistory ( ) ;
2182+ } else if ( activeTab . primary === 'flow' ) {
2183+ activeTab . secondary = 'history' ;
2184+ handleBpmnHistory ( ) ;
2185+ // handleTabClick('flow', 'history');
20882186 } else if ( activeTab . primary === 'bpmn' ) {
20892187 handleTabClick ( 'bpmn' , 'history' ) ;
20902188 }
0 commit comments