debian-mirror-gitlab/app/assets/javascripts/integrations/edit/components/active_checkbox.vue

49 lines
1 KiB
Vue
Raw Normal View History

2020-04-22 19:07:51 +05:30
<script>
2020-07-28 23:09:34 +05:30
import { mapGetters } from 'vuex';
2020-11-24 15:15:51 +05:30
import { GlFormGroup, GlFormCheckbox } from '@gitlab/ui';
2020-10-24 23:57:45 +05:30
import eventHub from '../event_hub';
2020-04-22 19:07:51 +05:30
export default {
2020-11-24 15:15:51 +05:30
name: 'ActiveCheckbox',
2020-04-22 19:07:51 +05:30
components: {
2020-06-23 00:09:42 +05:30
GlFormGroup,
2020-11-24 15:15:51 +05:30
GlFormCheckbox,
2020-04-22 19:07:51 +05:30
},
data() {
return {
2020-11-24 15:15:51 +05:30
activated: false,
2020-04-22 19:07:51 +05:30
};
},
2020-07-28 23:09:34 +05:30
computed: {
2020-11-24 15:15:51 +05:30
...mapGetters(['isInheriting', 'propsSource']),
2020-07-28 23:09:34 +05:30
},
2020-04-22 19:07:51 +05:30
mounted() {
2020-11-24 15:15:51 +05:30
this.activated = this.propsSource.initialActivated;
2020-04-22 19:07:51 +05:30
// Initialize view
this.$nextTick(() => {
2020-11-24 15:15:51 +05:30
this.onChange(this.activated);
2020-04-22 19:07:51 +05:30
});
},
methods: {
2020-11-24 15:15:51 +05:30
onChange(e) {
2020-04-22 19:07:51 +05:30
eventHub.$emit('toggle', e);
},
},
};
</script>
<template>
2020-10-24 23:57:45 +05:30
<gl-form-group :label="__('Enable integration')" label-for="service[active]">
2020-11-24 15:15:51 +05:30
<input name="service[active]" type="hidden" :value="activated || false" />
<gl-form-checkbox
2020-10-24 23:57:45 +05:30
v-model="activated"
name="service[active]"
class="gl-display-block gl-line-height-0"
:disabled="isInheriting"
2020-11-24 15:15:51 +05:30
@change="onChange"
>
{{ __('Active') }}
</gl-form-checkbox>
2020-10-24 23:57:45 +05:30
</gl-form-group>
2020-04-22 19:07:51 +05:30
</template>