Skip to content

Commit

Permalink
EPMRPP-98423 || Error occurs when clicking on Add integration with di…
Browse files Browse the repository at this point in the history
…sabled BTS plugin (#4160)
  • Loading branch information
BlazarQSO authored Jan 17, 2025
1 parent 2ac2cd9 commit 02b255a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
removePluginAction,
addIntegrationAction,
removeProjectIntegrationsByTypeAction,
enabledPluginSelector,
} from 'controllers/plugins';
import { showModalAction } from 'controllers/modal';
import {
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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);
Expand All @@ -323,7 +327,7 @@ export class InstancesSection extends Component {
onItemClick={onItemClick}
isGlobal={isGlobal}
/>
{this.multiple && !disabled && (
{this.multiple && !disabled && isEnabled && (
<div className={cx('add-integration-button')}>
<GhostButton icon={PlusIcon} onClick={this.addIntegrationClickHandler}>
{formatMessage(messages.addIntegrationButtonTitle)}
Expand Down Expand Up @@ -357,7 +361,7 @@ export class InstancesSection extends Component {
{formatMessage(messages.noGlobalIntegrationMessage)}
</p>
)}
{(this.multiple || !globalIntegrations.length) && !disabled && isGlobal && (
{(this.multiple || !globalIntegrations.length) && !disabled && isGlobal && isEnabled && (
<div className={cx('add-integration-button')}>
<GhostButton icon={PlusIcon} onClick={this.addIntegrationClickHandler}>
{formatMessage(messages.addIntegrationButtonTitle)}
Expand Down
1 change: 1 addition & 0 deletions app/src/controllers/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export { isPluginSupportsCommonCommand } from './uiExtensions/utils';
export {
pluginsSelector,
pluginByNameSelector,
enabledPluginSelector,
availablePluginsSelector,
availableGroupedPluginsSelector,
createNamedIntegrationsSelector,
Expand Down
2 changes: 2 additions & 0 deletions app/src/controllers/plugins/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down

0 comments on commit 02b255a

Please sign in to comment.