Skip to content

Commit

Permalink
resolved tab event issues and added esc event for popups (#1048)
Browse files Browse the repository at this point in the history
Signed-off-by: MadhuMosip <[email protected]>
  • Loading branch information
MadhuMosip authored Dec 20, 2024
1 parent 5c9cb0c commit 763ea46
Show file tree
Hide file tree
Showing 20 changed files with 160 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import React, { useState, useRef, useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import { getUserProfile } from '../../../services/UserProfileService';
import { isLangRTL, handleMouseClickForDropdown, resetPageNumber, onClickApplyFilter, setPageNumberAndPageSize,
getPartnerManagerUrl, handleServiceErrors, onResetFilter, formatDate, bgOfStatus, getStatusCode, onPressEnterKey, createRequest
getPartnerManagerUrl, handleServiceErrors, onResetFilter, formatDate, bgOfStatus, getStatusCode, onPressEnterKey, createRequest,
escapeKeyHandler
} from '../../../utils/AppUtils';
import ErrorMessage from '../../common/ErrorMessage';
import LoadingIcon from '../../common/LoadingIcon';
Expand Down Expand Up @@ -161,6 +162,7 @@ function AdminApiKeysList () {
const closeDeactivatePopup = () => {
setActionId(-1);
setShowDeactivatePopup(false);
document.body.style.overflow = "auto";
};

const deactivateApiKey = (selectedApiKeyData) => {
Expand Down Expand Up @@ -197,6 +199,10 @@ function AdminApiKeysList () {
setErrorMsg("");
};

useEffect(() => {
escapeKeyHandler(closeDeactivatePopup)
}, [showDeactivatePopup]);

const styles = {
loadingDiv: "!py-[20%]",
outerDiv: "!bg-opacity-[16%]"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { isLangRTL, handleMouseClickForDropdown, resetPageNumber, onClickApplyFi
getOidcClientDetails,
createRequest,
populateClientNames,
getClientNameLangMap
getClientNameLangMap,
escapeKeyHandler
} from '../../../utils/AppUtils';
import ErrorMessage from '../../common/ErrorMessage';
import LoadingIcon from '../../common/LoadingIcon';
Expand Down Expand Up @@ -218,6 +219,7 @@ function AdminOidcClientsList () {
const closeDeactivatePopup = () => {
setActionId(-1);
setShowDeactivatePopup(false);
document.body.style.overflow = "auto";
};

const cancelErrorMsg = () => {
Expand All @@ -229,6 +231,14 @@ function AdminOidcClientsList () {
outerDiv: "!bg-opacity-[16%]"
}

useEffect(() => {
if(showDeactivatePopup){
escapeKeyHandler(closeDeactivatePopup);
}else if(showClientIdPopup){
escapeKeyHandler(() => setShowClientIdPopup(false));
}
}, [showDeactivatePopup, showClientIdPopup]);

return (
<div className={`mt-2 w-[100%] ${isLoginLanguageRTL ? "mr-28 ml-5" : "ml-28 mr-5"} font-inter overflow-x-scroll`}>
{ !dataLoaded && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ function ViewAdminOidcClientDetails() {
</div>

<div id="oidc_client_details_copy_id" className={`${oidcClientDetails.status === "ACTIVE" ? 'bg-[#F0F5FF] border-[#BED3FF] cursor-pointer hover:shadow-md' : 'bg-gray-200 border-gray-400'} border h-[4%] w-[15%] max-[450px]:w-[40%] max-[800px]:w-[25%] ${isLoginLanguageRTL ? "pr-[3%] pl-[1.5%]" : "pl-[3%] pr-[1%]"} py-[0.5%] rounded-md text-right`}
tabIndex="0" onKeyPress={(e) => onPressEnterKey(e, copyClientId(selectedClientData, selectedClientData.clientId, setCopied))}>
tabIndex="0" onKeyPress={(e) => onPressEnterKey(e, () => copyClientId(selectedClientData, selectedClientData.clientId, setCopied))}>
<p className="text-sm font-semibold text-[#333333]">{t('viewOidcClientDetails.oidcClientId')}</p>
<div className="flex space-x-1 items-center">
<p className={`text-md font-bold ${selectedClientData.status === "ACTIVE" ? 'text-[#1447B2]' : 'text-gray-400'} truncate`}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import LoadingIcon from '../../common/LoadingIcon';
import EmptyList from '../../common/EmptyList';
import Title from '../../common/Title.js';
import DeviceProviderServicesTab from './DeviceProviderServicesTab.js';
import { handleMouseClickForDropdown, isLangRTL, onClickApplyFilter, setPageNumberAndPageSize, onResetFilter, bgOfStatus, getStatusCode, onPressEnterKey, formatDate, resetPageNumber, getPartnerManagerUrl, handleServiceErrors, createRequest, getApproveRejectStatus, updateActiveState } from '../../../utils/AppUtils';
import { handleMouseClickForDropdown, isLangRTL, onClickApplyFilter, setPageNumberAndPageSize, onResetFilter, bgOfStatus, getStatusCode, onPressEnterKey, formatDate, resetPageNumber, getPartnerManagerUrl, handleServiceErrors, createRequest, getApproveRejectStatus, updateActiveState, escapeKeyHandler } from '../../../utils/AppUtils';
import { HttpService } from '../../../services/HttpService.js';
import AdminDeviceDetailsFilter from './AdminDeviceDetailsFilter.js';
import FilterButtons from '../../common/FilterButtons.js';
Expand Down Expand Up @@ -174,6 +174,7 @@ function AdminDevicesList() {
const closeApproveRejectPopup = () => {
setActionId(-1);
setShowDeviceDetailApproveRejectPopup(false);
document.body.style.overflow = "auto";
};

const deactivateDevice = (selectedDevice) => {
Expand Down Expand Up @@ -204,6 +205,7 @@ function AdminDevicesList() {
const closeDeactivatePopup = () => {
setActionId(-1);
setShowDeactivatePopup(false);
document.body.style.overflow = "auto";
};

const sortAscOrder = (header) => {
Expand Down Expand Up @@ -240,6 +242,14 @@ function AdminDevicesList() {
loadingDiv: "!py-[20%]"
};

useEffect(() => {
if(showDeviceDetailApproveRejectPopup){
escapeKeyHandler(closeApproveRejectPopup);
}else if(showDeactivatePopup){
escapeKeyHandler(closeDeactivatePopup);
}
}, [showDeviceDetailApproveRejectPopup, showDeactivatePopup]);

return (
<div className={`mt-2 w-[100%] ${isLoginLanguageRTL ? "mr-28 ml-5" : "ml-28 mr-5"} font-inter overflow-x-scroll`}>
{!dataLoaded && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import disableDeactivateIcon from "../../../svg/disable_deactivate_icon.svg";
import FilterButtons from '../../common/FilterButtons.js';
import SortingIcon from '../../common/SortingIcon.js';
import Pagination from '../../common/Pagination.js';
import { bgOfStatus, formatDate, getPartnerManagerUrl, getApproveRejectStatus, getStatusCode, handleMouseClickForDropdown, handleServiceErrors, isLangRTL, onClickApplyFilter, onPressEnterKey, onResetFilter, resetPageNumber, setPageNumberAndPageSize, updateActiveState, createRequest } from '../../../utils/AppUtils.js';
import { bgOfStatus, formatDate, getPartnerManagerUrl, getApproveRejectStatus, getStatusCode, handleMouseClickForDropdown, handleServiceErrors, isLangRTL, onClickApplyFilter, onPressEnterKey, onResetFilter, resetPageNumber, setPageNumberAndPageSize, updateActiveState, createRequest, escapeKeyHandler } from '../../../utils/AppUtils.js';
import DeviceProviderServicesTab from './DeviceProviderServicesTab.js';
import AdminSbiListFilter from './AdminSbiListFilter.js';
import { HttpService } from '../../../services/HttpService.js';
Expand Down Expand Up @@ -191,6 +191,7 @@ function AdminSbiList() {
const closeApproveRejectPopup = () => {
setActionId(-1);
setShowSbiApproveRejectPopUp(false);
document.body.style.overflow = "auto";
};

const deactivateSbi = (selectedSbi) => {
Expand Down Expand Up @@ -220,6 +221,7 @@ function AdminSbiList() {
const closeDeactivatePopup = () => {
setActionId(-1);
setShowDeactivatePopup(false);
document.body.style.overflow = "auto";
};

const cancelErrorMsg = () => {
Expand All @@ -230,6 +232,14 @@ function AdminSbiList() {
loadingDiv: "!py-[20%]",
}

useEffect(() => {
if(showSbiApproveRejectPopUp){
escapeKeyHandler(closeApproveRejectPopup);
}else if(showDeactivatePopup){
escapeKeyHandler(closeDeactivatePopup);
}
}, [showSbiApproveRejectPopUp, showDeactivatePopup]);

return (
<div className={`mt-2 w-[100%] ${isLoginLanguageRTL ? "mr-28 ml-5" : "ml-28 mr-5"} font-inter overflow-x-scroll`}>
{!dataLoaded && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import approveRejectIcon from "../../../svg/approve_reject_icon.svg";
import disabledApproveRejectIcon from "../../../svg/approve_reject_disabled_icon.svg";
import EmptyList from '../../common/EmptyList';
import AdminFtmListFilter from './AdminFtmListFilter.js';
import { handleMouseClickForDropdown, isLangRTL, onClickApplyFilter, setPageNumberAndPageSize, onResetFilter, bgOfStatus, getStatusCode, onPressEnterKey, formatDate, resetPageNumber, getPartnerManagerUrl, handleServiceErrors, createRequest, getApproveRejectStatus, updateActiveState } from '../../../utils/AppUtils';
import { handleMouseClickForDropdown, isLangRTL, onClickApplyFilter, setPageNumberAndPageSize, onResetFilter, bgOfStatus, getStatusCode, onPressEnterKey, formatDate, resetPageNumber, getPartnerManagerUrl, handleServiceErrors, createRequest, getApproveRejectStatus, updateActiveState, escapeKeyHandler } from '../../../utils/AppUtils';
import ApproveRejectPopup from '../../common/ApproveRejectPopup.js';
import DeactivatePopup from '../../common/DeactivatePopup.js';

Expand Down Expand Up @@ -168,6 +168,7 @@ function AdminFtmList() {
const closeApproveRejectPopup = () => {
setActionId(-1);
setShowFtmApproveRejectPopup(false);
document.body.style.overflow = "auto";
};

const deactivateFtmDetails = (ftm) => {
Expand Down Expand Up @@ -197,6 +198,7 @@ function AdminFtmList() {
const closeDeactivatePopup = () => {
setActionId(-1);
setShowDeactivatePopup(false);
document.body.style.overflow = "auto";
};

const sortAscOrder = (header) => {
Expand Down Expand Up @@ -224,6 +226,14 @@ function AdminFtmList() {
loadingDiv: "!py-[20%]"
};

useEffect(() => {
if(showFtmApproveRejectPopup){
escapeKeyHandler(closeApproveRejectPopup);
}else if(showDeactivatePopup){
escapeKeyHandler(closeDeactivatePopup);
}
}, [showFtmApproveRejectPopup, showDeactivatePopup]);

return (
<div className={`mt-2 w-[100%] ${isLoginLanguageRTL ? "mr-28 ml-5" : "ml-28 mr-5"} font-inter overflow-x-scroll`}>
{!dataLoaded && (
Expand Down
7 changes: 6 additions & 1 deletion pmp-revamp-ui/src/pages/admin/partners/PartnersList.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useState, useEffect, useRef } from "react";
import { useNavigate } from "react-router-dom";
import { useTranslation } from "react-i18next";
import { getUserProfile } from "../../../services/UserProfileService";
import { createRequest, isLangRTL, onPressEnterKey } from "../../../utils/AppUtils";
import { createRequest, escapeKeyHandler, isLangRTL, onPressEnterKey } from "../../../utils/AppUtils";
import {
getPartnerManagerUrl,
handleServiceErrors,
Expand Down Expand Up @@ -197,6 +197,7 @@ function PartnersList() {
const closeDeactivatePopup = () => {
setViewPartnersId(-1);
setShowDeactivatePopup(false);
document.body.style.overflow = "auto";
}

const onClickConfirmDeactivate = (deactivationResponse, selectedPartnerData) => {
Expand All @@ -212,6 +213,10 @@ function PartnersList() {
}
};

useEffect(() => {
escapeKeyHandler(closeDeactivatePopup);
}, [showDeactivatePopup]);

const styles = {
loadingDiv: "!py-[20%]"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,12 @@ function CreatePolicyGroup() {
</div>
<div className="border bg-medium-gray" />
<div className="flex flex-row max-[450px]:flex-col px-[3%] py-9 justify-between max-[450px]:space-y-2">
<button id="createPolicy_clear_form" onClick={() => clearForm()} className={`w-40 h-10 mr-3 border-[#1447B2] ${isLoginLanguageRTL ? "mr-2" : "ml-2"} border rounded-md bg-white text-tory-blue text-sm font-semibold`} tabIndex="0" onKeyPress={(e) => onPressEnterKey(e, clearForm())}>
<button id="createPolicy_clear_form" onClick={() => clearForm()} className={`w-40 h-10 mr-3 border-[#1447B2] ${isLoginLanguageRTL ? "mr-2" : "ml-2"} border rounded-md bg-white text-tory-blue text-sm font-semibold`} tabIndex="0" onKeyDown={(e) => onPressEnterKey(e, () => clearForm())}>
{t('requestPolicy.clearForm')}
</button>
<div className={`flex flex-row max-[450px]:flex-col space-x-3 max-[450px]:space-x-0 max-[450px]:space-y-2 w-full md:w-auto justify-end`}>
<button id="createPolicy_cancel_btn" onClick={() => clickOnCancel()} className={`${isLoginLanguageRTL ? "ml-2" : "mr-2"} w-11/12 md:w-40 h-10 border-[#1447B2] border rounded-md bg-white text-tory-blue text-sm font-semibold`}>{t('requestPolicy.cancel')}</button>
<button id="createPolicy_submit_btn" disabled={!isFormValid()} onClick={() => clickOnSubmit()} className={`${isLoginLanguageRTL ? "ml-2" : "mr-2"} w-11/12 md:w-40 h-10 border-[#1447B2] border rounded-md text-sm font-semibold ${isFormValid() ? 'bg-tory-blue text-white' : 'border-[#A5A5A5] bg-[#A5A5A5] text-white cursor-not-allowed'}`} tabIndex="0" onKeyPress={(e) => onPressEnterKey(e, clearForm())}>
<button id="createPolicy_submit_btn" disabled={!isFormValid()} onClick={() => clickOnSubmit()} className={`${isLoginLanguageRTL ? "ml-2" : "mr-2"} w-11/12 md:w-40 h-10 border-[#1447B2] border rounded-md text-sm font-semibold ${isFormValid() ? 'bg-tory-blue text-white' : 'border-[#A5A5A5] bg-[#A5A5A5] text-white cursor-not-allowed'}`} tabIndex="0" onKeyDown={(e) => onPressEnterKey(e, () =>clearForm())}>
{t('requestPolicy.submit')}
</button>
</div>
Expand Down
Loading

0 comments on commit 763ea46

Please sign in to comment.