From 5181356bef02d474c6189241fca189224814540a Mon Sep 17 00:00:00 2001 From: Marco Beretta <81851188+berry-13@users.noreply.github.com> Date: Sun, 28 Dec 2025 17:01:25 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=AA=84=20refactor:=20UI=20Polish=20and=20?= =?UTF-8?q?Admin=20Dialog=20Unification=20(#11108)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor(OpenSidebar): removed useless classNames * style(Header): update hover styles across various components for improved UI consistency * style(Nav): update hover styles in AccountSettings and SearchBar for improved UI consistency * style: update button classes for consistent hover effects and improved UI responsiveness * style(Nav, OpenSidebar, Header, Convo): improve UI responsiveness and animation transitions * style(PresetsMenu, NewChat): update icon sizes and improve component styling for better UI consistency * style(Nav, Root): enhance sidebar mobile animations and responsiveness for better UI experience * style(ExportAndShareMenu, BookmarkMenu): update icon sizes for improved UI consistency * style: remove transition duration from button classes for improved UI responsiveness * style(CustomMenu, ModelSelector): update background colors for improved UI consistency and responsiveness * style(ExportAndShareMenu): update icon color for improved UI consistency * style(TemporaryChat): refine button styles for improved UI consistency and responsiveness * style(BookmarkNav): refactor to use DropdownPopup and remove BookmarkNavItems for improved UI consistency and functionality * style(CustomMenu, EndpointItem): enhance UI elements for improved consistency and accessibility * style(EndpointItem): adjust gap in icon container for improved layout consistency * style(CustomMenu, EndpointItem): update focus ring color for improved UI consistency * style(EndpointItem): update icon color for improved UI consistency in dark theme * style: update focus styles for improved accessibility and consistency across components * refactor(Nav): extract sidebar width to NAV_WIDTH constant Centralize mobile (320px) and desktop (260px) sidebar widths in a single exported constant to avoid magic numbers and ensure consistency. * fix(BookmarkNav): memoize handlers used in useMemo Wrap handleTagClick and handleClear in useCallback and add them to the dropdownItems useMemo dependency array to prevent stale closures. * feat: introduce FilterInput component and replace existing inputs with it across multiple components * feat(DataTable): replace custom input with FilterInput component for improved filtering * fix: Nested dialog overlay stacking issue Fixes overlay appearing behind content when opening nested dialogs. Introduced dynamic z-index calculation based on dialog depth using React context. - First dialog: overlay z-50, content z-100 - Nested dialogs increment by 60: overlay z-110/content z-160, etc. Preserves a11y escape key handling from #10975 and #10851. Regression from #11008 (afb67fcf1) which increased content z-index without adjusting overlay z-index for nested dialog scenarios. * Refactor admin settings components to use a unified AdminSettingsDialog - Removed redundant code from AdminSettings, MCPAdminSettings, and Memories AdminSettings components. - Introduced AdminSettingsDialog component to handle permission management for different sections. - Updated permission handling logic to use a consistent structure across components. - Enhanced role selection and permission confirmation features in the new dialog. - Improved UI consistency and maintainability by centralizing dialog functionality. * refactor(Memory): memory management UI components and replace MemoryViewer with MemoryPanel * refactor(Memory): enhance UI components for Memory dialogs and improve input styling * refactor(Bookmarks): improve bookmark management UI with enhanced styling * refactor(translations): remove redundant filter input and bookmark count entries * refactor(Convo): integrate useShiftKey hook for enhanced keyboard interaction and improve UI responsiveness --- client/src/components/Agents/Marketplace.tsx | 2 +- .../Agents/MarketplaceAdminSettings.tsx | 219 ++------- .../Bookmarks/BookmarkEditDialog.tsx | 2 +- .../src/components/Bookmarks/BookmarkForm.tsx | 45 +- .../components/Chat/ExportAndShareMenu.tsx | 2 +- client/src/components/Chat/Header.tsx | 8 +- .../Chat/Input/Files/AttachFile.tsx | 2 +- .../Chat/Input/Files/AttachFileMenu.tsx | 2 +- .../Chat/Input/Files/Table/DataTable.tsx | 27 +- .../components/Chat/Input/ToolsDropdown.tsx | 2 +- .../components/Chat/Menus/BookmarkMenu.tsx | 4 +- .../Chat/Menus/Endpoints/CustomMenu.tsx | 14 +- .../Chat/Menus/Endpoints/ModelSelector.tsx | 2 +- .../Endpoints/components/EndpointItem.tsx | 134 +++--- .../components/Chat/Menus/HeaderNewChat.tsx | 2 +- .../src/components/Chat/Menus/OpenSidebar.tsx | 16 +- .../src/components/Chat/Menus/PresetsMenu.tsx | 26 +- .../src/components/Chat/Messages/Feedback.tsx | 2 +- client/src/components/Chat/Messages/Fork.tsx | 2 +- .../components/Chat/Messages/HoverButtons.tsx | 2 +- .../Chat/Messages/SiblingSwitch.tsx | 2 +- client/src/components/Chat/TemporaryChat.tsx | 20 +- client/src/components/Conversations/Convo.tsx | 23 +- .../ConvoOptions/ConvoOptions.tsx | 166 +++++-- client/src/components/Nav/AccountSettings.tsx | 4 +- .../components/Nav/Bookmarks/BookmarkNav.tsx | 147 ++++-- .../Nav/Bookmarks/BookmarkNavItems.tsx | 76 --- client/src/components/Nav/MobileNav.tsx | 6 +- client/src/components/Nav/Nav.tsx | 177 ++++--- client/src/components/Nav/NewChat.tsx | 6 +- client/src/components/Nav/SearchBar.tsx | 2 +- client/src/components/Nav/index.ts | 2 +- .../src/components/Prompts/AdminSettings.tsx | 309 +++---------- .../Prompts/Groups/FilterPrompts.tsx | 11 +- .../Sharing/GenericGrantAccessDialog.tsx | 5 +- .../SidePanel/Agents/AdminSettings.tsx | 233 +--------- .../SidePanel/Bookmarks/BookmarkCard.tsx | 111 +++++ .../Bookmarks/BookmarkCardActions.tsx | 118 +++++ .../Bookmarks/BookmarkEmptyState.tsx | 21 + .../SidePanel/Bookmarks/BookmarkList.tsx | 32 ++ .../SidePanel/Bookmarks/BookmarkTable.tsx | 150 +++--- .../SidePanel/Bookmarks/BookmarkTableRow.tsx | 90 ---- .../components/SidePanel/Bookmarks/index.ts | 6 + .../components/SidePanel/Files/PanelTable.tsx | 30 +- .../SidePanel/MCPBuilder/MCPAdminSettings.tsx | 232 +--------- .../SidePanel/MCPBuilder/MCPBuilderPanel.tsx | 20 +- .../SidePanel/Memories/AdminSettings.tsx | 223 +-------- .../SidePanel/Memories/MemoryCard.tsx | 57 +++ .../SidePanel/Memories/MemoryCardActions.tsx | 124 +++++ .../SidePanel/Memories/MemoryCreateDialog.tsx | 11 +- .../SidePanel/Memories/MemoryEditDialog.tsx | 88 ++-- .../SidePanel/Memories/MemoryEmptyState.tsx | 28 ++ .../SidePanel/Memories/MemoryList.tsx | 32 ++ .../SidePanel/Memories/MemoryPanel.tsx | 229 +++++++++ .../SidePanel/Memories/MemoryUsageBadge.tsx | 63 +++ .../SidePanel/Memories/MemoryViewer.tsx | 434 ------------------ .../components/SidePanel/Memories/index.ts | 10 +- .../src/components/ui/AdminSettingsDialog.tsx | 275 +++++++++++ client/src/components/ui/index.ts | 2 + client/src/hooks/Generic/index.ts | 1 + client/src/hooks/Generic/useShiftKey.ts | 47 ++ client/src/hooks/Nav/useSideNavLinks.ts | 4 +- client/src/locales/en/translation.json | 17 +- client/src/routes/Root.tsx | 18 +- package-lock.json | 2 +- packages/client/package.json | 2 +- .../client/src/components/DropdownPopup.tsx | 4 +- .../client/src/components/FilterInput.tsx | 54 +++ packages/client/src/components/Input.tsx | 2 +- .../client/src/components/OriginalDialog.tsx | 64 ++- packages/client/src/components/index.ts | 1 + 71 files changed, 2115 insertions(+), 2191 deletions(-) delete mode 100644 client/src/components/Nav/Bookmarks/BookmarkNavItems.tsx create mode 100644 client/src/components/SidePanel/Bookmarks/BookmarkCard.tsx create mode 100644 client/src/components/SidePanel/Bookmarks/BookmarkCardActions.tsx create mode 100644 client/src/components/SidePanel/Bookmarks/BookmarkEmptyState.tsx create mode 100644 client/src/components/SidePanel/Bookmarks/BookmarkList.tsx delete mode 100644 client/src/components/SidePanel/Bookmarks/BookmarkTableRow.tsx create mode 100644 client/src/components/SidePanel/Bookmarks/index.ts create mode 100644 client/src/components/SidePanel/Memories/MemoryCard.tsx create mode 100644 client/src/components/SidePanel/Memories/MemoryCardActions.tsx create mode 100644 client/src/components/SidePanel/Memories/MemoryEmptyState.tsx create mode 100644 client/src/components/SidePanel/Memories/MemoryList.tsx create mode 100644 client/src/components/SidePanel/Memories/MemoryPanel.tsx create mode 100644 client/src/components/SidePanel/Memories/MemoryUsageBadge.tsx delete mode 100644 client/src/components/SidePanel/Memories/MemoryViewer.tsx create mode 100644 client/src/components/ui/AdminSettingsDialog.tsx create mode 100644 client/src/hooks/Generic/useShiftKey.ts create mode 100644 packages/client/src/components/FilterInput.tsx diff --git a/client/src/components/Agents/Marketplace.tsx b/client/src/components/Agents/Marketplace.tsx index 899bb4f020..69db9fc630 100644 --- a/client/src/components/Agents/Marketplace.tsx +++ b/client/src/components/Agents/Marketplace.tsx @@ -268,7 +268,7 @@ const AgentMarketplace: React.FC = ({ className = '' }) = variant="outline" data-testid="agents-new-chat-button" aria-label={localize('com_ui_new_chat')} - className="rounded-xl border border-border-light bg-surface-secondary p-2 hover:bg-surface-hover max-md:hidden" + className="rounded-xl border border-border-light bg-surface-secondary p-2 hover:bg-surface-active-alt max-md:hidden" onClick={handleNewChat} > diff --git a/client/src/components/Agents/MarketplaceAdminSettings.tsx b/client/src/components/Agents/MarketplaceAdminSettings.tsx index 7c1a29d0fb..c3d7dedda3 100644 --- a/client/src/components/Agents/MarketplaceAdminSettings.tsx +++ b/client/src/components/Agents/MarketplaceAdminSettings.tsx @@ -1,75 +1,20 @@ -import { useMemo, useEffect, useState } from 'react'; -import * as Ariakit from '@ariakit/react'; import { ShieldEllipsis } from 'lucide-react'; -import { useForm, Controller } from 'react-hook-form'; -import { Permissions, SystemRoles, roleDefaults, PermissionTypes } from 'librechat-data-provider'; -import { - Button, - Switch, - OGDialog, - DropdownPopup, - OGDialogTitle, - OGDialogContent, - OGDialogTrigger, - useToastContext, -} from '@librechat/client'; -import type { Control, UseFormSetValue, UseFormGetValues } from 'react-hook-form'; +import { Permissions, PermissionTypes } from 'librechat-data-provider'; +import { Button, useToastContext } from '@librechat/client'; +import { AdminSettingsDialog } from '~/components/ui'; import { useUpdateMarketplacePermissionsMutation } from '~/data-provider'; -import { useLocalize, useAuthContext } from '~/hooks'; +import { useLocalize } from '~/hooks'; +import type { PermissionConfig } from '~/components/ui'; -type FormValues = { - [Permissions.USE]: boolean; -}; - -type LabelControllerProps = { - label: string; - marketplacePerm: Permissions.USE; - control: Control; - setValue: UseFormSetValue; - getValues: UseFormGetValues; -}; - -const LabelController: React.FC = ({ - control, - marketplacePerm, - label, - getValues, - setValue, -}) => ( -
- - ( - - )} - /> -
-); +const permissions: PermissionConfig[] = [ + { permission: Permissions.USE, labelKey: 'com_ui_marketplace_allow_use' }, +]; const MarketplaceAdminSettings = () => { const localize = useLocalize(); const { showToast } = useToastContext(); - const { user, roles } = useAuthContext(); - const { mutate, isLoading } = useUpdateMarketplacePermissionsMutation({ + + const mutation = useUpdateMarketplacePermissionsMutation({ onSuccess: () => { showToast({ status: 'success', message: localize('com_ui_saved') }); }, @@ -78,133 +23,27 @@ const MarketplaceAdminSettings = () => { }, }); - const [isRoleMenuOpen, setIsRoleMenuOpen] = useState(false); - const [selectedRole, setSelectedRole] = useState(SystemRoles.USER); - - const defaultValues = useMemo(() => { - const rolePerms = roles?.[selectedRole]?.permissions; - if (rolePerms) { - return rolePerms[PermissionTypes.MARKETPLACE]; - } - return roleDefaults[selectedRole].permissions[PermissionTypes.MARKETPLACE]; - }, [roles, selectedRole]); - - const { - reset, - control, - setValue, - getValues, - handleSubmit, - formState: { isSubmitting }, - } = useForm({ - mode: 'onChange', - defaultValues, - }); - - useEffect(() => { - const value = roles?.[selectedRole]?.permissions?.[PermissionTypes.MARKETPLACE]; - if (value) { - reset(value); - } else { - reset(roleDefaults[selectedRole].permissions[PermissionTypes.MARKETPLACE]); - } - }, [roles, selectedRole, reset]); - - if (user?.role !== SystemRoles.ADMIN) { - return null; - } - - const labelControllerData: { - marketplacePerm: Permissions.USE; - label: string; - }[] = [ - { - marketplacePerm: Permissions.USE, - label: localize('com_ui_marketplace_allow_use'), - }, - ]; - - const onSubmit = (data: FormValues) => { - mutate({ roleName: selectedRole, updates: data }); - }; - - const roleDropdownItems = [ - { - label: SystemRoles.USER, - onClick: () => { - setSelectedRole(SystemRoles.USER); - }, - }, - { - label: SystemRoles.ADMIN, - onClick: () => { - setSelectedRole(SystemRoles.ADMIN); - }, - }, - ]; + const trigger = ( + + ); return ( - - - - - - - {localize('com_ui_admin_settings_section', { section: localize('com_ui_marketplace') })} - -
- {/* Role selection dropdown */} -
- {localize('com_ui_role_select')}: - - {selectedRole} - - } - items={roleDropdownItems} - itemClassName="items-center justify-center" - sameWidth={true} - /> -
- {/* Permissions form */} -
-
- {labelControllerData.map(({ marketplacePerm, label }) => ( -
- -
- ))} -
-
- -
-
-
-
-
+ ); }; diff --git a/client/src/components/Bookmarks/BookmarkEditDialog.tsx b/client/src/components/Bookmarks/BookmarkEditDialog.tsx index aaf965c05d..952a8784eb 100644 --- a/client/src/components/Bookmarks/BookmarkEditDialog.tsx +++ b/client/src/components/Bookmarks/BookmarkEditDialog.tsx @@ -91,7 +91,7 @@ const BookmarkEditDialog = ({ -
-
-