Skip to content

Commit e550443

Browse files
Hartesicsonartech
authored andcommitted
SONAR-25899 Hide binding status in community build
GitOrigin-RevId: f9db6823ce48f3bf4ad4cd02660efcb32945d23b
1 parent cc1c828 commit e550443

File tree

2 files changed

+37
-5
lines changed

2 files changed

+37
-5
lines changed

apps/sq-server/src/main/js/app/components/nav/component/ProjectBindingStatus.tsx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@ import classNames from 'classnames';
3434
import { forwardRef } from 'react';
3535
import { FormattedMessage, useIntl } from 'react-intl';
3636
import { Image } from '~adapters/components/common/Image';
37-
import { useCurrentUser } from '~sq-server-commons/context/current-user/CurrentUserContext';
37+
import { useCurrentUser } from '~adapters/helpers/users';
38+
import { useAvailableFeatures } from '~sq-server-commons/context/available-features/withAvailableFeatures';
3839
import { getProjectSettingsUrl } from '~sq-server-commons/helpers/urls';
3940
import { useProjectBindingQuery } from '~sq-server-commons/queries/devops-integration';
4041
import { AlmKeys } from '~sq-server-commons/types/alm-settings';
42+
import { Feature } from '~sq-server-commons/types/features';
4143
import { Component } from '~sq-server-commons/types/types';
4244
import { isLoggedIn } from '~sq-server-commons/types/users';
4345
import { PULL_REQUEST_DECORATION_BINDING_CATEGORY } from '../../../../apps/settings/constants';
@@ -69,6 +71,8 @@ export function ProjectBindingStatus({
6971
}: Readonly<ProjectNavBindingStatusProps>) {
7072
const { formatMessage } = useIntl();
7173

74+
const { hasFeature } = useAvailableFeatures();
75+
7276
const { currentUser } = useCurrentUser();
7377

7478
const { data: projectBinding, isLoading: isLoadingProjectBinding } = useProjectBindingQuery(
@@ -83,6 +87,8 @@ export function ProjectBindingStatus({
8387
{ dop: formatMessage({ id: DOP_LABEL_IDS[almKey] }) },
8488
);
8589

90+
const hasBranchSupport = hasFeature(Feature.BranchSupport);
91+
8692
return (
8793
<Spinner isLoading={isLoadingProjectBinding}>
8894
{almKey && (
@@ -96,11 +102,15 @@ export function ProjectBindingStatus({
96102
/>
97103
)}
98104

99-
{!almKey && !isLoadingProjectBinding && !component.configuration?.showSettings && (
100-
<UnboundBadge className={className} isUserLoggedIn={isLoggedIn(currentUser)} />
101-
)}
105+
{hasBranchSupport &&
106+
!almKey &&
107+
!isLoadingProjectBinding &&
108+
!component.configuration?.showSettings && (
109+
<UnboundBadge className={className} isUserLoggedIn={isLoggedIn(currentUser)} />
110+
)}
102111

103-
{!almKey &&
112+
{hasBranchSupport &&
113+
!almKey &&
104114
!isLoadingProjectBinding &&
105115
isLoggedIn(currentUser) &&
106116
component.configuration?.showSettings && (

apps/sq-server/src/main/js/app/components/nav/component/__tests__/Header-test.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,28 @@ it('should show the correct help tooltip when branch support is not enabled', as
109109
});
110110

111111

112+
it('should not render project binding link if branch support is not enabled and the project is not bound', async () => {
113+
handler.emptyBranchesAndPullRequest();
114+
renderHeader(
115+
{
116+
component: mockComponent({
117+
key: 'header-project',
118+
configuration: { showSettings: true },
119+
breadcrumbs: [{ name: 'project', key: 'project', qualifier: ComponentQualifier.Project }],
120+
}),
121+
currentUser: mockLoggedInUser(),
122+
},
123+
[],
124+
'pullRequest=1001&id=compa',
125+
);
126+
127+
// Waiting for the Header to be rendered
128+
expect(await screen.findByText('project')).toBeInTheDocument();
129+
130+
// Checking that the project binding status is not rendered
131+
expect(screen.queryByText('project_navigation.binding_status.bind')).not.toBeInTheDocument();
132+
});
133+
112134
function renderHeader(
113135
props?: Partial<HeaderProps>,
114136
featureList = [Feature.BranchSupport],

0 commit comments

Comments
 (0)