Skip to content

Commit

Permalink
MOSIP-36036: Sonar bugs, security hotspots, duplications for UI code
Browse files Browse the repository at this point in the history
Signed-off-by: Anil_Kumar_Majji <106086523+Anil-kumar-Majji@users.noreply.github.com>
  • Loading branch information
Anil-kumar-Majji committed Jan 7, 2025
1 parent 16e13ca commit 7274409
Show file tree
Hide file tree
Showing 43 changed files with 312 additions and 308 deletions.
16 changes: 10 additions & 6 deletions pmp-revamp-ui/src/nav/HeaderNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ function HeaderNav({ open, setOpen }) {
<div className={`flex items-center ${isLoginLanguageRTL ? "pr-5" : "pl-6"}`}>
<img src={process.env.PUBLIC_URL + '/mosip_icon.svg'} alt="Mosip Icon" className="w-8 h-8" />
<div id='header_hamburger_open_sidenav' className="p-9 cursor-pointer">
<img role='button' id=' hamburger_icon' src={hamburgerIcon} className="min-w-5 w-5 h-5" alt="" onClick={() => setOpen(!open)} tabIndex="0" onKeyDown={(e) => onPressEnterKey(e, () => setOpen(!open))} />
<button id='hamburger_close_icon' className="min-w-5 w-5 h-5" onClick={() => setOpen(!open)}>
<img alt="" src={hamburgerIcon} />
</button>
</div>
</div>
)}
Expand All @@ -54,7 +56,9 @@ function HeaderNav({ open, setOpen }) {
<img src={side_menu_title} alt="" className="w-32 h-10" />
</div>
<div id='header_hamburger_close_sidenav' className="cursor-pointer" >
<img role='button' id=' hamburger_icon' src={hamburgerIcon} className="min-w-5" alt="" onClick={() => setOpen(!open)} tabIndex="0" onKeyDown={(e) => onPressEnterKey(e, () => setOpen(!open))} />
<button id=' hamburger_open_icon' className="min-w-5" onClick={() => setOpen(!open)}>
<img src={hamburgerIcon} alt="" />
</button>
</div>
</div>
)}
Expand All @@ -70,14 +74,14 @@ function HeaderNav({ open, setOpen }) {
<img id='orgIcon' src={orgIcon} alt="" className="w-5 h-5" />
</div>

<h2 className={`text-xs font-bold text-gray-600 ${isLoginLanguageRTL ? "mr-1": "ml-1"}`}>{getUserProfile().orgName}</h2>
<h2 className={`text-xs font-bold text-gray-600 ${isLoginLanguageRTL ? "mr-1" : "ml-1"}`}>{getUserProfile().orgName}</h2>
</div>
<div role='button' onClick={openDropdown} className={`flex items-center ${isLoginLanguageRTL ? "mr-1" : "ml-1"}`} ref={dropdownRef} tabIndex="0" onKeyDown={(e)=>onPressEnterKey(e,openDropdown)}>
<div role='button' onClick={openDropdown} className={`flex items-center ${isLoginLanguageRTL ? "mr-1" : "ml-1"}`} ref={dropdownRef} tabIndex="0" onKeyDown={(e) => onPressEnterKey(e, openDropdown)}>
<button id='header_user_profile_icon_btn' className="relative flex rounded-full text-sm focus:outline-none focus:ring-2 focus:ring-white focus:ring-offset-2 focus:ring-transparent">
<img id='orgIcon' className="h-9 w-8 rounded-full" src={profileIcon} alt="" />
</button>
<h2 id='header_user_profile_title' className={`text-xs font-bold text-gray-600 cursor-pointer ${isLoginLanguageRTL ? "mr-1": "ml-1"}`}>{getUserProfile().userName}</h2>
<img id="profileDropDown" src={profileDropDown} alt="" className={`h-2 mt-[1%] cursor-pointer ${isLoginLanguageRTL ? "mr-2 ml-2" : "ml-2 mr-2"} ${isDropdownOpen ? "rotate-180 duration-500" : "duration-500"}`}/>
<h2 id='header_user_profile_title' className={`text-xs font-bold text-gray-600 cursor-pointer ${isLoginLanguageRTL ? "mr-1" : "ml-1"}`}>{getUserProfile().userName}</h2>
<img id="profileDropDown" src={profileDropDown} alt="" className={`h-2 mt-[1%] cursor-pointer ${isLoginLanguageRTL ? "mr-2 ml-2" : "ml-2 mr-2"} ${isDropdownOpen ? "rotate-180 duration-500" : "duration-500"}`} />

{isDropdownOpen && (
<div className={`absolute top-[3.1rem] ${isLoginLanguageRTL ? "origin-top-left" : "origin-top-right"} z-10 w-dynamic rounded-md bg-white py-1 shadow-md ring-1 ring-gray-50 focus:outline-none`}>
Expand Down
26 changes: 13 additions & 13 deletions pmp-revamp-ui/src/nav/SideNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,57 +120,57 @@ function SideNav({ open, policyRequiredPartnerTypes, partnerType }) {
<div className={`h-full ${open ? "absolute inset-y-14 min-w-[16rem]" : "absolute inset-y-14 w-[4.5rem]"}
flex-col duration-500`}>
<ul className={`pt-3 h-full space-y-5 bg-[#FCFCFC] shadow-[rgba(0,0,0,0.13)_5px_2px_8px_-2px]`}>
<li role="button" id='side_nav_home_icon' className="duration-700 cursor-pointer" onClick={() => showHome()} onKeyDown={(e) => { e.key === 'Enter' && showHome() }}>
<li role="listItem" id='side_nav_home_icon' className="duration-700 cursor-pointer" onClick={() => showHome()} onKeyDown={(e) => { e.key === 'Enter' && showHome() }}>
<SideNavMenuItem title={t('commons.home')} id='home' isExpanded={open} activeIcon={activeIcon} />
</li>
{!enablePartnerAdminMenu &&
<li role="button" id='side_nav_partner_certificate_icon' className="duration-700 cursor-pointer" onClick={() => showPartnerCertificatesList()} onKeyDown={(e) => { e.key === 'Enter' && showPartnerCertificatesList() }}>
<li role="listItem" id='side_nav_partner_certificate_icon' className="duration-700 cursor-pointer" onClick={() => showPartnerCertificatesList()} onKeyDown={(e) => { e.key === 'Enter' && showPartnerCertificatesList() }}>
<SideNavMenuItem title={t('dashboard.partnerCertificate')} id='partnerCertificate' isExpanded={open} activeIcon={activeIcon} />
</li>
}
{!enablePartnerAdminMenu && enablePoliciesMenu &&
<li role="button" id='side_nav_policies_icon' className="duration-700 cursor-pointer" onClick={() => showPolicies()} onKeyDown={(e) => { e.key === 'Enter' && showPolicies() }}>
<li role="listItem" id='side_nav_policies_icon' className="duration-700 cursor-pointer" onClick={() => showPolicies()} onKeyDown={(e) => { e.key === 'Enter' && showPolicies() }}>
<SideNavMenuItem title={t('dashboard.policies')} id='policies' isExpanded={open} activeIcon={activeIcon} />
</li>
}
{!enablePartnerAdminMenu && enableAuthenticationServicesMenu &&
<li role="button" id='side_nav_authentication_service_icon' className="duration-700 cursor-pointer" onClick={() => showAuthenticationServices()} onKeyDown={(e) => { e.key === 'Enter' && showAuthenticationServices() }}>
<li role="listItem" id='side_nav_authentication_service_icon' className="duration-700 cursor-pointer" onClick={() => showAuthenticationServices()} onKeyDown={(e) => { e.key === 'Enter' && showAuthenticationServices() }}>
<SideNavMenuItem title={t('dashboard.authenticationServices')} id='authenticationServices' isExpanded={open} activeIcon={activeIcon} />
</li>
}
{!enablePartnerAdminMenu && enableDeviceProviderServicesMenu &&
<li role="button" id='side_nav_device_provider_service_icon' className="duration-700 cursor-pointer" onClick={() => showDeviceProviderServices()} onKeyDown={(e) => { e.key === 'Enter' && showDeviceProviderServices() }}>
<li role="listItem" id='side_nav_device_provider_service_icon' className="duration-700 cursor-pointer" onClick={() => showDeviceProviderServices()} onKeyDown={(e) => { e.key === 'Enter' && showDeviceProviderServices() }}>
<SideNavMenuItem title={t('dashboard.deviceProviderServices')} id='deviceProviderServices' isExpanded={open} activeIcon={activeIcon} />
</li>
}
{!enablePartnerAdminMenu && enableFtmServicesMenu &&
<li role="button" id='side_nav_ftmchip_provider_service_icon' className="duration-700 cursor-pointer" onClick={() => showFtmServices()} onKeyDown={(e) => { e.key === 'Enter' && showFtmServices() }}>
<li role="listItem" id='side_nav_ftmchip_provider_service_icon' className="duration-700 cursor-pointer" onClick={() => showFtmServices()} onKeyDown={(e) => { e.key === 'Enter' && showFtmServices() }}>
<SideNavMenuItem title={t('dashboard.ftmChipProviderServices')} id='ftmChipProviderServices' isExpanded={open} activeIcon={activeIcon} />
</li>
}
{enablePartnerAdminMenu && (
<>
<li role="button" id='side_nav_rootOfTrustCertificate_service_icon' className="duration-700 cursor-pointer" onClick={() => showRootOfTrustCertificate()} onKeyDown={(e) => { e.key === 'Enter' && showRootOfTrustCertificate() }}>
<li role="listItem" id='side_nav_rootOfTrustCertificate_service_icon' className="duration-700 cursor-pointer" onClick={() => showRootOfTrustCertificate()} onKeyDown={(e) => { e.key === 'Enter' && showRootOfTrustCertificate() }}>
<SideNavMenuItem title={t('dashboard.rootOfTrustCertificate')} id='rootOfTrustCertificate' isExpanded={open} activeIcon={activeIcon} />
</li>
<li role="button" id='side_nav_partner_icon' className="duration-700 cursor-pointer" onClick={() => showPartner()} onKeyDown={(e) => { e.key === 'Enter' && showPartner() }}>
<li role="listItem" id='side_nav_partner_icon' className="duration-700 cursor-pointer" onClick={() => showPartner()} onKeyDown={(e) => { e.key === 'Enter' && showPartner() }}>
<SideNavMenuItem title={t('dashboard.partner')} id='partner' isExpanded={open} activeIcon={activeIcon} />
</li>
{enablePolicyManagerMenu && (
<li role="button" id='side_nav_policy_icon' className="duration-700 cursor-pointer" onClick={() => showAdminPolicies()} onKeyDown={(e) => { e.key === 'Enter' && showAdminPolicies() }}>
<li role="listItem" id='side_nav_policy_icon' className="duration-700 cursor-pointer" onClick={() => showAdminPolicies()} onKeyDown={(e) => { e.key === 'Enter' && showAdminPolicies() }}>
<SideNavMenuItem title={t('dashboard.policies')} id='admin_policies' isExpanded={open} activeIcon={activeIcon} />
</li>
)}
<li role="button" id='side_nav_partnerPolicyMapping_icon' className={`duration-700 cursor-pointer ${isLoginLanguageRTL ? 'pl-1' : 'pr-1'}`} onClick={() => showPartnerPolicyMapping()} onKeyDown={(e) => { e.key === 'Enter' && showPartnerPolicyMapping() }}>
<li role="listItem" id='side_nav_partnerPolicyMapping_icon' className={`duration-700 cursor-pointer ${isLoginLanguageRTL ? 'pl-1' : 'pr-1'}`} onClick={() => showPartnerPolicyMapping()} onKeyDown={(e) => { e.key === 'Enter' && showPartnerPolicyMapping() }}>
<SideNavMenuItem title={t('dashboard.partnerPolicyMapping')} id='partnerPolicyMapping' isExpanded={open} activeIcon={activeIcon} />
</li>
<li role="button" id='side_nav_sbiDeviceDetails_icon' className="duration-700 cursor-pointer" onClick={() => showSbiDeviceDetails()} onKeyDown={(e) => { e.key === 'Enter' && showSbiDeviceDetails() }}>
<li role="listItem" id='side_nav_sbiDeviceDetails_icon' className="duration-700 cursor-pointer" onClick={() => showSbiDeviceDetails()} onKeyDown={(e) => { e.key === 'Enter' && showSbiDeviceDetails() }}>
<SideNavMenuItem title={t('dashboard.sbiDevice')} id='deviceProviderServices' isExpanded={open} activeIcon={activeIcon} />
</li>
<li role="button" id='side_nav_ftmDetails_icon' className="duration-700 cursor-pointer" onClick={() => showAdminFtmDetails()} onKeyDown={(e) => { e.key === 'Enter' && showAdminFtmDetails() }}>
<li role="listItem" id='side_nav_ftmDetails_icon' className="duration-700 cursor-pointer" onClick={() => showAdminFtmDetails()} onKeyDown={(e) => { e.key === 'Enter' && showAdminFtmDetails() }}>
<SideNavMenuItem title={t('dashboard.ftmChip')} id='ftmChipProviderServices' isExpanded={open} activeIcon={activeIcon} />
</li>
<li role="button" id='side_nav_authenticationServices_icon' className="duration-700 cursor-pointer" onClick={() => showAdminAuthenticationServices()} onKeyDown={(e) => { e.key === 'Enter' && showAdminAuthenticationServices() }}>
<li role="listItem" id='side_nav_authenticationServices_icon' className="duration-700 cursor-pointer" onClick={() => showAdminAuthenticationServices()} onKeyDown={(e) => { e.key === 'Enter' && showAdminAuthenticationServices() }}>
<SideNavMenuItem title={t('dashboard.authenticationServices')} id='authenticationServices' isExpanded={open} activeIcon={activeIcon} />
</li>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,9 @@ function AdminApiKeysList() {
</td>
<td className="text-center">
<div ref={(el) => (submenuRef.current[index] = el)}>
<p role='button' id={"api_key_list_action_view" + (index + 1)} onClick={() => setActionId(index === actionId ? null : index)} className={`font-semibold mb-0.5 text-[#191919] cursor-pointer text-center`}
tabIndex="0" onKeyDown={(e) => onPressEnterKey(e, () => setActionId(index === actionId ? null : index))}>
<button id={"api_key_list_action_view" + (index + 1)} onClick={() => setActionId(index === actionId ? null : index)} className={`font-semibold mb-0.5 text-[#191919] cursor-pointer text-center`}>
...
</p>
</button>
{actionId === index && (
<div className={`absolute w-[7%] z-50 bg-white text-xs font-semibold rounded-lg shadow-md border min-w-fit ${isLoginLanguageRTL ? "left-10 text-right" : "right-11 text-left"}`}>
<div role='button' className="flex justify-between hover:bg-gray-100" onClick={() => viewApiKeyRequestDetails(apiKey)} tabIndex="0" onKeyDown={(e) => onPressEnterKey(e, () => viewApiKeyRequestDetails(apiKey))}>
Expand Down
Loading

0 comments on commit 7274409

Please sign in to comment.