mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-29 14:18:26 +02:00
fix hide raw resource option
This commit is contained in:
parent
7fd1fb89f1
commit
8199202dc3
1 changed files with 102 additions and 60 deletions
|
@ -119,15 +119,18 @@ export default function Page() {
|
||||||
const resourceTypes: ReadonlyArray<ResourceTypeOption> = [
|
const resourceTypes: ReadonlyArray<ResourceTypeOption> = [
|
||||||
{
|
{
|
||||||
id: "http",
|
id: "http",
|
||||||
title: t('resourceHTTP'),
|
title: t("resourceHTTP"),
|
||||||
description: t('resourceHTTPDescription')
|
description: t("resourceHTTPDescription")
|
||||||
},
|
},
|
||||||
{
|
...(env.flags.allowRawResources
|
||||||
id: "raw",
|
? []
|
||||||
title: t('resourceRaw'),
|
: [
|
||||||
description: t('resourceRawDescription'),
|
{
|
||||||
disabled: !env.flags.allowRawResources
|
id: "raw" as ResourceType,
|
||||||
}
|
title: t("resourceRaw"),
|
||||||
|
description: t("resourceRawDescription")
|
||||||
|
}
|
||||||
|
])
|
||||||
];
|
];
|
||||||
|
|
||||||
const baseForm = useForm<BaseResourceFormValues>({
|
const baseForm = useForm<BaseResourceFormValues>({
|
||||||
|
@ -199,10 +202,10 @@ export default function Page() {
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
toast({
|
toast({
|
||||||
variant: "destructive",
|
variant: "destructive",
|
||||||
title: t('resourceErrorCreate'),
|
title: t("resourceErrorCreate"),
|
||||||
description: formatAxiosError(
|
description: formatAxiosError(
|
||||||
e,
|
e,
|
||||||
t('resourceErrorCreateDescription')
|
t("resourceErrorCreateDescription")
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -219,11 +222,11 @@ export default function Page() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(t('resourceErrorCreateMessage'), e);
|
console.error(t("resourceErrorCreateMessage"), e);
|
||||||
toast({
|
toast({
|
||||||
variant: "destructive",
|
variant: "destructive",
|
||||||
title: t('resourceErrorCreate'),
|
title: t("resourceErrorCreate"),
|
||||||
description:t('resourceErrorCreateMessageDescription')
|
description: t("resourceErrorCreateMessageDescription")
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,10 +245,10 @@ export default function Page() {
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
toast({
|
toast({
|
||||||
variant: "destructive",
|
variant: "destructive",
|
||||||
title: t('sitesErrorFetch'),
|
title: t("sitesErrorFetch"),
|
||||||
description: formatAxiosError(
|
description: formatAxiosError(
|
||||||
e,
|
e,
|
||||||
t('sitesErrorFetchDescription')
|
t("sitesErrorFetchDescription")
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -270,10 +273,10 @@ export default function Page() {
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
toast({
|
toast({
|
||||||
variant: "destructive",
|
variant: "destructive",
|
||||||
title: t('domainsErrorFetch'),
|
title: t("domainsErrorFetch"),
|
||||||
description: formatAxiosError(
|
description: formatAxiosError(
|
||||||
e,
|
e,
|
||||||
t('domainsErrorFetchDescription')
|
t("domainsErrorFetchDescription")
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -300,8 +303,8 @@ export default function Page() {
|
||||||
<>
|
<>
|
||||||
<div className="flex justify-between">
|
<div className="flex justify-between">
|
||||||
<HeaderTitle
|
<HeaderTitle
|
||||||
title={t('resourceCreate')}
|
title={t("resourceCreate")}
|
||||||
description={t('resourceCreateDescription')}
|
description={t("resourceCreateDescription")}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
|
@ -309,7 +312,7 @@ export default function Page() {
|
||||||
router.push(`/${orgId}/settings/resources`);
|
router.push(`/${orgId}/settings/resources`);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{t('resourceSeeAll')}
|
{t("resourceSeeAll")}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -320,7 +323,7 @@ export default function Page() {
|
||||||
<SettingsSection>
|
<SettingsSection>
|
||||||
<SettingsSectionHeader>
|
<SettingsSectionHeader>
|
||||||
<SettingsSectionTitle>
|
<SettingsSectionTitle>
|
||||||
{t('resourceInfo')}
|
{t("resourceInfo")}
|
||||||
</SettingsSectionTitle>
|
</SettingsSectionTitle>
|
||||||
</SettingsSectionHeader>
|
</SettingsSectionHeader>
|
||||||
<SettingsSectionBody>
|
<SettingsSectionBody>
|
||||||
|
@ -336,7 +339,7 @@ export default function Page() {
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>
|
<FormLabel>
|
||||||
{t('name')}
|
{t("name")}
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input
|
||||||
|
@ -345,7 +348,9 @@ export default function Page() {
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
<FormDescription>
|
<FormDescription>
|
||||||
{t('resourceNameDescription')}
|
{t(
|
||||||
|
"resourceNameDescription"
|
||||||
|
)}
|
||||||
</FormDescription>
|
</FormDescription>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
|
@ -357,7 +362,7 @@ export default function Page() {
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem className="flex flex-col">
|
<FormItem className="flex flex-col">
|
||||||
<FormLabel>
|
<FormLabel>
|
||||||
{t('site')}
|
{t("site")}
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
<Popover>
|
<Popover>
|
||||||
<PopoverTrigger
|
<PopoverTrigger
|
||||||
|
@ -382,17 +387,25 @@ export default function Page() {
|
||||||
field.value
|
field.value
|
||||||
)
|
)
|
||||||
?.name
|
?.name
|
||||||
: t('siteSelect')}
|
: t(
|
||||||
|
"siteSelect"
|
||||||
|
)}
|
||||||
<CaretSortIcon className="ml-2 h-4 w-4 shrink-0 opacity-50" />
|
<CaretSortIcon className="ml-2 h-4 w-4 shrink-0 opacity-50" />
|
||||||
</Button>
|
</Button>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</PopoverTrigger>
|
</PopoverTrigger>
|
||||||
<PopoverContent className="p-0">
|
<PopoverContent className="p-0">
|
||||||
<Command>
|
<Command>
|
||||||
<CommandInput placeholder={t('siteSearch')} />
|
<CommandInput
|
||||||
|
placeholder={t(
|
||||||
|
"siteSearch"
|
||||||
|
)}
|
||||||
|
/>
|
||||||
<CommandList>
|
<CommandList>
|
||||||
<CommandEmpty>
|
<CommandEmpty>
|
||||||
{t('siteNotFound')}
|
{t(
|
||||||
|
"siteNotFound"
|
||||||
|
)}
|
||||||
</CommandEmpty>
|
</CommandEmpty>
|
||||||
<CommandGroup>
|
<CommandGroup>
|
||||||
{sites.map(
|
{sites.map(
|
||||||
|
@ -433,7 +446,9 @@ export default function Page() {
|
||||||
</Popover>
|
</Popover>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
<FormDescription>
|
<FormDescription>
|
||||||
{t('siteSelectionDescription')}
|
{t(
|
||||||
|
"siteSelectionDescription"
|
||||||
|
)}
|
||||||
</FormDescription>
|
</FormDescription>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
|
@ -447,10 +462,10 @@ export default function Page() {
|
||||||
<SettingsSection>
|
<SettingsSection>
|
||||||
<SettingsSectionHeader>
|
<SettingsSectionHeader>
|
||||||
<SettingsSectionTitle>
|
<SettingsSectionTitle>
|
||||||
{t('resourceType')}
|
{t("resourceType")}
|
||||||
</SettingsSectionTitle>
|
</SettingsSectionTitle>
|
||||||
<SettingsSectionDescription>
|
<SettingsSectionDescription>
|
||||||
{t('resourceTypeDescription')}
|
{t("resourceTypeDescription")}
|
||||||
</SettingsSectionDescription>
|
</SettingsSectionDescription>
|
||||||
</SettingsSectionHeader>
|
</SettingsSectionHeader>
|
||||||
<SettingsSectionBody>
|
<SettingsSectionBody>
|
||||||
|
@ -472,10 +487,12 @@ export default function Page() {
|
||||||
<SettingsSection>
|
<SettingsSection>
|
||||||
<SettingsSectionHeader>
|
<SettingsSectionHeader>
|
||||||
<SettingsSectionTitle>
|
<SettingsSectionTitle>
|
||||||
{t('resourceHTTPSSettings')}
|
{t("resourceHTTPSSettings")}
|
||||||
</SettingsSectionTitle>
|
</SettingsSectionTitle>
|
||||||
<SettingsSectionDescription>
|
<SettingsSectionDescription>
|
||||||
{t('resourceHTTPSSettingsDescription')}
|
{t(
|
||||||
|
"resourceHTTPSSettingsDescription"
|
||||||
|
)}
|
||||||
</SettingsSectionDescription>
|
</SettingsSectionDescription>
|
||||||
</SettingsSectionHeader>
|
</SettingsSectionHeader>
|
||||||
<SettingsSectionBody>
|
<SettingsSectionBody>
|
||||||
|
@ -497,7 +514,9 @@ export default function Page() {
|
||||||
}) => (
|
}) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>
|
<FormLabel>
|
||||||
{t('domainType')}
|
{t(
|
||||||
|
"domainType"
|
||||||
|
)}
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
<Select
|
<Select
|
||||||
value={
|
value={
|
||||||
|
@ -521,10 +540,14 @@ export default function Page() {
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectItem value="subdomain">
|
<SelectItem value="subdomain">
|
||||||
{t('subdomain')}
|
{t(
|
||||||
|
"subdomain"
|
||||||
|
)}
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
<SelectItem value="basedomain">
|
<SelectItem value="basedomain">
|
||||||
{t('baseDomain')}
|
{t(
|
||||||
|
"baseDomain"
|
||||||
|
)}
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
|
@ -539,7 +562,7 @@ export default function Page() {
|
||||||
) && (
|
) && (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>
|
<FormLabel>
|
||||||
{t('subdomain')}
|
{t("subdomain")}
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
<div className="flex space-x-0">
|
<div className="flex space-x-0">
|
||||||
<div className="w-1/2">
|
<div className="w-1/2">
|
||||||
|
@ -618,7 +641,9 @@ export default function Page() {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<FormDescription>
|
<FormDescription>
|
||||||
{t('subdomnainDescription')}
|
{t(
|
||||||
|
"subdomnainDescription"
|
||||||
|
)}
|
||||||
</FormDescription>
|
</FormDescription>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
|
@ -636,7 +661,9 @@ export default function Page() {
|
||||||
}) => (
|
}) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>
|
<FormLabel>
|
||||||
{t('baseDomain')}
|
{t(
|
||||||
|
"baseDomain"
|
||||||
|
)}
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
<Select
|
<Select
|
||||||
onValueChange={
|
onValueChange={
|
||||||
|
@ -683,14 +710,16 @@ export default function Page() {
|
||||||
</SettingsSectionForm>
|
</SettingsSectionForm>
|
||||||
</SettingsSectionBody>
|
</SettingsSectionBody>
|
||||||
</SettingsSection>
|
</SettingsSection>
|
||||||
) : env.flags.allowRawResources ? (
|
) : (
|
||||||
<SettingsSection>
|
<SettingsSection>
|
||||||
<SettingsSectionHeader>
|
<SettingsSectionHeader>
|
||||||
<SettingsSectionTitle>
|
<SettingsSectionTitle>
|
||||||
{t('resourceRawSettings')}
|
{t("resourceRawSettings")}
|
||||||
</SettingsSectionTitle>
|
</SettingsSectionTitle>
|
||||||
<SettingsSectionDescription>
|
<SettingsSectionDescription>
|
||||||
{t('resourceRawSettingsDescription')}
|
{t(
|
||||||
|
"resourceRawSettingsDescription"
|
||||||
|
)}
|
||||||
</SettingsSectionDescription>
|
</SettingsSectionDescription>
|
||||||
</SettingsSectionHeader>
|
</SettingsSectionHeader>
|
||||||
<SettingsSectionBody>
|
<SettingsSectionBody>
|
||||||
|
@ -708,7 +737,9 @@ export default function Page() {
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>
|
<FormLabel>
|
||||||
{t('protocol')}
|
{t(
|
||||||
|
"protocol"
|
||||||
|
)}
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
<Select
|
<Select
|
||||||
onValueChange={
|
onValueChange={
|
||||||
|
@ -718,7 +749,11 @@ export default function Page() {
|
||||||
>
|
>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<SelectTrigger>
|
<SelectTrigger>
|
||||||
<SelectValue placeholder={t('protocolSelect')} />
|
<SelectValue
|
||||||
|
placeholder={t(
|
||||||
|
"protocolSelect"
|
||||||
|
)}
|
||||||
|
/>
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
|
@ -743,7 +778,9 @@ export default function Page() {
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>
|
<FormLabel>
|
||||||
{t('resourcePortNumber')}
|
{t(
|
||||||
|
"resourcePortNumber"
|
||||||
|
)}
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input
|
||||||
|
@ -771,7 +808,9 @@ export default function Page() {
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
<FormDescription>
|
<FormDescription>
|
||||||
{t('resourcePortNumberDescription')}
|
{t(
|
||||||
|
"resourcePortNumberDescription"
|
||||||
|
)}
|
||||||
</FormDescription>
|
</FormDescription>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
|
@ -781,23 +820,26 @@ export default function Page() {
|
||||||
</SettingsSectionForm>
|
</SettingsSectionForm>
|
||||||
</SettingsSectionBody>
|
</SettingsSectionBody>
|
||||||
</SettingsSection>
|
</SettingsSection>
|
||||||
) : null}
|
)}
|
||||||
|
|
||||||
<div className="flex justify-end space-x-2 mt-8">
|
<div className="flex justify-end space-x-2 mt-8">
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
router.push(`/${orgId}/settings/resources`)
|
router.push(
|
||||||
|
`/${orgId}/settings/resources`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{t('cancel')}
|
{t("cancel")}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
const isHttp = baseForm.watch("http");
|
const isHttp = baseForm.watch("http");
|
||||||
const baseValid = await baseForm.trigger();
|
const baseValid =
|
||||||
|
await baseForm.trigger();
|
||||||
const settingsValid = isHttp
|
const settingsValid = isHttp
|
||||||
? await httpForm.trigger()
|
? await httpForm.trigger()
|
||||||
: await tcpUdpForm.trigger();
|
: await tcpUdpForm.trigger();
|
||||||
|
@ -808,7 +850,7 @@ export default function Page() {
|
||||||
}}
|
}}
|
||||||
loading={createLoading}
|
loading={createLoading}
|
||||||
>
|
>
|
||||||
{t('resourceCreate')}
|
{t("resourceCreate")}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</SettingsContainer>
|
</SettingsContainer>
|
||||||
|
@ -817,17 +859,17 @@ export default function Page() {
|
||||||
<SettingsSection>
|
<SettingsSection>
|
||||||
<SettingsSectionHeader>
|
<SettingsSectionHeader>
|
||||||
<SettingsSectionTitle>
|
<SettingsSectionTitle>
|
||||||
{t('resourceConfig')}
|
{t("resourceConfig")}
|
||||||
</SettingsSectionTitle>
|
</SettingsSectionTitle>
|
||||||
<SettingsSectionDescription>
|
<SettingsSectionDescription>
|
||||||
{t('resourceConfigDescription')}
|
{t("resourceConfigDescription")}
|
||||||
</SettingsSectionDescription>
|
</SettingsSectionDescription>
|
||||||
</SettingsSectionHeader>
|
</SettingsSectionHeader>
|
||||||
<SettingsSectionBody>
|
<SettingsSectionBody>
|
||||||
<div className="space-y-6">
|
<div className="space-y-6">
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<h3 className="text-lg font-semibold">
|
<h3 className="text-lg font-semibold">
|
||||||
{t('resourceAddEntrypoints')}
|
{t("resourceAddEntrypoints")}
|
||||||
</h3>
|
</h3>
|
||||||
<CopyTextBox
|
<CopyTextBox
|
||||||
text={`entryPoints:
|
text={`entryPoints:
|
||||||
|
@ -839,7 +881,7 @@ export default function Page() {
|
||||||
|
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<h3 className="text-lg font-semibold">
|
<h3 className="text-lg font-semibold">
|
||||||
{t('resourceExposePorts')}
|
{t("resourceExposePorts")}
|
||||||
</h3>
|
</h3>
|
||||||
<CopyTextBox
|
<CopyTextBox
|
||||||
text={`ports:
|
text={`ports:
|
||||||
|
@ -854,9 +896,7 @@ export default function Page() {
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
>
|
>
|
||||||
<span>
|
<span>{t("resourceLearnRaw")}</span>
|
||||||
{t('resourceLearnRaw')}
|
|
||||||
</span>
|
|
||||||
<SquareArrowOutUpRight size={14} />
|
<SquareArrowOutUpRight size={14} />
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
|
@ -868,10 +908,12 @@ export default function Page() {
|
||||||
type="button"
|
type="button"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
router.push(`/${orgId}/settings/resources`)
|
router.push(
|
||||||
|
`/${orgId}/settings/resources`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{t('resourceBack')}
|
{t("resourceBack")}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
|
@ -881,7 +923,7 @@ export default function Page() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{t('resourceGoTo')}
|
{t("resourceGoTo")}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</SettingsContainer>
|
</SettingsContainer>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue