From e8d2c2579383897a1dd7f9debd359abe8ae8373d Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Tue, 20 Jul 2021 09:55:51 +0000 Subject: Add latest changes from gitlab-org/gitlab@14-1-stable-ee --- app/assets/javascripts/api/analytics_api.js | 19 +++++++++++++++++++ app/assets/javascripts/api/constants.js | 1 - app/assets/javascripts/api/groups_api.js | 2 +- app/assets/javascripts/api/projects_api.js | 2 +- app/assets/javascripts/api/user_api.js | 10 +++++++--- 5 files changed, 28 insertions(+), 6 deletions(-) delete mode 100644 app/assets/javascripts/api/constants.js (limited to 'app/assets/javascripts/api') diff --git a/app/assets/javascripts/api/analytics_api.js b/app/assets/javascripts/api/analytics_api.js index 58494c5a2b8..fd9b0160b0d 100644 --- a/app/assets/javascripts/api/analytics_api.js +++ b/app/assets/javascripts/api/analytics_api.js @@ -1,6 +1,8 @@ import axios from '~/lib/utils/axios_utils'; import { buildApiUrl } from './api_utils'; +const GROUP_VSA_PATH_BASE = + '/groups/:id/-/analytics/value_stream_analytics/value_streams/:value_stream_id/stages/:stage_id'; const PROJECT_VSA_PATH_BASE = '/:project_path/-/analytics/value_stream_analytics/value_streams'; const PROJECT_VSA_STAGES_PATH = `${PROJECT_VSA_PATH_BASE}/:value_stream_id/stages`; @@ -13,6 +15,12 @@ const buildProjectValueStreamPath = (projectPath, valueStreamId = null) => { return buildApiUrl(PROJECT_VSA_PATH_BASE).replace(':project_path', projectPath); }; +const buildGroupValueStreamPath = ({ groupId, valueStreamId = null, stageId = null }) => + buildApiUrl(GROUP_VSA_PATH_BASE) + .replace(':id', groupId) + .replace(':value_stream_id', valueStreamId) + .replace(':stage_id', stageId); + export const getProjectValueStreams = (projectPath) => { const url = buildProjectValueStreamPath(projectPath); return axios.get(url); @@ -30,3 +38,14 @@ export const getProjectValueStreamStageData = ({ requestPath, stageId, params }) export const getProjectValueStreamMetrics = (requestPath, params) => axios.get(requestPath, { params }); + +/** + * Shared group VSA paths + * We share some endpoints across and group and project level VSA + * When used for project level VSA, requests should include the `project_id` in the params object + */ + +export const getValueStreamStageMedian = ({ groupId, valueStreamId, stageId }, params = {}) => { + const stageBase = buildGroupValueStreamPath({ groupId, valueStreamId, stageId }); + return axios.get(`${stageBase}/median`, { params }); +}; diff --git a/app/assets/javascripts/api/constants.js b/app/assets/javascripts/api/constants.js deleted file mode 100644 index b6c720a85f3..00000000000 --- a/app/assets/javascripts/api/constants.js +++ /dev/null @@ -1 +0,0 @@ -export const DEFAULT_PER_PAGE = 20; diff --git a/app/assets/javascripts/api/groups_api.js b/app/assets/javascripts/api/groups_api.js index d6c9e1d42cc..a563afc6abb 100644 --- a/app/assets/javascripts/api/groups_api.js +++ b/app/assets/javascripts/api/groups_api.js @@ -1,6 +1,6 @@ +import { DEFAULT_PER_PAGE } from '~/api'; import axios from '../lib/utils/axios_utils'; import { buildApiUrl } from './api_utils'; -import { DEFAULT_PER_PAGE } from './constants'; const GROUPS_PATH = '/api/:version/groups.json'; const DESCENDANT_GROUPS_PATH = '/api/:version/groups/:id/descendant_groups'; diff --git a/app/assets/javascripts/api/projects_api.js b/app/assets/javascripts/api/projects_api.js index d9a2467cff3..1cd7fb0b954 100644 --- a/app/assets/javascripts/api/projects_api.js +++ b/app/assets/javascripts/api/projects_api.js @@ -1,6 +1,6 @@ +import { DEFAULT_PER_PAGE } from '~/api'; import axios from '../lib/utils/axios_utils'; import { buildApiUrl } from './api_utils'; -import { DEFAULT_PER_PAGE } from './constants'; const PROJECTS_PATH = '/api/:version/projects.json'; diff --git a/app/assets/javascripts/api/user_api.js b/app/assets/javascripts/api/user_api.js index 27901120c53..09995fad628 100644 --- a/app/assets/javascripts/api/user_api.js +++ b/app/assets/javascripts/api/user_api.js @@ -1,8 +1,8 @@ -import { deprecatedCreateFlash as flash } from '~/flash'; +import { DEFAULT_PER_PAGE } from '~/api'; +import createFlash from '~/flash'; import { __ } from '~/locale'; import axios from '../lib/utils/axios_utils'; import { buildApiUrl } from './api_utils'; -import { DEFAULT_PER_PAGE } from './constants'; const USER_COUNTS_PATH = '/api/:version/user_counts'; const USERS_PATH = '/api/:version/users.json'; @@ -52,7 +52,11 @@ export function getUserProjects(userId, query, options, callback) { params: { ...defaults, ...options }, }) .then(({ data }) => callback(data)) - .catch(() => flash(__('Something went wrong while fetching projects'))); + .catch(() => + createFlash({ + message: __('Something went wrong while fetching projects'), + }), + ); } export function updateUserStatus({ emoji, message, availability, clearStatusAfter }) { -- cgit v1.2.3