Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
@@ -1,7 +1,6 @@
|
||||
import { ActionFunction, LoaderFunctionArgs, useLoaderData } from "react-router";
|
||||
import { ActionFunction, LoaderFunctionArgs, useActionData, useLoaderData } from "react-router";
|
||||
import { FilterablePropertyDto } from "~/application/dtos/data/FilterablePropertyDto";
|
||||
import { PaginationDto } from "~/application/dtos/data/PaginationDto";
|
||||
import { getTranslations } from "~/locale/i18next.server";
|
||||
import { verifyUserHasPermission } from "~/utils/helpers/.server/PermissionsService";
|
||||
import ApiKeyLogService from "~/modules/api/services/ApiKeyLogService";
|
||||
import { ApiKeyLogDto } from "~/modules/api/dtos/ApiKeyLogDto";
|
||||
@@ -9,14 +8,16 @@ import ApiKeyLogsDetails from "~/modules/api/components/ApiKeyLogsDetails";
|
||||
import EditPageLayout from "~/components/ui/layouts/EditPageLayout";
|
||||
import { requireAuth } from "~/utils/loaders.middleware";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { adminPath } from "~/utils/app/CanonicalUrlUtils";
|
||||
import { validateCSRFToken } from "~/utils/session.server";
|
||||
import { apiTabs } from "./index";
|
||||
import { useSaveToast } from "~/hooks/use-save-toast";
|
||||
|
||||
type LoaderData = {
|
||||
items: ApiKeyLogDto[];
|
||||
filterableProperties: FilterablePropertyDto[];
|
||||
pagination: PaginationDto;
|
||||
};
|
||||
type ActionData = { intent: "delete"; ok?: true; messageKey?: string; messageValues?: { count: number }; errorKey?: string };
|
||||
export const loader = async ({ request, params }: LoaderFunctionArgs) => {
|
||||
await requireAuth({ request, params, adminOnly: true });
|
||||
await verifyUserHasPermission(request, "admin.apiKeys.view");
|
||||
@@ -32,39 +33,29 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
|
||||
export const action: ActionFunction = async ({ request, params }) => {
|
||||
await requireAuth({ request, params, adminOnly: true });
|
||||
await verifyUserHasPermission(request, "admin.apiKeys.update");
|
||||
const { t } = await getTranslations(request);
|
||||
await validateCSRFToken(request);
|
||||
const form = await request.formData();
|
||||
if (form.get("action") === "delete") {
|
||||
await verifyUserHasPermission(request, "admin.apiKeys.delete");
|
||||
const ids = (form.get("ids")?.toString().split(",") ?? []).map((x) => x.toString() ?? "");
|
||||
await ApiKeyLogService.adminDeleteMany(ids);
|
||||
return Response.json({ success: true });
|
||||
const result = await ApiKeyLogService.adminDeleteMany(ids);
|
||||
if (result.rejectedTenantlessIds.length > 0) {
|
||||
return Response.json({ intent: "delete", errorKey: "admin.apiAdmin.logs.tenantlessDeleteDenied" } satisfies ActionData, { status: 400 });
|
||||
}
|
||||
return Response.json({ intent: "delete", ok: true, messageKey: "admin.apiAdmin.logs.deleted", messageValues: { count: ids.length } } satisfies ActionData);
|
||||
} else {
|
||||
return Response.json({ error: t("shared.invalidForm"), success: false }, { status: 400 });
|
||||
return Response.json({ intent: "delete", errorKey: "shared.invalidForm" } satisfies ActionData, { status: 400 });
|
||||
}
|
||||
};
|
||||
|
||||
export default function () {
|
||||
const { t } = useTranslation();
|
||||
const data = useLoaderData<LoaderData>();
|
||||
const actionData = useActionData<ActionData>();
|
||||
|
||||
useSaveToast(actionData);
|
||||
return (
|
||||
<EditPageLayout
|
||||
tabs={[
|
||||
{
|
||||
name: t("shared.overview"),
|
||||
routePath: adminPath("api", { mode: "host-aware" }),
|
||||
},
|
||||
{
|
||||
name: t("models.apiCall.plural"),
|
||||
routePath: adminPath("api/logs", { mode: "host-aware" }),
|
||||
},
|
||||
{
|
||||
name: t("models.apiKey.plural"),
|
||||
routePath: adminPath("api/keys", { mode: "host-aware" }),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<EditPageLayout title={t("models.apiCall.plural")} tabs={apiTabs(t)} fullWidth>
|
||||
<ApiKeyLogsDetails data={data} />
|
||||
</EditPageLayout>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user