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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

72 lines
1.5 KiB
Vue
Raw Normal View History

2022-07-23 23:45:48 +05:30
<script>
2023-03-17 16:20:25 +05:30
import { GlFormCheckbox, GlFormInput } from '@gitlab/ui';
2022-07-23 23:45:48 +05:30
import { mapGetters } from 'vuex';
2023-03-17 16:20:25 +05:30
import {
placeholderForType,
integrationTriggerEventTitles,
} from 'any_else_ce/integrations/constants';
2022-07-23 23:45:48 +05:30
export default {
name: 'TriggerField',
components: {
GlFormCheckbox,
2023-03-17 16:20:25 +05:30
GlFormInput,
2022-07-23 23:45:48 +05:30
},
props: {
event: {
type: Object,
required: false,
default: () => ({}),
},
2023-03-17 16:20:25 +05:30
type: {
type: String,
required: true,
},
2022-07-23 23:45:48 +05:30
},
data() {
return {
value: false,
2023-03-17 16:20:25 +05:30
fieldValue: this.event.field?.value,
2022-07-23 23:45:48 +05:30
};
},
computed: {
...mapGetters(['isInheriting']),
name() {
return `service[${this.event.name}]`;
},
2023-03-17 16:20:25 +05:30
fieldName() {
return `service[${this.event.field?.name}]`;
},
2022-07-23 23:45:48 +05:30
title() {
return integrationTriggerEventTitles[this.event.name];
},
2023-03-17 16:20:25 +05:30
defaultPlaceholder() {
return placeholderForType[this.type];
},
2022-07-23 23:45:48 +05:30
},
mounted() {
this.value = this.event.value || false;
},
};
</script>
<template>
<div>
<input :name="name" type="hidden" :value="value" />
<gl-form-checkbox v-model="value" :disabled="isInheriting">
{{ title }}
</gl-form-checkbox>
2023-03-17 16:20:25 +05:30
<div class="gl-ml-6">
<gl-form-input
v-if="event.field"
v-show="value"
v-model="fieldValue"
:name="fieldName"
:placeholder="event.field.placeholder || defaultPlaceholder"
:readonly="isInheriting"
/>
</div>
2022-07-23 23:45:48 +05:30
</div>
</template>