diff --git a/client/specs/__snapshots__/book-tocs.spec.ts.snap b/client/specs/__snapshots__/book-tocs.spec.ts.snap index 88b4bbe1..a81de877 100644 --- a/client/specs/__snapshots__/book-tocs.spec.ts.snap +++ b/client/specs/__snapshots__/book-tocs.spec.ts.snap @@ -176,7 +176,7 @@ exports[`filtering toggleTocTreesFilteringHandler 1`] = ` [ { "children": [], - "type": "ClientOnlyTocKinds.OrphanCollection", + "type": "OrphanCollection", "value": undefined, }, { diff --git a/client/specs/book-tocs.spec.ts b/client/specs/book-tocs.spec.ts index 2cc92bdf..44725b64 100644 --- a/client/specs/book-tocs.spec.ts +++ b/client/specs/book-tocs.spec.ts @@ -3,7 +3,7 @@ import type vscode from 'vscode' import { expect } from '@jest/globals' import { BookRootNode, type BookToc, type ClientTocNode, TocNodeKind } from '../../common/src/toc' -import { type BookOrTocNode, ClientOnlyTocKinds, TocsTreeProvider, toggleTocTreesFilteringHandler } from '../src/book-tocs' +import { type BookOrTocNode, type OrphanCollection, OrphanCollectionKind, TocsTreeProvider, toggleTocTreesFilteringHandler } from '../src/book-tocs' const testTocPage: ClientTocNode = { type: TocNodeKind.Page, @@ -38,8 +38,8 @@ const testToc: BookToc = { licenseUrl: 'licenseUrl', tocTree: [testTocSubbook] } -const testOrphanCollection = { - type: ClientOnlyTocKinds.OrphanCollection, +const testOrphanCollection: OrphanCollection = { + type: OrphanCollectionKind, children: [] } describe('Toc Provider', () => { @@ -69,7 +69,7 @@ describe('Toc Provider', () => { }) it('gets children and parents', () => { p.update([testToc], []) - expect(p.getChildren()).toEqual([testToc, { children: [], type: ClientOnlyTocKinds.OrphanCollection, value: undefined }]) + expect(p.getChildren()).toEqual([testToc, { children: [], type: OrphanCollectionKind, value: undefined }]) expect(p.getParent(testToc)).toBe(undefined) expect(p.getChildren(testToc)).toEqual(testToc.tocTree) expect(p.getParent(testToc.tocTree[0])).toBe(testToc) @@ -98,7 +98,7 @@ describe('filtering', () => { const fakeChildren = [ { type: BookRootNode.Singleton, tocTree: [{ type: TocNodeKind.Subbook, label: 'unit1', children: [{ type: TocNodeKind.Subbook, label: 'subcol1', children: [{ type: TocNodeKind.Page, label: 'm2', children: [] }] }] }] }, { type: BookRootNode.Singleton, tocTree: [{ label: 'm1', children: [] }] }, - { type: ClientOnlyTocKinds.OrphanCollection, children: [], value: undefined } + { type: OrphanCollectionKind, children: [], value: undefined } ] getChildrenStub.returns(fakeChildren) diff --git a/client/src/book-tocs.ts b/client/src/book-tocs.ts index b06c2d8d..6751856e 100644 --- a/client/src/book-tocs.ts +++ b/client/src/book-tocs.ts @@ -3,13 +3,11 @@ import { EventEmitter, type TreeItem, TreeItemCollapsibleState, Uri, type TreeDa import { type BookToc, type ClientTocNode, BookRootNode, TocNodeKind, type ClientPageish } from '../../common/src/toc' import type vscode from 'vscode' -export enum ClientOnlyTocKinds { - OrphanCollection = 'ClientOnlyTocKinds.OrphanCollection' -} +export const OrphanCollectionKind = 'OrphanCollection' -interface OrphanCollection { - type: ClientOnlyTocKinds.OrphanCollection - children: BookOrTocNode[] +export interface OrphanCollection { + type: typeof OrphanCollectionKind + children: Array } export type BookOrTocNode = BookToc | ClientTocNode | OrphanCollection @@ -32,7 +30,7 @@ export class TocsTreeProvider implements TreeDataProvider { constructor() { this.bookTocs = [] - this.orphanCollection = { type: ClientOnlyTocKinds.OrphanCollection, children: [] } + this.orphanCollection = { type: OrphanCollectionKind, children: [] } } public toggleFilterMode() { @@ -96,7 +94,7 @@ export class TocsTreeProvider implements TreeDataProvider { label: node.value.title, contextValue: capabilities.join(',') } - case ClientOnlyTocKinds.OrphanCollection: + case OrphanCollectionKind: return { iconPath: TocItemIcon.Subbook, collapsibleState: TreeItemCollapsibleState.Collapsed, diff --git a/client/src/tocs-event-handler.ts b/client/src/tocs-event-handler.ts index 2462f9fe..5cd1412c 100644 --- a/client/src/tocs-event-handler.ts +++ b/client/src/tocs-event-handler.ts @@ -1,5 +1,5 @@ import vscode from 'vscode' -import { type TocsTreeProvider, type BookOrTocNode, ClientOnlyTocKinds } from './book-tocs' +import { type TocsTreeProvider, type BookOrTocNode, OrphanCollectionKind } from './book-tocs' import { type TocModification, TocModificationKind, type TocModificationParams, TocNodeKind, BookRootNode, type CreatePageEvent, type CreateSubbookEvent, type CreateAncillaryEvent, isClientTocNode } from '../../common/src/toc' import { ExtensionServerRequest } from '../../common/src/requests' import { expect, getRootPathUri } from './utils' @@ -212,10 +212,10 @@ export class TocsEventHandler implements vscode.TreeDragAndDropController