Skip to content

Commit c52f855

Browse files
Merge branch 'main' into admin-ui-issue-2368
Signed-off-by: Faisal Siddique <71010439+faisalsiddique4400@users.noreply.github.com>
2 parents 79a84bd + aabd989 commit c52f855

File tree

20 files changed

+480
-135
lines changed

20 files changed

+480
-135
lines changed

admin-ui/app/routes/Apps/Gluu/GluuCommitFooter.tsx

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,42 @@ import applicationStyle from 'Routes/Apps/Gluu/styles/applicationstyle'
55
import { ThemeContext } from 'Context/theme/themeContext'
66
import { Box } from '@mui/material'
77

8+
interface GluuCommitFooterProps {
9+
extraOnClick?: () => void
10+
saveHandler?: () => void
11+
extraLabel?: string
12+
hideButtons?: {
13+
save?: boolean
14+
back?: boolean
15+
}
16+
type?: 'button' | 'submit'
17+
disableBackButton?: boolean
18+
cancelHandler?: () => void
19+
backButtonLabel?: string
20+
backButtonHandler?: () => void
21+
}
22+
823
function GluuCommitFooter({
924
extraOnClick,
1025
saveHandler,
1126
extraLabel,
1227
hideButtons,
1328
type = 'button',
14-
}: any) {
29+
backButtonLabel,
30+
backButtonHandler,
31+
disableBackButton = false,
32+
cancelHandler = () => {},
33+
}: GluuCommitFooterProps) {
1534
const { t } = useTranslation()
16-
const theme: any = useContext(ThemeContext)
17-
const selectedTheme = theme.state.theme
35+
const theme = useContext(ThemeContext)
36+
const selectedTheme = theme?.state.theme || 'darkBlack'
1837

1938
function goBack() {
20-
window.history.back()
39+
if (backButtonHandler) {
40+
backButtonHandler()
41+
} else {
42+
window.history.back()
43+
}
2144
}
2245

2346
return (
@@ -29,11 +52,11 @@ function GluuCommitFooter({
2952
color={`primary-${selectedTheme}`}
3053
style={{ ...applicationStyle.buttonStyle, ...applicationStyle.buttonFlexIconStyles }}
3154
type="button"
32-
onClick={goBack}
55+
onClick={disableBackButton ? cancelHandler : goBack}
3356
className="d-flex m-1 mx-5"
3457
>
35-
<i className="fa fa-arrow-circle-left me-2"></i>
36-
{t('actions.cancel')}
58+
{!disableBackButton && <i className="fa fa-arrow-circle-left me-2"></i>}
59+
{backButtonLabel || t('actions.cancel')}
3760
</Button>
3861
)}
3962
{extraLabel && extraOnClick && (

admin-ui/app/routes/Apps/Gluu/GluuProperties.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState, useContext } from 'react'
1+
import { useState, useContext, useEffect } from 'react'
22
import { FormGroup, Col, Button, Accordion, AccordionHeader, AccordionBody } from 'Components'
33
import GluuPropertyItem from './GluuPropertyItem'
44
import { useTranslation } from 'react-i18next'
@@ -35,6 +35,12 @@ function GluuProperties({
3535
const theme: any = useContext(ThemeContext)
3636
const selectedTheme = theme.state.theme
3737

38+
// Sync internal state with options prop when it changes
39+
// This ensures the component properly resets when formik values are reset
40+
useEffect(() => {
41+
setProperties(options)
42+
}, [options])
43+
3844
const addProperty = () => {
3945
let item
4046
if (multiProperties) {

admin-ui/app/routes/Apps/Gluu/GluuTypeAhead.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ function GluuTypeAhead({
7979
id={name}
8080
data-testid={name}
8181
multiple={multiple}
82-
selected={value}
82+
selected={value || []}
8383
options={options}
8484
/>
8585
{!hideHelperMessage && (

admin-ui/app/utils/AuditLogger.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export interface LogAuditParams {
1515
message: string
1616
modifiedFields?: Record<string, unknown>
1717
performedOn?: string | Date
18+
ip_address?: string
1819
extra?: Record<string, unknown>
1920
status?: string
2021
client_id?: string

admin-ui/app/utils/types.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,22 @@ export interface ReduxState {
3333
error: ApiError | null
3434
data: any
3535
}
36+
37+
// Redux Root State interface for auth-related state
38+
export interface AuthRootState {
39+
authReducer: {
40+
token: {
41+
access_token: string
42+
}
43+
userinfo: {
44+
inum?: string
45+
name?: string
46+
}
47+
config: {
48+
clientId: string
49+
}
50+
location: {
51+
IPv4: string
52+
}
53+
}
54+
}

admin-ui/plugins/auth-server/components/Configuration/ConfigApiConfiguration/ApiConfigForm.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { useCallback, useState, useEffect } from 'react'
22
import GluuCommitDialog from 'Routes/Apps/Gluu/GluuCommitDialog'
33
import { FormGroup } from 'Components'
44
import { useDispatch, useSelector } from 'react-redux'
5+
import { useNavigate } from 'react-router-dom'
56
import spec from '../../../../../configApiSpecs.yaml'
67
import { buildPayload, API_CONFIG_WRITE } from 'Utils/PermChecker'
78
import { useCedarling } from '@/cedarling'
@@ -15,6 +16,7 @@ const schema = spec.components.schemas.ApiAppConfiguration.properties
1516
const ApiConfigForm = () => {
1617
const { hasCedarPermission, authorize } = useCedarling()
1718
const dispatch = useDispatch()
19+
const navigate = useNavigate()
1820
const [modal, setModal] = useState(false)
1921
const [patches, setPatches] = useState([])
2022
const [operations, setOperations] = useState([])
@@ -74,6 +76,10 @@ const ApiConfigForm = () => {
7476
setOperations(newPatches)
7577
}
7678

79+
const handleBack = () => {
80+
navigate('/home/dashboard')
81+
}
82+
7783
return (
7884
<>
7985
{Object.keys(configuration).map((propKey) => {
@@ -93,7 +99,14 @@ const ApiConfigForm = () => {
9399
})}
94100

95101
<FormGroup row></FormGroup>
96-
{hasCedarPermission(API_CONFIG_WRITE) && <GluuCommitFooter saveHandler={toggle} />}
102+
{hasCedarPermission(API_CONFIG_WRITE) && (
103+
<GluuCommitFooter
104+
saveHandler={toggle}
105+
hideButtons={{ back: false }}
106+
backButtonLabel="Back"
107+
backButtonHandler={handleBack}
108+
/>
109+
)}
97110

98111
{hasCedarPermission(API_CONFIG_WRITE) && (
99112
<GluuCommitDialog

admin-ui/plugins/auth-server/components/Configuration/ConfigPage.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { FormGroup, Card, CardBody, CardHeader } from 'Components'
44
import GluuLoader from 'Routes/Apps/Gluu/GluuLoader'
55
import GluuCommitFooter from 'Routes/Apps/Gluu/GluuCommitFooter'
66
import GluuCommitDialog from 'Routes/Apps/Gluu/GluuCommitDialog'
7-
87
import PropertyBuilder from './JsonPropertyBuilder'
98
import { useDispatch, useSelector } from 'react-redux'
9+
import { useNavigate } from 'react-router-dom'
1010
import RefreshIcon from '@mui/icons-material/Refresh'
1111
import spec from '../../../../configApiSpecs.yaml'
1212
import { buildPayload, PROPERTIES_WRITE } from 'Utils/PermChecker'
@@ -30,6 +30,7 @@ function ConfigPage() {
3030
const { permissions: cedarPermissions } = useSelector((state) => state.cedarPermissions)
3131

3232
const dispatch = useDispatch()
33+
const navigate = useNavigate()
3334

3435
const { t } = useTranslation()
3536
const lSize = 6
@@ -50,7 +51,6 @@ function ConfigPage() {
5051

5152
const [put, setPut] = useState([])
5253

53-
// Permission initialization
5454
useEffect(() => {
5555
const authorizePermissions = async () => {
5656
try {
@@ -129,6 +129,10 @@ function ConfigPage() {
129129
return result.toLowerCase()
130130
}
131131

132+
const handleBack = () => {
133+
navigate('/home/dashboard')
134+
}
135+
132136
return (
133137
<GluuLoader blocking={!(!!configuration && Object.keys(configuration).length > 0)}>
134138
<Card style={{ borderRadius: 24 }}>
@@ -203,7 +207,14 @@ function ConfigPage() {
203207
)}
204208

205209
<FormGroup row></FormGroup>
206-
{hasCedarPermission(PROPERTIES_WRITE) && <GluuCommitFooter saveHandler={toggle} />}
210+
{hasCedarPermission(PROPERTIES_WRITE) && (
211+
<GluuCommitFooter
212+
saveHandler={toggle}
213+
hideButtons={{ back: false }}
214+
backButtonLabel="Back"
215+
backButtonHandler={handleBack}
216+
/>
217+
)}
207218
<FormGroup row></FormGroup>
208219
<FormGroup row></FormGroup>
209220
<FormGroup row></FormGroup>

admin-ui/plugins/auth-server/components/Configuration/Defaults/LoggingPage.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import React, { useEffect, useContext, useState, useMemo, useCallback } from 'react'
2-
import { Form, Button, FormGroup, Card, CardBody, Col, CustomInput } from 'Components'
1+
import React, { useEffect, useState, useMemo, useCallback } from 'react'
2+
import { Form, FormGroup, Card, CardBody, Col, CustomInput, Row } from 'Components'
33
import GluuLabel from 'Routes/Apps/Gluu/GluuLabel'
44
import GluuLoader from 'Routes/Apps/Gluu/GluuLoader'
55
import GluuViewWrapper from 'Routes/Apps/Gluu/GluuViewWrapper'
66
import GluuCommitDialog from 'Routes/Apps/Gluu/GluuCommitDialog'
7+
import GluuCommitFooter from 'Routes/Apps/Gluu/GluuCommitFooter'
78
import { JSON_CONFIG } from 'Utils/ApiResources'
89
import applicationStyle from 'Routes/Apps/Gluu/styles/applicationstyle'
910
import { useDispatch, useSelector } from 'react-redux'
@@ -16,20 +17,17 @@ import { LOGGING_READ, LOGGING_WRITE } from 'Utils/PermChecker'
1617
import { useCedarling } from '@/cedarling'
1718
import { useTranslation } from 'react-i18next'
1819
import SetTitle from 'Utils/SetTitle'
19-
import { ThemeContext } from 'Context/theme/themeContext'
2020
import GluuToogleRow from 'Routes/Apps/Gluu/GluuToogleRow'
2121
import { getChangedFields, getMergedValues } from '@/helpers'
2222

2323
function LoggingPage() {
2424
const { t } = useTranslation()
2525
const { hasCedarPermission, authorize } = useCedarling()
26-
const theme = useContext(ThemeContext)
2726
const logging = useSelector((state) => state.loggingReducer.logging)
2827
const loading = useSelector((state) => state.loggingReducer.loading)
2928
const { permissions: cedarPermissions } = useSelector((state) => state.cedarPermissions)
3029

3130
const dispatch = useDispatch()
32-
const selectedTheme = theme.state.theme
3331

3432
const [showCommitDialog, setShowCommitDialog] = useState(false)
3533
const [pendingValues, setPendingValues] = useState(null)
@@ -192,10 +190,17 @@ function LoggingPage() {
192190
/>
193191

194192
{hasCedarPermission(LOGGING_WRITE) && (
195-
<Button color={`primary-${selectedTheme}`} type="submit">
196-
<i className="fa fa-check-circle me-2"></i>
197-
{t('actions.save')}
198-
</Button>
193+
<Row>
194+
<Col>
195+
<GluuCommitFooter
196+
saveHandler={formik.handleSubmit}
197+
extraLabel={t('actions.cancel')}
198+
extraOnClick={() => formik.resetForm()}
199+
hideButtons={{ save: true, back: true }}
200+
type="submit"
201+
/>
202+
</Col>
203+
</Row>
199204
)}
200205
</Form>
201206
)}

admin-ui/plugins/fido/components/DynamicConfiguration.tsx

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,21 @@ const DynamicConfiguration: React.FC<DynamicConfigurationProps> = ({
3232
enableReinitialize: true,
3333
})
3434

35-
const submitForm = useCallback(() => {
36-
toggle()
37-
handleSubmit(formik.values)
38-
}, [handleSubmit, toggle, formik.values])
35+
const submitForm = useCallback(
36+
(userMessage: string) => {
37+
toggle()
38+
handleSubmit(formik.values, userMessage)
39+
},
40+
[handleSubmit, toggle, formik.values],
41+
)
42+
43+
const handleCancel = useCallback(() => {
44+
const initialValues = transformToFormValues(
45+
fidoConfiguration,
46+
fidoConstants.DYNAMIC,
47+
) as DynamicConfigFormValues
48+
formik.resetForm({ values: initialValues })
49+
}, [formik, fidoConfiguration])
3950

4051
const handleFormSubmit = useCallback(
4152
(e: React.FormEvent<HTMLFormElement>) => {
@@ -288,34 +299,14 @@ const DynamicConfiguration: React.FC<DynamicConfigurationProps> = ({
288299
doc_category={fidoConstants.DOC_CATEGORY}
289300
/>
290301
</Col>
291-
292-
<Col sm={8}>
293-
<GluuToggleRow
294-
label={fidoConstants.LABELS.SESSION_ID_PERSIST_IN_CACHE}
295-
name={fidoConstants.FORM_FIELDS.SESSION_ID_PERSIST_IN_CACHE}
296-
formik={formik}
297-
lsize={4}
298-
rsize={8}
299-
doc_category={fidoConstants.DOC_CATEGORY}
300-
/>
301-
</Col>
302-
303-
<Col sm={8}>
304-
<GluuToggleRow
305-
label={fidoConstants.LABELS.ERROR_REASON_ENABLED}
306-
name={fidoConstants.FORM_FIELDS.ERROR_REASON_ENABLED}
307-
formik={formik}
308-
lsize={4}
309-
rsize={8}
310-
doc_category={fidoConstants.DOC_CATEGORY}
311-
/>
312-
</Col>
313302
</FormGroup>
314303
<Row>
315304
<Col>
316305
<GluuCommitFooter
317306
saveHandler={toggle}
318-
hideButtons={{ save: true, back: false }}
307+
hideButtons={{ save: true, back: true }}
308+
extraLabel="Cancel"
309+
extraOnClick={handleCancel}
319310
type="submit"
320311
disabled={isSubmitting}
321312
/>

0 commit comments

Comments
 (0)