Skip to content

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

chore: converge anomaly frontend usage pattern (#14957)

Danny Xu44c59431354e
diff --git a/frontend/src/components/AnomalyCenter/AnomalyCenterDashboard.vue b/frontend/src/components/AnomalyCenter/AnomalyCenterDashboard.vue
index 88ade1705a..e32de79795 100644
--- a/frontend/src/components/AnomalyCenter/AnomalyCenterDashboard.vue
+++ b/frontend/src/components/AnomalyCenter/AnomalyCenterDashboard.vue
@@ -128,7 +128,7 @@ import { useI18n } from "vue-i18n";
import type { BBTableSectionDataSource } from "@/bbkit/types";
import {
featureToRef,
- useAnomalyV1List,
+ useAnomalyV1Store,
useDatabaseV1Store,
useEnvironmentV1List,
useEnvironmentV1Store,
@@ -167,7 +167,7 @@ const props = defineProps<{
const { t } = useI18n();
const databaseStore = useDatabaseV1Store();
const environmentStore = useEnvironmentV1Store();
-const allAnomalyList = useAnomalyV1List();
+const allAnomalyList = await useAnomalyV1Store().fetchAnomalyList({});
const instanceList = useInstanceResourceList();
const environmentList = useEnvironmentV1List(false /* !showDeleted */);
@@ -213,7 +213,7 @@ const databaseAnomalySectionList = computed(
);
for (const database of dbList) {
- const anomalyListOfDatabase = allAnomalyList.value.filter(
+ const anomalyListOfDatabase = allAnomalyList.filter(
(anomaly) => anomaly.resource === database.name
);
@@ -255,7 +255,7 @@ const instanceAnomalySectionList = computed(
);
for (const instance of insList) {
- const anomalyListOfInstance = allAnomalyList.value.filter((anomaly) =>
+ const anomalyListOfInstance = allAnomalyList.filter((anomaly) =>
anomaly.resource.startsWith(instance.name)
);
if (anomalyListOfInstance.length > 0) {
@@ -279,7 +279,7 @@ const databaseAnomalySummaryList = computed((): Summary[] => {
let criticalCount = 0;
let highCount = 0;
let mediumCount = 0;
- const anomalyListOfDatabase = allAnomalyList.value.filter(
+ const anomalyListOfDatabase = allAnomalyList.filter(
(anomaly) => anomaly.resource === database.name
);
for (const anomaly of anomalyListOfDatabase) {
@@ -327,7 +327,7 @@ const instanceAnomalySummaryList = computed((): Summary[] => {
let criticalCount = 0;
let highCount = 0;
let mediumCount = 0;
- const anomalyListOfInstance = allAnomalyList.value.filter(
+ const anomalyListOfInstance = allAnomalyList.filter(
(anomaly) => anomaly.resource === instance.name
);
for (const anomaly of anomalyListOfInstance) {
diff --git a/frontend/src/store/modules/v1/anomaly.ts b/frontend/src/store/modules/v1/anomaly.ts
index 1e11b145d0..521a131d4f 100644
--- a/frontend/src/store/modules/v1/anomaly.ts
+++ b/frontend/src/store/modules/v1/anomaly.ts
@@ -1,8 +1,6 @@
import { defineStore } from "pinia";
-import { computed, ref, unref, watch } from "vue";
import { anomalyServiceClient } from "@/grpcweb";
-import type { FindAnomalyMessage, MaybeRef } from "@/types";
-import type { Anomaly } from "@/types/proto/v1/anomaly_service";
+import type { FindAnomalyMessage } from "@/types";
const buildFilter = (find: FindAnomalyMessage): string => {
const filter: string[] = [];
@@ -25,19 +23,3 @@ export const useAnomalyV1Store = defineStore("anomaly_v1", {
},
},
});
-
-export const useAnomalyV1List = (find: MaybeRef<FindAnomalyMessage> = {}) => {
- const store = useAnomalyV1Store();
- const query = computed(() => buildFilter(unref(find)));
- const list = ref<Anomaly[]>([]);
- watch(
- query,
- () => {
- store.fetchAnomalyList(unref(find)).then((result) => {
- list.value = result;
- });
- },
- { immediate: true }
- );
- return list;
-};