aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/helpers
diff options
context:
space:
mode:
authorWouter Admiraal <wouter.admiraal@sonarsource.com>2021-06-15 09:43:43 +0200
committersonartech <sonartech@sonarsource.com>2021-06-17 20:03:07 +0000
commitdee4f363b8bdebe59126a5464e1ebc4fc3202932 (patch)
treefbe1296dd813a2db3f232cf199755bab0980d887 /server/sonar-web/src/main/js/helpers
parentcf6800f19682deb0450bcd2269910cf3e1fb2bdb (diff)
downloadsonarqube-dee4f363b8bdebe59126a5464e1ebc4fc3202932.tar.gz
sonarqube-dee4f363b8bdebe59126a5464e1ebc4fc3202932.zip
SONAR-14934 Improve the manual tutorial
Diffstat (limited to 'server/sonar-web/src/main/js/helpers')
-rw-r--r--server/sonar-web/src/main/js/helpers/__tests__/urls-test.ts35
-rw-r--r--server/sonar-web/src/main/js/helpers/urls.ts17
2 files changed, 49 insertions, 3 deletions
diff --git a/server/sonar-web/src/main/js/helpers/__tests__/urls-test.ts b/server/sonar-web/src/main/js/helpers/__tests__/urls-test.ts
index bed9b1df8fb..de610e43f4e 100644
--- a/server/sonar-web/src/main/js/helpers/__tests__/urls-test.ts
+++ b/server/sonar-web/src/main/js/helpers/__tests__/urls-test.ts
@@ -17,6 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+import { AlmKeys } from '../../types/alm-settings';
import { ComponentQualifier } from '../../types/component';
import { IssueType } from '../../types/issues';
import {
@@ -25,7 +26,9 @@ import {
getComponentIssuesUrl,
getComponentOverviewUrl,
getComponentSecurityHotspotsUrl,
+ getGlobalSettingsUrl,
getIssuesUrl,
+ getProjectSettingsUrl,
getQualityGatesUrl,
getQualityGateUrl,
stripTrailingSlash
@@ -67,7 +70,7 @@ describe('#getComponentIssuesUrl', () => {
});
});
-describe('getComponentSecurityHotspotsUrl', () => {
+describe('#getComponentSecurityHotspotsUrl', () => {
it('should work with no extra parameters', () => {
expect(getComponentSecurityHotspotsUrl(SIMPLE_COMPONENT_KEY, {})).toEqual({
pathname: '/security_hotspots',
@@ -88,7 +91,7 @@ describe('getComponentSecurityHotspotsUrl', () => {
});
});
-describe('getComponentOverviewUrl', () => {
+describe('#getComponentOverviewUrl', () => {
it('should return a portfolio url for a portfolio', () => {
expect(getComponentOverviewUrl(SIMPLE_COMPONENT_KEY, ComponentQualifier.Portfolio)).toEqual({
pathname: '/portfolio',
@@ -142,7 +145,7 @@ describe('#getQualityGate(s)Url', () => {
});
});
-describe('getIssuesUrl', () => {
+describe('#getIssuesUrl', () => {
it('should work as expected', () => {
const type = IssueType.Bug;
expect(getIssuesUrl({ type })).toEqual({
@@ -151,3 +154,29 @@ describe('getIssuesUrl', () => {
});
});
});
+
+describe('#getGlobalSettingsUrl', () => {
+ it('should work as expected', () => {
+ expect(getGlobalSettingsUrl('foo')).toEqual({
+ pathname: '/admin/settings',
+ query: { category: 'foo' }
+ });
+ expect(getGlobalSettingsUrl('foo', { alm: AlmKeys.GitHub })).toEqual({
+ pathname: '/admin/settings',
+ query: { category: 'foo', alm: AlmKeys.GitHub }
+ });
+ });
+});
+
+describe('#getProjectSettingsUrl', () => {
+ it('should work as expected', () => {
+ expect(getProjectSettingsUrl('foo')).toEqual({
+ pathname: '/project/settings',
+ query: { id: 'foo' }
+ });
+ expect(getProjectSettingsUrl('foo', 'bar')).toEqual({
+ pathname: '/project/settings',
+ query: { id: 'foo', category: 'bar' }
+ });
+ });
+});
diff --git a/server/sonar-web/src/main/js/helpers/urls.ts b/server/sonar-web/src/main/js/helpers/urls.ts
index 1adb6ee8ec6..992c0f76a90 100644
--- a/server/sonar-web/src/main/js/helpers/urls.ts
+++ b/server/sonar-web/src/main/js/helpers/urls.ts
@@ -221,6 +221,23 @@ export function getQualityGatesUrl(): Location {
};
}
+export function getGlobalSettingsUrl(
+ category?: string,
+ query?: T.Dict<string | undefined | number>
+): Location {
+ return {
+ pathname: '/admin/settings',
+ query: { category, ...query }
+ };
+}
+
+export function getProjectSettingsUrl(id: string, category?: string): Location {
+ return {
+ pathname: '/project/settings',
+ query: { id, category }
+ };
+}
+
/**
* Generate URL for the rules page
*/