Skip to content

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

Add “not selected” option and selectDefault props and make TaskSidebar use it.

Tianzhou Chen574ada4c9d67
diff --git a/frontend/src/components/EnvironmentSelect.vue b/frontend/src/components/EnvironmentSelect.vue
index 797250920f..4c01420ee1 100644
--- a/frontend/src/components/EnvironmentSelect.vue
+++ b/frontend/src/components/EnvironmentSelect.vue
@@ -7,6 +7,9 @@
}
"
>
+ <option disabled :selected="undefined === state.selectedId">
+ Not selected
+ </option>
<option
v-for="(environment, index) in state.environmentList"
:key="index"
@@ -37,6 +40,10 @@ export default {
selectedId: {
type: String,
},
+ selectDefault: {
+ default: true,
+ type: Boolean,
+ },
},
setup(props, { emit }) {
const state = reactive<LocalState>({
@@ -52,7 +59,11 @@ export default {
// Usually env is ordered by ascending importantance, thus we rervese the order to put
// more important ones first.
state.environmentList = cloneDeep(list).reverse();
- if (!state.selectedId && state.environmentList.length > 0) {
+ if (
+ !props.selectedId &&
+ props.selectDefault &&
+ state.environmentList.length > 0
+ ) {
state.selectedId = state.environmentList[0].id;
emit("select-environment-id", state.selectedId);
}
diff --git a/frontend/src/views/TaskSidebar.vue b/frontend/src/views/TaskSidebar.vue
index 46939e5e97..b3e15cd0ef 100644
--- a/frontend/src/views/TaskSidebar.vue
+++ b/frontend/src/views/TaskSidebar.vue
@@ -67,11 +67,7 @@
type="text"
class="textfield w-full"
:name="field.id"
- :value="
- field.preprocessor
- ? field.preprocessor(task.attributes.payload[field.id])
- : task.attributes.payload[field.id]
- "
+ :value="fieldValue(field)"
:placeholder="field.placeholder"
@input="
$emit('update-custom-field', field, $event.target.value)
@@ -83,11 +79,8 @@
<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]
- "
+ :selectedId="fieldValue(field)"
+ :selectDefault="false"
@select-environment-id="
(environmentId) => {
$emit('update-custom-field', field, environmentId);
@@ -155,9 +148,15 @@ export default {
state.new = isEmpty(props.task.id);
};
+ const fieldValue = (field: TaskField): string => {
+ return field.preprocessor
+ ? field.preprocessor(props.task.attributes.payload[field.id])
+ : props.task.attributes.payload[field.id];
+ };
+
watchEffect(refreshState);
- return { state, activeStageIsRunning };
+ return { state, activeStageIsRunning, fieldValue };
},
};
</script>