Skip to content

Commit

Permalink
Merge pull request #312 from giselles-ai/remove-unneeded-feature-flags
Browse files Browse the repository at this point in the history
Remove unneeded feature flags: freePlanFlag, proTeamPlanFlag, teamCreationFlag
  • Loading branch information
shige authored Jan 16, 2025
2 parents 1e4701c + 6fdb367 commit 36eb4cb
Show file tree
Hide file tree
Showing 19 changed files with 2,134 additions and 359 deletions.
3 changes: 0 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ DEBUG_FLAG="true"
VIEW_FLAG="true"
GITHUB_INTEGRATION_FLAG="true"
PLAYGROUND_V2_FLAG="true"
FREE_PLAN_FLAG="true"
PRO_TEAM_PLAN_FLAG="true"
TEAM_CREATION_FLAG="true"
DEVELOPER_FLAG="true"

# @vercel/blob https://vercel.com/docs/storage/vercel-blob/using-blob-sdk
Expand Down
12 changes: 2 additions & 10 deletions app/(main)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { GiselleLogo } from "@/components/giselle-logo";
import { proTeamPlanFlag, teamCreationFlag } from "@/flags";
import { UserButton } from "@/services/accounts/components";
import TeamCreation from "@/services/teams/components/team-creation";
import { TeamSelection } from "@/services/teams/components/team-selection";
Expand All @@ -8,9 +7,6 @@ import type { ReactNode } from "react";
import { Nav } from "./nav";

export default async function Layout({ children }: { children: ReactNode }) {
const proTeamPlan = await proTeamPlanFlag();
const teamCreation = await teamCreationFlag();

return (
<div className="h-screen overflow-y-hidden bg-black-100 divide-y divide-black-80 flex flex-col">
<header className="h-[60px] flex items-center px-[24px] justify-between">
Expand All @@ -21,12 +17,8 @@ export default async function Layout({ children }: { children: ReactNode }) {
<Nav />
</div>
<div className="flex items-center gap-4">
{proTeamPlan && (
<>
<TeamSelection />
{teamCreation && <TeamCreation />}
</>
)}
<TeamSelection />
<TeamCreation />
<UserButton />
</div>
</header>
Expand Down
24 changes: 0 additions & 24 deletions app/(main)/settings/billing/actions.ts

This file was deleted.

26 changes: 0 additions & 26 deletions app/(main)/settings/billing/page.tsx

This file was deleted.

28 changes: 8 additions & 20 deletions app/(main)/settings/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { freePlanFlag, githubIntegrationFlag, proTeamPlanFlag } from "@/flags";
import { CreditCardIcon, UserIcon, UsersIcon } from "lucide-react";
import { githubIntegrationFlag } from "@/flags";
import { UserIcon, UsersIcon } from "lucide-react";
import type { ReactNode } from "react";
import { IntegrationIcon } from "./components/integration-icon";
import { MenuLink } from "./components/menu-link";
Expand All @@ -8,8 +8,6 @@ export default async function SettingLayout({
children,
}: { children: ReactNode }) {
const displayGitHubIntegration = await githubIntegrationFlag();
const displayFreePlan = await freePlanFlag();
const displayProTeamPlan = await proTeamPlanFlag();

return (
<div className="flex divide-x divide-black-80 h-full">
Expand All @@ -32,22 +30,12 @@ export default async function SettingLayout({
Integration
</MenuLink>
)}
{!displayFreePlan && (
<MenuLink
href="/settings/billing"
icon={<CreditCardIcon className="w-4 h-4" />}
>
Billing
</MenuLink>
)}
{displayFreePlan && (
<MenuLink
href="/settings/team"
icon={<UsersIcon className="w-4 h-4" />}
>
Team
</MenuLink>
)}
<MenuLink
href="/settings/team"
icon={<UsersIcon className="w-4 h-4" />}
>
Team
</MenuLink>
</div>
</div>
<div className="px-[48px] py-[32px] flex-1">{children}</div>
Expand Down
4 changes: 1 addition & 3 deletions app/(main)/settings/team/billing-section.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Button } from "@/components/ui/button";
import { Skeleton } from "@/components/ui/skeleton";
import { proTeamPlanFlag } from "@/flags";
import { fetchCurrentTeam, isProPlan } from "@/services/teams";
import { manageBilling } from "@/services/teams/actions/manage-billing";
import { upgradeTeam } from "@/services/teams/actions/upgrade-team";
Expand All @@ -12,7 +11,6 @@ import { LocalDateTime } from "./components/local-date-time";

export default async function BillingSection() {
const team = await fetchCurrentTeam();
const proTeamPlan = await proTeamPlanFlag();

return (
<Card title="Billing">
Expand All @@ -30,7 +28,7 @@ export default async function BillingSection() {
)}
</div>

{proTeamPlan && team.type !== "internal" && (
{team.type !== "internal" && (
<form>
<Suspense
fallback={<Skeleton className="h-10 w-[120px] rounded-md" />}
Expand Down
32 changes: 0 additions & 32 deletions app/subscriptions/checkout/route.ts

This file was deleted.

14 changes: 0 additions & 14 deletions app/subscriptions/coming-soon/page.tsx

This file was deleted.

8 changes: 0 additions & 8 deletions drizzle/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,6 @@ export const supabaseUserMappings = pgTable("supabase_user_mappings", {
supabaseUserId: text("supabase_user_id").notNull().unique(),
});

export const stripeUserMappings = pgTable("stripe_user_mappings", {
userDbId: integer("user_db_id")
.notNull()
.unique()
.references(() => users.dbId),
stripeCustomerId: text("stripe_customer_id").notNull().unique(),
});

export type TeamRole = "admin" | "member";
export const teamMemberships = pgTable(
"team_memberships",
Expand Down
42 changes: 0 additions & 42 deletions flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,6 @@ export const githubIntegrationFlag = flag<boolean>({
],
});

export const freePlanFlag = flag<boolean>({
key: "free-plan",
async decide() {
return true;
// return takeLocalEnv("FREE_PLAN_FLAG");
},
description: "Enable Free Plan",
defaultValue: false,
options: [
{ value: false, label: "disable" },
{ value: true, label: "Enable" },
],
});

export const playgroundV2Flag = flag<boolean>({
key: "playground-v2",
async decide() {
Expand All @@ -92,34 +78,6 @@ export const googleOauthFlag = flag<boolean>({
],
});

export const proTeamPlanFlag = flag<boolean>({
key: "pro-team-plan",
async decide() {
return true;
// return takeLocalEnv("PRO_TEAM_PLAN_FLAG");
},
description: "Enable Pro Team Plan",
defaultValue: false,
options: [
{ value: false, label: "disable" },
{ value: true, label: "Enable" },
],
});

export const teamCreationFlag = flag<boolean>({
key: "team-creation",
async decide() {
return true;
// return takeLocalEnv("TEAM_CREATION_FLAG");
},
description: "Enable Team Creation",
defaultValue: false,
options: [
{ value: false, label: "disable" },
{ value: true, label: "Enable" },
],
});

export const developerFlag = flag<boolean>({
key: "developer",
async decide() {
Expand Down
26 changes: 1 addition & 25 deletions middleware.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { retrieveActiveStripeSubscriptionBySupabaseUserId } from "@/services/accounts/actions";
import { NextResponse } from "next/server";
import { freePlanFlag } from "./flags";
import { supabaseMiddleware } from "./lib/supabase";
import { isEmailFromRoute06 } from "./lib/utils";

export default supabaseMiddleware(async (user, request) => {
if (user == null) {
Expand All @@ -11,28 +8,7 @@ export default supabaseMiddleware(async (user, request) => {
url.pathname = "/login";
return NextResponse.redirect(url);
}

// Users can use giselle without subscription if the free plan is enabled
const freePlanEnabled = await freePlanFlag();
if (freePlanEnabled) {
return;
}

// Proceeding to check the user's subscription status since the email is not from the route06.co.jp
if (!isEmailFromRoute06(user.email ?? "")) {
const subscription = await retrieveActiveStripeSubscriptionBySupabaseUserId(
user.id,
);
if (subscription == null) {
const url = request.nextUrl.clone();
// We are planning a pricing revision.
// Temporarily hide new signups until the new plan is ready.
// url.pathname = "/subscriptions/checkout";
url.pathname = "/subscriptions/coming-soon";
return NextResponse.redirect(url);
}
/** @todo Validate subscription status */
}
return;
});

export const config = {
Expand Down
1 change: 1 addition & 0 deletions migrations/0026_military_spirit.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP TABLE "stripe_user_mappings";
Loading

0 comments on commit 36eb4cb

Please sign in to comment.