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

68 lines
1.5 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-04-22 19:07:51 +05:30
import eventHub from '../event_hub';
2020-06-23 00:09:42 +05:30
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import { GlFormGroup, GlToggle } from '@gitlab/ui';
2020-04-22 19:07:51 +05:30
export default {
name: 'ActiveToggle',
components: {
2020-06-23 00:09:42 +05:30
GlFormGroup,
2020-04-22 19:07:51 +05:30
GlToggle,
},
2020-06-23 00:09:42 +05:30
mixins: [glFeatureFlagsMixin()],
2020-04-22 19:07:51 +05:30
props: {
initialActivated: {
type: Boolean,
required: true,
},
},
data() {
return {
activated: this.initialActivated,
};
},
2020-07-28 23:09:34 +05:30
computed: {
...mapGetters(['isInheriting']),
},
2020-04-22 19:07:51 +05:30
mounted() {
// Initialize view
this.$nextTick(() => {
this.onToggle(this.activated);
});
},
methods: {
onToggle(e) {
eventHub.$emit('toggle', e);
},
},
};
</script>
<template>
2020-06-23 00:09:42 +05:30
<div v-if="glFeatures.integrationFormRefactor">
<gl-form-group :label="__('Enable integration')" label-for="service[active]">
<gl-toggle
v-model="activated"
name="service[active]"
class="gl-display-block gl-line-height-0"
2020-07-28 23:09:34 +05:30
:disabled="isInheriting"
2020-06-23 00:09:42 +05:30
@change="onToggle"
/>
</gl-form-group>
</div>
<div v-else>
2020-04-22 19:07:51 +05:30
<div class="form-group row" role="group">
<label for="service[active]" class="col-form-label col-sm-2">{{ __('Active') }}</label>
<div class="col-sm-10 pt-1">
2020-07-28 23:09:34 +05:30
<gl-toggle
v-model="activated"
name="service[active]"
:disabled="isInheriting"
@change="onToggle"
/>
2020-04-22 19:07:51 +05:30
</div>
</div>
</div>
</template>