+
Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.

Feature/addon import export #701

Merged
merged 12 commits into from
Aug 1, 2021
Merged

Conversation

tarkah
Copy link
Member

@tarkah tarkah commented Jul 24, 2021

Resolves: #659

Initial commit, this only adds the proposed data structure for exporting and a couple functions

Checklist

  • Tested on Windows
  • Tested on MacOS
  • Tested on Linux
  • Added an entry to CHANGELOG.md if knowledge of this change could be valuable to users

@tarkah tarkah changed the base branch from master to development July 24, 2021 18:21
Comment on lines 33 to 36
pub fn export(
addons: HashMap<Flavor, Vec<Addon>>,
output_dir: impl AsRef<Path>,
) -> Result<(), error::FilesystemError> {
Copy link
Member Author

Choose a reason for hiding this comment

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

With this function, we can easily just pass a cloned map of the addons and it'll save it to the supplied path as "ajour-addons.yml"

Comment on lines 60 to 63
pub fn parse_only_needed(
existing_addons: HashMap<Flavor, Vec<Addon>>,
import_string: String,
) -> Result<HashMap<Flavor, Vec<Data>>, serde_yaml::Error> {
Copy link
Member Author

Choose a reason for hiding this comment

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

There is no "import" function because I envision us just hooking right into the existing "install" process on the gui update loop. So this just parses the file and removes collisions. The resulting output has all the data needed to hook right into what Message::Interaction(Interaction::InstallAddon does.

Copy link
Member Author

Choose a reason for hiding this comment

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

We should instead return a Parsed structure that has the hashmap, but also a field that tells how many collisions were removed so we can display this in gui

Copy link
Member Author

Choose a reason for hiding this comment

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

I've added the Parsed structure in latest commit

@tarkah
Copy link
Member Author

tarkah commented Jul 24, 2021

I think we change the output_dir of export to be a full file path that the user selects via natve-dialog

@tarkah
Copy link
Member Author

tarkah commented Jul 25, 2021

@casperstorm Import / export buttons are hooked up and work great! As a phase 2, it'd be nice to have a "Confirmation" screen with the parsed addons prior to installing, where we can display how many collisions were removed and even allow "deselecting" addons.

@tarkah
Copy link
Member Author

tarkah commented Jul 25, 2021

Another cool idea would be to add the export file to backups!

@tarkah
Copy link
Member Author

tarkah commented Jul 25, 2021

Also, we need to build out the CLI command for this functionality.

@tarkah tarkah requested a review from casperstorm July 25, 2021 23:19
@casperstorm
Copy link
Member

casperstorm commented Jul 26, 2021

Code looks great @tarkah.
However, the updated native-dialog crashes on macOS:

fatal runtime error: Rust cannot catch foreign exceptions
[1]    39509 abort      cargo run

Running cargo run --example tour from https://github.com/balthild/native-dialog-rs/ works just fine so my guess it has something to do with our async scheduled functions.

Update from the repo:

Why the program crashed when opening a dialog on macOS?
The UI framework of macOS (Cocoa) has a limitation that all UI operations must be performed on the main thread.

https://github.com/balthild/native-dialog-rs/#why-the-program-crashed-when-opening-a-dialog-on-macos

Base automatically changed from development to master July 26, 2021 10:58
@casperstorm
Copy link
Member

This LGTM for a first iteration. After merge to master we update all translations.

@tarkah tarkah changed the base branch from master to development August 1, 2021 15:11
@tarkah tarkah marked this pull request as ready for review August 1, 2021 15:16
@tarkah tarkah force-pushed the feature/addon-import-export branch from cb6abca to b316e4b Compare August 1, 2021 15:18
@tarkah tarkah merged commit 0768505 into development Aug 1, 2021
@tarkah tarkah deleted the feature/addon-import-export branch August 1, 2021 15:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Exporting "My Library" as YML, and importing on another computer
2 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载