Skip to content

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

chore: remove unused components (#16759)

boojackd01d8c181cbb
diff --git a/frontend/src/components/Plan/PlanDetailPage.vue b/frontend/src/components/Plan/PlanDetailPage.vue
deleted file mode 100644
index 727103ed1f..0000000000
--- a/frontend/src/components/Plan/PlanDetailPage.vue
+++ /dev/null
@@ -1,216 +0,0 @@
-<template>
- <div class="h-full flex flex-col">
- <HeaderSection />
- <NTabs
- type="line"
- :value="tabKey"
- tab-class="first:ml-4"
- @update-value="handleTabChange"
- >
- <NTab
- v-for="tab in availableTabs"
- :key="tab"
- :name="tab"
- :tab="tabRender(tab)"
- />
-
- <!-- Suffix slot for Specifications tab -->
- <template v-if="tabKey === TabKey.Specifications" #suffix>
- <div class="pr-4 flex flex-row justify-end items-center">
- <CurrentSpecSelector />
- </div>
- </template>
- </NTabs>
-
- <div class="flex-1 flex">
- <Overview v-if="tabKey === TabKey.Overview" />
- <SpecsView v-else-if="tabKey === TabKey.Specifications" />
- <ChecksView v-else-if="tabKey === TabKey.Checks" />
- <IssueReviewView v-else-if="tabKey === TabKey.Review" />
- <RolloutView v-else-if="tabKey === TabKey.Rollout" />
- <div class="pt-4 mx-auto max-w-2xl" v-else>
- <p>Unknown view for {{ tabKey }}</p>
- </div>
- </div>
- </div>
-</template>
-
-<script setup lang="tsx">
-import { head } from "lodash-es";
-import { NTab, NTabs } from "naive-ui";
-import { computed } from "vue";
-import { useI18n } from "vue-i18n";
-import { useRoute, useRouter } from "vue-router";
-import {
- PROJECT_V1_ROUTE_ISSUE_DETAIL_V1,
- PROJECT_V1_ROUTE_PLAN_DETAIL,
- PROJECT_V1_ROUTE_PLAN_DETAIL_CHECK_RUNS,
- PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL,
- PROJECT_V1_ROUTE_PLAN_DETAIL_SPECS,
- PROJECT_V1_ROUTE_ROLLOUT_DETAIL,
-} from "@/router/dashboard/projectV1";
-import {
- extractIssueUID,
- extractPlanUID,
- extractRolloutUID,
-} from "@/utils";
-import { ChecksView, HeaderSection, Overview } from "./components";
-import CurrentSpecSelector from "./components/CurrentSpecSelector.vue";
-import { IssueReviewView } from "./components/IssueReviewView";
-import { RolloutView } from "./components/RolloutView";
-import SpecsView from "./components/SpecsView.vue";
-import { useSpecsValidation } from "./components/common";
-import { gotoSpec } from "./components/common/utils";
-import { usePlanContext } from "./logic";
-
-enum TabKey {
- Overview = "overview",
- Specifications = "specifications",
- Checks = "checks",
- Review = "review",
- Rollout = "rollout",
-}
-
-const { t } = useI18n();
-const route = useRoute();
-const router = useRouter();
-const { isCreating, plan } = usePlanContext();
-const { isSpecEmpty } = useSpecsValidation(plan.value.specs);
-
-const planCheckRunCount = computed(() =>
- Object.values(plan.value.planCheckRunStatusCount).reduce(
- (sum, count) => sum + count,
- 0
- )
-);
-
-const tabKey = computed(() => {
- const routeName = route.name?.toString() as string;
- if (
- [
- PROJECT_V1_ROUTE_PLAN_DETAIL_SPECS,
- PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL,
- ].includes(routeName)
- ) {
- return TabKey.Specifications;
- } else if ([PROJECT_V1_ROUTE_PLAN_DETAIL_CHECK_RUNS].includes(routeName)) {
- return TabKey.Checks;
- } else if (routeName === PROJECT_V1_ROUTE_ISSUE_DETAIL_V1) {
- return TabKey.Review;
- } else if (routeName === PROJECT_V1_ROUTE_ROLLOUT_DETAIL) {
- return TabKey.Rollout;
- }
- // Fallback to Overview if no specific tab is matched.
- return TabKey.Overview;
-});
-
-const availableTabs = computed<TabKey[]>(() => {
- const tabs: TabKey[] = [TabKey.Overview, TabKey.Specifications];
- if (!isCreating.value) {
- if (
- plan.value.specs.some(
- (spec) => spec.config?.case === "changeDatabaseConfig"
- )
- ) {
- tabs.push(TabKey.Checks);
- }
- if (plan.value.issue) {
- tabs.push(TabKey.Review);
- }
- if (plan.value.rollout) {
- tabs.push(TabKey.Rollout);
- }
- }
- return tabs;
-});
-
-const tabRender = (tab: TabKey) => {
- switch (tab) {
- case TabKey.Overview:
- return t("common.overview");
- case TabKey.Specifications:
- return (
- <div>
- {t("plan.navigator.specifications")}
- {plan.value.specs.some(isSpecEmpty) && (
- <span
- class="text-error ml-0.5"
- title={t("plan.navigator.statement-empty")}
- >
- *
- </span>
- )}
- </div>
- );
- case TabKey.Checks:
- return (
- <div>
- {t("plan.navigator.checks")}
- {planCheckRunCount.value > 0 && (
- <span class="text-gray-500">({planCheckRunCount.value})</span>
- )}
- </div>
- );
- case TabKey.Review:
- return t("plan.navigator.review");
- case TabKey.Rollout:
- return t("plan.navigator.rollout");
- default:
- // Fallback to raw tab name.
- return tab;
- }
-};
-
-const handleTabChange = (tab: TabKey) => {
- const params = route.params;
- if (isCreating.value) {
- params.planId = "create";
- } else {
- params.planId = extractPlanUID(plan.value.name);
- if (plan.value.issue) {
- params.issueId = extractIssueUID(plan.value.issue);
- }
- if (plan.value.rollout) {
- params.rolloutId = extractRolloutUID(plan.value.rollout);
- }
- }
-
- if (tab === TabKey.Overview) {
- router.push({
- name: PROJECT_V1_ROUTE_PLAN_DETAIL,
- params: params,
- query: route.query,
- });
- } else if (tab === TabKey.Specifications) {
- // Auto select the first spec when switching to Specifications tab.
- const spec = head(plan.value.specs);
- if (spec) {
- gotoSpec(router, spec.id);
- } else {
- router.push({
- name: PROJECT_V1_ROUTE_PLAN_DETAIL_SPECS,
- params: params,
- query: route.query,
- });
- }
- } else if (tab === TabKey.Checks) {
- router.push({
- name: PROJECT_V1_ROUTE_PLAN_DETAIL_CHECK_RUNS,
- params: params,
- query: route.query,
- });
- } else if (tab === TabKey.Review) {
- router.push({
- name: PROJECT_V1_ROUTE_ISSUE_DETAIL_V1,
- params: params,
- query: route.query,
- });
- } else if (tab === TabKey.Rollout) {
- router.push({
- name: PROJECT_V1_ROUTE_ROLLOUT_DETAIL,
- params: params,
- query: route.query,
- });
- }
-};
-</script>
diff --git a/frontend/src/components/Plan/components/CurrentSpecSelector.vue b/frontend/src/components/Plan/components/CurrentSpecSelector.vue
index 4f6a10a002..772c4125b9 100644
--- a/frontend/src/components/Plan/components/CurrentSpecSelector.vue
+++ b/frontend/src/components/Plan/components/CurrentSpecSelector.vue
@@ -105,12 +105,12 @@ const getSpecTypeName = (spec: Plan_Spec): string => {
};
const handleSpecChange = (specId: string) => {
- gotoSpec(router, specId);
+ gotoSpec(router, plan.value, specId);
};
const handleSpecCreated = async (spec: Plan_Spec) => {
// Add the new spec to the plan
plan.value.specs.push(spec);
- gotoSpec(router, spec.id);
+ gotoSpec(router, plan.value, spec.id);
};
</script>
diff --git a/frontend/src/components/Plan/components/SpecDetailView/context.ts b/frontend/src/components/Plan/components/SpecDetailView/context.ts
index 1b482ce558..54f6ec4134 100644
--- a/frontend/src/components/Plan/components/SpecDetailView/context.ts
+++ b/frontend/src/components/Plan/components/SpecDetailView/context.ts
@@ -52,7 +52,7 @@ export const providePlanSpecContext = (refs: {
if (!foundSpec) {
throw new Error("No specs available in the plan to redirect to.");
}
- gotoSpec(router, foundSpec.id);
+ gotoSpec(router, plan.value, foundSpec.id);
}
});
diff --git a/frontend/src/components/Plan/components/common/utils.ts b/frontend/src/components/Plan/components/common/utils.ts
index add15bb651..a495d347de 100644
--- a/frontend/src/components/Plan/components/common/utils.ts
+++ b/frontend/src/components/Plan/components/common/utils.ts
@@ -1,7 +1,9 @@
import { type Router } from "vue-router";
import { PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL } from "@/router/dashboard/projectV1";
+import type { Plan } from "@/types/proto-es/v1/plan_service_pb";
+import { extractPlanUID } from "@/utils";
-export const gotoSpec = (router: Router, specId: string) => {
+export const gotoSpec = (router: Router, plan: Plan, specId: string) => {
// Defensive check for router and currentRoute
if (!router || !router.currentRoute?.value) {
console.error("Router or currentRoute is not available in gotoSpec");
@@ -9,11 +11,11 @@ export const gotoSpec = (router: Router, specId: string) => {
}
const currentRoute = router.currentRoute.value;
-
router.push({
name: PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL,
params: {
...(currentRoute.params || {}),
+ planId: extractPlanUID(plan.name),
specId,
},
query: currentRoute.query || {},
diff --git a/frontend/src/components/Plan/index.ts b/frontend/src/components/Plan/index.ts
index 33745ea948..f1104893b6 100644
--- a/frontend/src/components/Plan/index.ts
+++ b/frontend/src/components/Plan/index.ts
@@ -1,5 +1 @@
-import PlanDetailPage from "./PlanDetailPage.vue";
-
export * from "./logic";
-
-export { PlanDetailPage };
diff --git a/frontend/src/views/project/CICDLayout.vue b/frontend/src/views/project/CICDLayout.vue
index 3c029b1da5..59d499eece 100644
--- a/frontend/src/views/project/CICDLayout.vue
+++ b/frontend/src/views/project/CICDLayout.vue
@@ -160,7 +160,9 @@ const availableTabs = computed<TabKey[]>(() => {
if (!isCreating.value) {
if (
plan.value.specs.some(
- (spec) => !isNullOrUndefined(spec.config) && spec.config.case === "changeDatabaseConfig"
+ (spec) =>
+ !isNullOrUndefined(spec.config) &&
+ spec.config.case === "changeDatabaseConfig"
)
) {
tabs.push(TabKey.Checks);
@@ -243,7 +245,7 @@ const handleTabChange = (tab: TabKey) => {
// Auto select the first spec when switching to Specifications tab.
const spec = head(plan.value.specs);
if (spec) {
- gotoSpec(router, spec.id);
+ gotoSpec(router, plan.value, spec.id);
} else {
router.push({
name: PROJECT_V1_ROUTE_PLAN_DETAIL_SPECS,
diff --git a/frontend/src/views/project/ProjectPlanDetail.vue b/frontend/src/views/project/ProjectPlanDetail.vue
deleted file mode 100644
index f0114c0a39..0000000000
--- a/frontend/src/views/project/ProjectPlanDetail.vue
+++ /dev/null
@@ -1,80 +0,0 @@
-<template>
- <div class="relative overflow-x-hidden h-full">
- <template v-if="ready">
- <PlanDetailPage :key="plan.name" />
- </template>
- <div v-else class="w-full h-full flex flex-col items-center justify-center">
- <NSpin />
- </div>
- </div>
-</template>
-
-<script lang="ts" setup>
-import { useTitle } from "@vueuse/core";
-import { NSpin } from "naive-ui";
-import { computed, toRef } from "vue";
-import { useI18n } from "vue-i18n";
-import {
- providePlanContext,
- useBasePlanContext,
- useInitializePlan,
-} from "@/components/Plan";
-import PlanDetailPage from "@/components/Plan/PlanDetailPage.vue";
-import { provideIssueReviewContext } from "@/components/Plan/logic/issue-review";
-import { useBodyLayoutContext } from "@/layouts/common";
-import { isValidPlanName } from "@/utils";
-
-const props = defineProps<{
- projectId: string;
- planId?: string;
- issueId?: string;
- rolloutId?: string;
-}>();
-
-const { t } = useI18n();
-const { isCreating, plan, planCheckRuns, issue, rollout, isInitializing } =
- useInitializePlan(
- toRef(props, "projectId"),
- toRef(props, "planId"),
- toRef(props, "issueId"),
- toRef(props, "rolloutId")
- );
-const planBaseContext = useBasePlanContext({
- isCreating,
- plan,
-});
-
-const ready = computed(() => {
- return !isInitializing.value && !!plan.value;
-});
-
-providePlanContext(
- {
- isCreating,
- plan,
- planCheckRuns,
- issue,
- rollout,
- ...planBaseContext,
- },
- true /* root */
-);
-
-provideIssueReviewContext(issue);
-
-const { overrideMainContainerClass } = useBodyLayoutContext();
-
-overrideMainContainerClass("!py-0 !px-0");
-
-const documentTitle = computed(() => {
- if (isCreating.value) {
- return t("plan.new-plan");
- } else {
- if (ready.value && isValidPlanName(plan.value.name)) {
- return plan.value.title;
- }
- }
- return t("common.loading");
-});
-useTitle(documentTitle);
-</script>