chore: Deprecate collection.url on client
This commit is contained in:
@@ -34,11 +34,11 @@ export const openCollection = createAction({
|
|||||||
return collections.map((collection) => ({
|
return collections.map((collection) => ({
|
||||||
// Note: using url which includes the slug rather than id here to bust
|
// Note: using url which includes the slug rather than id here to bust
|
||||||
// cache if the collection is renamed
|
// cache if the collection is renamed
|
||||||
id: collection.url,
|
id: collection.path,
|
||||||
name: collection.name,
|
name: collection.name,
|
||||||
icon: <ColorCollectionIcon collection={collection} />,
|
icon: <ColorCollectionIcon collection={collection} />,
|
||||||
section: CollectionSection,
|
section: CollectionSection,
|
||||||
perform: () => history.push(collection.url),
|
perform: () => history.push(collection.path),
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ const DocumentBreadcrumb: React.FC<Props> = ({
|
|||||||
type: "route",
|
type: "route",
|
||||||
title: collection.name,
|
title: collection.name,
|
||||||
icon: <CollectionIcon collection={collection} expanded />,
|
icon: <CollectionIcon collection={collection} expanded />,
|
||||||
to: collectionPath(collection.url),
|
to: collectionPath(collection.path),
|
||||||
};
|
};
|
||||||
} else if (document.isCollectionDeleted) {
|
} else if (document.isCollectionDeleted) {
|
||||||
collectionNode = {
|
collectionNode = {
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ const CollectionLink: React.FC<Props> = ({
|
|||||||
await collection.save({
|
await collection.save({
|
||||||
name,
|
name,
|
||||||
});
|
});
|
||||||
history.replace(collection.url, history.location.state);
|
history.replace(collection.path, history.location.state);
|
||||||
},
|
},
|
||||||
[collection, history]
|
[collection, history]
|
||||||
);
|
);
|
||||||
@@ -133,7 +133,7 @@ const CollectionLink: React.FC<Props> = ({
|
|||||||
<DropToImport collectionId={collection.id}>
|
<DropToImport collectionId={collection.id}>
|
||||||
<SidebarLink
|
<SidebarLink
|
||||||
to={{
|
to={{
|
||||||
pathname: collection.url,
|
pathname: collection.path,
|
||||||
state: { starred: inStarredSection },
|
state: { starred: inStarredSection },
|
||||||
}}
|
}}
|
||||||
expanded={expanded}
|
expanded={expanded}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ export default function useCollectionTrees(): NavigationNode[] {
|
|||||||
const collectionNode: NavigationNode = {
|
const collectionNode: NavigationNode = {
|
||||||
id: collection.id,
|
id: collection.id,
|
||||||
title: collection.name,
|
title: collection.name,
|
||||||
url: collection.url,
|
url: collection.path,
|
||||||
type: NavigationNodeType.Collection,
|
type: NavigationNodeType.Collection,
|
||||||
children: collection.documents
|
children: collection.documents
|
||||||
? sortNavigationNodes(collection.documents, collection.sort, true)
|
? sortNavigationNodes(collection.documents, collection.sort, true)
|
||||||
|
|||||||
@@ -65,6 +65,9 @@ export default class Collection extends ParanoidModel {
|
|||||||
@observable
|
@observable
|
||||||
documents?: NavigationNode[];
|
documents?: NavigationNode[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use path instead.
|
||||||
|
*/
|
||||||
@observable
|
@observable
|
||||||
url: string;
|
url: string;
|
||||||
|
|
||||||
@@ -139,6 +142,11 @@ export default class Collection extends ParanoidModel {
|
|||||||
return (this.name ? this.name[0] : "?").toUpperCase();
|
return (this.name ? this.name[0] : "?").toUpperCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@computed
|
||||||
|
get path() {
|
||||||
|
return this.url;
|
||||||
|
}
|
||||||
|
|
||||||
fetchDocuments = async (options?: { force: boolean }) => {
|
fetchDocuments = async (options?: { force: boolean }) => {
|
||||||
if (this.isFetching) {
|
if (this.isFetching) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ class Notification extends Model {
|
|||||||
const collection = this.collectionId
|
const collection = this.collectionId
|
||||||
? this.store.rootStore.collections.get(this.collectionId)
|
? this.store.rootStore.collections.get(this.collectionId)
|
||||||
: undefined;
|
: undefined;
|
||||||
return collection ? collectionPath(collection.url) : "";
|
return collection ? collectionPath(collection.path) : "";
|
||||||
}
|
}
|
||||||
case NotificationEventType.AddUserToDocument:
|
case NotificationEventType.AddUserToDocument:
|
||||||
case NotificationEventType.MentionedInDocument: {
|
case NotificationEventType.MentionedInDocument: {
|
||||||
|
|||||||
@@ -179,27 +179,27 @@ function CollectionScene() {
|
|||||||
|
|
||||||
<Documents>
|
<Documents>
|
||||||
<Tabs>
|
<Tabs>
|
||||||
<Tab to={collectionPath(collection.url)} exact>
|
<Tab to={collectionPath(collection.path)} exact>
|
||||||
{t("Documents")}
|
{t("Documents")}
|
||||||
</Tab>
|
</Tab>
|
||||||
<Tab to={collectionPath(collection.url, "updated")} exact>
|
<Tab to={collectionPath(collection.path, "updated")} exact>
|
||||||
{t("Recently updated")}
|
{t("Recently updated")}
|
||||||
</Tab>
|
</Tab>
|
||||||
<Tab to={collectionPath(collection.url, "published")} exact>
|
<Tab to={collectionPath(collection.path, "published")} exact>
|
||||||
{t("Recently published")}
|
{t("Recently published")}
|
||||||
</Tab>
|
</Tab>
|
||||||
<Tab to={collectionPath(collection.url, "old")} exact>
|
<Tab to={collectionPath(collection.path, "old")} exact>
|
||||||
{t("Least recently updated")}
|
{t("Least recently updated")}
|
||||||
</Tab>
|
</Tab>
|
||||||
<Tab
|
<Tab
|
||||||
to={collectionPath(collection.url, "alphabetical")}
|
to={collectionPath(collection.path, "alphabetical")}
|
||||||
exact
|
exact
|
||||||
>
|
>
|
||||||
{t("A–Z")}
|
{t("A–Z")}
|
||||||
</Tab>
|
</Tab>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route path={collectionPath(collection.url, "alphabetical")}>
|
<Route path={collectionPath(collection.path, "alphabetical")}>
|
||||||
<PaginatedDocumentList
|
<PaginatedDocumentList
|
||||||
key="alphabetical"
|
key="alphabetical"
|
||||||
documents={documents.alphabeticalInCollection(
|
documents={documents.alphabeticalInCollection(
|
||||||
@@ -211,7 +211,7 @@ function CollectionScene() {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Route>
|
</Route>
|
||||||
<Route path={collectionPath(collection.url, "old")}>
|
<Route path={collectionPath(collection.path, "old")}>
|
||||||
<PaginatedDocumentList
|
<PaginatedDocumentList
|
||||||
key="old"
|
key="old"
|
||||||
documents={documents.leastRecentlyUpdatedInCollection(
|
documents={documents.leastRecentlyUpdatedInCollection(
|
||||||
@@ -223,12 +223,12 @@ function CollectionScene() {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Route>
|
</Route>
|
||||||
<Route path={collectionPath(collection.url, "recent")}>
|
<Route path={collectionPath(collection.path, "recent")}>
|
||||||
<Redirect
|
<Redirect
|
||||||
to={collectionPath(collection.url, "published")}
|
to={collectionPath(collection.path, "published")}
|
||||||
/>
|
/>
|
||||||
</Route>
|
</Route>
|
||||||
<Route path={collectionPath(collection.url, "published")}>
|
<Route path={collectionPath(collection.path, "published")}>
|
||||||
<PaginatedDocumentList
|
<PaginatedDocumentList
|
||||||
key="published"
|
key="published"
|
||||||
documents={documents.recentlyPublishedInCollection(
|
documents={documents.recentlyPublishedInCollection(
|
||||||
@@ -241,7 +241,7 @@ function CollectionScene() {
|
|||||||
showPublished
|
showPublished
|
||||||
/>
|
/>
|
||||||
</Route>
|
</Route>
|
||||||
<Route path={collectionPath(collection.url, "updated")}>
|
<Route path={collectionPath(collection.path, "updated")}>
|
||||||
<PaginatedDocumentList
|
<PaginatedDocumentList
|
||||||
key="updated"
|
key="updated"
|
||||||
documents={documents.recentlyUpdatedInCollection(
|
documents={documents.recentlyUpdatedInCollection(
|
||||||
@@ -253,7 +253,7 @@ function CollectionScene() {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Route>
|
</Route>
|
||||||
<Route path={collectionPath(collection.url)} exact>
|
<Route path={collectionPath(collection.path)} exact>
|
||||||
<PaginatedDocumentList
|
<PaginatedDocumentList
|
||||||
documents={documents.rootInCollection(collection.id)}
|
documents={documents.rootInCollection(collection.id)}
|
||||||
fetch={documents.fetchPage}
|
fetch={documents.fetchPage}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ class CollectionNew extends React.Component<Props> {
|
|||||||
try {
|
try {
|
||||||
await collection.save();
|
await collection.save();
|
||||||
this.props.onSubmit();
|
this.props.onSubmit();
|
||||||
history.push(collection.url);
|
history.push(collection.path);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
toast.error(err.message);
|
toast.error(err.message);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ function DocumentDelete({ document, onSubmit }: Props) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// otherwise, redirect to the collection home
|
// otherwise, redirect to the collection home
|
||||||
history.push(collectionPath(collection?.url || "/"));
|
history.push(collectionPath(collection?.path || "/"));
|
||||||
}
|
}
|
||||||
|
|
||||||
onSubmit();
|
onSubmit();
|
||||||
|
|||||||
@@ -121,13 +121,13 @@ export default class CollectionsStore extends Store<Collection> {
|
|||||||
|
|
||||||
if (this.isLoaded) {
|
if (this.isLoaded) {
|
||||||
this.data.forEach((collection) => {
|
this.data.forEach((collection) => {
|
||||||
const { id, name, url } = collection;
|
const { id, name, path } = collection;
|
||||||
const node = {
|
const node = {
|
||||||
type: DocumentPathItemType.Collection,
|
type: DocumentPathItemType.Collection,
|
||||||
id,
|
id,
|
||||||
collectionId: id,
|
collectionId: id,
|
||||||
title: name,
|
title: name,
|
||||||
url,
|
url: path,
|
||||||
};
|
};
|
||||||
results.push([node]);
|
results.push([node]);
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ export function updateCollectionPath(
|
|||||||
// Update url to match the current one
|
// Update url to match the current one
|
||||||
return oldUrl.replace(
|
return oldUrl.replace(
|
||||||
new RegExp("/collection/[0-9a-zA-Z-_~]*"),
|
new RegExp("/collection/[0-9a-zA-Z-_~]*"),
|
||||||
collection.url
|
collection.path
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user