From c2954e35714c703c84b0e4c2af4e0249751516b6 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Fri, 1 Sep 2017 16:33:48 +0200 Subject: SONAR-9736 fix access to project admin pages --- server/sonar-web/src/main/js/api/quality-gates.ts | 25 ++++++++++++++++++---- .../sonar-web/src/main/js/api/quality-profiles.ts | 21 +++++++++++++++++- 2 files changed, 41 insertions(+), 5 deletions(-) (limited to 'server/sonar-web/src/main/js/api') diff --git a/server/sonar-web/src/main/js/api/quality-gates.ts b/server/sonar-web/src/main/js/api/quality-gates.ts index b07f1a89104..2839607c23c 100644 --- a/server/sonar-web/src/main/js/api/quality-gates.ts +++ b/server/sonar-web/src/main/js/api/quality-gates.ts @@ -24,11 +24,21 @@ export function fetchQualityGatesAppDetails(): Promise { return getJSON('/api/qualitygates/app').catch(throwGlobalError); } -export function fetchQualityGates(): Promise { +export interface QualityGate { + isDefault?: boolean; + id: string; + name: string; +} + +export function fetchQualityGates(): Promise { return getJSON('/api/qualitygates/list').then( r => r.qualitygates.map((qualityGate: any) => { - return { ...qualityGate, isDefault: qualityGate.id === r.default }; + return { + ...qualityGate, + id: String(qualityGate.id), + isDefault: qualityGate.id === r.default + }; }), throwGlobalError ); @@ -74,8 +84,15 @@ export function deleteCondition(id: string): Promise { return post('/api/qualitygates/delete_condition', { id }); } -export function getGateForProject(projectKey: string): Promise { - return getJSON('/api/qualitygates/get_by_project', { projectKey }).then(r => r.qualityGate); +export function getGateForProject(projectKey: string): Promise { + return getJSON('/api/qualitygates/get_by_project', { projectKey }).then( + r => + r.qualityGate && { + id: r.qualityGate.id, + isDefault: r.qualityGate.default, + name: r.qualityGate.name + } + ); } export function associateGateWithProject( diff --git a/server/sonar-web/src/main/js/api/quality-profiles.ts b/server/sonar-web/src/main/js/api/quality-profiles.ts index 630effa1831..9ee43f3eabf 100644 --- a/server/sonar-web/src/main/js/api/quality-profiles.ts +++ b/server/sonar-web/src/main/js/api/quality-profiles.ts @@ -27,10 +27,29 @@ import { RequestData } from '../helpers/request'; +export interface Profile { + key: string; + name: string; + language: string; + languageName: string; + isInherited?: boolean; + parentKey?: string; + parentName?: string; + isDefault?: boolean; + activeRuleCount: number; + activeDeprecatedRuleCount: number; + rulesUpdatedAt?: string; + lastUsed?: string; + userUpdatedAt?: string; + organization: string; + isBuiltIn?: boolean; + projectCount?: number; +} + export function searchQualityProfiles(data: { organization?: string; projectKey?: string; -}): Promise { +}): Promise { return getJSON('/api/qualityprofiles/search', data).then(r => r.profiles); } -- cgit v1.2.3