aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/api
diff options
context:
space:
mode:
authorStas Vilchik <stas.vilchik@sonarsource.com>2017-06-12 03:50:27 -0700
committerStas Vilchik <stas.vilchik@sonarsource.com>2017-06-20 04:10:53 -0700
commitfbc932a882b6dec72900f5242d0cead7ff03e4b2 (patch)
tree504bae0d532ab34faa13fc4d7cf27668c3c31634 /server/sonar-web/src/main/js/api
parenta5e983797e23c5ff158483653415da05394d2bef (diff)
downloadsonarqube-fbc932a882b6dec72900f5242d0cead7ff03e4b2.tar.gz
sonarqube-fbc932a882b6dec72900f5242d0cead7ff03e4b2.zip
UI: SONAR-9355 Create onboarding tutorial (#2137)
Diffstat (limited to 'server/sonar-web/src/main/js/api')
-rw-r--r--server/sonar-web/src/main/js/api/components.js3
-rw-r--r--server/sonar-web/src/main/js/api/organizations.js10
-rw-r--r--server/sonar-web/src/main/js/api/user-tokens.js25
3 files changed, 27 insertions, 11 deletions
diff --git a/server/sonar-web/src/main/js/api/components.js b/server/sonar-web/src/main/js/api/components.js
index 867100c4fae..e024ce947f5 100644
--- a/server/sonar-web/src/main/js/api/components.js
+++ b/server/sonar-web/src/main/js/api/components.js
@@ -19,6 +19,7 @@
*/
// @flow
import { getJSON, postJSON, post } from '../helpers/request';
+import throwGlobalError from '../app/utils/throwGlobalError';
export function getComponents(data?: Object) {
const url = '/api/projects/search';
@@ -55,7 +56,7 @@ export function createProject(
}
) {
const url = '/api/projects/create';
- return postJSON(url, data);
+ return postJSON(url, data).catch(throwGlobalError);
}
export function searchProjectTags(data?: { ps?: number, q?: string }) {
diff --git a/server/sonar-web/src/main/js/api/organizations.js b/server/sonar-web/src/main/js/api/organizations.js
index 097a17ce5cb..7ca0263ba81 100644
--- a/server/sonar-web/src/main/js/api/organizations.js
+++ b/server/sonar-web/src/main/js/api/organizations.js
@@ -20,6 +20,7 @@
// @flow
import { getJSON, post, postJSON } from '../helpers/request';
import type { Organization } from '../store/organizations/duck';
+import throwGlobalError from '../app/utils/throwGlobalError';
export const getOrganizations = (organizations?: Array<string>) => {
const data = {};
@@ -44,7 +45,9 @@ type GetOrganizationNavigation = {
};
export const getOrganization = (key: string): Promise<GetOrganizationType> => {
- return getOrganizations([key]).then(r => r.organizations.find(o => o.key === key));
+ return getOrganizations([key])
+ .then(r => r.organizations.find(o => o.key === key))
+ .catch(throwGlobalError);
};
export const getOrganizationNavigation = (key: string): Promise<GetOrganizationNavigation> => {
@@ -52,12 +55,13 @@ export const getOrganizationNavigation = (key: string): Promise<GetOrganizationN
};
export const createOrganization = (fields: {}): Promise<Organization> =>
- postJSON('/api/organizations/create', fields).then(r => r.organization);
+ postJSON('/api/organizations/create', fields).then(r => r.organization, throwGlobalError);
export const updateOrganization = (key: string, changes: {}) =>
post('/api/organizations/update', { key, ...changes });
-export const deleteOrganization = (key: string) => post('/api/organizations/delete', { key });
+export const deleteOrganization = (key: string) =>
+ post('/api/organizations/delete', { key }).catch(throwGlobalError);
export const searchMembers = (
data: { organization?: string, p?: number, ps?: number, q?: string, selected?: string }
diff --git a/server/sonar-web/src/main/js/api/user-tokens.js b/server/sonar-web/src/main/js/api/user-tokens.js
index 4b3b97e2bba..3947b07f1be 100644
--- a/server/sonar-web/src/main/js/api/user-tokens.js
+++ b/server/sonar-web/src/main/js/api/user-tokens.js
@@ -17,14 +17,16 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+// @flow
import { getJSON, postJSON, post } from '../helpers/request';
+import throwGlobalError from '../app/utils/throwGlobalError';
/**
* List tokens for given user login
* @param {string} login
* @returns {Promise}
*/
-export function getTokens(login) {
+export function getTokens(login: string) {
const url = '/api/user_tokens/search';
const data = { login };
return getJSON(url, data).then(r => r.userTokens);
@@ -36,10 +38,16 @@ export function getTokens(login) {
* @param {string} tokenName
* @returns {Promise}
*/
-export function generateToken(userLogin, tokenName) {
+export function generateToken(
+ tokenName: string,
+ userLogin?: string
+): Promise<{ name: string, token: string }> {
const url = '/api/user_tokens/generate';
- const data = { login: userLogin, name: tokenName };
- return postJSON(url, data);
+ const data: { [string]: string } = { name: tokenName };
+ if (userLogin) {
+ data.login = userLogin;
+ }
+ return postJSON(url, data).catch(throwGlobalError);
}
/**
@@ -48,8 +56,11 @@ export function generateToken(userLogin, tokenName) {
* @param {string} tokenName
* @returns {Promise}
*/
-export function revokeToken(userLogin, tokenName) {
+export function revokeToken(tokenName: string, userLogin?: string) {
const url = '/api/user_tokens/revoke';
- const data = { login: userLogin, name: tokenName };
- return post(url, data);
+ const data: { [string]: string } = { name: tokenName };
+ if (userLogin) {
+ data.login = userLogin;
+ }
+ return post(url, data).catch(throwGlobalError);
}