fix: allow removing branding on self-hosted (#1671)

This commit is contained in:
Johannes
2023-11-22 11:44:01 +01:00
committed by GitHub
parent 593619daf9
commit dae8aaaefb
2 changed files with 17 additions and 5 deletions

View File

@@ -14,6 +14,7 @@ interface EditFormbricksBrandingProps {
product: TProduct;
canRemoveBranding: boolean;
environmentId: string;
isFormbricksCloud?: boolean;
}
export function EditFormbricksBranding({
@@ -21,6 +22,7 @@ export function EditFormbricksBranding({
product,
canRemoveBranding,
environmentId,
isFormbricksCloud,
}: EditFormbricksBrandingProps) {
const [isBrandingEnabled, setIsBrandingEnabled] = useState(
type === "linkSurvey" ? product.linkSurveyBranding : product.inAppSurveyBranding
@@ -65,7 +67,11 @@ export function EditFormbricksBranding({
</span>
) : (
<span className="underline">
<Link href={`/environments/${environmentId}/settings/billing`}>add your creditcard.</Link>
{isFormbricksCloud ? (
<Link href={`/environments/${environmentId}/settings/billing`}>add your creditcard.</Link>
) : (
<a href="mailto:hola@formbricks.com">get a self-hosted license (free to get started).</a>
)}
</span>
)}
</AlertDescription>

View File

@@ -1,7 +1,8 @@
export const revalidate = REVALIDATION_INTERVAL;
import { getIsEnterpriseEdition } from "@formbricks/ee/lib/service";
import { authOptions } from "@formbricks/lib/authOptions";
import { DEFAULT_BRAND_COLOR, REVALIDATION_INTERVAL } from "@formbricks/lib/constants";
import { DEFAULT_BRAND_COLOR, IS_FORMBRICKS_CLOUD, REVALIDATION_INTERVAL } from "@formbricks/lib/constants";
import { getMembershipByUserIdTeamId } from "@formbricks/lib/membership/service";
import { getAccessFlags } from "@formbricks/lib/membership/utils";
import { getProductByEnvironmentId } from "@formbricks/lib/product/service";
@@ -11,9 +12,9 @@ import { getServerSession } from "next-auth";
import SettingsCard from "../components/SettingsCard";
import SettingsTitle from "../components/SettingsTitle";
import { EditBrandColor } from "./components/EditBrandColor";
import { EditFormbricksBranding } from "./components/EditBranding";
import { EditHighlightBorder } from "./components/EditHighlightBorder";
import { EditPlacement } from "./components/EditPlacement";
import { EditFormbricksBranding } from "./components/EditBranding";
export default async function ProfileSettingsPage({ params }: { params: { environmentId: string } }) {
const [session, team, product] = await Promise.all([
@@ -32,8 +33,12 @@ export default async function ProfileSettingsPage({ params }: { params: { enviro
throw new Error("Team not found");
}
const canRemoveLinkBranding = team.billing.features.linkSurvey.status !== "inactive";
const canRemoveInAppBranding = team.billing.features.inAppSurvey.status !== "inactive";
const isEnterpriseEdition = await getIsEnterpriseEdition();
const canRemoveLinkBranding =
team.billing.features.linkSurvey.status !== "inactive" || !IS_FORMBRICKS_CLOUD;
const canRemoveInAppBranding =
team.billing.features.inAppSurvey.status !== "inactive" || isEnterpriseEdition;
const currentUserMembership = await getMembershipByUserIdTeamId(session?.user.id, team.id);
const { isDeveloper, isViewer } = getAccessFlags(currentUserMembership?.role);
@@ -82,6 +87,7 @@ export default async function ProfileSettingsPage({ params }: { params: { enviro
product={product}
canRemoveBranding={canRemoveInAppBranding}
environmentId={params.environmentId}
isFormbricksCloud={IS_FORMBRICKS_CLOUD}
/>
</SettingsCard>
</div>