From 5a9c581eb543041f211abea72321484db2218902 Mon Sep 17 00:00:00 2001 From: Ajay krishna Date: Thu, 14 Nov 2024 12:07:30 +0530 Subject: [PATCH 1/4] nav changes regarding multi tenant issue --- forms-flow-nav/src/sidenav/MenuComponent.jsx | 16 +++++++++++++++- forms-flow-nav/src/sidenav/Sidebar.jsx | 13 +++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/forms-flow-nav/src/sidenav/MenuComponent.jsx b/forms-flow-nav/src/sidenav/MenuComponent.jsx index 2e3e9e05..b344a10b 100644 --- a/forms-flow-nav/src/sidenav/MenuComponent.jsx +++ b/forms-flow-nav/src/sidenav/MenuComponent.jsx @@ -5,14 +5,28 @@ import { Link, useLocation, useHistory } from "react-router-dom"; import { ChevronIcon } from "@formsflow/components"; import { MULTITENANCY_ENABLED } from "../constants/constants"; import { useTranslation } from "react-i18next"; +import { StorageService } from "@formsflow/service"; -const MenuComponent = ({ eventKey, mainMenu, subMenu, optionsCount }) => { +const MenuComponent = ({ eventKey, mainMenu, subMenu, optionsCount, subscribe }) => { + const [tenant, setTenant] = React.useState({}); const location = useLocation(); const history = useHistory(); + const tenantKey = tenant?.tenantId; const baseUrl = MULTITENANCY_ENABLED ? `/tenant/${tenantKey}/` : "/"; const { t } = useTranslation(); const noOptionsMenu = optionsCount === "0"; + React.useEffect(() => { + subscribe("ES_TENANT", (msg, data) => { + if (data) { + setTenant(data); + if (!JSON.parse(StorageService.get("TENANT_DATA"))?.name) { + StorageService.save("TENANT_DATA", JSON.stringify(data.tenantData)); + } + } + }); + }, []); + const handleHeaderClick = () => { if (noOptionsMenu) { subMenu.map((item, index) => { diff --git a/forms-flow-nav/src/sidenav/Sidebar.jsx b/forms-flow-nav/src/sidenav/Sidebar.jsx index d92df2c8..c5e9a4f8 100644 --- a/forms-flow-nav/src/sidenav/Sidebar.jsx +++ b/forms-flow-nav/src/sidenav/Sidebar.jsx @@ -210,13 +210,14 @@ const Sidebar = React.memo(({ props }) => { }, ] : [], ]} + subscribe={props.subscribe} /> )} {showApplications && isViewSubmissions && ENABLE_APPLICATIONS_MODULE && ( { ], }, ]} + subscribe={props.subscribe} /> )} {(isViewTask || isManageTask) && ENABLE_TASKS_MODULE && ( { matchExps: [createURLPathMatchExp("task", baseUrl)], }, ]} + subscribe={props.subscribe} /> )} {isViewDashboard && ENABLE_DASHBOARDS_MODULE && ( { ], } ]} + subscribe={props.subscribe} /> )} {isAdmin && ( { matchExps: [createURLPathMatchExp("admin/users", baseUrl)], }, ]} + subscribe={props.subscribe} /> )} From 3a53ac96b9cb91c25a3d847fb254d0482446546a Mon Sep 17 00:00:00 2001 From: Ajay krishna Date: Thu, 14 Nov 2024 13:50:56 +0530 Subject: [PATCH 2/4] props validation added --- forms-flow-nav/src/sidenav/MenuComponent.jsx | 31 +++++++++++++++++--- forms-flow-nav/src/sidenav/Sidebar.jsx | 8 +++++ 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/forms-flow-nav/src/sidenav/MenuComponent.jsx b/forms-flow-nav/src/sidenav/MenuComponent.jsx index b344a10b..8212bf85 100644 --- a/forms-flow-nav/src/sidenav/MenuComponent.jsx +++ b/forms-flow-nav/src/sidenav/MenuComponent.jsx @@ -6,8 +6,15 @@ import { ChevronIcon } from "@formsflow/components"; import { MULTITENANCY_ENABLED } from "../constants/constants"; import { useTranslation } from "react-i18next"; import { StorageService } from "@formsflow/service"; +import PropTypes from "prop-types"; -const MenuComponent = ({ eventKey, mainMenu, subMenu, optionsCount, subscribe }) => { +const MenuComponent = ({ + eventKey, + mainMenu, + subMenu, + optionsCount, + subscribe, +}) => { const [tenant, setTenant] = React.useState({}); const location = useLocation(); const history = useHistory(); @@ -16,7 +23,7 @@ const MenuComponent = ({ eventKey, mainMenu, subMenu, optionsCount, subscribe }) const { t } = useTranslation(); const noOptionsMenu = optionsCount === "0"; - React.useEffect(() => { + React.useEffect(() => { subscribe("ES_TENANT", (msg, data) => { if (data) { setTenant(data); @@ -35,8 +42,10 @@ const MenuComponent = ({ eventKey, mainMenu, subMenu, optionsCount, subscribe }) } }; - const isActive = subMenu.some((menu) => - menu.matchExps && menu.matchExps.some((exp) => exp.test(location.pathname)) + const isActive = subMenu.some( + (menu) => + menu.matchExps && + menu.matchExps.some((exp) => exp.test(location.pathname)) ); return ( @@ -85,4 +94,18 @@ const MenuComponent = ({ eventKey, mainMenu, subMenu, optionsCount, subscribe }) ); }; +MenuComponent.propTypes = { + eventKey: PropTypes.string.isRequired, + mainMenu: PropTypes.string.isRequired, + subMenu: PropTypes.arrayOf( + PropTypes.shape({ + path: PropTypes.string.isRequired, + name: PropTypes.string.isRequired, + matchExps: PropTypes.arrayOf(PropTypes.instanceOf(RegExp)), + }) + ).isRequired, + optionsCount: PropTypes.string.isRequired, + subscribe: PropTypes.func.isRequired, +}; + export default MenuComponent; diff --git a/forms-flow-nav/src/sidenav/Sidebar.jsx b/forms-flow-nav/src/sidenav/Sidebar.jsx index c5e9a4f8..cfd34e55 100644 --- a/forms-flow-nav/src/sidenav/Sidebar.jsx +++ b/forms-flow-nav/src/sidenav/Sidebar.jsx @@ -33,6 +33,7 @@ import { checkIntegrationEnabled } from "../services/integration"; import MenuComponent from "./MenuComponent"; // import Appname from "./formsflow.svg"; import { ApplicationLogo } from "@formsflow/components"; +import PropTypes from 'prop-types'; const Sidebar = React.memo(({ props }) => { const [tenantLogo, setTenantLogo] = React.useState(""); @@ -336,4 +337,11 @@ const Sidebar = React.memo(({ props }) => { ); }); +Sidebar.propTypes = { + props: PropTypes.shape({ + subscribe: PropTypes.func.isRequired, + getKcInstance: PropTypes.func.isRequired, + }).isRequired, +}; + export default Sidebar; From 8089820a8181c036b0e96f2767c43a67abe852c7 Mon Sep 17 00:00:00 2001 From: shuhaib s <95394061+shuhaib-aot@users.noreply.github.com> Date: Mon, 18 Nov 2024 13:01:58 +0530 Subject: [PATCH 3/4] Disabled revert button in history modal (#340) --- .../src/components/CustomComponents/HistoryModal.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/forms-flow-components/src/components/CustomComponents/HistoryModal.tsx b/forms-flow-components/src/components/CustomComponents/HistoryModal.tsx index dec640cd..2d7aad3c 100644 --- a/forms-flow-components/src/components/CustomComponents/HistoryModal.tsx +++ b/forms-flow-components/src/components/CustomComponents/HistoryModal.tsx @@ -23,6 +23,7 @@ interface HistoryModalProps { currentVersionId?:number|string; disabledData:{key:string,value:any} ignoreFirstEntryDisable?: boolean + disableAllRevertButton?: boolean } interface AllHistory { @@ -113,7 +114,7 @@ export const HistoryModal: React.FC = React.memo( allHistory, categoryType, historyCount, - currentVersionId, + disableAllRevertButton = false, ignoreFirstEntryDisable = false, disabledData = {key:"", value:""} // we can pass the key and its value based on that we can disable revert button eg: key:"processKey",value:"bpmn" if the data[key] == value it will disable }) => { @@ -232,7 +233,7 @@ export const HistoryModal: React.FC = React.memo( categoryType === "FORM" ? entry.changeLog.cloned_form_id : null; const process_id = categoryType === "WORKFLOW" ? entry.id : null; const isLastEntry = index === allHistory.length - 1; - const revertButtonDisabled = entry[disabledData.key] == disabledData.value || (!ignoreFirstEntryDisable && index === 0); + const revertButtonDisabled = disableAllRevertButton || entry[disabledData.key] == disabledData.value || (!ignoreFirstEntryDisable && index === 0); const fields = [ { id:1, heading: t("Last Edit On"), value: formatDate(entry.created) }, { id:2, heading: t("Last Edit By"), value: entry.createdBy }, From e4f16df29dbfc5cece1803c2da1732242eef6fe1 Mon Sep 17 00:00:00 2001 From: Bonymol-aot Date: Mon, 18 Nov 2024 20:10:32 -0800 Subject: [PATCH 4/4] FWF-3945: [Bugfix] Removed pagination import and fix --- .../src/components/roles/roles.tsx | 76 +++++++++---------- .../src/components/users/users.tsx | 1 - 2 files changed, 38 insertions(+), 39 deletions(-) diff --git a/forms-flow-admin/src/components/roles/roles.tsx b/forms-flow-admin/src/components/roles/roles.tsx index 5f62c3cd..8587ec56 100644 --- a/forms-flow-admin/src/components/roles/roles.tsx +++ b/forms-flow-admin/src/components/roles/roles.tsx @@ -3,7 +3,6 @@ import BootstrapTable from "react-bootstrap-table-next"; import "./roles.scss"; import { useParams } from "react-router-dom"; import { Translation, useTranslation } from "react-i18next"; -import paginationFactory from "react-bootstrap-table2-paginator"; import Form from "react-bootstrap/Form"; import Button from "react-bootstrap/Button"; import { fetchUsers } from "../../services/users"; @@ -27,6 +26,7 @@ import { import { DEFAULT_ROLES } from "../../constants"; import {removingTenantId} from "../../utils/utils.js"; +import { TableFooter } from "@formsflow/components"; const Roles = React.memo((props: any) => { const { t } = useTranslation(); const { tenantId } = useParams(); @@ -593,31 +593,23 @@ const Roles = React.memo((props: any) => { {(t) => t("results")} ); - const getpageList = () => { - const list = [ - { - text: "5", - value: 5, - }, - { - text: "25", - value: 25, - }, - { - text: "50", - value: 50, - }, - { - text: "100", - value: 100, - }, - { - text: t("All"), - value: roles.length, - }, - ]; - return list; + const getPageList = () => [ + { text: '5', value: 5 }, + { text: '25', value: 25 }, + { text: '50', value: 50 }, + { text: '100', value: 100 }, + { text: 'All', value: roles.length }, + ]; + const paginatedRoles = roles.slice( + (activePage - 1) * sizePerPage, + activePage * sizePerPage + ); + + const handlePageChange = (page: number) => { + setActivePage(page); }; + + const customDropUp = ({ options, currSizePerPage, onSizePerPageChange }) => { return ( { ); }; - const pagination = paginationFactory({ - showTotal: true, - align: "center", - className: "d-flex", - sizePerPageList: getpageList(), - page: activePage, - sizePerPage: sizePerPage, - paginationTotalRenderer: customTotal, - onPageChange: (page) => setActivePage(page), - sizePerPageRenderer: customDropUp, - }); + + const handleLimitChange = (newLimit: number) => { + setSizePerPage(newLimit); + setActivePage(1); + }; const columns = [ { @@ -773,11 +759,11 @@ const Roles = React.memo((props: any) => { {!props?.loading ? ( +
{ noDataIndication={noData} data-testid="admin-roles-table" /> + + + + + +
+
) : ( )} diff --git a/forms-flow-admin/src/components/users/users.tsx b/forms-flow-admin/src/components/users/users.tsx index 8690d4ca..22eaea8e 100644 --- a/forms-flow-admin/src/components/users/users.tsx +++ b/forms-flow-admin/src/components/users/users.tsx @@ -7,7 +7,6 @@ import Loading from "../loading"; import { AddUserRole, RemoveUserRole } from "../../services/users"; import OverlayTrigger from "react-bootstrap/OverlayTrigger"; import Popover from "react-bootstrap/Popover"; -import paginationFactory from "react-bootstrap-table2-paginator"; import DropdownButton from "react-bootstrap/DropdownButton"; import Dropdown from "react-bootstrap/Dropdown"; import { toast } from "react-toastify";