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 = ({ -
-
-