mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-13 00:16:39 +00:00
Resource identified with niceId now
This commit is contained in:
@@ -18,7 +18,7 @@ import { getTranslations } from 'next-intl/server';
|
||||
|
||||
interface ResourceLayoutProps {
|
||||
children: React.ReactNode;
|
||||
params: Promise<{ resourceId: number | string; orgId: string }>;
|
||||
params: Promise<{ niceId: string; orgId: string }>;
|
||||
}
|
||||
|
||||
export default async function ResourceLayout(props: ResourceLayoutProps) {
|
||||
@@ -31,7 +31,7 @@ export default async function ResourceLayout(props: ResourceLayoutProps) {
|
||||
let resource = null;
|
||||
try {
|
||||
const res = await internal.get<AxiosResponse<GetResourceResponse>>(
|
||||
`/resource/${params.resourceId}`,
|
||||
`/org/${params.orgId}/resource/${params.niceId}`,
|
||||
await authCookieHeader()
|
||||
);
|
||||
resource = res.data.data;
|
||||
@@ -77,22 +77,22 @@ export default async function ResourceLayout(props: ResourceLayoutProps) {
|
||||
const navItems = [
|
||||
{
|
||||
title: t('general'),
|
||||
href: `/{orgId}/settings/resources/{resourceId}/general`
|
||||
href: `/{orgId}/settings/resources/{niceId}/general`
|
||||
},
|
||||
{
|
||||
title: t('proxy'),
|
||||
href: `/{orgId}/settings/resources/{resourceId}/proxy`
|
||||
href: `/{orgId}/settings/resources/{niceId}/proxy`
|
||||
}
|
||||
];
|
||||
|
||||
if (resource.http) {
|
||||
navItems.push({
|
||||
title: t('authentication'),
|
||||
href: `/{orgId}/settings/resources/{resourceId}/authentication`
|
||||
href: `/{orgId}/settings/resources/{niceId}/authentication`
|
||||
});
|
||||
navItems.push({
|
||||
title: t('rules'),
|
||||
href: `/{orgId}/settings/resources/{resourceId}/rules`
|
||||
href: `/{orgId}/settings/resources/{niceId}/rules`
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
export default async function ResourcePage(props: {
|
||||
params: Promise<{ resourceId: number | string; orgId: string }>;
|
||||
params: Promise<{ niceId: string; orgId: string }>;
|
||||
}) {
|
||||
const params = await props.params;
|
||||
redirect(
|
||||
`/${params.orgId}/settings/resources/${params.resourceId}/proxy`
|
||||
`/${params.orgId}/settings/resources/${params.niceId}/proxy`
|
||||
);
|
||||
}
|
||||
@@ -256,7 +256,7 @@ export default function ReverseProxyTargets(props: {
|
||||
const fetchTargets = async () => {
|
||||
try {
|
||||
const res = await api.get<AxiosResponse<ListTargetsResponse>>(
|
||||
`/resource/${params.resourceId}/targets`
|
||||
`/resource/${resource.resourceId}/targets`
|
||||
);
|
||||
|
||||
if (res.status === 200) {
|
||||
@@ -447,7 +447,7 @@ export default function ReverseProxyTargets(props: {
|
||||
if (target.new) {
|
||||
const res = await api.put<
|
||||
AxiosResponse<CreateTargetResponse>
|
||||
>(`/resource/${params.resourceId}/target`, data);
|
||||
>(`/resource/${resource.resourceId}/target`, data);
|
||||
target.targetId = res.data.data.targetId;
|
||||
target.new = false;
|
||||
} else if (target.updated) {
|
||||
@@ -475,7 +475,7 @@ export default function ReverseProxyTargets(props: {
|
||||
};
|
||||
|
||||
// Single API call to update all settings
|
||||
await api.post(`/resource/${params.resourceId}`, payload);
|
||||
await api.post(`/resource/${resource.resourceId}`, payload);
|
||||
|
||||
// Update local resource context
|
||||
updateResource({
|
||||
@@ -128,7 +128,7 @@ export default function ResourceRules(props: {
|
||||
try {
|
||||
const res = await api.get<
|
||||
AxiosResponse<ListResourceRulesResponse>
|
||||
>(`/resource/${params.resourceId}/rules`);
|
||||
>(`/resource/${resource.resourceId}/rules`);
|
||||
if (res.status === 200) {
|
||||
setRules(res.data.data.rules);
|
||||
}
|
||||
@@ -251,7 +251,7 @@ export default function ResourceRules(props: {
|
||||
|
||||
// Save rules enabled state
|
||||
const res = await api
|
||||
.post(`/resource/${params.resourceId}`, {
|
||||
.post(`/resource/${resource.resourceId}`, {
|
||||
applyRules: rulesEnabled
|
||||
})
|
||||
.catch((err) => {
|
||||
@@ -336,13 +336,13 @@ export default function ResourceRules(props: {
|
||||
|
||||
if (rule.new) {
|
||||
const res = await api.put(
|
||||
`/resource/${params.resourceId}/rule`,
|
||||
`/resource/${resource.resourceId}/rule`,
|
||||
data
|
||||
);
|
||||
rule.ruleId = res.data.data.ruleId;
|
||||
} else if (rule.updated) {
|
||||
await api.post(
|
||||
`/resource/${params.resourceId}/rule/${rule.ruleId}`,
|
||||
`/resource/${resource.resourceId}/rule/${rule.ruleId}`,
|
||||
data
|
||||
);
|
||||
}
|
||||
@@ -361,7 +361,7 @@ export default function ResourceRules(props: {
|
||||
|
||||
for (const ruleId of rulesToRemove) {
|
||||
await api.delete(
|
||||
`/resource/${params.resourceId}/rule/${ruleId}`
|
||||
`/resource/${resource.resourceId}/rule/${ruleId}`
|
||||
);
|
||||
setRules(rules.filter((r) => r.ruleId !== ruleId));
|
||||
}
|
||||
@@ -481,7 +481,7 @@ export default function ResourcesTable({
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
<Link
|
||||
href={`/${resourceRow.orgId}/settings/resources/${resourceRow.id}`}
|
||||
href={`/${resourceRow.orgId}/settings/resources/${resourceRow.nice}`}
|
||||
>
|
||||
<Button
|
||||
variant={"secondary"}
|
||||
|
||||
Reference in New Issue
Block a user