Skip to content

Commit 300ebfa

Browse files
authored
Updated OpenID UX (#3050)
- Display ENV variables set in configuration - Removed Password empty placeholders - Added notification to re-enter password when modifying OpenID configuration Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
1 parent 1ce2846 commit 300ebfa

File tree

5 files changed

+194
-62
lines changed

5 files changed

+194
-62
lines changed

portal-ui/src/screens/Console/EventDestinations/WebhookSettings/EditWebhookEndpoint.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,9 @@ const EditEndpointModal = ({
218218
<Tooltip
219219
tooltip={
220220
overrideValues.enable
221-
? `This value is set from the ${overrideValues.enable.overrideEnv} environment variable`
221+
? `This value is set from the ${
222+
overrideValues.enable?.overrideEnv || "N/A"
223+
} environment variable`
222224
: ""
223225
}
224226
placement={"left"}
@@ -245,7 +247,9 @@ const EditEndpointModal = ({
245247
<Tooltip
246248
tooltip={
247249
overrideValues.enable
248-
? `This value is set from the ${overrideValues.endpoint.overrideEnv} environment variable`
250+
? `This value is set from the ${
251+
overrideValues.endpoint?.overrideEnv || "N/A"
252+
} environment variable`
249253
: ""
250254
}
251255
placement={"left"}
@@ -272,7 +276,9 @@ const EditEndpointModal = ({
272276
<Tooltip
273277
tooltip={
274278
overrideValues.enable
275-
? `This value is set from the ${overrideValues.auth_token.overrideEnv} environment variable`
279+
? `This value is set from the ${
280+
overrideValues.auth_token?.overrideEnv || "N/A"
281+
} environment variable`
276282
: ""
277283
}
278284
placement={"left"}

portal-ui/src/screens/Console/IDP/IDPConfigurationDetails.tsx

Lines changed: 173 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,26 @@
1414
// You should have received a copy of the GNU Affero General Public License
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
import React, { Fragment, useEffect, useState } from "react";
17+
import React, { Fragment, useCallback, useEffect, useState } from "react";
1818
import {
1919
BackLink,
20+
Box,
21+
breakPoints,
2022
Button,
23+
ConsoleIcon,
2124
EditIcon,
22-
PageLayout,
23-
RefreshIcon,
24-
TrashIcon,
25-
Box,
25+
FormLayout,
2626
Grid,
27-
Switch,
27+
HelpBox,
2828
InputBox,
29-
FormLayout,
30-
breakPoints,
29+
PageLayout,
30+
RefreshIcon,
3131
ScreenTitle,
32+
Switch,
33+
Tooltip,
34+
TrashIcon,
35+
ValuePair,
36+
WarnIcon,
3237
} from "mds";
3338
import { useNavigate, useParams } from "react-router-dom";
3439
import { modalStyleUtils } from "../Common/FormComponents/common/styleLibrary";
@@ -42,7 +47,6 @@ import {
4247
import api from "../../../common/api";
4348
import useApi from "../Common/Hooks/useApi";
4449
import DeleteIDPConfigurationModal from "./DeleteIDPConfigurationModal";
45-
import LabelValuePair from "../Common/UsageBarWrapper/LabelValuePair";
4650
import PageHeaderWrapper from "../Common/PageHeaderWrapper/PageHeaderWrapper";
4751
import HelpMenu from "../HelpMenu";
4852

@@ -74,10 +78,12 @@ const IDPConfigurationDetails = ({
7478
const [loading, setLoading] = useState<boolean>(true);
7579
const [isEnabled, setIsEnabled] = useState<boolean>(false);
7680
const [fields, setFields] = useState<any>({});
81+
const [overrideFields, setOverrideFields] = useState<any>({});
7782
const [originalFields, setOriginalFields] = useState<any>({});
7883
const [record, setRecord] = useState<any>({});
7984
const [editMode, setEditMode] = useState<boolean>(false);
8085
const [deleteOpen, setDeleteOpen] = useState<boolean>(false);
86+
const [envOverride, setEnvOverride] = useState<boolean>(false);
8187

8288
const onSuccess = (res: any) => {
8389
dispatch(setServerNeedsRestart(res.restart === true));
@@ -102,26 +108,47 @@ const IDPConfigurationDetails = ({
102108
onEnabledError,
103109
);
104110

111+
const parseFields = useCallback(
112+
(record: any) => {
113+
let fields: any = {};
114+
let overrideFields: any = {};
115+
let totEnv = 0;
116+
117+
if (record.info) {
118+
record.info.forEach((item: any) => {
119+
if (item.key === "enable") {
120+
setIsEnabled(item.value === "on");
121+
}
122+
123+
if (item.isEnv) {
124+
overrideFields[
125+
item.key
126+
] = `MINIO_IDENTITY_OPENID_${item.key.toUpperCase()}${
127+
configurationName !== "_" ? `_${configurationName}` : ""
128+
}`;
129+
totEnv++;
130+
}
131+
132+
fields[item.key] = item.value;
133+
});
134+
135+
if (totEnv > 0) {
136+
setEnvOverride(true);
137+
}
138+
}
139+
setFields(fields);
140+
setOverrideFields(overrideFields);
141+
},
142+
[configurationName],
143+
);
144+
105145
const toggleEditMode = () => {
106146
if (editMode) {
107147
parseFields(record);
108148
}
109149
setEditMode(!editMode);
110150
};
111151

112-
const parseFields = (record: any) => {
113-
let fields: any = {};
114-
if (record.info) {
115-
record.info.forEach((item: any) => {
116-
if (item.key === "enable") {
117-
setIsEnabled(item.value === "on");
118-
}
119-
fields[item.key] = item.value;
120-
});
121-
}
122-
setFields(fields);
123-
};
124-
125152
const parseOriginalFields = (record: any) => {
126153
let fields: any = {};
127154
if (record.info) {
@@ -157,7 +184,7 @@ const IDPConfigurationDetails = ({
157184
if (loading) {
158185
loadRecord();
159186
}
160-
}, [dispatch, loading, configurationName, endpoint]);
187+
}, [dispatch, loading, configurationName, endpoint, parseFields]);
161188

162189
const validSave = () => {
163190
for (const [key, value] of Object.entries(formFields)) {
@@ -255,6 +282,27 @@ const IDPConfigurationDetails = ({
255282
}}
256283
>
257284
<Grid container>
285+
{editMode ? (
286+
<Grid item xs={12} sx={{ marginBottom: 15 }}>
287+
<HelpBox
288+
title={
289+
<Box
290+
style={{
291+
display: "flex",
292+
justifyContent: "space-between",
293+
alignItems: "center",
294+
flexGrow: 1,
295+
}}
296+
>
297+
Client Secret must be re-entered to change OpenID
298+
configurations
299+
</Box>
300+
}
301+
iconComponent={<WarnIcon />}
302+
help={null}
303+
/>
304+
</Grid>
305+
) : null}
258306
<Grid xs={12} item>
259307
{Object.entries(formFields).map(([key, value]) =>
260308
renderFormField(key, value),
@@ -298,26 +346,72 @@ const IDPConfigurationDetails = ({
298346
const renderViewForm = () => {
299347
return (
300348
<Box
349+
withBorders
301350
sx={{
302351
display: "grid",
303352
gridTemplateColumns: "1fr",
304353
gridAutoFlow: "dense",
305354
gap: 3,
306355
padding: "15px",
307-
border: "1px solid #eaeaea",
308356
[`@media (min-width: ${breakPoints.sm}px)`]: {
309357
gridTemplateColumns: "2fr 1fr",
310358
gridAutoFlow: "row",
311359
},
312360
}}
313361
>
314-
{Object.entries(formFields).map(([key, value]) => (
315-
<LabelValuePair
316-
key={key}
317-
label={value.label}
318-
value={fields[key] ? fields[key] : ""}
319-
/>
320-
))}
362+
{Object.entries(formFields).map(([key, value]) => {
363+
if (!value.editOnly) {
364+
let label: React.ReactNode = value.label;
365+
let val: React.ReactNode = fields[key] ? fields[key] : "";
366+
367+
if (value.type === "toggle" && fields[key]) {
368+
if (val !== "on") {
369+
val = "Off";
370+
} else {
371+
val = "On";
372+
}
373+
}
374+
375+
if (overrideFields[key]) {
376+
label = (
377+
<Box
378+
sx={{
379+
display: "flex",
380+
alignItems: "center",
381+
gap: 5,
382+
"& .min-icon": {
383+
height: 20,
384+
width: 20,
385+
},
386+
"& span": {
387+
height: 20,
388+
display: "flex",
389+
alignItems: "center",
390+
},
391+
}}
392+
>
393+
<span>{value.label}</span>
394+
<Tooltip
395+
tooltip={`This value is set from the ${overrideFields[key]} environment variable`}
396+
placement={"right"}
397+
>
398+
<span className={"muted"}>
399+
<ConsoleIcon />
400+
</span>
401+
</Tooltip>
402+
</Box>
403+
);
404+
405+
val = (
406+
<i>
407+
<span className={"muted"}>{val}</span>
408+
</i>
409+
);
410+
}
411+
return <ValuePair key={key} label={label} value={val} />;
412+
}
413+
return null;
414+
})}
321415
</Box>
322416
);
323417
};
@@ -351,32 +445,58 @@ const IDPConfigurationDetails = ({
351445
actions={
352446
<Fragment>
353447
{configurationName !== "_" && (
354-
<Button
355-
id={"delete-idp-config"}
356-
onClick={() => {
357-
setDeleteOpen(true);
358-
}}
359-
label={"Delete Configuration"}
360-
icon={<TrashIcon />}
361-
variant={"secondary"}
362-
/>
448+
<Tooltip
449+
tooltip={
450+
envOverride
451+
? "This configuration cannot be deleted using this module as this was set using OpenID environment variables."
452+
: ""
453+
}
454+
>
455+
<Button
456+
id={"delete-idp-config"}
457+
onClick={() => {
458+
setDeleteOpen(true);
459+
}}
460+
label={"Delete Configuration"}
461+
icon={<TrashIcon />}
462+
variant={"secondary"}
463+
disabled={envOverride}
464+
/>
465+
</Tooltip>
363466
)}
364467
{!editMode && (
468+
<Tooltip
469+
tooltip={
470+
envOverride
471+
? "Configuration cannot be edited in this module as OpenID environment variables are set for this MinIO instance."
472+
: ""
473+
}
474+
>
475+
<Button
476+
id={"edit"}
477+
type="button"
478+
variant={"callAction"}
479+
icon={<EditIcon />}
480+
onClick={toggleEditMode}
481+
label={"Edit"}
482+
disabled={envOverride}
483+
/>
484+
</Tooltip>
485+
)}
486+
<Tooltip
487+
tooltip={
488+
envOverride
489+
? "Configuration cannot be disabled / enabled in this module as OpenID environment variables are set for this MinIO instance."
490+
: ""
491+
}
492+
>
365493
<Button
366-
id={"edit"}
367-
type="button"
368-
variant={"callAction"}
369-
icon={<EditIcon />}
370-
onClick={toggleEditMode}
371-
label={"Edit"}
494+
id={"is-configuration-enabled"}
495+
onClick={() => toggleConfiguration(!isEnabled)}
496+
label={isEnabled ? "Disable" : "Enable"}
497+
disabled={loadingEnabledSave || envOverride}
372498
/>
373-
)}
374-
<Button
375-
id={"is-configuration-enabled"}
376-
onClick={() => toggleConfiguration(!isEnabled)}
377-
label={isEnabled ? "Disable" : "Enable"}
378-
disabled={loadingEnabledSave}
379-
/>
499+
</Tooltip>
380500
<Button
381501
id={"refresh-idp-config"}
382502
onClick={() => setLoading(true)}

0 commit comments

Comments
 (0)