Commit a3336953 authored by Justin Ho's avatar Justin Ho Committed by Lukas Eipert

Disable form fields when not overriding

Apply to all form components
parent 28d65da6
<script> <script>
import { mapGetters } from 'vuex';
import eventHub from '../event_hub'; import eventHub from '../event_hub';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import { GlFormGroup, GlToggle } from '@gitlab/ui'; import { GlFormGroup, GlToggle } from '@gitlab/ui';
...@@ -21,6 +22,9 @@ export default { ...@@ -21,6 +22,9 @@ export default {
activated: this.initialActivated, activated: this.initialActivated,
}; };
}, },
computed: {
...mapGetters(['disableForm']),
},
mounted() { mounted() {
// Initialize view // Initialize view
this.$nextTick(() => { this.$nextTick(() => {
...@@ -42,6 +46,7 @@ export default { ...@@ -42,6 +46,7 @@ export default {
v-model="activated" v-model="activated"
name="service[active]" name="service[active]"
class="gl-display-block gl-line-height-0" class="gl-display-block gl-line-height-0"
:disabled="disableForm"
@change="onToggle" @change="onToggle"
/> />
</gl-form-group> </gl-form-group>
......
<script> <script>
import { mapGetters } from 'vuex';
import eventHub from '../event_hub'; import eventHub from '../event_hub';
import { capitalize, lowerCase, isEmpty } from 'lodash'; import { capitalize, lowerCase, isEmpty } from 'lodash';
import { __, sprintf } from '~/locale'; import { __, sprintf } from '~/locale';
...@@ -59,6 +60,7 @@ export default { ...@@ -59,6 +60,7 @@ export default {
}; };
}, },
computed: { computed: {
...mapGetters(['disableForm']),
isCheckbox() { isCheckbox() {
return this.type === 'checkbox'; return this.type === 'checkbox';
}, },
...@@ -107,6 +109,7 @@ export default { ...@@ -107,6 +109,7 @@ export default {
id: this.fieldId, id: this.fieldId,
name: this.fieldName, name: this.fieldName,
state: this.valid, state: this.valid,
disabled: this.disableForm,
}; };
}, },
valid() { valid() {
......
<script> <script>
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import { mapGetters } from 'vuex';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import { GlFormGroup, GlFormCheckbox, GlFormRadio } from '@gitlab/ui'; import { GlFormGroup, GlFormCheckbox, GlFormRadio } from '@gitlab/ui';
...@@ -55,6 +56,7 @@ export default { ...@@ -55,6 +56,7 @@ export default {
}; };
}, },
computed: { computed: {
...mapGetters(['disableForm']),
showEnableComments() { showEnableComments() {
return this.triggerCommit || this.triggerMergeRequest; return this.triggerCommit || this.triggerMergeRequest;
}, },
...@@ -74,12 +76,20 @@ export default { ...@@ -74,12 +76,20 @@ export default {
" "
> >
<input name="service[commit_events]" type="hidden" value="false" /> <input name="service[commit_events]" type="hidden" value="false" />
<gl-form-checkbox v-model="triggerCommit" name="service[commit_events]"> <gl-form-checkbox
v-model="triggerCommit"
name="service[commit_events]"
:disabled="disableForm"
>
{{ __('Commit') }} {{ __('Commit') }}
</gl-form-checkbox> </gl-form-checkbox>
<input name="service[merge_requests_events]" type="hidden" value="false" /> <input name="service[merge_requests_events]" type="hidden" value="false" />
<gl-form-checkbox v-model="triggerMergeRequest" name="service[merge_requests_events]"> <gl-form-checkbox
v-model="triggerMergeRequest"
name="service[merge_requests_events]"
:disabled="disableForm"
>
{{ __('Merge request') }} {{ __('Merge request') }}
</gl-form-checkbox> </gl-form-checkbox>
</gl-form-group> </gl-form-group>
...@@ -90,7 +100,11 @@ export default { ...@@ -90,7 +100,11 @@ export default {
data-testid="comment-settings" data-testid="comment-settings"
> >
<input name="service[comment_on_event_enabled]" type="hidden" value="false" /> <input name="service[comment_on_event_enabled]" type="hidden" value="false" />
<gl-form-checkbox v-model="enableComments" name="service[comment_on_event_enabled]"> <gl-form-checkbox
v-model="enableComments"
name="service[comment_on_event_enabled]"
:disabled="disableForm"
>
{{ s__('Integrations|Enable comments') }} {{ s__('Integrations|Enable comments') }}
</gl-form-checkbox> </gl-form-checkbox>
</gl-form-group> </gl-form-group>
...@@ -106,6 +120,7 @@ export default { ...@@ -106,6 +120,7 @@ export default {
v-model="commentDetail" v-model="commentDetail"
:value="commentDetailOption.value" :value="commentDetailOption.value"
name="service[comment_detail]" name="service[comment_detail]"
:disabled="disableForm"
> >
{{ commentDetailOption.label }} {{ commentDetailOption.label }}
<template #help> <template #help>
......
<script> <script>
import { mapGetters } from 'vuex';
import { startCase } from 'lodash'; import { startCase } from 'lodash';
import { __ } from '~/locale'; import { __ } from '~/locale';
import { GlFormGroup, GlFormCheckbox, GlFormInput } from '@gitlab/ui'; import { GlFormGroup, GlFormCheckbox, GlFormInput } from '@gitlab/ui';
...@@ -32,6 +33,7 @@ export default { ...@@ -32,6 +33,7 @@ export default {
}, },
}, },
computed: { computed: {
...mapGetters(['disableForm']),
placeholder() { placeholder() {
return placeholderForType[this.type]; return placeholderForType[this.type];
}, },
...@@ -58,7 +60,11 @@ export default { ...@@ -58,7 +60,11 @@ export default {
<div id="trigger-fields" class="gl-pt-3"> <div id="trigger-fields" class="gl-pt-3">
<gl-form-group v-for="event in events" :key="event.title" :description="event.description"> <gl-form-group v-for="event in events" :key="event.title" :description="event.description">
<input :name="checkboxName(event.name)" type="hidden" value="false" /> <input :name="checkboxName(event.name)" type="hidden" value="false" />
<gl-form-checkbox v-model="event.value" :name="checkboxName(event.name)"> <gl-form-checkbox
v-model="event.value"
:name="checkboxName(event.name)"
:disabled="disableForm"
>
{{ startCase(event.title) }} {{ startCase(event.title) }}
</gl-form-checkbox> </gl-form-checkbox>
<gl-form-input <gl-form-input
...@@ -66,6 +72,7 @@ export default { ...@@ -66,6 +72,7 @@ export default {
v-model="event.field.value" v-model="event.field.value"
:name="fieldName(event.field.name)" :name="fieldName(event.field.name)"
:placeholder="placeholder" :placeholder="placeholder"
:disabled="disableForm"
/> />
</gl-form-group> </gl-form-group>
</div> </div>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment