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,18 +1,33 @@
|
||||
import { useLoaderData } from "react-router";
|
||||
import { Link, useLoaderData } from "react-router";
|
||||
import { useSearchParams } from "react-router";
|
||||
import {
|
||||
FeatherActivity,
|
||||
FeatherAlertTriangle,
|
||||
FeatherArrowRight,
|
||||
FeatherCheckCircle,
|
||||
FeatherCreditCard,
|
||||
FeatherRocket,
|
||||
FeatherServer,
|
||||
FeatherShieldCheck,
|
||||
} from "@subframe/core";
|
||||
import type React from "react";
|
||||
import { DashboardStats } from "~/components/ui/stats/DashboardStats";
|
||||
import ProfileBanner from "~/components/app/ProfileBanner";
|
||||
import { AdminPageHeader } from "~/components/screens/admin/AdminPageHeader";
|
||||
import { AdminPersonalizedDashboard } from "~/components/screens/admin/AdminPersonalizedDashboard";
|
||||
import TenantsTable from "~/components/core/tenants/TenantsTable";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { defaultPeriodFilter, PeriodFilters } from "~/utils/helpers/PeriodHelper";
|
||||
import { useAppOrAdminData } from "~/utils/data/useAppOrAdminData";
|
||||
import { serverTimingHeaders } from "~/modules/metrics/utils/defaultHeaders";
|
||||
import { getUserHasPermission } from "~/utils/helpers/PermissionsHelper";
|
||||
import ButtonSecondary from "~/components/ui/buttons/ButtonSecondary";
|
||||
import InputSelect from "~/components/ui/input/InputSelect";
|
||||
import { v2MetaFunction } from "~/utils/compat/v2MetaFunction";
|
||||
import { adminPath } from "~/utils/app/CanonicalUrlUtils";
|
||||
import type { AdminDashboardLoaderData } from "~/routeModules/admin/dashboard.impl";
|
||||
import type { AdminDashboardActivity, AdminDashboardSignal, AdminDashboardSignalTone } from "~/utils/services/adminDashboardService";
|
||||
import { formatDate } from "~/locale/format";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
export { serverTimingHeaders as headers };
|
||||
export { loader } from "~/routeModules/admin/dashboard.impl";
|
||||
|
||||
@@ -26,20 +41,23 @@ export default function AdminNavigationRoute() {
|
||||
|
||||
return (
|
||||
<main className="relative z-0 flex-1 pb-8">
|
||||
{/*Page header */}
|
||||
<div className="bg-background lg:border-border hidden shadow-xs md:block lg:border-t">
|
||||
<ProfileBanner user={appOrAdminData.user} />
|
||||
</div>
|
||||
<AdminPageHeader title={t("app.sidebar.dashboard")} description={t("admin.dashboard.pageDescription")} />
|
||||
|
||||
<div className="mx-auto grid max-w-5xl gap-5 px-4 py-5 sm:px-8">
|
||||
{getUserHasPermission(appOrAdminData, "admin.dashboard.view") ? (
|
||||
<div className="space-y-5 overflow-hidden">
|
||||
<div className="space-y-3 truncate p-1">
|
||||
<div className="mobile:px-4 grid w-full gap-5 px-6 py-6">
|
||||
<div className="space-y-5 overflow-hidden">
|
||||
<GreetingTile firstName={appOrAdminData.user?.firstName} email={appOrAdminData.user?.email} />
|
||||
<AdminPersonalizedDashboard vm={data.dashboard} />
|
||||
{data.superOverview ? (
|
||||
<>
|
||||
<div className="space-y-3 p-1">
|
||||
<div className="flex items-center justify-between space-x-2">
|
||||
<h3 className="text-foreground grow font-medium leading-4">{t("app.dashboard.summary")}</h3>
|
||||
<h3 className="text-body-large-0 font-body-large-0 text-text-neutral-primary grow">
|
||||
{t("admin.dashboard.personalized.platformDetails")}
|
||||
</h3>
|
||||
<div>
|
||||
{/* Subframe Select has a fixed 192px min-width — the wrapper must match or the chevron gets clipped. */}
|
||||
<InputSelect
|
||||
className="w-44"
|
||||
className="w-48"
|
||||
name="period"
|
||||
value={searchParams.get("period")?.toString() ?? defaultPeriodFilter}
|
||||
options={PeriodFilters.map((f) => {
|
||||
@@ -59,21 +77,275 @@ export default function AdminNavigationRoute() {
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<DashboardStats items={data.stats} />
|
||||
<DashboardStats items={data.superOverview.stats} />
|
||||
</div>
|
||||
|
||||
<div className="grid gap-4 lg:grid-cols-[minmax(0,1.3fr)_minmax(320px,0.7fr)]">
|
||||
<OperatorPanel
|
||||
title={t("admin.dashboard.billing.title")}
|
||||
description={t("admin.dashboard.billing.description")}
|
||||
icon={<FeatherCreditCard aria-hidden="true" />}
|
||||
signals={data.superOverview.overview.billing.signals}
|
||||
ctaHref={adminPath("system/billing", { mode: "host-aware" })}
|
||||
ctaLabel={t("admin.dashboard.billing.cta")}
|
||||
/>
|
||||
<DeployPanel
|
||||
title={t("admin.dashboard.deploy.title")}
|
||||
description={t("admin.dashboard.deploy.description")}
|
||||
environment={data.superOverview.overview.deploy.environment}
|
||||
release={data.superOverview.overview.deploy.release}
|
||||
signals={data.superOverview.overview.deploy.signals}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="grid gap-4 lg:grid-cols-[minmax(0,1fr)_minmax(320px,0.85fr)]">
|
||||
<OperatorPanel
|
||||
title={t("admin.dashboard.system.title")}
|
||||
description={t("admin.dashboard.system.description")}
|
||||
icon={<FeatherServer aria-hidden="true" />}
|
||||
signals={data.superOverview.overview.system.signals}
|
||||
ctaHref={adminPath("events", { mode: "host-aware" })}
|
||||
ctaLabel={t("admin.dashboard.system.cta")}
|
||||
/>
|
||||
<RecentActivityPanel
|
||||
title={t("admin.dashboard.recentActivity.title")}
|
||||
description={t("admin.dashboard.recentActivity.description")}
|
||||
emptyLabel={t("admin.dashboard.recentActivity.empty")}
|
||||
items={data.superOverview.overview.recentEvents}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="space-y-4 overflow-x-auto p-1">
|
||||
<div className="flex items-center justify-between space-x-2">
|
||||
<h3 className="text-foreground font-medium leading-4">{t("models.tenant.plural")}</h3>
|
||||
<ButtonSecondary to={adminPath("accounts", { mode: "host-aware" })}>{t("shared.viewAll")}</ButtonSecondary>
|
||||
<h3 className="text-body-large-0 font-body-large-0 text-text-neutral-primary">{t("models.tenant.plural")}</h3>
|
||||
<Link to={adminPath("accounts", { mode: "host-aware" })}>
|
||||
<Button variant="tertiary" size="small" iconRight={<FeatherArrowRight />}>
|
||||
{t("shared.viewAll")}
|
||||
</Button>
|
||||
</Link>
|
||||
</div>
|
||||
<TenantsTable items={data.tenants.items} pagination={data.tenants.pagination} />
|
||||
<TenantsTable
|
||||
items={data.superOverview.tenants.items}
|
||||
pagination={data.superOverview.tenants.pagination}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div className="font-medium">{t("app.dashboard.noPermission")}</div>
|
||||
)}
|
||||
</>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
function GreetingTile({ firstName, email }: { firstName?: string | null; email?: string | null }) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Card variant="neutral">
|
||||
<div className="flex w-full flex-col items-start">
|
||||
<span className="text-body-large-0 font-body-large-0 text-text-neutral-primary">
|
||||
{t("shared.hi")} {firstName ? <span>{firstName} 👋</span> : null}
|
||||
</span>
|
||||
{email ? <span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{email}</span> : null}
|
||||
</div>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
function OperatorPanel({
|
||||
title,
|
||||
description,
|
||||
icon,
|
||||
signals,
|
||||
ctaHref,
|
||||
ctaLabel,
|
||||
}: {
|
||||
title: string;
|
||||
description: string;
|
||||
icon: React.ReactNode;
|
||||
signals: AdminDashboardSignal[];
|
||||
ctaHref: string;
|
||||
ctaLabel: string;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<Card>
|
||||
<div className="flex w-full items-start justify-between gap-4">
|
||||
<div className="flex min-w-0 items-start gap-3">
|
||||
<span className="text-heading- font-heading- text-icon-neutral-tertiary">{icon}</span>
|
||||
<div className="flex min-w-0 flex-col items-start">
|
||||
<span className="text-body-large-0 font-body-large-0 text-text-neutral-primary">{title}</span>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{description}</span>
|
||||
</div>
|
||||
</div>
|
||||
<Link to={ctaHref}>
|
||||
<Button variant="tertiary" size="small" iconRight={<FeatherArrowRight />}>
|
||||
{ctaLabel}
|
||||
</Button>
|
||||
</Link>
|
||||
</div>
|
||||
<div className="grid w-full gap-3 sm:grid-cols-2 xl:grid-cols-3">
|
||||
{signals.map((signal) => (
|
||||
<SignalCard key={signal.id} signal={signal} label={t(signal.labelKey)} detail={t(signal.detailKey)} />
|
||||
))}
|
||||
</div>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
function DeployPanel({
|
||||
title,
|
||||
description,
|
||||
environment,
|
||||
release,
|
||||
signals,
|
||||
}: {
|
||||
title: string;
|
||||
description: string;
|
||||
environment: string;
|
||||
release: string;
|
||||
signals: AdminDashboardSignal[];
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<Card>
|
||||
<div className="flex w-full items-start gap-3">
|
||||
<span className="text-heading- font-heading- text-icon-neutral-tertiary">
|
||||
<FeatherRocket />
|
||||
</span>
|
||||
<div className="flex min-w-0 flex-col items-start">
|
||||
<span className="text-body-large-0 font-body-large-0 text-text-neutral-primary">{title}</span>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{description}</span>
|
||||
</div>
|
||||
</div>
|
||||
<dl className="grid w-full grid-cols-[7rem_minmax(0,1fr)] gap-x-3 gap-y-2">
|
||||
<dt className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t("admin.dashboard.deploy.environment")}</dt>
|
||||
<dd className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-primary truncate">{environment}</dd>
|
||||
<dt className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t("admin.dashboard.deploy.release")}</dt>
|
||||
<dd className="text-text-neutral-primary truncate font-mono text-xs">{release}</dd>
|
||||
</dl>
|
||||
<div className="grid w-full gap-3">
|
||||
{signals.map((signal) => (
|
||||
<SignalCard key={signal.id} signal={signal} label={t(signal.labelKey)} detail={t(signal.detailKey)} compact />
|
||||
))}
|
||||
</div>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
function SignalCard({ signal, label, detail, compact = false }: { signal: AdminDashboardSignal; label: string; detail: string; compact?: boolean }) {
|
||||
const content = (
|
||||
<div className="border-border-default bg-surface-neutral-primary hover:bg-surface-neutral-secondary/60 flex h-full min-h-20 w-full flex-col justify-between gap-3 rounded-md border border-solid px-4 py-3 transition-colors">
|
||||
<div className="flex w-full items-start justify-between gap-3">
|
||||
<div className="flex min-w-0 flex-col items-start">
|
||||
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-primary truncate">{label}</span>
|
||||
<span className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary">{detail}</span>
|
||||
</div>
|
||||
<StatusBadge tone={signal.tone} />
|
||||
</div>
|
||||
<span className={compact ? "text-body-large-0 font-body-large-0 text-text-neutral-primary" : "text-subtitle-0 font-subtitle-0 text-text-neutral-primary"}>
|
||||
{signal.value}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
|
||||
if (!signal.href) {
|
||||
return content;
|
||||
}
|
||||
|
||||
return (
|
||||
<Link className="focus-visible:shadow-focus block focus-visible:outline-none" to={signal.href}>
|
||||
{content}
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
|
||||
function RecentActivityPanel({
|
||||
title,
|
||||
description,
|
||||
emptyLabel,
|
||||
items,
|
||||
}: {
|
||||
title: string;
|
||||
description: string;
|
||||
emptyLabel: string;
|
||||
items: AdminDashboardActivity[];
|
||||
}) {
|
||||
const { i18n } = useTranslation();
|
||||
return (
|
||||
<Card>
|
||||
<div className="flex w-full items-start gap-3">
|
||||
<span className="text-heading- font-heading- text-icon-neutral-tertiary">
|
||||
<FeatherActivity />
|
||||
</span>
|
||||
<div className="flex min-w-0 flex-col items-start">
|
||||
<span className="text-body-large-0 font-body-large-0 text-text-neutral-primary">{title}</span>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{description}</span>
|
||||
</div>
|
||||
</div>
|
||||
{items.length === 0 ? (
|
||||
<span className="border-border-default text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary w-full rounded-md border border-dashed p-4">
|
||||
{emptyLabel}
|
||||
</span>
|
||||
) : (
|
||||
<div className="flex w-full flex-col items-start gap-2">
|
||||
{items.map((item) => (
|
||||
<Link
|
||||
key={item.id}
|
||||
to={item.href}
|
||||
className="border-border-default bg-surface-neutral-primary hover:bg-surface-neutral-secondary/60 flex w-full items-start gap-3 rounded-md border border-solid px-4 py-3 transition-colors"
|
||||
>
|
||||
<StatusIcon tone={item.tone} />
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-primary truncate">{item.label}</p>
|
||||
<p className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary truncate">{item.detail}</p>
|
||||
</div>
|
||||
<time
|
||||
className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary shrink-0"
|
||||
dateTime={item.timestamp}
|
||||
>
|
||||
{formatTimestamp(item.timestamp, i18n.language)}
|
||||
</time>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
function StatusBadge({ tone }: { tone: AdminDashboardSignalTone }) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<BadgeFeedback farbe={toneToBadgeTone(tone)} size="small">
|
||||
{t(`admin.dashboard.tones.${tone}`)}
|
||||
</BadgeFeedback>
|
||||
);
|
||||
}
|
||||
|
||||
function StatusIcon({ tone }: { tone: AdminDashboardSignalTone }) {
|
||||
if (tone === "success") {
|
||||
return <FeatherCheckCircle className="text-icon-feedback-positive mt-0.5 size-4 shrink-0" aria-hidden="true" />;
|
||||
}
|
||||
if (tone === "danger" || tone === "warning") {
|
||||
return <FeatherAlertTriangle className="text-icon-feedback-warning mt-0.5 size-4 shrink-0" aria-hidden="true" />;
|
||||
}
|
||||
return <FeatherShieldCheck className="text-icon-neutral-tertiary mt-0.5 size-4 shrink-0" aria-hidden="true" />;
|
||||
}
|
||||
|
||||
function toneToBadgeTone(tone: AdminDashboardSignalTone): "subtle-positive" | "subtle-negative" | "subtle-warning" | "subtle-neutral" {
|
||||
if (tone === "success") return "subtle-positive";
|
||||
if (tone === "danger") return "subtle-negative";
|
||||
if (tone === "warning") return "subtle-warning";
|
||||
return "subtle-neutral";
|
||||
}
|
||||
|
||||
function formatTimestamp(value: string, locale: string) {
|
||||
try {
|
||||
// Explicit locale + fixed time zone keep SSR and client output identical (React #418).
|
||||
return formatDate(value, locale, { day: "2-digit", month: "2-digit", hour: "2-digit", minute: "2-digit" });
|
||||
} catch {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user