Skip to content

Commit e8ccfea

Browse files
authored
Fixed disabled Change Password button and added clarifying text (#1973)
1 parent 6c892f0 commit e8ccfea

File tree

2 files changed

+57
-7
lines changed

2 files changed

+57
-7
lines changed

portal-ui/src/screens/Console/Account/Account.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ import RBIconButton from "../Buckets/BucketDetails/SummaryItems/RBIconButton";
5555
import { selectSAs } from "../Configurations/utils";
5656
import DeleteMultipleServiceAccounts from "../Users/DeleteMultipleServiceAccounts";
5757
import ServiceAccountPolicy from "./ServiceAccountPolicy";
58+
import { AppState } from "../../../store";
5859

5960
const DeleteServiceAccount = withSuspense(
6061
React.lazy(() => import("./DeleteServiceAccount"))
@@ -77,12 +78,14 @@ interface IServiceAccountsProps {
7778
classes: any;
7879
history: any;
7980
displayErrorMessage: typeof setErrorSnackMessage;
81+
features: any;
8082
}
8183

8284
const Account = ({
8385
classes,
8486
displayErrorMessage,
8587
history,
88+
features,
8689
}: IServiceAccountsProps) => {
8790
const [records, setRecords] = useState<string[]>([]);
8891
const [loading, setLoading] = useState<boolean>(false);
@@ -97,10 +100,12 @@ const Account = ({
97100
const [deleteMultipleOpen, setDeleteMultipleOpen] = useState<boolean>(false);
98101
const [policyOpen, setPolicyOpen] = useState<boolean>(false);
99102

103+
const userIDP = (features && features.includes("external-idp")) || false;
104+
100105
useEffect(() => {
101106
fetchRecords();
102107
}, []);
103-
108+
104109
useEffect(() => {
105110
if (loading) {
106111
api
@@ -240,7 +245,7 @@ const Account = ({
240245
icon={<PasswordKeyIcon />}
241246
color={"primary"}
242247
variant={"outlined"}
243-
disabled={selectedSAs.length === 0}
248+
disabled={userIDP}
244249
/>
245250
</SecureComponent>
246251
<RBIconButton
@@ -301,7 +306,11 @@ const Account = ({
301306
);
302307
};
303308

304-
const connector = connect(null, {
309+
const mapState = (state: AppState) => ({
310+
features: state.console.session.features,
311+
});
312+
313+
const connector = connect(mapState, {
305314
displayErrorMessage: setErrorSnackMessage,
306315
});
307316

portal-ui/src/screens/Console/Account/ChangePasswordModal.tsx

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ import { setModalErrorSnackMessage } from "../../../actions";
3434
import { ErrorResponseHandler } from "../../../common/types";
3535
import api from "../../../common/api";
3636
import { ChangePasswordIcon } from "../../../icons";
37+
import { decodeFileName } from "../../../common/utils";
38+
import RemoveRedEyeIcon from "@mui/icons-material/RemoveRedEye";
39+
import VisibilityOffIcon from "@mui/icons-material/VisibilityOff";
3740

3841
const styles = (theme: Theme) =>
3942
createStyles({
@@ -60,6 +63,11 @@ const ChangePassword = ({
6063
const [newPassword, setNewPassword] = useState<string>("");
6164
const [reNewPassword, setReNewPassword] = useState<string>("");
6265
const [loading, setLoading] = useState<boolean>(false);
66+
const [showPassword, setShowPassword] = useState<boolean>(false);
67+
68+
const userLoggedIn = decodeFileName(
69+
localStorage.getItem("userLoggedIn") || ""
70+
);
6371

6472
const changePassword = (event: React.FormEvent) => {
6573
event.preventDefault();
@@ -110,7 +118,7 @@ const ChangePassword = ({
110118

111119
return open ? (
112120
<ModalWrapper
113-
title="Change Password"
121+
title={`Change Password for ${userLoggedIn}`}
114122
modalOpen={open}
115123
onClose={() => {
116124
setNewPassword("");
@@ -120,6 +128,9 @@ const ChangePassword = ({
120128
}}
121129
titleIcon={<ChangePasswordIcon />}
122130
>
131+
<div>
132+
This will change your Console password. Please note your new password down, as it will be required to log into Console after this session.
133+
</div>
123134
<form
124135
noValidate
125136
autoComplete="off"
@@ -137,8 +148,18 @@ const ChangePassword = ({
137148
setCurrentPassword(event.target.value);
138149
}}
139150
label="Current Password"
140-
type="password"
151+
type={showPassword ? "text" : "password"}
141152
value={currentPassword}
153+
overlayAction={() =>
154+
setShowPassword(!showPassword)
155+
}
156+
overlayIcon={
157+
showPassword ? (
158+
<VisibilityOffIcon />
159+
) : (
160+
<RemoveRedEyeIcon />
161+
)
162+
}
142163
/>
143164
</Grid>
144165
<Grid item xs={12} className={classes.formFieldRow}>
@@ -149,8 +170,18 @@ const ChangePassword = ({
149170
setNewPassword(event.target.value);
150171
}}
151172
label="New Password"
152-
type="password"
173+
type={showPassword ? "text" : "password"}
153174
value={newPassword}
175+
overlayAction={() =>
176+
setShowPassword(!showPassword)
177+
}
178+
overlayIcon={
179+
showPassword ? (
180+
<VisibilityOffIcon />
181+
) : (
182+
<RemoveRedEyeIcon />
183+
)
184+
}
154185
/>
155186
</Grid>
156187
<Grid item xs={12} className={classes.formFieldRow}>
@@ -161,8 +192,18 @@ const ChangePassword = ({
161192
setReNewPassword(event.target.value);
162193
}}
163194
label="Type New Password Again"
164-
type="password"
195+
type={showPassword ? "text" : "password"}
165196
value={reNewPassword}
197+
overlayAction={() =>
198+
setShowPassword(!showPassword)
199+
}
200+
overlayIcon={
201+
showPassword ? (
202+
<VisibilityOffIcon />
203+
) : (
204+
<RemoveRedEyeIcon />
205+
)
206+
}
166207
/>
167208
</Grid>
168209
</Grid>

0 commit comments

Comments
 (0)