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,79 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { LoaderFunctionArgs, redirect } from "react-router";
|
||||
import { Outlet, useLoaderData } from "react-router";
|
||||
import { PlusIcon } from "~/components/ui/icons/vendor";
|
||||
import ButtonTertiary from "~/components/ui/buttons/ButtonTertiary";
|
||||
import TableSimple from "~/components/ui/tables/TableSimple";
|
||||
import { getEntityBySlug } from "~/utils/db/entities/entities.db.server";
|
||||
import { EntityWebhookWithDetails, getEntityWebhooks } from "~/utils/db/entities/entityWebhooks.db.server";
|
||||
import { verifyUserHasPermission } from "~/utils/helpers/.server/PermissionsService";
|
||||
import { adminPath } from "~/utils/app/CanonicalUrlUtils";
|
||||
|
||||
type LoaderData = {
|
||||
items: EntityWebhookWithDetails[];
|
||||
};
|
||||
export const loader = async ({ request, params }: LoaderFunctionArgs) => {
|
||||
await verifyUserHasPermission(request, "admin.entities.view");
|
||||
const entity = await getEntityBySlug({ tenantId: null, slug: params.entity ?? "" });
|
||||
if (!entity) {
|
||||
return redirect(adminPath("entities", { mode: "host-aware" }));
|
||||
}
|
||||
const items = await getEntityWebhooks(entity.id);
|
||||
const data: LoaderData = {
|
||||
items,
|
||||
};
|
||||
return data;
|
||||
};
|
||||
|
||||
export default function EditEntityIndexRoute() {
|
||||
const data = useLoaderData<LoaderData>();
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="space-y-3">
|
||||
<h3 className="text-foreground text-sm font-medium leading-3">{t("models.entityWebhook.plural")}</h3>
|
||||
<TableSimple
|
||||
headers={[
|
||||
{
|
||||
title: t("models.entityWebhook.action"),
|
||||
name: "action",
|
||||
value: (item) => t(`models.entityWebhook.actions.${item.action.toLowerCase()}`),
|
||||
},
|
||||
{
|
||||
title: t("models.entityWebhook.method"),
|
||||
name: "method",
|
||||
value: (item) => item.method,
|
||||
},
|
||||
{
|
||||
title: t("models.entityWebhook.endpoint"),
|
||||
name: "endpoint",
|
||||
className: "w-full",
|
||||
value: (item) => item.endpoint,
|
||||
},
|
||||
{
|
||||
title: t("models.entityWebhook.logs"),
|
||||
name: "logs",
|
||||
className: "w-full",
|
||||
value: (item) => item._count.logs,
|
||||
},
|
||||
]}
|
||||
items={data.items}
|
||||
actions={[
|
||||
{
|
||||
title: t("shared.edit"),
|
||||
onClickRoute: (idx, item) => item.id,
|
||||
},
|
||||
]}
|
||||
></TableSimple>
|
||||
<div className="w-fu flex justify-start">
|
||||
<ButtonTertiary to="new">
|
||||
<PlusIcon className="h-5 w-5" />
|
||||
<span className="font-medium uppercase">{t("shared.add")}</span>
|
||||
</ButtonTertiary>
|
||||
</div>
|
||||
</div>
|
||||
<Outlet />
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user