diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 11:59:07 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 11:59:07 +0000 |
commit | 8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch) | |
tree | 544930fb309b30317ae9797a9683768705d664c4 /app/assets/javascripts/integrations | |
parent | 4b1de649d0168371549608993deac953eb692019 (diff) | |
download | gitlab-ce-8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca.tar.gz |
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'app/assets/javascripts/integrations')
5 files changed, 59 insertions, 7 deletions
diff --git a/app/assets/javascripts/integrations/edit/components/integration_form.vue b/app/assets/javascripts/integrations/edit/components/integration_form.vue index bbfa865905a..c6f8ba8dcb2 100644 --- a/app/assets/javascripts/integrations/edit/components/integration_form.vue +++ b/app/assets/javascripts/integrations/edit/components/integration_form.vue @@ -33,7 +33,14 @@ export default { mixins: [glFeatureFlagsMixin()], computed: { ...mapGetters(['currentKey', 'propsSource', 'isDisabled']), - ...mapState(['defaultState', 'override', 'isSaving', 'isTesting', 'isResetting']), + ...mapState([ + 'defaultState', + 'customState', + 'override', + 'isSaving', + 'isTesting', + 'isResetting', + ]), isEditable() { return this.propsSource.editable; }, @@ -42,8 +49,8 @@ export default { }, isInstanceOrGroupLevel() { return ( - this.propsSource.integrationLevel === integrationLevels.INSTANCE || - this.propsSource.integrationLevel === integrationLevels.GROUP + this.customState.integrationLevel === integrationLevels.INSTANCE || + this.customState.integrationLevel === integrationLevels.GROUP ); }, showJiraIssuesFields() { @@ -52,9 +59,18 @@ export default { showReset() { return this.isInstanceOrGroupLevel && this.propsSource.resetPath; }, + saveButtonKey() { + return `save-button-${this.isDisabled}`; + }, }, methods: { - ...mapActions(['setOverride', 'setIsSaving', 'setIsTesting', 'setIsResetting']), + ...mapActions([ + 'setOverride', + 'setIsSaving', + 'setIsTesting', + 'setIsResetting', + 'fetchResetIntegration', + ]), onSaveClick() { this.setIsSaving(true); eventHub.$emit('saveIntegration'); @@ -63,7 +79,9 @@ export default { this.setIsTesting(true); eventHub.$emit('testIntegration'); }, - onResetClick() {}, + onResetClick() { + this.fetchResetIntegration(); + }, }, }; </script> @@ -102,6 +120,7 @@ export default { <div v-if="isEditable" class="footer-block row-content-block"> <template v-if="isInstanceOrGroupLevel"> <gl-button + :key="saveButtonKey" v-gl-modal.confirmSaveIntegration category="primary" variant="success" @@ -115,6 +134,7 @@ export default { </template> <gl-button v-else + :key="saveButtonKey" category="primary" variant="success" type="submit" diff --git a/app/assets/javascripts/integrations/edit/store/actions.js b/app/assets/javascripts/integrations/edit/store/actions.js index 097304be242..421917b720a 100644 --- a/app/assets/javascripts/integrations/edit/store/actions.js +++ b/app/assets/javascripts/integrations/edit/store/actions.js @@ -1,3 +1,5 @@ +import axios from 'axios'; +import { refreshCurrentPage } from '~/lib/utils/url_utility'; import * as types from './mutation_types'; export const setOverride = ({ commit }, override) => commit(types.SET_OVERRIDE, override); @@ -5,3 +7,22 @@ export const setIsSaving = ({ commit }, isSaving) => commit(types.SET_IS_SAVING, export const setIsTesting = ({ commit }, isTesting) => commit(types.SET_IS_TESTING, isTesting); export const setIsResetting = ({ commit }, isResetting) => commit(types.SET_IS_RESETTING, isResetting); + +export const requestResetIntegration = ({ commit }) => { + commit(types.REQUEST_RESET_INTEGRATION); +}; +export const receiveResetIntegrationSuccess = () => { + refreshCurrentPage(); +}; +export const receiveResetIntegrationError = ({ commit }) => { + commit(types.RECEIVE_RESET_INTEGRATION_ERROR); +}; + +export const fetchResetIntegration = ({ dispatch, getters }) => { + dispatch('requestResetIntegration'); + + return axios + .post(getters.propsSource.resetPath, { params: { format: 'json' } }) + .then(() => dispatch('receiveResetIntegrationSuccess')) + .catch(() => dispatch('receiveResetIntegrationError')); +}; diff --git a/app/assets/javascripts/integrations/edit/store/mutation_types.js b/app/assets/javascripts/integrations/edit/store/mutation_types.js index 2a84408f658..54928148b22 100644 --- a/app/assets/javascripts/integrations/edit/store/mutation_types.js +++ b/app/assets/javascripts/integrations/edit/store/mutation_types.js @@ -2,3 +2,6 @@ export const SET_OVERRIDE = 'SET_OVERRIDE'; export const SET_IS_SAVING = 'SET_IS_SAVING'; export const SET_IS_TESTING = 'SET_IS_TESTING'; export const SET_IS_RESETTING = 'SET_IS_RESETTING'; + +export const REQUEST_RESET_INTEGRATION = 'REQUEST_RESET_INTEGRATION'; +export const RECEIVE_RESET_INTEGRATION_ERROR = 'RECEIVE_RESET_INTEGRATION_ERROR'; diff --git a/app/assets/javascripts/integrations/edit/store/mutations.js b/app/assets/javascripts/integrations/edit/store/mutations.js index 07e3e25ccf0..826757e665b 100644 --- a/app/assets/javascripts/integrations/edit/store/mutations.js +++ b/app/assets/javascripts/integrations/edit/store/mutations.js @@ -13,4 +13,10 @@ export default { [types.SET_IS_RESETTING](state, isResetting) { state.isResetting = isResetting; }, + [types.REQUEST_RESET_INTEGRATION](state) { + state.isResetting = true; + }, + [types.RECEIVE_RESET_INTEGRATION_ERROR](state) { + state.isResetting = false; + }, }; diff --git a/app/assets/javascripts/integrations/integration_settings_form.js b/app/assets/javascripts/integrations/integration_settings_form.js index 1d0814125e6..14d6f133d27 100644 --- a/app/assets/javascripts/integrations/integration_settings_form.js +++ b/app/assets/javascripts/integrations/integration_settings_form.js @@ -35,12 +35,14 @@ export default class IntegrationSettingsForm { } saveIntegration() { - // Service was marked active so now we check; + // Save Service if not active and check the following if active; // 1) If form contents are valid // 2) If this service can be saved // If both conditions are true, we override form submission // and save the service using provided configuration. - if (this.$form.get(0).checkValidity()) { + const formValid = this.$form.get(0).checkValidity() || this.formActive === false; + + if (formValid) { this.$form.submit(); } else { eventHub.$emit('validateForm'); |