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
@@ -0,0 +1,78 @@
|
||||
import { buildApiAdminVM } from "@hivegrid/view-models";
|
||||
import { Link, LoaderFunctionArgs, MetaFunction, useLoaderData } from "react-router";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import EditPageLayout from "~/components/ui/layouts/EditPageLayout";
|
||||
import ServerError from "~/components/ui/errors/ServerError";
|
||||
import { getTranslations } from "~/locale/i18next.server";
|
||||
import { useLocaleFormatters } from "~/locale/format";
|
||||
import { getApiAdminSnapshot } from "~/services/admin/api-admin.server";
|
||||
import { adminPath } from "~/utils/app/CanonicalUrlUtils";
|
||||
import { verifyUserHasPermission } from "~/utils/helpers/.server/PermissionsService";
|
||||
import { apiTabs } from "./index";
|
||||
|
||||
type LoaderData = {
|
||||
title: string;
|
||||
vm: ReturnType<typeof buildApiAdminVM>;
|
||||
};
|
||||
|
||||
export const meta: MetaFunction<typeof loader> = ({ data }) => [{ title: data?.title }];
|
||||
|
||||
export const loader = async ({ request }: LoaderFunctionArgs) => {
|
||||
await verifyUserHasPermission(request, "admin.apiKeys.view");
|
||||
const { t } = await getTranslations(request);
|
||||
return {
|
||||
title: `${t("admin.apiAdmin.clients.title")} | ${process.env.APP_NAME}`,
|
||||
vm: buildApiAdminVM(await getApiAdminSnapshot({ platformLeadVisibility: null })),
|
||||
} satisfies LoaderData;
|
||||
};
|
||||
|
||||
export default function ApiClientsRoute() {
|
||||
const { t } = useTranslation();
|
||||
const format = useLocaleFormatters();
|
||||
const data = useLoaderData<LoaderData>();
|
||||
const rows = data.vm.status === "ready" ? data.vm.data.consumers : [];
|
||||
|
||||
return (
|
||||
<EditPageLayout title={t("admin.apiAdmin.clients.title")} tabs={apiTabs(t)} fullWidth>
|
||||
<div className="overflow-hidden rounded-md border">
|
||||
<table className="w-full text-sm">
|
||||
<thead className="bg-muted/40 text-muted-foreground text-xs uppercase">
|
||||
<tr>
|
||||
<th className="px-3 py-2 text-left">{t("models.tenant.object")}</th>
|
||||
<th className="px-3 py-2 text-left">{t("admin.apiAdmin.consumers.keys")}</th>
|
||||
<th className="px-3 py-2 text-left">{t("admin.apiAdmin.consumers.activeKeys")}</th>
|
||||
<th className="px-3 py-2 text-left">{t("admin.apiAdmin.consumers.lastKey")}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{rows.length === 0 ? (
|
||||
<tr>
|
||||
<td colSpan={4} className="text-muted-foreground px-3 py-6 text-center">
|
||||
{t("admin.apiAdmin.clients.empty")}
|
||||
</td>
|
||||
</tr>
|
||||
) : (
|
||||
rows.map((row) => (
|
||||
<tr key={row.id} className="border-border hover:bg-muted/30 border-t">
|
||||
<td className="px-3 py-2">
|
||||
<Link className="text-primary font-medium hover:underline" to={adminPath(`accounts/${row.id}`, { mode: "host-aware" })}>
|
||||
{row.name}
|
||||
</Link>
|
||||
<div className="text-muted-foreground text-xs">/{row.slug}</div>
|
||||
</td>
|
||||
<td className="px-3 py-2">{format.number(row.keyCount)}</td>
|
||||
<td className="px-3 py-2">{format.number(row.activeKeyCount)}</td>
|
||||
<td className="text-muted-foreground px-3 py-2">{row.lastKeyCreatedAt ? format.dateTime(row.lastKeyCreatedAt) : t("shared.notSet")}</td>
|
||||
</tr>
|
||||
))
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</EditPageLayout>
|
||||
);
|
||||
}
|
||||
|
||||
export function ErrorBoundary() {
|
||||
return <ServerError />;
|
||||
}
|
||||
Reference in new issue
Block a user