mirror of
https://github.com/outline/outline.git
synced 2026-12-06 03:05:08 +03:00
works
This commit is contained in:
1 parent
021e99a391
commit
d6d443769a
3 files changed
+39
-2
No files matched your search
@@ -78,6 +78,19 @@ function DocumentListItem(
|
||||
!!document.title.toLowerCase().includes(highlight.toLowerCase());
|
||||
const canStar = !document.isArchived && !document.isTemplate;
|
||||
|
||||
const membershipType = document.membershipType;
|
||||
|
||||
let sidebarContext: string | undefined = "collections";
|
||||
|
||||
if (membershipType === "direct") {
|
||||
sidebarContext = "shared";
|
||||
} else if (membershipType === "group") {
|
||||
const group = user.groupsWithDocumentMemberships.find(
|
||||
(g) => !!g.documentMemberships.find((m) => m.documentId === document.id)
|
||||
);
|
||||
sidebarContext = group?.id;
|
||||
}
|
||||
|
||||
return (
|
||||
<DocumentLink
|
||||
ref={itemRef}
|
||||
@@ -89,7 +102,7 @@ function DocumentListItem(
|
||||
pathname: documentPath(document),
|
||||
state: {
|
||||
title: document.titleWithDefault,
|
||||
sidebarContext: document.collection ? "collections" : undefined,
|
||||
sidebarContext,
|
||||
},
|
||||
}}
|
||||
{...rest}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { observer } from "mobx-react";
|
||||
import { GroupIcon } from "outline-icons";
|
||||
import * as React from "react";
|
||||
import Group from "~/models/Group";
|
||||
import { useLocationState } from "../hooks/useLocationState";
|
||||
import Folder from "./Folder";
|
||||
import Relative from "./Relative";
|
||||
import SharedWithMeLink from "./SharedWithMeLink";
|
||||
@@ -14,13 +15,22 @@ type Props = {
|
||||
};
|
||||
|
||||
const GroupLink: React.FC<Props> = ({ group }) => {
|
||||
const [expanded, setExpanded] = React.useState(false);
|
||||
const locationSidebarContext = useLocationState();
|
||||
const [expanded, setExpanded] = React.useState(
|
||||
locationSidebarContext === group.id
|
||||
);
|
||||
|
||||
const handleDisclosureClick = React.useCallback((ev) => {
|
||||
ev?.preventDefault();
|
||||
setExpanded((e) => !e);
|
||||
}, []);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (locationSidebarContext === group.id) {
|
||||
setExpanded(true);
|
||||
}
|
||||
}, [group.id, locationSidebarContext, setExpanded]);
|
||||
|
||||
return (
|
||||
<Relative>
|
||||
<SidebarLink
|
||||
|
||||
@@ -429,6 +429,20 @@ export default class Document extends ArchivableModel {
|
||||
return this.title || i18n.t("Untitled");
|
||||
}
|
||||
|
||||
@computed
|
||||
get membershipType(): "collection" | "direct" | "group" {
|
||||
if (this.collection) {
|
||||
return "collection";
|
||||
}
|
||||
|
||||
const hasDocumentMembership =
|
||||
this.store.rootStore.auth.user?.documentMemberships.find(
|
||||
(m) => m.documentId === this.id
|
||||
) ?? false;
|
||||
|
||||
return hasDocumentMembership ? "direct" : "group";
|
||||
}
|
||||
|
||||
@action
|
||||
updateTasks(total: number, completed: number) {
|
||||
if (total !== this.tasks.total || completed !== this.tasks.completed) {
|
||||
|
||||
Reference in new issue
Block a user