mirror of
https://github.com/fosrl/pangolin.git
synced 2026-07-21 13:06:59 +02:00
Properly hide things with disable enterprise flag
This commit is contained in:
@@ -43,6 +43,7 @@ import { usePaidStatus } from "@app/hooks/usePaidStatus";
|
|||||||
import { tierMatrix, TierFeature } from "@server/lib/billing/tierMatrix";
|
import { tierMatrix, TierFeature } from "@server/lib/billing/tierMatrix";
|
||||||
import { PaidFeaturesAlert } from "@app/components/PaidFeaturesAlert";
|
import { PaidFeaturesAlert } from "@app/components/PaidFeaturesAlert";
|
||||||
import { ExternalLink } from "lucide-react";
|
import { ExternalLink } from "lucide-react";
|
||||||
|
import { env } from "process";
|
||||||
|
|
||||||
// Schema for general organization settings
|
// Schema for general organization settings
|
||||||
const GeneralFormSchema = z.object({
|
const GeneralFormSchema = z.object({
|
||||||
@@ -165,6 +166,7 @@ function DeleteForm({ org }: SectionFormProps) {
|
|||||||
|
|
||||||
function GeneralSectionForm({ org }: SectionFormProps) {
|
function GeneralSectionForm({ org }: SectionFormProps) {
|
||||||
const { updateOrg } = useOrgContext();
|
const { updateOrg } = useOrgContext();
|
||||||
|
const { env } = useEnvContext();
|
||||||
const form = useForm({
|
const form = useForm({
|
||||||
resolver: zodResolver(
|
resolver: zodResolver(
|
||||||
GeneralFormSchema.pick({
|
GeneralFormSchema.pick({
|
||||||
@@ -265,36 +267,42 @@ function GeneralSectionForm({ org }: SectionFormProps) {
|
|||||||
<PaidFeaturesAlert
|
<PaidFeaturesAlert
|
||||||
tiers={tierMatrix.newtAutoUpdate}
|
tiers={tierMatrix.newtAutoUpdate}
|
||||||
/>
|
/>
|
||||||
<FormField
|
{!env.flags.disableEnterpriseFeatures && (
|
||||||
control={form.control}
|
<FormField
|
||||||
name="settingsEnableGlobalNewtAutoUpdate"
|
control={form.control}
|
||||||
render={({ field }) => (
|
name="settingsEnableGlobalNewtAutoUpdate"
|
||||||
<FormItem>
|
render={({ field }) => (
|
||||||
<FormControl>
|
<FormItem>
|
||||||
<SwitchInput
|
<FormControl>
|
||||||
id="settings-enable-global-newt-auto-update"
|
<SwitchInput
|
||||||
label={t("newtAutoUpdate")}
|
id="settings-enable-global-newt-auto-update"
|
||||||
checked={field.value}
|
label={t("newtAutoUpdate")}
|
||||||
onCheckedChange={field.onChange}
|
checked={field.value}
|
||||||
disabled={!hasAutoUpdateFeature}
|
onCheckedChange={
|
||||||
/>
|
field.onChange
|
||||||
</FormControl>
|
}
|
||||||
<FormDescription>
|
disabled={
|
||||||
{t("newtAutoUpdateDescription")}{" "}
|
!hasAutoUpdateFeature
|
||||||
<a
|
}
|
||||||
href="https://docs.pangolin.net/manage/sites/auto-update"
|
/>
|
||||||
target="_blank"
|
</FormControl>
|
||||||
rel="noopener noreferrer"
|
<FormDescription>
|
||||||
className="text-primary hover:underline inline-flex items-center gap-1"
|
{t("newtAutoUpdateDescription")}{" "}
|
||||||
>
|
<a
|
||||||
{t("learnMore")}
|
href="https://docs.pangolin.net/manage/sites/auto-update"
|
||||||
<ExternalLink className="size-3.5 shrink-0" />
|
target="_blank"
|
||||||
</a>
|
rel="noopener noreferrer"
|
||||||
</FormDescription>
|
className="text-primary hover:underline inline-flex items-center gap-1"
|
||||||
<FormMessage />
|
>
|
||||||
</FormItem>
|
{t("learnMore")}
|
||||||
)}
|
<ExternalLink className="size-3.5 shrink-0" />
|
||||||
/>
|
</a>
|
||||||
|
</FormDescription>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
</SettingsSectionForm>
|
</SettingsSectionForm>
|
||||||
|
|||||||
@@ -253,85 +253,87 @@ export default function GeneralPage() {
|
|||||||
<PaidFeaturesAlert
|
<PaidFeaturesAlert
|
||||||
tiers={tierMatrix.newtAutoUpdate}
|
tiers={tierMatrix.newtAutoUpdate}
|
||||||
/>
|
/>
|
||||||
{site && site.type === "newt" && (
|
{site &&
|
||||||
<FormField
|
site.type === "newt" &&
|
||||||
control={form.control}
|
!env.flags.disableEnterpriseFeatures && (
|
||||||
name="autoUpdateEnabled"
|
<FormField
|
||||||
render={({ field }) => {
|
control={form.control}
|
||||||
const isOverriding = form.watch(
|
name="autoUpdateEnabled"
|
||||||
"autoUpdateOverrideOrg"
|
render={({ field }) => {
|
||||||
);
|
const isOverriding = form.watch(
|
||||||
return (
|
"autoUpdateOverrideOrg"
|
||||||
<FormItem>
|
);
|
||||||
<FormControl>
|
return (
|
||||||
<div className="">
|
<FormItem>
|
||||||
<SwitchInput
|
<FormControl>
|
||||||
id="auto-update-enabled"
|
<div className="">
|
||||||
label={t(
|
<SwitchInput
|
||||||
"siteAutoUpdateLabel"
|
id="auto-update-enabled"
|
||||||
)}
|
label={t(
|
||||||
checked={
|
"siteAutoUpdateLabel"
|
||||||
field.value
|
)}
|
||||||
}
|
checked={
|
||||||
onCheckedChange={(
|
field.value
|
||||||
checked
|
}
|
||||||
) => {
|
onCheckedChange={(
|
||||||
field.onChange(
|
|
||||||
checked
|
checked
|
||||||
);
|
) => {
|
||||||
form.setValue(
|
field.onChange(
|
||||||
"autoUpdateOverrideOrg",
|
checked
|
||||||
true
|
);
|
||||||
);
|
|
||||||
}}
|
|
||||||
disabled={
|
|
||||||
!hasAutoUpdateFeature
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
{isOverriding && (
|
|
||||||
<ButtonUI
|
|
||||||
type="button"
|
|
||||||
variant="link"
|
|
||||||
size="sm"
|
|
||||||
className="text-sm text-muted-foreground px-0"
|
|
||||||
onClick={() => {
|
|
||||||
form.setValue(
|
form.setValue(
|
||||||
"autoUpdateOverrideOrg",
|
"autoUpdateOverrideOrg",
|
||||||
false
|
true
|
||||||
);
|
|
||||||
form.setValue(
|
|
||||||
"autoUpdateEnabled",
|
|
||||||
orgAutoUpdate
|
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
>
|
disabled={
|
||||||
{t(
|
!hasAutoUpdateFeature
|
||||||
"siteAutoUpdateResetToOrg"
|
}
|
||||||
)}
|
/>
|
||||||
</ButtonUI>
|
{isOverriding && (
|
||||||
)}
|
<ButtonUI
|
||||||
</div>
|
type="button"
|
||||||
</FormControl>
|
variant="link"
|
||||||
<FormDescription>
|
size="sm"
|
||||||
{t(
|
className="text-sm text-muted-foreground px-0"
|
||||||
"siteAutoUpdateDescription"
|
onClick={() => {
|
||||||
)}{" "}
|
form.setValue(
|
||||||
<a
|
"autoUpdateOverrideOrg",
|
||||||
href="https://docs.pangolin.net/manage/sites/auto-update"
|
false
|
||||||
target="_blank"
|
);
|
||||||
rel="noopener noreferrer"
|
form.setValue(
|
||||||
className="text-primary hover:underline inline-flex items-center gap-1"
|
"autoUpdateEnabled",
|
||||||
>
|
orgAutoUpdate
|
||||||
{t("learnMore")}
|
);
|
||||||
<ExternalLink className="size-3.5 shrink-0" />
|
}}
|
||||||
</a>
|
>
|
||||||
</FormDescription>
|
{t(
|
||||||
<FormMessage />
|
"siteAutoUpdateResetToOrg"
|
||||||
</FormItem>
|
)}
|
||||||
);
|
</ButtonUI>
|
||||||
}}
|
)}
|
||||||
/>
|
</div>
|
||||||
)}
|
</FormControl>
|
||||||
|
<FormDescription>
|
||||||
|
{t(
|
||||||
|
"siteAutoUpdateDescription"
|
||||||
|
)}{" "}
|
||||||
|
<a
|
||||||
|
href="https://docs.pangolin.net/manage/sites/auto-update"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
className="text-primary hover:underline inline-flex items-center gap-1"
|
||||||
|
>
|
||||||
|
{t("learnMore")}
|
||||||
|
<ExternalLink className="size-3.5 shrink-0" />
|
||||||
|
</a>
|
||||||
|
</FormDescription>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
</SettingsSectionForm>
|
</SettingsSectionForm>
|
||||||
|
|||||||
@@ -75,7 +75,11 @@ export function NewtSiteInstallCommands({
|
|||||||
: "";
|
: "";
|
||||||
|
|
||||||
const disableSshFlag =
|
const disableSshFlag =
|
||||||
supportsSshOption && !allowPangolinSsh ? " --disable-ssh" : "";
|
supportsSshOption &&
|
||||||
|
!allowPangolinSsh &&
|
||||||
|
!env.flags.disableEnterpriseFeatures
|
||||||
|
? " --disable-ssh"
|
||||||
|
: "";
|
||||||
const runAsRootPrefix =
|
const runAsRootPrefix =
|
||||||
supportsSshOption && allowPangolinSsh ? "sudo " : "";
|
supportsSshOption && allowPangolinSsh ? "sudo " : "";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user