From fd986cc656dfd10b3308fecd576995f127acd183 Mon Sep 17 00:00:00 2001 From: Siarhei Iukou Date: Wed, 15 Jan 2025 04:16:36 +0300 Subject: [PATCH] EPMRPP-98423 || Error occurs when clicking on Add integration with disabled BTS plugin --- .../instancesSection/instancesSection.jsx | 10 +++++++--- app/src/controllers/plugins/index.js | 1 + app/src/controllers/plugins/selectors.js | 2 ++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/src/components/integrations/containers/integrationInfoContainer/instancesSection/instancesSection.jsx b/app/src/components/integrations/containers/integrationInfoContainer/instancesSection/instancesSection.jsx index 1a99f639f9..a654704094 100644 --- a/app/src/components/integrations/containers/integrationInfoContainer/instancesSection/instancesSection.jsx +++ b/app/src/components/integrations/containers/integrationInfoContainer/instancesSection/instancesSection.jsx @@ -28,6 +28,7 @@ import { removePluginAction, addIntegrationAction, removeProjectIntegrationsByTypeAction, + enabledPluginSelector, } from 'controllers/plugins'; import { showModalAction } from 'controllers/modal'; import { @@ -115,10 +116,11 @@ const messages = defineMessages({ }); @connect( - (state) => ({ + (state, ownProps) => ({ projectId: projectIdSelector(state), accountRole: userAccountRoleSelector(state), userRole: activeProjectRoleSelector(state), + isEnabled: enabledPluginSelector(state, ownProps.instanceType), }), { showModalAction, @@ -142,6 +144,7 @@ export class InstancesSection extends Component { removePluginAction: PropTypes.func.isRequired, accountRole: PropTypes.string.isRequired, userRole: PropTypes.string.isRequired, + isEnabled: PropTypes.bool.isRequired, tracking: PropTypes.shape({ trackEvent: PropTypes.func, getTrackingData: PropTypes.func, @@ -297,6 +300,7 @@ export class InstancesSection extends Component { userRole, isGlobal, pluginDetails: { metadata }, + isEnabled, } = this.props; const isProjectIntegrationsExists = !!projectIntegrations.length; const disabled = !canUpdateSettings(accountRole, userRole); @@ -323,7 +327,7 @@ export class InstancesSection extends Component { onItemClick={onItemClick} isGlobal={isGlobal} /> - {this.multiple && !disabled && ( + {this.multiple && !disabled && isEnabled && (
{formatMessage(messages.addIntegrationButtonTitle)} @@ -357,7 +361,7 @@ export class InstancesSection extends Component { {formatMessage(messages.noGlobalIntegrationMessage)}

)} - {(this.multiple || !globalIntegrations.length) && !disabled && isGlobal && ( + {(this.multiple || !globalIntegrations.length) && !disabled && isGlobal && isEnabled && (
{formatMessage(messages.addIntegrationButtonTitle)} diff --git a/app/src/controllers/plugins/index.js b/app/src/controllers/plugins/index.js index 1cbd39eb65..1851d3f924 100644 --- a/app/src/controllers/plugins/index.js +++ b/app/src/controllers/plugins/index.js @@ -42,6 +42,7 @@ export { isPluginSupportsCommonCommand } from './uiExtensions/utils'; export { pluginsSelector, pluginByNameSelector, + enabledPluginSelector, availablePluginsSelector, availableGroupedPluginsSelector, createNamedIntegrationsSelector, diff --git a/app/src/controllers/plugins/selectors.js b/app/src/controllers/plugins/selectors.js index 716602def9..3a4f89c623 100644 --- a/app/src/controllers/plugins/selectors.js +++ b/app/src/controllers/plugins/selectors.js @@ -40,6 +40,8 @@ export const publicPluginsSelector = (state) => { export const pluginByNameSelector = (state, name) => pluginsSelector(state).find((plugin) => plugin.name === name); +export const enabledPluginSelector = (state, name) => pluginByNameSelector(state, name).enabled; + export const notificationPluginsSelector = createSelector(pluginsSelector, (plugins) => { return plugins.filter((item) => item.groupType === NOTIFICATION_GROUP_TYPE); });