diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
commit | 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch) | |
tree | a77e7fe7a93de11213032ed4ab1f33a3db51b738 /app/assets/javascripts/releases/stores | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'app/assets/javascripts/releases/stores')
3 files changed, 31 insertions, 7 deletions
diff --git a/app/assets/javascripts/releases/stores/modules/detail/actions.js b/app/assets/javascripts/releases/stores/modules/detail/actions.js index 3bc427dfa16..2026eeba880 100644 --- a/app/assets/javascripts/releases/stores/modules/detail/actions.js +++ b/app/assets/javascripts/releases/stores/modules/detail/actions.js @@ -3,7 +3,10 @@ import api from '~/api'; import createFlash from '~/flash'; import { s__ } from '~/locale'; import { redirectTo } from '~/lib/utils/url_utility'; -import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; +import { + convertObjectPropsToCamelCase, + convertObjectPropsToSnakeCase, +} from '~/lib/utils/common_utils'; export const requestRelease = ({ commit }) => commit(types.REQUEST_RELEASE); export const receiveReleaseSuccess = ({ commit }, data) => @@ -54,13 +57,18 @@ export const updateRelease = ({ dispatch, state, getters }) => { const { release } = state; const milestones = release.milestones ? release.milestones.map(milestone => milestone.title) : []; + const updatedRelease = convertObjectPropsToSnakeCase( + { + name: release.name, + description: release.description, + milestones, + }, + { deep: true }, + ); + return ( api - .updateRelease(state.projectId, state.tagName, { - name: release.name, - description: release.description, - milestones, - }) + .updateRelease(state.projectId, state.tagName, updatedRelease) /** * Currently, we delete all existing links and then @@ -91,7 +99,11 @@ export const updateRelease = ({ dispatch, state, getters }) => { // Create a new link for each link in the form return Promise.all( getters.releaseLinksToCreate.map(l => - api.createReleaseLink(state.projectId, release.tagName, l), + api.createReleaseLink( + state.projectId, + release.tagName, + convertObjectPropsToSnakeCase(l, { deep: true }), + ), ), ); }) @@ -118,6 +130,10 @@ export const updateAssetLinkName = ({ commit }, { linkIdToUpdate, newName }) => commit(types.UPDATE_ASSET_LINK_NAME, { linkIdToUpdate, newName }); }; +export const updateAssetLinkType = ({ commit }, { linkIdToUpdate, newType }) => { + commit(types.UPDATE_ASSET_LINK_TYPE, { linkIdToUpdate, newType }); +}; + export const removeAssetLink = ({ commit }, linkIdToRemove) => { commit(types.REMOVE_ASSET_LINK, linkIdToRemove); }; diff --git a/app/assets/javascripts/releases/stores/modules/detail/mutation_types.js b/app/assets/javascripts/releases/stores/modules/detail/mutation_types.js index 1d6356990ce..7b694120126 100644 --- a/app/assets/javascripts/releases/stores/modules/detail/mutation_types.js +++ b/app/assets/javascripts/releases/stores/modules/detail/mutation_types.js @@ -13,4 +13,5 @@ export const RECEIVE_UPDATE_RELEASE_ERROR = 'RECEIVE_UPDATE_RELEASE_ERROR'; export const ADD_EMPTY_ASSET_LINK = 'ADD_EMPTY_ASSET_LINK'; export const UPDATE_ASSET_LINK_URL = 'UPDATE_ASSET_LINK_URL'; export const UPDATE_ASSET_LINK_NAME = 'UPDATE_ASSET_LINK_NAME'; +export const UPDATE_ASSET_LINK_TYPE = 'UPDATE_ASSET_LINK_TYPE'; export const REMOVE_ASSET_LINK = 'REMOVE_ASSET_LINK'; diff --git a/app/assets/javascripts/releases/stores/modules/detail/mutations.js b/app/assets/javascripts/releases/stores/modules/detail/mutations.js index 5c29b402cba..ca544151323 100644 --- a/app/assets/javascripts/releases/stores/modules/detail/mutations.js +++ b/app/assets/javascripts/releases/stores/modules/detail/mutations.js @@ -1,5 +1,6 @@ import * as types from './mutation_types'; import { uniqueId, cloneDeep } from 'lodash'; +import { DEFAULT_ASSET_LINK_TYPE } from '../../../constants'; const findReleaseLink = (release, id) => { return release.assets.links.find(l => l.id === id); @@ -49,6 +50,7 @@ export default { id: uniqueId('new-link-'), url: '', name: '', + linkType: DEFAULT_ASSET_LINK_TYPE, }); }, @@ -62,6 +64,11 @@ export default { linkToUpdate.name = newName; }, + [types.UPDATE_ASSET_LINK_TYPE](state, { linkIdToUpdate, newType }) { + const linkToUpdate = findReleaseLink(state.release, linkIdToUpdate); + linkToUpdate.linkType = newType; + }, + [types.REMOVE_ASSET_LINK](state, linkIdToRemove) { state.release.assets.links = state.release.assets.links.filter(l => l.id !== linkIdToRemove); }, |