vorta icon indicating copy to clipboard operation
vorta copied to clipboard

Launch `Add new repository` when `Add existing repository` fails/is not initialized.

Open SAMAD101 opened this issue 2 years ago • 15 comments
trafficstars

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.

SAMAD101 avatar Sep 09 '23 13:09 SAMAD101

This PR is not complete yet. The problems I'm facing right now are:

  • When the add new window comes up through this route, the entries are filled, but when clicked on Add, 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?

SAMAD101 avatar Sep 09 '23 13:09 SAMAD101

  • When the add new window comes up through this route, the entries are filled, but when clicked on Add, 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

real-yfprojects avatar Sep 12 '23 09:09 real-yfprojects

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)

SAMAD101 avatar Sep 12 '23 18:09 SAMAD101

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)

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 avatar Sep 14 '23 09:09 real-yfprojects

@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.

SAMAD101 avatar Sep 15 '23 13:09 SAMAD101

@real-yfprojects I've made the necessary changes.

SAMAD101 avatar Sep 19 '23 12:09 SAMAD101

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.

SAMAD101 avatar Oct 20 '23 17:10 SAMAD101

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.

real-yfprojects avatar Oct 20 '23 17:10 real-yfprojects

Looks like all macOS tests are timing out on Github today. Likely unrelated to this PR, seeing it elsewhere too.

m3nu avatar Oct 20 '23 19:10 m3nu

@m3nu ping

real-yfprojects avatar Nov 23 '23 20:11 real-yfprojects

This is what I get when adding an empty repo as existing repo. There is no change in dialog.

Screenshot 2024-01-10 at 11 19 49

m3nu avatar Jan 10 '24 11:01 m3nu

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

SAMAD101 avatar Jan 11 '24 11:01 SAMAD101

I tried with a remote repo. Maybe that's the reason?

Should it also work for an empty remote repo?

m3nu avatar Jan 11 '24 11:01 m3nu

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

SAMAD101 avatar Jan 12 '24 06:01 SAMAD101

@m3nu Can you check again?

real-yfprojects avatar Apr 01 '24 13:04 real-yfprojects