Phase B (items 1-6) of docs/AFFINE.md.
Properties: workspaces define custom page properties (text, number,
checkbox, date, select, multi-select, person, link) in the new
workspace_properties collection; pages keep their values in
pages.properties, checked against each property's type. The Info panel
under the title shows tags, custom and built-in properties, following
each property's visibility; the Info side panel shows them all, with the
page's collections and the journal. Settings gains Page properties and
Tags sections.
Tags: coloured, per workspace (tags collection, pages.tags); create from
the picker, rename, recolour, merge and delete. Search filters by tag.
All docs: GET /workspaces/{id}/docs lists the pages the caller can open
with their properties, narrowed by space, tag, collection or filter
rules evaluated on the server. The view shows a list, grid or cards,
groups and orders by any property, picks the properties shown, and acts
on several pages at once (tag, move, trash, collect).
Collections (page_collections): saved rules plus pages added or taken
out by hand, private to their creator until shared with the workspace,
listed in the sidebar.
Journals: one page per person and day in a private journal space
(spaces.journal_owner) that workspace admins do not see into, made on
first use. A week strip marks days with pages, new days can start from
a template, and dates in read mode open that day's journal.
The migration and schema snapshot, OpenAPI spec and generated Go, TS and
Dart types are updated (the Dart generator learns untyped values), the
mobile editor bundle is rebuilt, the new strings are translated into all
five languages, and the user guide covers the new features.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
55 lines
1.9 KiB
Go
55 lines
1.9 KiB
Go
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
package access
|
|
|
|
import "docwell/server/internal/apperr"
|
|
|
|
// Properties, tags and collections organize a workspace's pages. Anyone who
|
|
// works in the workspace (members and above) may shape them; guests, who see
|
|
// only pages shared with them, may only read them.
|
|
|
|
// OrganizeWorkspace allows adding, renaming and removing a workspace's page
|
|
// properties and tags, and making collections.
|
|
func OrganizeWorkspace(wsRole string) error {
|
|
switch {
|
|
case wsRole == "":
|
|
return apperr.NotFound("workspace not found")
|
|
case !AtLeast(wsRole, WorkspaceMember):
|
|
return apperr.Forbidden("guests cannot change the workspace's properties, tags or collections")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EditCollection allows changing or deleting a collection: its creator may,
|
|
// and workspace admins may change shared ones.
|
|
func EditCollection(callerID, wsRole, creator string, shared bool) error {
|
|
if err := OrganizeWorkspace(wsRole); err != nil {
|
|
return err
|
|
}
|
|
if callerID == creator || (shared && AtLeast(wsRole, WorkspaceAdmin)) {
|
|
return nil
|
|
}
|
|
return apperr.Forbidden("only the collection's creator can change it")
|
|
}
|
|
|
|
// KeepJournal allows having a journal in a workspace (members and above).
|
|
func KeepJournal(wsRole string) error { return OrganizeWorkspace(wsRole) }
|
|
|
|
// JournalSpaceRole is the caller's role in someone's journal space. It belongs
|
|
// to its owner: workspace admins get no role from the cascade, so it stays
|
|
// out of their sidebar and search. A role given in the space itself (the
|
|
// owner's, or someone the owner added) still counts, and pages shared from it
|
|
// are reached through page grants as usual.
|
|
func JournalSpaceRole(wsRole, owner, callerID, memberRole string) string {
|
|
switch {
|
|
case wsRole == "":
|
|
return ""
|
|
case ValidSpaceRole(memberRole):
|
|
return memberRole
|
|
case owner == callerID:
|
|
// The owner is the space's admin even if their membership row is gone.
|
|
return SpaceAdmin
|
|
}
|
|
return ""
|
|
}
|