Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

Add Environment Select to Request Data Source task template, also introduce the Environment Select control in the task sidebar

Tianzhou Chen7a468d3fa17f
diff --git a/frontend/src/plugins/task/template.ts b/frontend/src/plugins/task/template.ts
index c4a4ddba4f..55712b5808 100644
--- a/frontend/src/plugins/task/template.ts
+++ b/frontend/src/plugins/task/template.ts
@@ -1,5 +1,5 @@
import { TaskTemplate, TemplateContext } from "../types";
-import { TaskNew } from "../../types";
+import { EnvironmentId, TaskNew } from "../../types";
export const taskTemplateList: TaskTemplate[] = [
{
@@ -68,6 +68,20 @@ export const taskTemplateList: TaskTemplate[] = [
return name?.toLowerCase();
},
},
+ {
+ category: "INPUT",
+ id: 2,
+ slug: "env",
+ name: "Environment",
+ type: "Environment",
+ required: true,
+ preprocessor: (environmentId: EnvironmentId): string => {
+ // In case caller passes corrupted data.
+ // Handled here instead of the caller, because it's
+ // preprocessor specific behavior to handle fallback.
+ return environmentId;
+ },
+ },
{
category: "OUTPUT",
id: 99,
diff --git a/frontend/src/plugins/types.ts b/frontend/src/plugins/types.ts
index f0a5925c32..7bd9bdff27 100644
--- a/frontend/src/plugins/types.ts
+++ b/frontend/src/plugins/types.ts
@@ -1,7 +1,7 @@
import { Environment, TaskNew, User } from "../types";
// Task
-export type TaskFieldType = "String";
+export type TaskFieldType = "String" | "Environment";
export type TaskField = {
category: "INPUT" | "OUTPUT";
diff --git a/frontend/src/views/TaskSidebar.vue b/frontend/src/views/TaskSidebar.vue
index 939fe62fd2..69af8626d0 100644
--- a/frontend/src/views/TaskSidebar.vue
+++ b/frontend/src/views/TaskSidebar.vue
@@ -56,11 +56,11 @@
</div>
<template v-for="(field, index) in fieldList" :key="index">
<div class="flex flex-row space-x-2 lg:flex-col lg:space-x-0">
+ <h2 class="flex items-center textlabel w-1/4 lg:w-auto">
+ {{ field.name }}
+ <span v-if="field.required" class="text-red-600">*</span>
+ </h2>
<template v-if="field.type == 'String'">
- <h2 class="flex items-center textlabel w-1/4 lg:w-auto">
- {{ field.name }}
- <span v-if="field.required" class="text-red-600">*</span>
- </h2>
<div class="lg:mt-3 w-3/4 lg:w-auto">
<input
type="text"
@@ -78,6 +78,23 @@
/>
</div>
</template>
+ <template v-else-if="field.type == 'Environment'">
+ <div class="lg:mt-3 w-3/4 lg:w-auto">
+ <EnvironmentSelect
+ :name="field.id"
+ :selectedId="
+ field.preprocessor
+ ? field.preprocessor(task.attributes.payload[field.id])
+ : task.attributes.payload[field.id]
+ "
+ @select-environment-id="
+ (environmentId) => {
+ $emit('update-custom-field', field, environmentId);
+ }
+ "
+ />
+ </div>
+ </template>
</div>
</template>
</div>
@@ -121,6 +138,7 @@
<script lang="ts">
import { PropType, watchEffect, reactive } from "vue";
import isEmpty from "lodash-es/isEmpty";
+import EnvironmentSelect from "../components/EnvironmentSelect.vue";
import TaskStatusSelect from "../components/TaskStatusSelect.vue";
import { TaskField } from "../plugins";
import { Task } from "../types";
@@ -143,7 +161,7 @@ export default {
type: Object as PropType<TaskField[]>,
},
},
- components: { TaskStatusSelect },
+ components: { EnvironmentSelect, TaskStatusSelect },
setup(props, { emit }) {
const state = reactive<LocalState>({
new: isEmpty(props.task.id),