mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-02-03 08:11:50 +01:00
🔖 feat: Enhance Bookmarks UX, add RBAC, toggle via librechat.yaml (#3747)
* chore: update package version to 0.7.416 * chore: Update Role.js imports order * refactor: move updateTagsInConvo to tags route, add RBAC for tags * refactor: add updateTagsInConvoOptions * fix: loading state for bookmark form * refactor: update primaryText class in TitleButton component * refactor: remove duplicate bookmarks and theming * refactor: update EditIcon component to use React.forwardRef * refactor: add _id field to tConversationTagSchema * refactor: remove promises * refactor: move mutation logic from BookmarkForm -> BookmarkEditDialog * refactor: update button class in BookmarkForm component * fix: conversation mutations and add better logging to useConversationTagMutation * refactor: update logger message in BookmarkEditDialog component * refactor: improve UI consistency in BookmarkNav and NewChat components * refactor: update logger message in BookmarkEditDialog component * refactor: Add tags prop to BookmarkForm component * refactor: Update BookmarkForm to avoid tag mutation if the tag already exists; also close dialog on submission programmatically * refactor: general role helper function to support updating access permissions for different permission types * refactor: Update getLatestText function to handle undefined values in message.content * refactor: Update useHasAccess hook to handle null role values for authenticated users * feat: toggle bookmarks access * refactor: Update PromptsCommand to handle access permissions for prompts * feat: updateConversationSelector * refactor: rename `vars` to `tagToDelete` for clarity * fix: prevent recreation of deleted tags in BookmarkMenu on Item Click * ci: mock updateBookmarksAccess function * ci: mock updateBookmarksAccess function
This commit is contained in:
parent
366e4c5adb
commit
f86e9dd04c
39 changed files with 530 additions and 298 deletions
|
|
@ -3,7 +3,7 @@ import useUpdateTagsInConvo from './useUpdateTagsInConvo';
|
|||
import store from '~/store';
|
||||
|
||||
const useBookmarkSuccess = (conversationId: string) => {
|
||||
const setConversation = useSetRecoilState(store.conversationByIndex(0));
|
||||
const updateConversation = useSetRecoilState(store.updateConversationSelector(conversationId));
|
||||
const { updateTagsInConversation } = useUpdateTagsInConvo();
|
||||
|
||||
return (newTags: string[]) => {
|
||||
|
|
@ -11,16 +11,7 @@ const useBookmarkSuccess = (conversationId: string) => {
|
|||
return;
|
||||
}
|
||||
updateTagsInConversation(conversationId, newTags);
|
||||
setConversation((prev) => {
|
||||
if (prev) {
|
||||
return {
|
||||
...prev,
|
||||
tags: newTags,
|
||||
};
|
||||
}
|
||||
console.error('Conversation not found for bookmark/tags update');
|
||||
return prev;
|
||||
});
|
||||
updateConversation({ tags: newTags });
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,10 @@ export default function useSideNavLinks({
|
|||
permissionType: PermissionTypes.PROMPTS,
|
||||
permission: Permissions.USE,
|
||||
});
|
||||
const hasAccessToBookmarks = useHasAccess({
|
||||
permissionType: PermissionTypes.BOOKMARKS,
|
||||
permission: Permissions.USE,
|
||||
});
|
||||
|
||||
const Links = useMemo(() => {
|
||||
const links: NavLink[] = [];
|
||||
|
|
@ -75,13 +79,15 @@ export default function useSideNavLinks({
|
|||
Component: FilesPanel,
|
||||
});
|
||||
|
||||
links.push({
|
||||
title: 'com_sidepanel_conversation_tags',
|
||||
label: '',
|
||||
icon: Bookmark,
|
||||
id: 'bookmarks',
|
||||
Component: BookmarkPanel,
|
||||
});
|
||||
if (hasAccessToBookmarks) {
|
||||
links.push({
|
||||
title: 'com_sidepanel_conversation_tags',
|
||||
label: '',
|
||||
icon: Bookmark,
|
||||
id: 'bookmarks',
|
||||
Component: BookmarkPanel,
|
||||
});
|
||||
}
|
||||
|
||||
links.push({
|
||||
title: 'com_sidepanel_hide_panel',
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ const useHasAccess = ({
|
|||
({ user, permissionType, permission }) => {
|
||||
if (isAuthenticated && user?.role === SystemRoles.ADMIN) {
|
||||
return true;
|
||||
} else if (isAuthenticated && user?.role && roles && roles[user.role]) {
|
||||
} else if (isAuthenticated && user?.role != null && roles && roles[user.role]) {
|
||||
return roles[user.role]?.[permissionType]?.[permission] === true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue