Skip to content

Publish feature/respect page selection - #2916

Merged
kjoscha merged 9 commits into
feature/collectives-publishfrom
publish-feature/respect-page-selection
Nov 10, 2026
Merged

kjoscha merged 9 commits into
feature/collectives-publishfrom
publish-feature/respect-page-selection

Conversation

@kjoscha

@kjoscha kjoscha commented Nov 3, 2026 •

Copy link
Copy Markdown
  • StaticSiteContentCollector now only collects selected pages, their
    ancestors, and their attachments, instead of the whole collective
  • StaticSiteService resolves and adds missing ancestor page IDs so a
    subpage can never be selected without its parent pages
  • CollectivePublishModal auto-selects a page's parent pages when the
    page itself is selected, keeping selection state consistent with
    the backend's hierarchy requirement
Screencast From 2026-11-03 15-39-47

@kjoscha
kjoscha changed the base branch from main to feature/collectives-publish November 3, 2026 14:36
@kjoscha
kjoscha force-pushed the publish-feature/respect-page-selection branch 3 times, most recently from 2e529b9 to 5b61d59 Compare November 9, 2026 16:11
- StaticSiteContentCollector now only collects selected pages, their
  ancestors, and their attachments, instead of the whole collective
- StaticSiteService resolves and adds missing ancestor page IDs so a
  subpage can never be selected without its parent pages
- CollectivePublishModal auto-selects a page's parent pages when the
  page itself is selected, keeping selection state consistent with
  the backend's hierarchy requirement

Assisted-by: ClaudeCode:claude-sonnet-5
Signed-off-by: kayoshi <jo5cha@web.de>
@kjoscha
kjoscha force-pushed the publish-feature/respect-page-selection branch from 5b61d59 to f1fa170 Compare November 9, 2026 16:11
@code4candy

code4candy commented Nov 9, 2026 •

Copy link
Copy Markdown

Sonnet had some valuable ramarks:

  • 1. Hidden files and folders are published (severity: low)

    • Collective folders live in appdata_/collectives// and are mounted into every member's
      files (CollectiveFolderManager::getMount(), MountProvider). Members can add files via Files app,
      WebDAV or the desktop client.
    • Collectives itself only creates .templates/ (top level) and .attachments./. Hidden entries can
      still appear from outside, e.g. .DS_Store / ._* (Finder WebDAV mount), .obsidian/, .git/.
    • PageInfoTreeBuilder ignores hidden entries (line 78), so they are never pages and can't be (de)selected
      in the UI. The collector still includes them:
      • hidden files in a page folder via collectFiles() (lines 84–88),
      • hidden folders via collectSubFolder() → collectFiles() → no index page → collectAllFiles() (line 70),
      • hidden files inside attachment folders via collectAllFiles() (line 116).
    • Not a regression (everything was published before), but it contradicts "only selected content is published".
    • Suggested fix: in the loop of collectFiles() (lines 79–82) skip entries starting with . except
      .attachments.*; this also covers .templates, so the TEMPLATE_FOLDER check becomes redundant.
      Apply the same check (without the attachment exception) in collectAllFiles(). Shared helper isHidden(Node).
    • Related: the collector relies on findAll() creating missing index pages beforehand
      (PageInfoTreeBuilder.php:96-108) – hidden coupling, currently safe.
  • 2. Stored selection is not normalized in the UI

    CollectivePublishModal::created() only removes deleted pages from the stored selection. If a page was moved
    after publication (or the selection predates this commit), a subpage can be checked while its parent is not.
    The backend fixes this on publish, but the dialog shows an inconsistent state. Suggestion: add ancestors of
    every preselected page on load, reusing the same helper.

  • 3. DRY: .attachments. prefix hard-coded in several places

    AttachmentService.php:71,230, PageTrashBackend.php:260, NodeHelper.php:206, FileIndexer.php:132, plus
    the new private constant. Suggestion: one public constant or helper (e.g. NodeHelper::getAttachmentFolderPageId()),
    used in the new code; migrating the existing places as a separate refactor commit.
    Minor: (int)substr(...) parses .attachments.12abc as 12 → check with ctype_digit.

  • 4. Frontend: parentPageIds() lives in the modal instead of the pages store

    parentPageIds() in CollectivePublishModal.vue works correctly. The point is where it lives, not a bug.

    • Why it belongs in the store: The other page tree getters already live in src/stores/pages.js (pagesTreeWalkForCollective, visibleSubpagesForCollective, pageParentsForCollective). Walking up the
      page hierarchy is generic tree logic, not modal-specific. As a store getter it can be reused, for example to normalize the preselection when the modal loads (see finding 2).
    • Why the existing pageParentsForCollective can't be reused: Its loop stops at state.rootPage, which is the root page of the currently opened collective, not the collective passed in. The modal is
      also opened from CollectiveSelector for other collectives, so the result would depend on context:
      • For the current collective, the root page is excluded.
      • For any other collective, the root page is included.
      • It also includes the page itself and returns page objects in top-down order, because it was built for the breadcrumbs.
    • Suggestion: Move the logic into a new store getter that uses only the given collective and stops at parentId === 0, e.g. pageAncestorIdsForCollective(collective, pageId). Leave
      pageParentsForCollective unchanged, since it serves the breadcrumbs and changing it is out of scope.
    • Naming: The backend calls the same concept "ancestors" (resolvePageIdsWithAncestors). "parentPageIds" suggests only the direct parent, while the function returns all ancestors up to the root page.
      ancestorPageIds is more precise and consistent with the backend.
  1. Missing tests

    • Collector: hidden file/folder cases, .attachments. of the index page of an unselected subfolder,
      attachment folder with invalid suffix. testCollectSkipsTemplateFolderOnlyAtTopLevel needs adjusting if
      hidden entries are skipped everywhere.
    • Service: unordered input, e.g. [3, 1] → [3, 2, 1] without duplicates.
    • Frontend: no coverage of the new selection logic; e2e cases in playwright/e2e/collective-publish.spec.ts
      (select subpage → parents and root checked; deselect parent → children unchecked; preselection with moved page).
  2. Minor

    • Comment "Everything but a subpage is an attachment of this page" is inaccurate (the index page is a page file too --> "README.md").

    • important for UI: indeterminate state for partially selected, collapsed parent pages. --> otherwise there is no indicator, for a collapsed directory, if all or only some subpages / subfolders are selected --> see image:

image

kayoshi added 8 commits November 10, 2026 15:07
Hidden entries are never pages, so they can't be (de)selected in the UI.
Publishing them anyway contradicts "only selected content is published" and
leaked things like .DS_Store, .obsidian/ or .git/ that members added from
outside. Attachment folders stay the only exception; the dedicated
.templates check becomes redundant and now also applies to nested folders.

Assisted-by: ClaudeCode:claude-sonnet-5
Signed-off-by: kayoshi <jo5cha@web.de>
…odal

A page moved since the last publication could show up checked while its
parent was not. The backend already pulls in the ancestors on publish, so
do the same when loading the stored selection to keep the dialog
consistent with what gets published.

Assisted-by: ClaudeCode:claude-sonnet-5
Signed-off-by: kayoshi <jo5cha@web.de>
Instead of hard-coding the `.attachments.` prefix, the static site collector
uses NodeHelper to build and parse attachment folder names. A folder only
counts as attachment folder if its suffix is a numeric page ID now.

Assisted-by: ClaudeCode:claude-sonnet-5
Signed-off-by: kayoshi <jo5cha@web.de>
Replace the remaining hard-coded `.attachments.` prefixes. The page ID mock
in the NodeHelper test returned a string, the real `getId()` returns an int.

Assisted-by: ClaudeCode:claude-sonnet-5
Signed-off-by: kayoshi <jo5cha@web.de>
Walking up the page hierarchy is generic tree logic, not modal-specific, and
can now be reused. The existing pageParentsForCollective can't serve this:
it stops at the currently opened collective's root page, so its result
depends on which collective is passed in. Name it after the backend's
"ancestors" wording, since it returns all ancestors, not just the parent.

Assisted-by: ClaudeCode:claude-sonnet-5
Signed-off-by: kayoshi <jo5cha@web.de>
Cover attachments of the index page of a subpage folder, a selection
whose ancestors are resolved out of order, the ancestor lookup in the
pages store and selecting/deselecting pages in the publish modal.

Assisted-by: ClaudeCode:claude-sonnet-5
Signed-off-by: kayoshi <jo5cha@web.de>
…tent

Assisted-by: ClaudeCode:claude-sonnet-5
Signed-off-by: kayoshi <jo5cha@web.de>
Assisted-by: ClaudeCode:claude-sonnet-5
Signed-off-by: kayoshi <jo5cha@web.de>
@kjoscha
kjoscha force-pushed the publish-feature/respect-page-selection branch from 109d034 to 298482f Compare November 10, 2026 14:38
@kjoscha
kjoscha merged commit c2bc04f into feature/collectives-publish Nov 10, 2026
53 checks passed
@kjoscha
kjoscha deleted the publish-feature/respect-page-selection branch November 10, 2026 15:07
@github-actions

Copy link
Copy Markdown
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants