diff --git a/docs/changes/5.5.0.md b/docs/changes/5.5.0.md index eac32e4330..b602581321 100644 --- a/docs/changes/5.5.0.md +++ b/docs/changes/5.5.0.md @@ -5,6 +5,7 @@ Release date: `2024-xx-xx` ## Core - [NXDRIVE-2882](https://jira.nuxeo.com/browse/NXDRIVE-2882): fix_db should create dump.sql in same dir as db +- [NXDRIVE-2912](https://jira.nuxeo.com/browse/NXDRIVE-2912): Display Drive notification for document review - [NXDRIVE-2](https://jira.nuxeo.com/browse/NXDRIVE-2): ### Direct Edit diff --git a/nxdrive/data/qml/Main.qml b/nxdrive/data/qml/Main.qml index f9cf4c3afb..2e8c2a1b67 100644 --- a/nxdrive/data/qml/Main.qml +++ b/nxdrive/data/qml/Main.qml @@ -34,11 +34,11 @@ QtObject { signal appUpdate(string version) signal getLastFiles(string uid) - signal setStatus(string sync, string error, string update) + signal setStatus(string sync, string error, string update, string tasks) signal updateAvailable() signal updateProgress(int progress) - onSetStatus: systray.setStatus(sync, error, update) + onSetStatus: systray.setStatus(sync, error, update, tasks) onUpdateAvailable: systray.updateAvailable() onUpdateProgress: systray.updateProgress(progress) diff --git a/nxdrive/data/qml/Systray.qml b/nxdrive/data/qml/Systray.qml index c1907455cf..897ddacd62 100755 --- a/nxdrive/data/qml/Systray.qml +++ b/nxdrive/data/qml/Systray.qml @@ -17,7 +17,7 @@ Rectangle { signal appUpdate(string version) signal getLastFiles(string uid) - signal setStatus(string sync, string error, string update) + signal setStatus(string sync, string error, string update, string tasks) signal updateAvailable() signal updateProgress(int progress) @@ -73,6 +73,9 @@ Rectangle { syncState.state = sync errorState.state = error updateState.state = update + if (tasks == "tasks_available") { + taskState.visible = true + } // Force the counts update at the end of the sync if (sync == "") { @@ -379,9 +382,9 @@ Rectangle { // Pending Tasks SystrayStatus { - id: pendingTasks + id: taskState state: "pending_tasks" - visible: (state == "pending_tasks") + visible: false color: progressFilledLight textColor: lightTheme icon: MdiFont.Icon.bell @@ -390,9 +393,9 @@ Rectangle { State { name: "pending_tasks" PropertyChanges { - target: updateState - text: qsTr("PENDING_DOCUMENT_REVIEWS").arg(api.fetch_pending_tasks(accountSelect.getRole("uid"))) + tl.tr - // onClicked: updatePopup.open() + target: taskState + text: qsTr("PENDING_DOCUMENT_REVIEWS").arg(api.tasks_remaining(accountSelect.getRole("uid"))) + tl.tr + onClicked: api.open_tasks_window(accountSelect.getRole("uid")) } } ] diff --git a/nxdrive/gui/api.py b/nxdrive/gui/api.py index c445a527e9..6b0cfefa50 100644 --- a/nxdrive/gui/api.py +++ b/nxdrive/gui/api.py @@ -237,13 +237,19 @@ def get_completed_sessions_count(self, uid: str, /) -> int: return 0 @pyqtSlot(str, result=int) - def fetch_pending_tasks(self, uid: str, /) -> str: + def tasks_remaining(self, uid: str, /) -> int: """Return pending tasks count for Drive notification.""" - """engine = self._manager.engines.get(uid) + engine = self._manager.engines.get(uid) if engine: - workflow = self.application.workflow - workflow.get_pending_tasks(uid, engine)""" - return 2 + tasks = self.application.fetch_pending_tasks(engine) + return len(tasks) + log.info("Engine not vailable") + return + + @pyqtSlot(str) + def open_tasks_window(self, uid: str, /) -> None: + self.application.hide_systray() + print(f">>>>>> opening task window [engine_id: {uid!r}]") @pyqtSlot(str, str, int, float, bool) def pause_transfer( diff --git a/nxdrive/gui/application.py b/nxdrive/gui/application.py index 39d91da1a3..2c73f199af 100644 --- a/nxdrive/gui/application.py +++ b/nxdrive/gui/application.py @@ -1828,6 +1828,12 @@ def ctx_direct_transfer(self, path: Path, /) -> None: else: self.show_server_folders(engine, path) + def fetch_pending_tasks(self, engine: Engine, /) -> list: + remote = engine.remote + user = {"userId": remote.user_id} + tasks = remote.tasks.get(user) + return tasks + def update_status(self, engine: Engine, /) -> None: """ Update the systray status for synchronization, @@ -1841,6 +1847,12 @@ def update_status(self, engine: Engine, /) -> None: update_state = self.manager.updater.status + tasks = self.fetch_pending_tasks(engine) + task_state = "no_tasks_available" + if len(tasks) > 0: + task_state = "tasks_available" + # task_state = "no_tasks_available" + # Check synchronization state if self.manager.restart_needed: sync_state = "restart" @@ -1860,8 +1872,10 @@ def update_status(self, engine: Engine, /) -> None: elif self.errors_model.count: error_state = "error" + print(f">>>>>> task_state{task_state!r}") + self._window_root(self.systray_window).setStatus.emit( - sync_state, error_state, update_state + sync_state, error_state, update_state, task_state ) @pyqtSlot(object)