Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
4c985cf
add icons and workspace selection ui
uclaros Sep 15, 2022
0c9f0a1
refactor data items
uclaros Sep 15, 2022
ef78155
properly handle workspace switching
uclaros Sep 19, 2022
fa952eb
hande root item name
uclaros Sep 19, 2022
0b048d4
change dialog icon
uclaros Sep 19, 2022
559ddd0
remove browser_data_items file
uclaros Sep 19, 2022
607eadf
remove workspace from project's displayed name
uclaros Sep 19, 2022
d601613
black
uclaros Sep 20, 2022
bb20b14
handle case of no workspace
uclaros Sep 20, 2022
ff959fe
fix refreshing root item
uclaros Sep 20, 2022
7181290
Change switch workspace icon.
uclaros Sep 20, 2022
be1f044
Filter workspaces dialog
uclaros Sep 20, 2022
0d53dd1
always store last workspace as string on settings
uclaros Sep 20, 2022
a6bdac7
fix fetch more
uclaros Sep 21, 2022
7dcb1f3
properly refresh if MerginRootItem is empty
uclaros Sep 21, 2022
bccb839
move root/group item renaming
uclaros Sep 21, 2022
538d05c
handle project cloning
uclaros Sep 21, 2022
ae9f939
handle cloning CE server projects
uclaros Sep 28, 2022
1c93496
fix cloning in user namespace in old server
uclaros Sep 28, 2022
fa6962d
add warning message to clone dialog
uclaros Sep 29, 2022
121dee9
black
uclaros Oct 10, 2022
c8b9f75
depopulate groups when user changes
uclaros Oct 19, 2022
8b4cf4e
also handle project creation
uclaros Oct 25, 2022
c827f2f
remove find/explore code
uclaros Oct 25, 2022
ef64fa5
cleanup
uclaros Oct 26, 2022
853e510
better handling of no workspaces
uclaros Oct 26, 2022
8235ea3
properly recall previously used workspace
uclaros Oct 26, 2022
4ab261d
change icon and title
uclaros Nov 2, 2022
611c85f
use label link to /workspaces and button to select workspace
uclaros Nov 2, 2022
7d74f8a
link to /workspaces when there are no workspaces
uclaros Nov 2, 2022
a2c460e
use workspace item delegate, store last used workspace id
uclaros Nov 2, 2022
ddda3ba
Fix workspace writeability logic and add some docstrings
uclaros Nov 3, 2022
24ea7d6
replace str.removesuffix
uclaros Nov 3, 2022
b787aab
error message when no permissions to clone/create project in workspace
uclaros Nov 3, 2022
66c5261
disable select workspace button when none selected
uclaros Nov 3, 2022
a01daea
fix reusing last used workspace
uclaros Nov 4, 2022
9edd974
adapt to api change
uclaros Nov 9, 2022
c84c991
docstrings and typo
uclaros Nov 9, 2022
95e7ae2
black
uclaros Nov 9, 2022
bda1d5b
disable select workspace button by default
uclaros Nov 10, 2022
18f8815
properly elide workspace description text
uclaros Nov 10, 2022
8a03716
minor font metrics fix
uclaros Nov 10, 2022
9d40635
use enum for server type
uclaros Nov 10, 2022
aaf1bed
Update browser's root item renaming logic so it updates without needi…
uclaros Nov 10, 2022
91707c6
Revert "Update browser's root item renaming logic so it updates witho…
uclaros Nov 10, 2022
16eaf91
Properly Update browser's root item renaming logic so it updates with…
uclaros Nov 10, 2022
531975a
find project / explore public projects (#469)
uclaros Nov 10, 2022
ddf18ca
reload browser items when creating new project
uclaros Nov 10, 2022
3b36cc0
only limit fetched projects' namespace when no filter is applied
uclaros Nov 14, 2022
e1e807d
if there's no workspace, refreshing should check if on was created
uclaros Nov 14, 2022
f8bf003
old servers should not have current_workspace_name set
uclaros Nov 15, 2022
b916cab
don't filter by workspace name when not visible
uclaros Nov 15, 2022
2204f10
update wording when syncing non writable project
uclaros Nov 16, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 47 additions & 8 deletions Mergin/clone_project_dialog.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,68 @@
import os
from qgis.PyQt.QtWidgets import QDialog, QDialogButtonBox, QFileDialog, QApplication, QMessageBox

from qgis.PyQt.QtWidgets import QDialog, QDialogButtonBox, QFileDialog, QApplication, QMessageBox, QComboBox
from qgis.PyQt.QtCore import Qt
from qgis.PyQt import uic

ui_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), "ui", "ui_clone_project.ui")


class CloneProjectDialog(QDialog):
def __init__(self, username, user_organisations=None):
"""Dialog for cloning remote projects. Allows selection of workspace/namespace and project name"""

def __init__(self, user_info, default_workspace=None):
"""Create a dialog for cloning remote projects

:param user_info: The user_info dictionary as returned from server
:param default_workspace: Optionally, the name of the current workspace so it can be pre-selected in the list
"""
QDialog.__init__(self)
self.ui = uic.loadUi(ui_file, self)
self.ui.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
self.ui.buttonBox.accepted.connect(self.accept_dialog)
self.ui.projectNamespace.addItem(username)
if user_organisations:
self.ui.projectNamespace.addItems(
[o for o in user_organisations if user_organisations[o] in ["admin", "owner"]]
)

workspaces = user_info.get("workspaces", None)
if workspaces is not None:
for ws in workspaces:
is_writable = ws.get("role", "owner") in ["owner", "admin", "writer"]
self.ui.projectNamespace.addItem(ws["name"], is_writable)

else:
# This means server is old and uses namespaces
self.ui.projectNamespaceLabel.setText("Owner")
username = user_info["username"]
user_organisations = user_info.get("organisations", [])
self.ui.projectNamespace.addItem(username, True)
for o in user_organisations:
if user_organisations[o] in ["owner", "admin", "writer"]:
self.ui.projectNamespace.addItem(o, True)

self.ui.projectNamespace.currentTextChanged.connect(self.workspace_changed)
self.ui.edit_project_name.textChanged.connect(self.text_changed)

# disable widgets if default workspace is read only
self.workspace_changed()
self.ui.projectNamespace.setCurrentText(default_workspace)

# these are the variables used by the caller
self.project_name = None
self.project_namespace = None

def text_changed(self):
self.ui.buttonBox.button(QDialogButtonBox.Ok).setEnabled(bool(self.ui.edit_project_name.text()))
enabled = bool(self.ui.edit_project_name.text()) and not self.ui.warningMessageLabel.isVisible()
self.ui.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enabled)

def workspace_changed(self):
is_writable = bool(self.ui.projectNamespace.currentData(Qt.UserRole))
if is_writable:
msg = ""
else:
msg = "You do not have permissions to create a project in this workspace!"
self.ui.edit_project_name.setToolTip(msg)
self.ui.buttonBox.button(QDialogButtonBox.Ok).setToolTip(msg)
self.ui.warningMessageLabel.setVisible(not is_writable)
self.ui.warningMessageLabel.setText(msg)
self.ui.buttonBox.button(QDialogButtonBox.Ok).setEnabled(is_writable and bool(self.ui.edit_project_name.text()))

def accept_dialog(self):
self.project_name = self.ui.edit_project_name.text()
Expand Down
40 changes: 32 additions & 8 deletions Mergin/create_project_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def __init__(self, parent=None):
self.path_ledit.setReadOnly(True)
self.path_ledit.textChanged.connect(self.check_input)
self.project_name_ledit.textChanged.connect(self.check_input)
self.project_owner_cbo.currentTextChanged.connect(self.check_input)

def nextId(self):
return -1
Expand All @@ -112,11 +113,22 @@ def initializePage(self):
self.for_current_proj = False

def populate_namespace_cbo(self):
self.project_owner_cbo.addItem(self.parent.username)
if self.parent.user_organisations:
self.project_owner_cbo.addItems(
[o for o in self.parent.user_organisations if self.parent.user_organisations[o] in ["admin", "owner"]]
)
if self.parent.workspaces is not None:
for ws in self.parent.workspaces:
is_writable = ws.get("role", "owner") in ["owner", "admin", "writer"]
self.project_owner_cbo.addItem(ws["name"], is_writable)

else:
# This means server is old and uses namespaces
self.projectNamespaceLabel.setText("Owner")
username = self.parent.user_info["username"]
user_organisations = self.parent.user_info.get("organisations", [])
self.project_owner_cbo.addItem(username, True)
for o in user_organisations:
if user_organisations[o] in ["owner", "admin", "writer"]:
self.project_owner_cbo.addItem(o, True)

self.project_owner_cbo.setCurrentText(self.parent.default_workspace)

def setup_browsing(self, question=None, current_proj=False, field=None):
"""This will setup label and signals for browse button."""
Expand Down Expand Up @@ -158,6 +170,9 @@ def set_info(self, info=None):
def check_input(self):
"""Check if entered path is not already a Mergin Maps project dir and has at most a single QGIS project file."""
# TODO: check if the project exists on the server
if not self.project_owner_cbo.currentData(Qt.UserRole):
self.create_warning("You do not have permissions to create a project in this workspace!")
return
proj_name = self.project_name_ledit.text()
if not proj_name:
self.create_warning("Project name missing!")
Expand Down Expand Up @@ -393,16 +408,25 @@ def nextId(self):
class NewMerginProjectWizard(QWizard):
"""Wizard for creating new Mergin Maps project."""

def __init__(self, project_manager, username, user_organisations=None, parent=None):
def __init__(self, project_manager, user_info, default_workspace=None, parent=None):
"""Create a wizard for new Mergin Maps project

:param project_manager: MerginProjectsManager instance
:param user_info: The user_info dictionary as returned from server
:param default_workspace: Optionally, the name of the current workspace so it can be pre-selected in the list
"""
super().__init__(parent)
self.iface = iface
self.settings = QSettings()
self.setWindowTitle("Create new Mergin Maps project")
self.setWizardStyle(QWizard.ClassicStyle)
self.setDefaultProperty("QComboBox", "currentText", QComboBox.currentTextChanged)
self.project_manager = project_manager
self.username = username
self.user_organisations = user_organisations
self.username = user_info["username"]
self.user_organisations = user_info.get("organisations", [])
self.workspaces = user_info.get("workspaces", None)
self.default_workspace = default_workspace
self.user_info = user_info

self.init_page = InitPage(self)
self.setPage(INIT_PAGE, self.init_page)
Expand Down
7 changes: 7 additions & 0 deletions Mergin/images/default/tabler_icons/explore.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions Mergin/images/default/tabler_icons/replace.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions Mergin/images/default/tabler_icons/search.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading