aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/coding-rules
diff options
context:
space:
mode:
authorMatteo Mara <matteo.mara@sonarsource.com>2022-10-10 16:07:02 +0200
committersonartech <sonartech@sonarsource.com>2022-10-12 20:03:43 +0000
commit687e4c8d3830ff68fe39f60d8db18e9afe007bc6 (patch)
tree347640c307b703934a7f52e386c1f3e7904badb7 /server/sonar-web/src/main/js/apps/coding-rules
parentb7782da37057932f728f41b11553bc0592b0a141 (diff)
downloadsonarqube-687e4c8d3830ff68fe39f60d8db18e9afe007bc6.tar.gz
sonarqube-687e4c8d3830ff68fe39f60d8db18e9afe007bc6.zip
SONAR-17118 migrate branch support flag to features/list API
Diffstat (limited to 'server/sonar-web/src/main/js/apps/coding-rules')
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsIssues.tsx13
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleDetailsIssues-test.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/RuleDetails-test.tsx.snap2
3 files changed, 9 insertions, 9 deletions
diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsIssues.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsIssues.tsx
index 1a6a3ebd363..8ca75699c7b 100644
--- a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsIssues.tsx
+++ b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsIssues.tsx
@@ -19,18 +19,19 @@
*/
import * as React from 'react';
import { getFacet } from '../../../api/issues';
-import withAppStateContext from '../../../app/components/app-state/withAppStateContext';
+import withAvailableFeatures, {
+ WithAvailableFeaturesProps
+} from '../../../app/components/available-features/withAvailableFeatures';
import Link from '../../../components/common/Link';
import Tooltip from '../../../components/controls/Tooltip';
import DeferredSpinner from '../../../components/ui/DeferredSpinner';
import { translate } from '../../../helpers/l10n';
import { formatMeasure } from '../../../helpers/measures';
import { getIssuesUrl } from '../../../helpers/urls';
-import { AppState } from '../../../types/appstate';
+import { Feature } from '../../../types/features';
import { RuleDetails } from '../../../types/types';
-interface Props {
- appState: AppState;
+interface Props extends WithAvailableFeaturesProps {
ruleDetails: Pick<RuleDetails, 'key' | 'type'>;
}
@@ -118,7 +119,7 @@ export class RuleDetailsIssues extends React.PureComponent<Props, State> {
</span>
);
- if (!this.props.appState.branchesEnabled) {
+ if (!this.props.hasFeature(Feature.BranchSupport)) {
return totalItem;
}
@@ -176,4 +177,4 @@ export class RuleDetailsIssues extends React.PureComponent<Props, State> {
}
}
-export default withAppStateContext(RuleDetailsIssues);
+export default withAvailableFeatures(RuleDetailsIssues);
diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleDetailsIssues-test.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleDetailsIssues-test.tsx
index 7aeb0542100..16865c5ea2e 100644
--- a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleDetailsIssues-test.tsx
+++ b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleDetailsIssues-test.tsx
@@ -20,7 +20,6 @@
import { shallow } from 'enzyme';
import * as React from 'react';
import { getFacet } from '../../../../api/issues';
-import { mockAppState } from '../../../../helpers/testMocks';
import { waitAndUpdate } from '../../../../helpers/testUtils';
import { RuleDetailsIssues } from '../RuleDetailsIssues';
@@ -60,7 +59,7 @@ it('should fetch issues and render', async () => {
function shallowRender(props: Partial<RuleDetailsIssues['props']> = {}) {
return shallow(
<RuleDetailsIssues
- appState={mockAppState({ branchesEnabled: false })}
+ hasFeature={jest.fn().mockReturnValue(false)}
ruleDetails={{ key: 'foo', type: 'BUG' }}
{...props}
/>
diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/RuleDetails-test.tsx.snap b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/RuleDetails-test.tsx.snap
index 39780c67157..450d9d3ecc0 100644
--- a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/RuleDetails-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/RuleDetails-test.tsx.snap
@@ -174,7 +174,7 @@ exports[`should render correctly: loaded 1`] = `
}
}
/>
- <withAppStateContext(RuleDetailsIssues)
+ <withAvailableFeaturesContext(RuleDetailsIssues)
ruleDetails={
Object {
"createdAt": "2014-12-16T17:26:54+0100",