mirror of
https://github.com/multipleof4/octopus-file-browser.git
synced 2026-09-25 12:35:25 +00:00
Show one directory at a time and let the app load each directory
The browser no longer takes a nested tree. The app sets path and the current directory's entries; selecting a directory or .. emits octopus:navigate with the requested path for the app to load. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+15
-2
@@ -1,6 +1,19 @@
|
||||
import './demo.css';
|
||||
import './octopus-file-browser.js';
|
||||
import entries from 'virtual:octopus-repo-tree';
|
||||
import tree from 'virtual:octopus-repo-tree';
|
||||
|
||||
const browser = document.querySelector('octopus-file-browser');
|
||||
browser.entries = entries;
|
||||
|
||||
// Stands in for an app backend: returns one directory listing per request.
|
||||
function list(path) {
|
||||
return path.reduce((entries, name) =>
|
||||
entries.find((entry) => entry.type === 'directory' && entry.name === name)?.children || [], tree)
|
||||
.map(({ children, ...entry }) => entry);
|
||||
}
|
||||
|
||||
browser.addEventListener('octopus:navigate', ({ detail }) => {
|
||||
browser.path = detail.path;
|
||||
browser.entries = list(detail.path);
|
||||
});
|
||||
|
||||
browser.entries = list([]);
|
||||
|
||||
Reference in New Issue
Block a user