aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWouter Admiraal <wouter.admiraal@sonarsource.com>2020-12-18 16:46:42 +0100
committersonartech <sonartech@sonarsource.com>2020-12-22 20:09:39 +0000
commita0ee873fb078986f9794213cd844f2f73499ceda (patch)
tree1d4ac25d271e05c24da17fd47097e27dd905b72b
parentbdeff0460ea672a798a89a4e7a380ef69c94529b (diff)
downloadsonarqube-a0ee873fb078986f9794213cd844f2f73499ceda.tar.gz
sonarqube-a0ee873fb078986f9794213cd844f2f73499ceda.zip
SONAR-14292 Allow to directly link to a specific ALM Integration settings tab
-rw-r--r--server/sonar-web/src/main/js/apps/settings/components/__tests__/__snapshots__/AdditionalCategories-test.tsx.snap2
-rw-r--r--server/sonar-web/src/main/js/apps/settings/components/__tests__/__snapshots__/AppContainer-test.tsx.snap2
-rw-r--r--server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmIntegration.tsx35
-rw-r--r--server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmIntegration-test.tsx5
4 files changed, 27 insertions, 17 deletions
diff --git a/server/sonar-web/src/main/js/apps/settings/components/__tests__/__snapshots__/AdditionalCategories-test.tsx.snap b/server/sonar-web/src/main/js/apps/settings/components/__tests__/__snapshots__/AdditionalCategories-test.tsx.snap
index e4b23d5b084..65a43008441 100644
--- a/server/sonar-web/src/main/js/apps/settings/components/__tests__/__snapshots__/AdditionalCategories-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/settings/components/__tests__/__snapshots__/AdditionalCategories-test.tsx.snap
@@ -59,7 +59,7 @@ exports[`should render additional categories component correctly 3`] = `
`;
exports[`should render additional categories component correctly 4`] = `
-<Connect(withAppState(AlmIntegration))
+<withRouter(Connect(withAppState(AlmIntegration)))
component={
Object {
"breadcrumbs": Array [],
diff --git a/server/sonar-web/src/main/js/apps/settings/components/__tests__/__snapshots__/AppContainer-test.tsx.snap b/server/sonar-web/src/main/js/apps/settings/components/__tests__/__snapshots__/AppContainer-test.tsx.snap
index a650f8e78fa..96e4786b9d9 100644
--- a/server/sonar-web/src/main/js/apps/settings/components/__tests__/__snapshots__/AppContainer-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/settings/components/__tests__/__snapshots__/AppContainer-test.tsx.snap
@@ -28,7 +28,7 @@ exports[`should render ALM integration correctly 1`] = `
<div
className="side-tabs-main"
>
- <Connect(withAppState(AlmIntegration))
+ <withRouter(Connect(withAppState(AlmIntegration)))
selectedCategory="almintegration"
/>
</div>
diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmIntegration.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmIntegration.tsx
index 0bb9f013a85..59a85559dd5 100644
--- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmIntegration.tsx
+++ b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmIntegration.tsx
@@ -18,6 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import * as React from 'react';
+import { WithRouterProps } from 'react-router';
import {
countBindedProjects,
deleteConfiguration,
@@ -25,6 +26,7 @@ import {
validateAlmSettings
} from '../../../../api/alm-settings';
import { withAppState } from '../../../../components/hoc/withAppState';
+import { withRouter } from '../../../../components/hoc/withRouter';
import {
AlmBindingDefinition,
AlmKeys,
@@ -35,7 +37,7 @@ import {
import AlmIntegrationRenderer from './AlmIntegrationRenderer';
import { ALM_KEY_LIST } from './utils';
-interface Props {
+interface Props extends Pick<WithRouterProps, 'location'> {
appState: Pick<T.AppState, 'branchesEnabled' | 'multipleAlmEnabled'>;
component?: T.Component;
}
@@ -52,18 +54,23 @@ interface State {
export class AlmIntegration extends React.PureComponent<Props, State> {
mounted = false;
- state: State = {
- currentAlm: AlmKeys.GitHub,
- definitions: {
- [AlmKeys.Azure]: [],
- [AlmKeys.Bitbucket]: [],
- [AlmKeys.GitHub]: [],
- [AlmKeys.GitLab]: []
- },
- definitionStatus: {},
- loadingAlmDefinitions: true,
- loadingProjectCount: false
- };
+ state: State;
+
+ constructor(props: Props) {
+ super(props);
+ this.state = {
+ currentAlm: props.location.query.alm || AlmKeys.GitHub,
+ definitions: {
+ [AlmKeys.Azure]: [],
+ [AlmKeys.Bitbucket]: [],
+ [AlmKeys.GitHub]: [],
+ [AlmKeys.GitLab]: []
+ },
+ definitionStatus: {},
+ loadingAlmDefinitions: true,
+ loadingProjectCount: false
+ };
+ }
componentDidMount() {
this.mounted = true;
@@ -205,4 +212,4 @@ export class AlmIntegration extends React.PureComponent<Props, State> {
}
}
-export default withAppState(AlmIntegration);
+export default withRouter(withAppState(AlmIntegration));
diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmIntegration-test.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmIntegration-test.tsx
index d24361dbfde..a2b5dae9195 100644
--- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmIntegration-test.tsx
+++ b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmIntegration-test.tsx
@@ -26,6 +26,7 @@ import {
getAlmDefinitions,
validateAlmSettings
} from '../../../../../api/alm-settings';
+import { mockLocation } from '../../../../../helpers/testMocks';
import { AlmKeys, AlmSettingsBindingStatusType } from '../../../../../types/alm-settings';
import { AlmIntegration } from '../AlmIntegration';
@@ -158,5 +159,7 @@ it('should fetch settings', async () => {
});
function shallowRender() {
- return shallow<AlmIntegration>(<AlmIntegration appState={{ branchesEnabled: true }} />);
+ return shallow<AlmIntegration>(
+ <AlmIntegration appState={{ branchesEnabled: true }} location={mockLocation()} />
+ );
}