Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Ancillary feature #204

Merged
merged 24 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
9929559
Add tocs event handler for drag and drop
TylerZeroMaster May 20, 2024
5a256a6
Update vscode types to latest version
TylerZeroMaster May 20, 2024
7946661
Always set dragging to undefined after a drop
TylerZeroMaster May 21, 2024
7a4c9f5
Add orphans to tree view and try to fix coverage
TylerZeroMaster May 21, 2024
50ce134
Use contextValue to conditionally add buttons to tree items
TylerZeroMaster May 22, 2024
96fcd69
Use capabilities instead of ToCNodeKind for tree condition
TylerZeroMaster May 22, 2024
cf905dd
Use data transfer items instead of class field for dragged item
TylerZeroMaster May 22, 2024
c11bd2c
Update tests; add some polish
TylerZeroMaster May 22, 2024
f8764a6
Find parent book recursively instead of iteratively
TylerZeroMaster May 23, 2024
4ae148c
Remove seemingly unnecessary istanbul ignores
TylerZeroMaster May 23, 2024
a93d014
When moving node to different book, update both collection files
TylerZeroMaster May 23, 2024
769eb6c
Fix typo in comment
TylerZeroMaster May 23, 2024
5e0dffd
Merge branch 'main' of https://github.com/openstax/poet into sk-ancil…
sparksam Jun 25, 2024
fdd527c
Add Ancillary functionality to TOC Tree
sparksam Jun 25, 2024
73918f6
Fixed test cases
sparksam Jun 26, 2024
29b4b01
Added `book-tocs` snapshot to commit.
sparksam Jun 30, 2024
12f1d95
Code lint
sparksam Jun 30, 2024
d74a76e
Fixed the code coverage.
sparksam Jul 16, 2024
195c636
Merge branch 'main' of https://github.com/openstax/poet into sk-ancil…
sparksam Jul 16, 2024
b12e2cb
Fixed bug when the no node was selected
sparksam Jul 22, 2024
d7cc00b
Move leaf nodes into Book and Subbook drop targets
TylerZeroMaster Jul 22, 2024
f096716
Properly handle ouroboros case for subbooks
TylerZeroMaster Jul 22, 2024
63f1d52
Added possibility to create nodes in selected books and subbooks
sparksam Jul 29, 2024
db72511
Updated the tests.
sparksam Jul 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"@types/node": "^17.0.16",
"@types/react-sortable-tree": "^0.3.15",
"@types/uuid": "^8.3.4",
"@types/vscode": "^1.64.0",
"@types/vscode": "^1.89.0",
"@types/xmldom": "^0.1.31",
"json-stable-stringify": "^1.0.1",
"preact": "^10.6.5",
Expand Down
6 changes: 6 additions & 0 deletions client/specs/__mocks__/vscode.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ class CodeLens {}
class DocumentLink {}
class CodeAction {}
class CallHierarchyItem {}
class DataTransferItem {
constructor(value) { this.value = value }
}
class DataTransfer {}

class ThemeIcon {
static File = 'File'
Expand Down Expand Up @@ -222,6 +226,8 @@ const vscode = {
ProgressLocation,
FileSystemError,
TextEditorRevealType,
DataTransferItem,
DataTransfer
};

module.exports = { ...vscode, default: vscode };
14 changes: 14 additions & 0 deletions client/specs/__snapshots__/book-tocs.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ exports[`Toc Provider filters fileids when filtering is set 1`] = `
"command": "vscode.open",
"title": "open",
},
"contextValue": "rename,delete",
"description": "fileId",
"iconPath": "File",
"label": "title",
Expand All @@ -39,6 +40,7 @@ exports[`Toc Provider filters fileids when filtering is set 2`] = `
"command": "vscode.open",
"title": "open",
},
"contextValue": "rename,delete",
"iconPath": "File",
"label": "title (fileId)",
"resourceUri": {
Expand All @@ -63,6 +65,7 @@ exports[`Toc Provider filters fileids when filtering is set 3`] = `
"command": "vscode.open",
"title": "open",
},
"contextValue": "rename,delete",
"description": "fileId",
"iconPath": "File",
"label": "title",
Expand Down Expand Up @@ -102,6 +105,7 @@ exports[`Toc Provider returns tree items for children 1`] = `
exports[`Toc Provider returns tree items for children 2`] = `
{
"collapsibleState": "Collapsed",
"contextValue": "rename",
"iconPath": "Folder",
"label": "title",
}
Expand All @@ -121,6 +125,7 @@ exports[`Toc Provider returns tree items for children 3`] = `
"command": "vscode.open",
"title": "open",
},
"contextValue": "rename",
"description": "fileId",
"iconPath": "File",
"label": "title",
Expand All @@ -131,3 +136,12 @@ exports[`Toc Provider returns tree items for children 3`] = `
},
}
`;

exports[`Toc Provider returns tree items for children 4`] = `
{
"collapsibleState": "Collapsed",
"contextValue": "rename",
"iconPath": "Folder",
"label": "title",
}
`;
18 changes: 15 additions & 3 deletions client/specs/book-tocs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,19 @@ const testTocPage: ClientTocNode = {
fileId: 'fileId'
}
}
const testTocAncillary: ClientTocNode = {
type: TocNodeKind.Ancillary,
value: {
absPath: '/path/to/ancillary',
token: 'token',
title: 'title',
fileId: 'fileId'
}
}
const testTocSubbook: ClientTocNode = {
type: TocNodeKind.Subbook,
value: { token: 'token', title: 'title' },
children: [testTocPage]
children: [testTocPage, testTocAncillary]
}
const testToc: BookToc = {
type: BookRootNode.Singleton,
Expand All @@ -27,15 +36,17 @@ const testToc: BookToc = {
licenseUrl: 'licenseUrl',
tocTree: [testTocSubbook]
}

describe('Toc Provider', () => {
const p = new TocsTreeProvider()
it('returns tree items for children', () => {
expect(p.getTreeItem(testToc)).toMatchSnapshot()
expect(p.getTreeItem(testTocSubbook)).toMatchSnapshot()
expect(p.getTreeItem(testTocPage)).toMatchSnapshot()
expect(p.getTreeItem(testTocAncillary)).toMatchSnapshot()
})
it('filters fileids when filtering is set', () => {
const p = new TocsTreeProvider()
p.update([testToc], [])
expect(p.getTreeItem(testTocPage)).toMatchSnapshot()
p.toggleFilterMode()
expect(p.getTreeItem(testTocPage)).toMatchSnapshot()
Expand All @@ -50,10 +61,11 @@ describe('Toc Provider', () => {
expect(p.getTreeItem(nonloadedPage).label).toBe(`Loading... (${nonloadedPage.value.fileId})`)
})
it('gets children and parents', () => {
p.update([testToc])
p.update([testToc], [])
expect(p.getChildren()).toEqual([testToc])
expect(p.getParent(testToc)).toBe(undefined)
expect(p.getChildren(testToc)).toEqual(testToc.tocTree)
expect(p.getParent(testToc.tocTree[0])).toBe(testToc)
expect(p.getParentBook(testToc)).toBe(undefined)
})
})
Loading
Loading