mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
* 🔄 refactor: frontend and backend share link logic; feat: qrcode for share link; feat: refresh link * 🐛 fix: Conditionally render shared link and refactor share link creation logic * 🐛 fix: Correct conditional check for shareId in ShareButton component * 🔄 refactor: Update shared links API and data handling; improve query parameters and response structure * 🔄 refactor: Update shared links pagination and response structure; replace pageNumber with cursor for improved data fetching * 🔄 refactor: DataTable performance optimization * fix: delete shared link cache update * 🔄 refactor: Enhance shared links functionality; add conversationId to shared link model and update related components * 🔄 refactor: Add delete functionality to SharedLinkButton; integrate delete mutation and confirmation dialog * 🔄 feat: Add AnimatedSearchInput component with gradient animations and search functionality; update search handling in API and localization * 🔄 refactor: Improve SharedLinks component; enhance delete functionality and loading states, optimize AnimatedSearchInput, and refine DataTable scrolling behavior * fix: mutation type issues with deleted shared link mutation * fix: MutationOptions types * fix: Ensure only public shared links are retrieved in getSharedLink function * fix: `qrcode.react` install location * fix: ensure non-public shared links are not fetched when checking for existing shared links, and remove deprecated .exec() method for queries * fix: types and import order * refactor: cleanup share button UI logic, make more intuitive --------- Co-authored-by: Danny Avila <danny@librechat.ai>
99 lines
3.2 KiB
TypeScript
99 lines
3.2 KiB
TypeScript
import { forwardRef, ReactNode, Ref } from 'react';
|
|
import {
|
|
OGDialogTitle,
|
|
OGDialogClose,
|
|
OGDialogFooter,
|
|
OGDialogHeader,
|
|
OGDialogContent,
|
|
OGDialogDescription,
|
|
} from './OriginalDialog';
|
|
import { useLocalize } from '~/hooks';
|
|
import { cn } from '~/utils/';
|
|
|
|
type SelectionProps = {
|
|
selectHandler?: () => void;
|
|
selectClasses?: string;
|
|
selectText?: string | ReactNode;
|
|
};
|
|
|
|
type DialogTemplateProps = {
|
|
title: string;
|
|
description?: string;
|
|
main?: ReactNode;
|
|
buttons?: ReactNode;
|
|
leftButtons?: ReactNode;
|
|
selection?: SelectionProps;
|
|
className?: string;
|
|
overlayClassName?: string;
|
|
headerClassName?: string;
|
|
mainClassName?: string;
|
|
footerClassName?: string;
|
|
showCloseButton?: boolean;
|
|
showCancelButton?: boolean;
|
|
};
|
|
|
|
const OGDialogTemplate = forwardRef((props: DialogTemplateProps, ref: Ref<HTMLDivElement>) => {
|
|
const localize = useLocalize();
|
|
const {
|
|
title,
|
|
main,
|
|
buttons,
|
|
selection,
|
|
className,
|
|
leftButtons,
|
|
description = '',
|
|
mainClassName,
|
|
headerClassName,
|
|
footerClassName,
|
|
showCloseButton,
|
|
overlayClassName,
|
|
showCancelButton = true,
|
|
} = props;
|
|
const { selectHandler, selectClasses, selectText } = selection || {};
|
|
const Cancel = localize('com_ui_cancel');
|
|
|
|
const defaultSelect =
|
|
'bg-gray-800 text-white transition-colors hover:bg-gray-700 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-gray-200 dark:text-gray-800 dark:hover:bg-gray-200';
|
|
return (
|
|
<OGDialogContent
|
|
overlayClassName={overlayClassName}
|
|
showCloseButton={showCloseButton}
|
|
ref={ref}
|
|
className={cn('w-11/12 border-none bg-background text-foreground', className ?? '')}
|
|
onClick={(e) => e.stopPropagation()}
|
|
>
|
|
<OGDialogHeader className={cn(headerClassName ?? '')}>
|
|
<OGDialogTitle>{title}</OGDialogTitle>
|
|
{description && (
|
|
<OGDialogDescription className="items-center justify-center">
|
|
{description}
|
|
</OGDialogDescription>
|
|
)}
|
|
</OGDialogHeader>
|
|
<div className={cn('px-0 py-2', mainClassName)}>{main != null ? main : null}</div>
|
|
<OGDialogFooter className={footerClassName}>
|
|
<div>{leftButtons != null ? <div className="mt-3 sm:mt-0">{leftButtons}</div> : null}</div>
|
|
<div className="flex h-auto gap-3 max-sm:w-full max-sm:flex-col sm:flex-row">
|
|
{buttons != null ? buttons : null}
|
|
{showCancelButton && (
|
|
<OGDialogClose className="btn btn-neutral border-token-border-light relative justify-center rounded-lg text-sm ring-offset-2 focus:ring-2 focus:ring-black dark:ring-offset-0 max-sm:order-last max-sm:w-full sm:order-first">
|
|
{Cancel}
|
|
</OGDialogClose>
|
|
)}
|
|
{selection ? (
|
|
<OGDialogClose
|
|
onClick={selectHandler}
|
|
className={`${
|
|
selectClasses ?? defaultSelect
|
|
} flex h-10 items-center justify-center rounded-lg border-none px-4 py-2 text-sm max-sm:order-first max-sm:w-full sm:order-none`}
|
|
>
|
|
{selectText}
|
|
</OGDialogClose>
|
|
) : null}
|
|
</div>
|
|
</OGDialogFooter>
|
|
</OGDialogContent>
|
|
);
|
|
});
|
|
|
|
export default OGDialogTemplate;
|