Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(admin-ui): unable to add country claim in Users form. #1966

Merged
merged 2 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions admin-ui/app/routes/Apps/Gluu/GluuRemovableSelectRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ function GluuRemovableSelectRow({
data-testid={name}
name={name}
defaultValue={value}
onChange={() => {
onChange={(e) => {
setModifiedFields({
...modifiedFields,
[name]: formik.values[name],
[name]: e.target.value,
});
formik.handleChange(e);
}}
Expand Down
93 changes: 53 additions & 40 deletions admin-ui/plugins/auth-server/components/Scopes/ScopeAddPage.js
Original file line number Diff line number Diff line change
@@ -1,56 +1,68 @@
import React, { useEffect } from 'react'
import { useDispatch, useSelector } from 'react-redux'
import { useNavigate } from 'react-router-dom'
import { CardBody, Card } from 'Components'
import ScopeForm from './ScopeForm'
import { addScope } from 'Plugins/auth-server/redux/features/scopeSlice'
import { buildPayload } from 'Utils/PermChecker'
import GluuLoader from 'Routes/Apps/Gluu/GluuLoader'
import { getAttributes, getScripts } from 'Redux/features/initSlice'
import GluuAlert from 'Routes/Apps/Gluu/GluuAlert'
import { useTranslation } from 'react-i18next'
import applicationStyle from 'Routes/Apps/Gluu/styles/applicationstyle'
import React, { useEffect } from "react";
import { useDispatch, useSelector } from "react-redux";
import { useNavigate } from "react-router-dom";
import { CardBody, Card } from "Components";
import ScopeForm from "./ScopeForm";
import { addScope } from "Plugins/auth-server/redux/features/scopeSlice";
import { buildPayload } from "Utils/PermChecker";
import GluuLoader from "Routes/Apps/Gluu/GluuLoader";
import { getAttributes, getScripts } from "Redux/features/initSlice";
import GluuAlert from "Routes/Apps/Gluu/GluuAlert";
import { useTranslation } from "react-i18next";
import applicationStyle from "Routes/Apps/Gluu/styles/applicationstyle";

function ScopeAddPage() {
const loading = useSelector((state) => state.scopeReducer.loading)
const scripts = useSelector((state) => state.initReducer.scripts)
const attributes = useSelector((state) => state.initReducer.attributes)
const saveOperationFlag = useSelector((state) => state.scopeReducer.saveOperationFlag)
const errorInSaveOperationFlag = useSelector((state) => state.scopeReducer.errorInSaveOperationFlag)
const loading = useSelector((state) => state.scopeReducer.loading);
const scripts = useSelector((state) => state.initReducer.scripts);
const attributes = useSelector((state) => state.initReducer.attributes);
const saveOperationFlag = useSelector(
(state) => state.scopeReducer.saveOperationFlag
);
const errorInSaveOperationFlag = useSelector(
(state) => state.scopeReducer.errorInSaveOperationFlag
);

const dispatch = useDispatch()
const dispatch = useDispatch();

const userAction = {}
const navigate = useNavigate()
const { t } = useTranslation()
const userAction = {};
const navigate = useNavigate();
const { t } = useTranslation();
useEffect(() => {
if (attributes.length === 0) {
buildPayload(userAction, 'Fetch attributes', { limit: 100 })
dispatch(getAttributes({ options: userAction }))
buildPayload(userAction, "Fetch attributes", { limit: 100 });
console.log("userAction", userAction);
dispatch(getAttributes({ options: userAction }));
}
if (scripts.length === 0) {
buildPayload(userAction, 'Fetch custom scripts', {})
dispatch(getScripts({ action: userAction }))
buildPayload(userAction, "Fetch custom scripts", {});
dispatch(getScripts({ action: userAction }));
}
}, [])
}, []);

useEffect(() => {
if (saveOperationFlag && !errorInSaveOperationFlag)
navigate('/auth-server/scopes')
}, [saveOperationFlag])
navigate("/auth-server/scopes");
}, [saveOperationFlag]);

function handleSubmit(data) {
if (data) {
const postBody = {}
data = JSON.parse(data)
const message = data.action_message
delete data.action_message
postBody['scope'] = data
buildPayload(userAction, message, postBody)
dispatch(addScope({ action: userAction }))
const postBody = {};
data = JSON.parse(data);
const message = data.action_message;
delete data.action_message;
postBody["scope"] = data;
buildPayload(userAction, message, postBody);
dispatch(addScope({ action: userAction }));
}
}

const handleSearch = (value) => {
const option = {
pattern:value
}
dispatch(getAttributes({ options: option }));
};

const scope = {
claims: [],
dynamicScopeScripts: [],
Expand All @@ -60,13 +72,13 @@ function ScopeAddPage() {
spontaneousClientScopes: [],
showInConfigurationEndpoint: false,
},
}
};

return (
<GluuLoader blocking={loading}>
<GluuAlert
severity={t('titles.error')}
message={t('messages.error_in_saving')}
severity={t("titles.error")}
message={t("messages.error_in_saving")}
show={errorInSaveOperationFlag}
/>
<Card className="mb-3" style={applicationStyle.mainCard}>
Expand All @@ -76,11 +88,12 @@ function ScopeAddPage() {
scripts={scripts}
attributes={attributes}
handleSubmit={handleSubmit}
onSearch={handleSearch}
/>
</CardBody>
</Card>
</GluuLoader>
)
);
}

export default ScopeAddPage
export default ScopeAddPage;
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { LIMIT, PATTERN } from "Plugins/auth-server/common/Constants";
import moment from "moment";
import { adminUiFeatures } from "Plugins/admin/helper/utils";

function ScopeForm({ scope, scripts, attributes, handleSubmit }) {
function ScopeForm({ scope, scripts, attributes, handleSubmit,onSearch }) {
const { t } = useTranslation();
let dynamicScopeScripts = [];
let umaAuthorizationPolicies = [];
Expand Down Expand Up @@ -361,6 +361,7 @@ function ScopeForm({ scope, scripts, attributes, handleSubmit }) {
options={claims}
doc_category={SCOPE}
placeholder="Search by display name or claim name"
onSearch={onSearch}
/>
</Accordion.Body>
</Accordion>
Expand Down
Loading