Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,107 @@
|
||||
import { Entity } from "@toolctrl/db/prisma-browser";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { LoaderFunctionArgs, redirect } from "react-router";
|
||||
import { Outlet, useLoaderData, useParams } from "react-router";
|
||||
import EditPageLayout from "~/components/ui/layouts/EditPageLayout";
|
||||
import TabsVertical from "~/components/ui/tabs/TabsVertical";
|
||||
import { findEntityBySlug } from "~/utils/db/entities/entities.db.server";
|
||||
import { verifyUserHasPermission } from "~/utils/helpers/.server/PermissionsService";
|
||||
import { adminPath } from "~/utils/app/CanonicalUrlUtils";
|
||||
|
||||
type LoaderData = {
|
||||
item: Entity;
|
||||
};
|
||||
export const loader = async ({ request, params }: LoaderFunctionArgs) => {
|
||||
await verifyUserHasPermission(request, "admin.entities.update");
|
||||
const item = await findEntityBySlug(params.entity!);
|
||||
if (!item) {
|
||||
return redirect(adminPath("entities", { mode: "host-aware" }));
|
||||
}
|
||||
|
||||
const pathname = new URL(request.url).pathname;
|
||||
if (pathname === adminPath(`entities/${params.entity}`, { mode: "host-aware" })) {
|
||||
return redirect(adminPath(`entities/${params.entity}/details`, { mode: "host-aware" }));
|
||||
}
|
||||
const data: LoaderData = {
|
||||
item,
|
||||
};
|
||||
return data;
|
||||
};
|
||||
|
||||
export default function EditEntityRoute() {
|
||||
const { t } = useTranslation();
|
||||
const data = useLoaderData<LoaderData>();
|
||||
const params = useParams();
|
||||
return (
|
||||
<EditPageLayout
|
||||
title={`${t(data.item.title)}`}
|
||||
menu={[
|
||||
{ title: t("models.entity.plural"), routePath: adminPath("entities", { mode: "host-aware" }) },
|
||||
{ title: t(data.item.title), routePath: adminPath(`entities/${params.entity}/details`, { mode: "host-aware" }) },
|
||||
]}
|
||||
withHome={false}
|
||||
>
|
||||
<div className="grid grid-cols-1 gap-4 lg:grid-cols-12 xl:gap-12">
|
||||
<div className="lg:col-span-3">
|
||||
<TabsVertical
|
||||
tabs={[
|
||||
{
|
||||
name: t("shared.details"),
|
||||
routePath: adminPath(`entities/${params.entity}/details`, { mode: "host-aware" }),
|
||||
},
|
||||
{
|
||||
name: t("models.property.plural"),
|
||||
routePath: adminPath(`entities/${params.entity}/properties`, { mode: "host-aware" }),
|
||||
},
|
||||
{
|
||||
name: t("models.relationship.plural"),
|
||||
routePath: adminPath(`entities/${params.entity}/relationships`, { mode: "host-aware" }),
|
||||
},
|
||||
{
|
||||
name: t("models.view.plural"),
|
||||
routePath: adminPath(`entities/${params.entity}/views`, { mode: "host-aware" }),
|
||||
},
|
||||
{
|
||||
name: t("models.entity.rows"),
|
||||
routePath: adminPath(`entities/${params.entity}/rows`, { mode: "host-aware" }),
|
||||
},
|
||||
// {
|
||||
// name: "Views and Forms",
|
||||
// routePath: adminPath(`entities/${params.entity}/views-and-forms`, { mode: "host-aware" }),
|
||||
// },
|
||||
{
|
||||
name: t("models.log.plural"),
|
||||
routePath: adminPath(`entities/logs?entity=${data.item.id}`, { mode: "host-aware" }),
|
||||
},
|
||||
{
|
||||
name: t("models.entityWebhook.plural"),
|
||||
routePath: adminPath(`entities/${params.entity}/webhooks`, { mode: "host-aware" }),
|
||||
},
|
||||
{
|
||||
name: t("models.entityTemplate.plural"),
|
||||
routePath: adminPath(`entities/${params.entity}/templates`, { mode: "host-aware" }),
|
||||
},
|
||||
{
|
||||
name: t("models.entity.api"),
|
||||
routePath: adminPath(`entities/${params.entity}/api`, { mode: "host-aware" }),
|
||||
},
|
||||
{
|
||||
name: t("models.entity.noCode.menu"),
|
||||
routePath: adminPath(`entities/${params.entity}/no-code`, { mode: "host-aware" }),
|
||||
},
|
||||
{
|
||||
name: t("shared.danger"),
|
||||
routePath: adminPath(`entities/${params.entity}/danger`, { mode: "host-aware" }),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
<div className="lg:col-span-9">
|
||||
<div className="w-full">
|
||||
<Outlet />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</EditPageLayout>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user