From e8ccfeafe13bd38ec2e0d4aa2ebdd5679cdf6595 Mon Sep 17 00:00:00 2001 From: jinapurapu <65002498+jinapurapu@users.noreply.github.com> Date: Fri, 13 May 2022 12:10:00 -0700 Subject: [PATCH] Fixed disabled Change Password button and added clarifying text (#1973) --- .../src/screens/Console/Account/Account.tsx | 15 ++++-- .../Console/Account/ChangePasswordModal.tsx | 49 +++++++++++++++++-- 2 files changed, 57 insertions(+), 7 deletions(-) diff --git a/portal-ui/src/screens/Console/Account/Account.tsx b/portal-ui/src/screens/Console/Account/Account.tsx index 722d4a564..e65ee35e2 100644 --- a/portal-ui/src/screens/Console/Account/Account.tsx +++ b/portal-ui/src/screens/Console/Account/Account.tsx @@ -55,6 +55,7 @@ import RBIconButton from "../Buckets/BucketDetails/SummaryItems/RBIconButton"; import { selectSAs } from "../Configurations/utils"; import DeleteMultipleServiceAccounts from "../Users/DeleteMultipleServiceAccounts"; import ServiceAccountPolicy from "./ServiceAccountPolicy"; +import { AppState } from "../../../store"; const DeleteServiceAccount = withSuspense( React.lazy(() => import("./DeleteServiceAccount")) @@ -77,12 +78,14 @@ interface IServiceAccountsProps { classes: any; history: any; displayErrorMessage: typeof setErrorSnackMessage; + features: any; } const Account = ({ classes, displayErrorMessage, history, + features, }: IServiceAccountsProps) => { const [records, setRecords] = useState([]); const [loading, setLoading] = useState(false); @@ -97,10 +100,12 @@ const Account = ({ const [deleteMultipleOpen, setDeleteMultipleOpen] = useState(false); const [policyOpen, setPolicyOpen] = useState(false); + const userIDP = (features && features.includes("external-idp")) || false; + useEffect(() => { fetchRecords(); }, []); - + useEffect(() => { if (loading) { api @@ -240,7 +245,7 @@ const Account = ({ icon={} color={"primary"} variant={"outlined"} - disabled={selectedSAs.length === 0} + disabled={userIDP} /> ({ + features: state.console.session.features, +}); + +const connector = connect(mapState, { displayErrorMessage: setErrorSnackMessage, }); diff --git a/portal-ui/src/screens/Console/Account/ChangePasswordModal.tsx b/portal-ui/src/screens/Console/Account/ChangePasswordModal.tsx index 5a5826686..c5c9d3f8c 100644 --- a/portal-ui/src/screens/Console/Account/ChangePasswordModal.tsx +++ b/portal-ui/src/screens/Console/Account/ChangePasswordModal.tsx @@ -34,6 +34,9 @@ import { setModalErrorSnackMessage } from "../../../actions"; import { ErrorResponseHandler } from "../../../common/types"; import api from "../../../common/api"; import { ChangePasswordIcon } from "../../../icons"; +import { decodeFileName } from "../../../common/utils"; +import RemoveRedEyeIcon from "@mui/icons-material/RemoveRedEye"; +import VisibilityOffIcon from "@mui/icons-material/VisibilityOff"; const styles = (theme: Theme) => createStyles({ @@ -60,6 +63,11 @@ const ChangePassword = ({ const [newPassword, setNewPassword] = useState(""); const [reNewPassword, setReNewPassword] = useState(""); const [loading, setLoading] = useState(false); + const [showPassword, setShowPassword] = useState(false); + + const userLoggedIn = decodeFileName( + localStorage.getItem("userLoggedIn") || "" + ); const changePassword = (event: React.FormEvent) => { event.preventDefault(); @@ -110,7 +118,7 @@ const ChangePassword = ({ return open ? ( { setNewPassword(""); @@ -120,6 +128,9 @@ const ChangePassword = ({ }} titleIcon={} > +
+ This will change your Console password. Please note your new password down, as it will be required to log into Console after this session. +
+ setShowPassword(!showPassword) + } + overlayIcon={ + showPassword ? ( + + ) : ( + + ) + } /> @@ -149,8 +170,18 @@ const ChangePassword = ({ setNewPassword(event.target.value); }} label="New Password" - type="password" + type={showPassword ? "text" : "password"} value={newPassword} + overlayAction={() => + setShowPassword(!showPassword) + } + overlayIcon={ + showPassword ? ( + + ) : ( + + ) + } /> @@ -161,8 +192,18 @@ const ChangePassword = ({ setReNewPassword(event.target.value); }} label="Type New Password Again" - type="password" + type={showPassword ? "text" : "password"} value={reNewPassword} + overlayAction={() => + setShowPassword(!showPassword) + } + overlayIcon={ + showPassword ? ( + + ) : ( + + ) + } />