Skip to content

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

Return an UNKNOWN environment if not found

天舟c462683feda6
diff --git a/frontend/src/components/InstanceTable.vue b/frontend/src/components/InstanceTable.vue
index ca7cce353b..e185a27d49 100644
--- a/frontend/src/components/InstanceTable.vue
+++ b/frontend/src/components/InstanceTable.vue
@@ -108,7 +108,7 @@ export default {
};
const environmentName = function (id: EnvironmentId) {
- return store.getters["environment/environmentById"](id)?.name;
+ return store.getters["environment/environmentById"](id).name;
};
return {
diff --git a/frontend/src/components/TaskTable.vue b/frontend/src/components/TaskTable.vue
index c51480d316..56ddc45fd8 100644
--- a/frontend/src/components/TaskTable.vue
+++ b/frontend/src/components/TaskTable.vue
@@ -151,7 +151,7 @@ export default {
const activeEnvironmentName = function (task: Task) {
const id = activeEnvironmentId(task);
if (id) {
- return store.getters["environment/environmentById"](id)?.name;
+ return store.getters["environment/environmentById"](id).name;
}
return "";
};
diff --git a/frontend/src/store/modules/environment.ts b/frontend/src/store/modules/environment.ts
index ce8fa84c1a..c455394d6c 100644
--- a/frontend/src/store/modules/environment.ts
+++ b/frontend/src/store/modules/environment.ts
@@ -5,6 +5,7 @@ import {
EnvironmentNew,
EnvironmentState,
ResourceObject,
+ unknown,
} from "../../types";
function convert(environment: ResourceObject): Environment {
@@ -19,19 +20,19 @@ const state: () => EnvironmentState = () => ({
});
const getters = {
- environmentList: (state: EnvironmentState) => () => {
+ environmentList: (state: EnvironmentState) => (): Environment[] => {
return state.environmentList;
},
environmentById: (state: EnvironmentState) => (
environmentId: EnvironmentId
- ): Environment | undefined => {
+ ): Environment => {
for (const environment of state.environmentList) {
if (environment.id == environmentId) {
return environment;
}
}
- return undefined;
+ return unknown("ENVIRONMENT") as Environment;
},
};
diff --git a/frontend/src/views/DatabaseNew.vue b/frontend/src/views/DatabaseNew.vue
index bbb0b61755..c8977cfa09 100644
--- a/frontend/src/views/DatabaseNew.vue
+++ b/frontend/src/views/DatabaseNew.vue
@@ -285,7 +285,7 @@ export default {
environmentId: router.currentRoute.value.query.environment
? store.getters["environment/environmentById"](
router.currentRoute.value.query.environment
- )?.id
+ ).id
: undefined,
instanceId: router.currentRoute.value.query.instance
? store.getters["instance/instanceById"](
diff --git a/frontend/src/views/TaskActivityPanel.vue b/frontend/src/views/TaskActivityPanel.vue
index f2a590d134..b3c24eb183 100644
--- a/frontend/src/views/TaskActivityPanel.vue
+++ b/frontend/src/views/TaskActivityPanel.vue
@@ -515,21 +515,13 @@ export default {
const environment: Environment = store.getters[
"environment/environmentById"
](update.oldValue);
- if (environment) {
- oldValue = environment.name;
- } else {
- oldValue = "Unknown Environment";
- }
+ oldValue = environment.name;
}
if (update.newValue) {
const environment: Environment = store.getters[
"environment/environmentById"
](update.newValue);
- if (environment) {
- newValue = environment.name;
- } else {
- newValue = "Unknown Environment";
- }
+ newValue = environment.name;
}
}
}