Files
outline/app/utils/routeHelpers.ts
Saumya Pandey 4c95674ef0 fix: Add ability to collapse and expand collections that are not active (#3102)
* fix: add disclosure and transition

* fix: keep collections expanded

* fix: tune transition and collapsing conditions

* fix: collectionIcon expanded props is no longer driven by expanded state

* fix: sync issue

* fix: managing state together

* fix: remove comment

* fix: simplify expanded state

* fix: remove extra state

* fix: remove animation and retain expanded state

* fix: remove isCollectionDropped

* fix: don't use ref

* review suggestions

* fix many functional and design issues

* don't render every single document in the sidebar, just ones that the user has seen before

* chore: Sidebar refinement (#3154)

* stash

* wip: More sidebar tweaks

* Simplify draft bubble

* disclosure refactor

* wip wip

* lint

* tweak menu position

* Use document emoji for starred docs where available

* feat: Trigger cmd+k from sidebar (#3149)

* feat: Trigger cmd+k from sidebar

* Add hint when opening command bar from sidebar

* fix: Clicking internal links in shared documents sometimes reroutes to Login

* fix: Spacing issues on connected slack channels list

* Merge

* fix: Do not prefetch JS bundles on public share links

* fix: Buttons show on collection empty state when user does not have permission to edit

* fix: the hover area for the "collections" subheading was being obfuscated by the initial collection drop cursor

* fix: top-align disclosures

* fix: Disclosure color PR feedback
fix: Starred no longer draggable

* fix: Overflow on sidebar button

* fix: Scrollbar in sidebar when command menu is open

* Minor alignment issues, clarify back in settings sidebar

* fix: Fade component causes SidebarButton missizing

Co-authored-by: Nan Yu <thenanyu@gmail.com>

Co-authored-by: Tom Moor <tom.moor@gmail.com>
Co-authored-by: Nan Yu <thenanyu@gmail.com>
2022-02-23 21:26:38 -08:00

130 lines
2.7 KiB
TypeScript

import queryString from "query-string";
import Collection from "~/models/Collection";
import Document from "~/models/Document";
export function homePath(): string {
return "/home";
}
export function draftsPath(): string {
return "/drafts";
}
export function templatesPath(): string {
return "/templates";
}
export function archivePath(): string {
return "/archive";
}
export function trashPath(): string {
return "/trash";
}
export function settingsPath(): string {
return "/settings";
}
export function organizationSettingsPath(): string {
return "/settings/details";
}
export function profileSettingsPath(): string {
return "/settings/profile";
}
export function groupSettingsPath(): string {
return "/settings/groups";
}
export function collectionUrl(url: string, section?: string): string {
if (section) {
return `${url}/${section}`;
}
return url;
}
export function updateCollectionUrl(
oldUrl: string,
collection: Collection
): string {
// Update url to match the current one
return oldUrl.replace(
new RegExp("/collection/[0-9a-zA-Z-_~]*"),
collection.url
);
}
export function documentUrl(doc: Document): string {
return doc.url;
}
export function editDocumentUrl(doc: Document): string {
return `${doc.url}/edit`;
}
export function documentMoveUrl(doc: Document): string {
return `${doc.url}/move`;
}
export function documentHistoryUrl(doc: Document, revisionId?: string): string {
let base = `${doc.url}/history`;
if (revisionId) {
base += `/${revisionId}`;
}
return base;
}
/**
* Replace full url's document part with the new one in case
* the document slug has been updated
*/
export function updateDocumentUrl(oldUrl: string, document: Document): string {
// Update url to match the current one
return oldUrl.replace(
new RegExp("/doc/([0-9a-zA-Z-_~]*-[a-zA-z0-9]{10,15})"),
document.url
);
}
export function newDocumentPath(
collectionId: string,
params: {
parentDocumentId?: string;
templateId?: string;
template?: boolean;
} = {}
): string {
return `/collection/${collectionId}/new?${queryString.stringify(params)}`;
}
export function searchPath(
query?: string,
params: {
collectionId?: string;
ref?: string;
} = {}
): string {
let search = queryString.stringify(params);
let route = "/search";
if (query) {
route += `/${encodeURIComponent(query.replace(/%/g, "%25"))}`;
}
search = search ? `?${search}` : "";
return `${route}${search}`;
}
export function notFoundUrl(): string {
return "/404";
}
export const matchDocumentSlug =
":documentSlug([0-9a-zA-Z-_~]*-[a-zA-z0-9]{10,15})";
export const matchDocumentEdit = `/doc/${matchDocumentSlug}/edit`;
export const matchDocumentHistory = `/doc/${matchDocumentSlug}/history/:revisionId?`;