@rebasepro/cms 0.26.0 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/collection_editor/serializable_utils.js +5 -2
- package/dist/collection_editor/serializable_utils.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/EnumForm.d.ts +17 -0
- package/dist/collection_editor/ui/collection_editor/EnumForm.js +31 -17
- package/dist/collection_editor/ui/collection_editor/EnumForm.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/EnumPropertyField.js +6 -5
- package/dist/collection_editor/ui/collection_editor/properties/EnumPropertyField.js.map +1 -1
- package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js +3 -2
- package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.js +32 -16
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.js.map +1 -1
- package/dist/components/DefaultDrawer.js +3 -2
- package/dist/components/DefaultDrawer.js.map +1 -1
- package/dist/components/DetailViewBinding.js +4 -3
- package/dist/components/DetailViewBinding.js.map +1 -1
- package/dist/components/EditViewBinding.js +23 -5
- package/dist/components/EditViewBinding.js.map +1 -1
- package/dist/components/EntityPreviewBinding.js +1 -0
- package/dist/components/EntityPreviewBinding.js.map +1 -1
- package/dist/components/HomePage/ContentHomePage.js +3 -2
- package/dist/components/HomePage/ContentHomePage.js.map +1 -1
- package/dist/components/SelectableTable/filters/StringNumberFilterField.js +3 -3
- package/dist/components/SelectableTable/filters/StringNumberFilterField.js.map +1 -1
- package/dist/components/SidePanelBinding.js +7 -6
- package/dist/components/SidePanelBinding.js.map +1 -1
- package/dist/components/app/Scaffold.js +16 -1
- package/dist/components/app/Scaffold.js.map +1 -1
- package/dist/components/history/EntityHistoryView.js +2 -1
- package/dist/components/history/EntityHistoryView.js.map +1 -1
- package/dist/data_export/export/export.js +3 -3
- package/dist/data_export/export/export.js.map +1 -1
- package/dist/data_import/import/ImportCollectionAction.js +10 -12
- package/dist/data_import/import/ImportCollectionAction.js.map +1 -1
- package/dist/data_import/utils/id_column.d.ts +19 -0
- package/dist/data_import/utils/id_column.js +19 -1
- package/dist/data_import/utils/id_column.js.map +1 -1
- package/dist/data_import/utils/transforms.js +24 -7
- package/dist/data_import/utils/transforms.js.map +1 -1
- package/dist/form/EntityForm.d.ts +1 -1
- package/dist/form/EntityForm.js +14 -4
- package/dist/form/EntityForm.js.map +1 -1
- package/dist/form/EntityFormBinding.js +12 -8
- package/dist/form/EntityFormBinding.js.map +1 -1
- package/dist/form/components/FieldBlock.js +2 -1
- package/dist/form/components/FieldBlock.js.map +1 -1
- package/dist/form/field_bindings/KeyValueFieldBinding.js +3 -1
- package/dist/form/field_bindings/KeyValueFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/ReadOnlyFieldBinding.js +0 -2
- package/dist/form/field_bindings/ReadOnlyFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/TextFieldBinding.js +3 -2
- package/dist/form/field_bindings/TextFieldBinding.js.map +1 -1
- package/dist/form/validation.js +12 -1
- package/dist/form/validation.js.map +1 -1
- package/dist/hooks/navigation/url_segments.d.ts +33 -0
- package/dist/hooks/navigation/url_segments.js +56 -0
- package/dist/hooks/navigation/url_segments.js.map +1 -0
- package/dist/hooks/navigation/useBuildUrlController.js +4 -2
- package/dist/hooks/navigation/useBuildUrlController.js.map +1 -1
- package/dist/hooks/useBuildSidePanel.js +6 -5
- package/dist/hooks/useBuildSidePanel.js.map +1 -1
- package/dist/hooks/useHistory.js +4 -3
- package/dist/hooks/useHistory.js.map +1 -1
- package/dist/routes/RebaseRoute.js +20 -30
- package/dist/routes/RebaseRoute.js.map +1 -1
- package/dist/util/navigation_utils.js +4 -3
- package/dist/util/navigation_utils.js.map +1 -1
- package/package.json +9 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultDrawer.js","names":[],"sources":["../../src/components/DefaultDrawer.tsx"],"sourcesContent":["import type { NavigationEntry, NavigationResult } from \"@rebasepro/cms-types\";\nimport React, { useCallback, useMemo } from \"react\";\n\nimport { useCollapsedGroups, buildCollapsedDefaults, useLargeLayout, useAdminModeController, useAuthController, useModeController, useTranslation, useSlot, useRebaseContext, useAnalyticsController, useRebaseRegistry, useComponentOverride } from \"@rebasepro/app\";\nimport type { AdminModeController } from \"@rebasepro/app\";\nimport { useUrlController } from \"../hooks/navigation/contexts/UrlContext\";\nimport { useNavigationStateController } from \"../hooks/navigation/contexts/NavigationStateContext\";\n\n\nimport { Link, useNavigate } from \"react-router\";\nimport { AnalyticsEvent } from \"@rebasepro/cms-types\";\nimport {\n Avatar,\n ChevronsLeftIcon,\n ChevronsRightIcon,\n cls,\n iconSize,\n IconButton,\n LanguagesIcon,\n LogOutIcon,\n Menu,\n MenuItem,\n MoonIcon,\n Separator,\n SettingsIcon,\n Skeleton,\n SunIcon,\n SunMoonIcon,\n ToggleButtonGroup,\n Tooltip,\n Typography\n} from \"@rebasepro/ui\";\nimport { DrawerNavigationGroup } from \"./DrawerNavigationGroup\";\nimport { DrawerExpansionContext, useDrawerExpansion } from \"./drawer_expansion\";\nimport { LanguageToggle, RebaseLogo, RlsSimulatorBar, useCanSimulateAccess } from \"@rebasepro/app\";\nimport { useApp } from \"./app/useApp\";\n\n/**\n * Default drawer used in the admin.\n *\n * When no `children` are provided, renders the full admin navigation\n * (collection groups, mode switch, plugin slots).\n *\n * When `children` **are** provided, renders the shared drawer shell\n * (logo, scrollable area, footer actions, collapse toggle) with the\n * custom content injected in the scrollable area. This lets consumers\n * like the SaaS dashboard reuse the identical structural layout while\n * supplying their own navigation items.\n *\n * @group Core\n */\nexport function DefaultDrawer({\n title,\n logo,\n logoDestination,\n children,\n footerActions,\n className,\n style\n}: {\n title?: React.ReactNode;\n logo?: string;\n logoDestination?: string;\n /**\n * Custom navigation content for the drawer.\n * When provided, replaces the default admin navigation (collection groups,\n * mode switch, slots). The shared shell (logo, scroll area, footer\n * actions, collapse toggle) is still rendered around it.\n */\n children?: React.ReactNode;\n /**\n * Custom content for the drawer footer actions area (language, theme, user menu).\n * - `undefined` — renders the default `DrawerFooterActions`.\n * - `null` — renders nothing (hides the footer actions).\n * - `ReactNode` — renders the provided custom content.\n */\n footerActions?: React.ReactNode | null;\n className?: string;\n style?: React.CSSProperties;\n}) {\n\n const {\n drawerHovered,\n drawerOpen,\n openDrawer,\n closeDrawer,\n logo: appLogo\n } = useApp();\n\n const resolvedLogo = logo ?? appLogo;\n\n const scrollRef = React.useRef<HTMLDivElement>(null);\n const [scrolled, setScrolled] = React.useState(false);\n\n // Open, pinned or floating under the pointer. The rows read it from the\n // `data-expanded` attribute (through CSS) and the expansion store, not as a\n // prop, so the rail opening under the pointer re-renders none of them.\n const expanded = drawerOpen || drawerHovered;\n const expansion = useDrawerExpansion(expanded);\n\n const handleScroll = () => {\n if (scrollRef.current) {\n setScrolled(scrollRef.current.scrollTop > 0);\n }\n };\n\n return (\n <div role=\"navigation\" aria-label=\"Main navigation\"\n data-expanded={expanded}\n className={cls(\"group/drawer flex flex-col h-full relative grow w-full\", className)} style={style}>\n\n <DrawerLogo\n logo={resolvedLogo}\n title={title}\n logoDestination={logoDestination}\n drawerOpen={drawerOpen}\n drawerHovered={drawerHovered}\n />\n\n <div\n ref={scrollRef}\n onScroll={handleScroll}\n className={\"flex-grow min-h-0 overflow-y-auto overflow-x-hidden no-scrollbar px-2\"}\n style={{\n maskImage: scrolled\n ? \"linear-gradient(to bottom, transparent 0, black 20px, black calc(100% - 20px), transparent 100%)\"\n : \"linear-gradient(to bottom, black 0, black calc(100% - 20px), transparent 100%)\"\n }}>\n <DrawerExpansionContext.Provider value={expansion}>\n {children ?? <AdminNavigationContent />}\n </DrawerExpansionContext.Provider>\n </div>\n\n {footerActions !== null && (\n footerActions !== undefined\n ? footerActions\n : <DrawerFooterActions\n drawerOpen={drawerOpen}\n drawerHovered={drawerHovered}\n />\n )}\n\n <DrawerToggle\n drawerOpen={drawerOpen}\n drawerHovered={drawerHovered}\n openDrawer={openDrawer}\n closeDrawer={closeDrawer}\n />\n </div>\n );\n}\n\n/**\n * Default admin navigation content — rendered inside DefaultDrawer when no\n * custom `children` are provided. Contains the mode switch, navigation\n * groups, and header / footer plugin slots.\n */\nfunction AdminNavigationContent() {\n\n const {\n drawerHovered,\n drawerOpen,\n closeDrawer,\n closeHover\n } = useApp();\n\n const analyticsController = useAnalyticsController();\n const navigationState = useNavigationStateController();\n const context = useRebaseContext();\n\n const largeLayout = useLargeLayout();\n const adminModeController = useAdminModeController();\n const registry = useRebaseRegistry();\n const ResolvedDrawerNavigationGroup = useComponentOverride(\"Shell.DrawerNavigationGroup\", DrawerNavigationGroup);\n\n const allNavigationEntries = navigationState.topLevelNavigation?.navigationEntries ?? [];\n\n // Build a set of Studio-only dev view slugs so we can distinguish them from\n // admin custom views added via <RebaseCMS views={...}> or plugins.\n const studioViewSlugs = useMemo(() => {\n const slugs = new Set<string>();\n (registry.studioConfig?.devViews ?? []).forEach(v => slugs.add(v.slug));\n // The schema view is also a Studio dev view (auto-injected when collectionEditor is enabled)\n if (registry.studioConfig && registry.cmsConfig?.collectionEditor) slugs.add(\"schema\");\n return slugs;\n }, [registry.studioConfig, registry.cmsConfig?.collectionEditor]);\n\n // Studio mode shows Studio dev views + admin entries (Users/Roles).\n // Content mode shows collections, admin custom views, and admin entries — but not Studio dev views.\n const filteredEntries = adminModeController.mode === \"studio\"\n ? allNavigationEntries.filter(e => (e.type === \"view\" && studioViewSlugs.has(e.slug)) || e.type === \"admin\")\n : allNavigationEntries.filter(e => e.type !== \"view\" || !studioViewSlugs.has(e.slug));\n\n // Derive groups from the filtered entries, preserving the order from topLevelNavigation.groups\n const entryGroups = new Set(filteredEntries.map(e => e.group).filter(Boolean));\n const orderedGroups = navigationState.topLevelNavigation?.groups ?? [];\n const groupsToRender = [\n ...orderedGroups.filter(g => entryGroups.has(g)),\n ...[...entryGroups].filter(g => !orderedGroups.includes(g))\n ];\n\n // Group header icons, declared on `navigationGroupMappings`. Keyed by name\n // because that is what a navigation entry's `group` holds.\n const groupIcons = useMemo(() => {\n const icons = new Map<string, string>();\n (registry.cmsConfig?.navigationGroupMappings ?? []).forEach(mapping => {\n if (mapping.icon) icons.set(mapping.name, mapping.icon);\n });\n return icons;\n }, [registry.cmsConfig?.navigationGroupMappings]);\n\n // Collapsible groups state - using \"drawer\" namespace for independent state from home page\n const collapsedDefaults = useMemo(\n () => buildCollapsedDefaults(registry.cmsConfig?.navigationGroupMappings, \"drawer\"),\n [registry.cmsConfig?.navigationGroupMappings]\n );\n const { isGroupCollapsed, toggleGroupCollapsed } = useCollapsedGroups(groupsToRender, \"drawer\", collapsedDefaults);\n\n const headerSlot = useSlot(\"navigation.header\", { drawerOpen,\ndrawerHovered,\ncontext });\n const footerSlot = useSlot(\"navigation.footer\", { drawerOpen,\ndrawerHovered,\ncontext });\n\n // The same handler across a hover: every row is handed it.\n const onItemClick = useCallback((view: NavigationEntry) => {\n const eventName: AnalyticsEvent = view.type === \"collection\"\n ? \"drawer_navigate_to_collection\"\n : (view.type === \"view\" ? \"drawer_navigate_to_view\" : \"unmapped_event\");\n analyticsController.onAnalyticsEvent?.(eventName, { url: view.url });\n if (!largeLayout) {\n closeDrawer();\n } else if (!drawerOpen) {\n closeHover();\n }\n }, [analyticsController, largeLayout, drawerOpen, closeDrawer, closeHover]);\n\n if (!navigationState.topLevelNavigation)\n return null;\n\n const drawerVisuallyOpen = drawerOpen || drawerHovered;\n\n return (\n <>\n {registry.studioConfig && (\n <DrawerModeSwitch\n drawerOpen={drawerOpen}\n drawerHovered={drawerHovered}\n />\n )}\n\n {headerSlot}\n\n {groupsToRender.map((group) => {\n const entriesInGroup = filteredEntries.filter(e => e.group === group);\n return (\n <ResolvedDrawerNavigationGroup\n key={`drawer_group_${group}`}\n group={group}\n entries={entriesInGroup}\n collapsed={isGroupCollapsed(group)}\n onToggleCollapsed={() => toggleGroupCollapsed(group)}\n drawerOpen={drawerVisuallyOpen}\n onItemClick={onItemClick}\n icon={groupIcons.get(group)}\n />\n );\n })}\n\n {footerSlot}\n </>\n );\n}\n\nexport function DrawerLogo({\n logo,\n title,\n logoDestination = \"/\",\n drawerOpen,\n drawerHovered\n}: {\n logo?: string;\n title?: React.ReactNode;\n logoDestination?: string;\n drawerOpen: boolean;\n drawerHovered: boolean;\n}) {\n\n const showFullContent = drawerOpen || drawerHovered;\n const { t } = useTranslation();\n\n return (\n <div className=\"flex flex-row items-center shrink-0 pt-4 pb-0 px-2\">\n {/* Logo — always visible */}\n {/* Named explicitly because neither branch below carries text: the\n stock `RebaseLogo` is a bare <svg> with no <title>, and a custom\n `logo` only ever gets the generic alt \"Logo\", which names the image\n rather than saying where the link goes. The title link beside it is\n no help either — it renders only when a `title` is set. */}\n <Link\n className=\"shrink-0 flex items-center justify-center w-[56px] h-[40px]\"\n to={logoDestination}\n aria-label={t(\"home\", { defaultValue: \"Home\" })}\n >\n {logo\n ? <img src={logo} alt=\"Logo\" className=\"w-[28px] h-[28px] object-contain\"/>\n : <RebaseLogo width=\"28px\" height=\"28px\"/>\n }\n </Link>\n\n {/* Title (fades in when expanded or hovered) */}\n <div\n className={cls(\n \"flex flex-row items-center overflow-hidden transition-all duration-200 ease-in-out\",\n showFullContent ? \"opacity-100 w-full ml-1\" : \"opacity-0 w-0 ml-0\"\n )}\n >\n {title && (\n <Link\n className=\"visited:text-inherit dark:visited:text-inherit block truncate\"\n to={logoDestination}\n >\n {typeof title === \"string\"\n ? <Typography variant=\"subtitle1\" noWrap className=\"truncate\">{title}</Typography>\n : title\n }\n </Link>\n )}\n </div>\n </div>\n );\n}\n\n/**\n * Toggle button at the bottom of the drawer.\n * Uses double-chevron icons to indicate collapse/expand direction.\n */\nexport function DrawerToggle({\n drawerOpen,\n drawerHovered,\n openDrawer,\n closeDrawer\n}: {\n drawerOpen: boolean;\n drawerHovered: boolean;\n openDrawer: () => void;\n closeDrawer: () => void;\n}) {\n const isExpanded = drawerOpen;\n const isHovered = drawerHovered && !drawerOpen;\n const showFullContent = isExpanded || isHovered;\n\n const [wantsTooltip, setWantsTooltip] = React.useState(false);\n // See {@link DrawerNavigationItem}: a masked tooltip never hears the pointer\n // leave, so the stale state is dropped as the mask goes on.\n if (showFullContent && wantsTooltip) setWantsTooltip(false);\n\n const { t } = useTranslation();\n\n return (\n <div className=\"shrink-0 mt-auto px-4 pt-0.5 pb-2\">\n <Tooltip\n title={isExpanded ? t(\"collapse\") : t(\"expand\")}\n // The row spells out \"Collapse\"/\"Expand\" itself whenever it is wide\n // enough to show the label — expanded, or floating open under the\n // pointer. A tooltip repeating that word is noise; it earns its\n // place only on a bare rail, where the chevron stands alone.\n //\n // Masked, not withheld: see {@link DrawerNavigationItem} for why\n // this stays controlled in both states.\n open={!showFullContent && wantsTooltip}\n onOpenChange={setWantsTooltip}\n side=\"right\"\n sideOffset={12}\n asChild={true}\n >\n <button\n type=\"button\"\n className={cls(\n \"flex flex-row items-center rounded-lg cursor-pointer w-full\",\n \"hover:bg-surface-hover\",\n \"transition-colors duration-150\",\n \"py-2\"\n )}\n aria-expanded={isExpanded}\n aria-label={isExpanded ? t(\"collapse\") : t(\"expand\")}\n onClick={() => isExpanded ? closeDrawer() : openDrawer()}\n >\n {/* 44px in both states, on the same grid as the rows above and\n for the same reason: the rail floats open under the pointer,\n and a slot that changed width with it walked the chevron\n sideways on hover. See the note in DrawerNavigationItem. */}\n <div className=\"shrink-0 flex items-center justify-center w-[44px] h-[24px] text-surface-500 dark:text-surface-400\">\n {isExpanded\n ? <ChevronsLeftIcon size={iconSize.small}/>\n : <ChevronsRightIcon size={iconSize.small}/>\n }\n </div>\n <div className={cls(\n \"overflow-hidden transition-all duration-200 ease-in-out\",\n showFullContent ? \"opacity-100 w-auto\" : \"opacity-0 w-0\"\n )}>\n <Typography\n variant=\"body2\"\n className=\"text-surface-500 dark:text-surface-400 select-none whitespace-nowrap\"\n >\n {isExpanded ? t(\"collapse\") : t(\"expand\")}\n </Typography>\n </div>\n </button>\n </Tooltip>\n </div>\n );\n}\n\n/**\n * Segmented Content / Studio switch rendered inside the drawer.\n * Animates in/out with the drawer open state via opacity + max-height.\n */\nfunction DrawerModeSwitch({\n drawerOpen,\n drawerHovered\n}: {\n drawerOpen: boolean;\n drawerHovered: boolean;\n}) {\n const adminModeController = useAdminModeController();\n const urlController = useUrlController();\n const navigate = useNavigate();\n const { t } = useTranslation();\n const showSwitch = drawerOpen || drawerHovered;\n\n return (\n <div\n // Hidden by opacity so it can fade with the rail; `inert` takes it\n // out of the tab order and the accessibility tree while it is.\n inert={!showSwitch}\n className={cls(\n \"shrink-0 overflow-hidden transition-all duration-200 ease-in-out px-3 h-8 mt-2 mb-0\",\n showSwitch ? \"opacity-100\" : \"opacity-0 pointer-events-none\"\n )}\n >\n <ToggleButtonGroup<AdminModeController[\"mode\"]>\n fullWidth\n aria-label={t(\"panel_mode\")}\n value={adminModeController.mode}\n onValueChange={(mode) => {\n adminModeController.setMode(mode);\n if (mode === \"cms\") navigate(urlController.basePath ?? \"/\");\n else navigate(urlController.basePath === \"/\" ? \"/s\" : `${urlController.basePath ?? \"\"}/s`);\n }}\n options={[\n { value: \"cms\", label: \"CMS\" },\n { value: \"studio\", label: \"Studio\" }\n ]}\n />\n </div>\n );\n}\n\n/**\n * Footer actions rendered at the bottom of the drawer, above the collapse/expand toggle.\n * Replaces the app bar icons (language, theme, user avatar) with a drawer-native layout\n * that adapts between collapsed (icons only) and expanded (full labels + user bar) states.\n *\n * @group Core\n */\nexport function DrawerFooterActions({\n drawerOpen,\n drawerHovered,\n /**\n * Custom content to render inside the user dropdown menu.\n * When provided, these items are appended after the user info header\n * and before the default Sign Out item.\n */\n dropDownActions,\n /**\n * Override the user object displayed in the footer.\n * When omitted, falls back to `authController.user`.\n */\n user: userProp\n}: {\n drawerOpen: boolean;\n drawerHovered: boolean;\n dropDownActions?: React.ReactNode;\n user?: import(\"@rebasepro/types\").User;\n}) {\n const authController = useAuthController();\n const {\n mode,\n setMode\n } = useModeController();\n const navigate = useNavigate();\n const { t } = useTranslation();\n\n const user = userProp ?? authController.user;\n const showFullContent = drawerOpen || drawerHovered;\n const isFloating = drawerHovered && !drawerOpen;\n const portalRef = React.useRef<HTMLDivElement>(null);\n const canSimulateAccess = useCanSimulateAccess();\n\n // User avatar\n let avatarComponent: React.ReactElement | null;\n if (user) {\n const initial = user?.displayName\n ? user.displayName[0].toUpperCase()\n : (user?.email ? user.email[0].toUpperCase() : \"A\");\n avatarComponent = <Avatar src={user.photoURL ?? undefined} className=\"w-8 h-8 text-xs\">\n {initial}\n </Avatar>;\n } else if (user === undefined || authController.initialLoading) {\n avatarComponent = <Skeleton className=\"w-8 h-8 rounded-full\"/>;\n } else {\n avatarComponent = null;\n }\n\n return (\n <div className=\"shrink-0 pt-2 pb-0\" ref={portalRef}>\n {/* The RLS simulator: an icon on the collapsed rail, the pill when expanded. */}\n {canSimulateAccess && (\n <div className=\"flex items-center px-[16px] py-1\">\n {/* The avatar's 44px column, so the icon lines up with it. */}\n <div className={cls(\"flex\", { \"w-[44px] justify-center\": !showFullContent })}>\n <RlsSimulatorBar\n compact={!showFullContent}\n side=\"right\"\n align=\"end\"\n portalContainer={portalRef.current}/>\n </div>\n </div>\n )}\n {avatarComponent && (\n <div className=\"flex items-center px-[16px] py-1\">\n <Menu\n trigger={\n <div\n className={cls(\n // Same 44px grid, and fixed across both states for\n // the same reason — see DrawerNavigationItem.\n \"shrink-0 flex items-center justify-center w-[44px] cursor-pointer\",\n \"rounded-md py-1\",\n \"hover:bg-surface-hover\",\n \"transition-colors duration-150\"\n )}\n role=\"button\"\n tabIndex={0}\n aria-label={t(\"user_menu\", { defaultValue: \"User menu\" })}\n >\n {avatarComponent}\n </div>\n }\n side=\"top\"\n align=\"start\"\n >\n {user && <div className=\"px-4 py-2 mb-1\">\n {user.displayName && <Typography variant=\"body1\" color=\"secondary\">\n {user.displayName}\n </Typography>}\n {user.email && <Typography variant=\"body2\" color=\"secondary\">\n {user.email}\n </Typography>}\n </div>}\n\n {dropDownActions}\n\n {!dropDownActions && <>\n <MenuItem onClick={() => navigate(\"/settings\")}>\n <SettingsIcon/>\n {t(\"account_settings\")}\n </MenuItem>\n <MenuItem onClick={async () => {\n await authController.signOut();\n navigate(\"/\");\n }}>\n <LogOutIcon/>\n {t(\"log_out\")}\n </MenuItem>\n </>}\n </Menu>\n\n {/* Language + Theme — only when expanded */}\n {showFullContent && (\n <div className=\"flex items-center gap-0\">\n <LanguageToggle/>\n <Menu\n trigger={\n <IconButton\n aria-label={t(\"toggle_theme\", { defaultValue: \"Toggle theme\" })}\n className=\"text-surface-500 dark:text-surface-400\"\n >\n {mode === \"dark\"\n ? <MoonIcon size={iconSize.small}/>\n : mode === \"light\"\n ? <SunIcon size={iconSize.small}/>\n : <SunMoonIcon size={iconSize.small}/>}\n </IconButton>\n }\n portalContainer={portalRef.current}\n side=\"top\"\n >\n <MenuItem onClick={() => setMode(\"dark\")}><MoonIcon size={iconSize.smallest}/> {t(\"dark_mode\")}</MenuItem>\n <MenuItem onClick={() => setMode(\"light\")}><SunIcon size={iconSize.smallest}/> {t(\"light_mode\")}</MenuItem>\n <MenuItem onClick={() => setMode(\"system\")}><SunMoonIcon size={iconSize.smallest}/> {t(\"system_mode\")}</MenuItem>\n </Menu>\n </div>\n )}\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,SAAgB,cAAc,EAC1B,OACA,MACA,iBACA,UACA,eACA,WACA,SAqBD;CAEC,MAAM,EACF,eACA,YACA,YACA,aACA,MAAM,YACN,OAAO;CAEX,MAAM,eAAe,QAAQ;CAE7B,MAAM,YAAY,MAAM,OAAuB,IAAI;CACnD,MAAM,CAAC,UAAU,eAAe,MAAM,SAAS,KAAK;CAKpD,MAAM,WAAW,cAAc;CAC/B,MAAM,YAAY,mBAAmB,QAAQ;CAE7C,MAAM,qBAAqB;EACvB,IAAI,UAAU,SACV,YAAY,UAAU,QAAQ,YAAY,CAAC;CAEnD;CAE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AE,WAAW;OAAY;;MACzG,qBAAC,UAAD;OAAU,eAAe,QAAQ,OAAO;iBAAxC;QAA2C,oBAAC,SAAD,EAAS,MAAM,SAAS,SAAU,CAAA;QAAC;QAAE,EAAE,YAAY;OAAY;;MAC1G,qBAAC,UAAD;OAAU,eAAe,QAAQ,QAAQ;iBAAzC;QAA4C,oBAAC,aAAD,EAAa,MAAM,SAAS,SAAU,CAAA;QAAC;QAAE,EAAE,aAAa;OAAY;;KAC9G;MACL;KAER;IAER;;AAEb"}
|
|
1
|
+
{"version":3,"file":"DefaultDrawer.js","names":[],"sources":["../../src/components/DefaultDrawer.tsx"],"sourcesContent":["import type { NavigationEntry, NavigationResult } from \"@rebasepro/cms-types\";\nimport React, { useCallback, useMemo } from \"react\";\n\nimport { useCollapsedGroups, buildCollapsedDefaults, useLargeLayout, useAdminModeController, useAuthController, useModeController, useTranslation, useSlot, useRebaseContext, useAnalyticsController, useRebaseRegistry, useComponentOverride } from \"@rebasepro/app\";\nimport type { AdminModeController } from \"@rebasepro/app\";\nimport { useUrlController } from \"../hooks/navigation/contexts/UrlContext\";\nimport { useNavigationStateController } from \"../hooks/navigation/contexts/NavigationStateContext\";\n\n\nimport { Link, useNavigate } from \"react-router\";\nimport { AnalyticsEvent, studioSchemaToolEnabled } from \"@rebasepro/cms-types\";\nimport {\n Avatar,\n ChevronsLeftIcon,\n ChevronsRightIcon,\n cls,\n iconSize,\n IconButton,\n LanguagesIcon,\n LogOutIcon,\n Menu,\n MenuItem,\n MoonIcon,\n Separator,\n SettingsIcon,\n Skeleton,\n SunIcon,\n SunMoonIcon,\n ToggleButtonGroup,\n Tooltip,\n Typography\n} from \"@rebasepro/ui\";\nimport { DrawerNavigationGroup } from \"./DrawerNavigationGroup\";\nimport { DrawerExpansionContext, useDrawerExpansion } from \"./drawer_expansion\";\nimport { LanguageToggle, RebaseLogo, RlsSimulatorBar, useCanSimulateAccess } from \"@rebasepro/app\";\nimport { useApp } from \"./app/useApp\";\n\n/**\n * Default drawer used in the admin.\n *\n * When no `children` are provided, renders the full admin navigation\n * (collection groups, mode switch, plugin slots).\n *\n * When `children` **are** provided, renders the shared drawer shell\n * (logo, scrollable area, footer actions, collapse toggle) with the\n * custom content injected in the scrollable area. This lets consumers\n * like the SaaS dashboard reuse the identical structural layout while\n * supplying their own navigation items.\n *\n * @group Core\n */\nexport function DefaultDrawer({\n title,\n logo,\n logoDestination,\n children,\n footerActions,\n className,\n style\n}: {\n title?: React.ReactNode;\n logo?: string;\n logoDestination?: string;\n /**\n * Custom navigation content for the drawer.\n * When provided, replaces the default admin navigation (collection groups,\n * mode switch, slots). The shared shell (logo, scroll area, footer\n * actions, collapse toggle) is still rendered around it.\n */\n children?: React.ReactNode;\n /**\n * Custom content for the drawer footer actions area (language, theme, user menu).\n * - `undefined` — renders the default `DrawerFooterActions`.\n * - `null` — renders nothing (hides the footer actions).\n * - `ReactNode` — renders the provided custom content.\n */\n footerActions?: React.ReactNode | null;\n className?: string;\n style?: React.CSSProperties;\n}) {\n\n const {\n drawerHovered,\n drawerOpen,\n openDrawer,\n closeDrawer,\n logo: appLogo\n } = useApp();\n\n const resolvedLogo = logo ?? appLogo;\n\n const scrollRef = React.useRef<HTMLDivElement>(null);\n const [scrolled, setScrolled] = React.useState(false);\n\n // Open, pinned or floating under the pointer. The rows read it from the\n // `data-expanded` attribute (through CSS) and the expansion store, not as a\n // prop, so the rail opening under the pointer re-renders none of them.\n const expanded = drawerOpen || drawerHovered;\n const expansion = useDrawerExpansion(expanded);\n\n const handleScroll = () => {\n if (scrollRef.current) {\n setScrolled(scrollRef.current.scrollTop > 0);\n }\n };\n\n return (\n <div role=\"navigation\" aria-label=\"Main navigation\"\n data-expanded={expanded}\n className={cls(\"group/drawer flex flex-col h-full relative grow w-full\", className)} style={style}>\n\n <DrawerLogo\n logo={resolvedLogo}\n title={title}\n logoDestination={logoDestination}\n drawerOpen={drawerOpen}\n drawerHovered={drawerHovered}\n />\n\n <div\n ref={scrollRef}\n onScroll={handleScroll}\n className={\"flex-grow min-h-0 overflow-y-auto overflow-x-hidden no-scrollbar px-2\"}\n style={{\n maskImage: scrolled\n ? \"linear-gradient(to bottom, transparent 0, black 20px, black calc(100% - 20px), transparent 100%)\"\n : \"linear-gradient(to bottom, black 0, black calc(100% - 20px), transparent 100%)\"\n }}>\n <DrawerExpansionContext.Provider value={expansion}>\n {children ?? <AdminNavigationContent />}\n </DrawerExpansionContext.Provider>\n </div>\n\n {footerActions !== null && (\n footerActions !== undefined\n ? footerActions\n : <DrawerFooterActions\n drawerOpen={drawerOpen}\n drawerHovered={drawerHovered}\n />\n )}\n\n <DrawerToggle\n drawerOpen={drawerOpen}\n drawerHovered={drawerHovered}\n openDrawer={openDrawer}\n closeDrawer={closeDrawer}\n />\n </div>\n );\n}\n\n/**\n * Default admin navigation content — rendered inside DefaultDrawer when no\n * custom `children` are provided. Contains the mode switch, navigation\n * groups, and header / footer plugin slots.\n */\nfunction AdminNavigationContent() {\n\n const {\n drawerHovered,\n drawerOpen,\n closeDrawer,\n closeHover\n } = useApp();\n\n const analyticsController = useAnalyticsController();\n const navigationState = useNavigationStateController();\n const context = useRebaseContext();\n\n const largeLayout = useLargeLayout();\n const adminModeController = useAdminModeController();\n const registry = useRebaseRegistry();\n const ResolvedDrawerNavigationGroup = useComponentOverride(\"Shell.DrawerNavigationGroup\", DrawerNavigationGroup);\n\n const allNavigationEntries = navigationState.topLevelNavigation?.navigationEntries ?? [];\n\n // Build a set of Studio-only dev view slugs so we can distinguish them from\n // admin custom views added via <RebaseCMS views={...}> or plugins.\n const studioViewSlugs = useMemo(() => {\n const slugs = new Set<string>();\n (registry.studioConfig?.devViews ?? []).forEach(v => slugs.add(v.slug));\n // The schema view is also a Studio dev view (auto-injected when collectionEditor is enabled)\n if (studioSchemaToolEnabled(registry)) slugs.add(\"schema\");\n return slugs;\n }, [registry]);\n\n // Studio mode shows Studio dev views + admin entries (Users/Roles).\n // Content mode shows collections, admin custom views, and admin entries — but not Studio dev views.\n const filteredEntries = adminModeController.mode === \"studio\"\n ? allNavigationEntries.filter(e => (e.type === \"view\" && studioViewSlugs.has(e.slug)) || e.type === \"admin\")\n : allNavigationEntries.filter(e => e.type !== \"view\" || !studioViewSlugs.has(e.slug));\n\n // Derive groups from the filtered entries, preserving the order from topLevelNavigation.groups\n const entryGroups = new Set(filteredEntries.map(e => e.group).filter(Boolean));\n const orderedGroups = navigationState.topLevelNavigation?.groups ?? [];\n const groupsToRender = [\n ...orderedGroups.filter(g => entryGroups.has(g)),\n ...[...entryGroups].filter(g => !orderedGroups.includes(g))\n ];\n\n // Group header icons, declared on `navigationGroupMappings`. Keyed by name\n // because that is what a navigation entry's `group` holds.\n const groupIcons = useMemo(() => {\n const icons = new Map<string, string>();\n (registry.cmsConfig?.navigationGroupMappings ?? []).forEach(mapping => {\n if (mapping.icon) icons.set(mapping.name, mapping.icon);\n });\n return icons;\n }, [registry.cmsConfig?.navigationGroupMappings]);\n\n // Collapsible groups state - using \"drawer\" namespace for independent state from home page\n const collapsedDefaults = useMemo(\n () => buildCollapsedDefaults(registry.cmsConfig?.navigationGroupMappings, \"drawer\"),\n [registry.cmsConfig?.navigationGroupMappings]\n );\n const { isGroupCollapsed, toggleGroupCollapsed } = useCollapsedGroups(groupsToRender, \"drawer\", collapsedDefaults);\n\n const headerSlot = useSlot(\"navigation.header\", { drawerOpen,\ndrawerHovered,\ncontext });\n const footerSlot = useSlot(\"navigation.footer\", { drawerOpen,\ndrawerHovered,\ncontext });\n\n // The same handler across a hover: every row is handed it.\n const onItemClick = useCallback((view: NavigationEntry) => {\n const eventName: AnalyticsEvent = view.type === \"collection\"\n ? \"drawer_navigate_to_collection\"\n : (view.type === \"view\" ? \"drawer_navigate_to_view\" : \"unmapped_event\");\n analyticsController.onAnalyticsEvent?.(eventName, { url: view.url });\n if (!largeLayout) {\n closeDrawer();\n } else if (!drawerOpen) {\n closeHover();\n }\n }, [analyticsController, largeLayout, drawerOpen, closeDrawer, closeHover]);\n\n if (!navigationState.topLevelNavigation)\n return null;\n\n const drawerVisuallyOpen = drawerOpen || drawerHovered;\n\n return (\n <>\n {registry.studioConfig && (\n <DrawerModeSwitch\n drawerOpen={drawerOpen}\n drawerHovered={drawerHovered}\n />\n )}\n\n {headerSlot}\n\n {groupsToRender.map((group) => {\n const entriesInGroup = filteredEntries.filter(e => e.group === group);\n return (\n <ResolvedDrawerNavigationGroup\n key={`drawer_group_${group}`}\n group={group}\n entries={entriesInGroup}\n collapsed={isGroupCollapsed(group)}\n onToggleCollapsed={() => toggleGroupCollapsed(group)}\n drawerOpen={drawerVisuallyOpen}\n onItemClick={onItemClick}\n icon={groupIcons.get(group)}\n />\n );\n })}\n\n {footerSlot}\n </>\n );\n}\n\nexport function DrawerLogo({\n logo,\n title,\n logoDestination = \"/\",\n drawerOpen,\n drawerHovered\n}: {\n logo?: string;\n title?: React.ReactNode;\n logoDestination?: string;\n drawerOpen: boolean;\n drawerHovered: boolean;\n}) {\n\n const showFullContent = drawerOpen || drawerHovered;\n const { t } = useTranslation();\n\n return (\n <div className=\"flex flex-row items-center shrink-0 pt-4 pb-0 px-2\">\n {/* Logo — always visible */}\n {/* Named explicitly because neither branch below carries text: the\n stock `RebaseLogo` is a bare <svg> with no <title>, and a custom\n `logo` only ever gets the generic alt \"Logo\", which names the image\n rather than saying where the link goes. The title link beside it is\n no help either — it renders only when a `title` is set. */}\n <Link\n className=\"shrink-0 flex items-center justify-center w-[56px] h-[40px]\"\n to={logoDestination}\n aria-label={t(\"home\", { defaultValue: \"Home\" })}\n >\n {logo\n ? <img src={logo} alt=\"Logo\" className=\"w-[28px] h-[28px] object-contain\"/>\n : <RebaseLogo width=\"28px\" height=\"28px\"/>\n }\n </Link>\n\n {/* Title (fades in when expanded or hovered) */}\n <div\n className={cls(\n \"flex flex-row items-center overflow-hidden transition-all duration-200 ease-in-out\",\n showFullContent ? \"opacity-100 w-full ml-1\" : \"opacity-0 w-0 ml-0\"\n )}\n >\n {title && (\n <Link\n className=\"visited:text-inherit dark:visited:text-inherit block truncate\"\n to={logoDestination}\n >\n {typeof title === \"string\"\n ? <Typography variant=\"subtitle1\" noWrap className=\"truncate\">{title}</Typography>\n : title\n }\n </Link>\n )}\n </div>\n </div>\n );\n}\n\n/**\n * Toggle button at the bottom of the drawer.\n * Uses double-chevron icons to indicate collapse/expand direction.\n */\nexport function DrawerToggle({\n drawerOpen,\n drawerHovered,\n openDrawer,\n closeDrawer\n}: {\n drawerOpen: boolean;\n drawerHovered: boolean;\n openDrawer: () => void;\n closeDrawer: () => void;\n}) {\n const isExpanded = drawerOpen;\n const isHovered = drawerHovered && !drawerOpen;\n const showFullContent = isExpanded || isHovered;\n\n const [wantsTooltip, setWantsTooltip] = React.useState(false);\n // See {@link DrawerNavigationItem}: a masked tooltip never hears the pointer\n // leave, so the stale state is dropped as the mask goes on.\n if (showFullContent && wantsTooltip) setWantsTooltip(false);\n\n const { t } = useTranslation();\n\n return (\n <div className=\"shrink-0 mt-auto px-4 pt-0.5 pb-2\">\n <Tooltip\n title={isExpanded ? t(\"collapse\") : t(\"expand\")}\n // The row spells out \"Collapse\"/\"Expand\" itself whenever it is wide\n // enough to show the label — expanded, or floating open under the\n // pointer. A tooltip repeating that word is noise; it earns its\n // place only on a bare rail, where the chevron stands alone.\n //\n // Masked, not withheld: see {@link DrawerNavigationItem} for why\n // this stays controlled in both states.\n open={!showFullContent && wantsTooltip}\n onOpenChange={setWantsTooltip}\n side=\"right\"\n sideOffset={12}\n asChild={true}\n >\n <button\n type=\"button\"\n className={cls(\n \"flex flex-row items-center rounded-lg cursor-pointer w-full\",\n \"hover:bg-surface-hover\",\n \"transition-colors duration-150\",\n \"py-2\"\n )}\n aria-expanded={isExpanded}\n aria-label={isExpanded ? t(\"collapse\") : t(\"expand\")}\n onClick={() => isExpanded ? closeDrawer() : openDrawer()}\n >\n {/* 44px in both states, on the same grid as the rows above and\n for the same reason: the rail floats open under the pointer,\n and a slot that changed width with it walked the chevron\n sideways on hover. See the note in DrawerNavigationItem. */}\n <div className=\"shrink-0 flex items-center justify-center w-[44px] h-[24px] text-surface-500 dark:text-surface-400\">\n {isExpanded\n ? <ChevronsLeftIcon size={iconSize.small}/>\n : <ChevronsRightIcon size={iconSize.small}/>\n }\n </div>\n <div className={cls(\n \"overflow-hidden transition-all duration-200 ease-in-out\",\n showFullContent ? \"opacity-100 w-auto\" : \"opacity-0 w-0\"\n )}>\n <Typography\n variant=\"body2\"\n className=\"text-surface-500 dark:text-surface-400 select-none whitespace-nowrap\"\n >\n {isExpanded ? t(\"collapse\") : t(\"expand\")}\n </Typography>\n </div>\n </button>\n </Tooltip>\n </div>\n );\n}\n\n/**\n * Segmented Content / Studio switch rendered inside the drawer.\n * Animates in/out with the drawer open state via opacity + max-height.\n */\nfunction DrawerModeSwitch({\n drawerOpen,\n drawerHovered\n}: {\n drawerOpen: boolean;\n drawerHovered: boolean;\n}) {\n const adminModeController = useAdminModeController();\n const urlController = useUrlController();\n const navigate = useNavigate();\n const { t } = useTranslation();\n const showSwitch = drawerOpen || drawerHovered;\n\n return (\n <div\n // Hidden by opacity so it can fade with the rail; `inert` takes it\n // out of the tab order and the accessibility tree while it is.\n inert={!showSwitch}\n className={cls(\n \"shrink-0 overflow-hidden transition-all duration-200 ease-in-out px-3 h-8 mt-2 mb-0\",\n showSwitch ? \"opacity-100\" : \"opacity-0 pointer-events-none\"\n )}\n >\n <ToggleButtonGroup<AdminModeController[\"mode\"]>\n fullWidth\n aria-label={t(\"panel_mode\")}\n value={adminModeController.mode}\n onValueChange={(mode) => {\n adminModeController.setMode(mode);\n if (mode === \"cms\") navigate(urlController.basePath ?? \"/\");\n else navigate(urlController.basePath === \"/\" ? \"/s\" : `${urlController.basePath ?? \"\"}/s`);\n }}\n options={[\n { value: \"cms\", label: \"CMS\" },\n { value: \"studio\", label: \"Studio\" }\n ]}\n />\n </div>\n );\n}\n\n/**\n * Footer actions rendered at the bottom of the drawer, above the collapse/expand toggle.\n * Replaces the app bar icons (language, theme, user avatar) with a drawer-native layout\n * that adapts between collapsed (icons only) and expanded (full labels + user bar) states.\n *\n * @group Core\n */\nexport function DrawerFooterActions({\n drawerOpen,\n drawerHovered,\n /**\n * Custom content to render inside the user dropdown menu.\n * When provided, these items are appended after the user info header\n * and before the default Sign Out item.\n */\n dropDownActions,\n /**\n * Override the user object displayed in the footer.\n * When omitted, falls back to `authController.user`.\n */\n user: userProp\n}: {\n drawerOpen: boolean;\n drawerHovered: boolean;\n dropDownActions?: React.ReactNode;\n user?: import(\"@rebasepro/types\").User;\n}) {\n const authController = useAuthController();\n const {\n mode,\n setMode\n } = useModeController();\n const navigate = useNavigate();\n const { t } = useTranslation();\n\n const user = userProp ?? authController.user;\n const showFullContent = drawerOpen || drawerHovered;\n const isFloating = drawerHovered && !drawerOpen;\n const portalRef = React.useRef<HTMLDivElement>(null);\n const canSimulateAccess = useCanSimulateAccess();\n\n // User avatar\n let avatarComponent: React.ReactElement | null;\n if (user) {\n const initial = user?.displayName\n ? user.displayName[0].toUpperCase()\n : (user?.email ? user.email[0].toUpperCase() : \"A\");\n avatarComponent = <Avatar src={user.photoURL ?? undefined} className=\"w-8 h-8 text-xs\">\n {initial}\n </Avatar>;\n } else if (user === undefined || authController.initialLoading) {\n avatarComponent = <Skeleton className=\"w-8 h-8 rounded-full\"/>;\n } else {\n avatarComponent = null;\n }\n\n return (\n <div className=\"shrink-0 pt-2 pb-0\" ref={portalRef}>\n {/* The RLS simulator: an icon on the collapsed rail, the pill when expanded. */}\n {canSimulateAccess && (\n <div className=\"flex items-center px-[16px] py-1\">\n {/* The avatar's 44px column, so the icon lines up with it. */}\n <div className={cls(\"flex\", { \"w-[44px] justify-center\": !showFullContent })}>\n <RlsSimulatorBar\n compact={!showFullContent}\n side=\"right\"\n align=\"end\"\n portalContainer={portalRef.current}/>\n </div>\n </div>\n )}\n {avatarComponent && (\n <div className=\"flex items-center px-[16px] py-1\">\n <Menu\n trigger={\n <div\n className={cls(\n // Same 44px grid, and fixed across both states for\n // the same reason — see DrawerNavigationItem.\n \"shrink-0 flex items-center justify-center w-[44px] cursor-pointer\",\n \"rounded-md py-1\",\n \"hover:bg-surface-hover\",\n \"transition-colors duration-150\"\n )}\n role=\"button\"\n tabIndex={0}\n aria-label={t(\"user_menu\", { defaultValue: \"User menu\" })}\n >\n {avatarComponent}\n </div>\n }\n side=\"top\"\n align=\"start\"\n >\n {user && <div className=\"px-4 py-2 mb-1\">\n {user.displayName && <Typography variant=\"body1\" color=\"secondary\">\n {user.displayName}\n </Typography>}\n {user.email && <Typography variant=\"body2\" color=\"secondary\">\n {user.email}\n </Typography>}\n </div>}\n\n {dropDownActions}\n\n {!dropDownActions && <>\n <MenuItem onClick={() => navigate(\"/settings\")}>\n <SettingsIcon/>\n {t(\"account_settings\")}\n </MenuItem>\n <MenuItem onClick={async () => {\n await authController.signOut();\n navigate(\"/\");\n }}>\n <LogOutIcon/>\n {t(\"log_out\")}\n </MenuItem>\n </>}\n </Menu>\n\n {/* Language + Theme — only when expanded */}\n {showFullContent && (\n <div className=\"flex items-center gap-0\">\n <LanguageToggle/>\n <Menu\n trigger={\n <IconButton\n aria-label={t(\"toggle_theme\", { defaultValue: \"Toggle theme\" })}\n className=\"text-surface-500 dark:text-surface-400\"\n >\n {mode === \"dark\"\n ? <MoonIcon size={iconSize.small}/>\n : mode === \"light\"\n ? <SunIcon size={iconSize.small}/>\n : <SunMoonIcon size={iconSize.small}/>}\n </IconButton>\n }\n portalContainer={portalRef.current}\n side=\"top\"\n >\n <MenuItem onClick={() => setMode(\"dark\")}><MoonIcon size={iconSize.smallest}/> {t(\"dark_mode\")}</MenuItem>\n <MenuItem onClick={() => setMode(\"light\")}><SunIcon size={iconSize.smallest}/> {t(\"light_mode\")}</MenuItem>\n <MenuItem onClick={() => setMode(\"system\")}><SunMoonIcon size={iconSize.smallest}/> {t(\"system_mode\")}</MenuItem>\n </Menu>\n </div>\n )}\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA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ACJ,oBAAC,UAAD,EAAU,MAAM,SAAS,MAAO,CAAA,IAChC,SAAS,UACL,oBAAC,SAAD,EAAS,MAAM,SAAS,MAAO,CAAA,IAC/B,oBAAC,aAAD,EAAa,MAAM,SAAS,MAAO,CAAA;KACrC,CAAA;KAEhB,iBAAiB,UAAU;KAC3B,MAAK;eAdT;MAgBI,qBAAC,UAAD;OAAU,eAAe,QAAQ,MAAM;iBAAvC;QAA0C,oBAAC,UAAD,EAAU,MAAM,SAAS,SAAU,CAAA;QAAC;QAAE,EAAE,WAAW;OAAY;;MACzG,qBAAC,UAAD;OAAU,eAAe,QAAQ,OAAO;iBAAxC;QAA2C,oBAAC,SAAD,EAAS,MAAM,SAAS,SAAU,CAAA;QAAC;QAAE,EAAE,YAAY;OAAY;;MAC1G,qBAAC,UAAD;OAAU,eAAe,QAAQ,QAAQ;iBAAzC;QAA4C,oBAAC,aAAD,EAAa,MAAM,SAAS,SAAU,CAAA;QAAC;QAAE,EAAE,aAAa;OAAY;;KAC9G;MACL;KAER;IAER;;AAEb"}
|
|
@@ -15,6 +15,7 @@ import { CollectionViewBinding } from "./CollectionViewBinding/CollectionViewBin
|
|
|
15
15
|
import { Suspense, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
16
16
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
17
17
|
import { Button, CenteredView, CircularProgressCenter, ErrorBoundary, IconButton, Maximize2Icon, PencilIcon, Skeleton, Tab, Tabs, Tooltip, Typography, cls, defaultBorderMixin, iconSize } from "@rebasepro/ui";
|
|
18
|
+
import { hasEntityId } from "@rebasepro/common";
|
|
18
19
|
import { CollectionScopeProvider, ErrorView, PluginProviderStack, createFormexStub, getAdminEntityChildViews, getIcon, removeInitialAndTrailingSlashes, resolveComponentRef, resolveDefaultSelectedView, useComponentOverride, useCustomizationController, useFetch, usePermissions, useRebaseContext, useSlot, useTranslation } from "@rebasepro/app";
|
|
19
20
|
import { useNavigate } from "react-router";
|
|
20
21
|
//#region src/components/DetailViewBinding.tsx
|
|
@@ -104,7 +105,7 @@ function DetailViewBindingInner({ path, entityId, selectedTab: selectedTabProp,
|
|
|
104
105
|
const mountedTabsRef = useRef(/* @__PURE__ */ new Set());
|
|
105
106
|
if (activeTab) mountedTabsRef.current.add(activeTab);
|
|
106
107
|
const readOnlyFormContext = useMemo(() => {
|
|
107
|
-
if (!entityId) return void 0;
|
|
108
|
+
if (!hasEntityId(entityId)) return void 0;
|
|
108
109
|
const formexStub = createFormexStub(usedEntity?.values ?? {});
|
|
109
110
|
return {
|
|
110
111
|
entityId,
|
|
@@ -197,7 +198,7 @@ function DetailViewBindingInner({ path, entityId, selectedTab: selectedTabProp,
|
|
|
197
198
|
if (!customView) return null;
|
|
198
199
|
const Builder = resolveComponentRef(customView.Builder);
|
|
199
200
|
if (!Builder) return null;
|
|
200
|
-
if (!entityId) return null;
|
|
201
|
+
if (!hasEntityId(entityId)) return null;
|
|
201
202
|
const isActive = activeTab === customView.key;
|
|
202
203
|
const hasBeenMounted = mountedTabsRef.current.has(customView.key);
|
|
203
204
|
if (!isActive && !hasBeenMounted) return null;
|
|
@@ -318,7 +319,7 @@ function DetailViewBindingInner({ path, entityId, selectedTab: selectedTabProp,
|
|
|
318
319
|
});
|
|
319
320
|
const collectionUrl = withListState(urlController.buildUrlCollectionPath(path));
|
|
320
321
|
const backToCollection = layout === "full_screen" && !onShowList ? () => navigate(collectionUrl) : void 0;
|
|
321
|
-
const fullScreenButton = !barActions && (layout === "side_panel" || layout === "dialog") && entityId ? /* @__PURE__ */ jsx(Tooltip, {
|
|
322
|
+
const fullScreenButton = !barActions && (layout === "side_panel" || layout === "dialog") && hasEntityId(entityId) ? /* @__PURE__ */ jsx(Tooltip, {
|
|
322
323
|
title: "Open full screen",
|
|
323
324
|
children: /* @__PURE__ */ jsx(IconButton, {
|
|
324
325
|
"aria-label": "Open full screen",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DetailViewBinding.js","names":[],"sources":["../../src/components/DetailViewBinding.tsx"],"sourcesContent":["import type { ComponentRef } from \"@rebasepro/types\";\nimport type { EntityCustomViewParams, FormViewConfig, AdminCollection } from \"@rebasepro/cms-types\";\nimport type { FormContext } from \"../types/fields\";\nimport type { PluginFormActionProps } from \"@rebasepro/cms-types\";\nimport React, { lazy, Suspense, useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { Entity, EntityStatus, Property } from \"@rebasepro/types\";\nimport { PluginProviderStack, resolveComponentRef, useComponentOverride, CollectionScopeProvider, getAdminEntityChildViews } from \"@rebasepro/app\";\n\nimport { CollectionViewBinding } from \"./CollectionViewBinding/CollectionViewBinding\";\nimport { EntityViewBinding } from \"./EntityViewBinding\";\nimport { EntityIdentityBar } from \"./EntityIdentityBar\";\nimport { SplitListCloseButton } from \"./CollectionViewBinding/SplitListCloseButton\";\nimport { SplitListShowButton } from \"./CollectionViewBinding/SplitListShowButton\";\nimport { EntityInspector, InspectorTab } from \"./EntityInspector\";\nimport { CircularProgressCenter, iconSize } from \"@rebasepro/ui\";\nimport {\n Alert,\n Button,\n CenteredView,\n cls,\n CodeIcon,\n defaultBorderMixin,\n HistoryIcon,\n IconButton,\n Maximize2Icon,\n PencilIcon,\n Skeleton,\n Tab,\n Tabs,\n Tooltip,\n Typography\n} from \"@rebasepro/ui\";\nimport { ErrorBoundary } from \"@rebasepro/ui\";\nimport { ErrorView, createFormexStub, usePermissions, useTranslation, getIcon } from \"@rebasepro/app\";\n\nimport { removeInitialAndTrailingSlashes, resolveDefaultSelectedView } from \"@rebasepro/app\";\nimport { withListState } from \"../util/view_mode\";\nimport { resolvedSelectedEntityView } from \"../util/resolutions\";\nimport {\n useCustomizationController,\n useFetch,\n useRebaseContext,\n useLargeLayout,\n useSlot\n} from \"@rebasepro/app\";\nimport { useUrlController } from \"../hooks/navigation/contexts/UrlContext\";\nimport { useCollectionRegistryController } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useNavigate } from \"react-router\";\nimport { useEntityDisplayTitle } from \"../hooks/useEntityDisplayTitle\";\nimport { useAdminContext } from \"../hooks/useAdminContext\";\nimport { useLeaveRecord, useRecordActions } from \"../hooks/useRecordActions\";\n\n\nimport {\n MAIN_TAB_VALUE,\n JSON_TAB_VALUE,\n HISTORY_TAB_VALUE,\n ENTITY_VIEW_TAB_BAR_CLASS,\n ENTITY_VIEW_TAB_CLASS,\n ENTITY_VIEW_TAB_LABEL_CLASS\n} from \"../util/view_constants\";\n\nexport type BarActionsParams = {\n values: object,\n status: EntityStatus,\n path: string,\n entityId?: string | number;\n /** Always false here — this view reads a record, it does not edit one. */\n dirty: boolean;\n};\n\nexport type OnTabChangeParams<M extends Record<string, unknown>> = {\n path: string;\n entityId?: string | number;\n selectedTab?: string;\n collection: AdminCollection<M>;\n};\n\nexport interface DetailViewBindingProps<M extends Record<string, unknown> = Record<string, unknown>> {\n path: string;\n collection: AdminCollection<M>;\n entityId: string | number;\n selectedTab?: string;\n parentCollectionSlugs: string[];\n parentEntityIds: string[];\n onTabChange?: (props: OnTabChangeParams<M>) => void;\n onEditClick?: () => void;\n /**\n * Dismiss this record — the ✕ at the identity bar's trailing edge.\n *\n * Set by the layouts that own the record's place on screen but are not side\n * dialogs: the split, where dismissing is navigating back to the collection.\n */\n onCloseRequest?: () => void;\n layout?: \"side_panel\" | \"full_screen\" | \"split\" | \"dialog\";\n barActions?: (params: BarActionsParams) => React.ReactNode;\n /**\n * Controls the owning panel puts at the identity bar's leading edge, ahead\n * of the breadcrumb — the side panel's close button.\n */\n barActionsStart?: React.ReactNode;\n /**\n * Full screen only: bring the list back beside this record. Set when the\n * record was opened out of a split collection, so folding the list away is\n * reversible; it takes the place of the back arrow when present.\n */\n onShowList?: () => void;\n}\n\nexport function DetailViewBinding<M extends Record<string, unknown>>({\n entityId,\n ...props\n}: DetailViewBindingProps<M>) {\n\n const {\n entity,\n dataLoading,\n dataLoadingError\n } = useFetch<M>({\n path: props.path,\n entityId: entityId,\n collection: props.collection,\n // The relation fields' values, read with the record (see `useFetch`).\n relations: true,\n useCache: false\n });\n\n if (!dataLoading && dataLoadingError) {\n return <CenteredView>\n <ErrorView error={dataLoadingError} />\n </CenteredView>;\n }\n\n if (!dataLoading && !entity) {\n return <CenteredView>\n <Typography variant=\"label\">Entity not found</Typography>\n </CenteredView>;\n }\n\n const content = (\n <DetailViewBindingInner<M>\n {...props}\n entityId={entityId}\n entity={entity}\n dataLoading={dataLoading}\n />\n );\n\n return (\n <CollectionScopeProvider collection={props.collection}>\n {content}\n </CollectionScopeProvider>\n );\n}\n\nfunction DetailViewBindingInner<M extends Record<string, unknown>>({\n path,\n entityId,\n selectedTab: selectedTabProp,\n collection,\n parentCollectionSlugs,\n parentEntityIds,\n onTabChange,\n onEditClick,\n onCloseRequest,\n entity,\n dataLoading,\n layout = \"full_screen\",\n barActions,\n barActionsStart,\n onShowList\n}: DetailViewBindingProps<M> & {\n entity?: Entity<M>,\n dataLoading: boolean,\n}) {\n const ResolvedCollectionView = useComponentOverride(\"Collection.View\", CollectionViewBinding);\n const { t } = useTranslation();\n const context = useRebaseContext();\n const urlController = useUrlController();\n const navigate = useNavigate();\n const customizationController = useCustomizationController();\n const plugins = customizationController.plugins;\n const collectionRegistryController = useCollectionRegistryController();\n const { canEdit: canEditHook } = usePermissions();\n\n const canEdit = useMemo(() => {\n return entity ? canEditHook(collection, path, entity) : false;\n }, [canEditHook, entity, collection, path]);\n\n const [usedEntity, setUsedEntity] = useState<Entity<M> | undefined>(entity);\n useEffect(() => {\n if (entity) setUsedEntity(entity);\n }, [entity]);\n\n const defaultSelectedView = useMemo(() => resolveDefaultSelectedView(\n collection.defaultSelectedView,\n { status: \"existing\",\nentityId }\n ), [collection, entityId]);\n\n // Track whether the user has explicitly clicked a tab in this component\n // instance. See EditViewBindingInner for full explanation.\n const userHasChangedTab = useRef(false);\n\n const [selectedTab, setSelectedTab] = useState<string>(() => {\n const val = selectedTabProp ?? defaultSelectedView ?? MAIN_TAB_VALUE;\n return val === \"edit\" ? MAIN_TAB_VALUE : val;\n });\n useEffect(() => {\n const val = userHasChangedTab.current\n ? (selectedTabProp ?? MAIN_TAB_VALUE)\n : (selectedTabProp ?? defaultSelectedView ?? MAIN_TAB_VALUE);\n const target = val === \"edit\" ? MAIN_TAB_VALUE : val;\n if (target !== selectedTab) {\n setSelectedTab(target);\n }\n }, [selectedTabProp, defaultSelectedView]);\n\n // `hideFromEntityViews`, not `hideFromNavigation`: the latter governs the\n // drawer. Filtering tabs on it defeated the introspection generator, which\n // sets `hideFromNavigation` on owned-child tables precisely *because* \"every\n // inbound foreign key renders as a tab on the parent\" — so the rows it\n // deliberately kept out of the drawer became reachable from nowhere.\n const childViews = getAdminEntityChildViews(collection).filter(v => !v.collection.hideFromEntityViews);\n const subcollections = childViews.map(v => v.collection);\n const subcollectionsCount = subcollections?.length ?? 0;\n const customViews = collection.entityViews ?? [];\n const customViewsCount = customViews?.length ?? 0;\n const includeJsonView = collection.includeJsonView === undefined ? true : collection.includeJsonView;\n const includeHistoryView = Boolean(collection.history);\n // Same split as the edit view: the strip is for destinations, the inspector\n // for the developer tools that used to sit in front of them.\n const hasAdditionalViews = customViewsCount > 0 || subcollectionsCount > 0;\n\n const [inspectorTab, setInspectorTab] = useState<InspectorTab | null>(null);\n\n const legacyInspectorTab: InspectorTab | undefined = selectedTab === JSON_TAB_VALUE\n ? \"json\"\n : selectedTab === HISTORY_TAB_VALUE ? \"history\" : undefined;\n useEffect(() => {\n if (legacyInspectorTab) setInspectorTab(legacyInspectorTab);\n }, [legacyInspectorTab]);\n\n const {\n resolvedEntityViews\n } = resolvedSelectedEntityView(customViews, customizationController, undefined, canEdit);\n\n const validTabValues = useMemo(() => {\n const set = new Set<string>([\n MAIN_TAB_VALUE,\n ...resolvedEntityViews.map(v => v.key),\n ...subcollections.map(s => s.slug)\n ]);\n return set;\n }, [resolvedEntityViews, subcollections]);\n\n const activeTab = validTabValues.has(selectedTab) ? selectedTab : MAIN_TAB_VALUE;\n\n const {\n selectedEntityView\n } = resolvedSelectedEntityView(customViews, customizationController, activeTab, canEdit);\n\n const mainViewVisible = activeTab === MAIN_TAB_VALUE;\n\n // Track which custom view tabs have been visited\n const mountedTabsRef = useRef<Set<string>>(new Set());\n if (activeTab) {\n mountedTabsRef.current.add(activeTab);\n }\n\n // Read-only form context for custom entity views\n const readOnlyFormContext = useMemo<FormContext<M> | undefined>(() => {\n if (!entityId) return undefined;\n const formexStub = createFormexStub<M>(usedEntity?.values ?? {} as M);\n return {\n entityId,\n disabled: true,\n readOnly: true,\n openEntityMode: layout,\n status: \"existing\",\n values: usedEntity?.values ?? ({} as M),\n setFieldValue: () => {\n throw new Error(\"Cannot update values in read-only detail view\");\n },\n save: () => {\n throw new Error(\"Cannot save in read-only detail view\");\n },\n submit: () => {\n throw new Error(\"Cannot submit in read-only detail view\");\n },\n collection,\n path,\n entity: usedEntity,\n savingError: undefined,\n formex: formexStub\n };\n }, [entityId, layout, usedEntity, collection, path]);\n\n // Plugin slots\n const formActionTopProps: PluginFormActionProps = useMemo(() => ({\n entityId,\n parentCollectionSlugs,\n parentEntityIds,\n path,\n status: \"existing\",\n collection: collection!,\n context,\n formContext: readOnlyFormContext as FormContext<Record<string, unknown>> | undefined,\n openEntityMode: layout,\n disabled: true\n }), [entityId, parentCollectionSlugs, parentEntityIds, path, collection, context, readOnlyFormContext, layout]);\n const pluginActionsTop = useSlot(\"form.actions.top\", formActionTopProps);\n\n // The record's own actions, as on the edit view: a read-only record is\n // still one you can recalculate, resend or delete. There is no form here,\n // so they are called without a `formContext`.\n const adminContext = useAdminContext();\n const leaveRecord = useLeaveRecord({ layout, path, onCloseRequest });\n const recordActionClickProps = useMemo(() => usedEntity\n ? {\n view: \"form\" as const,\n entity: usedEntity as Entity<Record<string, unknown>>,\n path,\n collection: collection as AdminCollection,\n context,\n sidePanelController: adminContext.sidePanelController,\n openEntityMode: layout,\n navigateBack: leaveRecord\n }\n : undefined, [usedEntity, path, collection, context, adminContext.sidePanelController, layout, leaveRecord]);\n const recordActions = useRecordActions({\n collection,\n path,\n entity: usedEntity,\n clickProps: recordActionClickProps\n });\n\n // Resolve formView.Builder if provided\n const formViewConfig = (collection as AdminCollection<M> & { formView?: FormViewConfig<M> }).formView;\n const FormViewBuilder = formViewConfig?.Builder ? resolveComponentRef<EntityCustomViewParams>(formViewConfig.Builder as ComponentRef<EntityCustomViewParams>) : null;\n\n // The heading, resolved the one way — this used to be a copy of\n // `useEntityDisplayTitle`'s body, and the two had already drifted.\n const title = useEntityDisplayTitle({\n collection,\n entity: usedEntity,\n status: \"existing\"\n });\n\n // Non-action custom views\n const nonActionCustomViews = useMemo(() =>\n resolvedEntityViews.filter(e => !e.includeActions),\n [resolvedEntityViews]\n );\n\n const customViewsView = customViews && nonActionCustomViews\n .map((customView) => {\n if (!customView) return null;\n const Builder = resolveComponentRef<EntityCustomViewParams>(customView.Builder);\n if (!Builder) return null;\n if (!entityId) return null;\n\n const isActive = activeTab === customView.key;\n const hasBeenMounted = mountedTabsRef.current.has(customView.key);\n if (!isActive && !hasBeenMounted) return null;\n\n return <div\n className={cls(defaultBorderMixin,\n \"relative flex-1 w-full h-full overflow-auto\",\n { \"hidden\": !isActive }\n )}\n key={`custom_view_${customView.key}`}\n role=\"tabpanel\">\n <ErrorBoundary>\n <Suspense fallback={<CircularProgressCenter />}>\n {readOnlyFormContext && <Builder\n collection={collection}\n parentCollectionSlugs={parentCollectionSlugs}\n parentEntityIds={parentEntityIds}\n entity={usedEntity}\n modifiedValues={usedEntity?.values}\n formContext={readOnlyFormContext as FormContext<Record<string, unknown>>}\n />}\n </Suspense>\n </ErrorBoundary>\n </div>;\n }).filter(Boolean);\n\n const globalLoading = dataLoading && !usedEntity;\n\n // Subcollection views\n const subCollectionsViews = childViews && childViews.map(({ collection: subcollection }) => {\n const subcollectionId = subcollection.slug;\n // By slug, like the path it extends: the data layer hands the driver\n // the stored path, `path` included, for the whole of it at once.\n const newFullPath = usedEntity ? `${path}/${usedEntity?.id}/${removeInitialAndTrailingSlashes(subcollection.slug)}` : undefined;\n\n if (activeTab !== subcollectionId) return null;\n return (\n <div\n className={\"relative flex-1 h-full overflow-auto w-full\"}\n key={`subcol_${subcollectionId}`}\n role=\"tabpanel\">\n {globalLoading && <CircularProgressCenter />}\n {!globalLoading &&\n (usedEntity && newFullPath\n ? <ResolvedCollectionView\n path={newFullPath}\n parentCollectionSlugs={[...parentCollectionSlugs, collection.slug]}\n parentEntityIds={[...parentEntityIds, String(usedEntity?.id)]}\n updateUrl={false}\n {...subcollection}\n openEntityMode={layout} />\n : <div className=\"flex items-center justify-center w-full h-full p-3\">\n <Typography variant={\"label\"}>\n {/* No `?? \"…\"` here: `t` returns the key itself\n when it cannot find one, never null, so the\n fallback never ran and this rendered the raw\n `save_entity_before_subcollections`. The key\n exists now, in all seven locales. */}\n {t(\"save_entity_before_subcollections\")}\n </Typography>\n </div>)\n }\n </div>\n );\n }).filter(Boolean);\n\n const onSideTabClick = useCallback((value: string) => {\n userHasChangedTab.current = true;\n setSelectedTab(value);\n onTabChange?.({\n path,\n entityId,\n selectedTab: value === MAIN_TAB_VALUE ? undefined : value,\n collection\n });\n }, [onTabChange, path, entityId, collection]);\n\n const propertyDetailView = () => {\n // formView.Builder replaces the default property display. It gets the\n // centred column the record used to be given here; the default display\n // now lays itself out, rail included.\n if (FormViewBuilder && usedEntity) {\n return <div className={\"@container/form flex-1 min-w-0 overflow-y-auto flex justify-center items-start\"}>\n <div className={cls(\n // Same widths as the default form (see EntityForm).\n \"w-full max-w-3xl @7xl/form:max-w-4xl 2xl:max-w-4xl flex flex-col\",\n layout === \"dialog\"\n ? \"pt-5 pb-12 px-6 sm:px-8\"\n : \"pt-6 pb-16 px-5 sm:px-8\"\n )}>\n <ErrorBoundary>\n <Suspense fallback={<CircularProgressCenter />}>\n <FormViewBuilder\n collection={collection}\n parentCollectionSlugs={parentCollectionSlugs}\n parentEntityIds={parentEntityIds}\n entity={usedEntity}\n modifiedValues={usedEntity?.values}\n formContext={readOnlyFormContext as FormContext<Record<string, unknown>>}\n />\n </Suspense>\n </ErrorBoundary>\n </div>\n </div>;\n }\n\n return (\n <>\n {usedEntity && <EntityViewBinding\n entity={usedEntity}\n collection={collection}\n path={path}\n asPage\n openEntityMode={layout}\n formContext={readOnlyFormContext}\n />}\n </>\n );\n };\n\n // Tabs\n const subcollectionTabs = subcollections && subcollections.map((subcollection) => {\n const icon = getIcon(subcollection.icon, undefined, undefined, \"smallest\");\n return (\n <Tab\n className={cls(ENTITY_VIEW_TAB_CLASS, ENTITY_VIEW_TAB_LABEL_CLASS)}\n value={subcollection.slug}\n key={`entity_detail_collection_tab_${subcollection.name}`}>\n <span className=\"flex items-center gap-1.5\">\n {icon}\n {subcollection.name}\n </span>\n </Tab>\n );\n });\n\n const customViewTabsStart = resolvedEntityViews.filter(view => view.position === \"start\")\n .map((view) => {\n const icon = getIcon(view.icon, undefined, undefined, \"smallest\");\n return (\n <Tab\n className={cls(ENTITY_VIEW_TAB_CLASS, !view.tabComponent && ENTITY_VIEW_TAB_LABEL_CLASS)}\n value={view.key}\n key={`entity_detail_collection_tab_${view.name}`}>\n {view.tabComponent ?? (\n <span className=\"flex items-center gap-1.5\">\n {icon}\n {view.name}\n </span>\n )}\n </Tab>\n );\n });\n const customViewTabsEnd = resolvedEntityViews.filter(view => !view.position || view.position === \"end\")\n .map((view) => {\n const icon = getIcon(view.icon, undefined, undefined, \"smallest\");\n return (\n <Tab\n className={cls(ENTITY_VIEW_TAB_CLASS, !view.tabComponent && ENTITY_VIEW_TAB_LABEL_CLASS)}\n value={view.key}\n key={`entity_detail_collection_tab_${view.name}`}>\n {view.tabComponent ?? (\n <span className=\"flex items-center gap-1.5\">\n {icon}\n {view.name}\n </span>\n )}\n </Tab>\n );\n });\n\n // The breadcrumb's destination, and the back arrow's when it renders. Both\n // keep the list's whole URL state: a collection reached from one of its own\n // records must come back as the user left it — the same view mode, search,\n // filters and sort.\n const collectionUrl = withListState(urlController.buildUrlCollectionPath(path));\n\n // Full screen is the one layout with no way out of its own: a side panel and a\n // dialog can be dismissed, and a split keeps the list beside it, but opening an\n // entity full screen replaces the collection entirely and left browser Back as\n // the only route back to it — which is not an affordance the page shows, and is\n // wrong anyway once the user has moved between tabs inside the entity.\n //\n // Unless the list can be unfolded back beside the record: that chevron\n // leads to the same collection while keeping the record open, so it stands\n // alone rather than beside an arrow going almost the same place.\n //\n // It goes to the bar's leading edge — where a back control reads as back,\n // and where the edit view has always put the same arrow — rather than to\n // the trailing edge among the record's own actions.\n const backToCollection = layout === \"full_screen\" && !onShowList\n ? () => navigate(collectionUrl)\n : undefined;\n\n const fullScreenButton = !barActions && // Not in split: the list panel beside it carries the close control,\n // and an expand button there competes with it.\n (layout === \"side_panel\" || layout === \"dialog\") && entityId ? (\n <Tooltip title={\"Open full screen\"}>\n <IconButton aria-label={\"Open full screen\"}\n size=\"small\"\n onClick={() => {\n const entityUrl = urlController.buildUrlCollectionPath(`${path}/${entityId}`);\n navigate(`${entityUrl}#full`);\n }}\n >\n <Maximize2Icon size={iconSize.smallest} />\n </IconButton>\n </Tooltip>\n ) : null;\n\n // Edit button — only rendered when the user has edit permissions\n const editButton = canEdit && onEditClick ? (\n <Button\n variant=\"filled\"\n color=\"primary\"\n size=\"small\"\n startIcon={<PencilIcon size={iconSize.smallest} />}\n onClick={onEditClick}>\n {t(\"edit_entity\")}\n </Button>\n ) : null;\n\n // Main content view. The title, the `path/id` chip and the empty band under\n // them have moved into the identity bar, and the `w-80 2xl:w-96` rail that\n // held a single Edit button is gone — the bar holds it now.\n //\n // The scroll now lives on the record's own column rather than on this row,\n // so the metadata rail beside it stays put while the record scrolls — the\n // same arrangement the form uses.\n const mainView = <div\n className={cls(\n \"flex-1 flex flex-row w-full min-h-0\",\n !mainViewVisible ? \"hidden\" : \"\"\n )}>\n {propertyDetailView()}\n </div>;\n\n let result = <div className=\"relative flex flex-col h-full w-full bg-surface-card\">\n\n <EntityIdentityBar\n collection={collection as AdminCollection}\n collectionUrl={layout === \"full_screen\" || layout === \"split\" ? collectionUrl : undefined}\n title={title}\n entityId={entityId}\n status={\"existing\"}\n dirty={false}\n saving={false}\n onBack={backToCollection}\n onClose={onCloseRequest}\n onInspect={includeJsonView ? () => setInspectorTab(\"json\") : undefined}\n onViewHistory={includeHistoryView ? () => setInspectorTab(\"history\") : undefined}\n externalLink={usedEntity\n ? customizationController?.entityLinkBuilder?.({ entity: usedEntity })\n : undefined}\n recordActions={recordActions}\n // Where Save stands on the edit view: after the record's own\n // buttons, ahead of the menu.\n primaryAction={editButton}\n leading={<>\n {barActionsStart}\n {/* Split view: closing the list is opening this record\n full screen, and the control for it belongs at this\n bar's leading edge. Full screen carries its mirror. */}\n {layout === \"split\" && <SplitListCloseButton/>}\n {layout === \"full_screen\" && onShowList && <SplitListShowButton onClick={onShowList}/>}\n </>}\n trailing={<>\n {pluginActionsTop}\n {fullScreenButton}\n {barActions?.({\n path,\n entityId,\n values: usedEntity?.values ?? {},\n status: \"existing\",\n dirty: false\n })}\n </>}\n />\n\n {hasAdditionalViews && <div className={cls(\n \"h-10 shrink-0 flex items-stretch border-b px-2 min-w-0\",\n ENTITY_VIEW_TAB_BAR_CLASS,\n defaultBorderMixin\n )}>\n <Tabs\n className={\"!w-full items-stretch\"}\n innerClassName={\"h-full\"}\n variant={\"boxy\"}\n value={activeTab}\n onValueChange={(value) => {\n onSideTabClick(value);\n }}>\n\n {/* Before the record, not after it.\n\n `position: \"start\"` used to mean \"first among the custom\n views\", which put it after a tab it was already after: the\n record's own tab is drawn here unconditionally, so \"start\"\n and \"end\" only ever ordered the custom views against each\n other, and no collection could open with anything but the\n form on the left.\n\n A cover — a read-only summary of the record, the thing an\n operator opens a row to see — belongs in front of the form\n that edits it. That is what `defaultSelectedView` already\n allowed, and the strip contradicted it by drawing the\n selected tab second. Views that say nothing still land after\n the record, so nothing moves for a collection that never\n asked. */}\n {customViewTabsStart}\n\n <Tab value={MAIN_TAB_VALUE}\n className={cls(ENTITY_VIEW_TAB_CLASS, ENTITY_VIEW_TAB_LABEL_CLASS)}>\n <span className=\"flex items-center gap-1.5\">\n {getIcon(collection.icon, undefined, undefined, \"smallest\")}\n {collection.singularName ?? collection.name}\n </span>\n </Tab>\n\n {customViewTabsEnd}\n {subcollectionTabs}\n </Tabs>\n </div>}\n\n {/* See EditViewBinding: the inspector docks beside the record rather\n than over it, so the record stays readable and scrollable. */}\n <div className={\"flex-1 min-h-0 flex\"}>\n\n <div className={\"flex-1 min-w-0 flex flex-col\"}>\n {globalLoading\n ? <DetailViewSkeleton collection={collection} />\n : mainView}\n\n {customViewsView}\n {subCollectionsViews}\n </div>\n\n <EntityInspector\n tab={inspectorTab}\n onTabChange={setInspectorTab}\n onClose={() => setInspectorTab(null)}\n collection={collection as AdminCollection}\n entity={usedEntity as Entity<Record<string, unknown>> | undefined}\n formContext={readOnlyFormContext as FormContext<Record<string, unknown>> | undefined}\n values={usedEntity?.values}\n includeHistory={includeHistoryView}/>\n </div>\n\n </div>;\n\n if (plugins && plugins.length > 0) {\n result = (\n <PluginProviderStack\n plugins={plugins}\n scope=\"form\"\n scopeProps={{\n status: \"existing\",\n path,\n collection,\n entity: usedEntity,\n context,\n formContext: readOnlyFormContext\n }}>\n {result}\n </PluginProviderStack>\n );\n }\n\n return result;\n}\n\nfunction DetailViewSkeleton({ collection }: { collection: AdminCollection<Record<string, unknown>> }) {\n return (\n <div className=\"flex-1 flex flex-row w-full overflow-y-auto justify-center\">\n <div className=\"relative flex flex-row max-w-4xl lg:max-w-3xl xl:max-w-4xl 2xl:max-w-6xl w-full h-fit\">\n <div className=\"flex flex-col w-full pt-12 pb-16 px-4 sm:px-8 md:px-10\">\n <div className=\"w-full flex flex-col items-start my-4 lg:my-6\">\n <div className={`py-1 my-4 w-2/3 ${collection.hideIdFromForm ? \"mb-6\" : \"\"}`}>\n <Skeleton height={28} className=\"w-full rounded-md\" />\n </div>\n <Skeleton height={32} className=\"w-full rounded-md\" />\n </div>\n <div className=\"mt-12 flex flex-col gap-8\">\n <div className=\"flex flex-wrap gap-x-4 w-full space-y-8\">\n <div className=\"relative w-full\">\n <Skeleton height={60} className=\"w-full rounded-md\" />\n </div>\n <div className=\"relative w-full\">\n <Skeleton height={60} className=\"w-full rounded-md\" />\n </div>\n <div className=\"relative w-full\">\n <Skeleton height={60} className=\"w-full rounded-md\" />\n </div>\n <div className=\"relative w-full\">\n <Skeleton height={60} className=\"w-full rounded-md\" />\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA6GA,SAAgB,kBAAqD,EACjE,UACA,GAAG,SACuB;CAE1B,MAAM,EACF,QACA,aACA,qBACA,SAAY;EACZ,MAAM,MAAM;EACF;EACV,YAAY,MAAM;EAElB,WAAW;EACX,UAAU;CACd,CAAC;CAED,IAAI,CAAC,eAAe,kBAChB,OAAO,oBAAC,cAAD,EAAA,UACH,oBAAC,WAAD,EAAW,OAAO,iBAAmB,CAAA,EAC3B,CAAA;CAGlB,IAAI,CAAC,eAAe,CAAC,QACjB,OAAO,oBAAC,cAAD,EAAA,UACH,oBAAC,YAAD;EAAY,SAAQ;YAAQ;CAA4B,CAAA,EAC9C,CAAA;CAGlB,MAAM,UACF,oBAAC,wBAAD;EACI,GAAI;EACM;EACF;EACK;CAChB,CAAA;CAGL,OACI,oBAAC,yBAAD;EAAyB,YAAY,MAAM;YACtC;CACoB,CAAA;AAEjC;AAEA,SAAS,uBAA0D,EAC/D,MACA,UACA,aAAa,iBACb,YACA,uBACA,iBACA,aACA,aACA,gBACA,QACA,aACA,SAAS,eACT,YACA,iBACA,cAID;CACC,MAAM,yBAAyB,qBAAqB,mBAAmB,qBAAqB;CAC5F,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,UAAU,iBAAiB;CACjC,MAAM,gBAAgB,iBAAiB;CACvC,MAAM,WAAW,YAAY;CAC7B,MAAM,0BAA0B,2BAA2B;CAC3D,MAAM,UAAU,wBAAwB;CACH,gCAAgC;CACrE,MAAM,EAAE,SAAS,gBA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AAC,OAAD;IAAK,WAAU;cAAf,CACI,qBAAC,OAAD;KAAK,WAAU;eAAf,CACI,oBAAC,OAAD;MAAK,WAAW,mBAAmB,WAAW,iBAAiB,SAAS;gBACpE,oBAAC,UAAD;OAAU,QAAQ;OAAI,WAAU;MAAqB,CAAA;KACpD,CAAA,GACL,oBAAC,UAAD;MAAU,QAAQ;MAAI,WAAU;KAAqB,CAAA,CACpD;QACL,oBAAC,OAAD;KAAK,WAAU;eACX,qBAAC,OAAD;MAAK,WAAU;gBAAf;OACI,oBAAC,OAAD;QAAK,WAAU;kBACX,oBAAC,UAAD;SAAU,QAAQ;SAAI,WAAU;QAAqB,CAAA;OACpD,CAAA;OACL,oBAAC,OAAD;QAAK,WAAU;kBACX,oBAAC,UAAD;SAAU,QAAQ;SAAI,WAAU;QAAqB,CAAA;OACpD,CAAA;OACL,oBAAC,OAAD;QAAK,WAAU;kBACX,oBAAC,UAAD;SAAU,QAAQ;SAAI,WAAU;QAAqB,CAAA;OACpD,CAAA;OACL,oBAAC,OAAD;QAAK,WAAU;kBACX,oBAAC,UAAD;SAAU,QAAQ;SAAI,WAAU;QAAqB,CAAA;OACpD,CAAA;MACJ;;IACJ,CAAA,CACJ;;EACJ,CAAA;CACJ,CAAA;AAEb"}
|
|
1
|
+
{"version":3,"file":"DetailViewBinding.js","names":[],"sources":["../../src/components/DetailViewBinding.tsx"],"sourcesContent":["import type { ComponentRef } from \"@rebasepro/types\";\nimport { hasEntityId } from \"@rebasepro/common\";\nimport type { EntityCustomViewParams, FormViewConfig, AdminCollection } from \"@rebasepro/cms-types\";\nimport type { FormContext } from \"../types/fields\";\nimport type { PluginFormActionProps } from \"@rebasepro/cms-types\";\nimport React, { lazy, Suspense, useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { Entity, EntityStatus, Property } from \"@rebasepro/types\";\nimport { PluginProviderStack, resolveComponentRef, useComponentOverride, CollectionScopeProvider, getAdminEntityChildViews } from \"@rebasepro/app\";\n\nimport { CollectionViewBinding } from \"./CollectionViewBinding/CollectionViewBinding\";\nimport { EntityViewBinding } from \"./EntityViewBinding\";\nimport { EntityIdentityBar } from \"./EntityIdentityBar\";\nimport { SplitListCloseButton } from \"./CollectionViewBinding/SplitListCloseButton\";\nimport { SplitListShowButton } from \"./CollectionViewBinding/SplitListShowButton\";\nimport { EntityInspector, InspectorTab } from \"./EntityInspector\";\nimport { CircularProgressCenter, iconSize } from \"@rebasepro/ui\";\nimport {\n Alert,\n Button,\n CenteredView,\n cls,\n CodeIcon,\n defaultBorderMixin,\n HistoryIcon,\n IconButton,\n Maximize2Icon,\n PencilIcon,\n Skeleton,\n Tab,\n Tabs,\n Tooltip,\n Typography\n} from \"@rebasepro/ui\";\nimport { ErrorBoundary } from \"@rebasepro/ui\";\nimport { ErrorView, createFormexStub, usePermissions, useTranslation, getIcon } from \"@rebasepro/app\";\n\nimport { removeInitialAndTrailingSlashes, resolveDefaultSelectedView } from \"@rebasepro/app\";\nimport { withListState } from \"../util/view_mode\";\nimport { resolvedSelectedEntityView } from \"../util/resolutions\";\nimport {\n useCustomizationController,\n useFetch,\n useRebaseContext,\n useLargeLayout,\n useSlot\n} from \"@rebasepro/app\";\nimport { useUrlController } from \"../hooks/navigation/contexts/UrlContext\";\nimport { useCollectionRegistryController } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useNavigate } from \"react-router\";\nimport { useEntityDisplayTitle } from \"../hooks/useEntityDisplayTitle\";\nimport { useAdminContext } from \"../hooks/useAdminContext\";\nimport { useLeaveRecord, useRecordActions } from \"../hooks/useRecordActions\";\n\n\nimport {\n MAIN_TAB_VALUE,\n JSON_TAB_VALUE,\n HISTORY_TAB_VALUE,\n ENTITY_VIEW_TAB_BAR_CLASS,\n ENTITY_VIEW_TAB_CLASS,\n ENTITY_VIEW_TAB_LABEL_CLASS\n} from \"../util/view_constants\";\n\nexport type BarActionsParams = {\n values: object,\n status: EntityStatus,\n path: string,\n entityId?: string | number;\n /** Always false here — this view reads a record, it does not edit one. */\n dirty: boolean;\n};\n\nexport type OnTabChangeParams<M extends Record<string, unknown>> = {\n path: string;\n entityId?: string | number;\n selectedTab?: string;\n collection: AdminCollection<M>;\n};\n\nexport interface DetailViewBindingProps<M extends Record<string, unknown> = Record<string, unknown>> {\n path: string;\n collection: AdminCollection<M>;\n entityId: string | number;\n selectedTab?: string;\n parentCollectionSlugs: string[];\n parentEntityIds: string[];\n onTabChange?: (props: OnTabChangeParams<M>) => void;\n onEditClick?: () => void;\n /**\n * Dismiss this record — the ✕ at the identity bar's trailing edge.\n *\n * Set by the layouts that own the record's place on screen but are not side\n * dialogs: the split, where dismissing is navigating back to the collection.\n */\n onCloseRequest?: () => void;\n layout?: \"side_panel\" | \"full_screen\" | \"split\" | \"dialog\";\n barActions?: (params: BarActionsParams) => React.ReactNode;\n /**\n * Controls the owning panel puts at the identity bar's leading edge, ahead\n * of the breadcrumb — the side panel's close button.\n */\n barActionsStart?: React.ReactNode;\n /**\n * Full screen only: bring the list back beside this record. Set when the\n * record was opened out of a split collection, so folding the list away is\n * reversible; it takes the place of the back arrow when present.\n */\n onShowList?: () => void;\n}\n\nexport function DetailViewBinding<M extends Record<string, unknown>>({\n entityId,\n ...props\n}: DetailViewBindingProps<M>) {\n\n const {\n entity,\n dataLoading,\n dataLoadingError\n } = useFetch<M>({\n path: props.path,\n entityId: entityId,\n collection: props.collection,\n // The relation fields' values, read with the record (see `useFetch`).\n relations: true,\n useCache: false\n });\n\n if (!dataLoading && dataLoadingError) {\n return <CenteredView>\n <ErrorView error={dataLoadingError} />\n </CenteredView>;\n }\n\n if (!dataLoading && !entity) {\n return <CenteredView>\n <Typography variant=\"label\">Entity not found</Typography>\n </CenteredView>;\n }\n\n const content = (\n <DetailViewBindingInner<M>\n {...props}\n entityId={entityId}\n entity={entity}\n dataLoading={dataLoading}\n />\n );\n\n return (\n <CollectionScopeProvider collection={props.collection}>\n {content}\n </CollectionScopeProvider>\n );\n}\n\nfunction DetailViewBindingInner<M extends Record<string, unknown>>({\n path,\n entityId,\n selectedTab: selectedTabProp,\n collection,\n parentCollectionSlugs,\n parentEntityIds,\n onTabChange,\n onEditClick,\n onCloseRequest,\n entity,\n dataLoading,\n layout = \"full_screen\",\n barActions,\n barActionsStart,\n onShowList\n}: DetailViewBindingProps<M> & {\n entity?: Entity<M>,\n dataLoading: boolean,\n}) {\n const ResolvedCollectionView = useComponentOverride(\"Collection.View\", CollectionViewBinding);\n const { t } = useTranslation();\n const context = useRebaseContext();\n const urlController = useUrlController();\n const navigate = useNavigate();\n const customizationController = useCustomizationController();\n const plugins = customizationController.plugins;\n const collectionRegistryController = useCollectionRegistryController();\n const { canEdit: canEditHook } = usePermissions();\n\n const canEdit = useMemo(() => {\n return entity ? canEditHook(collection, path, entity) : false;\n }, [canEditHook, entity, collection, path]);\n\n const [usedEntity, setUsedEntity] = useState<Entity<M> | undefined>(entity);\n useEffect(() => {\n if (entity) setUsedEntity(entity);\n }, [entity]);\n\n const defaultSelectedView = useMemo(() => resolveDefaultSelectedView(\n collection.defaultSelectedView,\n { status: \"existing\",\nentityId }\n ), [collection, entityId]);\n\n // Track whether the user has explicitly clicked a tab in this component\n // instance. See EditViewBindingInner for full explanation.\n const userHasChangedTab = useRef(false);\n\n const [selectedTab, setSelectedTab] = useState<string>(() => {\n const val = selectedTabProp ?? defaultSelectedView ?? MAIN_TAB_VALUE;\n return val === \"edit\" ? MAIN_TAB_VALUE : val;\n });\n useEffect(() => {\n const val = userHasChangedTab.current\n ? (selectedTabProp ?? MAIN_TAB_VALUE)\n : (selectedTabProp ?? defaultSelectedView ?? MAIN_TAB_VALUE);\n const target = val === \"edit\" ? MAIN_TAB_VALUE : val;\n if (target !== selectedTab) {\n setSelectedTab(target);\n }\n }, [selectedTabProp, defaultSelectedView]);\n\n // `hideFromEntityViews`, not `hideFromNavigation`: the latter governs the\n // drawer. Filtering tabs on it defeated the introspection generator, which\n // sets `hideFromNavigation` on owned-child tables precisely *because* \"every\n // inbound foreign key renders as a tab on the parent\" — so the rows it\n // deliberately kept out of the drawer became reachable from nowhere.\n const childViews = getAdminEntityChildViews(collection).filter(v => !v.collection.hideFromEntityViews);\n const subcollections = childViews.map(v => v.collection);\n const subcollectionsCount = subcollections?.length ?? 0;\n const customViews = collection.entityViews ?? [];\n const customViewsCount = customViews?.length ?? 0;\n const includeJsonView = collection.includeJsonView === undefined ? true : collection.includeJsonView;\n const includeHistoryView = Boolean(collection.history);\n // Same split as the edit view: the strip is for destinations, the inspector\n // for the developer tools that used to sit in front of them.\n const hasAdditionalViews = customViewsCount > 0 || subcollectionsCount > 0;\n\n const [inspectorTab, setInspectorTab] = useState<InspectorTab | null>(null);\n\n const legacyInspectorTab: InspectorTab | undefined = selectedTab === JSON_TAB_VALUE\n ? \"json\"\n : selectedTab === HISTORY_TAB_VALUE ? \"history\" : undefined;\n useEffect(() => {\n if (legacyInspectorTab) setInspectorTab(legacyInspectorTab);\n }, [legacyInspectorTab]);\n\n const {\n resolvedEntityViews\n } = resolvedSelectedEntityView(customViews, customizationController, undefined, canEdit);\n\n const validTabValues = useMemo(() => {\n const set = new Set<string>([\n MAIN_TAB_VALUE,\n ...resolvedEntityViews.map(v => v.key),\n ...subcollections.map(s => s.slug)\n ]);\n return set;\n }, [resolvedEntityViews, subcollections]);\n\n const activeTab = validTabValues.has(selectedTab) ? selectedTab : MAIN_TAB_VALUE;\n\n const {\n selectedEntityView\n } = resolvedSelectedEntityView(customViews, customizationController, activeTab, canEdit);\n\n const mainViewVisible = activeTab === MAIN_TAB_VALUE;\n\n // Track which custom view tabs have been visited\n const mountedTabsRef = useRef<Set<string>>(new Set());\n if (activeTab) {\n mountedTabsRef.current.add(activeTab);\n }\n\n // Read-only form context for custom entity views\n const readOnlyFormContext = useMemo<FormContext<M> | undefined>(() => {\n if (!hasEntityId(entityId)) return undefined;\n const formexStub = createFormexStub<M>(usedEntity?.values ?? {} as M);\n return {\n entityId,\n disabled: true,\n readOnly: true,\n openEntityMode: layout,\n status: \"existing\",\n values: usedEntity?.values ?? ({} as M),\n setFieldValue: () => {\n throw new Error(\"Cannot update values in read-only detail view\");\n },\n save: () => {\n throw new Error(\"Cannot save in read-only detail view\");\n },\n submit: () => {\n throw new Error(\"Cannot submit in read-only detail view\");\n },\n collection,\n path,\n entity: usedEntity,\n savingError: undefined,\n formex: formexStub\n };\n }, [entityId, layout, usedEntity, collection, path]);\n\n // Plugin slots\n const formActionTopProps: PluginFormActionProps = useMemo(() => ({\n entityId,\n parentCollectionSlugs,\n parentEntityIds,\n path,\n status: \"existing\",\n collection: collection!,\n context,\n formContext: readOnlyFormContext as FormContext<Record<string, unknown>> | undefined,\n openEntityMode: layout,\n disabled: true\n }), [entityId, parentCollectionSlugs, parentEntityIds, path, collection, context, readOnlyFormContext, layout]);\n const pluginActionsTop = useSlot(\"form.actions.top\", formActionTopProps);\n\n // The record's own actions, as on the edit view: a read-only record is\n // still one you can recalculate, resend or delete. There is no form here,\n // so they are called without a `formContext`.\n const adminContext = useAdminContext();\n const leaveRecord = useLeaveRecord({ layout, path, onCloseRequest });\n const recordActionClickProps = useMemo(() => usedEntity\n ? {\n view: \"form\" as const,\n entity: usedEntity as Entity<Record<string, unknown>>,\n path,\n collection: collection as AdminCollection,\n context,\n sidePanelController: adminContext.sidePanelController,\n openEntityMode: layout,\n navigateBack: leaveRecord\n }\n : undefined, [usedEntity, path, collection, context, adminContext.sidePanelController, layout, leaveRecord]);\n const recordActions = useRecordActions({\n collection,\n path,\n entity: usedEntity,\n clickProps: recordActionClickProps\n });\n\n // Resolve formView.Builder if provided\n const formViewConfig = (collection as AdminCollection<M> & { formView?: FormViewConfig<M> }).formView;\n const FormViewBuilder = formViewConfig?.Builder ? resolveComponentRef<EntityCustomViewParams>(formViewConfig.Builder as ComponentRef<EntityCustomViewParams>) : null;\n\n // The heading, resolved the one way — this used to be a copy of\n // `useEntityDisplayTitle`'s body, and the two had already drifted.\n const title = useEntityDisplayTitle({\n collection,\n entity: usedEntity,\n status: \"existing\"\n });\n\n // Non-action custom views\n const nonActionCustomViews = useMemo(() =>\n resolvedEntityViews.filter(e => !e.includeActions),\n [resolvedEntityViews]\n );\n\n const customViewsView = customViews && nonActionCustomViews\n .map((customView) => {\n if (!customView) return null;\n const Builder = resolveComponentRef<EntityCustomViewParams>(customView.Builder);\n if (!Builder) return null;\n if (!hasEntityId(entityId)) return null;\n\n const isActive = activeTab === customView.key;\n const hasBeenMounted = mountedTabsRef.current.has(customView.key);\n if (!isActive && !hasBeenMounted) return null;\n\n return <div\n className={cls(defaultBorderMixin,\n \"relative flex-1 w-full h-full overflow-auto\",\n { \"hidden\": !isActive }\n )}\n key={`custom_view_${customView.key}`}\n role=\"tabpanel\">\n <ErrorBoundary>\n <Suspense fallback={<CircularProgressCenter />}>\n {readOnlyFormContext && <Builder\n collection={collection}\n parentCollectionSlugs={parentCollectionSlugs}\n parentEntityIds={parentEntityIds}\n entity={usedEntity}\n modifiedValues={usedEntity?.values}\n formContext={readOnlyFormContext as FormContext<Record<string, unknown>>}\n />}\n </Suspense>\n </ErrorBoundary>\n </div>;\n }).filter(Boolean);\n\n const globalLoading = dataLoading && !usedEntity;\n\n // Subcollection views\n const subCollectionsViews = childViews && childViews.map(({ collection: subcollection }) => {\n const subcollectionId = subcollection.slug;\n // By slug, like the path it extends: the data layer hands the driver\n // the stored path, `path` included, for the whole of it at once.\n const newFullPath = usedEntity ? `${path}/${usedEntity?.id}/${removeInitialAndTrailingSlashes(subcollection.slug)}` : undefined;\n\n if (activeTab !== subcollectionId) return null;\n return (\n <div\n className={\"relative flex-1 h-full overflow-auto w-full\"}\n key={`subcol_${subcollectionId}`}\n role=\"tabpanel\">\n {globalLoading && <CircularProgressCenter />}\n {!globalLoading &&\n (usedEntity && newFullPath\n ? <ResolvedCollectionView\n path={newFullPath}\n parentCollectionSlugs={[...parentCollectionSlugs, collection.slug]}\n parentEntityIds={[...parentEntityIds, String(usedEntity?.id)]}\n updateUrl={false}\n {...subcollection}\n openEntityMode={layout} />\n : <div className=\"flex items-center justify-center w-full h-full p-3\">\n <Typography variant={\"label\"}>\n {/* No `?? \"…\"` here: `t` returns the key itself\n when it cannot find one, never null, so the\n fallback never ran and this rendered the raw\n `save_entity_before_subcollections`. The key\n exists now, in all seven locales. */}\n {t(\"save_entity_before_subcollections\")}\n </Typography>\n </div>)\n }\n </div>\n );\n }).filter(Boolean);\n\n const onSideTabClick = useCallback((value: string) => {\n userHasChangedTab.current = true;\n setSelectedTab(value);\n onTabChange?.({\n path,\n entityId,\n selectedTab: value === MAIN_TAB_VALUE ? undefined : value,\n collection\n });\n }, [onTabChange, path, entityId, collection]);\n\n const propertyDetailView = () => {\n // formView.Builder replaces the default property display. It gets the\n // centred column the record used to be given here; the default display\n // now lays itself out, rail included.\n if (FormViewBuilder && usedEntity) {\n return <div className={\"@container/form flex-1 min-w-0 overflow-y-auto flex justify-center items-start\"}>\n <div className={cls(\n // Same widths as the default form (see EntityForm).\n \"w-full max-w-3xl @7xl/form:max-w-4xl 2xl:max-w-4xl flex flex-col\",\n layout === \"dialog\"\n ? \"pt-5 pb-12 px-6 sm:px-8\"\n : \"pt-6 pb-16 px-5 sm:px-8\"\n )}>\n <ErrorBoundary>\n <Suspense fallback={<CircularProgressCenter />}>\n <FormViewBuilder\n collection={collection}\n parentCollectionSlugs={parentCollectionSlugs}\n parentEntityIds={parentEntityIds}\n entity={usedEntity}\n modifiedValues={usedEntity?.values}\n formContext={readOnlyFormContext as FormContext<Record<string, unknown>>}\n />\n </Suspense>\n </ErrorBoundary>\n </div>\n </div>;\n }\n\n return (\n <>\n {usedEntity && <EntityViewBinding\n entity={usedEntity}\n collection={collection}\n path={path}\n asPage\n openEntityMode={layout}\n formContext={readOnlyFormContext}\n />}\n </>\n );\n };\n\n // Tabs\n const subcollectionTabs = subcollections && subcollections.map((subcollection) => {\n const icon = getIcon(subcollection.icon, undefined, undefined, \"smallest\");\n return (\n <Tab\n className={cls(ENTITY_VIEW_TAB_CLASS, ENTITY_VIEW_TAB_LABEL_CLASS)}\n value={subcollection.slug}\n key={`entity_detail_collection_tab_${subcollection.name}`}>\n <span className=\"flex items-center gap-1.5\">\n {icon}\n {subcollection.name}\n </span>\n </Tab>\n );\n });\n\n const customViewTabsStart = resolvedEntityViews.filter(view => view.position === \"start\")\n .map((view) => {\n const icon = getIcon(view.icon, undefined, undefined, \"smallest\");\n return (\n <Tab\n className={cls(ENTITY_VIEW_TAB_CLASS, !view.tabComponent && ENTITY_VIEW_TAB_LABEL_CLASS)}\n value={view.key}\n key={`entity_detail_collection_tab_${view.name}`}>\n {view.tabComponent ?? (\n <span className=\"flex items-center gap-1.5\">\n {icon}\n {view.name}\n </span>\n )}\n </Tab>\n );\n });\n const customViewTabsEnd = resolvedEntityViews.filter(view => !view.position || view.position === \"end\")\n .map((view) => {\n const icon = getIcon(view.icon, undefined, undefined, \"smallest\");\n return (\n <Tab\n className={cls(ENTITY_VIEW_TAB_CLASS, !view.tabComponent && ENTITY_VIEW_TAB_LABEL_CLASS)}\n value={view.key}\n key={`entity_detail_collection_tab_${view.name}`}>\n {view.tabComponent ?? (\n <span className=\"flex items-center gap-1.5\">\n {icon}\n {view.name}\n </span>\n )}\n </Tab>\n );\n });\n\n // The breadcrumb's destination, and the back arrow's when it renders. Both\n // keep the list's whole URL state: a collection reached from one of its own\n // records must come back as the user left it — the same view mode, search,\n // filters and sort.\n const collectionUrl = withListState(urlController.buildUrlCollectionPath(path));\n\n // Full screen is the one layout with no way out of its own: a side panel and a\n // dialog can be dismissed, and a split keeps the list beside it, but opening an\n // entity full screen replaces the collection entirely and left browser Back as\n // the only route back to it — which is not an affordance the page shows, and is\n // wrong anyway once the user has moved between tabs inside the entity.\n //\n // Unless the list can be unfolded back beside the record: that chevron\n // leads to the same collection while keeping the record open, so it stands\n // alone rather than beside an arrow going almost the same place.\n //\n // It goes to the bar's leading edge — where a back control reads as back,\n // and where the edit view has always put the same arrow — rather than to\n // the trailing edge among the record's own actions.\n const backToCollection = layout === \"full_screen\" && !onShowList\n ? () => navigate(collectionUrl)\n : undefined;\n\n const fullScreenButton = !barActions && // Not in split: the list panel beside it carries the close control,\n // and an expand button there competes with it.\n (layout === \"side_panel\" || layout === \"dialog\") && hasEntityId(entityId) ? (\n <Tooltip title={\"Open full screen\"}>\n <IconButton aria-label={\"Open full screen\"}\n size=\"small\"\n onClick={() => {\n const entityUrl = urlController.buildUrlCollectionPath(`${path}/${entityId}`);\n navigate(`${entityUrl}#full`);\n }}\n >\n <Maximize2Icon size={iconSize.smallest} />\n </IconButton>\n </Tooltip>\n ) : null;\n\n // Edit button — only rendered when the user has edit permissions\n const editButton = canEdit && onEditClick ? (\n <Button\n variant=\"filled\"\n color=\"primary\"\n size=\"small\"\n startIcon={<PencilIcon size={iconSize.smallest} />}\n onClick={onEditClick}>\n {t(\"edit_entity\")}\n </Button>\n ) : null;\n\n // Main content view. The title, the `path/id` chip and the empty band under\n // them have moved into the identity bar, and the `w-80 2xl:w-96` rail that\n // held a single Edit button is gone — the bar holds it now.\n //\n // The scroll now lives on the record's own column rather than on this row,\n // so the metadata rail beside it stays put while the record scrolls — the\n // same arrangement the form uses.\n const mainView = <div\n className={cls(\n \"flex-1 flex flex-row w-full min-h-0\",\n !mainViewVisible ? \"hidden\" : \"\"\n )}>\n {propertyDetailView()}\n </div>;\n\n let result = <div className=\"relative flex flex-col h-full w-full bg-surface-card\">\n\n <EntityIdentityBar\n collection={collection as AdminCollection}\n collectionUrl={layout === \"full_screen\" || layout === \"split\" ? collectionUrl : undefined}\n title={title}\n entityId={entityId}\n status={\"existing\"}\n dirty={false}\n saving={false}\n onBack={backToCollection}\n onClose={onCloseRequest}\n onInspect={includeJsonView ? () => setInspectorTab(\"json\") : undefined}\n onViewHistory={includeHistoryView ? () => setInspectorTab(\"history\") : undefined}\n externalLink={usedEntity\n ? customizationController?.entityLinkBuilder?.({ entity: usedEntity })\n : undefined}\n recordActions={recordActions}\n // Where Save stands on the edit view: after the record's own\n // buttons, ahead of the menu.\n primaryAction={editButton}\n leading={<>\n {barActionsStart}\n {/* Split view: closing the list is opening this record\n full screen, and the control for it belongs at this\n bar's leading edge. Full screen carries its mirror. */}\n {layout === \"split\" && <SplitListCloseButton/>}\n {layout === \"full_screen\" && onShowList && <SplitListShowButton onClick={onShowList}/>}\n </>}\n trailing={<>\n {pluginActionsTop}\n {fullScreenButton}\n {barActions?.({\n path,\n entityId,\n values: usedEntity?.values ?? {},\n status: \"existing\",\n dirty: false\n })}\n </>}\n />\n\n {hasAdditionalViews && <div className={cls(\n \"h-10 shrink-0 flex items-stretch border-b px-2 min-w-0\",\n ENTITY_VIEW_TAB_BAR_CLASS,\n defaultBorderMixin\n )}>\n <Tabs\n className={\"!w-full items-stretch\"}\n innerClassName={\"h-full\"}\n variant={\"boxy\"}\n value={activeTab}\n onValueChange={(value) => {\n onSideTabClick(value);\n }}>\n\n {/* Before the record, not after it.\n\n `position: \"start\"` used to mean \"first among the custom\n views\", which put it after a tab it was already after: the\n record's own tab is drawn here unconditionally, so \"start\"\n and \"end\" only ever ordered the custom views against each\n other, and no collection could open with anything but the\n form on the left.\n\n A cover — a read-only summary of the record, the thing an\n operator opens a row to see — belongs in front of the form\n that edits it. That is what `defaultSelectedView` already\n allowed, and the strip contradicted it by drawing the\n selected tab second. Views that say nothing still land after\n the record, so nothing moves for a collection that never\n asked. */}\n {customViewTabsStart}\n\n <Tab value={MAIN_TAB_VALUE}\n className={cls(ENTITY_VIEW_TAB_CLASS, ENTITY_VIEW_TAB_LABEL_CLASS)}>\n <span className=\"flex items-center gap-1.5\">\n {getIcon(collection.icon, undefined, undefined, \"smallest\")}\n {collection.singularName ?? collection.name}\n </span>\n </Tab>\n\n {customViewTabsEnd}\n {subcollectionTabs}\n </Tabs>\n </div>}\n\n {/* See EditViewBinding: the inspector docks beside the record rather\n than over it, so the record stays readable and scrollable. */}\n <div className={\"flex-1 min-h-0 flex\"}>\n\n <div className={\"flex-1 min-w-0 flex flex-col\"}>\n {globalLoading\n ? <DetailViewSkeleton collection={collection} />\n : mainView}\n\n {customViewsView}\n {subCollectionsViews}\n </div>\n\n <EntityInspector\n tab={inspectorTab}\n onTabChange={setInspectorTab}\n onClose={() => setInspectorTab(null)}\n collection={collection as AdminCollection}\n entity={usedEntity as Entity<Record<string, unknown>> | undefined}\n formContext={readOnlyFormContext as FormContext<Record<string, unknown>> | undefined}\n values={usedEntity?.values}\n includeHistory={includeHistoryView}/>\n </div>\n\n </div>;\n\n if (plugins && plugins.length > 0) {\n result = (\n <PluginProviderStack\n plugins={plugins}\n scope=\"form\"\n scopeProps={{\n status: \"existing\",\n path,\n collection,\n entity: usedEntity,\n context,\n formContext: readOnlyFormContext\n }}>\n {result}\n </PluginProviderStack>\n );\n }\n\n return result;\n}\n\nfunction DetailViewSkeleton({ collection }: { collection: AdminCollection<Record<string, unknown>> }) {\n return (\n <div className=\"flex-1 flex flex-row w-full overflow-y-auto justify-center\">\n <div className=\"relative flex flex-row max-w-4xl lg:max-w-3xl xl:max-w-4xl 2xl:max-w-6xl w-full h-fit\">\n <div className=\"flex flex-col w-full pt-12 pb-16 px-4 sm:px-8 md:px-10\">\n <div className=\"w-full flex flex-col items-start my-4 lg:my-6\">\n <div className={`py-1 my-4 w-2/3 ${collection.hideIdFromForm ? \"mb-6\" : \"\"}`}>\n <Skeleton height={28} className=\"w-full rounded-md\" />\n </div>\n <Skeleton height={32} className=\"w-full rounded-md\" />\n </div>\n <div className=\"mt-12 flex flex-col gap-8\">\n <div className=\"flex flex-wrap gap-x-4 w-full space-y-8\">\n <div className=\"relative w-full\">\n <Skeleton height={60} className=\"w-full rounded-md\" />\n </div>\n <div className=\"relative w-full\">\n <Skeleton height={60} className=\"w-full rounded-md\" />\n </div>\n <div className=\"relative w-full\">\n <Skeleton height={60} className=\"w-full rounded-md\" />\n </div>\n <div className=\"relative w-full\">\n <Skeleton height={60} className=\"w-full rounded-md\" />\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA8GA,SAAgB,kBAA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OAAD;MAAK,WAAU;gBAAf;OACI,oBAAC,OAAD;QAAK,WAAU;kBACX,oBAAC,UAAD;SAAU,QAAQ;SAAI,WAAU;QAAqB,CAAA;OACpD,CAAA;OACL,oBAAC,OAAD;QAAK,WAAU;kBACX,oBAAC,UAAD;SAAU,QAAQ;SAAI,WAAU;QAAqB,CAAA;OACpD,CAAA;OACL,oBAAC,OAAD;QAAK,WAAU;kBACX,oBAAC,UAAD;SAAU,QAAQ;SAAI,WAAU;QAAqB,CAAA;OACpD,CAAA;OACL,oBAAC,OAAD;QAAK,WAAU;kBACX,oBAAC,UAAD;SAAU,QAAQ;SAAI,WAAU;QAAqB,CAAA;OACpD,CAAA;MACJ;;IACJ,CAAA,CACJ;;EACJ,CAAA;CACJ,CAAA;AAEb"}
|
|
@@ -20,6 +20,7 @@ import { CollectionViewBinding } from "./CollectionViewBinding/CollectionViewBin
|
|
|
20
20
|
import { Suspense, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
21
21
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
22
22
|
import { Alert, Button, CenteredView, CircularProgressCenter, DialogActions, ErrorBoundary, IconButton, Maximize2Icon, Skeleton, Tab, Tabs, Tooltip, Typography, cls, defaultBorderMixin, iconSize } from "@rebasepro/ui";
|
|
23
|
+
import { hasEntityId } from "@rebasepro/common";
|
|
23
24
|
import { CollectionScopeProvider, ErrorView, PluginProviderStack, createFormexStub, getAdminEntityChildViews, getEntityFromMemoryCache, getIcon, removeEntityFromMemoryCache, removeInitialAndTrailingSlashes, resolveComponentRef, resolveDefaultSelectedView, saveEntityToMemoryCache, useComponentOverride, useCustomizationController, useFetch, useLargeLayout, usePermissions, useRebaseContext, useSlot, useTranslation } from "@rebasepro/app";
|
|
24
25
|
import { Link, useNavigate } from "react-router";
|
|
25
26
|
//#region src/components/EditViewBinding.tsx
|
|
@@ -50,7 +51,7 @@ function EditViewBinding({ entityId, ...props }) {
|
|
|
50
51
|
const { canEdit: canEditHook } = usePermissions();
|
|
51
52
|
const { t } = useTranslation();
|
|
52
53
|
const urlController = useUrlController();
|
|
53
|
-
const [status, setStatus] = useState(props.copy ? "copy" : entityId ? "existing" : "new");
|
|
54
|
+
const [status, setStatus] = useState(props.copy ? "copy" : hasEntityId(entityId) ? "existing" : "new");
|
|
54
55
|
const [lastSeenEntity, setLastSeenEntity] = useState(void 0);
|
|
55
56
|
useEffect(() => {
|
|
56
57
|
if (entity) setLastSeenEntity(entity);
|
|
@@ -68,7 +69,24 @@ function EditViewBinding({ entityId, ...props }) {
|
|
|
68
69
|
props.path
|
|
69
70
|
]);
|
|
70
71
|
if (!dataLoading && dataLoadingError) return /* @__PURE__ */ jsx(CenteredView, { children: /* @__PURE__ */ jsx(ErrorView, { error: dataLoadingError }) });
|
|
71
|
-
|
|
72
|
+
/**
|
|
73
|
+
* There is no id, so there is no record that could have been missing.
|
|
74
|
+
*
|
|
75
|
+
* The branch below answers "the record this URL names is not there", and
|
|
76
|
+
* with no id nothing is named. Without this it fired on every successful
|
|
77
|
+
* *create*: `EntityFormBinding` sets `status` to `"existing"` the moment a
|
|
78
|
+
* save lands, and the `entityId` prop arrives one render later from the
|
|
79
|
+
* URL, so for one frame the component reported a record with no id as
|
|
80
|
+
* missing — `Entity with id undefined not found in collection posts`,
|
|
81
|
+
* twice under StrictMode, beside a "Saved successfully" toast, with
|
|
82
|
+
* "Entity not found" flashed over the record that had just been created.
|
|
83
|
+
*
|
|
84
|
+
* Written against the id rather than against `status === "existing"`
|
|
85
|
+
* because the same thing is true of a copy in flight, and because "we have
|
|
86
|
+
* nothing to look up" is the actual reason.
|
|
87
|
+
*/
|
|
88
|
+
const nothingToLookUp = !hasEntityId(entityId);
|
|
89
|
+
if (!dataLoading && !initialDirtyValues && !entity && !nothingToLookUp && !deletedElsewhere && (status === "existing" || status === "copy")) {
|
|
72
90
|
console.warn(`Entity with id ${entityId} not found in collection ${props.path}`);
|
|
73
91
|
return /* @__PURE__ */ jsx(CenteredView, { children: /* @__PURE__ */ jsxs("div", {
|
|
74
92
|
className: "flex flex-col items-center gap-2 text-center",
|
|
@@ -202,7 +220,7 @@ function EditViewBindingInner({ path, entityId, selectedTab: selectedTabProp, co
|
|
|
202
220
|
* default rendering, and `additionalFields` vanished from the default one.
|
|
203
221
|
*/
|
|
204
222
|
const readOnlyFormContext = useMemo(() => {
|
|
205
|
-
if (!entityId) return void 0;
|
|
223
|
+
if (!hasEntityId(entityId)) return void 0;
|
|
206
224
|
const formexStub = createFormexStub(usedEntity?.values ?? {});
|
|
207
225
|
return {
|
|
208
226
|
entityId,
|
|
@@ -242,7 +260,7 @@ function EditViewBindingInner({ path, entityId, selectedTab: selectedTabProp, co
|
|
|
242
260
|
console.error("INTERNAL: customView.Builder is not defined or could not be resolved");
|
|
243
261
|
return null;
|
|
244
262
|
}
|
|
245
|
-
if (!entityId) return null;
|
|
263
|
+
if (!hasEntityId(entityId)) return null;
|
|
246
264
|
const isActive = activeTab === customView.key;
|
|
247
265
|
const hasBeenMounted = mountedTabsRef.current.has(customView.key);
|
|
248
266
|
if (!isActive && !hasBeenMounted) return null;
|
|
@@ -592,7 +610,7 @@ function EditViewBindingInner({ path, entityId, selectedTab: selectedTabProp, co
|
|
|
592
610
|
* stays in view while a long form scrolls.
|
|
593
611
|
*/
|
|
594
612
|
const actionsInFooter = layout === "dialog";
|
|
595
|
-
const fullScreenButton = !barActions && (layout === "side_panel" || layout === "dialog") && entityId ? /* @__PURE__ */ jsx(Tooltip, {
|
|
613
|
+
const fullScreenButton = !barActions && (layout === "side_panel" || layout === "dialog") && hasEntityId(entityId) ? /* @__PURE__ */ jsx(Tooltip, {
|
|
596
614
|
title: "Open full screen",
|
|
597
615
|
children: /* @__PURE__ */ jsx(IconButton, {
|
|
598
616
|
"aria-label": "Open full screen",
|