Skip to content

Commit 2224ff0

Browse files
committed
Add tree view support to browse datalayer spaces
1 parent 8657d5a commit 2224ff0

File tree

8 files changed

+1155
-2
lines changed

8 files changed

+1155
-2
lines changed

packages/vscode/.gitignore

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Build outputs
2+
out/
3+
dist/
4+
*.vsix
5+
6+
# Dependencies
7+
node_modules/
8+
9+
# IDE
10+
.vscode-test/
11+
*.suo
12+
*.ntvs*
13+
*.njsproj
14+
*.sln
15+
*.sw?
16+
17+
# Logs
18+
npm-debug.log*
19+
yarn-debug.log*
20+
yarn-error.log*
21+
22+
# OS
23+
.DS_Store
24+
Thumbs.db
25+
26+
# Environment
27+
.env
28+
.env.local

packages/vscode/CLAUDE.md

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
## Project Overview
44

5-
This is a VS Code extension that provides a custom Jupyter Notebook editor with integrated Datalayer platform authentication. It uses the `@datalayer/jupyter-react` component library and supports both local Jupyter servers and the Datalayer cloud platform.
5+
This is a VS Code extension that provides a custom Jupyter Notebook editor with integrated Datalayer platform authentication and a Spaces tree view for managing cloud documents. It uses the `@datalayer/jupyter-react` component library and supports both local Jupyter servers and the Datalayer cloud platform.
66

77
## Architecture
88

99
- **Extension Code** (`src/`): Runs in VS Code's Node.js context, handles authentication and server communication
1010
- **Webview Code** (`webview/`): Runs in an iframe, contains the React-based notebook editor
1111
- **Authentication System** (`src/auth/`): Token-based authentication with GitHub profile enrichment
12+
- **Spaces Tree View** (`src/spaces/`): Explorer sidebar for browsing Datalayer spaces and documents
1213
- **Communication**: Message passing between extension and webview with JWT token injection
1314

1415
## Development Setup
@@ -20,11 +21,25 @@ This is a VS Code extension that provides a custom Jupyter Notebook editor with
2021

2122
## Key Components
2223

24+
### Core Extension
25+
2326
- `src/extension.ts`: Main extension entry point with auth command registration
27+
- `src/notebookEditor.ts`: Custom editor provider with authenticated connections
28+
29+
### Authentication System
30+
2431
- `src/auth/authService.ts`: Authentication service with secure token storage
2532
- `src/auth/githubService.ts`: GitHub profile enrichment service
2633
- `src/auth/tokenProvider.ts`: User interface for authentication flows
27-
- `src/notebookEditor.ts`: Custom editor provider with authenticated connections
34+
35+
### Spaces Tree View
36+
37+
- `src/spaces/spacesTreeProvider.ts`: Tree data provider for Datalayer spaces
38+
- `src/spaces/spacerApiService.ts`: API service for fetching spaces and documents
39+
- `src/spaces/spaceItem.ts`: Data models for tree items
40+
41+
### Webview
42+
2843
- `webview/NotebookVSCode.tsx`: React component for the notebook UI
2944
- `webview/serviceManager.ts`: Handles Jupyter service connections with JWT tokens
3045

@@ -70,6 +85,9 @@ This is a VS Code extension that provides a custom Jupyter Notebook editor with
7085
- `datalayer.login`: Authenticate with Datalayer platform
7186
- `datalayer.logout`: Sign out and clear credentials
7287
- `datalayer.showAuthStatus`: View authentication status
88+
- `datalayer.refreshSpaces`: Refresh the Spaces tree view
89+
- `datalayer.openDocument`: Open a document from the Spaces tree
90+
- `datalayer.createNotebookInSpace`: Create a new notebook in a selected space
7391

7492
## Configuration
7593

@@ -89,3 +107,35 @@ This is a VS Code extension that provides a custom Jupyter Notebook editor with
89107

90108
- View Type: `datalayer.jupyter-notebook`
91109
- File Pattern: `*.ipynb`
110+
111+
## Spaces Tree View
112+
113+
The extension includes a tree view in the Explorer sidebar that displays:
114+
115+
- User's Datalayer spaces (with default space marked)
116+
- Documents within each space:
117+
- Notebooks (`.ipynb` files)
118+
- Lexical documents (`.lexical` files)
119+
- Exercises and other document types
120+
- Real-time sync with the Datalayer platform
121+
- Context menu actions for creating new notebooks
122+
123+
### API Endpoints Used
124+
125+
- `/api/spacer/v1/spaces/users/me` - Get user's spaces
126+
- `/api/spacer/v1/spaces/{id}/items` - Get items in a space
127+
- `/api/spacer/v1/notebooks` - Create new notebooks
128+
129+
## Directory Structure
130+
131+
```
132+
src/
133+
├── auth/ # Authentication services
134+
├── spaces/ # Spaces tree view implementation
135+
├── test/ # Test files
136+
├── extension.ts # Main extension entry
137+
└── notebookEditor.ts # Notebook editor provider
138+
139+
webview/ # React-based notebook UI
140+
dist/ # Webpack build output
141+
```

packages/vscode/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,34 @@ This [Visual Studio Code](https://code.visualstudio.com) extension allows you to
1616
- **Real-time Execution**: Run code cells with live output and error display
1717
- **IPyWidgets Support**: Full interactive widget support
1818
- **Status Bar Integration**: View connection status and user profile
19+
- **Spaces Tree View**: Browse and manage documents across all your Datalayer spaces
20+
21+
## Spaces Tree View
22+
23+
The extension provides a tree view in the Explorer sidebar that displays all your Datalayer spaces and documents:
24+
25+
### Features
26+
27+
- **Hierarchical Display**: Shows "Datalayer (@username)" as root, with spaces as folders containing documents
28+
- **Document Types**: Displays notebooks with `.ipynb` extension and documents with `.lexical` extension
29+
- **Default Space**: Marks your default space with "(Default)" label
30+
- **Real-time Updates**: Refreshes when authentication state changes
31+
- **Error Handling**: Shows helpful messages when not authenticated or when spaces are empty
32+
33+
### Tree Structure
34+
35+
```
36+
Datalayer (@username)
37+
├── My Library (Default)
38+
│ ├── notebook1.ipynb
39+
│ ├── document1.lexical
40+
│ └── notebook2.ipynb
41+
├── Project Space
42+
│ ├── analysis.ipynb
43+
│ └── notes.lexical
44+
└── Shared Space
45+
└── collaboration.ipynb
46+
```
1947

2048
## Authentication
2149

@@ -32,6 +60,9 @@ The extension supports authentication with the Datalayer platform:
3260
- `Datalayer: Logout from Datalayer` - Sign out and clear stored credentials
3361
- `Datalayer: Show Authentication Status` - View current authentication status
3462
- `Datalayer: Create new Datalayer Notebook` - Create a new notebook file
63+
- `Datalayer: Refresh Spaces` - Refresh the spaces tree view
64+
- `Datalayer: Open Document` - Open a document from the tree view (automatic on click)
65+
- `Datalayer: Create Notebook in Space` - Create a new notebook in a selected space
3566

3667
### Configuration
3768

packages/vscode/package.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,59 @@
4343
"command": "datalayer.showAuthStatus",
4444
"title": "Show Authentication Status",
4545
"category": "Datalayer"
46+
},
47+
{
48+
"command": "datalayer.refreshSpaces",
49+
"title": "Refresh Spaces",
50+
"category": "Datalayer",
51+
"icon": "$(refresh)"
52+
},
53+
{
54+
"command": "datalayer.openDocument",
55+
"title": "Open Document",
56+
"category": "Datalayer"
57+
},
58+
{
59+
"command": "datalayer.createNotebookInSpace",
60+
"title": "Create Notebook in Space",
61+
"category": "Datalayer",
62+
"icon": "$(add)"
4663
}
4764
],
65+
"views": {
66+
"explorer": [
67+
{
68+
"id": "datalayerSpaces",
69+
"name": "Datalayer Spaces",
70+
"icon": "$(menu)",
71+
"contextualTitle": "Datalayer Spaces",
72+
"when": "true"
73+
}
74+
]
75+
},
76+
"viewsWelcome": [
77+
{
78+
"view": "datalayerSpaces",
79+
"contents": "Welcome to Datalayer Spaces.\n[Login to Datalayer](command:datalayer.login) to view your spaces and documents.",
80+
"when": "!datalayer.authenticated"
81+
}
82+
],
83+
"menus": {
84+
"view/title": [
85+
{
86+
"command": "datalayer.refreshSpaces",
87+
"when": "view == datalayerSpaces",
88+
"group": "navigation"
89+
}
90+
],
91+
"view/item/context": [
92+
{
93+
"command": "datalayer.createNotebookInSpace",
94+
"when": "view == datalayerSpaces && viewItem == space",
95+
"group": "inline"
96+
}
97+
]
98+
},
4899
"configuration": {
49100
"title": "Datalayer",
50101
"properties": {

0 commit comments

Comments
 (0)