-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #233 from fahad-aot/feature/FWF-3435-permission-ma…
…trix-admin Feature/fwf-435 permission matrix Navbar & Admin module
- Loading branch information
Showing
5 changed files
with
355 additions
and
245 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
forms-flow-admin/src/components/AccessDenied/AccessDenied.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions
12
forms-flow-admin/src/components/AccessDenied/accessDenied.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.access-denied-text { | ||
font-family: Arial, Helvetica, sans-serif; | ||
font-size: 2rem; | ||
color: var(--ff-black); | ||
opacity: 1; | ||
} | ||
.access-denied{ | ||
font-family: Arial, Helvetica, sans-serif; | ||
font-size: 1rem; | ||
color: var(--ff-black); | ||
opacity: 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React from "react"; | ||
import AccessDeniedIcon from "./AccessDenied.svg"; | ||
import './accessDenied.scss'; | ||
import { useTranslation } from "react-i18next"; | ||
import { BASE_ROUTE } from "../../constants/index"; | ||
import { useHistory } from "react-router-dom"; | ||
|
||
|
||
const AccessDenied = ({ userRoles }) => { | ||
const { t } = useTranslation(); | ||
const history = useHistory(); | ||
|
||
const handleLogout = () => { | ||
const kcInstance = kcServiceInstance(); | ||
kcInstance.userLogout(); | ||
}; | ||
|
||
const handleReturn = () => { | ||
history.push(BASE_ROUTE); | ||
}; | ||
|
||
const showReturnToLogin = userRoles?.length === 0; | ||
const showReturnToHome = userRoles?.length > 0; | ||
|
||
return ( | ||
<div className="d-flex flex-column align-items-center text-center" data-testid="access-denied-component"> | ||
<img src={AccessDeniedIcon} alt="Access Denied Icon" className="mb-4 mt-2" /> | ||
<h1 className="access-denied-text" data-testid="access-denied-title">{t("Access Denied")}</h1> | ||
<span className="access-denied" data-testid="access-denied-message">{t("You don't have permission to access this page.")}</span> | ||
<span className="access-denied" data-testid="access-denied-submessage">{t("Please contact your administrator or try again later.")}</span> | ||
{showReturnToLogin && ( | ||
<button className="btn btn-primary me-1 mt-4" onClick={handleLogout} data-testid="return-to-login-button"> | ||
{t("Return to login")} | ||
</button> | ||
)} | ||
{showReturnToHome && ( | ||
<button className="btn btn-primary me-1 mt-4" onClick={handleReturn} data-testid="return-to-home-button"> | ||
{t("Return to home")} | ||
</button> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default AccessDenied; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.