mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-07 03:06:40 +00:00
disable re-key button for non licensed
This commit is contained in:
@@ -2112,5 +2112,6 @@
|
|||||||
"regenerateCredentialsConfirmation": "Are you sure you want to regenerate the credentials?",
|
"regenerateCredentialsConfirmation": "Are you sure you want to regenerate the credentials?",
|
||||||
"endpoint": "Endpoint",
|
"endpoint": "Endpoint",
|
||||||
"id": "Id",
|
"id": "Id",
|
||||||
"SecretKey": "Secret Key"
|
"SecretKey": "Secret Key",
|
||||||
|
"featureDisabledTooltip": "This feature is only available in the enterprise plan and require a license to use it."
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,10 @@ import {
|
|||||||
} from "@server/routers/remoteExitNode/types";
|
} from "@server/routers/remoteExitNode/types";
|
||||||
import { useRemoteExitNodeContext } from "@app/hooks/useRemoteExitNodeContext";
|
import { useRemoteExitNodeContext } from "@app/hooks/useRemoteExitNodeContext";
|
||||||
import RegenerateCredentialsModal from "@app/components/RegenerateCredentialsModal";
|
import RegenerateCredentialsModal from "@app/components/RegenerateCredentialsModal";
|
||||||
|
import { useSubscriptionStatusContext } from "@app/hooks/useSubscriptionStatusContext";
|
||||||
|
import { useLicenseStatusContext } from "@app/hooks/useLicenseStatusContext";
|
||||||
|
import { build } from "@server/build";
|
||||||
|
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@app/components/ui/tooltip";
|
||||||
|
|
||||||
export default function CredentialsPage() {
|
export default function CredentialsPage() {
|
||||||
const { env } = useEnvContext();
|
const { env } = useEnvContext();
|
||||||
@@ -34,6 +38,17 @@ export default function CredentialsPage() {
|
|||||||
const [modalOpen, setModalOpen] = useState(false);
|
const [modalOpen, setModalOpen] = useState(false);
|
||||||
const [credentials, setCredentials] = useState<PickRemoteExitNodeDefaultsResponse | null>(null);
|
const [credentials, setCredentials] = useState<PickRemoteExitNodeDefaultsResponse | null>(null);
|
||||||
|
|
||||||
|
const { licenseStatus, isUnlocked } = useLicenseStatusContext();
|
||||||
|
const subscription = useSubscriptionStatusContext();
|
||||||
|
|
||||||
|
const isSecurityFeatureDisabled = () => {
|
||||||
|
const isEnterpriseNotLicensed = build === "enterprise" && !isUnlocked();
|
||||||
|
const isSaasNotSubscribed =
|
||||||
|
build === "saas" && !subscription?.isSubscribed();
|
||||||
|
return isEnterpriseNotLicensed || isSaasNotSubscribed;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
const handleConfirmRegenerate = async () => {
|
const handleConfirmRegenerate = async () => {
|
||||||
|
|
||||||
const response = await api.get<AxiosResponse<PickRemoteExitNodeDefaultsResponse>>(
|
const response = await api.get<AxiosResponse<PickRemoteExitNodeDefaultsResponse>>(
|
||||||
@@ -82,9 +97,26 @@ export default function CredentialsPage() {
|
|||||||
</SettingsSectionHeader>
|
</SettingsSectionHeader>
|
||||||
|
|
||||||
<SettingsSectionBody>
|
<SettingsSectionBody>
|
||||||
<Button onClick={() => setModalOpen(true)}>
|
<TooltipProvider>
|
||||||
{t("regeneratecredentials")}
|
<Tooltip>
|
||||||
</Button>
|
<TooltipTrigger asChild>
|
||||||
|
<div className="inline-block">
|
||||||
|
<Button
|
||||||
|
onClick={() => setModalOpen(true)}
|
||||||
|
disabled={isSecurityFeatureDisabled()}
|
||||||
|
>
|
||||||
|
{t("regeneratecredentials")}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</TooltipTrigger>
|
||||||
|
|
||||||
|
{isSecurityFeatureDisabled() && (
|
||||||
|
<TooltipContent side="top">
|
||||||
|
{t("featureDisabledTooltip")}
|
||||||
|
</TooltipContent>
|
||||||
|
)}
|
||||||
|
</Tooltip>
|
||||||
|
</TooltipProvider>
|
||||||
</SettingsSectionBody>
|
</SettingsSectionBody>
|
||||||
</SettingsSection>
|
</SettingsSection>
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,10 @@ import { useTranslations } from "next-intl";
|
|||||||
import { PickClientDefaultsResponse } from "@server/routers/client";
|
import { PickClientDefaultsResponse } from "@server/routers/client";
|
||||||
import { useClientContext } from "@app/hooks/useClientContext";
|
import { useClientContext } from "@app/hooks/useClientContext";
|
||||||
import RegenerateCredentialsModal from "@app/components/RegenerateCredentialsModal";
|
import RegenerateCredentialsModal from "@app/components/RegenerateCredentialsModal";
|
||||||
|
import { build } from "@server/build";
|
||||||
|
import { useLicenseStatusContext } from "@app/hooks/useLicenseStatusContext";
|
||||||
|
import { useSubscriptionStatusContext } from "@app/hooks/useSubscriptionStatusContext";
|
||||||
|
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@app/components/ui/tooltip";
|
||||||
|
|
||||||
export default function CredentialsPage() {
|
export default function CredentialsPage() {
|
||||||
const { env } = useEnvContext();
|
const { env } = useEnvContext();
|
||||||
@@ -30,6 +34,17 @@ export default function CredentialsPage() {
|
|||||||
const [modalOpen, setModalOpen] = useState(false);
|
const [modalOpen, setModalOpen] = useState(false);
|
||||||
const [clientDefaults, setClientDefaults] = useState<PickClientDefaultsResponse | null>(null);
|
const [clientDefaults, setClientDefaults] = useState<PickClientDefaultsResponse | null>(null);
|
||||||
|
|
||||||
|
const { licenseStatus, isUnlocked } = useLicenseStatusContext();
|
||||||
|
const subscription = useSubscriptionStatusContext();
|
||||||
|
|
||||||
|
const isSecurityFeatureDisabled = () => {
|
||||||
|
const isEnterpriseNotLicensed = build === "enterprise" && !isUnlocked();
|
||||||
|
const isSaasNotSubscribed =
|
||||||
|
build === "saas" && !subscription?.isSubscribed();
|
||||||
|
return isEnterpriseNotLicensed || isSaasNotSubscribed;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
const handleConfirmRegenerate = async () => {
|
const handleConfirmRegenerate = async () => {
|
||||||
|
|
||||||
const res = await api.get(`/org/${orgId}/pick-client-defaults`);
|
const res = await api.get(`/org/${orgId}/pick-client-defaults`);
|
||||||
@@ -74,9 +89,25 @@ export default function CredentialsPage() {
|
|||||||
</SettingsSectionHeader>
|
</SettingsSectionHeader>
|
||||||
|
|
||||||
<SettingsSectionBody>
|
<SettingsSectionBody>
|
||||||
<Button onClick={() => setModalOpen(true)}>
|
<TooltipProvider>
|
||||||
{t("regeneratecredentials")}
|
<Tooltip>
|
||||||
</Button>
|
<TooltipTrigger asChild>
|
||||||
|
<div className="inline-block">
|
||||||
|
<Button
|
||||||
|
onClick={() => setModalOpen(true)}
|
||||||
|
disabled={isSecurityFeatureDisabled()}>
|
||||||
|
{t("regeneratecredentials")}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</TooltipTrigger>
|
||||||
|
|
||||||
|
{isSecurityFeatureDisabled() && (
|
||||||
|
<TooltipContent side="top">
|
||||||
|
{t("featureDisabledTooltip")}
|
||||||
|
</TooltipContent>
|
||||||
|
)}
|
||||||
|
</Tooltip>
|
||||||
|
</TooltipProvider>
|
||||||
</SettingsSectionBody>
|
</SettingsSectionBody>
|
||||||
</SettingsSection>
|
</SettingsSection>
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,10 @@ import { PickSiteDefaultsResponse } from "@server/routers/site";
|
|||||||
import { useSiteContext } from "@app/hooks/useSiteContext";
|
import { useSiteContext } from "@app/hooks/useSiteContext";
|
||||||
import { generateKeypair } from "../wireguardConfig";
|
import { generateKeypair } from "../wireguardConfig";
|
||||||
import RegenerateCredentialsModal from "@app/components/RegenerateCredentialsModal";
|
import RegenerateCredentialsModal from "@app/components/RegenerateCredentialsModal";
|
||||||
|
import { useLicenseStatusContext } from "@app/hooks/useLicenseStatusContext";
|
||||||
|
import { useSubscriptionStatusContext } from "@app/hooks/useSubscriptionStatusContext";
|
||||||
|
import { build } from "@server/build";
|
||||||
|
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@app/components/ui/tooltip";
|
||||||
|
|
||||||
export default function CredentialsPage() {
|
export default function CredentialsPage() {
|
||||||
const { env } = useEnvContext();
|
const { env } = useEnvContext();
|
||||||
@@ -33,6 +37,17 @@ export default function CredentialsPage() {
|
|||||||
const [wgConfig, setWgConfig] = useState("");
|
const [wgConfig, setWgConfig] = useState("");
|
||||||
const [publicKey, setPublicKey] = useState("");
|
const [publicKey, setPublicKey] = useState("");
|
||||||
|
|
||||||
|
const { licenseStatus, isUnlocked } = useLicenseStatusContext();
|
||||||
|
const subscription = useSubscriptionStatusContext();
|
||||||
|
|
||||||
|
const isSecurityFeatureDisabled = () => {
|
||||||
|
const isEnterpriseNotLicensed = build === "enterprise" && !isUnlocked();
|
||||||
|
const isSaasNotSubscribed =
|
||||||
|
build === "saas" && !subscription?.isSubscribed();
|
||||||
|
return isEnterpriseNotLicensed || isSaasNotSubscribed;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
const hydrateWireGuardConfig = (
|
const hydrateWireGuardConfig = (
|
||||||
privateKey: string,
|
privateKey: string,
|
||||||
publicKey: string,
|
publicKey: string,
|
||||||
@@ -142,12 +157,26 @@ PersistentKeepalive = 5`;
|
|||||||
</SettingsSectionHeader>
|
</SettingsSectionHeader>
|
||||||
|
|
||||||
<SettingsSectionBody>
|
<SettingsSectionBody>
|
||||||
<Button
|
<TooltipProvider>
|
||||||
onClick={() => setModalOpen(true)}
|
<Tooltip>
|
||||||
disabled={site?.type === "local"}
|
<TooltipTrigger asChild>
|
||||||
>
|
<div className="inline-block">
|
||||||
{t("regeneratecredentials")}
|
<Button
|
||||||
</Button>
|
onClick={() => setModalOpen(true)}
|
||||||
|
disabled={isSecurityFeatureDisabled()}
|
||||||
|
>
|
||||||
|
{t("regeneratecredentials")}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</TooltipTrigger>
|
||||||
|
|
||||||
|
{isSecurityFeatureDisabled() && (
|
||||||
|
<TooltipContent side="top">
|
||||||
|
{t("featureDisabledTooltip")}
|
||||||
|
</TooltipContent>
|
||||||
|
)}
|
||||||
|
</Tooltip>
|
||||||
|
</TooltipProvider>
|
||||||
</SettingsSectionBody>
|
</SettingsSectionBody>
|
||||||
</SettingsSection>
|
</SettingsSection>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user