mirror of
https://github.com/outline/outline.git
synced 2026-12-03 01:59:03 +03:00
Merge branch 'main' into feat/home-layout
This commit is contained in:
13 files changed
+340
-185
No files matched your search
@@ -28,7 +28,7 @@ export const CollectionBreadcrumb: React.FC<Props> = ({ collection }) => {
|
||||
name: collection.name,
|
||||
section: ActiveCollectionSection,
|
||||
icon: <CollectionIcon collection={collection} expanded />,
|
||||
to: collectionPath(collection.path),
|
||||
to: collectionPath(collection),
|
||||
}),
|
||||
],
|
||||
[collection, t]
|
||||
|
||||
@@ -331,7 +331,7 @@ function SharePopover({ collection, visible, onRequestClose }: Props) {
|
||||
) : (
|
||||
<CopyLinkButton
|
||||
key="copy-link"
|
||||
url={urlify(collectionPath(collection.path))}
|
||||
url={urlify(collectionPath(collection))}
|
||||
onCopy={onRequestClose}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -177,7 +177,7 @@ class Notification extends Model {
|
||||
const collection = this.collectionId
|
||||
? this.store.rootStore.collections.get(this.collectionId)
|
||||
: undefined;
|
||||
return collection ? collectionPath(collection.path) : "";
|
||||
return collection ? collectionPath(collection) : "";
|
||||
}
|
||||
case NotificationEventType.AddUserToDocument:
|
||||
case NotificationEventType.GroupMentionedInDocument:
|
||||
|
||||
@@ -17,7 +17,8 @@ import {
|
||||
homePath,
|
||||
searchPath,
|
||||
settingsPath,
|
||||
matchDocumentSlug as slug,
|
||||
matchDocumentSlug as documentSlug,
|
||||
matchCollectionSlug as collectionSlug,
|
||||
trashPath,
|
||||
} from "~/utils/routeHelpers";
|
||||
|
||||
@@ -80,22 +81,39 @@ function AuthenticatedRoutes() {
|
||||
to={settingsPath("templates")}
|
||||
/>
|
||||
<Redirect exact from="/collections/*" to="/collection/*" />
|
||||
<Route exact path="/collection/:id/new" component={DocumentNew} />
|
||||
<Route
|
||||
exact
|
||||
path="/collection/:id/:tab?"
|
||||
path={`/collection/${collectionSlug}/new`}
|
||||
component={DocumentNew}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path={`/collection/${collectionSlug}/overview/edit`}
|
||||
component={Collection}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path={`/collection/${collectionSlug}/:tab?`}
|
||||
component={Collection}
|
||||
/>
|
||||
<Route exact path="/doc/new" component={DocumentNew} />
|
||||
<Route exact path={`/d/${slug}`} component={RedirectDocument} />
|
||||
<Route
|
||||
exact
|
||||
path={`/doc/${slug}/history/:revisionId?`}
|
||||
path={`/d/${documentSlug}`}
|
||||
component={RedirectDocument}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path={`/doc/${documentSlug}/history/:revisionId?`}
|
||||
component={Document}
|
||||
/>
|
||||
|
||||
<Route exact path={`/doc/${slug}/edit`} component={Document} />
|
||||
<Route path={`/doc/${slug}`} component={Document} />
|
||||
<Route
|
||||
exact
|
||||
path={`/doc/${documentSlug}/edit`}
|
||||
component={Document}
|
||||
/>
|
||||
<Route path={`/doc/${documentSlug}`} component={Document} />
|
||||
<Route
|
||||
exact
|
||||
path={`${searchPath()}/:query?`}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { observer } from "mobx-react";
|
||||
import { PlusIcon } from "outline-icons";
|
||||
import { EditIcon, PlusIcon } from "outline-icons";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router-dom";
|
||||
import Collection from "~/models/Collection";
|
||||
@@ -8,18 +8,76 @@ import Button from "~/components/Button";
|
||||
import Tooltip from "~/components/Tooltip";
|
||||
import usePolicy from "~/hooks/usePolicy";
|
||||
import CollectionMenu from "~/menus/CollectionMenu";
|
||||
import { newDocumentPath } from "~/utils/routeHelpers";
|
||||
import {
|
||||
collectionEditPath,
|
||||
collectionPath,
|
||||
newDocumentPath,
|
||||
} from "~/utils/routeHelpers";
|
||||
import useCurrentUser from "~/hooks/useCurrentUser";
|
||||
import { SidebarContextType } from "~/components/Sidebar/components/SidebarContext";
|
||||
import { CollectionTab } from "./Navigation";
|
||||
import lazyWithRetry from "~/utils/lazyWithRetry";
|
||||
import history from "~/utils/history";
|
||||
import RegisterKeyDown from "~/components/RegisterKeyDown";
|
||||
import { useCallback } from "react";
|
||||
|
||||
const ShareButton = lazyWithRetry(() => import("./ShareButton"));
|
||||
|
||||
type Props = {
|
||||
/** The collection for which to render actions */
|
||||
collection: Collection;
|
||||
/** Whether the collection is in editing mode */
|
||||
isEditing: boolean;
|
||||
/** Contextual information for the sidebar */
|
||||
sidebarContext: SidebarContextType;
|
||||
};
|
||||
|
||||
function Actions({ collection }: Props) {
|
||||
function Actions({ collection, isEditing, sidebarContext }: Props) {
|
||||
const { t } = useTranslation();
|
||||
const can = usePolicy(collection);
|
||||
const user = useCurrentUser();
|
||||
|
||||
const goToEdit = useCallback(() => {
|
||||
history.push({
|
||||
pathname: collectionEditPath(collection),
|
||||
state: { sidebarContext },
|
||||
});
|
||||
}, [collection, sidebarContext]);
|
||||
|
||||
const goBack = useCallback(() => {
|
||||
history.push({
|
||||
pathname: collectionPath(collection, CollectionTab.Overview),
|
||||
state: { sidebarContext },
|
||||
});
|
||||
}, [collection, sidebarContext]);
|
||||
|
||||
return (
|
||||
<>
|
||||
{(!isEditing || !user?.separateEditMode) && (
|
||||
<Action>
|
||||
<ShareButton collection={collection} />
|
||||
</Action>
|
||||
)}
|
||||
{!isEditing && user?.separateEditMode && (
|
||||
<Action>
|
||||
<RegisterKeyDown trigger="e" handler={goToEdit} />
|
||||
<Tooltip
|
||||
content={t("Edit collection")}
|
||||
shortcut="e"
|
||||
placement="bottom"
|
||||
>
|
||||
<Button icon={<EditIcon />} onClick={goToEdit} neutral>
|
||||
{t("Edit")}
|
||||
</Button>
|
||||
</Tooltip>
|
||||
</Action>
|
||||
)}
|
||||
{isEditing && user?.separateEditMode && (
|
||||
<Action>
|
||||
<RegisterKeyDown trigger="Escape" handler={goBack} />
|
||||
<Button onClick={goBack}>{t("Done editing")}</Button>
|
||||
</Action>
|
||||
)}
|
||||
{can.createDocument && (
|
||||
<>
|
||||
<Action>
|
||||
@@ -33,6 +91,7 @@ function Actions({ collection }: Props) {
|
||||
to={collection ? newDocumentPath(collection.id) : ""}
|
||||
disabled={!collection}
|
||||
icon={<PlusIcon />}
|
||||
neutral={isEditing}
|
||||
>
|
||||
{t("New doc")}
|
||||
</Button>
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
import { IconTitleWrapper } from "@shared/components/Icon";
|
||||
import breakpoint from "styled-components-breakpoint";
|
||||
import first from "lodash/first";
|
||||
import { Suspense, useCallback } from "react";
|
||||
import styled from "styled-components";
|
||||
import Heading from "~/components/Heading";
|
||||
import CollectionIcon from "~/components/Icons/CollectionIcon";
|
||||
import type Collection from "~/models/Collection";
|
||||
import { colorPalette } from "@shared/utils/collections";
|
||||
import usePolicy from "~/hooks/usePolicy";
|
||||
import { observer } from "mobx-react";
|
||||
import lazyWithRetry from "~/utils/lazyWithRetry";
|
||||
|
||||
const IconPicker = lazyWithRetry(() => import("~/components/IconPicker"));
|
||||
|
||||
type Props = {
|
||||
/** The collection for which to render a header */
|
||||
collection: Collection;
|
||||
};
|
||||
|
||||
export const Header = observer(function Header_({ collection }: Props) {
|
||||
const can = usePolicy(collection);
|
||||
const handleIconChange = useCallback(
|
||||
(icon: string | null, color: string | null) =>
|
||||
collection?.save({ icon, color }),
|
||||
[collection]
|
||||
);
|
||||
|
||||
const fallbackIcon = collection ? (
|
||||
<CollectionIcon collection={collection} size={40} expanded />
|
||||
) : null;
|
||||
|
||||
return (
|
||||
<StyledHeading>
|
||||
<IconTitleWrapper>
|
||||
{can.update ? (
|
||||
<Suspense fallback={fallbackIcon}>
|
||||
<IconPicker
|
||||
icon={collection.icon ?? "collection"}
|
||||
color={collection.color ?? (first(colorPalette) as string)}
|
||||
initial={collection.initial}
|
||||
size={40}
|
||||
popoverPosition="bottom-start"
|
||||
onChange={handleIconChange}
|
||||
borderOnHover
|
||||
>
|
||||
{fallbackIcon}
|
||||
</IconPicker>
|
||||
</Suspense>
|
||||
) : (
|
||||
fallbackIcon
|
||||
)}
|
||||
</IconTitleWrapper>
|
||||
{collection.name}
|
||||
</StyledHeading>
|
||||
);
|
||||
});
|
||||
|
||||
const StyledHeading = styled(Heading)`
|
||||
display: flex;
|
||||
align-items: center;
|
||||
position: relative;
|
||||
margin-left: 40px;
|
||||
|
||||
${breakpoint("tablet")`
|
||||
margin-left: 0;
|
||||
`}
|
||||
`;
|
||||
@@ -0,0 +1,78 @@
|
||||
import { observer } from "mobx-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import Collection from "~/models/Collection";
|
||||
import Tab from "~/components/Tab";
|
||||
import Tabs from "~/components/Tabs";
|
||||
import { collectionPath } from "~/utils/routeHelpers";
|
||||
import { type SidebarContextType } from "~/components/Sidebar/components/SidebarContext";
|
||||
|
||||
export enum CollectionTab {
|
||||
Overview = "overview",
|
||||
Recent = "recent",
|
||||
Popular = "popular",
|
||||
Updated = "updated",
|
||||
Published = "published",
|
||||
Old = "old",
|
||||
Alphabetical = "alphabetical",
|
||||
}
|
||||
|
||||
type Props = {
|
||||
/** The collection for which to render navigation tabs */
|
||||
collection: Collection;
|
||||
/** Callback when the tab is changed */
|
||||
onChangeTab: (tab: CollectionTab) => void;
|
||||
/** Whether to show the overview tab */
|
||||
showOverview?: boolean;
|
||||
/** Contextual information for the sidebar */
|
||||
sidebarContext: SidebarContextType;
|
||||
};
|
||||
|
||||
/**
|
||||
* Navigation component for collection tabs, providing navigation between
|
||||
* different views of collection documents.
|
||||
*/
|
||||
const Navigation = observer(function Navigation({
|
||||
collection,
|
||||
onChangeTab,
|
||||
showOverview,
|
||||
sidebarContext,
|
||||
}: Props) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const tabProps = (path: CollectionTab) => ({
|
||||
exact: true,
|
||||
onClick: () => onChangeTab(path),
|
||||
to: {
|
||||
pathname: collectionPath(collection, path),
|
||||
state: { sidebarContext },
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<Tabs>
|
||||
{showOverview && (
|
||||
<Tab {...tabProps(CollectionTab.Overview)} exact={false}>
|
||||
{t("Overview")}
|
||||
</Tab>
|
||||
)}
|
||||
<Tab {...tabProps(CollectionTab.Recent)}>{t("Documents")}</Tab>
|
||||
{!collection.isArchived && (
|
||||
<>
|
||||
<Tab {...tabProps(CollectionTab.Popular)}>{t("Popular")}</Tab>
|
||||
<Tab {...tabProps(CollectionTab.Updated)}>
|
||||
{t("Recently updated")}
|
||||
</Tab>
|
||||
<Tab {...tabProps(CollectionTab.Published)}>
|
||||
{t("Recently published")}
|
||||
</Tab>
|
||||
<Tab {...tabProps(CollectionTab.Old)}>
|
||||
{t("Least recently updated")}
|
||||
</Tab>
|
||||
<Tab {...tabProps(CollectionTab.Alphabetical)}>{t("A–Z")}</Tab>
|
||||
</>
|
||||
)}
|
||||
</Tabs>
|
||||
);
|
||||
});
|
||||
|
||||
export default Navigation;
|
||||
@@ -1,6 +1,6 @@
|
||||
import debounce from "lodash/debounce";
|
||||
import { observer } from "mobx-react";
|
||||
import { useMemo, useRef, useCallback, Suspense } from "react";
|
||||
import { useMemo, useRef, useCallback, useEffect, Suspense } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { toast } from "sonner";
|
||||
import styled from "styled-components";
|
||||
@@ -24,10 +24,10 @@ const extensions = withUIExtensions(richExtensions);
|
||||
|
||||
type Props = {
|
||||
collection: Collection;
|
||||
shareId?: string;
|
||||
readOnly?: boolean;
|
||||
};
|
||||
|
||||
function Overview({ collection, shareId }: Props) {
|
||||
function Overview({ collection, readOnly }: Props) {
|
||||
const { documents, collections } = useStores();
|
||||
const { t } = useTranslation();
|
||||
const user = useCurrentUser({ rejectOnEmpty: false });
|
||||
@@ -48,6 +48,13 @@ function Overview({ collection, shareId }: Props) {
|
||||
[collection, t]
|
||||
);
|
||||
|
||||
useEffect(
|
||||
() => () => {
|
||||
handleSave.flush();
|
||||
},
|
||||
[handleSave]
|
||||
);
|
||||
|
||||
const childRef = useRef<HTMLDivElement>(null);
|
||||
const childOffsetHeight = childRef.current?.offsetHeight || 0;
|
||||
const editorStyle = useMemo(
|
||||
@@ -91,7 +98,7 @@ function Overview({ collection, shareId }: Props) {
|
||||
maxLength={CollectionValidation.maxDescriptionLength}
|
||||
onCreateLink={onCreateLink}
|
||||
canUpdate={can.update}
|
||||
readOnly={!can.update || !!shareId}
|
||||
readOnly={!can.update || readOnly}
|
||||
userId={user?.id}
|
||||
editorStyle={editorStyle}
|
||||
/>
|
||||
|
||||
+68
-155
@@ -1,5 +1,5 @@
|
||||
import { observer } from "mobx-react";
|
||||
import { useState, useCallback, useEffect, Suspense } from "react";
|
||||
import { useState, useEffect } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import {
|
||||
useParams,
|
||||
@@ -11,13 +11,9 @@ import {
|
||||
Redirect,
|
||||
} from "react-router-dom";
|
||||
import styled from "styled-components";
|
||||
import breakpoint from "styled-components-breakpoint";
|
||||
import { IconTitleWrapper } from "@shared/components/Icon";
|
||||
import { s } from "@shared/styles";
|
||||
import { StatusFilter } from "@shared/types";
|
||||
import { colorPalette } from "@shared/utils/collections";
|
||||
import Collection from "~/models/Collection";
|
||||
import { Action } from "~/components/Actions";
|
||||
import CenteredContent from "~/components/CenteredContent";
|
||||
import { CollectionBreadcrumb } from "~/components/CollectionBreadcrumb";
|
||||
import Heading from "~/components/Heading";
|
||||
@@ -28,77 +24,62 @@ import PaginatedDocumentList from "~/components/PaginatedDocumentList";
|
||||
import PinnedDocuments from "~/components/PinnedDocuments";
|
||||
import PlaceholderText from "~/components/PlaceholderText";
|
||||
import Scene from "~/components/Scene";
|
||||
import Tab from "~/components/Tab";
|
||||
import Tabs from "~/components/Tabs";
|
||||
import { editCollection } from "~/actions/definitions/collections";
|
||||
import useCommandBarActions from "~/hooks/useCommandBarActions";
|
||||
import { useLastVisitedPath } from "~/hooks/useLastVisitedPath";
|
||||
import { useLocationSidebarContext } from "~/hooks/useLocationSidebarContext";
|
||||
import usePersistedState from "~/hooks/usePersistedState";
|
||||
import { usePinnedDocuments } from "~/hooks/usePinnedDocuments";
|
||||
import usePolicy from "~/hooks/usePolicy";
|
||||
import useStores from "~/hooks/useStores";
|
||||
import { NotFoundError } from "~/utils/errors";
|
||||
import { collectionPath, updateCollectionPath } from "~/utils/routeHelpers";
|
||||
import {
|
||||
collectionEditPath,
|
||||
collectionPath,
|
||||
matchCollectionEdit,
|
||||
updateCollectionPath,
|
||||
} from "~/utils/routeHelpers";
|
||||
import Error404 from "../Errors/Error404";
|
||||
import Actions from "./components/Actions";
|
||||
import DropToImport from "./components/DropToImport";
|
||||
import Empty from "./components/Empty";
|
||||
import MembershipPreview from "./components/MembershipPreview";
|
||||
import Navigation, { CollectionTab } from "./components/Navigation";
|
||||
import Notices from "./components/Notices";
|
||||
import Overview from "./components/Overview";
|
||||
import first from "lodash/first";
|
||||
import lazyWithRetry from "~/utils/lazyWithRetry";
|
||||
|
||||
const IconPicker = lazyWithRetry(() => import("~/components/IconPicker"));
|
||||
|
||||
const ShareButton = lazyWithRetry(() => import("./components/ShareButton"));
|
||||
|
||||
enum CollectionPath {
|
||||
Overview = "overview",
|
||||
Recent = "recent",
|
||||
Popular = "popular",
|
||||
Updated = "updated",
|
||||
Published = "published",
|
||||
Old = "old",
|
||||
Alphabetical = "alphabetical",
|
||||
}
|
||||
import { Header } from "./components/Header";
|
||||
import usePersistedState from "~/hooks/usePersistedState";
|
||||
import useCurrentUser from "~/hooks/useCurrentUser";
|
||||
|
||||
const CollectionScene = observer(function _CollectionScene() {
|
||||
const params = useParams<{ id?: string }>();
|
||||
const params = useParams<{ collectionSlug?: string }>();
|
||||
const history = useHistory();
|
||||
const match = useRouteMatch();
|
||||
const location = useLocation();
|
||||
const { t } = useTranslation();
|
||||
const user = useCurrentUser();
|
||||
const { documents, collections, shares, ui } = useStores();
|
||||
const [error, setError] = useState<Error | undefined>();
|
||||
const currentPath = location.pathname;
|
||||
const [, setLastVisitedPath] = useLastVisitedPath();
|
||||
const sidebarContext = useLocationSidebarContext();
|
||||
const isEditRoute = match.path === matchCollectionEdit;
|
||||
|
||||
const id = params.id || "";
|
||||
const id = params.collectionSlug || "";
|
||||
const urlId = id.split("-").pop() ?? "";
|
||||
|
||||
const collection: Collection | null | undefined = collections.get(id);
|
||||
const can = usePolicy(collection);
|
||||
|
||||
const { pins, count } = usePinnedDocuments(urlId, collection?.id);
|
||||
const [collectionTab, setCollectionTab] = usePersistedState<CollectionPath>(
|
||||
|
||||
const [collectionTab, setCollectionTab] = usePersistedState<CollectionTab>(
|
||||
`collection-tab:${collection?.id}`,
|
||||
collection?.hasDescription
|
||||
? CollectionPath.Overview
|
||||
: CollectionPath.Recent,
|
||||
collection?.hasDescription ? CollectionTab.Overview : CollectionTab.Recent,
|
||||
{
|
||||
listen: false,
|
||||
}
|
||||
);
|
||||
|
||||
const handleIconChange = useCallback(
|
||||
(icon: string | null, color: string | null) =>
|
||||
collection?.save({ icon, color }),
|
||||
[collection]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
setLastVisitedPath(currentPath);
|
||||
}, [currentPath, setLastVisitedPath]);
|
||||
@@ -149,23 +130,13 @@ const CollectionScene = observer(function _CollectionScene() {
|
||||
if (!collection && error) {
|
||||
return <Error404 />;
|
||||
}
|
||||
if (!collection) {
|
||||
return <Loading />;
|
||||
}
|
||||
|
||||
const hasOverview = can.update || collection?.hasDescription;
|
||||
const showOverview = can.update || collection?.hasDescription;
|
||||
|
||||
const fallbackIcon = collection ? (
|
||||
<CollectionIcon collection={collection} size={40} expanded />
|
||||
) : null;
|
||||
|
||||
const tabProps = (path: CollectionPath) => ({
|
||||
exact: true,
|
||||
onClick: () => setCollectionTab(path),
|
||||
to: {
|
||||
pathname: collectionPath(collection!.path, path),
|
||||
state: { sidebarContext },
|
||||
},
|
||||
});
|
||||
|
||||
return collection ? (
|
||||
return (
|
||||
<Scene
|
||||
centered={false}
|
||||
textTitle={collection.name}
|
||||
@@ -190,10 +161,11 @@ const CollectionScene = observer(function _CollectionScene() {
|
||||
actions={
|
||||
<>
|
||||
<MembershipPreview collection={collection} />
|
||||
<Action>
|
||||
{can.update && <ShareButton collection={collection} />}
|
||||
</Action>
|
||||
<Actions collection={collection} />
|
||||
<Actions
|
||||
collection={collection}
|
||||
isEditing={isEditRoute}
|
||||
sidebarContext={sidebarContext}
|
||||
/>
|
||||
</>
|
||||
}
|
||||
>
|
||||
@@ -204,28 +176,7 @@ const CollectionScene = observer(function _CollectionScene() {
|
||||
>
|
||||
<CenteredContent withStickyHeader>
|
||||
<Notices collection={collection} />
|
||||
<CollectionHeading>
|
||||
<IconTitleWrapper>
|
||||
{can.update ? (
|
||||
<Suspense fallback={fallbackIcon}>
|
||||
<IconPicker
|
||||
icon={collection.icon ?? "collection"}
|
||||
color={collection.color ?? (first(colorPalette) as string)}
|
||||
initial={collection.initial}
|
||||
size={40}
|
||||
popoverPosition="bottom-start"
|
||||
onChange={handleIconChange}
|
||||
borderOnHover
|
||||
>
|
||||
{fallbackIcon}
|
||||
</IconPicker>
|
||||
</Suspense>
|
||||
) : (
|
||||
fallbackIcon
|
||||
)}
|
||||
</IconTitleWrapper>
|
||||
{collection.name}
|
||||
</CollectionHeading>
|
||||
<Header collection={collection} />
|
||||
|
||||
<PinnedDocuments
|
||||
pins={pins}
|
||||
@@ -233,54 +184,39 @@ const CollectionScene = observer(function _CollectionScene() {
|
||||
placeholderCount={count}
|
||||
/>
|
||||
|
||||
<Documents>
|
||||
<Tabs>
|
||||
{hasOverview && (
|
||||
<Tab {...tabProps(CollectionPath.Overview)}>
|
||||
{t("Overview")}
|
||||
</Tab>
|
||||
)}
|
||||
<Tab {...tabProps(CollectionPath.Recent)}>{t("Documents")}</Tab>
|
||||
{!collection.isArchived && (
|
||||
<>
|
||||
<Tab {...tabProps(CollectionPath.Popular)}>
|
||||
{t("Popular")}
|
||||
</Tab>
|
||||
<Tab {...tabProps(CollectionPath.Updated)}>
|
||||
{t("Recently updated")}
|
||||
</Tab>
|
||||
<Tab {...tabProps(CollectionPath.Published)}>
|
||||
{t("Recently published")}
|
||||
</Tab>
|
||||
<Tab {...tabProps(CollectionPath.Old)}>
|
||||
{t("Least recently updated")}
|
||||
</Tab>
|
||||
<Tab {...tabProps(CollectionPath.Alphabetical)}>
|
||||
{t("A–Z")}
|
||||
</Tab>
|
||||
</>
|
||||
)}
|
||||
</Tabs>
|
||||
<Content>
|
||||
<Navigation
|
||||
collection={collection}
|
||||
onChangeTab={setCollectionTab}
|
||||
showOverview={showOverview}
|
||||
sidebarContext={sidebarContext}
|
||||
/>
|
||||
<Switch>
|
||||
<Route path={collectionPath(collection.path)} exact>
|
||||
<Route path={collectionPath(collection)} exact>
|
||||
<Redirect
|
||||
to={{
|
||||
pathname: collectionPath(collection!.path, collectionTab),
|
||||
pathname: collectionPath(collection!, collectionTab),
|
||||
state: { sidebarContext },
|
||||
}}
|
||||
/>
|
||||
</Route>
|
||||
<Route
|
||||
path={collectionPath(collection.path, CollectionPath.Overview)}
|
||||
path={[
|
||||
collectionPath(collection, CollectionTab.Overview),
|
||||
collectionEditPath(collection),
|
||||
]}
|
||||
>
|
||||
{hasOverview ? (
|
||||
<Overview collection={collection} />
|
||||
{showOverview ? (
|
||||
<Overview
|
||||
collection={collection}
|
||||
readOnly={!isEditRoute && !!user?.separateEditMode}
|
||||
/>
|
||||
) : (
|
||||
<Redirect
|
||||
to={{
|
||||
pathname: collectionPath(
|
||||
collection.path,
|
||||
CollectionPath.Recent
|
||||
collection,
|
||||
CollectionTab.Recent
|
||||
),
|
||||
state: { sidebarContext },
|
||||
}}
|
||||
@@ -293,8 +229,8 @@ const CollectionScene = observer(function _CollectionScene() {
|
||||
<>
|
||||
<Route
|
||||
path={collectionPath(
|
||||
collection.path,
|
||||
CollectionPath.Alphabetical
|
||||
collection,
|
||||
CollectionTab.Alphabetical
|
||||
)}
|
||||
>
|
||||
<PaginatedDocumentList
|
||||
@@ -308,9 +244,7 @@ const CollectionScene = observer(function _CollectionScene() {
|
||||
}}
|
||||
/>
|
||||
</Route>
|
||||
<Route
|
||||
path={collectionPath(collection.path, CollectionPath.Old)}
|
||||
>
|
||||
<Route path={collectionPath(collection, CollectionTab.Old)}>
|
||||
<PaginatedDocumentList
|
||||
key="old"
|
||||
documents={documents.leastRecentlyUpdatedInCollection(
|
||||
@@ -323,10 +257,7 @@ const CollectionScene = observer(function _CollectionScene() {
|
||||
/>
|
||||
</Route>
|
||||
<Route
|
||||
path={collectionPath(
|
||||
collection.path,
|
||||
CollectionPath.Published
|
||||
)}
|
||||
path={collectionPath(collection, CollectionTab.Published)}
|
||||
>
|
||||
<PaginatedDocumentList
|
||||
key="published"
|
||||
@@ -341,10 +272,7 @@ const CollectionScene = observer(function _CollectionScene() {
|
||||
/>
|
||||
</Route>
|
||||
<Route
|
||||
path={collectionPath(
|
||||
collection.path,
|
||||
CollectionPath.Updated
|
||||
)}
|
||||
path={collectionPath(collection, CollectionTab.Updated)}
|
||||
>
|
||||
<PaginatedDocumentList
|
||||
key="updated"
|
||||
@@ -358,10 +286,7 @@ const CollectionScene = observer(function _CollectionScene() {
|
||||
/>
|
||||
</Route>
|
||||
<Route
|
||||
path={collectionPath(
|
||||
collection.path,
|
||||
CollectionPath.Popular
|
||||
)}
|
||||
path={collectionPath(collection, CollectionTab.Popular)}
|
||||
>
|
||||
<PaginatedDocumentList
|
||||
key="popular"
|
||||
@@ -373,10 +298,7 @@ const CollectionScene = observer(function _CollectionScene() {
|
||||
/>
|
||||
</Route>
|
||||
<Route
|
||||
path={collectionPath(
|
||||
collection.path,
|
||||
CollectionPath.Recent
|
||||
)}
|
||||
path={collectionPath(collection, CollectionTab.Recent)}
|
||||
exact
|
||||
>
|
||||
<PaginatedDocumentList
|
||||
@@ -394,7 +316,7 @@ const CollectionScene = observer(function _CollectionScene() {
|
||||
</>
|
||||
) : (
|
||||
<Route
|
||||
path={collectionPath(collection.path, CollectionPath.Recent)}
|
||||
path={collectionPath(collection, CollectionTab.Recent)}
|
||||
exact
|
||||
>
|
||||
<PaginatedDocumentList
|
||||
@@ -412,20 +334,22 @@ const CollectionScene = observer(function _CollectionScene() {
|
||||
</Route>
|
||||
)}
|
||||
</Switch>
|
||||
</Documents>
|
||||
</Content>
|
||||
</CenteredContent>
|
||||
</DropToImport>
|
||||
</Scene>
|
||||
) : (
|
||||
<CenteredContent>
|
||||
<Heading>
|
||||
<PlaceholderText height={35} />
|
||||
</Heading>
|
||||
<PlaceholderList count={5} />
|
||||
</CenteredContent>
|
||||
);
|
||||
});
|
||||
|
||||
const Loading = () => (
|
||||
<CenteredContent>
|
||||
<Heading>
|
||||
<PlaceholderText height={35} />
|
||||
</Heading>
|
||||
<PlaceholderList count={5} />
|
||||
</CenteredContent>
|
||||
);
|
||||
|
||||
const KeyedCollection = () => {
|
||||
const params = useParams<{ id?: string }>();
|
||||
|
||||
@@ -434,20 +358,9 @@ const KeyedCollection = () => {
|
||||
return <CollectionScene key={params.id} />;
|
||||
};
|
||||
|
||||
const Documents = styled.div`
|
||||
const Content = styled.div`
|
||||
position: relative;
|
||||
background: ${s("background")};
|
||||
`;
|
||||
|
||||
const CollectionHeading = styled(Heading)`
|
||||
display: flex;
|
||||
align-items: center;
|
||||
position: relative;
|
||||
margin-left: 40px;
|
||||
|
||||
${breakpoint("tablet")`
|
||||
margin-left: 0;
|
||||
`}
|
||||
`;
|
||||
|
||||
export default KeyedCollection;
|
||||
@@ -11,6 +11,7 @@ import useStores from "~/hooks/useStores";
|
||||
import {
|
||||
collectionPath,
|
||||
documentPath,
|
||||
homePath,
|
||||
settingsPath,
|
||||
} from "~/utils/routeHelpers";
|
||||
|
||||
@@ -67,7 +68,9 @@ function DocumentDelete({ document, onSubmit }: Props) {
|
||||
// Otherwise redirect to the collection (or) home.
|
||||
const path = document.template
|
||||
? settingsPath("templates")
|
||||
: collectionPath(collection?.path || "/");
|
||||
: collection
|
||||
? collectionPath(collection)
|
||||
: homePath();
|
||||
history.push(path);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ function SharedCollection({ collection }: Props) {
|
||||
as={Link}
|
||||
icon={<EditIcon />}
|
||||
to={{
|
||||
pathname: collectionPath(collection.path, "overview"),
|
||||
pathname: collectionPath(collection, "overview"),
|
||||
}}
|
||||
neutral
|
||||
>
|
||||
@@ -83,7 +83,7 @@ function SharedCollection({ collection }: Props) {
|
||||
</SharedMeta>
|
||||
) : null}
|
||||
</Flex>
|
||||
<Overview collection={collection} shareId={shareId} />
|
||||
<Overview collection={collection} readOnly />
|
||||
</CenteredContent>
|
||||
</Scene>
|
||||
);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import queryString from "query-string";
|
||||
import Collection from "~/models/Collection";
|
||||
import Comment from "~/models/Comment";
|
||||
import Document from "~/models/Document";
|
||||
import type Collection from "~/models/Collection";
|
||||
import type Comment from "~/models/Comment";
|
||||
import type Document from "~/models/Document";
|
||||
import env from "~/env";
|
||||
|
||||
export function homePath(): string {
|
||||
@@ -37,11 +37,18 @@ export function commentPath(document: Document, comment: Comment): string {
|
||||
}`;
|
||||
}
|
||||
|
||||
export function collectionPath(url: string, section?: string): string {
|
||||
export function collectionPath(
|
||||
collection: Collection,
|
||||
section?: string
|
||||
): string {
|
||||
if (section) {
|
||||
return `${url}/${section}`;
|
||||
return `${collection.path}/${section}`;
|
||||
}
|
||||
return url;
|
||||
return collection.path;
|
||||
}
|
||||
|
||||
export function collectionEditPath(collection: Collection): string {
|
||||
return collectionPath(collection, "overview/edit");
|
||||
}
|
||||
|
||||
export function updateCollectionPath(
|
||||
@@ -144,6 +151,8 @@ export function urlify(path: string): string {
|
||||
export const matchCollectionSlug =
|
||||
":collectionSlug([0-9a-zA-Z-_~]*-[a-zA-z0-9]{10,15})";
|
||||
|
||||
export const matchCollectionEdit = `/collection/${matchCollectionSlug}/overview/edit`;
|
||||
|
||||
export const matchDocumentSlug =
|
||||
":documentSlug([0-9a-zA-Z-_~]*-[a-zA-z0-9]{10,15})";
|
||||
|
||||
|
||||
@@ -678,6 +678,7 @@
|
||||
"90 days": "90 days",
|
||||
"No expiration": "No expiration",
|
||||
"The document archive is empty at the moment.": "The document archive is empty at the moment.",
|
||||
"Done editing": "Done editing",
|
||||
"Drop documents to import": "Drop documents to import",
|
||||
"<em>{{ collectionName }}</em> doesn’t contain any\n documents yet.": "<em>{{ collectionName }}</em> doesn’t contain any\n documents yet.",
|
||||
"{{ usersCount }} users and {{ groupsCount }} groups with access": "{{ usersCount }} user and {{ groupsCount }} groups with access",
|
||||
@@ -688,15 +689,15 @@
|
||||
"{{ usersCount }} users with access_plural": "{{ usersCount }} users with access",
|
||||
"{{ groupsCount }} groups with access": "{{ groupsCount }} group with access",
|
||||
"{{ groupsCount }} groups with access_plural": "{{ groupsCount }} groups with access",
|
||||
"Archived by {{userName}}": "Archived by {{userName}}",
|
||||
"Sorry, an error occurred saving the collection": "Sorry, an error occurred saving the collection",
|
||||
"Add a description": "Add a description",
|
||||
"Overview": "Overview",
|
||||
"Popular": "Popular",
|
||||
"Recently updated": "Recently updated",
|
||||
"Recently published": "Recently published",
|
||||
"Least recently updated": "Least recently updated",
|
||||
"A–Z": "A–Z",
|
||||
"Archived by {{userName}}": "Archived by {{userName}}",
|
||||
"Sorry, an error occurred saving the collection": "Sorry, an error occurred saving the collection",
|
||||
"Add a description": "Add a description",
|
||||
"Signing in": "Signing in",
|
||||
"You can safely close this window once the Outline desktop app has opened": "You can safely close this window once the Outline desktop app has opened",
|
||||
"Error creating comment": "Error creating comment",
|
||||
@@ -745,7 +746,6 @@
|
||||
"Edit {{noun}}": "Edit {{noun}}",
|
||||
"Archived": "Archived",
|
||||
"Save draft": "Save draft",
|
||||
"Done editing": "Done editing",
|
||||
"Restore version": "Restore version",
|
||||
"No history yet": "No history yet",
|
||||
"Source": "Source",
|
||||
|
||||
Reference in new issue
Block a user