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

EAGLE-1295: Add support for "LocalDirectory"-type repositories #753

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

james-strauss-uwa
Copy link
Collaborator

@james-strauss-uwa james-strauss-uwa commented Nov 4, 2024

Allow users to add "LocalDirectory"-type repositories to EAGLE's repository list. User's can load and save graphs as normal.

We re-use the "add custom git repository" modal to add the LocalDirectory-type repository. I've just removed the word "git" from the modal title.
We re-use the "git commit" modal to save files. I've just removed the word "git" from the modal title. And I hide the "commit message" input on the modal if we are saving to a "LocalDirectory"-type repo.

The contents of the "LocalDirectory"-type repos are shown as expected. Only graphs, palettes, and READMEs are shown, other files are hidden. The ".git" directory is hidden. Files are sorted directories-first, then alphabetically.

I also made a change to the Typescript config JSON (tsconfig.json), adding two libraries: "DOM.Iterable" and "DOM.AsyncIterable". These are required to provide type definitions for the FileSystemHandle.entries() function.

Issues:

  • LocalDirectory repositories are not stored in localStorage, so they are forgotten when EAGLE is reloaded. The FileSystemDirectoryHandle (which stores in information on the location of the directory on disk) can not be serialised to a string, and therefore can't be stored in localStorage. According to the internet, it can only be stored in the browser's IndexedDB. So I've created a JIRA ticket (EAGLE-1328) to migrate repositories from localStorage to IndexedDB.
  • There is no menu item to store files into LocalDirectory-type repos. The user can only use the 's' keyboard shortcut, or the 'save graph' quick action.
  • There is no way to save palettes to the LocalDirectory-type repos, unless the palette originated from a LocalDirectory-type repo, in which case saving will default to the original location.

I'm planning on adding "LocalGit"-type next, which will rely on the eagleServer.py loading data from git repos.

Summary by Sourcery

Introduce support for 'LocalDirectory'-type repositories, enabling users to manage local directories similarly to Git repositories. Adjust the UI and repository handling logic to integrate this new repository type, and update TypeScript configuration to support necessary file system operations.

New Features:

  • Add support for 'LocalDirectory'-type repositories, allowing users to add, load, and save graphs from local directories.

Enhancements:

  • Modify the repository management UI to accommodate 'LocalDirectory'-type repositories by reusing existing modals with minor adjustments.
  • Update the file and folder handling logic to support local directory operations, including sorting and filtering of files.

Build:

  • Update TypeScript configuration to include 'DOM.Iterable' and 'DOM.AsyncIterable' libraries for type definitions.

Copy link
Contributor

sourcery-ai bot commented Nov 4, 2024

Reviewer's Guide by Sourcery

This PR adds support for "LocalDirectory"-type repositories, allowing users to load and save graphs directly from local directories without git. The implementation reuses existing UI components, adapts them for local directory operations, and adds new functionality to handle local filesystem operations using the File System Access API.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Added new LocalDirectory repository type and core functionality
  • Added LocalDirectory as a new repository service type
  • Implemented file loading and saving operations for local directories using FileSystemHandle API
  • Added directory selection functionality using window.showDirectoryPicker
  • Implemented file sorting and filtering for local directory contents
src/Repository.ts
src/Repositories.ts
Modified UI components to support LocalDirectory repositories
  • Updated repository modal to handle LocalDirectory type selection
  • Modified commit modal to hide git-specific elements for LocalDirectory repos
  • Added directory selection button and input field
  • Updated repository component to display LocalDirectory icon and name
templates/modals.html
static/components/repository.html
src/Modals.ts
Updated save/load operations in Eagle class
  • Added LocalDirectory handling to saveGraph and saveGraphAs methods
  • Implemented saveFileToLocalDirectory method
  • Updated file loading operations to support LocalDirectory repositories
src/Eagle.ts
Added FileSystemHandle support to data structures
  • Added handle property to Repository class for storing FileSystemDirectoryHandle
  • Added handle property to RepositoryFile for storing FileSystemFileHandle
  • Added handle property to RepositoryFolder for storing FileSystemDirectoryHandle
src/Repository.ts
src/RepositoryFile.ts
src/RepositoryFolder.ts
Updated TypeScript configuration and utilities
  • Added DOM.Iterable and DOM.AsyncIterable libraries to tsconfig.json
  • Added utility functions for handling LocalDirectory operations
  • Added constants for directory picker ID
tsconfig.json
src/Utils.ts
src/EagleConfig.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @james-strauss-uwa - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

…e in the wrong place if a directory was specified incorrectly, resulting in the wrong file returned.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant