diff options
Diffstat (limited to 'app/assets/javascripts/api.js')
-rw-r--r-- | app/assets/javascripts/api.js | 59 |
1 files changed, 51 insertions, 8 deletions
diff --git a/app/assets/javascripts/api.js b/app/assets/javascripts/api.js index 63b75cdb734..f469f49ce20 100644 --- a/app/assets/javascripts/api.js +++ b/app/assets/javascripts/api.js @@ -6,6 +6,7 @@ import { __ } from '~/locale'; const DEFAULT_PER_PAGE = 20; const Api = { + DEFAULT_PER_PAGE, groupsPath: '/api/:version/groups.json', groupPath: '/api/:version/groups/:id', groupMembersPath: '/api/:version/groups/:id/members', @@ -22,6 +23,7 @@ const Api = { projectLabelsPath: '/:namespace_path/:project_path/-/labels', projectFileSchemaPath: '/:namespace_path/:project_path/-/schema/:ref/:filename', projectUsersPath: '/api/:version/projects/:id/users', + projectMembersPath: '/api/:version/projects/:id/members', projectMergeRequestsPath: '/api/:version/projects/:id/merge_requests', projectMergeRequestPath: '/api/:version/projects/:id/merge_requests/:mrid', projectMergeRequestChangesPath: '/api/:version/projects/:id/merge_requests/:mrid/changes', @@ -34,6 +36,7 @@ const Api = { mergeRequestsPath: '/api/:version/merge_requests', groupLabelsPath: '/groups/:namespace_path/-/labels', issuableTemplatePath: '/:namespace_path/:project_path/templates/:type/:key', + issuableTemplatesPath: '/:namespace_path/:project_path/templates/:type', projectTemplatePath: '/api/:version/projects/:id/templates/:type/:key', projectTemplatesPath: '/api/:version/projects/:id/templates/:type', userCountsPath: '/api/:version/user_counts', @@ -70,6 +73,7 @@ const Api = { featureFlagUserLists: '/api/:version/projects/:id/feature_flags_user_lists', featureFlagUserList: '/api/:version/projects/:id/feature_flags_user_lists/:list_iid', billableGroupMembersPath: '/api/:version/groups/:id/billable_members', + containerRegistryDetailsPath: '/api/:version/registry/repositories/:id/', group(groupId, callback = () => {}) { const url = Api.buildUrl(Api.groupPath).replace(':id', groupId); @@ -106,6 +110,11 @@ const Api = { return axios.delete(url); }, + containerRegistryDetails(registryId, options = {}) { + const url = Api.buildUrl(this.containerRegistryDetailsPath).replace(':id', registryId); + return axios.get(url, options); + }, + groupMembers(id, options) { const url = Api.buildUrl(this.groupMembersPath).replace(':id', encodeURIComponent(id)); @@ -207,6 +216,12 @@ const Api = { .then(({ data }) => data); }, + inviteProjectMembers(id, data) { + const url = Api.buildUrl(this.projectMembersPath).replace(':id', encodeURIComponent(id)); + + return axios.post(url, data); + }, + // Return single project project(projectPath) { const url = Api.buildUrl(Api.projectPath).replace(':id', encodeURIComponent(projectPath)); @@ -454,17 +469,38 @@ const Api = { }, issueTemplate(namespacePath, projectPath, key, type, callback) { - const url = Api.buildUrl(Api.issuableTemplatePath) - .replace(':key', encodeURIComponent(key)) - .replace(':type', type) - .replace(':project_path', projectPath) - .replace(':namespace_path', namespacePath); + const url = this.buildIssueTemplateUrl( + Api.issuableTemplatePath, + type, + projectPath, + namespacePath, + ).replace(':key', encodeURIComponent(key)); + return axios + .get(url) + .then(({ data }) => callback(null, data)) + .catch(callback); + }, + + issueTemplates(namespacePath, projectPath, type, callback) { + const url = this.buildIssueTemplateUrl( + Api.issuableTemplatesPath, + type, + projectPath, + namespacePath, + ); return axios .get(url) .then(({ data }) => callback(null, data)) .catch(callback); }, + buildIssueTemplateUrl(path, type, projectPath, namespacePath) { + return Api.buildUrl(path) + .replace(':type', type) + .replace(':project_path', projectPath) + .replace(':namespace_path', namespacePath); + }, + users(query, options) { const url = Api.buildUrl(this.usersPath); return axios.get(url, { @@ -530,12 +566,13 @@ const Api = { }); }, - postUserStatus({ emoji, message }) { + postUserStatus({ emoji, message, availability }) { const url = Api.buildUrl(this.userPostStatusPath); return axios.put(url, { emoji, message, + availability, }); }, @@ -610,12 +647,12 @@ const Api = { return axios.get(url); }, - pipelineJobs(projectId, pipelineId) { + pipelineJobs(projectId, pipelineId, params) { const url = Api.buildUrl(this.pipelineJobsPath) .replace(':id', encodeURIComponent(projectId)) .replace(':pipeline_id', encodeURIComponent(pipelineId)); - return axios.get(url); + return axios.get(url, { params }); }, // Return all pipelines for a project or filter by query params @@ -737,6 +774,12 @@ const Api = { return axios.get(url, { params: { page } }); }, + searchFeatureFlagUserLists(id, search) { + const url = Api.buildUrl(this.featureFlagUserLists).replace(':id', id); + + return axios.get(url, { params: { search } }); + }, + createFeatureFlagUserList(id, list) { const url = Api.buildUrl(this.featureFlagUserLists).replace(':id', id); |