mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-05-30 09:40:35 +02:00
Add open in new tab for custom links (#2568)
This commit is contained in:
parent
deee2b3513
commit
1f61447b4b
@ -23,6 +23,7 @@ interface DropdownOptionProps {
|
|||||||
onClick?: () => void;
|
onClick?: () => void;
|
||||||
icon: React.ReactNode;
|
icon: React.ReactNode;
|
||||||
label: string;
|
label: string;
|
||||||
|
openInNewTab?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DropdownOption: React.FC<DropdownOptionProps> = ({
|
const DropdownOption: React.FC<DropdownOptionProps> = ({
|
||||||
@ -30,6 +31,7 @@ const DropdownOption: React.FC<DropdownOptionProps> = ({
|
|||||||
onClick,
|
onClick,
|
||||||
icon,
|
icon,
|
||||||
label,
|
label,
|
||||||
|
openInNewTab,
|
||||||
}) => {
|
}) => {
|
||||||
const content = (
|
const content = (
|
||||||
<div className="flex py-3 px-4 cursor-pointer rounded hover:bg-hover-light">
|
<div className="flex py-3 px-4 cursor-pointer rounded hover:bg-hover-light">
|
||||||
@ -38,11 +40,19 @@ const DropdownOption: React.FC<DropdownOptionProps> = ({
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
return href ? (
|
if (href) {
|
||||||
<Link href={href}>{content}</Link>
|
return (
|
||||||
) : (
|
<Link
|
||||||
<div onClick={onClick}>{content}</div>
|
href={href}
|
||||||
|
target={openInNewTab ? "_blank" : undefined}
|
||||||
|
rel={openInNewTab ? "noopener noreferrer" : undefined}
|
||||||
|
>
|
||||||
|
{content}
|
||||||
|
</Link>
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
return <div onClick={onClick}>{content}</div>;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export function UserDropdown({
|
export function UserDropdown({
|
||||||
@ -173,6 +183,7 @@ export function UserDropdown({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
label={item.title}
|
label={item.title}
|
||||||
|
openInNewTab
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user