Skip to content

Commit 4fe93f0

Browse files
authored
fix(admin-ui): unable to add country claim in Users form. (#1966)
* fix: removable select value * feat: update search on scope form
1 parent 35fe996 commit 4fe93f0

File tree

3 files changed

+57
-43
lines changed

3 files changed

+57
-43
lines changed

Diff for: admin-ui/app/routes/Apps/Gluu/GluuRemovableSelectRow.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ function GluuRemovableSelectRow({
3636
data-testid={name}
3737
name={name}
3838
defaultValue={value}
39-
onChange={() => {
39+
onChange={(e) => {
4040
setModifiedFields({
4141
...modifiedFields,
42-
[name]: formik.values[name],
42+
[name]: e.target.value,
4343
});
4444
formik.handleChange(e);
4545
}}
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,68 @@
1-
import React, { useEffect } from 'react'
2-
import { useDispatch, useSelector } from 'react-redux'
3-
import { useNavigate } from 'react-router-dom'
4-
import { CardBody, Card } from 'Components'
5-
import ScopeForm from './ScopeForm'
6-
import { addScope } from 'Plugins/auth-server/redux/features/scopeSlice'
7-
import { buildPayload } from 'Utils/PermChecker'
8-
import GluuLoader from 'Routes/Apps/Gluu/GluuLoader'
9-
import { getAttributes, getScripts } from 'Redux/features/initSlice'
10-
import GluuAlert from 'Routes/Apps/Gluu/GluuAlert'
11-
import { useTranslation } from 'react-i18next'
12-
import applicationStyle from 'Routes/Apps/Gluu/styles/applicationstyle'
1+
import React, { useEffect } from "react";
2+
import { useDispatch, useSelector } from "react-redux";
3+
import { useNavigate } from "react-router-dom";
4+
import { CardBody, Card } from "Components";
5+
import ScopeForm from "./ScopeForm";
6+
import { addScope } from "Plugins/auth-server/redux/features/scopeSlice";
7+
import { buildPayload } from "Utils/PermChecker";
8+
import GluuLoader from "Routes/Apps/Gluu/GluuLoader";
9+
import { getAttributes, getScripts } from "Redux/features/initSlice";
10+
import GluuAlert from "Routes/Apps/Gluu/GluuAlert";
11+
import { useTranslation } from "react-i18next";
12+
import applicationStyle from "Routes/Apps/Gluu/styles/applicationstyle";
1313

1414
function ScopeAddPage() {
15-
const loading = useSelector((state) => state.scopeReducer.loading)
16-
const scripts = useSelector((state) => state.initReducer.scripts)
17-
const attributes = useSelector((state) => state.initReducer.attributes)
18-
const saveOperationFlag = useSelector((state) => state.scopeReducer.saveOperationFlag)
19-
const errorInSaveOperationFlag = useSelector((state) => state.scopeReducer.errorInSaveOperationFlag)
15+
const loading = useSelector((state) => state.scopeReducer.loading);
16+
const scripts = useSelector((state) => state.initReducer.scripts);
17+
const attributes = useSelector((state) => state.initReducer.attributes);
18+
const saveOperationFlag = useSelector(
19+
(state) => state.scopeReducer.saveOperationFlag
20+
);
21+
const errorInSaveOperationFlag = useSelector(
22+
(state) => state.scopeReducer.errorInSaveOperationFlag
23+
);
2024

21-
const dispatch = useDispatch()
25+
const dispatch = useDispatch();
2226

23-
const userAction = {}
24-
const navigate = useNavigate()
25-
const { t } = useTranslation()
27+
const userAction = {};
28+
const navigate = useNavigate();
29+
const { t } = useTranslation();
2630
useEffect(() => {
2731
if (attributes.length === 0) {
28-
buildPayload(userAction, 'Fetch attributes', { limit: 100 })
29-
dispatch(getAttributes({ options: userAction }))
32+
buildPayload(userAction, "Fetch attributes", { limit: 100 });
33+
console.log("userAction", userAction);
34+
dispatch(getAttributes({ options: userAction }));
3035
}
3136
if (scripts.length === 0) {
32-
buildPayload(userAction, 'Fetch custom scripts', {})
33-
dispatch(getScripts({ action: userAction }))
37+
buildPayload(userAction, "Fetch custom scripts", {});
38+
dispatch(getScripts({ action: userAction }));
3439
}
35-
}, [])
40+
}, []);
3641

3742
useEffect(() => {
3843
if (saveOperationFlag && !errorInSaveOperationFlag)
39-
navigate('/auth-server/scopes')
40-
}, [saveOperationFlag])
44+
navigate("/auth-server/scopes");
45+
}, [saveOperationFlag]);
4146

4247
function handleSubmit(data) {
4348
if (data) {
44-
const postBody = {}
45-
data = JSON.parse(data)
46-
const message = data.action_message
47-
delete data.action_message
48-
postBody['scope'] = data
49-
buildPayload(userAction, message, postBody)
50-
dispatch(addScope({ action: userAction }))
49+
const postBody = {};
50+
data = JSON.parse(data);
51+
const message = data.action_message;
52+
delete data.action_message;
53+
postBody["scope"] = data;
54+
buildPayload(userAction, message, postBody);
55+
dispatch(addScope({ action: userAction }));
5156
}
5257
}
5358

59+
const handleSearch = (value) => {
60+
const option = {
61+
pattern:value
62+
}
63+
dispatch(getAttributes({ options: option }));
64+
};
65+
5466
const scope = {
5567
claims: [],
5668
dynamicScopeScripts: [],
@@ -60,13 +72,13 @@ function ScopeAddPage() {
6072
spontaneousClientScopes: [],
6173
showInConfigurationEndpoint: false,
6274
},
63-
}
75+
};
6476

6577
return (
6678
<GluuLoader blocking={loading}>
6779
<GluuAlert
68-
severity={t('titles.error')}
69-
message={t('messages.error_in_saving')}
80+
severity={t("titles.error")}
81+
message={t("messages.error_in_saving")}
7082
show={errorInSaveOperationFlag}
7183
/>
7284
<Card className="mb-3" style={applicationStyle.mainCard}>
@@ -76,11 +88,12 @@ function ScopeAddPage() {
7688
scripts={scripts}
7789
attributes={attributes}
7890
handleSubmit={handleSubmit}
91+
onSearch={handleSearch}
7992
/>
8093
</CardBody>
8194
</Card>
8295
</GluuLoader>
83-
)
96+
);
8497
}
8598

86-
export default ScopeAddPage
99+
export default ScopeAddPage;

Diff for: admin-ui/plugins/auth-server/components/Scopes/ScopeForm.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { LIMIT, PATTERN } from "Plugins/auth-server/common/Constants";
3333
import moment from "moment";
3434
import { adminUiFeatures } from "Plugins/admin/helper/utils";
3535

36-
function ScopeForm({ scope, scripts, attributes, handleSubmit }) {
36+
function ScopeForm({ scope, scripts, attributes, handleSubmit,onSearch }) {
3737
const { t } = useTranslation();
3838
let dynamicScopeScripts = [];
3939
let umaAuthorizationPolicies = [];
@@ -361,6 +361,7 @@ function ScopeForm({ scope, scripts, attributes, handleSubmit }) {
361361
options={claims}
362362
doc_category={SCOPE}
363363
placeholder="Search by display name or claim name"
364+
onSearch={onSearch}
364365
/>
365366
</Accordion.Body>
366367
</Accordion>

0 commit comments

Comments
 (0)