mirror of
https://github.com/outline/outline.git
synced 2026-12-06 11:12:32 +03:00
* feat: Add document owners Documents can now have owners, stored as an array of user IDs. Owners must be active members or admins, and changing them requires the existing manage users permission on the document, gated behind a new DocumentOwners plan entitlement that is included in every plan. - ownerIds accepted by documents.create and documents.update and returned by the document presenter - ownerIds filter field (eq/in) for documents.list and documents.search - ownerIds on the MCP create_document and update_document tools, and an ownerId filter on list_documents - Owners section in the document Insights dialog to add and remove owners - Owner filter on the search page - In-app and email notification when a user is made an owner Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016MJXFdSZ39ZGPf31jyGcYz * feat: Give document owners responsibility for their documents - Access requests are routed to owners that can manage the document before falling back to document, collection and workspace admins - Owners are subscribed to a document when they are added, respecting a previous unsubscribe - Owners that can edit a document can also manage its access, owners and archive it; ownership never grants access on its own - Owners are shown in the document byline, list items and search results, and document hover previews Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016MJXFdSZ39ZGPf31jyGcYz * feat: Manage document owners from the share panel - Owner is a role in the share panel permission menu and invite picker for individual users, adding an owner gives them the manage permission - Lowering an owner's permission or removing their access removes the ownership - Owners are sorted to the top of the member list - Owners added through the API or MCP are given the manage permission - Owners do not also receive the "added to document" notification - Only added owners are validated, so suspended owners can still be removed - Deleted users are removed from document owners - Removes the owners section from Insights * fix: Address review feedback on document owners - Authorize owner changes before assigning owners on create - Lock the document when adding an owner so concurrent invitations are kept - Enforce the owner limit on every path - Run MCP document updates in a transaction - Broadcast owner removals to connected clients * feat: Add collection owners - Collections can have owners, who also own every document in the collection, shown first in document bylines - Owner is a role in the collection share panel and invite picker for individual users, adding an owner gives them the manage permission - Lowering an owner's permission or removing their access removes the ownership - ownerIds on collections.create, collections.update and the MCP collection tools - The document owner filter includes documents in owned collections - Access requests go to document and collection owners together - Collection owners are subscribed to the collection and notified when they are added - Deleted users are removed from collection owners - Renames the personal collection policy helper to isPersonalCollectionOwner * feat: Show profile cards on owner names, hide inherited owners in collection lists * fix: Allow adding yourself as a collection owner, include collection owners in MCP exact match * fix: Correct singular owner translations * feat: Allow users to make themselves a document owner - The share panel suggests the current user when they can manage owners, and only offers the Owner permission for them - documents.add_user accepts the actor's own ID when changing ownership, without changing their own access - An owner's own row offers "Remove as owner", which keeps their access - Hides the duplicate "You have full access" row when the current user is listed as a member * fix: Restore singular owner translations * fix: Limit owners to 5, use no key update locks when adding owners * refactor: Move owner logic into Document and Collection model methods - addOwner, removeOwner, grantOwnerAccess and setOwnerIds on both models, locking the row so concurrent owner changes are kept - Owner events are created by an update hook from the change in ownerIds - The manageOwners check runs at the route level when ownerIds is sent - Removes the documentOwners and collectionOwners command modules - Removes duplicate owner tests * fix: Owner selection and membership edge cases - Remove document owners from the legacy plan - Selecting yourself in the share picker only suggests other users that can be owners, and you are not suggested next to groups or guests - Users that make themselves an owner through the API get the manage permission, so they are listed in the share panel * perf: Scope the collection owner filter subquery to the team * chore: Drop redundant teamId UUID check --------- Co-authored-by: Claude <noreply@anthropic.com>
414 lines
12 KiB
TypeScript
414 lines
12 KiB
TypeScript
import { debounce } from "es-toolkit/compat";
|
|
import { runInAction } from "mobx";
|
|
import { observer } from "mobx-react";
|
|
import {
|
|
AcademicCapIcon,
|
|
CheckboxIcon,
|
|
CollectionIcon,
|
|
CommentIcon,
|
|
DocumentIcon,
|
|
DoneIcon,
|
|
EditIcon,
|
|
EmailIcon,
|
|
PublishIcon,
|
|
SmileyIcon,
|
|
StarredIcon,
|
|
UserIcon,
|
|
GroupIcon,
|
|
} from "outline-icons";
|
|
import * as React from "react";
|
|
import { useTranslation, Trans } from "react-i18next";
|
|
import { toast } from "sonner";
|
|
import { NotificationEventType } from "@shared/types";
|
|
import { errToString } from "@shared/utils/error";
|
|
import Heading from "~/components/Heading";
|
|
import Notice from "~/components/Notice";
|
|
import Scene from "~/components/Scene";
|
|
import Switch from "~/components/Switch";
|
|
import Text from "~/components/Text";
|
|
import useCurrentUser from "~/hooks/useCurrentUser";
|
|
import { client } from "~/utils/ApiClient";
|
|
import isCloudHosted from "~/utils/isCloudHosted";
|
|
import SettingRow from "./components/SettingRow";
|
|
import { SettingsSection } from "./components/SettingsSection";
|
|
|
|
interface NotificationOption {
|
|
/** The event types that the option controls. */
|
|
events: NotificationEventType[];
|
|
/** The icon for the option. */
|
|
icon: React.ReactNode;
|
|
/** The label for the option. */
|
|
title: string;
|
|
/** The description for the option. */
|
|
description: string;
|
|
}
|
|
|
|
interface NotificationGroup {
|
|
/** A stable key for the group. */
|
|
id: string;
|
|
/** The section heading. */
|
|
title: string;
|
|
/** A summary of the notification types in the group. */
|
|
description: string;
|
|
/** Whether the group is shown. Defaults to true. */
|
|
visible?: boolean;
|
|
/** The options in the group. */
|
|
options: NotificationOption[];
|
|
}
|
|
|
|
function Notifications() {
|
|
const user = useCurrentUser();
|
|
const { t } = useTranslation();
|
|
|
|
const groups: NotificationGroup[] = [
|
|
{
|
|
id: "documents",
|
|
title: t("Documents"),
|
|
description: t(
|
|
"Documents that are published, updated, or shared with you, and access requests"
|
|
),
|
|
options: [
|
|
{
|
|
events: [NotificationEventType.PublishDocument],
|
|
icon: <PublishIcon />,
|
|
title: t("Document published"),
|
|
description: t(
|
|
"Receive a notification whenever a new document is published"
|
|
),
|
|
},
|
|
{
|
|
events: [NotificationEventType.UpdateDocument],
|
|
icon: <EditIcon />,
|
|
title: t("Document updated"),
|
|
description: t(
|
|
"Receive a notification when a document you are subscribed to is edited"
|
|
),
|
|
},
|
|
{
|
|
events: [NotificationEventType.AddUserToDocument],
|
|
icon: <DocumentIcon />,
|
|
title: t("Invited to document"),
|
|
description: t(
|
|
"Receive a notification when a document is shared with you"
|
|
),
|
|
},
|
|
{
|
|
events: [
|
|
NotificationEventType.AddOwnerToDocument,
|
|
NotificationEventType.AddOwnerToCollection,
|
|
],
|
|
icon: <DocumentIcon />,
|
|
title: t("Made an owner"),
|
|
description: t(
|
|
"Receive a notification when you are made an owner of a document or collection"
|
|
),
|
|
},
|
|
{
|
|
events: [NotificationEventType.RequestDocumentAccess],
|
|
icon: <CheckboxIcon checked />,
|
|
title: t("Document access requested"),
|
|
description: t(
|
|
"Receive a notification when a user requests access to a document you manage"
|
|
),
|
|
},
|
|
],
|
|
},
|
|
{
|
|
id: "collections",
|
|
title: t("Collections"),
|
|
description: t("New collections and access to collections"),
|
|
options: [
|
|
{
|
|
events: [NotificationEventType.CreateCollection],
|
|
icon: <CollectionIcon />,
|
|
title: t("Collection created"),
|
|
description: t(
|
|
"Receive a notification whenever a new collection is created"
|
|
),
|
|
},
|
|
{
|
|
events: [NotificationEventType.AddUserToCollection],
|
|
icon: <CollectionIcon />,
|
|
title: t("Invited to collection"),
|
|
description: t(
|
|
"Receive a notification when you are given access to a collection"
|
|
),
|
|
},
|
|
],
|
|
},
|
|
{
|
|
id: "comments",
|
|
title: t("Comments and mentions"),
|
|
description: t(
|
|
"New comments, mentions of you or your groups, resolved threads, and reactions"
|
|
),
|
|
options: [
|
|
{
|
|
events: [NotificationEventType.CreateComment],
|
|
icon: <CommentIcon />,
|
|
title: t("Comment posted"),
|
|
description: t(
|
|
"Receive a notification when a document you are subscribed to or a thread you participated in receives a comment"
|
|
),
|
|
},
|
|
{
|
|
events: [
|
|
NotificationEventType.MentionedInComment,
|
|
NotificationEventType.MentionedInDocument,
|
|
],
|
|
icon: <EmailIcon />,
|
|
title: t("Mentioned"),
|
|
description: t(
|
|
"Receive a notification when someone mentions you in a document or comment"
|
|
),
|
|
},
|
|
{
|
|
events: [
|
|
NotificationEventType.GroupMentionedInDocument,
|
|
NotificationEventType.GroupMentionedInComment,
|
|
],
|
|
icon: <GroupIcon />,
|
|
title: t("Group mentions"),
|
|
description: t(
|
|
"Receive a notification when someone mentions a group you are a member of in a document or comment"
|
|
),
|
|
},
|
|
{
|
|
events: [NotificationEventType.ResolveComment],
|
|
icon: <DoneIcon />,
|
|
title: t("Resolved"),
|
|
description: t(
|
|
"Receive a notification when a comment thread you were involved in is resolved"
|
|
),
|
|
},
|
|
{
|
|
events: [NotificationEventType.ReactionsCreate],
|
|
icon: <SmileyIcon />,
|
|
title: t("Reaction added"),
|
|
description: t(
|
|
"Receive a notification when someone reacts to your comment"
|
|
),
|
|
},
|
|
],
|
|
},
|
|
{
|
|
id: "workspace",
|
|
title: t("Workspace"),
|
|
description: t(
|
|
"Group membership, accepted invites, and completed exports"
|
|
),
|
|
options: [
|
|
{
|
|
events: [NotificationEventType.AddUserToGroup],
|
|
icon: <GroupIcon />,
|
|
title: t("Group membership"),
|
|
description: t(
|
|
"Receive a notification when you are added to or removed from a group"
|
|
),
|
|
},
|
|
{
|
|
events: [NotificationEventType.InviteAccepted],
|
|
icon: <UserIcon />,
|
|
title: t("Invite accepted"),
|
|
description: t(
|
|
"Receive a notification when someone you invited creates an account"
|
|
),
|
|
},
|
|
{
|
|
events: [NotificationEventType.ExportCompleted],
|
|
icon: <CheckboxIcon checked />,
|
|
title: t("Export completed"),
|
|
description: t(
|
|
"Receive a notification when an export you requested has been completed"
|
|
),
|
|
},
|
|
],
|
|
},
|
|
{
|
|
id: "product",
|
|
title: t("Product updates"),
|
|
description: t(
|
|
"Tips on getting started and announcements of new features"
|
|
),
|
|
visible: isCloudHosted,
|
|
options: [
|
|
{
|
|
icon: <AcademicCapIcon />,
|
|
events: [NotificationEventType.Onboarding],
|
|
title: t("Getting started"),
|
|
description: t(
|
|
"Tips on getting started with features and functionality"
|
|
),
|
|
},
|
|
{
|
|
icon: <StarredIcon />,
|
|
events: [NotificationEventType.Features],
|
|
title: t("New features"),
|
|
description: t(
|
|
"Receive an email when new features of note are added"
|
|
),
|
|
},
|
|
],
|
|
},
|
|
];
|
|
|
|
const visibleGroups = groups.filter((group) => group.visible !== false);
|
|
const visibleEvents = visibleGroups.flatMap((group) =>
|
|
group.options.flatMap((option) => option.events)
|
|
);
|
|
|
|
const showSuccessMessage = debounce(() => {
|
|
toast.success(t("Notifications saved"));
|
|
}, 500);
|
|
|
|
const handleChange = React.useCallback(
|
|
(eventTypes: NotificationEventType[]) => async (checked: boolean) => {
|
|
const changed = eventTypes.filter(
|
|
(eventType) => user.subscribedToEventType(eventType) !== checked
|
|
);
|
|
|
|
// Update all switches at once, before the requests complete.
|
|
runInAction(() => {
|
|
const updated = { ...user.notificationSettings };
|
|
for (const eventType of changed) {
|
|
updated[eventType] = checked;
|
|
}
|
|
user.notificationSettings = updated;
|
|
});
|
|
|
|
const unsaved = new Set(changed);
|
|
|
|
try {
|
|
// Sequential, as each request saves the full settings object.
|
|
for (const eventType of changed) {
|
|
await user.setNotificationEventType(eventType, checked);
|
|
unsaved.delete(eventType);
|
|
}
|
|
showSuccessMessage();
|
|
} catch (err) {
|
|
toast.error(errToString(err));
|
|
|
|
// Restore the events that were not saved.
|
|
runInAction(() => {
|
|
const updated = { ...user.notificationSettings };
|
|
for (const eventType of unsaved) {
|
|
updated[eventType] = !checked;
|
|
}
|
|
user.notificationSettings = updated;
|
|
});
|
|
}
|
|
},
|
|
[user, showSuccessMessage]
|
|
);
|
|
|
|
const handleToggleAll = React.useCallback(
|
|
async (checked: boolean) => {
|
|
runInAction(() => {
|
|
const updated = { ...user.notificationSettings };
|
|
for (const eventType of visibleEvents) {
|
|
updated[eventType] = checked;
|
|
}
|
|
user.notificationSettings = updated;
|
|
});
|
|
await client.post(
|
|
checked
|
|
? `/users.notificationsSubscribe`
|
|
: `/users.notificationsUnsubscribe`
|
|
);
|
|
showSuccessMessage();
|
|
},
|
|
[user, visibleEvents, showSuccessMessage]
|
|
);
|
|
|
|
const isSubscribed = (eventTypes: NotificationEventType[]) =>
|
|
eventTypes.every((eventType) => user.subscribedToEventType(eventType));
|
|
|
|
const allEnabled = isSubscribed(visibleEvents);
|
|
|
|
const showSuccessNotice = window.location.search === "?success";
|
|
|
|
return (
|
|
<Scene title={t("Notifications")} icon={<EmailIcon />}>
|
|
<Heading>{t("Notifications")}</Heading>
|
|
|
|
{showSuccessNotice && (
|
|
<Notice>
|
|
<Trans>
|
|
Unsubscription successful. Your notification settings were updated
|
|
</Trans>
|
|
</Notice>
|
|
)}
|
|
<Text as="p" type="secondary">
|
|
<Trans>Manage when and where you receive email notifications.</Trans>
|
|
</Text>
|
|
|
|
<SettingRow
|
|
name="allNotifications"
|
|
label={t("All notifications")}
|
|
compact
|
|
border={false}
|
|
>
|
|
<Switch
|
|
id="allNotifications"
|
|
checked={allEnabled}
|
|
onChange={handleToggleAll}
|
|
/>
|
|
</SettingRow>
|
|
|
|
{visibleGroups.map((group) => {
|
|
const groupEvents = group.options.flatMap((option) => option.events);
|
|
const groupChecked = isSubscribed(groupEvents);
|
|
const isMixed =
|
|
!groupChecked &&
|
|
groupEvents.some((eventType) =>
|
|
user.subscribedToEventType(eventType)
|
|
);
|
|
|
|
return (
|
|
<SettingsSection
|
|
key={group.id}
|
|
title={group.title}
|
|
description={group.description}
|
|
collapsible
|
|
defaultOpen={isMixed}
|
|
action={
|
|
<Switch
|
|
aria-label={group.title}
|
|
checked={groupChecked}
|
|
onChange={handleChange(groupEvents)}
|
|
/>
|
|
}
|
|
>
|
|
{group.options.map((option) => {
|
|
const [name] = option.events;
|
|
|
|
return (
|
|
<SettingRow
|
|
key={name}
|
|
label={option.title}
|
|
name={name}
|
|
description={
|
|
<Text size="small" type="secondary">
|
|
{option.description}
|
|
</Text>
|
|
}
|
|
compact
|
|
>
|
|
<Switch
|
|
id={name}
|
|
name={name}
|
|
checked={isSubscribed(option.events)}
|
|
onChange={handleChange(option.events)}
|
|
/>
|
|
</SettingRow>
|
|
);
|
|
})}
|
|
</SettingsSection>
|
|
);
|
|
})}
|
|
</Scene>
|
|
);
|
|
}
|
|
|
|
export default observer(Notifications);
|