summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/integrations
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/integrations')
-rw-r--r--app/assets/javascripts/integrations/edit/components/confirmation_modal.vue6
-rw-r--r--app/assets/javascripts/integrations/edit/components/integration_form.vue41
-rw-r--r--app/assets/javascripts/integrations/edit/components/jira_trigger_fields.vue7
-rw-r--r--app/assets/javascripts/integrations/edit/components/reset_confirmation_modal.vue61
-rw-r--r--app/assets/javascripts/integrations/edit/index.js2
-rw-r--r--app/assets/javascripts/integrations/edit/store/actions.js2
-rw-r--r--app/assets/javascripts/integrations/edit/store/getters.js2
-rw-r--r--app/assets/javascripts/integrations/edit/store/mutation_types.js1
-rw-r--r--app/assets/javascripts/integrations/edit/store/mutations.js3
-rw-r--r--app/assets/javascripts/integrations/edit/store/state.js1
10 files changed, 107 insertions, 19 deletions
diff --git a/app/assets/javascripts/integrations/edit/components/confirmation_modal.vue b/app/assets/javascripts/integrations/edit/components/confirmation_modal.vue
index 890381a8f29..93ea1f4f636 100644
--- a/app/assets/javascripts/integrations/edit/components/confirmation_modal.vue
+++ b/app/assets/javascripts/integrations/edit/components/confirmation_modal.vue
@@ -8,14 +8,14 @@ export default {
GlModal,
},
computed: {
- ...mapGetters(['isSavingOrTesting']),
+ ...mapGetters(['isDisabled']),
primaryProps() {
return {
text: __('Save'),
attributes: [
{ variant: 'success' },
{ category: 'primary' },
- { disabled: this.isSavingOrTesting },
+ { disabled: this.isDisabled },
],
};
},
@@ -52,7 +52,7 @@ export default {
<p class="gl-mb-0">
{{
s__(
- 'Integrations|Projects using custom settings will not be impacted unless the project owner chooses to use instance-level defaults.',
+ 'Integrations|Projects using custom settings will not be impacted unless the project owner chooses to use parent level defaults.',
)
}}
</p>
diff --git a/app/assets/javascripts/integrations/edit/components/integration_form.vue b/app/assets/javascripts/integrations/edit/components/integration_form.vue
index 0fd39c5635d..bbfa865905a 100644
--- a/app/assets/javascripts/integrations/edit/components/integration_form.vue
+++ b/app/assets/javascripts/integrations/edit/components/integration_form.vue
@@ -12,6 +12,7 @@ import JiraIssuesFields from './jira_issues_fields.vue';
import TriggerFields from './trigger_fields.vue';
import DynamicField from './dynamic_field.vue';
import ConfirmationModal from './confirmation_modal.vue';
+import ResetConfirmationModal from './reset_confirmation_modal.vue';
export default {
name: 'IntegrationForm',
@@ -23,6 +24,7 @@ export default {
TriggerFields,
DynamicField,
ConfirmationModal,
+ ResetConfirmationModal,
GlButton,
},
directives: {
@@ -30,23 +32,29 @@ export default {
},
mixins: [glFeatureFlagsMixin()],
computed: {
- ...mapGetters(['currentKey', 'propsSource', 'isSavingOrTesting']),
- ...mapState(['defaultState', 'override', 'isSaving', 'isTesting']),
+ ...mapGetters(['currentKey', 'propsSource', 'isDisabled']),
+ ...mapState(['defaultState', 'override', 'isSaving', 'isTesting', 'isResetting']),
isEditable() {
return this.propsSource.editable;
},
isJira() {
return this.propsSource.type === 'jira';
},
- isInstanceLevel() {
- return this.propsSource.integrationLevel === integrationLevels.INSTANCE;
+ isInstanceOrGroupLevel() {
+ return (
+ this.propsSource.integrationLevel === integrationLevels.INSTANCE ||
+ this.propsSource.integrationLevel === integrationLevels.GROUP
+ );
},
showJiraIssuesFields() {
return this.isJira && this.glFeatures.jiraIssuesIntegration;
},
+ showReset() {
+ return this.isInstanceOrGroupLevel && this.propsSource.resetPath;
+ },
},
methods: {
- ...mapActions(['setOverride', 'setIsSaving', 'setIsTesting']),
+ ...mapActions(['setOverride', 'setIsSaving', 'setIsTesting', 'setIsResetting']),
onSaveClick() {
this.setIsSaving(true);
eventHub.$emit('saveIntegration');
@@ -55,6 +63,7 @@ export default {
this.setIsTesting(true);
eventHub.$emit('testIntegration');
},
+ onResetClick() {},
},
};
</script>
@@ -91,13 +100,13 @@ export default {
v-bind="propsSource.jiraIssuesProps"
/>
<div v-if="isEditable" class="footer-block row-content-block">
- <template v-if="isInstanceLevel">
+ <template v-if="isInstanceOrGroupLevel">
<gl-button
v-gl-modal.confirmSaveIntegration
category="primary"
variant="success"
:loading="isSaving"
- :disabled="isSavingOrTesting"
+ :disabled="isDisabled"
data-qa-selector="save_changes_button"
>
{{ __('Save changes') }}
@@ -110,7 +119,7 @@ export default {
variant="success"
type="submit"
:loading="isSaving"
- :disabled="isSavingOrTesting"
+ :disabled="isDisabled"
data-qa-selector="save_changes_button"
@click.prevent="onSaveClick"
>
@@ -120,13 +129,27 @@ export default {
<gl-button
v-if="propsSource.canTest"
:loading="isTesting"
- :disabled="isSavingOrTesting"
+ :disabled="isDisabled"
:href="propsSource.testPath"
@click.prevent="onTestClick"
>
{{ __('Test settings') }}
</gl-button>
+ <template v-if="showReset">
+ <gl-button
+ v-gl-modal.confirmResetIntegration
+ category="secondary"
+ variant="default"
+ :loading="isResetting"
+ :disabled="isDisabled"
+ data-testid="reset-button"
+ >
+ {{ __('Reset') }}
+ </gl-button>
+ <reset-confirmation-modal @reset="onResetClick" />
+ </template>
+
<gl-button class="btn-cancel" :href="propsSource.cancelPath">{{ __('Cancel') }}</gl-button>
</div>
</div>
diff --git a/app/assets/javascripts/integrations/edit/components/jira_trigger_fields.vue b/app/assets/javascripts/integrations/edit/components/jira_trigger_fields.vue
index 08f24ce8ab6..123d794912a 100644
--- a/app/assets/javascripts/integrations/edit/components/jira_trigger_fields.vue
+++ b/app/assets/javascripts/integrations/edit/components/jira_trigger_fields.vue
@@ -108,12 +108,7 @@ export default {
:label="s__('Integrations|Comment detail:')"
data-testid="comment-detail"
>
- <input
- v-if="isInheriting"
- name="service[comment_detail]"
- type="hidden"
- :value="commentDetail"
- />
+ <input name="service[comment_detail]" type="hidden" :value="commentDetail" />
<gl-form-radio
v-for="commentDetailOption in commentDetailOptions"
:key="commentDetailOption.value"
diff --git a/app/assets/javascripts/integrations/edit/components/reset_confirmation_modal.vue b/app/assets/javascripts/integrations/edit/components/reset_confirmation_modal.vue
new file mode 100644
index 00000000000..d8503910566
--- /dev/null
+++ b/app/assets/javascripts/integrations/edit/components/reset_confirmation_modal.vue
@@ -0,0 +1,61 @@
+<script>
+import { mapGetters } from 'vuex';
+import { GlModal } from '@gitlab/ui';
+
+import { __ } from '~/locale';
+
+export default {
+ components: {
+ GlModal,
+ },
+ computed: {
+ ...mapGetters(['isDisabled']),
+ primaryProps() {
+ return {
+ text: __('Reset'),
+ attributes: [
+ { variant: 'warning' },
+ { category: 'primary' },
+ { disabled: this.isDisabled },
+ ],
+ };
+ },
+ cancelProps() {
+ return {
+ text: __('Cancel'),
+ };
+ },
+ },
+ methods: {
+ onReset() {
+ this.$emit('reset');
+ },
+ },
+};
+</script>
+
+<template>
+ <gl-modal
+ modal-id="confirmResetIntegration"
+ size="sm"
+ :title="s__('Integrations|Reset integration?')"
+ :action-primary="primaryProps"
+ :action-cancel="cancelProps"
+ @primary="onReset"
+ >
+ <p>
+ {{
+ s__(
+ 'Integrations|Resetting this integration will clear the settings and deactivate this integration.',
+ )
+ }}
+ </p>
+ <p>
+ {{ s__('Integrations|All projects inheriting these settings will also be reset.') }}
+ </p>
+
+ <p class="gl-mb-0">
+ {{ s__('Integrations|Projects using custom settings will not be affected.') }}
+ </p>
+ </gl-modal>
+</template>
diff --git a/app/assets/javascripts/integrations/edit/index.js b/app/assets/javascripts/integrations/edit/index.js
index 248ee62d43a..95a53f1beab 100644
--- a/app/assets/javascripts/integrations/edit/index.js
+++ b/app/assets/javascripts/integrations/edit/index.js
@@ -26,6 +26,7 @@ function parseDatasetToProps(data) {
integrationLevel,
cancelPath,
testPath,
+ resetPath,
...booleanAttributes
} = data;
const {
@@ -49,6 +50,7 @@ function parseDatasetToProps(data) {
editable,
canTest,
testPath,
+ resetPath,
triggerFieldsProps: {
initialTriggerCommit: commitEvents,
initialTriggerMergeRequest: mergeRequestEvents,
diff --git a/app/assets/javascripts/integrations/edit/store/actions.js b/app/assets/javascripts/integrations/edit/store/actions.js
index 199c9074ead..097304be242 100644
--- a/app/assets/javascripts/integrations/edit/store/actions.js
+++ b/app/assets/javascripts/integrations/edit/store/actions.js
@@ -3,3 +3,5 @@ import * as types from './mutation_types';
export const setOverride = ({ commit }, override) => commit(types.SET_OVERRIDE, override);
export const setIsSaving = ({ commit }, isSaving) => commit(types.SET_IS_SAVING, isSaving);
export const setIsTesting = ({ commit }, isTesting) => commit(types.SET_IS_TESTING, isTesting);
+export const setIsResetting = ({ commit }, isResetting) =>
+ commit(types.SET_IS_RESETTING, isResetting);
diff --git a/app/assets/javascripts/integrations/edit/store/getters.js b/app/assets/javascripts/integrations/edit/store/getters.js
index 4ee5f11855c..310d970c73e 100644
--- a/app/assets/javascripts/integrations/edit/store/getters.js
+++ b/app/assets/javascripts/integrations/edit/store/getters.js
@@ -1,6 +1,6 @@
export const isInheriting = state => (state.defaultState === null ? false : !state.override);
-export const isSavingOrTesting = state => state.isSaving || state.isTesting;
+export const isDisabled = state => state.isSaving || state.isTesting || state.isResetting;
export const propsSource = (state, getters) =>
getters.isInheriting ? state.defaultState : state.customState;
diff --git a/app/assets/javascripts/integrations/edit/store/mutation_types.js b/app/assets/javascripts/integrations/edit/store/mutation_types.js
index 0dae8ea079e..2a84408f658 100644
--- a/app/assets/javascripts/integrations/edit/store/mutation_types.js
+++ b/app/assets/javascripts/integrations/edit/store/mutation_types.js
@@ -1,3 +1,4 @@
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';
diff --git a/app/assets/javascripts/integrations/edit/store/mutations.js b/app/assets/javascripts/integrations/edit/store/mutations.js
index 8ac3c476f9e..07e3e25ccf0 100644
--- a/app/assets/javascripts/integrations/edit/store/mutations.js
+++ b/app/assets/javascripts/integrations/edit/store/mutations.js
@@ -10,4 +10,7 @@ export default {
[types.SET_IS_TESTING](state, isTesting) {
state.isTesting = isTesting;
},
+ [types.SET_IS_RESETTING](state, isResetting) {
+ state.isResetting = isResetting;
+ },
};
diff --git a/app/assets/javascripts/integrations/edit/store/state.js b/app/assets/javascripts/integrations/edit/store/state.js
index a9ecee6c539..aae3db1583f 100644
--- a/app/assets/javascripts/integrations/edit/store/state.js
+++ b/app/assets/javascripts/integrations/edit/store/state.js
@@ -7,5 +7,6 @@ export default ({ defaultState = null, customState = {} } = {}) => {
customState,
isSaving: false,
isTesting: false,
+ isResetting: false,
};
};