mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-05 02:06:41 +00:00
♻️ check for disabled features in general org settings page
This commit is contained in:
@@ -49,9 +49,10 @@ import { useUserContext } from "@app/hooks/useUserContext";
|
|||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import { build } from "@server/build";
|
import { build } from "@server/build";
|
||||||
import { SwitchInput } from "@app/components/SwitchInput";
|
import { SwitchInput } from "@app/components/SwitchInput";
|
||||||
import { SecurityFeaturesAlert } from "@app/components/SecurityFeaturesAlert";
|
import { PaidFeaturesAlert } from "@app/components/PaidFeaturesAlert";
|
||||||
import { useLicenseStatusContext } from "@app/hooks/useLicenseStatusContext";
|
import { useLicenseStatusContext } from "@app/hooks/useLicenseStatusContext";
|
||||||
import { useSubscriptionStatusContext } from "@app/hooks/useSubscriptionStatusContext";
|
import { useSubscriptionStatusContext } from "@app/hooks/useSubscriptionStatusContext";
|
||||||
|
import { usePaidStatus } from "@app/hooks/usePaidStatus";
|
||||||
|
|
||||||
// Session length options in hours
|
// Session length options in hours
|
||||||
const SESSION_LENGTH_OPTIONS = [
|
const SESSION_LENGTH_OPTIONS = [
|
||||||
@@ -113,16 +114,7 @@ export default function GeneralPage() {
|
|||||||
const { user } = useUserContext();
|
const { user } = useUserContext();
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
const { env } = useEnvContext();
|
const { env } = useEnvContext();
|
||||||
const { isUnlocked } = useLicenseStatusContext();
|
const { isPaidUser, hasSaasSubscription } = usePaidStatus();
|
||||||
const subscription = useSubscriptionStatusContext();
|
|
||||||
|
|
||||||
// Check if security features are disabled due to licensing/subscription
|
|
||||||
const isSecurityFeatureDisabled = () => {
|
|
||||||
const isEnterpriseNotLicensed = build === "enterprise" && !isUnlocked();
|
|
||||||
const isSaasNotSubscribed =
|
|
||||||
build === "saas" && !subscription?.isSubscribed();
|
|
||||||
return isEnterpriseNotLicensed || isSaasNotSubscribed;
|
|
||||||
};
|
|
||||||
|
|
||||||
const [loadingDelete, setLoadingDelete] = useState(false);
|
const [loadingDelete, setLoadingDelete] = useState(false);
|
||||||
const [loadingSave, setLoadingSave] = useState(false);
|
const [loadingSave, setLoadingSave] = useState(false);
|
||||||
@@ -398,9 +390,7 @@ export default function GeneralPage() {
|
|||||||
{LOG_RETENTION_OPTIONS.filter(
|
{LOG_RETENTION_OPTIONS.filter(
|
||||||
(option) => {
|
(option) => {
|
||||||
if (
|
if (
|
||||||
build ==
|
hasSaasSubscription &&
|
||||||
"saas" &&
|
|
||||||
!subscription?.subscribed &&
|
|
||||||
option.value >
|
option.value >
|
||||||
30
|
30
|
||||||
) {
|
) {
|
||||||
@@ -428,19 +418,15 @@ export default function GeneralPage() {
|
|||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{build != "oss" && (
|
{build !== "oss" && (
|
||||||
<>
|
<>
|
||||||
<SecurityFeaturesAlert />
|
<PaidFeaturesAlert />
|
||||||
|
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="settingsLogRetentionDaysAccess"
|
name="settingsLogRetentionDaysAccess"
|
||||||
render={({ field }) => {
|
render={({ field }) => {
|
||||||
const isDisabled =
|
const isDisabled = !isPaidUser;
|
||||||
(build == "saas" &&
|
|
||||||
!subscription?.subscribed) ||
|
|
||||||
(build == "enterprise" &&
|
|
||||||
!isUnlocked());
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
@@ -506,11 +492,7 @@ export default function GeneralPage() {
|
|||||||
control={form.control}
|
control={form.control}
|
||||||
name="settingsLogRetentionDaysAction"
|
name="settingsLogRetentionDaysAction"
|
||||||
render={({ field }) => {
|
render={({ field }) => {
|
||||||
const isDisabled =
|
const isDisabled = !isPaidUser;
|
||||||
(build == "saas" &&
|
|
||||||
!subscription?.subscribed) ||
|
|
||||||
(build == "enterprise" &&
|
|
||||||
!isUnlocked());
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
@@ -590,13 +572,12 @@ export default function GeneralPage() {
|
|||||||
</SettingsSectionHeader>
|
</SettingsSectionHeader>
|
||||||
<SettingsSectionBody>
|
<SettingsSectionBody>
|
||||||
<SettingsSectionForm>
|
<SettingsSectionForm>
|
||||||
<SecurityFeaturesAlert />
|
<PaidFeaturesAlert />
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="requireTwoFactor"
|
name="requireTwoFactor"
|
||||||
render={({ field }) => {
|
render={({ field }) => {
|
||||||
const isDisabled =
|
const isDisabled = !isPaidUser;
|
||||||
isSecurityFeatureDisabled();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FormItem className="col-span-2">
|
<FormItem className="col-span-2">
|
||||||
@@ -643,8 +624,7 @@ export default function GeneralPage() {
|
|||||||
control={form.control}
|
control={form.control}
|
||||||
name="maxSessionLengthHours"
|
name="maxSessionLengthHours"
|
||||||
render={({ field }) => {
|
render={({ field }) => {
|
||||||
const isDisabled =
|
const isDisabled = !isPaidUser;
|
||||||
isSecurityFeatureDisabled();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FormItem className="col-span-2">
|
<FormItem className="col-span-2">
|
||||||
@@ -730,8 +710,7 @@ export default function GeneralPage() {
|
|||||||
control={form.control}
|
control={form.control}
|
||||||
name="passwordExpiryDays"
|
name="passwordExpiryDays"
|
||||||
render={({ field }) => {
|
render={({ field }) => {
|
||||||
const isDisabled =
|
const isDisabled = !isPaidUser;
|
||||||
isSecurityFeatureDisabled();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FormItem className="col-span-2">
|
<FormItem className="col-span-2">
|
||||||
|
|||||||
Reference in New Issue
Block a user