Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ES-411] Implementation of cancel confirmation popup in consent page #451

Merged
merged 3 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions oidc-ui/public/images/warning_message_icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion oidc-ui/public/locales/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@
"Manage-Authentication": "السماح بالوصول لإدارة المصادقة",
"Manage-Service-Requests": "السماح بالوصول لإدارة طلبات الخدمة",
"Manage-Credentials": "السماح بالوصول لإدارة الاعتمادات",
"individual_id": "مُعرّف UIN/VID المستخدم في تسجيل الدخول"
"individual_id": "مُعرّف UIN/VID المستخدم في تسجيل الدخول",
"cancelpopup": {
"confirm_header": "يرجى تأكيد",
"confirm_text": "هل أنت متأكد أنك تريد إيقاف عملية تسجيل الدخول؟",
"stay_btn": "يقضي",
"discontinue_btn": "توقف"
}
},
"l1Biometrics": {
"scan_and_verify": "المسح والتحقق",
Expand Down
8 changes: 7 additions & 1 deletion oidc-ui/public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@
"Manage-Authentication": "Allow access to manage Authentication",
"Manage-Service-Requests": "Allow access to manage Service Requests",
"Manage-Credentials": "Allow access to manage Credentials",
"individual_id": "UIN/VID used in login"
"individual_id": "UIN/VID used in login",
"cancelpopup": {
"confirm_header": "Please confirm",
"confirm_text": "Are you sure you want to discontinue the login process?",
"stay_btn": "Stay",
"discontinue_btn": "Discontinue"
}
},
"l1Biometrics": {
"scan_and_verify": "Scan and Verify",
Expand Down
34 changes: 34 additions & 0 deletions oidc-ui/src/common/ModalPopup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from "react";

const ModalPopup = ({alertIcon, header, body, footer}) => {
return (
<div
class="relative z-10"
aria-labelledby="modal-title"
role="dialog"
aria-modal="true"
>
<div class="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity"></div>
gsasikumar marked this conversation as resolved.
Show resolved Hide resolved
<div class="fixed inset-0 z-10 w-screen overflow-y-auto">
<div class="flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0">
<div class="relative transform overflow-hidden rounded-[20px] bg-white text-left shadow-xl transition-all duration-300 ease-out sm:my-8 sm:w-full sm:max-w-lg">
{alertIcon && <div className="flex flex-shrink-0 items-center justify-center rounded-t-md p-4 my-4">
<img src={alertIcon} />
</div>}
{header && <div className="relative text-center text-dark font-semibold text-xl text-[#2B3840]">
{header}
</div>}
{body && <div className="relative px-4 py-3 text-center">
<p className="text-base text-[#707070]">{body}</p>
</div>}
{footer && <div className="flex flex-shrink-0 flex-wrap items-center justify-center rounded-b-md p-4 mb-5 mt-3">
{footer}
</div>}
</div>
</div>
</div>
</div>
);
};

export default ModalPopup;
38 changes: 37 additions & 1 deletion oidc-ui/src/components/Consent.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { buttonTypes, configurationKeys } from "../constants/clientConstants";
import { LoadingStates, LoadingStates as states } from "../constants/states";
import FormAction from "./FormAction";
import langConfigService from "./../services/langConfigService";
import ModalPopup from "../common/ModalPopup";

export default function Consent({
authService,
Expand Down Expand Up @@ -42,6 +43,7 @@ export default function Consent({
const [claimsScopes, setClaimsScopes] = useState([]);
const [langMap, setLangMap] = useState("");
const [timeLeft, setTimeLeft] = useState(null);
const [cancelPopup, setCancelPopup] = useState(false);

const hasAllElement = (mainArray, subArray) =>
subArray.every((ele) => mainArray.includes(ele));
Expand Down Expand Up @@ -255,8 +257,8 @@ export default function Consent({
};

const handleCancel = (e) => {
setCancelPopup(true);
e.preventDefault();
onError("consent_request_rejected", t("consent_request_rejected"));
gsasikumar marked this conversation as resolved.
Show resolved Hide resolved
};

//Handle Login API Integration here
Expand Down Expand Up @@ -367,9 +369,43 @@ export default function Consent({
);
}

// buttons with it's functionalities for the modalpopup footer
const handleStay = () => {
setCancelPopup(false);
};

const handleDiscontinue = () => {
setCancelPopup(false);
window.location.replace(openIDConnectService.getRedirectUri());
};

var footerButtons = (
<>
<div className="mx-5 w-full">
<div className="mb-1">
<FormAction
type={buttonTypes.button}
text={t("cancelpopup.stay_btn")}
handleClick={handleStay}
id="stay"
/>
</div>
<div className="mt-1">
<FormAction
type={buttonTypes.cancel}
text={t("cancelpopup.discontinue_btn")}
handleClick={handleDiscontinue}
id="discontinue"
/>
</div>
</div>
</>
);

return (
authTime && clientName && claimsScopes.length > 0 &&
<div className="container flex mx-auto sm:flex-row flex-col">
{cancelPopup && <ModalPopup alertIcon="images/warning_message_icon.svg" header={t("cancelpopup.confirm_header")} body={t("cancelpopup.confirm_text")} footer={footerButtons}/>}
<div className="flex justify-center m-10 lg:mt-20 mb:mt-0 lg:w-1/2 md:w-1/2 md:block sm:w-1/2 sm:block hidden w-5/6 mt-20 mb-10 md:mb-0">
<div>
<img
Expand Down