Open james-strauss-uwa opened 2 days ago
This PR implements a new developer setting that allows EAGLE to automatically fetch repository contents when loading a graph from a URL. The implementation includes a significant refactoring of the GitHub and GitLab repository loading logic to use async/await, improving the reliability of repository loading. Additionally, a new developer setting was added to control the visibility of translator JSON in the console.
sequenceDiagram
actor User
participant EAGLE
participant GitHub
participant GitLab
participant Repositories
participant localStorage
User->>EAGLE: Load graph from URL
EAGLE->>GitHub: loadRepoList()
GitHub->>Repositories: Fetch repositories
GitHub->>localStorage: Fetch custom repositories
localStorage-->>GitHub: Return custom repositories
GitHub-->>Repositories: Return repositories
EAGLE->>GitLab: loadRepoList()
GitLab->>Repositories: Fetch repositories
GitLab->>localStorage: Fetch custom repositories
localStorage-->>GitLab: Return custom repositories
GitLab-->>Repositories: Return repositories
Repositories->>EAGLE: Update repository list
EAGLE->>User: Graph loaded with repository contents
classDiagram
class GitHub {
+async refresh()
+async loadRepoList() Promise<Repository[]>
}
class GitLab {
+async refresh()
+async loadRepoList() Promise<Repository[]>
}
class Repositories {
+static listCustomRepositories(service: Repository.Service) Repository[]
+addCustomRepository()
}
class Setting {
+static FETCH_REPOSITORY_FOR_URLS
+static PRINT_TRANSLATOR_JSON_TO_JS_CONSOLE
}
GitHub --> Repositories
GitLab --> Repositories
Repositories --> Setting
Repositories --> GitHub
Repositories --> GitLab
Setting <.. Repositories: uses
Setting <.. GitHub: uses
Setting <.. GitLab: uses
note for GitHub "Refactored to use async/await"
note for GitLab "Refactored to use async/await"
note for Repositories "New method for listing custom repositories"
Change | Details | Files |
---|---|---|
Refactored repository loading logic to use async/await pattern |
|
src/GitHub.ts src/GitLab.ts |
Added new developer settings for repository loading and console output |
|
src/Setting.ts |
Modified repository and graph loading sequence |
|
src/main.ts |
Improved translator console output handling |
|
src/Translator.ts |
Yes, I think we could also open the folder hierarchy down to the graph's location. I'll add that.
I guess we could also add the repo if it doesn't exist. I'll probably add it permanently, rather than temporarily.
OK, I've added:
Note: the existing error messages are shown when:
If the new setting is enabled, then when EAGLE "autoloads" a graph from the URL, it will also fetch the contents of the repository the graph is from.
If the repository is not already in EAGLE's list of repositories, then nothing extra will happen.
I also improved the GitLab and GitHub repository list-building functions to use async/await, so that "fetching the contents" of the repo can be done AFTER the repository list has been fully build. Previously, if the repository list took longer than usual to read from localStorage, or fetch from the EAGLE server, then EAGLE would attempt to load the repo contents before the repo was in EAGLE's list of repositories, which would fail.
I also snuck in a new setting to enable/disable printing the JSON sent to the translator to the javascript console. This just cleans up the console a little during normal operation.
Summary by Sourcery
Add a developer setting to load repositories from URLs and improve repository list handling with async/await.
New Features:
Enhancements: