Files
outline/server/presenters/collection.ts
codegen-sh[bot]andTom Moor c02a33a74c feat: Disable commenting per collection (#9295)
* Address PR feedback: Move commenting logic to Collection model

- Update openDocumentComments action to use collection.canCreateComment
- Update AuthenticatedLayout to check collection-level commenting setting
- Update DocumentMeta to use collection commenting preference
- Add commenting field to CollectionForm with proper UI
- Maintain backward compatibility with team-level preferences

* Applied automatic fixes

* Disable comment creation UI when collection commenting is disabled

- Update Editor component to use collection-level commenting setting
- Pass onCreateCommentMark as undefined when commenting is disabled
- This removes the shortcut and toolbar icon for comment creation
- Maintains backward compatibility with team-level preferences

* Fix TypeScript error in Editor component

- Fix props destructuring to avoid variable shadowing
- Ensure all required props are properly destructured
- Maintain correct property order from original implementation

* Fix TypeScript error: add missing activeCollectionId parameter

- Add activeCollectionId to import document action perform function
- This parameter was being used but not declared in the function signature
- Fixes TS2304 error: Cannot find name 'activeCollectionId'

* fix form

* docs

---------

Co-authored-by: codegen-sh[bot] <131295404+codegen-sh[bot]@users.noreply.github.com>
Co-authored-by: Tom Moor <tom@getoutline.com>
2025-05-24 18:35:50 -04:00

33 lines
1.1 KiB
TypeScript

import Collection from "@server/models/Collection";
import { DocumentHelper } from "@server/models/helpers/DocumentHelper";
import { APIContext } from "@server/types";
import presentUser from "./user";
export default async function presentCollection(
ctx: APIContext | undefined,
collection: Collection
) {
const asData = !ctx || Number(ctx?.headers["x-api-version"] ?? 0) >= 3;
return {
id: collection.id,
url: collection.url,
urlId: collection.urlId,
name: collection.name,
data: asData ? await DocumentHelper.toJSON(collection) : undefined,
description: asData ? undefined : collection.description,
sort: collection.sort,
icon: collection.icon,
index: collection.index,
color: collection.color,
permission: collection.permission,
commenting: collection.commenting,
sharing: collection.sharing,
createdAt: collection.createdAt,
updatedAt: collection.updatedAt,
deletedAt: collection.deletedAt,
archivedAt: collection.archivedAt,
archivedBy: collection.archivedBy && presentUser(collection.archivedBy),
};
}