diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-18 21:09:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-18 21:09:07 +0300 |
commit | 6b8d671de726534a03c18e025a586e1bc9c04a4f (patch) | |
tree | f6a9168160b0d435641a1767b2e68487ec75ae46 /app | |
parent | 163a7046ac76eb4109184e82ce0af911633e6626 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/api.js | 6 | ||||
-rw-r--r-- | app/assets/javascripts/ci_variable_list/store/actions.js | 155 | ||||
-rw-r--r-- | app/assets/javascripts/ci_variable_list/store/index.js | 17 | ||||
-rw-r--r-- | app/assets/javascripts/ci_variable_list/store/mutation_types.js | 22 | ||||
-rw-r--r-- | app/assets/javascripts/ci_variable_list/store/mutations.js | 86 | ||||
-rw-r--r-- | app/assets/javascripts/ci_variable_list/store/state.js | 24 | ||||
-rw-r--r-- | app/assets/javascripts/ci_variable_list/store/utils.js | 44 | ||||
-rw-r--r-- | app/assets/stylesheets/framework/typography.scss | 2 | ||||
-rw-r--r-- | app/workers/admin_email_worker.rb | 2 | ||||
-rw-r--r-- | app/workers/all_queues.yml | 6 | ||||
-rw-r--r-- | app/workers/gitlab_usage_ping_worker.rb | 2 | ||||
-rw-r--r-- | app/workers/prune_old_events_worker.rb | 2 |
12 files changed, 360 insertions, 8 deletions
diff --git a/app/assets/javascripts/api.js b/app/assets/javascripts/api.js index 4dc4ce543e9..8a6395b42b5 100644 --- a/app/assets/javascripts/api.js +++ b/app/assets/javascripts/api.js @@ -47,6 +47,7 @@ const Api = { adminStatisticsPath: '/api/:version/application/statistics', pipelineSinglePath: '/api/:version/projects/:id/pipelines/:pipeline_id', lsifPath: '/api/:version/projects/:id/commits/:commit_id/lsif/info', + environmentsPath: '/api/:version/projects/:id/environments', group(groupId, callback) { const url = Api.buildUrl(Api.groupPath).replace(':id', groupId); @@ -483,6 +484,11 @@ const Api = { return axios.get(url, { params: { path } }); }, + environments(id) { + const url = Api.buildUrl(this.environmentsPath).replace(':id', encodeURIComponent(id)); + return axios.get(url); + }, + buildUrl(url) { return joinPaths(gon.relative_url_root || '', url.replace(':version', gon.api_version)); }, diff --git a/app/assets/javascripts/ci_variable_list/store/actions.js b/app/assets/javascripts/ci_variable_list/store/actions.js new file mode 100644 index 00000000000..f3a629b84ee --- /dev/null +++ b/app/assets/javascripts/ci_variable_list/store/actions.js @@ -0,0 +1,155 @@ +import * as types from './mutation_types'; +import axios from '~/lib/utils/axios_utils'; +import Api from '~/api'; +import createFlash from '~/flash'; +import { __ } from '~/locale'; +import { prepareDataForApi, prepareDataForDisplay, prepareEnvironments } from './utils'; + +export const toggleValues = ({ commit }, valueState) => { + commit(types.TOGGLE_VALUES, valueState); +}; + +export const clearModal = ({ commit }) => { + commit(types.CLEAR_MODAL); +}; + +export const resetEditing = ({ commit, dispatch }) => { + // fetch variables again if modal is being edited and then hidden + // without saving changes, to cover use case of reactivity in the table + dispatch('fetchVariables'); + commit(types.RESET_EDITING); +}; + +export const requestAddVariable = ({ commit }) => { + commit(types.REQUEST_ADD_VARIABLE); +}; + +export const receiveAddVariableSuccess = ({ commit }) => { + commit(types.RECEIVE_ADD_VARIABLE_SUCCESS); +}; + +export const receiveAddVariableError = ({ commit }, error) => { + commit(types.RECEIVE_ADD_VARIABLE_ERROR, error); +}; + +export const addVariable = ({ state, dispatch }) => { + dispatch('requestAddVariable'); + + return axios + .patch(state.endpoint, { + variables_attributes: [prepareDataForApi(state.variable)], + }) + .then(() => { + dispatch('receiveAddVariableSuccess'); + dispatch('fetchVariables'); + }) + .catch(error => { + createFlash(error.response.data[0]); + dispatch('receiveAddVariableError', error); + }); +}; + +export const requestUpdateVariable = ({ commit }) => { + commit(types.REQUEST_UPDATE_VARIABLE); +}; + +export const receiveUpdateVariableSuccess = ({ commit }) => { + commit(types.RECEIVE_UPDATE_VARIABLE_SUCCESS); +}; + +export const receiveUpdateVariableError = ({ commit }, error) => { + commit(types.RECEIVE_UPDATE_VARIABLE_ERROR, error); +}; + +export const updateVariable = ({ state, dispatch }, variable) => { + dispatch('requestUpdateVariable'); + + const updatedVariable = prepareDataForApi(variable); + updatedVariable.secrect_value = updateVariable.value; + + return axios + .patch(state.endpoint, { variables_attributes: [updatedVariable] }) + .then(() => { + dispatch('receiveUpdateVariableSuccess'); + dispatch('fetchVariables'); + }) + .catch(error => { + createFlash(error.response.data[0]); + dispatch('receiveUpdateVariableError', error); + }); +}; + +export const editVariable = ({ commit }, variable) => { + const variableToEdit = variable; + variableToEdit.secret_value = variableToEdit.value; + commit(types.VARIABLE_BEING_EDITED, variableToEdit); +}; + +export const requestVariables = ({ commit }) => { + commit(types.REQUEST_VARIABLES); +}; +export const receiveVariablesSuccess = ({ commit }, variables) => { + commit(types.RECEIVE_VARIABLES_SUCCESS, variables); +}; + +export const fetchVariables = ({ dispatch, state }) => { + dispatch('requestVariables'); + + return axios + .get(state.endpoint) + .then(({ data }) => { + dispatch('receiveVariablesSuccess', prepareDataForDisplay(data.variables)); + }) + .catch(() => { + createFlash(__('There was an error fetching the variables.')); + }); +}; + +export const requestDeleteVariable = ({ commit }) => { + commit(types.REQUEST_DELETE_VARIABLE); +}; + +export const receiveDeleteVariableSuccess = ({ commit }) => { + commit(types.RECEIVE_DELETE_VARIABLE_SUCCESS); +}; + +export const receiveDeleteVariableError = ({ commit }, error) => { + commit(types.RECEIVE_DELETE_VARIABLE_ERROR, error); +}; + +export const deleteVariable = ({ dispatch, state }, variable) => { + dispatch('requestDeleteVariable'); + + const destroy = true; + + return axios + .patch(state.endpoint, { variables_attributes: [prepareDataForApi(variable, destroy)] }) + .then(() => { + dispatch('receiveDeleteVariableSuccess'); + dispatch('fetchVariables'); + }) + .catch(error => { + createFlash(error.response.data[0]); + dispatch('receiveDeleteVariableError', error); + }); +}; + +export const requestEnvironments = ({ commit }) => { + commit(types.REQUEST_ENVIRONMENTS); +}; + +export const receiveEnvironmentsSuccess = ({ commit }, environments) => { + commit(types.RECEIVE_ENVIRONMENTS_SUCCESS, environments); +}; + +export const fetchEnvironments = ({ dispatch, state }) => { + dispatch('requestEnvironments'); + + return Api.environments(state.projectId) + .then(res => { + dispatch('receiveEnvironmentsSuccess', prepareEnvironments(res.data)); + }) + .catch(() => { + createFlash(__('There was an error fetching the environments information.')); + }); +}; diff --git a/app/assets/javascripts/ci_variable_list/store/index.js b/app/assets/javascripts/ci_variable_list/store/index.js new file mode 100644 index 00000000000..db4ba95b3c2 --- /dev/null +++ b/app/assets/javascripts/ci_variable_list/store/index.js @@ -0,0 +1,17 @@ +import Vue from 'vue'; +import Vuex from 'vuex'; +import * as actions from './actions'; +import mutations from './mutations'; +import state from './state'; + +Vue.use(Vuex); + +export default (initialState = {}) => + new Vuex.Store({ + actions, + mutations, + state: { + ...state(), + ...initialState, + }, + }); diff --git a/app/assets/javascripts/ci_variable_list/store/mutation_types.js b/app/assets/javascripts/ci_variable_list/store/mutation_types.js new file mode 100644 index 00000000000..240066d0f22 --- /dev/null +++ b/app/assets/javascripts/ci_variable_list/store/mutation_types.js @@ -0,0 +1,22 @@ +export const TOGGLE_VALUES = 'TOGGLE_VALUES'; +export const VARIABLE_BEING_EDITED = 'VARIABLE_BEING_EDITED'; +export const RESET_EDITING = 'RESET_EDITING'; +export const CLEAR_MODAL = 'CLEAR_MODAL'; + +export const REQUEST_VARIABLES = 'REQUEST_VARIABLES'; +export const RECEIVE_VARIABLES_SUCCESS = 'RECEIVE_VARIABLES_SUCCESS'; + +export const REQUEST_DELETE_VARIABLE = 'REQUEST_DELETE_VARIABLE'; +export const RECEIVE_DELETE_VARIABLE_SUCCESS = 'RECEIVE_DELETE_VARIABLE_SUCCESS'; +export const RECEIVE_DELETE_VARIABLE_ERROR = 'RECEIVE_DELETE_VARIABLE_ERROR'; + +export const REQUEST_ADD_VARIABLE = 'REQUEST_ADD_VARIABLE'; +export const RECEIVE_ADD_VARIABLE_SUCCESS = 'RECEIVE_ADD_VARIABLE_SUCCESS'; +export const RECEIVE_ADD_VARIABLE_ERROR = 'RECEIVE_ADD_VARIABLE_ERROR'; + +export const REQUEST_UPDATE_VARIABLE = 'REQUEST_UPDATE_VARIABLE'; +export const RECEIVE_UPDATE_VARIABLE_SUCCESS = 'RECEIVE_UPDATE_VARIABLE_SUCCESS'; +export const RECEIVE_UPDATE_VARIABLE_ERROR = 'RECEIVE_UPDATE_VARIABLE_ERROR'; + +export const REQUEST_ENVIRONMENTS = 'REQUEST_ENVIRONMENTS'; +export const RECEIVE_ENVIRONMENTS_SUCCESS = 'RECEIVE_ENVIRONMENTS_SUCCESS'; diff --git a/app/assets/javascripts/ci_variable_list/store/mutations.js b/app/assets/javascripts/ci_variable_list/store/mutations.js new file mode 100644 index 00000000000..74e2bcfa2db --- /dev/null +++ b/app/assets/javascripts/ci_variable_list/store/mutations.js @@ -0,0 +1,86 @@ +import * as types from './mutation_types'; +import { __ } from '~/locale'; + +export default { + [types.REQUEST_VARIABLES](state) { + state.isLoading = true; + }, + + [types.RECEIVE_VARIABLES_SUCCESS](state, variables) { + state.isLoading = false; + state.variables = variables; + }, + + [types.REQUEST_DELETE_VARIABLE](state) { + state.isDeleting = true; + }, + + [types.RECEIVE_DELETE_VARIABLE_SUCCESS](state) { + state.isDeleting = false; + }, + + [types.RECEIVE_DELETE_VARIABLE_ERROR](state, error) { + state.isDeleting = false; + state.error = error; + }, + + [types.REQUEST_ADD_VARIABLE](state) { + state.isLoading = true; + }, + + [types.RECEIVE_ADD_VARIABLE_SUCCESS](state) { + state.isLoading = false; + }, + + [types.RECEIVE_ADD_VARIABLE_ERROR](state, error) { + state.isLoading = false; + state.error = error; + }, + + [types.REQUEST_UPDATE_VARIABLE](state) { + state.isLoading = true; + }, + + [types.RECEIVE_UPDATE_VARIABLE_SUCCESS](state) { + state.isLoading = false; + }, + + [types.RECEIVE_UPDATE_VARIABLE_ERROR](state, error) { + state.isLoading = false; + state.error = error; + }, + + [types.TOGGLE_VALUES](state, valueState) { + state.valuesHidden = valueState; + }, + + [types.REQUEST_ENVIRONMENTS](state) { + state.isLoading = true; + }, + + [types.RECEIVE_ENVIRONMENTS_SUCCESS](state, environments) { + state.isLoading = false; + state.environments = environments; + state.environments.unshift(__('All environments')); + }, + + [types.VARIABLE_BEING_EDITED](state, variable) { + state.variableBeingEdited = variable; + }, + + [types.CLEAR_MODAL](state) { + state.variable = { + variable_type: __('Variable'), + key: '', + secret_value: '', + protected: false, + masked: false, + environment_scope: __('All environments'), + }; + }, + + [types.RESET_EDITING](state) { + state.variableBeingEdited = null; + state.showInputValue = false; + }, +}; diff --git a/app/assets/javascripts/ci_variable_list/store/state.js b/app/assets/javascripts/ci_variable_list/store/state.js new file mode 100644 index 00000000000..c5e0bbfdbf4 --- /dev/null +++ b/app/assets/javascripts/ci_variable_list/store/state.js @@ -0,0 +1,24 @@ +import { __ } from '~/locale'; + +export default () => ({ + endpoint: null, + projectId: null, + isGroup: null, + maskableRegex: null, + isLoading: false, + isDeleting: false, + variable: { + variable_type: __('Variable'), + key: '', + secret_value: '', + protected: false, + masked: false, + environment_scope: __('All environments'), + }, + variables: null, + valuesHidden: true, + error: null, + environments: [], + typeOptions: [__('Variable'), __('File')], + variableBeingEdited: null, +}); diff --git a/app/assets/javascripts/ci_variable_list/store/utils.js b/app/assets/javascripts/ci_variable_list/store/utils.js new file mode 100644 index 00000000000..44807e03dad --- /dev/null +++ b/app/assets/javascripts/ci_variable_list/store/utils.js @@ -0,0 +1,44 @@ +import { __ } from '~/locale'; + +const variableType = 'env_var'; +const fileType = 'file'; + +const variableTypeHandler = type => (type === 'Variable' ? variableType : fileType); + +export const prepareDataForDisplay = variables => { + const variablesToDisplay = []; + variables.forEach(variable => { + const variableCopy = variable; + if (variableCopy.variable_type === variableType) { + variableCopy.variable_type = __('Variable'); + } else { + variableCopy.variable_type = __('File'); + } + + if (variableCopy.environment_scope === '*') { + variableCopy.environment_scope = __('All environments'); + } + variablesToDisplay.push(variableCopy); + }); + return variablesToDisplay; +}; + +export const prepareDataForApi = (variable, destroy = false) => { + const variableCopy = variable; + variableCopy.protected.toString(); + variableCopy.masked.toString(); + variableCopy.variable_type = variableTypeHandler(variableCopy.variable_type); + + if (variableCopy.environment_scope === __('All environments')) { + variableCopy.environment_scope = __('*'); + } + + if (destroy) { + // eslint-disable-next-line + variableCopy._destroy = destroy; + } + + return variableCopy; +}; + +export const prepareEnvironments = environments => environments.map(e => e.name); diff --git a/app/assets/stylesheets/framework/typography.scss b/app/assets/stylesheets/framework/typography.scss index 6cd69fe75ce..a1bfa03a5ac 100644 --- a/app/assets/stylesheets/framework/typography.scss +++ b/app/assets/stylesheets/framework/typography.scss @@ -102,7 +102,6 @@ padding-bottom: 0.3em; border-bottom: 1px solid $white-dark; color: $gl-text-color; - overflow: hidden; &:first-child { margin-top: 0; @@ -116,7 +115,6 @@ padding-bottom: 0.3em; border-bottom: 1px solid $white-dark; color: $gl-text-color; - overflow: hidden; } h3 { diff --git a/app/workers/admin_email_worker.rb b/app/workers/admin_email_worker.rb index a7cc4fb0d11..9388b1014ac 100644 --- a/app/workers/admin_email_worker.rb +++ b/app/workers/admin_email_worker.rb @@ -7,7 +7,7 @@ class AdminEmailWorker include CronjobQueue # rubocop:enable Scalability/CronWorkerContext - feature_category_not_owned! + feature_category :source_code_management def perform send_repository_check_mail if Gitlab::CurrentSettings.repository_checks_enabled diff --git a/app/workers/all_queues.yml b/app/workers/all_queues.yml index f6daab73689..459872965f8 100644 --- a/app/workers/all_queues.yml +++ b/app/workers/all_queues.yml @@ -58,7 +58,7 @@ :resource_boundary: :unknown :weight: 1 - :name: cronjob:admin_email - :feature_category: :not_owned + :feature_category: :source_code_management :has_external_dependencies: :latency_sensitive: :resource_boundary: :unknown @@ -88,7 +88,7 @@ :resource_boundary: :unknown :weight: 1 - :name: cronjob:gitlab_usage_ping - :feature_category: :not_owned + :feature_category: :collection :has_external_dependencies: :latency_sensitive: :resource_boundary: :unknown @@ -142,7 +142,7 @@ :resource_boundary: :cpu :weight: 1 - :name: cronjob:prune_old_events - :feature_category: :not_owned + :feature_category: :users :has_external_dependencies: :latency_sensitive: :resource_boundary: :unknown diff --git a/app/workers/gitlab_usage_ping_worker.rb b/app/workers/gitlab_usage_ping_worker.rb index bf0dc0fdd59..002542e26f4 100644 --- a/app/workers/gitlab_usage_ping_worker.rb +++ b/app/workers/gitlab_usage_ping_worker.rb @@ -9,7 +9,7 @@ class GitlabUsagePingWorker include CronjobQueue # rubocop:enable Scalability/CronWorkerContext - feature_category_not_owned! + feature_category :collection # Retry for up to approximately three hours then give up. sidekiq_options retry: 10, dead: false diff --git a/app/workers/prune_old_events_worker.rb b/app/workers/prune_old_events_worker.rb index 835c51ec846..541a17c0fcf 100644 --- a/app/workers/prune_old_events_worker.rb +++ b/app/workers/prune_old_events_worker.rb @@ -7,7 +7,7 @@ class PruneOldEventsWorker include CronjobQueue # rubocop:enable Scalability/CronWorkerContext - feature_category_not_owned! + feature_category :users DELETE_LIMIT = 10_000 |