aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main
diff options
context:
space:
mode:
authorMatteo Mara <matteo.mara@sonarsource.com>2022-09-23 15:53:13 +0200
committersonartech <sonartech@sonarsource.com>2022-09-26 20:03:17 +0000
commitbb479f8716776ab8a68a9fd24ddabc578f889dc9 (patch)
tree9d7cba2ab17295daca347e39600ac0576ba17bf3 /server/sonar-web/src/main
parentba965061cb213d8897a8575c95d2ad944671d2eb (diff)
downloadsonarqube-bb479f8716776ab8a68a9fd24ddabc578f889dc9.tar.gz
sonarqube-bb479f8716776ab8a68a9fd24ddabc578f889dc9.zip
SONAR-17117 migrate project import feature trigger to /api/features/list endpoint
Diffstat (limited to 'server/sonar-web/src/main')
-rw-r--r--server/sonar-web/src/main/js/apps/projectDump/ProjectDumpApp.tsx22
-rw-r--r--server/sonar-web/src/main/js/apps/projectDump/__tests__/ProjectDumpApp-test.tsx6
-rw-r--r--server/sonar-web/src/main/js/types/appstate.ts1
-rw-r--r--server/sonar-web/src/main/js/types/features.ts3
4 files changed, 14 insertions, 18 deletions
diff --git a/server/sonar-web/src/main/js/apps/projectDump/ProjectDumpApp.tsx b/server/sonar-web/src/main/js/apps/projectDump/ProjectDumpApp.tsx
index 471e6f22599..0e9dd698d05 100644
--- a/server/sonar-web/src/main/js/apps/projectDump/ProjectDumpApp.tsx
+++ b/server/sonar-web/src/main/js/apps/projectDump/ProjectDumpApp.tsx
@@ -20,11 +20,13 @@
import * as React from 'react';
import { getActivity } from '../../api/ce';
import { getStatus } from '../../api/project-dump';
-import withAppStateContext from '../../app/components/app-state/withAppStateContext';
+import withAvailableFeatures, {
+ WithAvailableFeaturesProps
+} from '../../app/components/available-features/withAvailableFeatures';
import withComponentContext from '../../app/components/componentContext/withComponentContext';
import { throwGlobalError } from '../../helpers/error';
import { translate } from '../../helpers/l10n';
-import { AppState } from '../../types/appstate';
+import { Feature } from '../../types/features';
import { DumpStatus, DumpTask } from '../../types/project-dump';
import { ActivityRequestParameters, TaskStatuses, TaskTypes } from '../../types/tasks';
import { Component } from '../../types/types';
@@ -34,8 +36,7 @@ import './styles.css';
const POLL_INTERNAL = 5000;
-interface Props {
- appState: AppState;
+interface Props extends WithAvailableFeaturesProps {
component: Component;
}
@@ -84,10 +85,7 @@ export class ProjectDumpApp extends React.Component<Props, State> {
}
getLastTaskOfEachType(componentKey: string) {
- const {
- appState: { projectImportFeatureEnabled }
- } = this.props;
-
+ const projectImportFeatureEnabled = this.props.hasFeature(Feature.ProjectImport);
const all = projectImportFeatureEnabled
? [
this.getLastTask(componentKey, TaskTypes.ProjectExport),
@@ -154,10 +152,8 @@ export class ProjectDumpApp extends React.Component<Props, State> {
};
render() {
- const {
- component,
- appState: { projectImportFeatureEnabled }
- } = this.props;
+ const { component } = this.props;
+ const projectImportFeatureEnabled = this.props.hasFeature(Feature.ProjectImport);
const { lastAnalysisTask, lastExportTask, lastImportTask, status } = this.state;
return (
@@ -200,4 +196,4 @@ export class ProjectDumpApp extends React.Component<Props, State> {
}
}
-export default withComponentContext(withAppStateContext(ProjectDumpApp));
+export default withComponentContext(withAvailableFeatures(ProjectDumpApp));
diff --git a/server/sonar-web/src/main/js/apps/projectDump/__tests__/ProjectDumpApp-test.tsx b/server/sonar-web/src/main/js/apps/projectDump/__tests__/ProjectDumpApp-test.tsx
index 928cf3dd6ff..255e926dca1 100644
--- a/server/sonar-web/src/main/js/apps/projectDump/__tests__/ProjectDumpApp-test.tsx
+++ b/server/sonar-web/src/main/js/apps/projectDump/__tests__/ProjectDumpApp-test.tsx
@@ -22,7 +22,7 @@ import * as React from 'react';
import { getActivity } from '../../../api/ce';
import { getStatus } from '../../../api/project-dump';
import { mockComponent } from '../../../helpers/mocks/component';
-import { mockAppState, mockDumpStatus, mockDumpTask } from '../../../helpers/testMocks';
+import { mockDumpStatus, mockDumpTask } from '../../../helpers/testMocks';
import { waitAndUpdate } from '../../../helpers/testUtils';
import { TaskStatuses } from '../../../types/tasks';
import { ProjectDumpApp } from '../ProjectDumpApp';
@@ -58,7 +58,7 @@ it('should render correctly', async () => {
expect(wrapper).toMatchSnapshot('loaded');
- wrapper = shallowRender({ appState: mockAppState({ projectImportFeatureEnabled: false }) });
+ wrapper = shallowRender({ hasFeature: jest.fn().mockReturnValue(false) });
await waitAndUpdate(wrapper);
expect(wrapper).toMatchSnapshot('loaded without import');
});
@@ -91,7 +91,7 @@ it('should poll for task status update', async () => {
function shallowRender(overrides: Partial<ProjectDumpApp['props']> = {}) {
return shallow<ProjectDumpApp>(
<ProjectDumpApp
- appState={mockAppState({ projectImportFeatureEnabled: true })}
+ hasFeature={jest.fn().mockReturnValue(true)}
component={mockComponent()}
{...overrides}
/>
diff --git a/server/sonar-web/src/main/js/types/appstate.ts b/server/sonar-web/src/main/js/types/appstate.ts
index 62555148764..8124f143bb1 100644
--- a/server/sonar-web/src/main/js/types/appstate.ts
+++ b/server/sonar-web/src/main/js/types/appstate.ts
@@ -29,7 +29,6 @@ export interface AppState {
canAdmin?: boolean;
edition?: EditionKey;
globalPages?: Extension[];
- projectImportFeatureEnabled?: boolean;
instanceUsesDefaultAdminCredentials?: boolean;
multipleAlmEnabled?: boolean;
needIssueSync?: boolean;
diff --git a/server/sonar-web/src/main/js/types/features.ts b/server/sonar-web/src/main/js/types/features.ts
index cb4210542bc..87363ff5c2f 100644
--- a/server/sonar-web/src/main/js/types/features.ts
+++ b/server/sonar-web/src/main/js/types/features.ts
@@ -20,5 +20,6 @@
export enum Feature {
MonoRepositoryPullRequestDecoration = 'monorepo',
- RegulatoryReport = 'regulatory-reports'
+ RegulatoryReport = 'regulatory-reports',
+ ProjectImport = 'project-import'
}