-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: role management is only allowed on paid inAppSurveys plan (#1824)
- Loading branch information
1 parent
1ce02ed
commit ab22c02
Showing
9 changed files
with
106 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,29 @@ | ||
import "server-only"; | ||
|
||
import { unstable_cache } from "next/cache"; | ||
import { ENTERPRISE_LICENSE_KEY, IS_FORMBRICKS_CLOUD } from "@formbricks/lib/constants"; | ||
import { TTeam } from "@formbricks/types/teams"; | ||
|
||
import { ENTERPRISE_LICENSE_KEY } from "@formbricks/lib/constants"; | ||
export const getIsEnterpriseEdition = (): boolean => { | ||
if (ENTERPRISE_LICENSE_KEY) { | ||
return ENTERPRISE_LICENSE_KEY.length > 0; | ||
} | ||
return false; | ||
}; | ||
|
||
export const getIsEnterpriseEdition = () => | ||
unstable_cache( | ||
async () => { | ||
if (ENTERPRISE_LICENSE_KEY) { | ||
return ENTERPRISE_LICENSE_KEY?.length > 0; | ||
} | ||
return false; | ||
}, | ||
["getIsEnterpriseEdition"], | ||
{ revalidate: 60 * 60 * 24 } | ||
)(); | ||
export const getRemoveInAppBrandingPermission = (team: TTeam): boolean => { | ||
if (IS_FORMBRICKS_CLOUD) return team.billing.features.inAppSurvey.status !== "inactive"; | ||
else if (!IS_FORMBRICKS_CLOUD) return getIsEnterpriseEdition(); | ||
else return false; | ||
}; | ||
|
||
export const getRemoveLinkBrandingPermission = (team: TTeam): boolean => { | ||
if (IS_FORMBRICKS_CLOUD) return team.billing.features.linkSurvey.status !== "inactive"; | ||
else if (!IS_FORMBRICKS_CLOUD) return true; | ||
else return false; | ||
}; | ||
|
||
export const getRoleManagementPermission = (team: TTeam): boolean => { | ||
if (IS_FORMBRICKS_CLOUD) return team.billing.features.inAppSurvey.status !== "inactive"; | ||
else if (!IS_FORMBRICKS_CLOUD) return getIsEnterpriseEdition(); | ||
else return false; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,26 @@ | ||
import { LightBulbIcon } from "@heroicons/react/24/outline"; | ||
import Link from "next/link"; | ||
|
||
import { Alert } from "../Alert"; | ||
import { Alert, AlertDescription } from "../Alert"; | ||
|
||
export const UpgradePlanNotice = ({ message }: { message: string }) => { | ||
export const UpgradePlanNotice = ({ | ||
message, | ||
url, | ||
textForUrl, | ||
}: { | ||
message: string; | ||
url: string; | ||
textForUrl: string; | ||
}) => { | ||
return ( | ||
<Alert className="flex items-center"> | ||
<LightBulbIcon className="h-5 w-5 text-gray-500" /> | ||
<span className="text-sm text-gray-500">{message}</span> | ||
<AlertDescription> | ||
<span className="mr-2 text-sm text-gray-500">{message}</span> | ||
<span className="underline"> | ||
<Link href={url}>{textForUrl}</Link> | ||
</span> | ||
</AlertDescription> | ||
</Alert> | ||
); | ||
}; |