Refresh HiveGrid Cloud reference snapshot

This commit is contained in:
david committed 2026-08-03 15:31:14 +02:00
1 parent 5e99e14772
commit 7f88026f79
5955 files changed
+1177325 -188362

No files matched your search

@@ -1,54 +1,76 @@
// AK-P21 (AD-28 interim polish) — global feedback widget. The mini form is a
// real ~/ui Dialog (size XS 420) with a category select (bug/feature/question,
// designer brief P21); the category is prefixed into the message because the
// support-ticket contract intentionally has no category column. Shared by the
// legacy NavBar trigger (mobile visibility restriction removed) and the shadcn
// nav-actions trigger. Submission keeps the established add-feedback intent on
// the tenant root route (rate limit 3/24h lives in Feedback.server).
//
// Instead of the originally sketched screenshot checkbox, the reporter attaches
// an image themselves (decision 2026-07-21): the client never captures the page
// on its own, so no third-party personal data leaves the workspace without the
// reporter consciously picking the file. The upload is fail-closed scanned and
// ClamAV-checked server-side.
import { useFetcher, useLocation, useParams } from "react-router";
import { Fragment, useEffect, useState } from "react";
import toast from "react-hot-toast";
import { toast } from "sonner";
import { useTranslation } from "react-i18next";
import ButtonPrimary from "~/components/ui/buttons/ButtonPrimary";
import StarsIconFilled from "~/components/ui/icons/StarsIconFilled";
import InputText from "~/components/ui/input/InputText";
import Modal from "~/components/ui/modals/Modal";
import { appPath } from "~/utils/app/CanonicalUrlUtils";
import { useAppOrAdminData } from "~/utils/data/useAppOrAdminData";
import { useRootData } from "~/utils/data/useRootData";
import { Button } from "~/ui/components/Button";
import { Dialog } from "~/ui/components/Dialog";
import { Select } from "~/ui/components/Select";
import { TextArea } from "~/ui/components/TextArea";
const FEEDBACK_CATEGORIES = ["bug", "feature", "question"] as const;
type FeedbackCategory = (typeof FEEDBACK_CATEGORIES)[number];
/** Mirrors the server-side contract in Feedback.server. */
const FEEDBACK_ATTACHMENT_ACCEPT = "image/png,image/jpeg,image/webp,image/gif";
const FEEDBACK_ATTACHMENT_MAX_MB = 5;
export default function AddFeedbackButton() {
const [isOpen, setIsOpen] = useState(false);
const { t } = useTranslation();
return (
<Fragment>
<div className="relative hidden sm:inline-flex">
<div className="relative">
<div className="inline-flex divide-x divide-gray-300 rounded-sm shadow-none">
<div className="relative z-0 inline-flex rounded-full text-sm shadow-none">
<button
onClick={() => setIsOpen(!isOpen)}
type="button"
className="text-muted-foreground bg-secondary hover:bg-secondary/90 border-border relative inline-flex items-center rounded-full border p-2 font-medium shadow-inner focus:z-10 focus:outline-hidden focus:ring-2 focus:ring-offset-2"
aria-haspopup="listbox"
aria-expanded="true"
aria-label={t("feedback.title")}
>
<span className="sr-only">{t("feedback.title")}</span>
<StarsIconFilled className="h-5 w-5 p-0.5" />
</button>
</div>
</div>
</div>
<div className="relative inline-flex">
<button
onClick={() => setIsOpen(!isOpen)}
type="button"
className="text-muted-foreground bg-secondary hover:bg-secondary/90 border-border relative inline-flex items-center rounded-full border p-2 font-medium shadow-inner focus:z-10 focus:outline-hidden focus:ring-2 focus:ring-offset-2"
aria-haspopup="dialog"
aria-expanded={isOpen}
aria-label={t("feedback.title")}
>
<span className="sr-only">{t("feedback.title")}</span>
<StarsIconFilled className="h-5 w-5 p-0.5" />
</button>
</div>
<Modal open={isOpen} setOpen={setIsOpen} size="sm">
<FeedbackForm onClose={() => setIsOpen(false)} />
</Modal>
<FeedbackFormDialog open={isOpen} onClose={() => setIsOpen(false)} />
</Fragment>
);
}
function FeedbackForm({ onClose }: { onClose: () => void }) {
export function FeedbackFormDialog({ open, onClose }: { open: boolean; onClose: () => void }) {
const { t } = useTranslation();
const params = useParams();
const appOrAdminData = useAppOrAdminData();
const { csrf } = useRootData();
const fetcher = useFetcher<{ success?: string; error?: string }>();
const location = useLocation();
const [category, setCategory] = useState<FeedbackCategory>("bug");
const [attachmentError, setAttachmentError] = useState<string | null>(null);
useEffect(() => {
if (open) {
setCategory("bug");
setAttachmentError(null);
}
}, [open]);
useEffect(() => {
if (fetcher.data?.success) {
@@ -60,31 +82,109 @@ function FeedbackForm({ onClose }: { onClose: () => void }) {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [fetcher.data]);
const onSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
const submitting = fetcher.state !== "idle";
const onSubmit = (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
fetcher.submit(e.currentTarget, {
if (attachmentError) return;
void fetcher.submit(e.currentTarget, {
method: "post",
action: appPath({ tenantSlug: params.tenant ?? "", mode: "host-aware" }),
encType: "multipart/form-data",
action: params.tenant ? appPath({ tenantSlug: params.tenant, mode: "host-aware" }) : "",
});
// onClose();
};
// Reject oversized or non-image picks before the upload is attempted; the
// server enforces the same limits again.
const onAttachmentChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const file = e.currentTarget.files?.[0] ?? null;
if (!file) {
setAttachmentError(null);
return;
}
if (file.size > FEEDBACK_ATTACHMENT_MAX_MB * 1024 * 1024) {
setAttachmentError(t("feedback.attachment.tooLarge", { megabytes: FEEDBACK_ATTACHMENT_MAX_MB }));
return;
}
if (!FEEDBACK_ATTACHMENT_ACCEPT.split(",").includes(file.type)) {
setAttachmentError(t("feedback.attachment.unsupportedType"));
return;
}
setAttachmentError(null);
};
return (
<fetcher.Form onSubmit={onSubmit} method="post">
<input type="hidden" name="action" value="add-feedback" readOnly hidden />
<input type="hidden" name="csrf" value={csrf ?? ""} readOnly hidden />
<input type="hidden" name="tenantId" value={appOrAdminData.currentTenant?.id} readOnly hidden />
<input type="hidden" name="fromUrl" value={location.pathname} readOnly hidden />
<div className="space-y-3">
<h3 className="text-lg font-medium leading-6">{t("feedback.title")}</h3>
<p className="text-muted-foreground text-sm">{t("feedback.description")}</p>
<InputText name="message" title="feedback.message" withLabel={false} defaultValue="" required rows={5} placeholder={t("feedback.placeholder")} />
<div className="flex justify-between">
<button type="button" onClick={onClose} className="text-muted-foreground text-sm hover:underline">
{t("shared.cancel")}
</button>
<ButtonPrimary type="submit">{t("feedback.send")}</ButtonPrimary>
</div>
</div>
</fetcher.Form>
<Dialog open={open} onOpenChange={(nextOpen: boolean) => (nextOpen ? undefined : onClose())}>
<Dialog.Content className="w-[420px] max-w-[90vw] p-4" aria-label={t("feedback.title")} data-ui-id="ui.feedback.dialog">
<fetcher.Form onSubmit={onSubmit} method="post" className="flex w-full flex-col items-start">
<input type="hidden" name="action" value="add-feedback" readOnly hidden />
<input type="hidden" name="csrf" value={csrf ?? ""} readOnly hidden />
<input type="hidden" name="tenantId" value={appOrAdminData.currentTenant?.id} readOnly hidden />
<input type="hidden" name="fromUrl" value={location.pathname} readOnly hidden />
{/* Radix Select is not a native form control — mirror the picked category. */}
<input type="hidden" name="category" value={category} readOnly hidden />
<div className="flex w-full flex-col items-start gap-2">
<span className="text-heading-0 font-heading-0 text-text-neutral-primary">{t("feedback.title")}</span>
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">{t("feedback.description")}</span>
</div>
<div className="flex w-full flex-col items-start gap-4 pt-4">
<Select
className="w-full max-w-none"
showLabel
label={t("feedback.category.label")}
value={category}
onValueChange={(value: string) => setCategory(FEEDBACK_CATEGORIES.includes(value as FeedbackCategory) ? (value as FeedbackCategory) : "bug")}
data-ui-id="ui.feedback.category"
>
{FEEDBACK_CATEGORIES.map((key) => (
<Select.Item key={key} value={key}>
{t(`feedback.category.${key}`)}
</Select.Item>
))}
</Select>
<TextArea className="w-full max-w-none" label={t("feedback.message")} showLabel>
<TextArea.Input name="message" defaultValue="" rows={5} placeholder={t("feedback.placeholder")} required data-ui-id="ui.feedback.message" />
</TextArea>
<div className="flex w-full flex-col items-start gap-1">
<label
className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-primary"
htmlFor="feedback-attachment"
>
{t("feedback.attachment.label")}
</label>
<input
id="feedback-attachment"
type="file"
name="attachment"
accept={FEEDBACK_ATTACHMENT_ACCEPT}
onChange={onAttachmentChange}
data-ui-id="ui.feedback.attachment"
className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary w-full"
/>
{attachmentError ? (
<span className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-feedback-negative" role="alert">
{attachmentError}
</span>
) : (
<span className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary">
{t("feedback.attachment.hint", { megabytes: FEEDBACK_ATTACHMENT_MAX_MB })}
</span>
)}
</div>
<span className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary">
{t("feedback.rateLimitHint")}
</span>
</div>
<div className="flex w-full items-center justify-end gap-2 pt-4">
<Button type="button" variant="tertiary" disabled={submitting} onClick={onClose}>
{t("shared.cancel")}
</Button>
<Button type="submit" loading={submitting} disabled={Boolean(attachmentError)} data-ui-id="ui.feedback.send">
{t("feedback.send")}
</Button>
</div>
</fetcher.Form>
</Dialog.Content>
</Dialog>
);
}
@@ -19,7 +19,7 @@ export default function ChatSupportButton() {
$crisp?.push(["do", "chat:hide"]);
setIsOpen(false);
}
} catch (e) {
} catch (_e) {
// ignore
}
}
@@ -22,7 +22,7 @@ export default function CurrentSubscriptionButton() {
<div className="hidden divide-x divide-gray-300 rounded-sm shadow-none lg:inline-flex">
<div className="relative z-0 inline-flex rounded-full text-xs shadow-none sm:text-sm">
<Link
to={!params.tenant ? "" : appPath({ tenantSlug: params.tenant, path: "settings/subscription", mode: "host-aware" })}
to={!params.tenant ? "" : appPath({ tenantSlug: params.tenant, path: "settings/billing", mode: "host-aware" })}
className={clsx(
"text-muted-foreground bg-secondary border-border relative inline-flex items-center space-x-1 rounded-md border p-2 font-medium shadow-inner hover:bg-teal-50 hover:text-teal-800 focus:z-10 focus:bg-teal-100 focus:text-teal-900 focus:outline-hidden",
hasSubscription() &&
@@ -75,7 +75,7 @@ describe("layout button UI IDs", () => {
fireEvent.click(screen.getByLabelText("shell.profile.userMenu"));
expect(screen.getByRole("menuitem", { name: "app.navbar.profile" })).toHaveAttribute("href", "/acme/settings/profile");
expect(screen.getByRole("menuitem", { name: "app.navbar.subscription" })).toHaveAttribute("href", "/acme/settings/subscription");
expect(screen.getByRole("menuitem", { name: "app.navbar.subscription" })).toHaveAttribute("href", "/acme/settings/billing");
});
it("localizes the public admin menu link", () => {
@@ -12,4 +12,11 @@ describe("ProfileButton route fallbacks", () => {
expect(source).toContain('defaultTenantPath("settings/profile") ?? publicHeaderAdminPath("settings/profile")');
expect(source).not.toContain('defaultTenantPath("settings/profile") ?? adminShellPath("settings/profile")');
});
it("gives the tenant menu item additional vertical padding", () => {
const source = fs.readFileSync(path.resolve(process.cwd(), "apps/web/app/components/layouts/buttons/ProfileButton.tsx"), "utf8");
expect(source).toContain('className="hover:bg-secondary block px-4 py-3 text-sm transition duration-150 ease-in-out"');
expect(source).toContain('data-ui-id="ui.profile.menu.tenant"');
});
});
@@ -48,7 +48,7 @@ export default function ProfileButton({ user, layout, items }: Props) {
onClick={() => setOpened(!opened)}
data-ui-id={UI_ACTION_IDS.profile}
className={clsx(
"bg-background text-muted-foreground hover:bg-secondary border-border relative inline-flex items-center rounded-full border font-medium shadow-inner focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
"bg-background text-muted-foreground hover:bg-secondary border-border focus-visible:ring-ring relative inline-flex items-center rounded-full border font-medium shadow-inner focus-visible:z-10 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",
!user?.avatar && "p-2",
user?.avatar && "p-1"
)}
@@ -58,7 +58,9 @@ export default function ProfileButton({ user, layout, items }: Props) {
>
{(() => {
if (user?.avatar) {
return <img className="inline-flex h-8 w-8 items-center justify-center rounded-full bg-slate-800" src={user.avatar} alt={t("models.user.avatarAlt")} />;
return (
<img className="inline-flex h-8 w-8 items-center justify-center rounded-full bg-slate-800" src={user.avatar} alt={t("models.user.avatarAlt")} />
);
} else {
return (
<span className="inline-block h-5 w-5 overflow-hidden rounded-full">
@@ -81,7 +83,7 @@ export default function ProfileButton({ user, layout, items }: Props) {
leaveTo="transform opacity-0 scale-95"
>
<div className="divide-border border-border absolute right-0 z-40 mt-2 w-64 origin-top-right divide-y overflow-hidden rounded-sm border shadow-lg focus:outline-hidden">
<div className="shadow-2xs bg-background rounded-sm py-1" role="menu" aria-orientation="vertical" aria-labelledby="user-menu">
<div className="bg-background rounded-sm py-1 shadow-2xs" role="menu" aria-orientation="vertical" aria-labelledby="user-menu">
<div className="text-muted-foreground group flex items-center truncate px-4 py-2 text-sm transition duration-150 ease-in-out" role="menuitem">
<div className="flex flex-col space-y-1 truncate">
<div className="font-medium">{UserDisplayUtils.profileName(user)}</div>
@@ -106,7 +108,7 @@ export default function ProfileButton({ user, layout, items }: Props) {
className="hover:bg-secondary block px-4 py-2 text-sm transition duration-150 ease-in-out"
role="menuitem"
onClick={closeDropdownUser}
to={tenantPath("settings/members")}
to={tenantPath("settings/team")}
>
{t("app.navbar.members")}
</Link>
@@ -117,7 +119,7 @@ export default function ProfileButton({ user, layout, items }: Props) {
className="hover:bg-secondary block px-4 py-2 text-sm transition duration-150 ease-in-out"
role="menuitem"
onClick={closeDropdownUser}
to={tenantPath("settings/subscription")}
to={tenantPath("settings/billing")}
>
{t("app.navbar.subscription")}
</Link>
@@ -125,10 +127,11 @@ export default function ProfileButton({ user, layout, items }: Props) {
{getUserHasPermission(appOrAdminData, "app.settings.account.view") && (
<Link
className="hover:bg-secondary block px-4 py-2 text-sm transition duration-150 ease-in-out"
className="hover:bg-secondary block px-4 py-3 text-sm transition duration-150 ease-in-out"
data-ui-id="ui.profile.menu.tenant"
role="menuitem"
onClick={closeDropdownUser}
to={tenantPath("settings/account")}
to={tenantPath("settings/workspace")}
>
{t("app.navbar.tenant")}
</Link>
@@ -139,7 +142,7 @@ export default function ProfileButton({ user, layout, items }: Props) {
className="block px-4 py-2 text-sm transition duration-150 ease-in-out hover:bg-secondary"
role="menuitem"
onClick={closeDropdownUser}
to={tenantPath("settings/roles-and-permissions")}
to={tenantPath("settings/team/roles")}
>
{t("models.role.plural")}
</Link>
@@ -149,7 +152,7 @@ export default function ProfileButton({ user, layout, items }: Props) {
className="block px-4 py-2 text-sm transition duration-150 ease-in-out hover:bg-secondary"
role="menuitem"
onClick={closeDropdownUser}
to={tenantPath("settings/groups")}
to={tenantPath("settings/team/groups")}
>
{t("models.group.plural")}
</Link> */}
@@ -159,7 +162,7 @@ export default function ProfileButton({ user, layout, items }: Props) {
className="hover:bg-secondary block px-4 py-2 text-sm transition duration-150 ease-in-out"
role="menuitem"
onClick={closeDropdownUser}
to={tenantPath("settings/api")}
to={tenantPath("api")}
>
{t("models.apiKey.plural")}
</Link>
@@ -170,7 +173,7 @@ export default function ProfileButton({ user, layout, items }: Props) {
className="hover:bg-secondary block px-4 py-2 text-sm transition duration-150 ease-in-out"
role="menuitem"
onClick={closeDropdownUser}
to={tenantPath("settings/logs")}
to={tenantPath("settings/compliance")}
>
{t("models.log.plural")}
</Link>
@@ -209,12 +212,12 @@ export default function ProfileButton({ user, layout, items }: Props) {
{t("app.navbar.profile")}
</Link>
)}
{defaultTenantPath("settings/subscription") && (
{defaultTenantPath("settings/billing") && (
<Link
className="hover:bg-secondary block px-4 py-2 text-sm transition duration-150 ease-in-out"
role="menuitem"
onClick={closeDropdownUser}
to={defaultTenantPath("settings/subscription")!}
to={defaultTenantPath("settings/billing")!}
>
{t("app.navbar.subscription")}
</Link>