Skip to content

Commit

Permalink
reduced ternary operators
Browse files Browse the repository at this point in the history
  • Loading branch information
fahad-aot committed Jan 16, 2025
1 parent d63fd0b commit f4d6288
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions forms-flow-web/src/components/Modeler/ProcessTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ const ProcessTable = React.memo(() => {
const isBPMN = viewType === "subflow";
const dispatch = useDispatch();
const { t } = useTranslation();
const ProcessContents = isBPMN
? {
processType: "BPMN",
extension: ".bpmn",
}
: {
processType: "DMN",
extension: ".dmn",
};

// States and selectors
const processList = useSelector((state) =>
Expand Down Expand Up @@ -81,7 +90,7 @@ const ProcessTable = React.memo(() => {
{
pageNo: currentState.activePage,
tenant_key: tenantKey,
processType: isBPMN ? "BPMN" : "DMN",
processType: ProcessContents.processType,
limit: currentState.limit,
searchKey: search,
sortBy: currentState.sortConfig.activeKey,
Expand Down Expand Up @@ -180,13 +189,13 @@ const ProcessTable = React.memo(() => {
{
id: 1,
heading: "Build",
body: `Create the ${isBPMN ? "BPMN" : "DMN"} from scratch`,
body: `Create the ${ProcessContents.processType} from scratch`,
onClick: () => dispatch(push(`${redirectUrl}${viewType}/create`)),
},
{
id: 2,
heading: "Import",
body: `Upload ${isBPMN ? "BPMN" : "DMN"} from a file`,
body: `Upload ${ProcessContents.processType} from a file`,
onClick: showImportModal,
},
];
Expand All @@ -200,18 +209,20 @@ const ProcessTable = React.memo(() => {
setSearch={isBPMN ? setSearchBPMN : setSearchDMN}
handleSearch={handleSearch}
handleClearSearch={handleClearSearch}
placeholder={t(`Search ${isBPMN ? "BPMN" : "Decision Table"}`)}
placeholder={t(`Search ${ProcessContents.processType} Name`)}
searchLoading={searchLoading}
title={t(`Search ${isBPMN ? "BPMN" : "DMN"} Name`)}
dataTestId={`${isBPMN ? "BPMN" : "DMN"}-search-input`}
title={t(`Search ${ProcessContents.processType} Name`)}
dataTestId={`${ProcessContents.processType}-search-input`}
/>
</div>
<div className="d-md-flex justify-content-end align-items-center">
<CustomButton
variant="primary"
size="sm"
label={`New ${isBPMN ? "BPMN" : "DMN"}`}
label={`New ${ProcessContents.processType}`}
onClick={handleCreateProcess}
dataTestid={`create-${ProcessContents.processType}-button`}
ariaLabel={` Create ${ProcessContents.processType}`}
/>
</div>
</div>
Expand Down Expand Up @@ -264,7 +275,7 @@ const ProcessTable = React.memo(() => {
key={processItem.id}
item={processItem}
gotoEdit={gotoEdit}
buttonLabel={isBPMN ? "Bpmn" : "Dmn"}
buttonLabel={ProcessContents.processType}
/>
))}
<TableFooter
Expand All @@ -291,14 +302,14 @@ const ProcessTable = React.memo(() => {
<BuildModal
show={showBuildModal}
onClose={handleBuildModal}
title={t(`New ${isBPMN ? "BPMN" : "DMN"}`)}
title={t(`New ${ProcessContents.processType}`)}
contents={modalContents}
/>
{importProcess && (
<ImportProcess
showModal={importProcess}
closeImport={() => setImportProcess(false)}
fileType={isBPMN ? ".bpmn" : ".dmn"}
fileType={ProcessContents.extension}
/>
)}
</>
Expand Down

0 comments on commit f4d6288

Please sign in to comment.