From 7417514e7ceb9273a3dbb9d8de9c8954f44a6f1d Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Wed, 31 Jan 2024 20:08:01 -0500 Subject: [PATCH] chore: Deprecate collection.url on client --- app/actions/definitions/collections.tsx | 4 ++-- app/components/DocumentBreadcrumb.tsx | 2 +- .../Sidebar/components/CollectionLink.tsx | 4 ++-- app/hooks/useCollectionTrees.ts | 2 +- app/models/Collection.ts | 8 +++++++ app/models/Notification.ts | 2 +- app/scenes/Collection.tsx | 24 +++++++++---------- app/scenes/CollectionNew.tsx | 2 +- app/scenes/DocumentDelete.tsx | 2 +- app/stores/CollectionsStore.ts | 4 ++-- app/utils/routeHelpers.ts | 2 +- 11 files changed, 32 insertions(+), 24 deletions(-) diff --git a/app/actions/definitions/collections.tsx b/app/actions/definitions/collections.tsx index bc58398d8..6fc2539e3 100644 --- a/app/actions/definitions/collections.tsx +++ b/app/actions/definitions/collections.tsx @@ -34,11 +34,11 @@ export const openCollection = createAction({ return collections.map((collection) => ({ // Note: using url which includes the slug rather than id here to bust // cache if the collection is renamed - id: collection.url, + id: collection.path, name: collection.name, icon: , section: CollectionSection, - perform: () => history.push(collection.url), + perform: () => history.push(collection.path), })); }, }); diff --git a/app/components/DocumentBreadcrumb.tsx b/app/components/DocumentBreadcrumb.tsx index fae86a31e..5dcd5300b 100644 --- a/app/components/DocumentBreadcrumb.tsx +++ b/app/components/DocumentBreadcrumb.tsx @@ -79,7 +79,7 @@ const DocumentBreadcrumb: React.FC = ({ type: "route", title: collection.name, icon: , - to: collectionPath(collection.url), + to: collectionPath(collection.path), }; } else if (document.isCollectionDeleted) { collectionNode = { diff --git a/app/components/Sidebar/components/CollectionLink.tsx b/app/components/Sidebar/components/CollectionLink.tsx index 9ee02ad28..c8e760854 100644 --- a/app/components/Sidebar/components/CollectionLink.tsx +++ b/app/components/Sidebar/components/CollectionLink.tsx @@ -54,7 +54,7 @@ const CollectionLink: React.FC = ({ await collection.save({ name, }); - history.replace(collection.url, history.location.state); + history.replace(collection.path, history.location.state); }, [collection, history] ); @@ -133,7 +133,7 @@ const CollectionLink: React.FC = ({ { if (this.isFetching) { return; diff --git a/app/models/Notification.ts b/app/models/Notification.ts index e22c8bb17..54438017a 100644 --- a/app/models/Notification.ts +++ b/app/models/Notification.ts @@ -166,7 +166,7 @@ class Notification extends Model { const collection = this.collectionId ? this.store.rootStore.collections.get(this.collectionId) : undefined; - return collection ? collectionPath(collection.url) : ""; + return collection ? collectionPath(collection.path) : ""; } case NotificationEventType.AddUserToDocument: case NotificationEventType.MentionedInDocument: { diff --git a/app/scenes/Collection.tsx b/app/scenes/Collection.tsx index 8353e3c6a..090cddc5a 100644 --- a/app/scenes/Collection.tsx +++ b/app/scenes/Collection.tsx @@ -179,27 +179,27 @@ function CollectionScene() { - + {t("Documents")} - + {t("Recently updated")} - + {t("Recently published")} - + {t("Least recently updated")} {t("A–Z")} - + - + - + - + - + - + { try { await collection.save(); this.props.onSubmit(); - history.push(collection.url); + history.push(collection.path); } catch (err) { toast.error(err.message); } finally { diff --git a/app/scenes/DocumentDelete.tsx b/app/scenes/DocumentDelete.tsx index 5304a15ae..6bccba417 100644 --- a/app/scenes/DocumentDelete.tsx +++ b/app/scenes/DocumentDelete.tsx @@ -51,7 +51,7 @@ function DocumentDelete({ document, onSubmit }: Props) { } // otherwise, redirect to the collection home - history.push(collectionPath(collection?.url || "/")); + history.push(collectionPath(collection?.path || "/")); } onSubmit(); diff --git a/app/stores/CollectionsStore.ts b/app/stores/CollectionsStore.ts index 2bad4313c..813814806 100644 --- a/app/stores/CollectionsStore.ts +++ b/app/stores/CollectionsStore.ts @@ -121,13 +121,13 @@ export default class CollectionsStore extends Store { if (this.isLoaded) { this.data.forEach((collection) => { - const { id, name, url } = collection; + const { id, name, path } = collection; const node = { type: DocumentPathItemType.Collection, id, collectionId: id, title: name, - url, + url: path, }; results.push([node]); diff --git a/app/utils/routeHelpers.ts b/app/utils/routeHelpers.ts index 840330a97..9f64ab1af 100644 --- a/app/utils/routeHelpers.ts +++ b/app/utils/routeHelpers.ts @@ -42,7 +42,7 @@ export function updateCollectionPath( // Update url to match the current one return oldUrl.replace( new RegExp("/collection/[0-9a-zA-Z-_~]*"), - collection.url + collection.path ); }