Update hivegrid-cloud reference to latest main
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e98d38e716
commit
7b21524c86
3781 files changed
+373484
-225607
No files matched your search
+25
-4
@@ -1,3 +1,4 @@
|
||||
import { useState } from "react";
|
||||
import { useParams } from "react-router";
|
||||
import { useAppOrAdminData } from "~/utils/data/useAppOrAdminData";
|
||||
import AddFeedbackButton from "./buttons/AddFeedbackButton";
|
||||
@@ -5,9 +6,10 @@ import ChatSupportButton from "./buttons/ChatSupportButton";
|
||||
import CurrentSubscriptionButton from "./buttons/CurrentSubscriptionButton";
|
||||
import OnboardingButton from "./buttons/OnboardingButton";
|
||||
import ProfileButton from "./buttons/ProfileButton";
|
||||
import QuickActionsButton from "./buttons/QuickActionsButton";
|
||||
import SearchButton from "./buttons/SearchButton";
|
||||
import NotificationsButton from "./buttons/NotificationsButton";
|
||||
import { NotificationsDrawer } from "~/components/screens/notifications/NotificationsDrawer";
|
||||
import { useNotificationsStream } from "~/components/notifications/useNotificationsStream";
|
||||
import { adminPath, appPath } from "~/utils/app/CanonicalUrlUtils";
|
||||
|
||||
export default function NavBar({
|
||||
@@ -24,7 +26,6 @@ export default function NavBar({
|
||||
mySubscription: boolean;
|
||||
feedback: boolean;
|
||||
chatSupport: boolean;
|
||||
quickActions: boolean;
|
||||
search: boolean;
|
||||
notifications: boolean;
|
||||
onboarding: boolean;
|
||||
@@ -38,6 +39,13 @@ export default function NavBar({
|
||||
const params = useParams();
|
||||
const notificationsPath =
|
||||
layout === "admin" ? adminPath("notifications", { mode: "host-aware" }) : params.tenant ? appPath({ tenantSlug: params.tenant, path: "notifications", mode: "host-aware" }) : "/notifications";
|
||||
// AK-P3 (AD-28): tenant-app bell opens the notifications drawer with a live
|
||||
// SSE unseen count; the stream route is tenant-scoped, so the admin layout
|
||||
// keeps the plain link (documented Dev-Nachzug in the ticket doc).
|
||||
const isTenantApp = layout === "app" && Boolean(params.tenant);
|
||||
const streamPath = isTenantApp && params.tenant ? appPath({ tenantSlug: params.tenant, path: "notifications/stream", mode: "host-aware" }) : null;
|
||||
const notificationsStream = useNotificationsStream(streamPath, []);
|
||||
const [notificationsDrawerOpen, setNotificationsDrawerOpen] = useState(false);
|
||||
return (
|
||||
<div className="flex flex-1 justify-between space-x-2">
|
||||
<div className="flex flex-1 items-center">{title && <div className="font-extrabold">{title}</div>}</div>
|
||||
@@ -53,11 +61,24 @@ export default function NavBar({
|
||||
)}
|
||||
{layout === "app" && buttons.mySubscription && <CurrentSubscriptionButton />}
|
||||
{/* <LocaleSelector /> */}
|
||||
{buttons.notifications && appOrAdminData?.user && <NotificationsButton to={notificationsPath} />}
|
||||
{buttons.notifications && appOrAdminData?.user && (
|
||||
<NotificationsButton
|
||||
to={notificationsPath}
|
||||
unseenCount={isTenantApp ? notificationsStream.unreadCount : undefined}
|
||||
onOpen={isTenantApp ? () => setNotificationsDrawerOpen(true) : undefined}
|
||||
/>
|
||||
)}
|
||||
{isTenantApp && (
|
||||
<NotificationsDrawer
|
||||
open={notificationsDrawerOpen}
|
||||
items={notificationsStream.items}
|
||||
allHref={notificationsPath}
|
||||
onClose={() => setNotificationsDrawerOpen(false)}
|
||||
/>
|
||||
)}
|
||||
{buttons.search && <SearchButton onClick={onOpenCommandPalette} />}
|
||||
{layout === "app" && buttons.feedback && <AddFeedbackButton />}
|
||||
{layout === "app" && buttons.chatSupport && <ChatSupportButton />}
|
||||
{layout === "app" && buttons.quickActions && <QuickActionsButton entities={appOrAdminData?.entities?.filter((f) => f.showInSidebar)} />}
|
||||
{/* {(layout === "app" || layout === "admin") && <ThemeSelector variant="secondary" />} */}
|
||||
{(layout === "app" || layout === "admin") && buttons.userProfile && <ProfileButton user={appOrAdminData?.user} layout={layout} />}
|
||||
{children}
|
||||
|
||||
+5
-5
@@ -2,8 +2,8 @@ import { useTranslation } from "react-i18next";
|
||||
import { useAppData } from "~/utils/data/useAppData";
|
||||
import { Link, useParams } from "react-router";
|
||||
import clsx from "~/utils/shared/ClassesUtils";
|
||||
import { subscriptionCheckoutPath } from "~/utils/app/SubscriptionUrlUtils";
|
||||
import { SparklesIcon } from "~/components/ui/icons/vendor";
|
||||
import { appPath } from "~/utils/app/CanonicalUrlUtils";
|
||||
import { CreditCard } from "~/components/ui/icons/vendor";
|
||||
|
||||
export default function CurrentSubscriptionButton() {
|
||||
const params = useParams();
|
||||
@@ -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 ? "" : subscriptionCheckoutPath(params.tenant)}
|
||||
to={!params.tenant ? "" : appPath({ tenantSlug: params.tenant, path: "settings/subscription", 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() &&
|
||||
@@ -40,10 +40,10 @@ export default function CurrentSubscriptionButton() {
|
||||
</div>
|
||||
) : (
|
||||
<div>
|
||||
<span>{t("pricing.subscribe")} </span>
|
||||
<span>{t("app.navbar.subscription")} </span>
|
||||
</div>
|
||||
)}
|
||||
<SparklesIcon className="h-4 w-4" />
|
||||
<CreditCard className="h-4 w-4" />
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+42
-42
@@ -6,55 +6,55 @@ import { BellIcon } from "~/components/ui/icons/vendor";
|
||||
interface Props {
|
||||
unseenCount?: number;
|
||||
to: string;
|
||||
/**
|
||||
* AK-P3 (AD-28): when provided the bell opens the notifications drawer
|
||||
* instead of navigating; the tenant NavBar wires this together with the
|
||||
* live SSE unseen count. Hosts without a drawer (admin) keep the link.
|
||||
*/
|
||||
onOpen?: () => void;
|
||||
}
|
||||
export default function NotificationsButton({ unseenCount, to }: Props) {
|
||||
|
||||
export default function NotificationsButton({ unseenCount, to, onOpen }: Props) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const className = clsx(
|
||||
"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-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"
|
||||
);
|
||||
|
||||
const content = (
|
||||
<>
|
||||
<span className="relative inline-block h-5 w-5 overflow-hidden rounded-full">
|
||||
<BellIcon className="h-5 w-5" />
|
||||
</span>
|
||||
{typeof unseenCount === "number" && unseenCount > 0 && (
|
||||
<span className="absolute inset-0 -mr-6 object-right-top" data-ui-id="ui.notifications.bell.count">
|
||||
<div className="inline-flex items-center rounded-full border-2 border-white bg-red-500 px-1.5 py-0.5 text-xs font-semibold leading-4 text-white">
|
||||
{unseenCount}
|
||||
</div>
|
||||
</span>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="relative">
|
||||
<div className="inline-flex divide-x divide-gray-300 rounded-sm shadow-none">
|
||||
<a
|
||||
href={to}
|
||||
data-ui-id={UI_ACTION_IDS.notifications}
|
||||
aria-label={t("shell.notifications.ariaLabel")}
|
||||
className={clsx(
|
||||
"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-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"
|
||||
)}
|
||||
>
|
||||
<span className="relative inline-block h-5 w-5 overflow-hidden rounded-full">
|
||||
<BellIcon className="h-5 w-5" />
|
||||
</span>
|
||||
{unseenCount?.toString() !== "0" && (
|
||||
<span className="absolute inset-0 -mr-6 object-right-top">
|
||||
<div className="inline-flex items-center rounded-full border-2 border-white bg-red-500 px-1.5 py-0.5 text-xs font-semibold leading-4 text-white">
|
||||
{unseenCount}
|
||||
</div>
|
||||
</span>
|
||||
)}
|
||||
</a>
|
||||
{onOpen ? (
|
||||
<button
|
||||
type="button"
|
||||
onClick={onOpen}
|
||||
data-ui-id={UI_ACTION_IDS.notifications}
|
||||
aria-label={t("shell.notifications.ariaLabel")}
|
||||
className={className}
|
||||
>
|
||||
{content}
|
||||
</button>
|
||||
) : (
|
||||
<a href={to} data-ui-id={UI_ACTION_IDS.notifications} aria-label={t("shell.notifications.ariaLabel")} className={className}>
|
||||
{content}
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
// <div className="w-full flex md:ml-0">
|
||||
// <div className="align-baseline w-full text-slate-200 pl-1">
|
||||
// <div className="w-full">
|
||||
// <label htmlFor="command-palette" className="sr-only">
|
||||
// {t("shared.commandPalette")}
|
||||
// </label>
|
||||
// <div className="relative text-muted-foreground hover:text-muted-foreground truncate">
|
||||
|
||||
// <button
|
||||
// type="button"
|
||||
// onClick={onOpenCommandPalette}
|
||||
// className="flex space-x-2 text-left w-full pl-3 pr-3 py-1.5 text-sm sm:py-2 border border-border rounded-md leading-5 bg-secondary text-muted-foreground focus:outline-hidden hover:ring-0 hover:placeholder-gray-500 hover:text-muted-foreground truncate"
|
||||
// >
|
||||
// <div className="font-medium hidden lg:block">⌘K</div>
|
||||
// <div className="hidden lg:block truncate">{t("shared.commandPalette")}</div>
|
||||
// <div className="lg:hidden">{t("shared.search")}</div>
|
||||
// </button>
|
||||
// </div>
|
||||
// </div>
|
||||
// </div>
|
||||
// </div>
|
||||
}
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { quickActionEntityPath } from "./QuickActionsButton";
|
||||
|
||||
describe("quickActionEntityPath", () => {
|
||||
it("keeps create links inside the active group route", () => {
|
||||
expect(quickActionEntityPath({ tenant: "acme", group: "sales" }, "contacts")).toBe("/acme/g/sales/contacts/new");
|
||||
});
|
||||
|
||||
it("uses the tenant entity route outside groups", () => {
|
||||
expect(quickActionEntityPath({ tenant: "acme" }, "contacts")).toBe("/acme/contacts/new");
|
||||
});
|
||||
});
|
||||
-90
@@ -1,90 +0,0 @@
|
||||
import { Link, useParams } from "react-router";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Transition } from "@headlessui/react";
|
||||
import { Fragment, useState } from "react";
|
||||
import { useOuterClick } from "~/utils/shared/KeypressUtils";
|
||||
import { useAppData } from "~/utils/data/useAppData";
|
||||
import UrlUtils from "~/utils/app/UrlUtils";
|
||||
import { EntitySimple } from "~/utils/db/entities/entities.db.server";
|
||||
import { getEntityPermission, getUserHasPermission } from "~/utils/helpers/PermissionsHelper";
|
||||
import { PlusIcon } from "~/components/ui/icons/vendor";
|
||||
|
||||
interface Props {
|
||||
entities: EntitySimple[];
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export function quickActionEntityPath(params: { tenant?: string; group?: string }, entitySlug: string) {
|
||||
const path = params.group ? `g/${params.group}/${entitySlug}/new` : `${entitySlug}/new`;
|
||||
return UrlUtils.currentTenantUrl(params, path);
|
||||
}
|
||||
|
||||
export default function QuickActionsButton({ entities, className }: Props) {
|
||||
const { t } = useTranslation();
|
||||
const params = useParams();
|
||||
const appData = useAppData();
|
||||
|
||||
const [opened, setOpened] = useState(false);
|
||||
const creatableEntities = entities.filter((entity) => getUserHasPermission(appData, getEntityPermission(entity, "create")));
|
||||
const hasQuickActions = creatableEntities.length > 0;
|
||||
|
||||
const clickOutside = useOuterClick(() => setOpened(false));
|
||||
return (
|
||||
<span className={className} ref={clickOutside}>
|
||||
{hasQuickActions && (
|
||||
<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={() => setOpened(!opened)}
|
||||
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("shared.new")}
|
||||
>
|
||||
<span className="sr-only">{t("shared.new")}</span>
|
||||
<PlusIcon className="h-5 w-5" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Transition
|
||||
as={Fragment}
|
||||
show={opened}
|
||||
enter="transition ease-out duration-100"
|
||||
enterFrom="transform opacity-0 scale-95"
|
||||
enterTo="transform opacity-100 scale-100"
|
||||
leave="transition ease-in duration-75"
|
||||
leaveFrom="transform opacity-100 scale-100"
|
||||
leaveTo="transform opacity-0 scale-95"
|
||||
>
|
||||
<ul
|
||||
className="divide-border bg-background absolute right-0 z-40 mt-2 w-72 origin-top-right divide-y overflow-hidden rounded-sm shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-hidden"
|
||||
tabIndex={-1}
|
||||
aria-labelledby="listbox-label"
|
||||
>
|
||||
{creatableEntities.map((entity) => {
|
||||
return (
|
||||
<li key={entity.name} className="text-foreground relative cursor-default select-none text-sm" id="listbox-option-0">
|
||||
<Link
|
||||
to={quickActionEntityPath(params, entity.slug)}
|
||||
onClick={() => setOpened(false)}
|
||||
className="hover:bg-secondary flex flex-col p-4"
|
||||
>
|
||||
<div className="flex justify-between">
|
||||
<p className="font-semibold">
|
||||
{t("shared.new")} {t(entity.title)}
|
||||
</p>
|
||||
</div>
|
||||
</Link>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
</Transition>
|
||||
</div>
|
||||
)}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
-2
@@ -175,8 +175,6 @@ export function ShadcnAppSidebar({
|
||||
t,
|
||||
i18n,
|
||||
tenantId: params.tenant ?? "",
|
||||
entities: appOrAdminData?.entities ?? [],
|
||||
entityGroups: appOrAdminData?.entityGroups ?? [],
|
||||
appConfiguration: rootData.appConfiguration,
|
||||
routing: rootData.routing,
|
||||
productAccess: appOrAdminData?.productAccess,
|
||||
|
||||
+1
-27
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import * as React from "react";
|
||||
import { CreditCard, LogOut, MoreHorizontal, GearIcon, SparklesIcon, SearchIcon, MessageCircleIcon } from "~/components/ui/icons/vendor";
|
||||
import { CreditCard, LogOut, MoreHorizontal, GearIcon, SearchIcon, MessageCircleIcon } from "~/components/ui/icons/vendor";
|
||||
|
||||
import { Button } from "~/components/ui/button";
|
||||
import { Popover, PopoverContent, PopoverTrigger } from "~/components/ui/popover";
|
||||
@@ -15,13 +15,11 @@ import { useTranslation } from "react-i18next";
|
||||
import { adminPath, appPath } from "~/utils/app/CanonicalUrlUtils";
|
||||
import Modal from "~/components/ui/modals/Modal";
|
||||
import StarsIconFilled from "~/components/ui/icons/StarsIconFilled";
|
||||
import { useAppData } from "~/utils/data/useAppData";
|
||||
import OnboardingButton from "../../buttons/OnboardingButton";
|
||||
import { toast } from "sonner";
|
||||
import ButtonPrimary from "~/components/ui/buttons/ButtonPrimary";
|
||||
import { Textarea } from "~/components/ui/textarea";
|
||||
import { UI_ACTION_IDS, UI_SURFACE_IDS } from "~/application/ui/uiRegistry";
|
||||
import { subscriptionCheckoutPath } from "~/utils/app/SubscriptionUrlUtils";
|
||||
import NotificationsButton from "../../buttons/NotificationsButton";
|
||||
|
||||
const headerIconButtonClass = "size-10 shrink-0 text-muted-foreground";
|
||||
@@ -39,7 +37,6 @@ export function NavActions({
|
||||
// const title = useTitleData() ?? "";
|
||||
|
||||
const appOrAdminData = useAppOrAdminData();
|
||||
const appData = useAppData();
|
||||
const rootData = useRootData();
|
||||
const appConfiguration = rootData.appConfiguration;
|
||||
const params = useParams();
|
||||
@@ -49,11 +46,6 @@ export function NavActions({
|
||||
|
||||
const [isOpen, setIsOpen] = React.useState(false);
|
||||
|
||||
function hasSubscription() {
|
||||
const myProducts = appData?.mySubscription?.products.map((f) => t(f.subscriptionProduct.title)) ?? [];
|
||||
return myProducts.length > 0;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-w-0 max-w-full overflow-hidden text-sm">
|
||||
{false && (
|
||||
@@ -64,7 +56,6 @@ export function NavActions({
|
||||
mySubscription: getUserHasPermission(appOrAdminData, "app.settings.subscription.update"),
|
||||
feedback: rootData.appConfiguration.app.features.tenantFeedback,
|
||||
chatSupport: !!rootData.chatWebsiteId,
|
||||
quickActions: appOrAdminData?.entities?.filter((f) => f.showInSidebar).length > 0,
|
||||
search: true,
|
||||
notifications: appConfiguration.notifications.enabled && (layout === "admin" || layout === "app"),
|
||||
onboarding: appConfiguration.onboarding.enabled,
|
||||
@@ -82,20 +73,6 @@ export function NavActions({
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* NavBar Button: My Subscription */}
|
||||
{layout === "app" && getUserHasPermission(appOrAdminData, "app.settings.subscription.update") && (
|
||||
<React.Fragment>
|
||||
{!hasSubscription() && (
|
||||
<a href={subscriptionCheckoutPath(params.tenant ?? "")}>
|
||||
<Button variant="outline" size="sm" data-ui-id={UI_ACTION_IDS.subscription}>
|
||||
<span>{t("pricing.subscribe")} </span>
|
||||
<SparklesIcon className="ml-2 h-4 w-4" />
|
||||
</Button>
|
||||
</a>
|
||||
)}
|
||||
</React.Fragment>
|
||||
)}
|
||||
|
||||
{/* NavBar Button: Notifications */}
|
||||
{appConfiguration.notifications.enabled && (layout === "admin" || layout === "app") && appOrAdminData?.user && (
|
||||
<div className="text-foreground/70 px-2 py-0.5">
|
||||
@@ -147,9 +124,6 @@ export function NavActions({
|
||||
{/* NavBar Button: Theme Selector */}
|
||||
{/* {rootData.debug && <ThemeSelector variant="secondary" />} */}
|
||||
|
||||
{/* NavBar Button: Quick Actions */}
|
||||
{/* {layout === "app" && <QuickActionsButton entities={appOrAdminData?.entities?.filter((f) => f.showInSidebar)} />} */}
|
||||
|
||||
{/* NavBar Button: More */}
|
||||
<Popover open={isOpen} onOpenChange={setIsOpen}>
|
||||
<PopoverTrigger asChild>
|
||||
|
||||
Reference in new issue
Block a user