mirror of
https://github.com/fosrl/pangolin.git
synced 2026-06-11 18:09:05 +00:00
Properly paywall the new resource types
This commit is contained in:
@@ -16,10 +16,7 @@ import { useOrgContext } from "@app/hooks/useOrgContext";
|
||||
import { usePaidStatus } from "@app/hooks/usePaidStatus";
|
||||
import { toast } from "@app/hooks/useToast";
|
||||
import { createApiClient, formatAxiosError } from "@app/lib/api";
|
||||
import type {
|
||||
CreateRoleBody,
|
||||
CreateRoleResponse
|
||||
} from "@server/routers/role";
|
||||
import type { CreateRoleBody, CreateRoleResponse } from "@server/routers/role";
|
||||
import { AxiosResponse } from "axios";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { useTransition } from "react";
|
||||
@@ -50,7 +47,7 @@ export default function CreateRoleForm({
|
||||
requireDeviceApproval: values.requireDeviceApproval,
|
||||
allowSsh: values.allowSsh
|
||||
};
|
||||
if (isPaidUser(tierMatrix.sshPam)) {
|
||||
if (isPaidUser(tierMatrix.advancedPrivateResources)) {
|
||||
payload.sshSudoMode = values.sshSudoMode;
|
||||
payload.sshCreateHomeDir = values.sshCreateHomeDir;
|
||||
payload.sshSudoCommands =
|
||||
@@ -69,10 +66,9 @@ export default function CreateRoleForm({
|
||||
}
|
||||
}
|
||||
const res = await api
|
||||
.put<AxiosResponse<CreateRoleResponse>>(
|
||||
`/org/${org?.org.orgId}/role`,
|
||||
payload
|
||||
)
|
||||
.put<
|
||||
AxiosResponse<CreateRoleResponse>
|
||||
>(`/org/${org?.org.orgId}/role`, payload)
|
||||
.catch((e) => {
|
||||
toast({
|
||||
variant: "destructive",
|
||||
|
||||
@@ -16,10 +16,7 @@ import { usePaidStatus } from "@app/hooks/usePaidStatus";
|
||||
import { toast } from "@app/hooks/useToast";
|
||||
import { createApiClient, formatAxiosError } from "@app/lib/api";
|
||||
import type { Role } from "@server/db";
|
||||
import type {
|
||||
UpdateRoleBody,
|
||||
UpdateRoleResponse
|
||||
} from "@server/routers/role";
|
||||
import type { UpdateRoleBody, UpdateRoleResponse } from "@server/routers/role";
|
||||
import { AxiosResponse } from "axios";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { useTransition } from "react";
|
||||
@@ -53,7 +50,7 @@ export default function EditRoleForm({
|
||||
payload.name = values.name;
|
||||
payload.description = values.description || undefined;
|
||||
}
|
||||
if (isPaidUser(tierMatrix.sshPam)) {
|
||||
if (isPaidUser(tierMatrix.advancedPrivateResources)) {
|
||||
payload.sshSudoMode = values.sshSudoMode;
|
||||
payload.sshCreateHomeDir = values.sshCreateHomeDir;
|
||||
payload.sshSudoCommands =
|
||||
@@ -72,10 +69,9 @@ export default function EditRoleForm({
|
||||
}
|
||||
}
|
||||
const res = await api
|
||||
.post<AxiosResponse<UpdateRoleResponse>>(
|
||||
`/role/${role.roleId}`,
|
||||
payload
|
||||
)
|
||||
.post<
|
||||
AxiosResponse<UpdateRoleResponse>
|
||||
>(`/role/${role.roleId}`, payload)
|
||||
.catch((e) => {
|
||||
toast({
|
||||
variant: "destructive",
|
||||
|
||||
@@ -224,8 +224,10 @@ export function PrivateResourceForm({
|
||||
const { env } = useEnvContext();
|
||||
const { isPaidUser } = usePaidStatus();
|
||||
const disableEnterpriseFeatures = env.flags.disableEnterpriseFeatures;
|
||||
const sshSectionDisabled = !isPaidUser(tierMatrix.sshPam);
|
||||
const httpSectionDisabled = !isPaidUser(tierMatrix.httpPrivateResources);
|
||||
const sshSectionDisabled = !isPaidUser(tierMatrix.advancedPrivateResources);
|
||||
const httpSectionDisabled = !isPaidUser(
|
||||
tierMatrix.advancedPrivateResources
|
||||
);
|
||||
|
||||
const nameRequiredKey =
|
||||
variant === "create"
|
||||
@@ -594,6 +596,7 @@ export function PrivateResourceForm({
|
||||
const httpConfigDomainId = form.watch("httpConfigDomainId");
|
||||
const httpConfigFullDomain = form.watch("httpConfigFullDomain");
|
||||
const isHttpMode = mode === "http";
|
||||
const isSshMode = mode === "ssh";
|
||||
const authDaemonMode = form.watch("authDaemonMode") ?? "site";
|
||||
const pamMode = form.watch("pamMode") ?? "passthrough";
|
||||
const isNative = sshServerMode === "native";
|
||||
@@ -739,8 +742,17 @@ export function PrivateResourceForm({
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
onSubmitDisabledChange?.(isHttpMode && httpSectionDisabled);
|
||||
}, [isHttpMode, httpSectionDisabled, onSubmitDisabledChange]);
|
||||
onSubmitDisabledChange?.(
|
||||
(isHttpMode && httpSectionDisabled) ||
|
||||
(isSshMode && sshSectionDisabled)
|
||||
);
|
||||
}, [
|
||||
isHttpMode,
|
||||
httpSectionDisabled,
|
||||
isSshMode,
|
||||
sshSectionDisabled,
|
||||
onSubmitDisabledChange
|
||||
]);
|
||||
|
||||
return (
|
||||
<Form {...form}>
|
||||
@@ -1129,8 +1141,10 @@ export function PrivateResourceForm({
|
||||
""
|
||||
}
|
||||
disabled={
|
||||
isHttpMode &&
|
||||
httpSectionDisabled
|
||||
(isHttpMode &&
|
||||
httpSectionDisabled) ||
|
||||
(isSshMode &&
|
||||
sshSectionDisabled)
|
||||
}
|
||||
onChange={(e) =>
|
||||
field.onChange(
|
||||
@@ -1169,6 +1183,10 @@ export function PrivateResourceForm({
|
||||
field.value ??
|
||||
""
|
||||
}
|
||||
disabled={
|
||||
isSshMode &&
|
||||
sshSectionDisabled
|
||||
}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
@@ -1202,7 +1220,10 @@ export function PrivateResourceForm({
|
||||
""
|
||||
}
|
||||
disabled={
|
||||
httpSectionDisabled
|
||||
(isHttpMode &&
|
||||
httpSectionDisabled) ||
|
||||
(isSshMode &&
|
||||
sshSectionDisabled)
|
||||
}
|
||||
onChange={(e) => {
|
||||
const raw =
|
||||
@@ -1237,9 +1258,9 @@ export function PrivateResourceForm({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{isHttpMode && (
|
||||
{(isHttpMode || isSshMode) && (
|
||||
<PaidFeaturesAlert
|
||||
tiers={tierMatrix.httpPrivateResources}
|
||||
tiers={tierMatrix.advancedPrivateResources}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -1773,7 +1794,9 @@ export function PrivateResourceForm({
|
||||
{/* SSH Access tab (ssh mode only) */}
|
||||
{!disableEnterpriseFeatures && mode === "ssh" && (
|
||||
<div className="space-y-4 mt-4 p-1">
|
||||
<PaidFeaturesAlert tiers={tierMatrix.sshPam} />
|
||||
<PaidFeaturesAlert
|
||||
tiers={tierMatrix.advancedPrivateResources}
|
||||
/>
|
||||
|
||||
{/* Mode */}
|
||||
<div className="space-y-3">
|
||||
|
||||
@@ -164,7 +164,7 @@ export function RoleForm({
|
||||
}
|
||||
}, [variant, role, form]);
|
||||
|
||||
const sshDisabled = !isPaidUser(tierMatrix.sshPam);
|
||||
const sshDisabled = !isPaidUser(tierMatrix.advancedPrivateResources);
|
||||
const sshSudoMode = form.watch("sshSudoMode");
|
||||
const isAdminRole = variant === "edit" && role?.isAdmin === true;
|
||||
|
||||
@@ -319,7 +319,9 @@ export function RoleForm({
|
||||
{/* SSH tab - hidden when enterprise features are disabled */}
|
||||
{!env.flags.disableEnterpriseFeatures && (
|
||||
<div className="space-y-4 mt-4">
|
||||
<PaidFeaturesAlert tiers={tierMatrix.sshPam} />
|
||||
<PaidFeaturesAlert
|
||||
tiers={tierMatrix.advancedPrivateResources}
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="allowSsh"
|
||||
|
||||
Reference in New Issue
Block a user