mirror of
https://github.com/zadam/trilium.git
synced 2025-12-23 16:49:58 +01:00
feat(layout): add shared badge
This commit is contained in:
@@ -3,11 +3,13 @@ import "./BreadcrumbBadges.css";
|
||||
import { ComponentChildren } from "preact";
|
||||
import { useIsNoteReadOnly, useNoteContext } from "./react/hooks";
|
||||
import Icon from "./react/Icon";
|
||||
import { useShareInfo } from "./shared_info";
|
||||
|
||||
export default function NoteBadges() {
|
||||
return (
|
||||
<div className="breadcrumb-badges">
|
||||
<ReadOnlyBadge />
|
||||
<ShareBadge />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -26,6 +28,19 @@ function ReadOnlyBadge() {
|
||||
);
|
||||
}
|
||||
|
||||
function ShareBadge() {
|
||||
const { note } = useNoteContext();
|
||||
const { isSharedExternally, link } = useShareInfo(note);
|
||||
|
||||
return (link &&
|
||||
<Badge
|
||||
icon={isSharedExternally ? "bx bx-world" : "bx bx-link"}
|
||||
>
|
||||
{isSharedExternally ? "Shared publicly" : "Shared locally"}
|
||||
</Badge>
|
||||
);
|
||||
}
|
||||
|
||||
function Badge({ icon, children, onClick }: { icon: string, children: ComponentChildren, onClick?: () => void }) {
|
||||
return (
|
||||
<div className="breadcrumb-badge" onClick={onClick}>
|
||||
|
||||
Reference in New Issue
Block a user