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

49 lines
1.1 KiB
Vue
Raw Normal View History

2020-04-22 19:07:51 +05:30
<script>
2020-11-24 15:15:51 +05:30
import { GlFormGroup, GlFormCheckbox } from '@gitlab/ui';
2021-03-11 19:13:27 +05:30
import { mapGetters } from 'vuex';
2021-11-18 22:05:49 +05:30
import { TOGGLE_INTEGRATION_EVENT } from '~/integrations/constants';
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) {
2021-11-18 22:05:49 +05:30
eventHub.$emit(TOGGLE_INTEGRATION_EVENT, e);
2020-04-22 19:07:51 +05:30
},
},
};
</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"
2021-04-17 20:07:23 +05:30
class="gl-display-block"
2020-10-24 23:57:45 +05:30
: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>