refactor(tree): borrow cleanups from the sibling expand-all impl

- extract collectAllIds / collectBranchIds into tree/utils and use them in
  space-tree.tsx instead of inline closures
- drop the duplicate SidebarPageTreeDto, reuse the existing SidebarPageDto
  for the /pages/tree endpoint
- type the getSpaceTree client call as api.post<{ items: IPage[] }>

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
vvzvlad
2026-06-20 17:39:34 +03:00
parent b38b71eb51
commit 234ae759f5
5 changed files with 37 additions and 31 deletions

View File

@@ -9,13 +9,3 @@ export class SidebarPageDto {
@IsString()
pageId: string;
}
export class SidebarPageTreeDto {
@IsOptional()
@IsUUID()
spaceId?: string;
@IsOptional()
@IsString()
pageId?: string;
}

View File

@@ -32,7 +32,7 @@ import {
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard';
import { PaginationOptions } from '@docmost/db/pagination/pagination-options';
import { Page, User, Workspace } from '@docmost/db/types/entity.types';
import { SidebarPageDto, SidebarPageTreeDto } from './dto/sidebar-page.dto';
import { SidebarPageDto } from './dto/sidebar-page.dto';
import {
SpaceCaslAction,
SpaceCaslSubject,
@@ -581,7 +581,7 @@ export class PageController {
@HttpCode(HttpStatus.OK)
@Post('/tree')
async getPagesTree(
@Body() dto: SidebarPageTreeDto,
@Body() dto: SidebarPageDto,
@AuthUser() user: User,
) {
if (!dto.spaceId && !dto.pageId) {