Skip to content

Commit 7d7ccfb

Browse files
authored
Merge pull request #2991 from vinaayakh-aot/feature/FWF-5410-phase-2-integration
Fix issues with flow history rendering and disabled save and publish …
2 parents 2bf72c0 + 7a744da commit 7d7ccfb

File tree

2 files changed

+80
-93
lines changed

2 files changed

+80
-93
lines changed

forms-flow-web/src/routes/Design/Forms/FlowEdit.js

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import React, {
88
import {
99
CustomButton,
1010
ConfirmModal,
11-
HistoryModal,
11+
// HistoryModal,
1212
//CurlyBracketsIcon,
1313
VariableSelection,
1414
CloseIcon,
@@ -26,7 +26,6 @@ import { push } from "connected-react-router";
2626
import { processMigrate } from "../../../apiManager/services/FormServices";
2727
import {
2828
updateProcess,
29-
getProcessHistory,
3029
fetchRevertingProcessData,
3130
saveFormProcessMapperPut
3231
} from "../../../apiManager/services/processServices.js";
@@ -47,7 +46,6 @@ const FlowEdit = forwardRef(
4746
(
4847
{
4948
isPublished = false,
50-
CategoryType,
5149
setWorkflowIsChanged,
5250
migration,
5351
setMigration,
@@ -79,7 +77,6 @@ const FlowEdit = forwardRef(
7977
return null;
8078
});
8179
const [showDiscardModal, setShowDiscardModal] = useState(false);
82-
const [showHistoryModal, setShowHistoryModal] = useState(false);
8380
const [isReverted, setIsReverted] = useState(false);
8481
const { createDesigns } = userRoles();
8582
const [showVariableModal, setShowVariableModal] = useState(false);
@@ -108,20 +105,19 @@ const FlowEdit = forwardRef(
108105
setSavedFormVariables(updatedLabels);
109106
}, [formProcessList]);
110107
/* --------- fetching all process history when click history button --------- */
111-
const {
112-
data: { data: historiesData } = {}, // response data destructured
113-
mutate: fetchHistories, // mutate function used to call the api function and here mutate renamed to fetch histories
114-
// isLoading: historiesLoading,
115-
// isError: historiesError,
116-
} = useMutation(
117-
({ parentProcessKey, page, limit }) =>
118-
getProcessHistory({ parentProcessKey, page, limit }) // this is api calling function and mutate function accepting some parameter and passing to the apicalling function
119-
);
108+
// const {
109+
// // data: { data: historiesData } = {}, // response data destructured
110+
// mutate: fetchHistories, // mutate function used to call the api function and here mutate renamed to fetch histories
111+
// // isLoading: historiesLoading,
112+
// // isError: historiesError,
113+
// } = useMutation(
114+
// ({ parentProcessKey, page, limit }) =>
115+
// getProcessHistory({ parentProcessKey, page, limit }) // this is api calling function and mutate function accepting some parameter and passing to the apicalling function
116+
// );
120117

121118
/* --------- fetch a perticular history when click the revert button -------- */
122119
const {
123120
data: { data: historyData } = {},
124-
mutate: fetchHistoryData,
125121
isLoading: historyLoading,
126122
// isError: historyDataError,
127123
} = useMutation((processId) => fetchRevertingProcessData(processId), {
@@ -132,8 +128,6 @@ const FlowEdit = forwardRef(
132128
});
133129

134130
const handleDiscardModal = () => setShowDiscardModal(!showDiscardModal);
135-
const handleToggleHistoryModal = () =>
136-
setShowHistoryModal(!showHistoryModal);
137131

138132

139133
const enableWorkflowChange = async () => {
@@ -203,9 +197,9 @@ const enableWorkflowChange = async () => {
203197
// });
204198
// };
205199

206-
const loadMoreBtnAction = () => {
207-
fetchHistories({ parentProcessKey: processData.parentProcessKey });
208-
};
200+
// const loadMoreBtnAction = () => {
201+
// fetchHistories({ parentProcessKey: processData.parentProcessKey });
202+
// };
209203
const handleSaveFlowClick = () => {
210204
//On clicking the save flow it checks if the current flow has already been migrated, if not, it tries to migrate first.
211205
if (shouldShowMigrationModal()) {
@@ -476,7 +470,7 @@ const enableWorkflowChange = async () => {
476470
/>
477471
)}
478472

479-
<HistoryModal
473+
{/* <HistoryModal
480474
show={showHistoryModal}
481475
onClose={handleToggleHistoryModal}
482476
title={t("History")}
@@ -491,7 +485,7 @@ const enableWorkflowChange = async () => {
491485
disableAllRevertButton={
492486
processData.status === "Published" || isPublished
493487
}
494-
/>
488+
/> */}
495489
{/* Show unsaved changes modal when layout is not saved */}
496490
{showUnsavedChangesModal && (
497491
<Modal
@@ -556,9 +550,6 @@ const enableWorkflowChange = async () => {
556550
);
557551

558552
FlowEdit.propTypes = {
559-
CategoryType: PropTypes.shape({
560-
WORKFLOW: PropTypes.string.isRequired,
561-
}).isRequired,
562553
isPublished: PropTypes.bool.isRequired,
563554
setWorkflowIsChanged: PropTypes.func,
564555
migration: PropTypes.bool,

forms-flow-web/src/routes/Design/Forms/FormEdit.js

Lines changed: 65 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ const EditComponent = () => {
180180
// created a copy for access and submissin access
181181
const [formAccessRoles, setFormAccessRoles] = useState(_cloneDeep(formAccess));
182182
const [submissionAccessRoles, setSubmissionAccessRoles] = useState(_cloneDeep(submissionAccess));
183-
const [formHistoryLoading, setFormHistoryLoading] = useState(false);
184183
const { path, display } = useSelector((state) => state.form.form);
185184

186185
const { authorizationDetails: formAuthorization } = useSelector(
@@ -438,7 +437,7 @@ const EditComponent = () => {
438437
}
439438
}
440439
);
441-
const [paginationModel, setPaginationModel] = useState({ page: 0, pageSize: 10 });
440+
const [paginationModel] = useState({ page: 0, pageSize: 10 });
442441

443442
const UploadActionType = {
444443
IMPORT: "import",
@@ -657,7 +656,6 @@ const EditComponent = () => {
657656
} = useSelector((state) => state.formRestore);
658657

659658
/* ------------------------- BPMN history variables ------------------------- */
660-
const [showBpmnHistoryModal, setShowBpmnHistoryModal] = useState(false);
661659
const [bpmnHistoryData, setBpmnHistoryData] = useState({ processHistory: [], totalCount: 0 });
662660

663661
/* -------------------------- getting process data -------------------------- */
@@ -741,6 +739,9 @@ useEffect(() => {
741739
if (activeTab.primary === "form" && activeTab.secondary === "history") {
742740
handleFormHistory();
743741
}
742+
if (activeTab.primary === "bpmn" && activeTab.secondary === "history") {
743+
handleBpmnHistory();
744+
}
744745
}, [activeTab.primary, activeTab.secondary, processListData?.parentFormId,
745746
paginationModel.pageSize]);
746747

@@ -1217,14 +1218,12 @@ const saveFormWithWorkflow = async () => {
12171218
// setShowHistoryModal(false);
12181219
// };
12191220
const fetchFormHistory = (parentFormId, page, limit) => {
1220-
setFormHistoryLoading(true);
12211221
parentFormId = parentFormId && typeof parentFormId === 'string' ? parentFormId : processListData?.parentFormId;
12221222
page = page ? page : paginationModel.page + 1;
12231223
limit = limit ? limit : paginationModel.pageSize;
12241224
getFormHistory(parentFormId,page, limit)
12251225
.then((res) => {
12261226
dispatch(setFormHistories(res.data));
1227-
setFormHistoryLoading(false);
12281227
})
12291228
.catch(() => {
12301229
setFormHistories([]);
@@ -1233,7 +1232,6 @@ const saveFormWithWorkflow = async () => {
12331232

12341233
const handleFormHistory = () => {
12351234
console.log("handleFormHistory", processListData);
1236-
// setShowHistoryModal(true);
12371235
dispatch(setFormHistories({ formHistory: [], totalCount: 0 }));
12381236
if (processListData?.parentFormId) {
12391237
fetchFormHistory(processListData?.parentFormId, 1, paginationModel.pageSize);
@@ -1246,7 +1244,6 @@ const saveFormWithWorkflow = async () => {
12461244

12471245
/* ------------------------- BPMN history handlers ------------------------- */
12481246
const handleBpmnHistory = () => {
1249-
setShowBpmnHistoryModal(true);
12501247
setBpmnHistoryData({ processHistory: [], totalCount: 0 });
12511248
if (processData?.parentProcessKey) {
12521249
fetchBpmnHistory(processData.parentProcessKey, 1, 4);
@@ -1282,9 +1279,7 @@ const saveFormWithWorkflow = async () => {
12821279
}
12831280
};
12841281

1285-
const closeBpmnHistoryModal = () => {
1286-
setShowBpmnHistoryModal(false);
1287-
};
1282+
12881283

12891284
const revertFormBtnAction = (cloneId) => {
12901285
dispatch(setRestoreFormId(cloneId));
@@ -1870,6 +1865,7 @@ const saveFormWithWorkflow = async () => {
18701865
const renderTabContent = () => {
18711866
switch (activeTab.primary) {
18721867
case 'form':
1868+
// Check if history sub-tab is active
18731869
if (activeTab.secondary === 'history') {
18741870
return (
18751871
<HistoryPage
@@ -1879,28 +1875,26 @@ const saveFormWithWorkflow = async () => {
18791875
revertBtnAction={revertFormBtnAction}
18801876
historyCount={formHistoryData.totalCount}
18811877
disableAllRevertButton={isPublished}
1882-
loading={formHistoryLoading}
1878+
loading={false}
18831879
refreshBtnAction={fetchFormHistory}
18841880
paginationModel={paginationModel}
1885-
handlePaginationModelChange={setPaginationModel}
1881+
handlePaginationModelChange={() => {}}
18861882
/>
18871883
);
18881884
}
18891885
// Check if settings sub-tab is active
18901886
if (activeTab.secondary === 'settings') {
18911887
return (
1892-
1893-
<SettingsTab
1894-
handleConfirm={handleConfirmSettings}
1895-
isCreateRoute={isCreateRoute}
1896-
rolesState={rolesState}
1897-
formDetails={formDetails}
1898-
isAnonymous={isAnonymous}
1899-
setIsAnonymous={setIsAnonymous}
1900-
setFormDetails={setFormDetails}
1901-
setRolesState={setRolesState}
1902-
/>
1903-
1888+
<SettingsTab
1889+
handleConfirm={handleConfirmSettings}
1890+
isCreateRoute={isCreateRoute}
1891+
rolesState={rolesState}
1892+
formDetails={formDetails}
1893+
isAnonymous={isAnonymous}
1894+
setIsAnonymous={setIsAnonymous}
1895+
setFormDetails={setFormDetails}
1896+
setRolesState={setRolesState}
1897+
/>
19041898
);
19051899
}
19061900
return (
@@ -2024,8 +2018,8 @@ const saveFormWithWorkflow = async () => {
20242018
{/* Show variable content when on variables tab */}
20252019
{variableContent && <div className="variable-content">{variableContent}</div>}
20262020

2027-
{/* Always keep FlowEdit mounted but hide when showing variables */}
2028-
<div className="bpmn-editor" style={{ display: variableContent ? 'none' : 'block' }}>
2021+
{/* Always keep FlowEdit mounted but hide when showing variables or history */}
2022+
<div className="bpmn-editor" style={{ display: (variableContent || activeTab.secondary === 'history') ? 'none' : 'block' }}>
20292023
{isProcessDetailsLoading ? (
20302024
<div className="d-flex justify-content-center p-4">
20312025
<div className="spinner-grow" aria-live="polite">
@@ -2093,11 +2087,9 @@ const saveFormWithWorkflow = async () => {
20932087
handleTabClick('form', 'settings');
20942088
} else if (key === 'history') {
20952089
if (activeTab.primary === 'form') {
2096-
activeTab.secondary = 'history';
20972090
handleTabClick('form', 'history');
2098-
handleFormHistory();
20992091
} else if (activeTab.primary === 'bpmn') {
2100-
handleBpmnHistory();
2092+
handleTabClick('bpmn', 'history');
21012093
}
21022094
} else if (key === 'preview') {
21032095
handlePreview();
@@ -2194,12 +2186,14 @@ const saveFormWithWorkflow = async () => {
21942186
</div>
21952187
{createDesigns && (
21962188
<>
2189+
{/* {
2190+
logic for save button disabled
2191+
isCreateRoute
2192+
? !formDetails.title?.trim()
2193+
: !formChangeState.changed && !workflowIsChanged
2194+
} */}
21972195
<V8CustomButton
2198-
disabled={
2199-
isCreateRoute
2200-
? !formDetails.title?.trim()
2201-
: !formChangeState.changed && !workflowIsChanged
2202-
}
2196+
disabled={true}
22032197
label={t("Save")}
22042198
onClick={
22052199
isPublished
@@ -2210,6 +2204,7 @@ const saveFormWithWorkflow = async () => {
22102204
ariaLabel={t("Save Form Layout")}
22112205
/>
22122206
<V8CustomButton
2207+
disabled={true}
22132208
label={t(publishText)}
22142209
onClick={handlePublishClick}
22152210
dataTestId="handle-publish-testid"
@@ -2235,13 +2230,26 @@ const saveFormWithWorkflow = async () => {
22352230
return (
22362231
<V8CustomButton
22372232
key={key}
2238-
onClick={() => handleTabClick(key)}
2233+
onClick={() => {
2234+
// When clicking a primary tab, always go to the main view
2235+
// Only skip navigation if already on the main view
2236+
const isOnMainView = activeTab.primary === key &&
2237+
!activeTab.secondary &&
2238+
!activeTab.tertiary;
2239+
2240+
if (isOnMainView) {
2241+
// Already on this tab's main view, avoid navigation
2242+
return;
2243+
}
2244+
// Switch to main view (clearing secondary and tertiary)
2245+
handleTabClick(key, null, null);
2246+
}}
22392247
data-testid={`tab-${key}`}
22402248
aria-label={t(`${config.label} Tab`)}
22412249
role="tab"
2242-
aria-selected={activeTab.primary === key}
2250+
aria-selected={activeTab.primary === key && !activeTab.secondary}
22432251
label={t(config.label)}
2244-
selected={activeTab.primary === key}
2252+
selected={activeTab.primary === key && !activeTab.secondary}
22452253
//disabled={isDisabled}
22462254
/>
22472255
);
@@ -2289,9 +2297,27 @@ const saveFormWithWorkflow = async () => {
22892297
)}
22902298

22912299
{/* Body Section - Main content */}
2292-
<div className="body-section formedit-layout">
2300+
<div className="body-section formedit-layout" style={{ display: (activeTab.primary === 'bpmn' && activeTab.secondary === 'history') ? 'none' : 'block' }}>
22932301
{renderTabContent()}
22942302
</div>
2303+
2304+
{/* BPMN History Section - Show when on BPMN history tab */}
2305+
{(activeTab.primary === 'bpmn' && activeTab.secondary === 'history') && (
2306+
<div className="body-section">
2307+
<HistoryPage
2308+
title={t("BPMN History")}
2309+
loadMoreBtnText={t("Load More")}
2310+
loadMoreBtndataTestId="load-more-bpmn-history"
2311+
revertBtnText={t("Revert To This")}
2312+
allHistory={bpmnHistoryData.processHistory}
2313+
loadMoreBtnAction={loadMoreBpmnHistory}
2314+
categoryType={CategoryType.WORKFLOW}
2315+
revertBtnAction={revertBpmnHistory}
2316+
historyCount={bpmnHistoryData.totalCount}
2317+
disableAllRevertButton={isPublished}
2318+
/>
2319+
</div>
2320+
)}
22952321
</div>
22962322
</div>
22972323
</LoadingOverlay>
@@ -2369,37 +2395,7 @@ const saveFormWithWorkflow = async () => {
23692395
/>
23702396
)}
23712397

2372-
{/* <HistoryPage
2373-
// show={showHistoryModal}
2374-
// onClose={closeHistoryModal}
2375-
title={t("History")}
2376-
loadMoreBtnText={t("Load More")}
2377-
loadMoreBtndataTestId="load-more-form-history"
2378-
revertBtnText={t("Revert To This")}
2379-
allHistory={formHistory}
2380-
loadMoreBtnAction={loadMoreBtnAction}
2381-
categoryType={CategoryType.FORM}
2382-
revertBtnAction={revertFormBtnAction}
2383-
historyCount={formHistoryData.totalCount}
2384-
disableAllRevertButton={isPublished}
2385-
/> */}
2386-
2387-
{showBpmnHistoryModal && (
2388-
<HistoryPage
2389-
show={showBpmnHistoryModal}
2390-
onClose={closeBpmnHistoryModal}
2391-
title={t("BPMN History")}
2392-
loadMoreBtnText={t("Load More")}
2393-
loadMoreBtndataTestId="load-more-bpmn-history"
2394-
revertBtnText={t("Revert To This")}
2395-
allHistory={bpmnHistoryData.processHistory}
2396-
loadMoreBtnAction={loadMoreBpmnHistory}
2397-
categoryType={CategoryType.WORKFLOW}
2398-
revertBtnAction={revertBpmnHistory}
2399-
historyCount={bpmnHistoryData.totalCount}
2400-
disableAllRevertButton={isPublished}
2401-
/>
2402-
)}
2398+
24032399

24042400
<PromptModal
24052401
show={showDeleteModal}

0 commit comments

Comments
 (0)