Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EPMRPP-76542 || Integrations section hiding depending on flag #3079

Merged
merged 3 commits into from
Apr 27, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import React, { Component, Fragment } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames/bind';
Expand Down Expand Up @@ -294,6 +293,7 @@ export class InstancesSection extends Component {
accountRole,
userRole,
isGlobal,
pluginDetails: { metadata },
} = this.props;
const isProjectIntegrationsExists = !!projectIntegrations.length;
const disabled = !canUpdateSettings(accountRole, userRole);
Expand All @@ -303,55 +303,61 @@ export class InstancesSection extends Component {

return (
<div className={cx('instances-section')}>
{isProjectIntegrationsExists && !isGlobal && (
<Fragment>
{(!metadata || metadata.isIntegrationsAllowed) && (
<React.Fragment>
AmsterGet marked this conversation as resolved.
Show resolved Hide resolved
{isProjectIntegrationsExists && !isGlobal && (
<Fragment>
<InstancesList
blocked={disabled}
title={formatMessage(
this.multiple ? messages.projectIntegrations : messages.projectIntegration,
)}
items={projectIntegrations}
onItemClick={onItemClick}
isGlobal={isGlobal}
/>
{this.multiple && !disabled && (
<div className={cx('add-integration-button')}>
<GhostButton icon={PlusIcon} onClick={this.addProjectIntegrationClickHandler}>
{formatMessage(messages.addIntegrationButtonTitle)}
</GhostButton>
</div>
)}
</Fragment>
)}
<InstancesList
blocked={disabled}
blocked={!isGlobal}
title={formatMessage(
this.multiple ? messages.projectIntegrations : messages.projectIntegration,
isGlobal && this.multiple
? messages.allGlobalIntegrations
: globalIntegrationMessage,
{
pluginName: this.props.title,
},
)}
items={projectIntegrations}
items={globalIntegrations}
onItemClick={onItemClick}
isGlobal={isGlobal}
{...(isGlobal
? {}
: {
disabled: isProjectIntegrationsExists,
disabledHint: formatMessage(messages.globalIntegrationsDisabledHint),
})}
/>
{this.multiple && !disabled && (
{!globalIntegrations.length && (
<p className={cx('no-items-message')}>
{formatMessage(messages.noGlobalIntegrationMessage)}
</p>
)}
{(this.multiple || !globalIntegrations.length) && !disabled && isGlobal && (
<div className={cx('add-integration-button')}>
<GhostButton icon={PlusIcon} onClick={this.addProjectIntegrationClickHandler}>
{formatMessage(messages.addIntegrationButtonTitle)}
</GhostButton>
</div>
)}
</Fragment>
)}
<InstancesList
blocked={!isGlobal}
title={formatMessage(
isGlobal && this.multiple ? messages.allGlobalIntegrations : globalIntegrationMessage,
{
pluginName: this.props.title,
},
)}
items={globalIntegrations}
onItemClick={onItemClick}
isGlobal={isGlobal}
{...(isGlobal
? {}
: {
disabled: isProjectIntegrationsExists,
disabledHint: formatMessage(messages.globalIntegrationsDisabledHint),
})}
/>
{!globalIntegrations.length && (
<p className={cx('no-items-message')}>
{formatMessage(messages.noGlobalIntegrationMessage)}
</p>
)}
{(this.multiple || !globalIntegrations.length) && !disabled && isGlobal && (
<div className={cx('add-integration-button')}>
<GhostButton icon={PlusIcon} onClick={this.addProjectIntegrationClickHandler}>
{formatMessage(messages.addIntegrationButtonTitle)}
</GhostButton>
</div>
</React.Fragment>
)}
{isGlobal && !this.builtin && (
<Fragment>
Expand Down