Skip to content

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

feat(frontend): BYT-810 avoid the tooltip to be clipped near the edge of the window (#1677)

Liu Ji0d9c9c53fce8
diff --git a/frontend/src/components/PricingTable/FeatureItem.vue b/frontend/src/components/PricingTable/FeatureItem.vue
new file mode 100644
index 0000000000..91acf8b279
--- /dev/null
+++ b/frontend/src/components/PricingTable/FeatureItem.vue
@@ -0,0 +1,56 @@
+<template>
+ <td
+ class="font-semibold tooltip-wrapper"
+ :class="plan.highlight ? 'text-indigo-600' : 'text-gray-600'"
+ >
+ <NTooltip
+ trigger="hover"
+ :disabled="!featureDetail?.tooltip"
+ :show-arrow="false"
+ style="margin-bottom: -1rem"
+ >
+ <template #trigger>
+ <div class="flex justify-center py-5 px-6">
+ <template v-if="featureDetail">
+ <span v-if="featureDetail.content" class="block text-sm">{{
+ $t(featureDetail.content ?? "")
+ }}</span>
+ <heroicons-solid:check v-else class="w-5 h-5" />
+ </template>
+ <template v-else>
+ <heroicons-solid:minus class="w-5 h-5" />
+ </template>
+ <heroicons-solid:question-mark-circle
+ v-if="featureDetail?.tooltip"
+ class="w-5 h-5 ml-1"
+ />
+ </div>
+ </template>
+
+ <span class="whitespace-nowrap">
+ {{ $t(featureDetail?.tooltip ?? "") }}
+ </span>
+ </NTooltip>
+ </td>
+</template>
+
+<script lang="ts" setup>
+import { PropType, computed } from "vue";
+import { NTooltip } from "naive-ui";
+import { LocalPlan } from "./types";
+
+const props = defineProps({
+ plan: {
+ type: Object as PropType<LocalPlan>,
+ required: true,
+ },
+ feature: {
+ type: String,
+ required: true,
+ },
+});
+
+const featureDetail = computed(() => {
+ return props.plan.features.find((f) => f.id === props.feature);
+});
+</script>
diff --git a/frontend/src/components/PricingTable.vue b/frontend/src/components/PricingTable/PricingTable.vue
similarity index 79%
rename from frontend/src/components/PricingTable.vue
rename to frontend/src/components/PricingTable/PricingTable.vue
index ed2af702ff..47fe657ebf 100644
--- a/frontend/src/components/PricingTable.vue
+++ b/frontend/src/components/PricingTable/PricingTable.vue
@@ -116,35 +116,12 @@
)
}}
</th>
- <td
+ <FeatureItem
v-for="plan in plans"
:key="plan.type"
- class="py-5 px-6 font-semibold tooltip-wrapper"
- :class="plan.highlight ? 'text-indigo-600' : 'text-gray-600'"
- >
- <div class="flex justify-center">
- <template v-if="getFeature(plan, feature)">
- <span
- v-if="getFeature(plan, feature)?.content"
- class="block text-sm"
- >{{ $t(getFeature(plan, feature)?.content ?? "") }}</span
- >
- <heroicons-solid:check v-else class="w-5 h-5" />
- </template>
- <template v-else>
- <heroicons-solid:minus class="w-5 h-5" />
- </template>
- <template v-if="getFeature(plan, feature)?.tooltip">
- <heroicons-solid:question-mark-circle class="w-5 h-5 ml-1" />
- <span
- v-if="getFeature(plan, feature)?.tooltip"
- class="tooltip whitespace-nowrap"
- >
- {{ $t(getFeature(plan, feature)?.tooltip ?? "") }}
- </span>
- </template>
- </div>
- </td>
+ :plan="plan"
+ :feature="feature"
+ />
</tr>
</template>
</tbody>
@@ -257,35 +234,7 @@
)
}}
</th>
- <td
- class="py-5 px-6 font-semibold tooltip-wrapper w-3/4"
- :class="plan.highlight ? 'text-indigo-600' : 'text-gray-600'"
- >
- <div class="flex justify-center">
- <template v-if="getFeature(plan, feature)">
- <span
- v-if="getFeature(plan, feature)?.content"
- class="block text-sm"
- >{{ $t(getFeature(plan, feature)?.content ?? "") }}</span
- >
- <heroicons-solid:check v-else class="w-5 h-5" />
- </template>
- <template v-else>
- <heroicons-solid:minus class="w-5 h-5" />
- </template>
- <template v-if="getFeature(plan, feature)?.tooltip">
- <heroicons-solid:question-mark-circle
- class="w-5 h-5 ml-1"
- />
- <span
- v-if="getFeature(plan, feature)?.tooltip"
- class="tooltip whitespace-nowrap"
- >
- {{ $t(getFeature(plan, feature)?.tooltip ?? "") }}
- </span>
- </template>
- </div>
- </td>
+ <FeatureItem :plan="plan" :feature="feature" class="w-3/4" />
</tr>
</template>
</tbody>
@@ -309,6 +258,7 @@
<script lang="ts">
import { reactive, computed, watch, defineComponent } from "vue";
+import { useI18n } from "vue-i18n";
import {
Plan,
PlanType,
@@ -316,30 +266,21 @@ import {
FREE_PLAN,
TEAM_PLAN,
ENTERPRISE_PLAN,
-} from "../types";
-import { useI18n } from "vue-i18n";
+} from "@/types";
import { useSubscriptionStore } from "@/store";
+import { LocalPlan } from "./types";
+import FeatureItem from "./FeatureItem.vue";
interface LocalState {
isMonthly: boolean;
instanceCount: number;
}
-interface LocalPlan extends Plan {
- label: string;
- image: string;
- buttonText: string;
- highlight: boolean;
- isFreePlan: boolean;
- isAvailable: boolean;
- pricePrefix: string;
- priceUnit: string;
-}
-
const minimumInstanceCount = 5;
export default defineComponent({
name: "PricingTable",
+ components: { FeatureItem },
setup() {
const { t } = useI18n();
const subscriptionStore = useSubscriptionStore();
@@ -359,7 +300,7 @@ export default defineComponent({
return [FREE_PLAN, TEAM_PLAN, ENTERPRISE_PLAN].map((plan) => ({
...plan,
image: new URL(
- `../assets/plan-${plan.title.toLowerCase()}.png`,
+ `../../assets/plan-${plan.title.toLowerCase()}.png`,
import.meta.url
).href,
buttonText: getButtonText(plan),
@@ -376,10 +317,6 @@ export default defineComponent({
}));
});
- const getFeature = (plan: Plan, feature: string) => {
- return plan.features.find((f) => f.id === feature);
- };
-
const getButtonText = (plan: Plan): string => {
if (plan.type === PlanType.FREE) return t("subscription.deploy");
if (plan.type === PlanType.ENTERPRISE)
@@ -417,7 +354,6 @@ export default defineComponent({
plans,
canTrial,
sections: FEATURE_SECTIONS,
- getFeature,
onButtonClick,
minimumInstanceCount,
};
diff --git a/frontend/src/components/PricingTable/index.ts b/frontend/src/components/PricingTable/index.ts
new file mode 100644
index 0000000000..cad5f0888f
--- /dev/null
+++ b/frontend/src/components/PricingTable/index.ts
@@ -0,0 +1,3 @@
+import PricingTable from "./PricingTable.vue";
+
+export default PricingTable;
diff --git a/frontend/src/components/PricingTable/types.ts b/frontend/src/components/PricingTable/types.ts
new file mode 100644
index 0000000000..2aad71c52a
--- /dev/null
+++ b/frontend/src/components/PricingTable/types.ts
@@ -0,0 +1,12 @@
+import { Plan } from "@/types";
+
+export interface LocalPlan extends Plan {
+ label: string;
+ image: string;
+ buttonText: string;
+ highlight: boolean;
+ isFreePlan: boolean;
+ isAvailable: boolean;
+ pricePrefix: string;
+ priceUnit: string;
+}
diff --git a/frontend/src/views/SettingWorkspaceSubscription.vue b/frontend/src/views/SettingWorkspaceSubscription.vue
index 927ba623ee..b89f7856eb 100644
--- a/frontend/src/views/SettingWorkspaceSubscription.vue
+++ b/frontend/src/views/SettingWorkspaceSubscription.vue
@@ -73,7 +73,7 @@
<script lang="ts">
import { computed, defineComponent, reactive } from "vue";
import { useI18n } from "vue-i18n";
-import PricingTable from "../components/PricingTable.vue";
+import PricingTable from "../components/PricingTable/";
import { PlanType } from "../types";
import { pushNotification, useSubscriptionStore } from "@/store";
import { storeToRefs } from "pinia";