diff --git a/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/AccessLogDetail.jsx b/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/AccessLogDetail.jsx index dc75efe50a..13b7758105 100644 --- a/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/AccessLogDetail.jsx +++ b/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/AccessLogDetail.jsx @@ -25,34 +25,18 @@ import { toast } from "react-toastify"; import { isEmpty } from "lodash"; import { Loader } from "Components/CommonComponents"; import { useParams } from "react-router-dom"; +import { getServiceDef } from "../../utils/appState"; -function AccessLogDetail(props) { +function AccessLogDetail() { const params = useParams(); const [access, setAccess] = useState([]); - const [serviceDefs, setServiceDefs] = useState([]); const [loader, setLoader] = useState(true); + const { allServiceDefs } = getServiceDef(); useEffect(() => { - fetchServiceDefs(); fetchAcessLogs(); }, []); - const fetchServiceDefs = async () => { - let serviceDefsResp = []; - try { - serviceDefsResp = await fetchApi({ - url: "plugins/definitions" - }); - } catch (error) { - console.error( - `Error occurred while fetching Service Definitions or CSRF headers! ${error}` - ); - } - - setServiceDefs(serviceDefsResp.data.serviceDefs); - setLoader(false); - }; - const fetchAcessLogs = async () => { let accessResp = {}; let accessData = {}; @@ -99,7 +83,7 @@ function AccessLogDetail(props) {
{ + serviceDef={allServiceDefs?.find((servicedef) => { return servicedef.name == access.serviceType; })} policyView={false} diff --git a/security-admin/src/main/webapp/react-webapp/src/views/Encryption/KeyCreate.jsx b/security-admin/src/main/webapp/react-webapp/src/views/Encryption/KeyCreate.jsx index 5f7fc8af01..aa17887729 100644 --- a/security-admin/src/main/webapp/react-webapp/src/views/Encryption/KeyCreate.jsx +++ b/security-admin/src/main/webapp/react-webapp/src/views/Encryption/KeyCreate.jsx @@ -30,10 +30,11 @@ import { scrollToError } from "../../components/CommonComponents"; import { commonBreadcrumb, serverError } from "../../utils/XAUtils"; -import { isEmpty, values } from "lodash"; +import { find, isEmpty, values } from "lodash"; import withRouter from "Hooks/withRouter"; import { useLocation, useNavigate } from "react-router-dom"; import usePrompt from "Hooks/usePrompt"; +import { getServiceDef } from "../../utils/appState"; const initialState = { service: {}, @@ -74,6 +75,7 @@ function KeyCreate(props) { const [preventUnBlock, setPreventUnblock] = useState(false); const [blockUI, setBlockUI] = useState(false); const toastId = useRef(null); + const { allServiceDefs } = getServiceDef(); useEffect(() => { fetchInitialData(); @@ -107,7 +109,6 @@ function KeyCreate(props) { } } - let apiError = "Error occurred while creating Key"; serviceJson.name = values.name; serviceJson.cipher = values.cipher; serviceJson.length = values.length; @@ -149,7 +150,6 @@ function KeyCreate(props) { }; const fetchKmsServices = async () => { let serviceResp; - let kmsDefinition; dispatch({ type: "SET_LOADER", loader: true @@ -161,20 +161,11 @@ function KeyCreate(props) { } catch (error) { console.error(`Error occurred while fetching Services! ${error}`); } - try { - kmsDefinition = await fetchApi({ - url: `plugins/definitions/name/${ - serviceResp.data && serviceResp.data.type - }` - }); - } catch (error) { - console.error(`Error occurred while fetching Definitions! ${error}`); - } dispatch({ type: "SET_DATA", service: serviceResp, - definition: kmsDefinition, + definition: find(allServiceDefs, { name: "kms" }), loader: false }); }; @@ -194,7 +185,7 @@ function KeyCreate(props) { }; const keyCreateBreadcrumb = () => { let serviceDetails = {}; - serviceDetails["serviceDefId"] = definition.data && definition.data.id; + serviceDetails["serviceDefId"] = definition && definition?.id; serviceDetails["serviceId"] = service.data && service.data.id; serviceDetails["serviceName"] = props.params.serviceName; return commonBreadcrumb( @@ -226,7 +217,6 @@ function KeyCreate(props) { handleSubmit, form, submitting, - pristine, invalid, errors, dirty, @@ -398,7 +388,6 @@ function KeyCreate(props) {