update all

This commit is contained in:
Lokowitz
2025-05-25 19:01:20 +00:00
parent ea24759bb3
commit f07e8d08c3
63 changed files with 380 additions and 381 deletions

View File

@@ -13,7 +13,7 @@ import {
} from "@app/components/InfoSection";
import Link from "next/link";
import { Switch } from "@app/components/ui/switch";
import { useTranslations } from 'next-intl';
import { useTranslations } from "next-intl";
type ResourceInfoBoxType = {};

View File

@@ -162,10 +162,9 @@ export default function ResourceAuthenticationPage() {
rolesResponse.data.data.roles
.map((role) => ({
id: role.roleId.toString(),
text: role.name,
isAdmin: role.isAdmin
text: role.name
}))
.filter((role) => !role.isAdmin)
.filter((role) => role.text !== "Admin")
);
usersRolesForm.setValue(
@@ -173,10 +172,9 @@ export default function ResourceAuthenticationPage() {
resourceRolesResponse.data.data.roles
.map((i) => ({
id: i.roleId.toString(),
text: i.name,
isAdmin: i.isAdmin
text: i.name
}))
.filter((role) => !role.isAdmin)
.filter((role) => role.text !== "Admin")
);
setAllUsers(

View File

@@ -67,45 +67,6 @@ import {
import { SwitchInput } from "@app/components/SwitchInput";
import { useTranslations } from "next-intl";
const GeneralFormSchema = z
.object({
subdomain: z.string().optional(),
name: z.string().min(1).max(255),
proxyPort: z.number().optional(),
http: z.boolean(),
isBaseDomain: z.boolean().optional(),
domainId: z.string().optional()
})
.refine(
(data) => {
if (!data.http) {
return z
.number()
.int()
.min(1)
.max(65535)
.safeParse(data.proxyPort).success;
}
return true;
},
{
message: "Invalid port number",
path: ["proxyPort"]
}
)
.refine(
(data) => {
if (data.http && !data.isBaseDomain) {
return subdomainSchema.safeParse(data.subdomain).success;
}
return true;
},
{
message: "Invalid subdomain",
path: ["subdomain"]
}
);
const TransferFormSchema = z.object({
siteId: z.number()
});
@@ -140,6 +101,45 @@ export default function GeneralForm() {
resource.isBaseDomain ? "basedomain" : "subdomain"
);
const GeneralFormSchema = z
.object({
subdomain: z.string().optional(),
name: z.string().min(1).max(255),
proxyPort: z.number().optional(),
http: z.boolean(),
isBaseDomain: z.boolean().optional(),
domainId: z.string().optional()
})
.refine(
(data) => {
if (!data.http) {
return z
.number()
.int()
.min(1)
.max(65535)
.safeParse(data.proxyPort).success;
}
return true;
},
{
message: t('proxyErrorInvalidPort'),
path: ["proxyPort"]
}
)
.refine(
(data) => {
if (data.http && !data.isBaseDomain) {
return subdomainSchema.safeParse(data.subdomain).success;
}
return true;
},
{
message: t('subdomainErrorInvalid'),
path: ["subdomain"]
}
);
const form = useForm<GeneralFormValues>({
resolver: zodResolver(GeneralFormSchema),
defaultValues: {

View File

@@ -93,45 +93,6 @@ type LocalTarget = Omit<
"protocol"
>;
const proxySettingsSchema = z.object({
setHostHeader: z
.string()
.optional()
.refine(
(data) => {
if (data) {
return tlsNameSchema.safeParse(data).success;
}
return true;
},
{
message: "Invalid custom Host Header value. Use domain name format, or save empty to unset custom Host Header."
}
)
});
const tlsSettingsSchema = z.object({
ssl: z.boolean(),
tlsServerName: z
.string()
.optional()
.refine(
(data) => {
if (data) {
return tlsNameSchema.safeParse(data).success;
}
return true;
},
{
message: "Invalid TLS Server Name. Use domain name format, or save empty to remove the TLS Server Name."
}
)
});
type ProxySettingsValues = z.infer<typeof proxySettingsSchema>;
type TlsSettingsValues = z.infer<typeof tlsSettingsSchema>;
type TargetsSettingsValues = z.infer<typeof targetsSettingsSchema>;
export default function ReverseProxyTargets(props: {
params: Promise<{ resourceId: number }>;
}) {
@@ -154,6 +115,45 @@ export default function ReverseProxyTargets(props: {
const [isAdvancedOpen, setIsAdvancedOpen] = useState(false);
const router = useRouter();
const proxySettingsSchema = z.object({
setHostHeader: z
.string()
.optional()
.refine(
(data) => {
if (data) {
return tlsNameSchema.safeParse(data).success;
}
return true;
},
{
message: t('proxyErrorInvalidHeader')
}
)
});
const tlsSettingsSchema = z.object({
ssl: z.boolean(),
tlsServerName: z
.string()
.optional()
.refine(
(data) => {
if (data) {
return tlsNameSchema.safeParse(data).success;
}
return true;
},
{
message: t('proxyErrorTls')
}
)
});
type ProxySettingsValues = z.infer<typeof proxySettingsSchema>;
type TlsSettingsValues = z.infer<typeof tlsSettingsSchema>;
type TargetsSettingsValues = z.infer<typeof targetsSettingsSchema>;
const addTargetForm = useForm({
resolver: zodResolver(addTargetSchema),
defaultValues: {
@@ -583,7 +583,7 @@ export default function ReverseProxyTargets(props: {
<FormControl>
<SwitchInput
id="ssl-toggle"
label="Enable SSL (https)"
label={t('proxyEnableSSL')}
defaultChecked={
field.value
}
@@ -927,7 +927,6 @@ function isIPInSubnet(subnet: string, ip: string): boolean {
// Split subnet into IP and mask parts
const [subnetIP, maskBits] = subnet.split("/");
const mask = parseInt(maskBits);
const t = useTranslations();
if (mask < 0 || mask > 32) {
throw new Error(t('subnetMaskErrorInvalid'));

View File

@@ -102,7 +102,8 @@ export default function ResourceRules(props: {
const router = useRouter();
const t = useTranslations();
const RuleAction = {
RuleAction = {
ACCEPT: t('alwaysAllow'),
DROP: t('alwaysDeny')
} as const;

View File

@@ -62,7 +62,7 @@ import { cn } from "@app/lib/cn";
import { SquareArrowOutUpRight } from "lucide-react";
import CopyTextBox from "@app/components/CopyTextBox";
import Link from "next/link";
import { useTranslations } from 'next-intl';
import { useTranslations } from "next-intl";
const baseResourceFormSchema = z.object({
name: z.string().min(1).max(255),

View File

@@ -9,7 +9,7 @@ import { cache } from "react";
import { GetOrgResponse } from "@server/routers/org";
import OrgProvider from "@app/providers/OrgProvider";
import ResourcesSplashCard from "./ResourcesSplashCard";
import { getTranslations } from 'next-intl/server';
import { getTranslations } from "next-intl/server";
type ResourcesPageProps = {
params: Promise<{ orgId: string }>;