mirror of
https://github.com/outline/outline.git
synced 2026-11-21 13:34:02 +03:00
* shares.info, collections.info, documents.info * shares.list, shares.create, shares.update * shares.sitemap * parity with existing document shared screen * collection share popover * parent share and table * collection scene * collection link in sidebar * sidebar and breadcrumb collection link click * collection link click in editor * meta * more meta + 404 page * map internal link, remove showLastUpdated option * fix shares.list pagination * show last updated * shareLoader tests * lint * sidebar context for collection link * badge in shares table * fix existing tests * tsc * update failing test snapshot * env * signed url for collection attachments * include collection content in SSR for screen readers * search * drafts can be shared * review * tsc, remove old shared-doc scene * tweaks * DRY * refactor loader * Remove share/collection urls * fix: Collection overview should not be editable when viewing shared link and logged in * Tweak public breadcrumb * fix: Deleted documents should never be exposed through share * empty sharedTree array where includeChildDocuments is false * revert includeChildDocs guard for logical correctness + SSR bug fix * fix: check document is part of share --------- Co-authored-by: Tom Moor <tom@getoutline.com>
64 lines
1.6 KiB
TypeScript
64 lines
1.6 KiB
TypeScript
import { observer } from "mobx-react";
|
|
import { GlobeIcon } from "outline-icons";
|
|
import { useCallback, useState } from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
import Document from "~/models/Document";
|
|
import Button from "~/components/Button";
|
|
import SharePopover from "~/components/Sharing/Document";
|
|
import {
|
|
Popover,
|
|
PopoverTrigger,
|
|
PopoverContent,
|
|
} from "~/components/primitives/Popover";
|
|
import useMobile from "~/hooks/useMobile";
|
|
import useStores from "~/hooks/useStores";
|
|
|
|
type Props = {
|
|
/** Document being shared */
|
|
document: Document;
|
|
};
|
|
|
|
function ShareButton({ document }: Props) {
|
|
const { t } = useTranslation();
|
|
const [open, setOpen] = useState(false);
|
|
const { shares } = useStores();
|
|
const isMobile = useMobile();
|
|
const share = shares.getByDocumentId(document.id);
|
|
const sharedParent = shares.getByDocumentParents(document);
|
|
const domain = share?.domain || sharedParent?.domain;
|
|
|
|
const closePopover = useCallback(() => {
|
|
setOpen(false);
|
|
}, []);
|
|
|
|
if (isMobile) {
|
|
return null;
|
|
}
|
|
|
|
const icon = document.isPubliclyShared ? <GlobeIcon /> : undefined;
|
|
|
|
return (
|
|
<Popover open={open} onOpenChange={setOpen}>
|
|
<PopoverTrigger>
|
|
<Button icon={icon} neutral>
|
|
{t("Share")} {domain && <>· {domain}</>}
|
|
</Button>
|
|
</PopoverTrigger>
|
|
<PopoverContent
|
|
aria-label={t("Share")}
|
|
width={400}
|
|
side="bottom"
|
|
align="end"
|
|
>
|
|
<SharePopover
|
|
document={document}
|
|
onRequestClose={closePopover}
|
|
visible={open}
|
|
/>
|
|
</PopoverContent>
|
|
</Popover>
|
|
);
|
|
}
|
|
|
|
export default observer(ShareButton);
|