From b20887bbc1d44e46f25e42ccb6cb3ced586d8ce6 Mon Sep 17 00:00:00 2001 From: Piumal Rathnayake Date: Sat, 1 Mar 2025 01:57:49 +0530 Subject: [PATCH] Ensure security config dialog is properly updated with props changes --- .../Apis/Details/Endpoints/EndpointOverview.jsx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/Endpoints/EndpointOverview.jsx b/portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/Endpoints/EndpointOverview.jsx index 411b0d13f6b..d94a5c305de 100644 --- a/portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/Endpoints/EndpointOverview.jsx +++ b/portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/Endpoints/EndpointOverview.jsx @@ -365,6 +365,21 @@ function EndpointOverview(props) { setEndpointSecurityInfo(endpointConfig.endpoint_security); }, [props]); + // If the props change while the dialog is open, + // re-initialize the security info and security config + useEffect(() => { + if (endpointSecurityConfig.open) { + const tmpSecurityInfo = !endpointSecurityInfo ? { + production: CONSTS.DEFAULT_ENDPOINT_SECURITY, + sandbox: CONSTS.DEFAULT_ENDPOINT_SECURITY, + } : endpointSecurityInfo; + setEndpointSecurityInfo(tmpSecurityInfo); + setEndpointSecurityConfig((prev) => ({ + ...prev, + config: tmpSecurityInfo === undefined ? {} : tmpSecurityInfo, + })); + } + }, [props, endpointSecurityConfig.open]); const getEndpoints = (type) => { if (epConfig[type]) {