feat(ui): add task params

This commit is contained in:
fiftin 2024-07-15 12:52:28 +05:00
parent 82d8d60fad
commit 5168717683
No known key found for this signature in database
GPG Key ID: 044381366A5D4731
2 changed files with 68 additions and 25 deletions

View File

@ -88,29 +88,8 @@
/>
</div>
<v-row no-gutters class="mt-6">
<v-col cols="12" sm="6">
<v-checkbox class="mt-0" v-model="item.debug">
<template v-slot:label>
<div class="text-no-wrap">{{ $t('debug') }} <code>--vvvv</code></div>
</template>
</v-checkbox>
</v-col>
<v-col cols="12" sm="6">
<v-checkbox class="mt-0" v-model="item.dry_run">
<template v-slot:label>
<div class="text-no-wrap">{{ $t('dryRun') }} <code>--check</code></div>
</template>
</v-checkbox>
</v-col>
<v-col cols="12" sm="6">
<v-checkbox class="mt-0" v-model="item.diff">
<template v-slot:label>
<div class="text-no-wrap">{{ $t('diff') }} <code>--diff</code></div>
</template>
</v-checkbox>
</v-col>
</v-row>
<TaskParamsForm v-if="template.app === 'ansible'" v-model="item" :template="template" />
<TaskParamsForm v-else v-model="item.params" :template="template" />
<div class="mt-4" v-if="!advancedOptions">
<a @click="advancedOptions = true">
@ -167,6 +146,7 @@ import 'codemirror/lib/codemirror.css';
import 'codemirror/mode/vue/vue.js';
import 'codemirror/addon/lint/json-lint.js';
import 'codemirror/addon/display/placeholder.js';
import TaskParamsForm from '@/components/TaskParamsForm.vue';
export default {
mixins: [ItemFormBase],
@ -175,6 +155,7 @@ export default {
sourceTask: Object,
},
components: {
TaskParamsForm,
codemirror,
},
data() {
@ -263,6 +244,10 @@ export default {
this.item.template_id = this.templateId;
if (!this.item.params) {
this.item.params = {};
}
this.advancedOptions = this.item.arguments != null;
this.template = (await axios({

View File

@ -1,5 +1,53 @@
<template>
<div></div>
<div v-if="template.app === 'ansible'">
<v-row no-gutters class="mt-6">
<v-col cols="12" sm="6">
<v-checkbox
class="mt-0"
:value="value.debug"
@change="updateValue('debug', $event)"
>
<template v-slot:label>
<div class="text-no-wrap">{{ $t('debug') }} <code>--vvvv</code></div>
</template>
</v-checkbox>
</v-col>
<v-col cols="12" sm="6">
<v-checkbox
class="mt-0"
:value="value.dry_run"
@change="updateValue('dry_run', $event)"
>
<template v-slot:label>
<div class="text-no-wrap">{{ $t('dryRun') }} <code>--check</code></div>
</template>
</v-checkbox>
</v-col>
<v-col cols="12" sm="6">
<v-checkbox
class="mt-0"
:value="value.diff"
@change="updateValue('diff', $event)"
>
<template v-slot:label>
<div class="text-no-wrap">{{ $t('diff') }} <code>--diff</code></div>
</template>
</v-checkbox>
</v-col>
</v-row>
</div>
<div v-else-if="template.app === 'terraform' || template.app === 'tofu'">
<v-checkbox
class="mt-0"
:value="value.plan"
@change="updateValue('plan', $event)"
>
<template v-slot:label>
<div class="text-no-wrap">{{ $t('Plan') }}</div>
</template>
</v-checkbox>
</div>
<div v-else></div>
</template>
<style lang="scss">
@ -7,5 +55,15 @@
</style>
<script>
export default {
props: {
value: Object,
template: Object,
},
methods: {
updateValue(prop, value) {
this.$emit('input', { ...this.value, [prop]: value });
},
},
};
</script>