vorta
vorta copied to clipboard
Launch `Add new repository` when `Add existing repository` fails/is not initialized.
Description
The Add new window window will automatically pop up when an existing repository fails/is not initialized.
#1799
Motivation and Context
This will reduce confusion in adding new and adding existing repositories. Will fill some entries automatically when the add new repository window is opened through this route.
How Has This Been Tested?
Types of changes
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [x] Breaking change (fix or feature that would cause existing functionality to change)
Checklist:
- [x] I have read the CONTRIBUTING guide.
- [x] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed.
I provide my contribution under the terms of the license of this repository and I affirm the Developer Certificate of Origin.
This PR is not complete yet. The problems I'm facing right now are:
- When the
add newwindow comes up through this route, the entries are filled, but when clicked onAdd, the URL appears to be invalid. You have to reselect the repo (which is to be initialized) - Even if added, the window appears to have no
current_profile.id(src/vorta/store/models.py/BackupProfileMixin)
return BackupProfileModel.get(id=self.window().current_profile.id)
I was wondering why this is happening?
- When the
add newwindow comes up through this route, the entries are filled, but when clicked onAdd, the URL appears to be invalid. You have to reselect the repo (which is to be initialized)
This due to the is_remote_repo attribute. It is checked here:
https://github.com/borgbase/vorta/blob/55ede38e5d7a088f7d38f8f30d3ab2ee2d437280/src/vorta/views/repo_add_dialog.py#L105-L107
When using the file selector it is set to False:
https://github.com/borgbase/vorta/blob/55ede38e5d7a088f7d38f8f30d3ab2ee2d437280/src/vorta/views/repo_add_dialog.py#L72
You already did very well implementing this although I would suggest a little bit of restructuring.
1. Implement a `from_values` method for the repo winows. 2. Use a `QMessageBox` to inform the user about the failure and ask them whether they want to create a new repository instead. 3. When the user confirms, call a method on `RepoTab` that opens `AddRepoWindow` using the `from_values` method.This will make the user experience more clear and the code more modular.
I've added the QMessageBox. I don't quite understand what you mean by the from_values method of RepoTab.
I've also tried launching the AddRepoWindow by using the new_repo() method of RepoTab, but the problem I faced was that importing RepoTab was giving this error:
from vorta.views.repo_tab import RepoTab
ImportError: cannot import name 'RepoTab' from partially initialized module 'vorta.views.repo_tab' (most likely due to a circular import) (/home/sam/Codes/vorta/src/vorta/views/repo_tab.py)
You already did very well implementing this although I would suggest a little bit of restructuring.
1. Implement a `from_values` method for the repo winows. 2. Use a `QMessageBox` to inform the user about the failure and ask them whether they want to create a new repository instead. 3. When the user confirms, call a method on `RepoTab` that opens `AddRepoWindow` using the `from_values` method.This will make the user experience more clear and the code more modular.
I've added the
QMessageBox. I don't quite understand what you mean by thefrom_valuesmethod ofRepoTab. I've also tried launching theAddRepoWindowby using thenew_repo()method ofRepoTab, but the problem I faced was that importingRepoTabwas giving this error:from vorta.views.repo_tab import RepoTab ImportError: cannot import name 'RepoTab' from partially initialized module 'vorta.views.repo_tab' (most likely due to a circular import) (/home/sam/Codes/vorta/src/vorta/views/repo_tab.py)
If you only import vorta.views.repo_tab and reference the class later through repo_tab.RepoTab it works. However you shouldn't need to use the RepoTab class inside repo_add_dialog.py.
The add dialogs already have a values method returning all relevant data entered in the dialog. It would make sense to add a (possibly static) from_values method expecting those values. The from_values method would then initialize the dialog with the values provided.
@real-yfprojects I've implemented the setting of values from the values method. However, for some reason, the repo addition is still failing for some reason.
Its just saying Unable to add your repository. Just have to fix this now.
@real-yfprojects I've made the necessary changes.
wow, that simplifies a lot of things, the 'confirm password' field is not auto-filled. And, the repo is still unable to be added for some reason.
the 'confirm password' field is not auto-filled
I implemented that on purpose.
he repo is still unable to be added for some reason
You are right. Fixed that in the following commit.
Looks like all macOS tests are timing out on Github today. Likely unrelated to this PR, seeing it elsewhere too.
@m3nu ping
This is what I get when adding an empty repo as existing repo. There is no change in dialog.
This is what I get when adding an empty repo as existing repo. There is no change in dialog.
@m3nu Works fine on mine. When you try to add an empty directory which is not a repository already. It will simply ask you to make it into one. Maybe, you're not running the same branch issue1799.
Here's a video:
https://github.com/borgbase/vorta/assets/71956678/33658788-bb2b-455e-92fb-45ce8bb232ce
I tried with a remote repo. Maybe that's the reason?
Should it also work for an empty remote repo?
I tried with a remote repo. Maybe that's the reason?
Should it also work for an empty remote repo?
that's odd, the from_values function should deal with (empty) remote repos too. Lemme check once again, will fix this behavior soon
@m3nu Can you check again?