Skip to content

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

Add feature matrix for feature gating

Tianzhou Chenaace1438ce72
diff --git a/frontend/src/utils/index.ts b/frontend/src/utils/index.ts
index bda445233b..363813c0b6 100644
--- a/frontend/src/utils/index.ts
+++ b/frontend/src/utils/index.ts
@@ -1,4 +1,5 @@
export * from "./env";
export * from "./slug";
+export * from "./plan";
export * from "./task";
export * from "./util";
diff --git a/frontend/src/utils/plan.ts b/frontend/src/utils/plan.ts
new file mode 100644
index 0000000000..7c92e0c28c
--- /dev/null
+++ b/frontend/src/utils/plan.ts
@@ -0,0 +1,22 @@
+export type FeatureType =
+ // - Task can only be assigned to DBA and Owner
+ "bytebase.admin";
+
+export enum PlanType {
+ FREE = 0,
+ STANDARD = 1,
+ PREMIUM = 2,
+}
+
+// A map from the a particular feature to the respective enablement of a particular plan
+const FEATURE_MATRIX: Map<FeatureType, boolean[]> = new Map([
+ ["bytebase.admin", [false, true, true]],
+]);
+
+// Feature gate. Returns true if the particular "type" feature is supported
+export function feature(type: FeatureType): boolean {
+ const currentPlanType = PlanType.STANDARD;
+ // It must be a typo or we forget adding the entry to the FEATURE_MATRIX,
+ // so let's just crash it.
+ return FEATURE_MATRIX.get(type)![currentPlanType];
+}