Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support deletion of multiple sources #2252

Merged
merged 5 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
6 changes: 3 additions & 3 deletions client/securedrop_client/gui/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def __init__(
source: Source,
parent: QMenu,
controller: Controller,
confirmation_dialog: Callable[[set[Source]], QDialog],
confirmation_dialog: Callable[[list[Source]], QDialog],
) -> None:
self.source = source
self.controller = controller
Expand All @@ -91,9 +91,9 @@ def __init__(

# DeleteSource Dialog can accept more than one source (bulk delete),
# but when triggered from this menu, only applies to one source
self._confirmation_dialog = confirmation_dialog(set([self.source]))
self._confirmation_dialog = confirmation_dialog([self.source])
self._confirmation_dialog.accepted.connect(
lambda: self.controller.delete_source(self.source)
lambda: self.controller.delete_sources([self.source])
)
self.triggered.connect(self.trigger)

Expand Down
9 changes: 9 additions & 0 deletions client/securedrop_client/gui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def __init__(
self.main_pane.setLayout(layout)
self.left_pane = LeftPane()
self.main_view = MainView(self.main_pane, app_state)
rocodes marked this conversation as resolved.
Show resolved Hide resolved

layout.addWidget(self.left_pane)
layout.addWidget(self.main_view)

Expand Down Expand Up @@ -107,6 +108,12 @@ def setup(self, controller: Controller) -> None:
self.bottom_pane.setup(self.controller)
self.left_pane.setup(self, self.controller)
self.main_view.setup(self.controller)

# Listen for changes to the selected sources in sourcelist
self.main_view.source_list.selected_sources.connect(
self.controller.on_receive_selected_sources
)

self.show_login()

def show_main_window(self, db_user: User | None = None) -> None:
Expand Down Expand Up @@ -184,13 +191,15 @@ def set_logged_in_as(self, db_user: User) -> None:
"""
self.left_pane.set_logged_in_as(db_user)
self.bottom_pane.set_logged_in()
self.main_view.set_logged_in()

def logout(self) -> None:
"""
Update the UI to show the user is logged out.
"""
self.left_pane.set_logged_out()
self.bottom_pane.set_logged_out()
self.main_view.set_logged_out()

def update_sync_status(self, message: str, duration: int = 0) -> None:
"""
Expand Down
6 changes: 3 additions & 3 deletions client/securedrop_client/gui/source/delete/dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
class DeleteSourceDialog(ModalDialog):
"""Used to confirm deletion of source accounts."""

def __init__(self, sources: set[Source]) -> None:
def __init__(self, sources: list[Source]) -> None:
super().__init__(show_header=False, dangerous=True)
self.sources = sources

Expand All @@ -50,7 +50,7 @@ def __init__(self, sources: set[Source]) -> None:
self.confirmation_label.setText(_("Are you sure this is what you want?"))
self.adjustSize()

def make_body_text(self, sources: set[Source]) -> str:
def make_body_text(self, sources: list[Source]) -> str:
message_tuple = (
"<p>",
_("Delete entire account for: {source_or_sources}?"),
Expand All @@ -74,7 +74,7 @@ def make_body_text(self, sources: set[Source]) -> str:
source_or_sources=f"<b>{self._get_source_names(sources)}</b>"
)

def _get_source_names(self, sources: set[Source]) -> str:
def _get_source_names(self, sources: list[Source]) -> str:
"""
Helper. Return a comma-separated list of journalist designations.
"""
Expand Down
Loading