mirror of
https://github.com/outline/outline.git
synced 2026-11-30 17:10:36 +03:00
Remove computedCollectionId
This commit is contained in:
1 parent
900ee7ada0
commit
faa67a7403
13 files changed
+33
-21
No files matched your search
@@ -58,9 +58,19 @@ function useCategory(document) {
|
||||
|
||||
const DocumentBreadcrumb = ({ document, children, onlyText }: Props) => {
|
||||
const { collections } = useStores();
|
||||
const { t } = useTranslation();
|
||||
const category = useCategory(document);
|
||||
|
||||
let collection = collections.get(document.computedCollectionId);
|
||||
let collection = collections.get(document.collectionId || "");
|
||||
|
||||
if (!collection && document.collectionId) {
|
||||
collection = {
|
||||
id: document.collectionId,
|
||||
name: t("Deleted Collection"),
|
||||
color: "currentColor",
|
||||
url: "deleted-collection",
|
||||
};
|
||||
}
|
||||
|
||||
const path = React.useMemo(
|
||||
() =>
|
||||
|
||||
@@ -65,7 +65,9 @@ function DocumentListItem(props: Props, ref) {
|
||||
!!document.title.toLowerCase().includes(highlight.toLowerCase());
|
||||
const canStar = policies.abilities(document.id).star;
|
||||
const can = policies.abilities(currentTeam.id);
|
||||
const canCollection = document.collectionId ? policies.abilities(document.collectionId) : {};
|
||||
const collectionPolicy = document.collectionId
|
||||
? policies.abilities(document.collectionId)
|
||||
: {};
|
||||
|
||||
return (
|
||||
<DocumentLink
|
||||
@@ -127,7 +129,7 @@ function DocumentListItem(props: Props, ref) {
|
||||
!document.isArchived &&
|
||||
!document.isDeleted &&
|
||||
can.createDocument &&
|
||||
canCollection.update && (
|
||||
collectionPolicy.update && (
|
||||
<>
|
||||
<Button
|
||||
as={Link}
|
||||
|
||||
@@ -75,7 +75,9 @@ function DocumentMeta({
|
||||
return null;
|
||||
}
|
||||
|
||||
const collection = document.collectionId ? collections.get(document.collectionId) : undefined;
|
||||
const collection = document.collectionId
|
||||
? collections.get(document.collectionId)
|
||||
: undefined;
|
||||
const lastUpdatedByCurrentUser = user.id === updatedBy.id;
|
||||
let content;
|
||||
|
||||
|
||||
@@ -156,7 +156,9 @@ function DocumentMenu({
|
||||
[document]
|
||||
);
|
||||
|
||||
const collection = document.collectionId ? collections.get(document.collectionId) : undefined;
|
||||
const collection = document.collectionId
|
||||
? collections.get(document.collectionId)
|
||||
: undefined;
|
||||
const can = policies.abilities(document.id);
|
||||
const canViewHistory = can.read && !can.restore;
|
||||
const restoreItems = React.useMemo(
|
||||
@@ -326,7 +328,7 @@ function DocumentMenu({
|
||||
},
|
||||
{
|
||||
title: t("New nested document"),
|
||||
to: newDocumentUrl(collectionId, {
|
||||
to: newDocumentUrl(collection?.id, {
|
||||
parentDocumentId: document.id,
|
||||
}),
|
||||
visible: !!can.createChildDocument,
|
||||
|
||||
@@ -18,7 +18,7 @@ function NewChildDocumentMenu({ document, label }: Props) {
|
||||
const menu = useMenuState({ modal: true });
|
||||
const { collections } = useStores();
|
||||
const { t } = useTranslation();
|
||||
const collection = collections.get(document.computedCollectionId);
|
||||
const collection = collections.get(document.collectionId || "");
|
||||
const collectionName = collection ? collection.name : t("collection");
|
||||
|
||||
if (!collection) {
|
||||
|
||||
@@ -165,11 +165,6 @@ export default class Document extends BaseModel {
|
||||
return floor((this.tasks.completed / this.tasks.total) * 100);
|
||||
}
|
||||
|
||||
@computed
|
||||
get computedCollectionId(): string {
|
||||
return this.collectionId || "";
|
||||
}
|
||||
|
||||
@action
|
||||
share = async () => {
|
||||
return this.store.rootStore.shares.create({ documentId: this.id });
|
||||
|
||||
@@ -70,7 +70,7 @@ function DocumentHeader({
|
||||
const { auth, ui, policies, collections } = useStores();
|
||||
const isMobile = useMobile();
|
||||
const dialog = useDialogState({ modal: true });
|
||||
const hasCollection = collections.get(document.computedCollectionId);
|
||||
const hasCollection = !!collections.get(document.collectionId || "");
|
||||
|
||||
const handleSave = React.useCallback(() => {
|
||||
onSave({ done: true });
|
||||
@@ -228,7 +228,7 @@ function DocumentHeader({
|
||||
<Button
|
||||
icon={<PlusIcon />}
|
||||
as={Link}
|
||||
to={newDocumentUrl(document.computedCollectionId, {
|
||||
to={newDocumentUrl(document.collectionId, {
|
||||
templateId: document.id,
|
||||
})}
|
||||
primary
|
||||
|
||||
@@ -26,7 +26,7 @@ class References extends React.Component<Props> {
|
||||
render() {
|
||||
const { documents, collections, document } = this.props;
|
||||
const backlinks = documents.getBacklinedDocuments(document.id);
|
||||
const collection = collections.get(document.computedCollectionId);
|
||||
const collection = collections.get(document.collectionId || "");
|
||||
const children = collection
|
||||
? collection.getDocumentChildren(document.id)
|
||||
: [];
|
||||
|
||||
@@ -24,7 +24,7 @@ function DocumentDelete({ document, onSubmit }: Props) {
|
||||
const [isArchiving, setArchiving] = React.useState(false);
|
||||
const { showToast } = useToasts();
|
||||
const canArchive = !document.isDraft && !document.isArchived;
|
||||
const collection = collections.get(document.computedCollectionId);
|
||||
const collection = collections.get(document.collectionId || "");
|
||||
|
||||
const handleSubmit = React.useCallback(
|
||||
async (ev: SyntheticEvent<>) => {
|
||||
|
||||
@@ -714,6 +714,6 @@ export default class DocumentsStore extends BaseStore<Document> {
|
||||
};
|
||||
|
||||
getCollectionForDocument(document: Document) {
|
||||
return this.rootStore.collections.data.get(document.computedCollectionId);
|
||||
return this.rootStore.collections.data.get(document.collectionId || "");
|
||||
}
|
||||
}
|
||||
@@ -66,7 +66,7 @@ export default class SharesStore extends BaseStore<Share> {
|
||||
if (!document) return;
|
||||
|
||||
const collection = this.rootStore.collections.get(
|
||||
document.computedCollectionId
|
||||
document.collectionId || ""
|
||||
);
|
||||
if (!collection) return;
|
||||
|
||||
|
||||
@@ -55,13 +55,14 @@ export function updateDocumentUrl(oldUrl: string, document: Document): string {
|
||||
}
|
||||
|
||||
export function newDocumentUrl(
|
||||
collectionId: string,
|
||||
collectionId: ?string,
|
||||
params?: {
|
||||
parentDocumentId?: string,
|
||||
templateId?: string,
|
||||
template?: boolean,
|
||||
}
|
||||
): string {
|
||||
if (!collectionId) return `/doc/new?${queryString.stringify(params)}`;
|
||||
return `/collection/${collectionId}/new?${queryString.stringify(params)}`;
|
||||
}
|
||||
|
||||
|
||||
@@ -335,7 +335,6 @@
|
||||
"Start your template…": "Start your template…",
|
||||
"Start with a title…": "Start with a title…",
|
||||
"…the rest is up to you": "…the rest is up to you",
|
||||
"Please select a path": "Please select a path",
|
||||
"Hide contents": "Hide contents",
|
||||
"Show contents": "Show contents",
|
||||
"Edit {{noun}}": "Edit {{noun}}",
|
||||
@@ -343,10 +342,11 @@
|
||||
"Save Draft": "Save Draft",
|
||||
"Done Editing": "Done Editing",
|
||||
"New from template": "New from template",
|
||||
"Search collections & documents": "Search collections & documents",
|
||||
"Publish": "Publish",
|
||||
"Publishing": "Publishing",
|
||||
"Nested documents": "Nested documents",
|
||||
"Please select a path": "Please select a path",
|
||||
"Search collections & documents": "Search collections & documents",
|
||||
"Anyone with the link <1></1>can view this document": "Anyone with the link <1></1>can view this document",
|
||||
"Share": "Share",
|
||||
"Share this document": "Share this document",
|
||||
|
||||
Reference in new issue
Block a user