Skip to content

Commit

Permalink
EPMRPP-88366 || Project integration shows values from another project…
Browse files Browse the repository at this point in the history
… integration configuration fields (#3684)
  • Loading branch information
Vadim73i authored Dec 5, 2023
1 parent aeeaf9b commit 5af63ea
Showing 1 changed file with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import React, { useState, useEffect } from 'react';
import React, { useState, useEffect, useMemo } from 'react';
import { useSelector, useDispatch } from 'react-redux';
import { redirect } from 'redux-first-router';
import classNames from 'classnames/bind';
Expand Down Expand Up @@ -69,26 +69,30 @@ export const IntegrationInfo = (props) => {
integrationId,
} = props;

const availableGlobalIntegrations = globalIntegrations[pluginName] || [];
const availableProjectIntegrations = projectIntegrations[pluginName] || [];
const availableGlobalIntegrations = useMemo(() => globalIntegrations[pluginName] || [], [
globalIntegrations,
pluginName,
]);
const availableProjectIntegrations = useMemo(() => projectIntegrations[pluginName] || [], [
projectIntegrations,
pluginName,
]);
const isAtLeastOneIntegrationAvailable =
availableGlobalIntegrations.length > 0 || availableProjectIntegrations.length > 0;

useEffect(() => {
const integration = availableProjectIntegrations.find((value) => value.id === +integrationId);

if (integration) {
setIntegrationInfo(integration);
let isGlobal = false;
let integration = availableProjectIntegrations.find((value) => value.id === +integrationId);
if (!integration) {
integration = availableGlobalIntegrations.find((value) => value.id === +integrationId);
isGlobal = !!integration;
}
}, [integrationId, availableProjectIntegrations]);

useEffect(() => {
const integration = availableGlobalIntegrations.find((value) => value.id === +integrationId);

if (integration) {
setIntegrationInfo({ ...integration, blocked: true });
setUpdatedParameters({});
setIntegrationInfo({ ...integration, blocked: isGlobal });
}
}, [integrationId, availableGlobalIntegrations]);
}, [availableGlobalIntegrations, availableProjectIntegrations, integrationId]);

const integrationSettingsExtension = settingsExtensions.find(
(ext) => ext.pluginName === pluginName,
Expand Down

0 comments on commit 5af63ea

Please sign in to comment.